r14758 by fschmid - Replaced the "placeSVG", "placeEPS" etc.. commands with the more general "placeVectorFile". This new command has the same syntax as the old ones. Scripts written with the old commands will still run as the old commands are mapped to the new one.

scribus-commit scribus-commit at lists.scribus.net
Thu Feb 18 10:50:28 CET 2010


Revision: 14758
Author: fschmid
Date: 2010-02-18T09:42:59.188341Z
Commit message: Replaced the "placeSVG", "placeEPS" etc.. commands with the more general "placeVectorFile". This new command has the same syntax as the old ones. Scripts written with the old commands will still run as the old commands are mapped to the new one.

Changeset: 
M  /trunk/Scribus/scribus/plugins/scriptplugin/svgimport.cpp
M  /trunk/Scribus/scribus/plugins/scriptplugin/svgimport.h
M  /trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Diffs:
Index: scribus/plugins/scriptplugin/svgimport.h
===================================================================
--- scribus/plugins/scriptplugin/svgimport.h	(revision 14757)
+++ scribus/plugins/scriptplugin/svgimport.h	(revision 14758)
@@ -11,6 +11,18 @@
 #include "cmdvar.h"
 
 /*! docstring */
+PyDoc_STRVAR(scribus_placevec__doc__,
+QT_TR_NOOP("placeVectorFile(\"filename\", x, y)\n\
+\n\
+Places the Vectorgrapics \"filename\" onto the current page,\n\
+x and y specify the coordinate of the topleft corner of the graphic placed on the page\n\
+\n\
+If loading was successful, the selection contains the imported grapic\n\
+"));
+/*! Places a Vector file. */
+PyObject *scribus_placevec(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_placesvg__doc__,
 QT_TR_NOOP("placeSVG(\"filename\", x, y)\n\
 \n\
@@ -20,7 +32,7 @@
 If loading was successful, the selection contains the imported SVG\n\
 "));
 /*! Places an SVG file. */
-PyObject *scribus_placesvg(PyObject * /*self*/, PyObject* args);
+//PyObject *scribus_placesvg(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
 PyDoc_STRVAR(scribus_placeeps__doc__,
@@ -32,7 +44,7 @@
 If loading was successful, the selection contains the imported EPS\n\
 "));
 /*! Places an EPS file. */
-PyObject *scribus_placeeps(PyObject * /*self*/, PyObject* args);
+//PyObject *scribus_placeeps(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
 PyDoc_STRVAR(scribus_placesxd__doc__,
@@ -44,7 +56,7 @@
 If loading was successful, the selection contains the imported SXD\n\
 "));
 /*! Places an SXD file. */
-PyObject *scribus_placesxd(PyObject * /*self*/, PyObject* args);
+//PyObject *scribus_placesxd(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
 PyDoc_STRVAR(scribus_placeodg__doc__,
@@ -56,6 +68,6 @@
 If loading was successful, the selection contains the imported ODG\n\
 "));
 /*! Places an ODG file. */
-PyObject *scribus_placeodg(PyObject * /*self*/, PyObject* args);
+//PyObject *scribus_placeodg(PyObject * /*self*/, PyObject* args);
 
 #endif
Index: scribus/plugins/scriptplugin/scriptplugin.cpp
===================================================================
--- scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14757)
+++ scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14758)
@@ -382,10 +382,11 @@
 	{const_cast<char*>("gotoPage"), scribus_gotopage, METH_VARARGS, tr(scribus_gotopage__doc__)},
 	{const_cast<char*>("groupObjects"), (PyCFunction)scribus_groupobj, METH_VARARGS, tr(scribus_groupobj__doc__)},
 	{const_cast<char*>("haveDoc"), (PyCFunction)scribus_havedoc, METH_NOARGS, tr(scribus_havedoc__doc__)},
-	{const_cast<char*>("placeSVG"), scribus_placesvg, METH_VARARGS, tr(scribus_placesvg__doc__)},
-	{const_cast<char*>("placeEPS"), scribus_placeeps, METH_VARARGS, tr(scribus_placeeps__doc__)},
-	{const_cast<char*>("placeSXD"), scribus_placesxd, METH_VARARGS, tr(scribus_placesxd__doc__)},
-	{const_cast<char*>("placeODG"), scribus_placeodg, METH_VARARGS, tr(scribus_placeodg__doc__)},
+	{const_cast<char*>("placeVectorFile"), scribus_placevec, METH_VARARGS, tr(scribus_placevec__doc__)},
+	{const_cast<char*>("placeSVG"), scribus_placevec, METH_VARARGS, tr(scribus_placesvg__doc__)},
+	{const_cast<char*>("placeEPS"), scribus_placevec, METH_VARARGS, tr(scribus_placeeps__doc__)},
+	{const_cast<char*>("placeSXD"), scribus_placevec, METH_VARARGS, tr(scribus_placesxd__doc__)},
+	{const_cast<char*>("placeODG"), scribus_placevec, METH_VARARGS, tr(scribus_placeodg__doc__)},
 	{const_cast<char*>("insertText"), scribus_inserttext, METH_VARARGS, tr(scribus_inserttext__doc__)},
 	{const_cast<char*>("isLayerPrintable"), scribus_glayerprint, METH_VARARGS, tr(scribus_glayerprint__doc__)},
 	{const_cast<char*>("isLayerVisible"), scribus_glayervisib, METH_VARARGS, tr(scribus_glayervisib__doc__)},
Index: scribus/plugins/scriptplugin/svgimport.cpp
===================================================================
--- scribus/plugins/scriptplugin/svgimport.cpp	(revision 14757)
+++ scribus/plugins/scriptplugin/svgimport.cpp	(revision 14758)
@@ -10,6 +10,7 @@
 
 // We need svgpluginid.h for the SVG format ID, and
 // loadsaveplugin.h for the FileFormat interface.
+#include "fileloader.h"
 #include "../formatidlist.h"
 #include "loadsaveplugin.h"
 #include "scribuscore.h"
@@ -18,6 +19,54 @@
 
 #include <QString>
 
+PyObject *scribus_placevec(PyObject* /* self */, PyObject* args)
+{
+	char *Image;
+	double x = 0.0;
+	double y = 0.0;
+	if (!PyArg_ParseTuple(args, "es|dd", "utf-8", &Image, &x, &y))
+		return NULL;
+	if(!checkHaveDocument())
+		return NULL;
+	QStringList allFormatsV = LoadSavePlugin::getExtensionsForImport(FORMATID_ODGIMPORT);
+	QString fName = QString::fromUtf8(Image);
+	QFileInfo fi = QFileInfo(fName);
+	QString ext = fi.suffix().toLower();
+	if (!allFormatsV.contains(ext))
+		return NULL;
+	FileLoader *fileLoader = new FileLoader(fName);
+	int testResult = fileLoader->TestFile();
+	delete fileLoader;
+	if ((testResult != -1) && (testResult >= FORMATID_ODGIMPORT))
+	{
+		const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
+		if( fmt )
+		{
+			fmt->loadFile(fName, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
+			if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
+			{
+				double x2, y2, w, h;
+				ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
+				ScCore->primaryMainWindow()->view->startGroupTransaction();
+				ScCore->primaryMainWindow()->doc->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
+				ScCore->primaryMainWindow()->view->endGroupTransaction();
+				ScCore->primaryMainWindow()->propertiesPalette->updateColorList();
+				ScCore->primaryMainWindow()->propertiesPalette->paraStyleCombo->updateFormatList();
+				ScCore->primaryMainWindow()->propertiesPalette->charStyleCombo->updateFormatList();
+				ScCore->primaryMainWindow()->propertiesPalette->SetLineFormats(ScCore->primaryMainWindow()->doc);
+			}
+		}
+	}
+	else
+	{
+		PyErr_SetString(PyExc_Exception, "Requested Import plugin not available");
+		return NULL;
+	}
+//	Py_INCREF(Py_None);
+//	return Py_None;
+	Py_RETURN_NONE;
+}
+#if 0
 PyObject *scribus_placesvg(PyObject* /* self */, PyObject* args)
 {
 	char *Image;
@@ -161,6 +210,7 @@
 //	return Py_None;
 	Py_RETURN_NONE;
 }
+#endif
 
 /*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
 with header files structure untouched (docstrings are kept near declarations)
@@ -168,5 +218,5 @@
 void svgimportdocwarnings()
 {
     QStringList s;
-    s << scribus_placesvg__doc__ << scribus_placeeps__doc__ << scribus_placesxd__doc__ << scribus_placeodg__doc__;
+    s << scribus_placevec__doc__ << scribus_placesvg__doc__ << scribus_placeeps__doc__ << scribus_placesxd__doc__ << scribus_placeodg__doc__;
 }




More information about the scribus-commit mailing list