Back to index

scribus-ng  1.3.4.dfsg+svn20071115
svgimport.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "svgimport.h"
00008 #include "cmdvar.h"
00009 #include "cmdutil.h"
00010 
00011 // We need svgpluginid.h for the SVG format ID, and
00012 // loadsaveplugin.h for the FileFormat interface.
00013 #include "../formatidlist.h"
00014 #include "loadsaveplugin.h"
00015 #include "scribuscore.h"
00016 #include "selection.h"
00017 
00018 #include <qstring.h>
00019 
00020 PyObject *scribus_placesvg(PyObject* /* self */, PyObject* args)
00021 {
00022        char *Image;
00023        double x = 0.0;
00024        double y = 0.0;
00025        if (!PyArg_ParseTuple(args, "es|dd", "utf-8", &Image, &x, &y))
00026               return NULL;
00027        if(!checkHaveDocument())
00028               return NULL;
00029        const FileFormat * fmt = LoadSavePlugin::getFormatById(FORMATID_SVGIMPORT);
00030        if( fmt )
00031        {
00032               fmt->loadFile(QString::fromUtf8(Image), LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
00033               if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
00034               {
00035                      double x2, y2, w, h;
00036                      ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
00037                      ScCore->primaryMainWindow()->view->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
00038               }
00039        }
00040        else
00041        {
00042               PyErr_SetString(PyExc_Exception, "SVG Import plugin not available");
00043               return NULL;
00044        }
00045 //     Py_INCREF(Py_None);
00046 //     return Py_None;
00047        Py_RETURN_NONE;
00048 }
00049 
00050 PyObject *scribus_placeeps(PyObject* /* self */, PyObject* args)
00051 {
00052        char *Image;
00053        double x = 0.0;
00054        double y = 0.0;
00055        if (!PyArg_ParseTuple(args, "es|dd", "utf-8", &Image, &x, &y))
00056               return NULL;
00057        if(!checkHaveDocument())
00058               return NULL;
00059        const FileFormat * fmt = LoadSavePlugin::getFormatById(FORMATID_PSIMPORT);
00060        if( fmt )
00061        {
00062               fmt->loadFile(QString::fromUtf8(Image), LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
00063               if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
00064               {
00065                      double x2, y2, w, h;
00066                      ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
00067                      ScCore->primaryMainWindow()->view->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
00068               }
00069        }
00070        else
00071        {
00072               PyErr_SetString(PyExc_Exception, "EPS Import plugin not available");
00073               return NULL;
00074        }
00075 //     Py_INCREF(Py_None);
00076 //     return Py_None;
00077        Py_RETURN_NONE;
00078 }
00079 
00080 PyObject *scribus_placesxd(PyObject* /* self */, PyObject* args)
00081 {
00082        char *Image;
00083        double x = 0.0;
00084        double y = 0.0;
00085        if (!PyArg_ParseTuple(args, "es|dd", "utf-8", &Image, &x, &y))
00086               return NULL;
00087        if(!checkHaveDocument())
00088               return NULL;
00089        const FileFormat * fmt = LoadSavePlugin::getFormatById(FORMATID_SXDIMPORT);
00090        if( fmt )
00091        {
00092               fmt->loadFile(QString::fromUtf8(Image), LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
00093               if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
00094               {
00095                      double x2, y2, w, h;
00096                      ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
00097                      ScCore->primaryMainWindow()->view->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
00098               }
00099        }
00100        else
00101        {
00102               PyErr_SetString(PyExc_Exception, "OpenOffice Import plugin not available");
00103               return NULL;
00104        }
00105 //     Py_INCREF(Py_None);
00106 //     return Py_None;
00107        Py_RETURN_NONE;
00108 }
00109 
00110 PyObject *scribus_placeodg(PyObject* /* self */, PyObject* args)
00111 {
00112        char *Image;
00113        double x = 0.0;
00114        double y = 0.0;
00115        if (!PyArg_ParseTuple(args, "es|dd", "utf-8", &Image, &x, &y))
00116               return NULL;
00117        if(!checkHaveDocument())
00118               return NULL;
00119        const FileFormat * fmt = LoadSavePlugin::getFormatById(FORMATID_ODGIMPORT);
00120        if( fmt )
00121        {
00122               fmt->loadFile(QString::fromUtf8(Image), LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
00123               if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
00124               {
00125                      double x2, y2, w, h;
00126                      ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
00127                      ScCore->primaryMainWindow()->view->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
00128               }
00129        }
00130        else
00131        {
00132               PyErr_SetString(PyExc_Exception, "OpenOffice Import plugin not available");
00133               return NULL;
00134        }
00135 //     Py_INCREF(Py_None);
00136 //     return Py_None;
00137        Py_RETURN_NONE;
00138 }
00139 
00143 void svgimportdocwarnings()
00144 {
00145     QStringList s;
00146     s << scribus_placesvg__doc__ << scribus_placeeps__doc__ << scribus_placesxd__doc__ << scribus_placeodg__doc__;
00147 }