[Scribus] Scribus cmdline import/export (patch)
Bryce Harrington
bryce
Sun Sep 25 08:26:15 CEST 2005
Hi Peter and Craig,
A while back we discussed an idea of packaging the scribus pdf/ps
import/export code for use with Inkscape, since Inkscape's pdf/ps
(esp. EPS import) support is so poor.
However it occurs to me that another solution would be to simply give
scribus some commandline options for doing import/export. E.g.
scribus -i filename.eps -e filename.svg
Inkscape would then be able to make use of scribus' import/export
capabilities via its extension mechanism. Since for all practical
intents and purposes, people would need to use scribus for getting
eps/pdf converted to svg for use in inkscape already anyway, I don't
think this imposes much additional dependency hassle for them.
I looked into the scribus code a bit to see how this could be
implemented. I wasn't sure how to call the import/export plugins, but I
sketched out the code for handling the -i/-e commandline options as a
start... See the attached patch. I put TODO's where the code to invoke
the import/export plugins would go.
I think that if it supported command line options for your input/output
operators, scribus would become more widely useful, especially for
commercial users (look at http://www.pdftron.com/store.html).
Bryce
--- main.cpp.orig 2005-09-24 22:48:40.000000000 -0700
+++ main.cpp 2005-09-24 22:17:48.000000000 -0700
@@ -52,6 +52,8 @@
#define ARG_NOSPLASH "--no-splash"
#define ARG_NOGUI "--no-gui"
#define ARG_DISPLAY "--display"
+#define ARG_IMPORT "--import"
+#define ARG_EXPORT "--export"
#define ARG_VERSION_SHORT "-v"
#define ARG_HELP_SHORT "-h"
@@ -60,12 +62,16 @@
#define ARG_NOSPLASH_SHORT "-s"
#define ARG_NOGUI_SHORT "-g"
#define ARG_DISPLAY_SHORT "-d"
+#define ARG_IMPORT_SHORT "-i"
+#define ARG_EXPORT_SHORT "-e"
QString lang = "";
bool showSplash = true;
bool useGui = true;
QString file;
+QString import_filename = "";
+QString export_filename = "";
void showUsage();
void showAvailLangs();
@@ -102,6 +108,20 @@
lang = argv[i];
} else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) {
showSplash = false;
+ } else if ((arg == ARG_IMPORT || arg == ARG_IMPORT_SHORT) && (++i < argc)) {
+ import_filename = QFile::decodeName(argv[i]);
+ if (!QFileInfo(import_filename).exists()) {
+ std::cout << std::endl;
+ if (import_filename.left(1) == "-" || import_filename.left(2) == "--") {
+ std::cout << "Invalid argument: " << import_filename << std::endl;
+ } else {
+ std::cout << "File " << import_filename << "does not exist, aborting." << std::endl;
+ }
+ showUsage();
+ return 0;
+ }
+ } else if ((arg == ARG_EXPORT || arg == ARG_EXPORT_SHORT) && (++i < argc)) {
+ export_filename = QFile::decodeName(argv[i]);
} else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) {
useGui = false;
} else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT) && ++i < argc) {
@@ -123,7 +143,8 @@
}
if (useGui)
- return mainGui(argc, argv);
+ return mainGui(argc, argv);
+
}
/*!
@@ -145,6 +166,8 @@
std::cout << "-la, --langs-available Lists the currently installed interface languages" << std::endl;
std::cout << "-h, --help Print help (this message) and exit" << std::endl;
std::cout << "-v, --version Output version information and exit" << std::endl;
+ std::cout << "-i, --import <file> Import given filename" << std::endl;
+ std::cout << "-e, --export <file> Export given filename" << std::endl;
/*
std::cout << "-file|-- name Open file 'name'" << std::endl;
std::cout << "name Open file 'name', the file name must not begin with '-'" << std::endl;
@@ -214,10 +237,24 @@
scribus->show();
scribus->ShowSubs();
- if (file != "")
- scribus->LadeDoc(file);
+ if (file != "") {
+ scribus->LadeDoc(file);
+ } else if (import_filename != "") {
+ // TODO: Import the file...
+ }
scribus->setFocus();
- return app.exec();
+
+ if (export_filename != "") {
+ QFile f(export_filename);
+ if (f.exists()) {
+ std::cout << "Cannot overwrite existing file " << export_filename << std::endl;
+ return -1;
+ }
+ // TODO: Export the file...
+ return 0;
+ } else {
+ return app.exec();
+ }
}
/*!
More information about the scribus
mailing list