/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdgetprop.cpp |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/runscriptdialog.ui |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/runscriptdialog.ui (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/runscriptdialog.ui (nonexistent) |
@@ -1,49 +0,0 @@ |
-<?xml version="1.0" encoding="UTF-8"?> |
-<ui version="4.0"> |
- <class>RunScriptDialog</class> |
- <widget class="QDialog" name="RunScriptDialog"> |
- <property name="geometry"> |
- <rect> |
- <x>0</x> |
- <y>0</y> |
- <width>400</width> |
- <height>300</height> |
- </rect> |
- </property> |
- <property name="windowTitle"> |
- <string>Run Script</string> |
- </property> |
- <layout class="QGridLayout"> |
- <item row="0" column="0"> |
- <widget class="ScFileWidget" name="fileWidget" native="true"/> |
- </item> |
- <item row="1" column="0"> |
- <widget class="QCheckBox" name="extChk"> |
- <property name="text"> |
- <string>Run as Extension Script</string> |
- </property> |
- </widget> |
- </item> |
- <item row="2" column="0"> |
- <widget class="QDialogButtonBox" name="buttonBox"> |
- <property name="orientation"> |
- <enum>Qt::Horizontal</enum> |
- </property> |
- <property name="standardButtons"> |
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
- </property> |
- </widget> |
- </item> |
- </layout> |
- </widget> |
- <customwidgets> |
- <customwidget> |
- <class>ScFileWidget</class> |
- <extends>QWidget</extends> |
- <header>ui/scfilewidget.h</header> |
- <container>1</container> |
- </customwidget> |
- </customwidgets> |
- <resources/> |
- <connections/> |
-</ui> |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdpage.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdpage.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdpage.h (nonexistent) |
@@ -1,228 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef CMDPAGE_H |
-#define CMDPAGE_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-/** Page related Commands */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_newpage__doc__, |
-QT_TR_NOOP("newPage(where [,\"masterpage\"])\n\ |
-\n\ |
-Creates a new page. If \"where\" is -1 the new Page is appended to the\n\ |
-document, otherwise the new page is inserted before \"where\". Page numbers are\n\ |
-counted from 1 upwards, no matter what the displayed first page number of your\n\ |
-document is. The optional parameter \"masterpage\" specifies the name of the\n\ |
-master page for the new page.\n\ |
-\n\ |
-May raise IndexError if the page number is out of range\n\ |
-")); |
-/*! new page */ |
-PyObject *scribus_newpage(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_currentpage__doc__, |
-QT_TR_NOOP("currentPage() -> integer\n\ |
-\n\ |
-Returns the number of the current working page. Page numbers are counted from 1\n\ |
-upwards, no matter what the displayed first page number of your document is.\n\ |
-")); |
-/*! get actual page */ |
-PyObject *scribus_currentpage(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_redraw__doc__, |
-QT_TR_NOOP("redrawAll()\n\ |
-\n\ |
-Redraws all pages.\n\ |
-")); |
-/*! redraw all */ |
-PyObject *scribus_redraw(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getpagetype__doc__, |
-QT_TR_NOOP("getPageType() -> integer\n\ |
-\n\ |
-Returns the type of the Page, 0 means left Page, 1 is a middle Page and 2 is a right Page\n\ |
-")); |
-/*! Go to page */ |
-PyObject *scribus_getpagetype(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_savepageeps__doc__, |
-QT_TR_NOOP("savePageAsEPS(\"name\")\n\ |
-\n\ |
-Saves the current page as an EPS to the file \"name\".\n\ |
-\n\ |
-May raise ScribusError if the save failed.\n\ |
-")); |
-/*! Export page as EPS file */ |
-PyObject *scribus_savepageeps(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_deletepage__doc__, |
-QT_TR_NOOP("deletePage(nr)\n\ |
-\n\ |
-Deletes the given page. Does nothing if the document contains only one page.\n\ |
-Page numbers are counted from 1 upwards, no matter what the displayed first\n\ |
-page number is.\n\ |
-\n\ |
-May raise IndexError if the page number is out of range\n\ |
-")); |
-/*! Delete page */ |
-PyObject *scribus_deletepage(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gotopage__doc__, |
-QT_TR_NOOP("gotoPage(nr)\n\ |
-\n\ |
-Moves to the page \"nr\" (that is, makes the current page \"nr\"). Note that\n\ |
-gotoPage doesn't (currently) change the page the user's view is displaying, it\n\ |
-just sets the page that script commands will operates on.\n\ |
-\n\ |
-May raise IndexError if the page number is out of range.\n\ |
-")); |
-/*! Go to page */ |
-PyObject *scribus_gotopage(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_pagecount__doc__, |
-QT_TR_NOOP("pageCount() -> integer\n\ |
-\n\ |
-Returns the number of pages in the document.\n\ |
-")); |
-/*! Go to page */ |
-PyObject *scribus_pagecount(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getHguides__doc__, |
-QT_TR_NOOP("getHGuides() -> list\n\ |
-\n\ |
-Returns a list containing positions of the horizontal guides. Values are in the\n\ |
-document's current units - see UNIT_<type> constants.\n\ |
-")); |
-/*! get H guides */ |
-PyObject *scribus_getHguides(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setHguides__doc__, |
-QT_TR_NOOP("setHGuides(list)\n\ |
-\n\ |
-Sets horizontal guides. Input parameter must be a list of guide positions\n\ |
-measured in the current document units - see UNIT_<type> constants.\n\ |
-\n\ |
-Example: setHGuides(getHGuides() + [200.0, 210.0] # add new guides without any lost\n\ |
- setHGuides([90,250]) # replace current guides entirely\n\ |
-")); |
-/*! set H guides */ |
-PyObject *scribus_setHguides(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getVguides__doc__, |
-QT_TR_NOOP("getVGuides()\n\ |
-\n\ |
-See getHGuides.\n\ |
-")); |
-/*! get V guides */ |
-PyObject *scribus_getVguides(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setVguides__doc__, |
-QT_TR_NOOP("setVGuides()\n\ |
-\n\ |
-See setHGuides.\n\ |
-")); |
-/*! set V guides */ |
-PyObject *scribus_setVguides(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getpagesize__doc__, |
-QT_TR_NOOP("getPageSize() -> tuple\n\ |
-\n\ |
-Returns a tuple with document page dimensions measured in the document's current units.\n\ |
-See UNIT_<type> constants and getPageMargins()\n\ |
-")); |
-/** |
-returns a tuple with page dimensions in used system |
-e.g. when is the doc in picas returns picas ;) |
-(Petr Vanek 02/17/04) |
-*/ |
-PyObject *scribus_getpagesize(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getpagensize__doc__, |
-QT_TR_NOOP("getPageNSize(nr) -> tuple\n\ |
-\n\ |
-Returns a tuple with a particular page's size measured in the document's current units.\n\ |
-See UNIT_<type> constants and getPageMargins()\n\ |
-")); |
-/** |
-returns a tuple with a particular page's size in used system |
-e.g. when is the doc in picas returns picas ;) |
-*/ |
-PyObject *scribus_getpagensize(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getpagemargins__doc__, |
-QT_TR_NOOP("getPageMargins()\n\ |
-\n\ |
-Returns the document page margins as a (top, left, right, bottom) tuple in the document's current\n\ |
-units. See UNIT_<type> constants and getPageSize().\n\ |
-")); |
-/** |
-returns a tuple with page margins |
-Craig Ringer, Petr Vanek 09/25/2004 |
-*/ |
-PyObject *scribus_getpagemargins(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getpagenmargins__doc__, |
-QT_TR_NOOP("getPageNMargins(nr) -> tuple\n\ |
-\n\ |
-Returns a tuple with a particular page's margins measured in the document's current units.\n\ |
-See UNIT_<type> constants and getPageMargins()\n\ |
-")); |
-/** |
-returns a tuple with a particular page's size in used system |
-e.g. when is the doc in picas returns picas ;) |
-*/ |
-PyObject *scribus_getpagenmargins(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getpageitems__doc__, |
-QT_TR_NOOP("getPageItems() -> list\n\ |
-\n\ |
-Returns a list of tuples with items on the current page. The tuple is:\n\ |
-(name, objectType, order) E.g. [('Text1', 4, 0), ('Image1', 2, 1)]\n\ |
-means that object named 'Text1' is a text frame (type 4) and is the first at\n\ |
-the page...\n\ |
-")); |
-/** |
-returns a list of tuples with items on the actual page |
-TODO: solve utf/iso chars in object names |
-(Petr Vanek 03/02/2004) |
-*/ |
-PyObject *scribus_getpageitems(PyObject * /*self*/); |
- |
-/*! importpage */ |
-PyDoc_STRVAR(scribus_importpage__doc__, |
-QT_TR_NOOP("importPage(\"fromDoc\", (pageList), [create, imortwhere, importwherePage])\n\ |
-\n\ |
-Imports a set of pages (given as a tuple) from an existing document (the file name must be given). This functions maps the \"Page->Import\" dropdown menu function.\n\ |
-fromDoc: string; the filename of the document to import pages from\n\ |
-pageList: tuple with page numbers of pages to import\n\ |
-create: number; 0 to replace existing pages, 1 (default) to insert new pages\n\ |
-importWhere: number; the page number (of the current document) at which import the pages\n\ |
-importWherePage: number; used if create==1; 0 to create pages before selected page; 1 to create pages after selected page; 2 (default) to create pages at the end of the document\n\ |
-")); |
-PyObject *scribus_importpage(PyObject */*self*/, PyObject* args); |
- |
-#endif |
- |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdpage.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdutil.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdutil.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdutil.h (nonexistent) |
@@ -1,91 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef CMDUTIL_H |
-#define CMDUTIL_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-double PointToValue(double Val); |
-double ValueToPoint(double Val); |
- |
-/*! \brief Convert an X coordinate part in page units to a document coordinate in system units. |
-*/ |
-double pageUnitXToDocX(double pageUnitX); |
-/// \brief Doc units -> page-relative units |
-double docUnitXToPageX(double pageUnitX); |
- |
-/*! \brief Convert a Y coordinate part in page units to a document coordinate |
-in system units. The document coordinates have their origin somewhere |
-up and left of the first page, where page coordinates have their |
-origin on the top left of the current page. */ |
-double pageUnitYToDocY(double pageUnitY); |
-/// \brief Doc units -> page-relative units |
-double docUnitYToPageY(double pageUnitY); |
- |
-PageItem *GetItem(const QString& name); |
-void ReplaceColor(const QString& col, const QString& rep); |
- |
-/*! |
- * @brief Returns named PageItem, or selection if name '', or exception and NULL if no item. |
- * |
- * Returns a pointer to a PageItem by looking it up by name - page independent. |
- * If `name' is empty, returns selected item. If the named item is not found, |
- * or `name' is empty and no item is selected, sets an exception and returns |
- * NULL. |
- * |
- * @author 03/10/2004 petr vanek |
- * @author 05/02/02 Craig Ringer |
- */ |
-PageItem* GetUniqueItem(const QString& name); |
- |
-/*! |
- * @brief Returns named PageItem, or exception and NULL if not found. |
- * |
- * @author 03/10/2004 Petr Vanek |
- * @author 05/02/02 Craig Ringer |
- */ |
-PageItem* getPageItemByName(const QString& name); |
- |
-// 2004-10-27 Craig Ringer see cmdutil.cpp for description |
-bool checkHaveDocument(); |
- |
-/*! |
- * @brief Returns true if the page number is between 0 and the number of pages. |
- * |
- * If the page number is smaller than 0 or bigger than the number of pages |
- * a Python exception is set, before returning false. |
- * |
- * The caller is required to check the returned value and return nullptr on false. |
- * |
- * @author ale rimoldi |
- */ |
-bool checkValidPageNumber(int page); |
- |
-// 2004-11-12 Craig Ringer see cmdutil.cpp for description |
-bool ItemExists(const QString& name); |
- |
-/*! |
- * @brief Returns a list of the names of all selected PageItems |
- */ |
-QStringList getSelectedItemsByName(); |
- |
-/*! |
- * @brief Replaces the current selection by selecting all the items named in the passed QStringList |
- * |
- * Returns false if one or more items can't be selected, true if all were selected. |
- * Selection state is undefined on failure. |
- */ |
-bool setSelectedItemsByName(const QStringList& itemNames); |
- |
-/*! |
- * @brief Helper method to parse a border from a list of tuples. |
- */ |
-TableBorder parseBorder(PyObject* borderLines, bool* ok); |
- |
- |
-#endif |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdutil.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcolor.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcolor.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcolor.h (nonexistent) |
@@ -1,309 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef CMDCOLOR_H |
-#define CMDCOLOR_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-/** Managing Colors */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcolornames__doc__, |
-QT_TR_NOOP("getColorNames() -> list\n\ |
-\n\ |
-Returns a list containing the names of all defined colors in the document.\n\ |
-If no document is open, returns a list of the default document colors.\n\ |
-")); |
-/** Returns a list with colours available in doc or in prefs. */ |
-PyObject *scribus_getcolornames(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcolor__doc__, |
-QT_TR_NOOP("getColor(\"name\") -> tuple\n\ |
-\n\ |
-Returns a tuple (C, M, Y, K) containing the four color components of the\n\ |
-color \"name\" from the current document. If no document is open, returns\n\ |
-the value of the named color from the default document colors.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Returns a CMYK tuple of the specified color. */ |
-PyObject *scribus_getcolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcolorfloat__doc__, |
-QT_TR_NOOP("getColorFloat(\"name\") -> tuple\n\ |
-\n\ |
-Returns a tuple (C, M, Y, K) containing the four color components of the\n\ |
-color \"name\" from the current document. Color components are floating point\n\ |
-values between 0 and 100. If no document is open, returns the value of the\n\ |
-named color from the default document colors.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Returns a CMYK tuple of the specified color. */ |
-PyObject *scribus_getcolorfloat(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcolorasrgb__doc__, |
-QT_TR_NOOP("getColorAsRGB(\"name\") -> tuple\n\ |
-\n\ |
-Returns a tuple (R,G,B) containing the three color components of the\n\ |
-color \"name\" from the current document, converted to the RGB color\n\ |
-space. If no document is open, returns the value of the named color\n\ |
-from the default document colors.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Returns a CMYK tuple of the specified color. */ |
-PyObject *scribus_getcolorasrgb(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcolorasrgbfloat__doc__, |
-QT_TR_NOOP("getColorAsRGBFloat(\"name\") -> tuple\n\ |
-\n\ |
-Returns a tuple (R,G,B) containing the three color components of the\n\ |
-color \"name\" from the current document, converted to the RGB color\n\ |
-space. Color components are floating point values between 0 and 255.\n\ |
-If no document is open, returns the value of the named color\n\ |
-from the default document colors.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Returns a CMYK tuple of the specified color. */ |
-PyObject *scribus_getcolorasrgbfloat(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcolor__doc__, |
-QT_TR_NOOP("changeColor(\"name\", c, m, y, k)\n\ |
-\n\ |
-Changes the color \"name\" to the specified CMYK value. The color value is\n\ |
-defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black.\n\ |
-Color components should be in the range from 0 to 255.\n\ |
-Note : deprecated, use changeColorCMYK() instead.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Sets named color with C,M,Y,K params. */ |
-PyObject *scribus_setcolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcolorcmyk__doc__, |
-QT_TR_NOOP("changeColorCMYK(\"name\", c, m, y, k)\n\ |
-\n\ |
-Changes the color \"name\" to the specified CMYK value. The color value is\n\ |
-defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black.\n\ |
-Color components should be in the range from 0 to 255.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Sets named color with C,M,Y,K params. */ |
-PyObject *scribus_setcolorcmyk(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcolorcmykfloat__doc__, |
-QT_TR_NOOP("changeColorCMYKFloat(\"name\", c, m, y, k)\n\ |
-\n\ |
-Changes the color \"name\" to the specified CMYK value. The color value is\n\ |
-defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black.\n\ |
-Color components are floating point values between 0 and 100.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Sets named color with C,M,Y,K params. */ |
-PyObject *scribus_setcolorcmykfloat(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcolorrgb__doc__, |
-QT_TR_NOOP("changeColorRGB(\"name\", r, g, b)\n\ |
-\n\ |
-Changes the color \"name\" to the specified RGB value. The color value is\n\ |
-defined via three components r = red, g = green, b = blue.\n\ |
-Color components should be in the range from 0 to 255.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Sets named color with R, G, B params. */ |
-PyObject *scribus_setcolorrgb(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcolorrgbfloat__doc__, |
-QT_TR_NOOP("changeColorRGBFloat(\"name\", r, g, b)\n\ |
-\n\ |
-Changes the color \"name\" to the specified RGB value. The color value is\n\ |
-defined via three components r = red, g = green, b = blue.\n\ |
-Color components are floating point values between 0 and 255.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Sets named color with R, G, B params. */ |
-PyObject *scribus_setcolorrgbfloat(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcolorlab__doc__, |
-QT_TR_NOOP("changeColorLab(\"name\", r, g, b)\n\ |
-\n\ |
-Changes the color \"name\" to the specified CIELab values. The color value is defined\n\ |
-via three components: L = luminosity, a = green/red, b = blue/yellow. Color components\n\ |
-are floating point values with L between 0 and 100, a and b between -128 and 128.\n\ |
-\n\ |
-May raise NotFoundError if the named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Sets named color with R, G, B params. */ |
-PyObject *scribus_setcolorlab(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_newcolor__doc__, |
-QT_TR_NOOP("defineColor(\"name\", c, m, y, k)\n\ |
-\n\ |
-Defines a new color \"name\". The color Value is defined via four components:\n\ |
-c = Cyan, m = Magenta, y = Yellow and k = Black. Color components should be in\n\ |
-the range from 0 to 255.\n\ |
-Note : deprecated, use defineColorCMYK() instead.\n\ |
-\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Creates new color with name, C, M, Y, K params. */ |
-PyObject *scribus_newcolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_newcolorcmyk__doc__, |
-QT_TR_NOOP("defineColorCMYK(\"name\", c, m, y, k)\n\ |
-\n\ |
-Defines a new color \"name\". The color Value is defined via four components:\n\ |
-c = Cyan, m = Magenta, y = Yellow and k = Black. Color components should be in\n\ |
-the range from 0 to 255.\n\ |
-\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Creates new color with name, C, M, Y, K params. */ |
-PyObject *scribus_newcolorcmyk(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_newcolorcmykfloat__doc__, |
-QT_TR_NOOP("defineColorCMYKFloat(\"name\", c, m, y, k)\n\ |
-\n\ |
-Defines a new color \"name\". The color Value is defined via four components:\n\ |
-c = Cyan, m = Magenta, y = Yellow and k = Black. Color components are\n\ |
-floating point values between 0 and 100.\n\ |
-\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Creates new color with name, C, M, Y, K params. */ |
-PyObject *scribus_newcolorcmykfloat(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_newcolorrgb__doc__, |
-QT_TR_NOOP("defineColorRGB(\"name\", r, g, b)\n\ |
-\n\ |
-Defines a new color \"name\". The color Value is defined via three components:\n\ |
-r = red, g = green, b = blue. Color components should be in\n\ |
-the range from 0 to 255.\n\ |
-\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Creates new color with name, R, G, B params. */ |
-PyObject *scribus_newcolorrgb(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_newcolorrgbfloat__doc__, |
-QT_TR_NOOP("defineColorRGBFloat(\"name\", r, g, b)\n\ |
-\n\ |
-Defines a new color \"name\". The color Value is defined via three components:\n\ |
-r = red, g = green, b = blue. Color components are floating point values\n\ |
-between 0 and 255.\n\ |
-\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Creates new color with name, R, G, B params. */ |
-PyObject *scribus_newcolorrgbfloat(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_newcolorlab__doc__, |
-QT_TR_NOOP("defineColorLab(\"name\", L, a, b)\n\ |
-\n\ |
-Defines a new color \"name\" using CIELab values. The color value is defined\n\ |
-via three components: L = luminosity, a = green/red, b = blue/yellow. Color components\n\ |
-are floating point values with L between 0 and 100, a and b between -128 and 128.\n\ |
-\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Creates new color with name, L, a, b params. */ |
-PyObject *scribus_newcolorlab(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_deletecolor__doc__, |
-QT_TR_NOOP("deleteColor(\"name\", \"replace\")\n\ |
-\n\ |
-Deletes the color \"name\". Every occurrence of that color is replaced by the\n\ |
-color \"replace\". If not specified, \"replace\" defaults to the color\n\ |
-\"None\" - transparent.\n\ |
-\n\ |
-deleteColor works on the default document colors if there is no document open.\n\ |
-In that case, \"replace\", if specified, has no effect.\n\ |
-\n\ |
-May raise NotFoundError if a named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Deletes named color */ |
-PyObject *scribus_deletecolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_replcolor__doc__, |
-QT_TR_NOOP("replaceColor(\"name\", \"replace\")\n\ |
-\n\ |
-Every occurrence of the color \"name\" is replaced by the color \"replace\".\n\ |
-\n\ |
-May raise NotFoundError if a named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Replaces color with the 2nd one. */ |
-PyObject *scribus_replcolor(PyObject * /*self*/, PyObject* args); |
- |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_isspotcolor__doc__, |
-QT_TR_NOOP("isSpotColor(\"name\") -> bool\n\ |
-\n\ |
-Returns True if the color \"name\" is a spot color.\n\ |
-See also setSpotColor()\n\ |
-\n\ |
-May raise NotFoundError if a named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Replaces color with the 2nd one. */ |
-PyObject *scribus_isspotcolor(PyObject * /*self*/, PyObject* args); |
- |
- |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setspotcolor__doc__, |
-QT_TR_NOOP("setSpotColor(\"name\", spot)\n\ |
-\n\ |
-Set the color \"name\" as a spot color if spot parameter is True.\n\ |
-See also isSpotColor()\n\ |
-\n\ |
-May raise NotFoundError if a named color wasn't found.\n\ |
-May raise ValueError if an invalid color name is specified.\n\ |
-")); |
-/** Replaces color with the 2nd one. */ |
-PyObject *scribus_setspotcolor(PyObject * /*self*/, PyObject* args); |
- |
-#endif |
- |
- |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcolor.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcell.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcell.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcell.h (nonexistent) |
@@ -1,215 +0,0 @@ |
-/* |
- * Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com> |
- * |
- * For general Scribus (>=1.3.2) copyright and licensing information please refer |
- * to the COPYING file provided with the program. Following this notice may exist |
- * a copyright and/or license notice that predates the release of Scribus 1.3.2 |
- * for which a new license (GPL+exception) is in place. |
- */ |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-/*! Table cell handling */ |
- |
-#ifndef CMDCELL_H |
-#define CMDCELL_H |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcelltext__doc__, |
-QT_TR_NOOP("getCellText(row, column, [\"name\"]) -> string\n\ |
-\n\ |
-Returns the text content of the cell at \"row\", \"column\" in the table \"name\".\n\ |
-If cell has some text selected, the selected text is returned.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the cell does not exist.\n\ |
-")); |
-/*! Get cell text */ |
-PyObject *scribus_getcelltext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcelltext__doc__, |
-QT_TR_NOOP("setCellText(row, column, text, [\"name\"])\n\ |
-\n\ |
-Sets the text of the cell at \"row\", \"column\" in the table \"name\" to \"text\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the cell does not exist.\n\ |
-")); |
-/*! Set cell text */ |
-PyObject *scribus_setcelltext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcellstyle__doc__, |
-QT_TR_NOOP("getCellStyle(row, column, [\"name\"]) -> string\n\ |
-\n\ |
-Returns the named style of the cell at \"row\", \"column\" in the table \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the cell does not exist.\n\ |
-")); |
-/*! Get cell style */ |
-PyObject *scribus_getcellstyle(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcellstyle__doc__, |
-QT_TR_NOOP("setCellStyle(row, column, style, [\"name\"])\n\ |
-\n\ |
-Sets the named style of the cell at \"row\", \"column\" in the table \"name\" to \"style\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the cell does not exist.\n\ |
-")); |
-/*! Set cell style */ |
-PyObject *scribus_setcellstyle(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcellrowspan__doc__, |
-QT_TR_NOOP("getCellRowSpan(row, column, [\"name\"]) -> int\n\ |
-\n\ |
-Returns the row span of the cell at \"row\", \"column\" in the table \"name\" or -1 if the\n\ |
-cell does not exist. If the cell is covered by another spanning cell, the row span of the\n\ |
-spanning cell is returned. If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get cell row span */ |
-PyObject *scribus_getcellrowspan(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcellcolumnspan__doc__, |
-QT_TR_NOOP("getCellColumnSpan(row, column, [\"name\"]) -> int\n\ |
-\n\ |
-Returns the column span of the cell at \"row\", \"column\" in the table \"name\" or -1 if the\n\ |
-cell does not exist. If the cell is covered by another spanning cell, the column span of the\n\ |
-spanning cell is returned. If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get cell column span */ |
-PyObject *scribus_getcellcolumnspan(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcellfillcolor__doc__, |
-QT_TR_NOOP("getCellFillColor(row, column, [\"name\"]) -> string\n\ |
-\n\ |
-Returns the fill color of the cell at \"row\", \"column\" in the table \"name\"\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get cell fill color */ |
-PyObject *scribus_getcellfillcolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcellfillcolor__doc__, |
-QT_TR_NOOP("setCellFillColor(row, column, color, [\"name\"])\n\ |
-\n\ |
-Sets the fill color of the cell at \"row\", \"column\" in the table \"name\"\n\ |
-to \"color\". If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist.\n\ |
-")); |
-/*! Set cell fill color */ |
-PyObject *scribus_setcellfillcolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcellleftborder__doc__, |
-QT_TR_NOOP("setCellLeftBorder(row, column, borderLines, [\"name\"])\n\ |
-\n\ |
-Sets the left border of the cell at \"row\", \"column\" in the table \"name\".\n\ |
-The border is specified as a list of \"(width, style, color)\" tuples.\n\ |
-\"style\" is one of the LINE_* constants. If \"name\" is not given\n\ |
-the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist or if \"borderLines\" is of the wrong format.\n\ |
-")); |
-/*! Set cell left border */ |
-PyObject *scribus_setcellleftborder(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcellrightborder__doc__, |
-QT_TR_NOOP("setCellRightBorder(row, column, borderLines, [\"name\"])\n\ |
-\n\ |
-Sets the right border of the cell at \"row\", \"column\" in the table \"name\".\n\ |
-The border is specified as a list of \"(width, style, color)\" tuples.\n\ |
-\"style\" is one of the LINE_* constants. If \"name\" is not given\n\ |
-the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist or if \"borderLines\" is of the wrong format.\n\ |
-")); |
-/*! Set cell right border */ |
-PyObject *scribus_setcellrightborder(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcelltopborder__doc__, |
-QT_TR_NOOP("setCellTopBorder(row, column, borderLines, [\"name\"])\n\ |
-\n\ |
-Sets the top border of the cell at \"row\", \"column\" in the table \"name\".\n\ |
-The border is specified as a list of \"(width, style, color)\" tuples.\n\ |
-\"style\" is one of the LINE_* constants. If \"name\" is not given\n\ |
-the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist or if \"borderLines\" is of the wrong format.\n\ |
-")); |
-/*! Set cell top border */ |
-PyObject *scribus_setcelltopborder(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcellbottomborder__doc__, |
-QT_TR_NOOP("setCellBottomBorder(row, column, borderLines, [\"name\"])\n\ |
-\n\ |
-Sets the bottom border of the cell at \"row\", \"column\" in the table \"name\".\n\ |
-The border is specified as a list of \"(width, style, color)\" tuples.\n\ |
-\"style\" is one of the LINE_* constants. If \"name\" is not given\n\ |
-the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist or if \"borderLines\" is of the wrong format.\n\ |
-")); |
-/*! Set cell bottom border */ |
-PyObject *scribus_setcellbottomborder(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcellleftpadding__doc__, |
-QT_TR_NOOP("setCellLeftPadding(row, column, padding, [\"name\"])\n\ |
-\n\ |
-Sets the left padding of the cell at \"row\", \"column\" in the table \"name\"\n\ |
-to \"padding\". If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist or if \"padding\" less than 0.\n\ |
-")); |
-/*! Set cell left padding */ |
-PyObject *scribus_setcellleftpadding(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcellrightpadding__doc__, |
-QT_TR_NOOP("setCellRightPadding(row, column, padding, [\"name\"])\n\ |
-\n\ |
-Sets the right padding of the cell at \"row\", \"column\" in the table \"name\"\n\ |
-to \"padding\". If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist or if \"padding\" less than 0.\n\ |
-")); |
-/*! Set cell right padding */ |
-PyObject *scribus_setcellrightpadding(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcelltoppadding__doc__, |
-QT_TR_NOOP("setCellTopPadding(row, column, padding, [\"name\"])\n\ |
-\n\ |
-Sets the top padding of the cell at \"row\", \"column\" in the table \"name\"\n\ |
-to \"padding\". If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist or if \"padding\" is less than 0.\n\ |
-")); |
-/*! Set cell top padding */ |
-PyObject *scribus_setcelltoppadding(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcellbottompadding__doc__, |
-QT_TR_NOOP("setCellBottomPadding(row, column, padding, [\"name\"])\n\ |
-\n\ |
-Sets the bottom padding of the cell at \"row\", \"column\" in the table \"name\"\n\ |
-to \"padding\". If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the cell does not exist or if \"padding\" is less than 0.\n\ |
-")); |
-/*! Set cell bottom padding */ |
-PyObject *scribus_setcellbottompadding(PyObject * /*self*/, PyObject* args); |
- |
-#endif // CMDCELL_H |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcell.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptercore.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptercore.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptercore.h (nonexistent) |
@@ -1,94 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef SCRIPTERCORE_H |
-#define SCRIPTERCORE_H |
- |
-#include "cmdvar.h" |
- |
-#include "qmap.h" |
-#include "qpointer.h" |
- |
-class ScrAction; |
-class ScribusMainWindow; |
-class MenuManager; |
-class PythonConsole; |
- |
-class ScripterCore : public QObject |
-{ |
- Q_OBJECT |
- |
-public: |
- ScripterCore(QWidget* parent); |
- ~ScripterCore(); |
- |
- void addToMainWindowMenu(ScribusMainWindow *); |
- void enableMainWindowMenu(); |
- void disableMainWindowMenu(); |
- |
- /** @brief String representation of result returned by last python console command */ |
- QString returnString; |
- /** @brief String representation of line of code to be passed to the Python interactive interpreter */ |
- QString inValue; |
- |
-public slots: |
- void runScriptDialog(); |
- void StdScript(const QString& baseFilename); |
- void RecentScript(const QString& fn); |
- void slotRunScriptFile(const QString& fileName, bool inMainInterpreter = false); |
- void slotRunScriptFile(const QString& fileName, QStringList arguments, bool inMainInterpreter = false); |
- void slotRunPythonScript(); // needed for running python script from CLI |
- void slotRunScript(const QString& script); |
- void slotInteractiveScript(bool); |
- void slotExecute(); |
- /*! \brief Show docstring of the script to the user. |
- * I don't know how to get docstring via e.g. pydoc because of |
- * it needs to run script => error cannot find scribus module |
- */ |
- void aboutScript(); |
- /** \brief Does setup for the main interpreter, particularly the interactive console. True for success. */ |
- bool setupMainInterpreter(); |
- /** \brief Sets up the plugin for extension scripts, if enabled */ |
- void initExtensionScripts(); |
- /** \brief Runs the startup script, if enabled */ |
- void runStartupScript(); |
- void languageChange(); |
- |
- const QString & startupScript() const; |
- bool extensionsEnabled() const; |
- void setStartupScript(const QString& newScript); |
- void setExtensionsEnabled(bool enable); |
- void updateSyntaxHighlighter(); |
- |
-protected: |
- // Private helper functions |
- void finishScriptRun(); |
- void readPlugPrefs(); |
- void savePlugPrefs(); |
- void rebuildRecentScriptsMenu(); |
- void buildScribusScriptsMenu(); |
- //void buildRecentScriptsMenu(); |
- void rebuildScribusScriptsMenu(); |
- |
- //Internal members |
- //! \brief Reference to the "IDE" widget |
- PythonConsole *m_pyConsole {nullptr}; |
- MenuManager *m_menuMgr {nullptr}; |
- QStringList m_savedRecentScripts; |
- QStringList m_recentScripts; |
- QMap<QString, QPointer<ScrAction> > m_scripterActions; |
- QMap<QString, QPointer<ScrAction> > m_recentScriptActions; |
- |
- // Preferences |
- /** \brief pref: Enable access to main interpreter and 'extension scripts' */ |
- bool m_enableExtPython {false}; |
- /** \brief pref: Run 'from scribus import *' at scripter startup */ |
- bool m_importAllNames {true}; |
- /** \brief pref: Load this script on startup */ |
- QString m_startupScript; |
-}; |
- |
-#endif |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptercore.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.h (nonexistent) |
@@ -1,33 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef OBJPDFFILE_H |
-#define OBJPDFFILE_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-extern PyTypeObject PDFfile_Type; |
- |
-// Nest items are not needed but are here for me to exercise |
-// writing complete python objects |
- |
-#define PDFfile_Check(op) ((op)->ob_type == &PDFfile_Type) |
- |
-PyDoc_STRVAR(pdffile__doc__,"Exporting PDF\n\ |
-\n\ |
-Class PDFfile() provides the PDF exporting\n\ |
-for Python scripting as you know it from Save as PDF\n\ |
-menu. \n\ |
-Example:\n\ |
-pdf = PDFfile()\n\ |
-pdf.thumbnails = 1 # generate thumbnails too\n\ |
-pdf.file = 'mypdf.pdf' \n\ |
-pdf.save()"); |
- |
-PyDoc_STRVAR(pdffile_save__doc__, "save() -> void\n\nSave selected pages to pdf file."); |
- |
-#endif /* OBJPDFFILE_H */ |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h (nonexistent) |
@@ -1,684 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef CMDTEXT_H |
-#define CMDTEXT_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-/*! Text frame handling */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getfontsize__doc__, |
-QT_TR_NOOP("getFontSize([\"name\"]) -> float\n\ |
-\n\ |
-Returns the font size in points for the text frame \"name\". If this text\n\ |
-frame has some text selected the value assigned to the first character of\n\ |
-the selection is returned.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get font size */ |
-PyObject *scribus_getfontsize(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getfont__doc__, |
-QT_TR_NOOP("getFont([\"name\"]) -> string\n\ |
-\n\ |
-Returns the font name for the text frame \"name\". If this text frame\n\ |
-has some text selected the value assigned to the first character\n\ |
-of the selection is returned. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-")); |
-/*! Get font */ |
-PyObject *scribus_getfont(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getfontfeatures__doc__, |
-QT_TR_NOOP("getFontFeatures([\"name\"]) -> string\n\ |
-\n\ |
-Returns the font features for the text frame \"name\". If this text frame\n\ |
-has some text selected the value assigned to the first character\n\ |
-of the selection is returned. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-")); |
-/*! Get fontfeatures */ |
-PyObject *scribus_getfontfeatures(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getfirstlinkedframe__doc__, |
-QT_TR_NOOP("getFirstLinkedFrame(item: str = None) -> str\n\ |
-\n\ |
-Return the first text frame in the chain.\n\ |
-\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get the name of the first text frame in the chain */ |
-PyObject *scribus_getfirstlinkedframe(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getlastlinkedframe__doc__, |
-QT_TR_NOOP("getLastLinkedFrame(item: str = None) -> str\n\ |
-\n\ |
-Return the last text frame in the chain.\n\ |
-\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get the name of the last text frame in the chain */ |
-PyObject *scribus_getlastlinkedframe(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getnextlinkedframe__doc__, |
-QT_TR_NOOP("getNextLinkedFrame(item: str = None) -> str\n\ |
-\n\ |
-Return the next text frame in the chain or None\n\ |
-if specified frame is the last frame in the chain.\n\ |
-\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get the name of the next frame in the chain */ |
-PyObject *scribus_getnextlinkedframe(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getprevlinkedframe__doc__, |
-QT_TR_NOOP("getPrevLinkedFrame(item: str = None) -> str\n\ |
-\n\ |
-Return the previous text frame in the chain or None\n\ |
-if specified frame is the first frame in the chain.\n\ |
-\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get the name of the previous frame in the chain */ |
-PyObject *scribus_getprevlinkedframe(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettextcolor__doc__, |
- QT_TR_NOOP("getTextColor([\"name\"]) -> string\n\ |
-\n\ |
-Returns the name of the text color used for text frame \"name\".\n\ |
-If this text frame has some text selected the value assigned\n\ |
-to the first character of the selection is returned.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Returns color of the line */ |
-PyObject *scribus_gettextcolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettextshade__doc__, |
- QT_TR_NOOP("getTextShade([\"name\"]) -> integer\n\ |
-\n\ |
-Returns the shade of text color used for text frame \"name\".\n\ |
-If this text frame has some text selected the value assigned\n\ |
-to the first character of the selection is returned.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Returns color of the line */ |
-PyObject *scribus_gettextshade(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettextlength__doc__, |
-QT_TR_NOOP("getTextLength([\"name\"]) -> integer\n\ |
-\n\ |
-Returns the length of the text in the text frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get text size */ |
-PyObject *scribus_gettextlength(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettextlines__doc__, |
-QT_TR_NOOP("getTextLines([\"name\"]) -> integer\n\ |
-\n\ |
-Returns the number of lines of the text in the text frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-As this function depends on text layout being up-to-date, you may need to call \n\ |
-layoutText() or layoutTextChain() before calling this function in order to get \n\ |
-expected result.\n\ |
-")); |
-/*! Get text lines */ |
-PyObject *scribus_gettextlines(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getframetext__doc__, |
-QT_TR_NOOP("getFrameText([\"name\"]) -> string\n\ |
-\n\ |
-Returns the text visible in text frame \"name\". If this text frame has some text\n\ |
-selected, the selected text is returned. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-\n\ |
-This function returns only the text visible in specified frame. If you need to \n\ |
-retrieve the text contained in a text chain, use getAllText() instead.\n\ |
-\n\ |
-As this function depends on text layout being up-to-date, you may need to call \n\ |
-layoutText() or layoutTextChain() before calling this function in order to get \n\ |
-expected result.\n\ |
-")); |
-PyDoc_STRVAR(scribus_gettext__doc__, |
-QT_TR_NOOP("getText([\"name\"]) -> string\n\ |
-\n\ |
-Deprecated. Use getFrameText() instead.\n\ |
-")); |
-/*! Get frame text */ |
-PyObject *scribus_getframetext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getalltext__doc__, |
-QT_TR_NOOP("getAllText([\"name\"]) -> string\n\ |
-\n\ |
-Returns the text of the text frame \"name\" and of all text frames which are\n\ |
-linked with this frame. If this textframe has some text selected, the selected\n\ |
-text is returned. If \"name\" is not given the currently selected item is\n\ |
-used.\n\ |
-")); |
-/*! Get all text */ |
-PyObject *scribus_getalltext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getfirstlineoffset__doc__, |
- QT_TR_NOOP("getFirstLineOffset([\"name\"]) -> integer\n\ |
-\n\ |
-Gets the offset of the first line of text inside text frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get columns */ |
-PyObject *scribus_getfirstlineoffset(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getlinespacing__doc__, |
-QT_TR_NOOP("getLineSpacing([\"name\"]) -> float\n\ |
-\n\ |
-Returns the line spacing (\"leading\") of the text frame \"name\" expressed in\n\ |
-points. If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get line space */ |
-PyObject *scribus_getlinespacing(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getlinespacingmode__doc__, |
-QT_TR_NOOP("getLineSpacingMode([\"name\"]) -> float\n\ |
-\n\ |
-Returns the line spacing mode of the text frame \"name\". If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get line spacing mode*/ |
-PyObject *scribus_getlinespacingmode(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettextdistances__doc__, |
-QT_TR_NOOP("getTextDistances([\"name\"]) -> tuple\n\ |
-\n\ |
-Returns the text distances of the text frame \"name\" expressed in points. The\n\ |
-distances are returned as a tuple like (left, right, top, bottom). If \"name\"\n\ |
-is not given the currently selected item is used.\n\ |
-")); |
-/*! Get text distances */ |
-PyObject *scribus_gettextdistances(PyObject */*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettextverticalalignment__doc__, |
- QT_TR_NOOP("getTextVerticalAlignment([\"name\"]) -> integer\n\ |
-\n\ |
-Gets the vertical alignment of text inside text frame \"name\". If \"name\" is not\n\ |
-given the currently selected item is used.\n\ |
-")); |
-/*! Get columns */ |
-PyObject *scribus_gettextverticalalignment(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcolumngap__doc__, |
-QT_TR_NOOP("getColumnGap([\"name\"]) -> float\n\ |
-\n\ |
-Returns the column gap size of the text frame \"name\" expressed in points. If\n\ |
-\"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get column gap */ |
-PyObject *scribus_getcolumngap(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcolumns__doc__, |
-QT_TR_NOOP("getColumns([\"name\"]) -> integer\n\ |
-\n\ |
-Gets the number of columns of the text frame \"name\". If \"name\" is not\n\ |
-given the currently selected item is used.\n\ |
-")); |
-/*! Get columns */ |
-PyObject *scribus_getcolumns(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settext__doc__, |
-QT_TR_NOOP("setText(\"text\", [\"name\"])\n\ |
-\n\ |
-Sets the text of the text frame \"name\" to the text of the string \"text\".\n\ |
-Text must be UTF8 encoded - use e.g. unicode(text, 'iso-8859-2'). See the FAQ\n\ |
-for more details. If \"name\" is not given the currently selected item is\n\ |
-used.\n\ |
-")); |
-/*! Set text */ |
-PyObject *scribus_settext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_inserttext__doc__, |
-QT_TR_NOOP("insertText(\"text\", pos, [\"name\"])\n\ |
-\n\ |
-Inserts the text \"text\" at the position \"pos\" into the text frame \"name\".\n\ |
-Text must be UTF encoded (see setText() as reference) The first character has an\n\ |
-index of 0. Inserting text at position -1 appends it to the frame. If \"name\" is\n\ |
-not given the currently selected item is used.\n\ |
-\n\ |
-For performance reason, this function does not update text layout in any way. \n\ |
-As a consequence, you may need to call layoutText() or layoutTextChain() at appropriate \n\ |
-times after calling this function and before calling functions such as getFrameText() \n\ |
-or getTextLines().\n\ |
-\n\ |
-May throw IndexError for an insertion out of bounds.\n\ |
-")); |
-/*! Insert text */ |
-PyObject *scribus_inserttext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_inserthtmltext__doc__, |
-QT_TR_NOOP("insertHTMLText(\"file\", [\"name\"])\n\ |
-\n\ |
-Inserts the text from \"file\" into the text frame \"name\".\n\ |
-Text must be UTF encoded (see setText() as reference). If \"name\" is\n\ |
-not given the currently selected Item is used.\n\ |
-")); |
-/*! Insert HTML text */ |
-PyObject *scribus_inserthtmltext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_layouttext__doc__, |
-QT_TR_NOOP("layoutText([\"name\"])\n\ |
-\n\ |
-Relayout text in the text frame \"name\". If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-")); |
-/*! Delete text */ |
-PyObject *scribus_layouttext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_layouttextchain__doc__, |
-QT_TR_NOOP("layoutTextChain([\"name\"])\n\ |
-\n\ |
-Relayout the whole text chain whom the text frame \"name\" belongs.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Delete text */ |
-PyObject *scribus_layouttextchain(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setfont__doc__, |
-QT_TR_NOOP("setFont(\"font\", [\"name\"])\n\ |
-\n\ |
-Sets the font of the text frame \"name\" to \"font\". If there is some text\n\ |
-selected only the selected text is changed. If \"name\" is not given the\n\ |
-currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the font cannot be found.\n\ |
-")); |
-/*! Set font */ |
-PyObject *scribus_setfont(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setfontfeatures__doc__, |
-QT_TR_NOOP("setFontFeatures(\"fontfeature\", [\"name\"])\n\ |
-\n\ |
-Sets the font features of the text frame \"name\" to \"fontfeature\". If there is some text\n\ |
-selected only the selected text is changed. If \"name\" is not given the\n\ |
-currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the font cannot be found.\n\ |
-")); |
-/*! Set font features */ |
-PyObject *scribus_setfontfeatures(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setfontsize__doc__, |
-QT_TR_NOOP("setFontSize(size, [\"name\"])\n\ |
-\n\ |
-Sets the font size of the text frame \"name\" to \"size\". \"size\" is treated\n\ |
-as a value in points. If there is some text selected only the selected text is\n\ |
-changed. \"size\" must be in the range 1 to 512. If \"name\" is not given the\n\ |
-currently selected item is used.\n\ |
-\n\ |
-May throw ValueError for a font size that's out of bounds.\n\ |
-")); |
-/*! Set font size */ |
-PyObject *scribus_setfontsize(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setfirstlineoffset__doc__, |
- QT_TR_NOOP("setFirstLineOffset(offset, [\"name\"])\n\ |
-\n\ |
-Sets the offset of the first line of text inside text frame \"name\" to the specified\n\ |
-offset policy. If \"name\" is not given the currently selected item is used. \"offset\" \n\ |
-should be one of the FLOP_* constants defined in this module - see dir(scribus).\n\ |
-\n\ |
-May throw ValueError for an invalid offset constant.\n\ |
-")); |
-/*! Set vertical alignment */ |
-PyObject *scribus_setfirstlineoffset(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setlinespacing__doc__, |
-QT_TR_NOOP("setLineSpacing(size, [\"name\"])\n\ |
-\n\ |
-Sets the line spacing (\"leading\") of the text frame \"name\" to \"size\".\n\ |
-\"size\" is a value in points. If \"name\" is not given the currently selected\n\ |
-item is used.\n\ |
-\n\ |
-May throw ValueError if the line spacing is out of bounds.\n\ |
-")); |
-/*! Set line space */ |
-PyObject *scribus_setlinespacing(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setlinespacingmode__doc__, |
-QT_TR_NOOP("setLineSpacingMode(mode, [\"name\"])\n\ |
-\n\ |
-Sets the line spacing mode of the text frame \"name\" to \"mode\".\n\ |
-If \"name\" is not given the currently selected\n\ |
-item is used.\n\ |
-Mode values are the same as in createParagraphStyle.\n\ |
-\n\ |
-May throw ValueError if the mode is out of bounds.\n\ |
-")); |
-/*! Set line space mode */ |
-PyObject *scribus_setlinespacingmode(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextdistances__doc__, |
-QT_TR_NOOP("setTextDistances(left, right, top, bottom, [\"name\"])\n\ |
-\n\ |
-Sets the text distances of the text frame \"name\" to the values \"left\"\n\ |
-\"right\", \"top\" and \"bottom\". If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-\n\ |
-May throw ValueError if any of the distances are out of bounds (must be positive).\n\ |
-")); |
- |
-/*! Set text distances */ |
-PyObject *scribus_settextdistances(PyObject */*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcolumngap__doc__, |
-QT_TR_NOOP("setColumnGap(size, [\"name\"])\n\ |
-\n\ |
-Sets the column gap of the text frame \"name\" to the value \"size\". If\n\ |
-\"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the column gap is out of bounds (must be positive).\n\ |
-")); |
-/*! Set column gap */ |
-PyObject *scribus_setcolumngap(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcolumns__doc__, |
-QT_TR_NOOP("setColumns(nr, [\"name\"])\n\ |
-\n\ |
-Sets the number of columns of the text frame \"name\" to the integer \"nr\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if number of columns is not at least one.\n\ |
-")); |
-/*! Set columns */ |
-PyObject *scribus_setcolumns(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextalignment__doc__, |
-QT_TR_NOOP("setTextAlignment(align, [\"name\"])\n\ |
-\n\ |
-Sets the text alignment of the text frame \"name\" to the specified alignment.\n\ |
-If \"name\" is not given the currently selected item is used. \"align\" should\n\ |
-be one of the ALIGN_ constants defined in this module - see dir(scribus).\n\ |
-\n\ |
-May throw ValueError for an invalid alignment constant.\n\ |
-")); |
-/*! Set alignt */ |
-PyObject *scribus_settextalignment(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextverticalalignment__doc__, |
- QT_TR_NOOP("setTextVerticalAlignment(align, [\"name\"])\n\ |
-\n\ |
-Sets the vertical alignment of text inside text frame \"name\" to the specified\n\ |
-alignment. If \"name\" is not given the currently selected item is used. \"align\" \n\ |
-should be one of the ALIGNV constants defined in this module - see dir(scribus).\n\ |
-\n\ |
-May throw ValueError for an invalid alignment constant.\n\ |
-")); |
-/*! Set vertical alignment */ |
-PyObject *scribus_settextverticalalignment(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setdirection__doc__, |
-QT_TR_NOOP("setTextDirection(direction, [\"name\"])\n\ |
-\n\ |
-Sets the text direction of the text frame \"name\" to the specified direction.\n\ |
-If \"name\" is not given the currently selected item is used. \"direction\" should\n\ |
-be one of the DIRECTION_ constants defined in this module - see dir(scribus).\n\ |
-\n\ |
-May throw ValueError for an invalid direction constant.\n\ |
-")); |
-/*! Set direction */ |
-PyObject *scribus_setdirection(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_selectframetext__doc__, |
-QT_TR_NOOP("selectFrameText(start, count, [\"name\"])\n\ |
-\n\ |
-Selects \"count\" characters of text in the text frame \"name\" starting from the\n\ |
-character \"start\". Character counting starts at 0.\n\ |
-If \"count\" is zero, any text selection will be cleared.\n\ |
-If \"count\" is -1, the selection will extend to the end of the frame.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-This function only acts on the text visible in the specified frame. If you need to \n\ |
-work on the text contained in a text chain, use selectText() instead.\n\ |
-As this function depends on text layout being up-to-date, you may need to call \n\ |
-layoutText() or layoutTextChain() before calling this function in order to get \n\ |
-expected result.\n\ |
-\n\ |
-May throw IndexError if the selection is outside the bounds of the text.\n\ |
-")); |
-/*! Select frame text */ |
-PyObject *scribus_selectframetext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_selecttext__doc__, |
-QT_TR_NOOP("selectText(start, count, [\"name\"])\n\ |
-\n\ |
-Selects \"count\" characters of text in the story of the text frame \"name\" starting from the\n\ |
-character \"start\". Character counting starts at 0. If \"count\" is zero, any\n\ |
-text selection will be cleared. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-\n\ |
-May throw IndexError if the selection is outside the bounds of the text.\n\ |
-")); |
-/*! Select text */ |
-PyObject *scribus_selecttext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_deletetext__doc__, |
-QT_TR_NOOP("deleteText([\"name\"])\n\ |
-\n\ |
-Deletes any text in the text frame \"name\". If there is some text selected,\n\ |
-only the selected text will be deleted. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-")); |
-/*! Delete text */ |
-PyObject *scribus_deletetext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextfill__doc__, |
-QT_TR_NOOP("setTextColor(\"color\", [\"name\"])\n\ |
-\n\ |
-Sets the text color of the text frame \"name\" to the color \"color\". If there\n\ |
-is some text selected only the selected text is changed. If \"name\" is not\n\ |
-given the currently selected item is used.\n\ |
-")); |
-/*! Set text fill */ |
-PyObject *scribus_settextfill(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextstroke__doc__, |
-QT_TR_NOOP("setTextStroke(\"color\", [\"name\"])\n\ |
-\n\ |
-Set \"color\" of the text stroke. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-")); |
-/*! Set text stroke */ |
-PyObject *scribus_settextstroke(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextscalingv__doc__, |
-QT_TR_NOOP("setTextScalingV(scale, [\"name\"])\n\ |
-\n\ |
-Sets the vertical character scaling of the object \"name\" to \"scale\" in percent.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Set text shde */ |
-PyObject *scribus_settextscalingv(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextscalingh__doc__, |
-QT_TR_NOOP("setTextScalingH(scale, [\"name\"])\n\ |
-\n\ |
-Sets the horizontal character scaling of the object \"name\" to \"scale\" in percent.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Set text shde */ |
-PyObject *scribus_settextscalingh(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextshade__doc__, |
-QT_TR_NOOP("setTextShade(shade, [\"name\"])\n\ |
-\n\ |
-Sets the shading of the text color of the object \"name\" to \"shade\". If\n\ |
-there is some text selected only the selected text is changed. \"shade\" must\n\ |
-be an integer value in the range from 0 (lightest) to 100 (full color\n\ |
-intensity). If \"name\" is not given the currently selected item is\n\ |
-used.\n\ |
-")); |
-/*! Set text shde */ |
-PyObject *scribus_settextshade(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_linktextframes__doc__, |
-QT_TR_NOOP("linkTextFrames(\"fromname\", \"toname\")\n\ |
-\n\ |
-Link two text frames. The frame named \"fromname\" is linked to the\n\ |
-frame named \"toname\". The target frame must be an empty text frame\n\ |
-and must not link to or be linked from any other frames already.\n\ |
-\n\ |
-May throw ScribusException if linking rules are violated.\n\ |
-")); |
-/** |
- Link text frames via Scripter. |
- 02/22/04 (petr vanek) |
- TODO: PDF bookmarks handling |
- */ |
-PyObject *scribus_linktextframes(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_unlinktextframes__doc__, |
-QT_TR_NOOP("unlinkTextFrames(\"name\")\n\ |
-\n\ |
-Remove the specified (named) object from the text frame flow/linkage. If the\n\ |
-frame was in the middle of a chain, the previous and next frames will be\n\ |
-connected, eg 'a->b->c' becomes 'a->c' when you unlinkTextFrames(b)'\n\ |
-\n\ |
-May throw ScribusException if linking rules are violated.\n\ |
-")); |
-/** |
- (Un)Link text frames via Scripter. |
- 02/22/04 (petr vanek) |
- TODO: PDF bookmarks handling |
- */ |
-PyObject *scribus_unlinktextframes(PyObject * self, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_outlinetext__doc__, |
-QT_TR_NOOP("traceText([\"name\"])\n\ |
-\n\ |
-Convert the text frame \"name\" to outlines. If \"name\" is not given the\n\ |
-currently selected item is used.")); |
-PyDoc_STRVAR(scribus_tracetext__doc__, |
-QT_TR_NOOP("traceText([\"name\"])\n\ |
-\n\ |
-Deprecated, use outlineText() instead.")); |
-/** |
- Trace text frames via Scripter. |
- 2004-09-07 (Craig Ringer) |
-*/ |
-PyObject *scribus_outlinetext(PyObject * self, PyObject* args); |
- |
-PyDoc_STRVAR(scribus_istextoverflowing__doc__, |
-QT_TR_NOOP("textOverflows([\"name\", nolinks]) -> integer\n\ |
-\n\ |
-Returns 1 if there are overflowing characters in text frame \"name\", 0 if not.\n\ |
-If is nolinks set to non zero value it takes only one frame - it doesn't\n\ |
-use text frame linking. Without this parameter it search all linking chain.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not an text frame\n")); |
-/** Check if is the text frame overflowind or not |
- 2005-02-04 petr vanek |
- */ |
-PyObject *scribus_istextoverflowing(PyObject * self, PyObject* args, PyObject* kw); |
- |
-PyDoc_STRVAR(scribus_hyphenatetext__doc__, |
-QT_TR_NOOP("hyphenateText([\"name\"]) -> bool\n\ |
-\n\ |
-Does hyphenation on text frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not a text frame\n\ |
-")); |
-/* |
- Does hyphenation on the given text frame |
- 08.12.2007: Joachim Neu |
-*/ |
-PyObject *scribus_hyphenatetext(PyObject *, PyObject* args); |
- |
-PyDoc_STRVAR(scribus_dehyphenatetext__doc__, |
-QT_TR_NOOP("dehyphenateText([\"name\"]) -> bool\n\ |
-\n\ |
-Does dehyphenation on text frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not a text frame\n\ |
-")); |
-/* |
- Does dehyphenation on the given text frame |
- 13.12.2007: Joachim Neu |
-*/ |
-PyObject *scribus_dehyphenatetext(PyObject *, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setpdfbookmark__doc__, |
-QT_TR_NOOP("setPDFBookmark(\"toggle\", [\"name\"])\n\ |
-\n\ |
-Sets whether (toggle = 1) the text frame \"name\" is a bookmark or not.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not a text frame\n\ |
-")); |
-/*! Set PDF bookmark */ |
-PyObject *scribus_setpdfbookmark(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_ispdfbookmark__doc__, |
- QT_TR_NOOP("isPDFBookmark([\"name\"]) -> bool\n\ |
-\n\ |
-Returns true if the text frame \"name\" is a PDF bookmark.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not a text frame\n\ |
-")); |
-/*! Is PDF bookmark? */ |
-PyObject *scribus_ispdfbookmark(PyObject * /*self*/, PyObject* args); |
- |
-#endif |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.h (nonexistent) |
@@ -1,281 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef CMDMANI_H |
-#define CMDMANI_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-/** Manipulating Objects */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_moveobjectrel__doc__, |
-QT_TR_NOOP("moveObject(dx, dy [, \"name\"])\n\ |
-\n\ |
-Moves the object \"name\" by dx and dy relative to its current position. The\n\ |
-distances are expressed in the current measurement unit of the document (see\n\ |
-UNIT constants). If \"name\" is not given the currently selected item is used.\n\ |
-If the object \"name\" belongs to a group, the whole group is moved.\n\ |
-")); |
-/*! Move REL the object */ |
-PyObject *scribus_moveobjectrel(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_moveobjectabs__doc__, |
-QT_TR_NOOP("moveObjectAbs(x, y [, \"name\"])\n\ |
-\n\ |
-Moves the object \"name\" to a new location. The coordinates are expressed in\n\ |
-the current measurement unit of the document (see UNIT constants). If \"name\"\n\ |
-is not given the currently selected item is used. If the object \"name\"\n\ |
-belongs to a group, the whole group is moved.\n\ |
-")); |
-/*! Move ABS the object */ |
-PyObject *scribus_moveobjectabs(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_rotateobjectrel__doc__, |
-QT_TR_NOOP("rotateObject(rot [, \"name\"])\n\ |
-\n\ |
-Rotates the object \"name\" by \"rot\" degrees relatively. The object is\n\ |
-rotated by the vertex that is currently selected as the rotation point - by\n\ |
-default, the top left vertex at zero rotation. Positive values mean counter\n\ |
-clockwise rotation when the default rotation point is used. If \"name\" is not\n\ |
-given the currently selected item is used.\n\ |
-")); |
-/*! Rotate REL the object */ |
-PyObject *scribus_rotateobjectrel(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_rotateobjectabs__doc__, |
-QT_TR_NOOP("rotateObjectAbs(rot [, \"name\"])\n\ |
-\n\ |
-Sets the rotation of the object \"name\" to \"rot\". Positive values\n\ |
-mean counter clockwise rotation. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-")); |
-/*! Rotate ABS the object */ |
-PyObject *scribus_rotateobjectabs(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_sizeobject__doc__, |
-QT_TR_NOOP("sizeObject(width, height [, \"name\"])\n\ |
-\n\ |
-Resizes the object \"name\" to the given width and height. If \"name\"\n\ |
-is not given the currently selected item is used.\n\ |
-")); |
-/*! Resize ABS the object */ |
-PyObject *scribus_sizeobject(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getselectedobject__doc__, |
-QT_TR_NOOP("getSelectedObject([nr]) -> string\n\ |
-\n\ |
-Returns the name of the selected object. \"nr\" if given indicates the number\n\ |
-of the selected object, e.g. 0 means the first selected object, 1 means the\n\ |
-second selected Object and so on.\n\ |
-")); |
-/*! Returns name of the selected object */ |
-PyObject *scribus_getselectedobject(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_selectioncount__doc__, |
-QT_TR_NOOP("selectionCount() -> integer\n\ |
-\n\ |
-Returns the number of selected objects.\n\ |
-")); |
-/*! Returns count of the selected object */ |
-PyObject *scribus_selectioncount(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_selectobject__doc__, |
-QT_TR_NOOP("selectObject(\"name\")\n\ |
-\n\ |
-Selects the object with the given \"name\".\n\ |
-")); |
-/*! Count selection */ |
-PyObject *scribus_selectobject(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_deselectall__doc__, |
-QT_TR_NOOP("deselectAll()\n\ |
-\n\ |
-Deselects all objects in the whole document.\n\ |
-")); |
-/*! Remove all selection */ |
-PyObject *scribus_deselectall(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_groupobjects__doc__, |
-QT_TR_NOOP("groupObjects(list) -> string\n\ |
-\n\ |
-Groups the objects named in \"list\" together. \"list\" must contain the names\n\ |
-of the objects to be grouped. If \"list\" is not given the currently selected\n\ |
-items are used. Returns the group name for further referencing.\n\ |
-")); |
-/*! Group objects named in list. */ |
-PyObject *scribus_groupobjects(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_ungroupobjects__doc__, |
-QT_TR_NOOP("unGroupObjects(\"name\")\n\n\ |
-Destructs the group the object \"name\" belongs to.\ |
-If \"name\" is not given the currently selected item is used.")); |
-/*! Ungroup objects named in list. */ |
-PyObject *scribus_ungroupobjects(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_scalegroup__doc__, |
-QT_TR_NOOP("scaleGroup(factor [,\"name\"])\n\ |
-\n\ |
-Scales the group the object \"name\" belongs to. Values greater than 1 enlarge\n\ |
-the group, values smaller than 1 make the group smaller e.g a value of 0.5\n\ |
-scales the group to 50 % of its original size, a value of 1.5 scales the group\n\ |
-to 150 % of its original size. The value for \"factor\" must be greater than\n\ |
-0. If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May raise ValueError if an invalid scale factor is passed.\n\ |
-")); |
-/*! Scale group with object name */ |
-PyObject *scribus_scalegroup(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_loadimage__doc__, |
-QT_TR_NOOP("loadImage(\"filename\" [, \"name\"])\n\ |
-\n\ |
-Loads the picture \"picture\" into the image frame \"name\". If \"name\" is\n\ |
-not given the currently selected item is used.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not an image frame\n\ |
-")); |
-/*! Loads image file into frame. */ |
-PyObject *scribus_loadimage(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_scaleimage__doc__, |
-QT_TR_NOOP("scaleImage(x, y [, \"name\"])\n\ |
-\n\ |
-Sets the internal scaling factors of the picture in the image frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used. A number of 1\n\ |
-means 100 %. Internal scaling factors are different from the values shown on \n\ |
-properties palette. Note : deprecated, use setImageScale() instead.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not an image frame\n\ |
-")); |
-/*! Scale Image. */ |
-PyObject *scribus_scaleimage(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setimageoffset__doc__, |
-QT_TR_NOOP("setImageOffset(x, y [, \"name\"])\n\ |
-\n\ |
-Sets the position of the picture in the image frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-The specified offset values are equal to the values shown on \n\ |
-properties palette when point unit is used.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not an image frame\n\ |
-")); |
-/*! Scale Image. */ |
-PyObject *scribus_setimageoffset(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setimagescale__doc__, |
-QT_TR_NOOP("setImageScale(x, y [, \"name\"])\n\ |
-\n\ |
-Sets the scaling factors of the picture in the image frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used. A number of 1\n\ |
-means 100 %. Scaling factors are equal to the values shown on properties palette.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not an image frame\n\ |
-")); |
-/*! Scale Image. */ |
-PyObject *scribus_setimagescale(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setimagebrightness__doc__, |
-QT_TR_NOOP("setImageBrightness(n [, \"name\"])\n\ |
-\n\ |
-Set image brightness effect of the picture in the image frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used. A number of 1\n\ |
-means 100 %. Brightness factor is equal to the value shown on properties palette.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not an image frame\n\ |
-")); |
-/*! Set Image Brightness. */ |
-PyObject *scribus_setimagebrightness(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setimagegrayscale__doc__, |
-QT_TR_NOOP("setImageGrayscale([\"name\"])\n\ |
-\n\ |
-Set image grayscale effect of the picture in the image frame \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May raise WrongFrameTypeError if the target frame is not an image frame\n\ |
-")); |
-/*! Set Image Brightness. */ |
-PyObject *scribus_setimagegrayscale(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_lockobject__doc__, |
-QT_TR_NOOP("lockObject([\"name\"]) -> bool\n\ |
-\n\ |
-Locks the object \"name\" if it's unlocked or unlock it if it's locked.\n\ |
-If \"name\" is not given the currently selected item is used. Returns true\n\ |
-if locked.\n\ |
-")); |
-/*! (Un)Lock the object 2004/7/10 pv.*/ |
-PyObject *scribus_lockobject(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_islocked__doc__, |
-QT_TR_NOOP("isLocked([\"name\"]) -> bool\n\ |
-\n\ |
-Returns true if is the object \"name\" locked. If \"name\" is not given the\n\ |
-currently selected item is used.\n\ |
-")); |
-/*! Status of locking 2004/7/10 pv.*/ |
-PyObject *scribus_islocked(PyObject * /*self*/, PyObject* args); |
- |
-PyDoc_STRVAR(scribus_setscaleframetoimage__doc__, |
-QT_TR_NOOP("setScaleFrameToImage([name])\n\ |
-\n\ |
-Set frame size on the selected or specified image frame to image size.\n\ |
-\n\ |
-May raise WrongFrameTypeError.\n\ |
-")); |
-PyObject *scribus_setscaleframetoimage(PyObject * /*self*/, PyObject* args); |
- |
-PyDoc_STRVAR(scribus_setscaleimagetoframe__doc__, |
-QT_TR_NOOP("setScaleImageToFrame(scaletoframe, proportional=None, name=<selection>)\n\ |
-\n\ |
-Sets the scale to frame on the selected or specified image frame to `scaletoframe'.\n\ |
-If `proportional' is specified, set fixed aspect ratio scaling to `proportional'.\n\ |
-Both `scaletoframe' and `proportional' are boolean.\n\ |
-\n\ |
-May raise WrongFrameTypeError.\n\ |
-")); |
-PyObject *scribus_setscaleimagetoframe(PyObject * /*self*/, PyObject* args, PyObject* kwargs); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_flipobject__doc__, |
-QT_TR_NOOP("flipObject(H,V,[\"name\"])\n\ |
-\n\ |
-Toggle the object \"name\" horizontal and/or vertical flip.\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Flip the object 2010/5/18.*/ |
-PyObject *scribus_flipobject(PyObject * /*self*/, PyObject* args); |
- |
-PyDoc_STRVAR(scribus_combinepolygons__doc__, |
-QT_TR_NOOP("combinePolygons()\n\ |
-\n\ |
-Combine two or more selected Polygons\n\ |
-")); |
-PyObject *scribus_combinepolygons(PyObject * /* self */); |
- |
-#endif |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/pconsole.ui |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/pconsole.ui (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/pconsole.ui (nonexistent) |
@@ -1,130 +0,0 @@ |
-<?xml version="1.0" encoding="UTF-8"?> |
-<ui version="4.0"> |
- <class>PythonConsole</class> |
- <widget class="QMainWindow" name="PythonConsole"> |
- <property name="geometry"> |
- <rect> |
- <x>0</x> |
- <y>0</y> |
- <width>535</width> |
- <height>471</height> |
- </rect> |
- </property> |
- <property name="windowTitle"> |
- <string>Script Console</string> |
- </property> |
- <widget class="QWidget" name="centralwidget"> |
- <layout class="QGridLayout"> |
- <property name="leftMargin"> |
- <number>9</number> |
- </property> |
- <property name="topMargin"> |
- <number>9</number> |
- </property> |
- <property name="rightMargin"> |
- <number>9</number> |
- </property> |
- <property name="bottomMargin"> |
- <number>9</number> |
- </property> |
- <property name="horizontalSpacing"> |
- <number>6</number> |
- </property> |
- <property name="verticalSpacing"> |
- <number>6</number> |
- </property> |
- <item row="0" column="0"> |
- <widget class="QSplitter" name="splitter"> |
- <property name="orientation"> |
- <enum>Qt::Vertical</enum> |
- </property> |
- <widget class="QTextEdit" name="commandEdit"> |
- <property name="lineWrapMode"> |
- <enum>QTextEdit::NoWrap</enum> |
- </property> |
- </widget> |
- <widget class="QTextEdit" name="outputEdit"> |
- <property name="lineWrapMode"> |
- <enum>QTextEdit::NoWrap</enum> |
- </property> |
- <property name="readOnly"> |
- <bool>true</bool> |
- </property> |
- <property name="acceptRichText"> |
- <bool>false</bool> |
- </property> |
- </widget> |
- </widget> |
- </item> |
- </layout> |
- </widget> |
- <widget class="QMenuBar" name="menubar"> |
- <property name="geometry"> |
- <rect> |
- <x>0</x> |
- <y>0</y> |
- <width>535</width> |
- <height>22</height> |
- </rect> |
- </property> |
- <widget class="QMenu" name="menu_File"> |
- <property name="title"> |
- <string>&File</string> |
- </property> |
- <addaction name="action_Open"/> |
- <addaction name="action_Save"/> |
- <addaction name="actionSave_As"/> |
- <addaction name="separator"/> |
- <addaction name="action_Exit"/> |
- </widget> |
- <widget class="QMenu" name="menu_Script"> |
- <property name="title"> |
- <string>&Script</string> |
- </property> |
- <addaction name="action_Run"/> |
- <addaction name="actionRun_As_Console"/> |
- <addaction name="action_Save_Output"/> |
- </widget> |
- <addaction name="menu_File"/> |
- <addaction name="menu_Script"/> |
- </widget> |
- <widget class="QStatusBar" name="statusbar"/> |
- <action name="action_Open"> |
- <property name="text"> |
- <string>&Open...</string> |
- </property> |
- </action> |
- <action name="action_Save"> |
- <property name="text"> |
- <string>&Save</string> |
- </property> |
- </action> |
- <action name="actionSave_As"> |
- <property name="text"> |
- <string>Save &As...</string> |
- </property> |
- </action> |
- <action name="action_Exit"> |
- <property name="text"> |
- <string>&Quit</string> |
- </property> |
- </action> |
- <action name="action_Run"> |
- <property name="text"> |
- <string>&Run</string> |
- </property> |
- </action> |
- <action name="actionRun_As_Console"> |
- <property name="text"> |
- <string>Run As &Console</string> |
- </property> |
- </action> |
- <action name="action_Save_Output"> |
- <property name="text"> |
- <string>&Save Output...</string> |
- </property> |
- </action> |
- </widget> |
- <resources/> |
- <connections/> |
-</ui> |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/runscriptdialog.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/runscriptdialog.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/runscriptdialog.h (nonexistent) |
@@ -1,44 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef _RUNSCRIPTDIALOG_H |
-#define _RUNSCRIPTDIALOG_H |
- |
-// Pulls in Python.h |
-// #include "cmdvar.h" |
-#include "ui_runscriptdialog.h" |
- |
- |
-/*! \brief Select a python script for execution. |
-\author Craig Ringer |
-\author Petr Vanek <petr@scribus.info> |
-*/ |
-class RunScriptDialog : public QDialog, public Ui::RunScriptDialog |
-{ |
- Q_OBJECT |
- |
- public: |
- RunScriptDialog(QWidget* parent, bool extEnable = false); |
- ~RunScriptDialog(); |
- |
- //! \brief Check if the user wanted the script run as an extension script |
- bool extensionRequested(); |
- //! \brief Return chosen filename |
- QString selectedFile(); |
- |
- protected: |
- // true id there is "scripter extensions" feature enabled |
- bool m_extEnable; |
- |
- static QString m_lastScriptDir; |
- |
- protected slots: |
- virtual void accept(); |
- void fileClicked(const QString &path); |
- void okClicked(); |
-}; |
- |
-#endif |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/runscriptdialog.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmisc.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmisc.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmisc.cpp (nonexistent) |
@@ -1,844 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "cmdmisc.h" |
-#include "cmdutil.h" |
- |
-#include "qbuffer.h" |
-#include "qpixmap.h" |
-//Added by qt3to4: |
-#include <QList> |
- |
-#include "prefsmanager.h" |
-#include "scribuscore.h" |
-#include "scribusdoc.h" |
-#include "scribusview.h" |
-#include "selection.h" |
-#include "fonts/scfontmetrics.h" |
-#include "pdfoptionsio.h" |
- |
-PyObject *scribus_setredraw(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- if (!PyArg_ParseTuple(args, "i", &e)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScCore->primaryMainWindow()->doc->DoDrawing = static_cast<bool>(e); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getfontnames(PyObject* /* self */) |
-{ |
- int cc2 = 0; |
- SCFontsIterator it2(PrefsManager::instance().appPrefs.fontPrefs.AvailFonts); |
- for ( ; it2.hasNext() ; it2.next()) |
- { |
- if (it2.current().usable()) |
- cc2++; |
- } |
- PyObject *l = PyList_New(cc2); |
- SCFontsIterator it(PrefsManager::instance().appPrefs.fontPrefs.AvailFonts); |
- int cc = 0; |
- for ( ; it.hasNext() ; it.next()) |
- { |
- if (it.current().usable()) |
- { |
- PyList_SetItem(l, cc, PyString_FromString(it.currentKey().toUtf8())); |
- cc++; |
- } |
- } |
- return l; |
-} |
- |
-PyObject *scribus_xfontnames(PyObject* /* self */) |
-{ |
- PyObject *l = PyList_New(PrefsManager::instance().appPrefs.fontPrefs.AvailFonts.count()); |
- SCFontsIterator it(PrefsManager::instance().appPrefs.fontPrefs.AvailFonts); |
- int cc = 0; |
- PyObject *row; |
- for ( ; it.hasNext() ; it.next()) |
- { |
- row = Py_BuildValue((char*)"(sssiis)", |
- it.currentKey().toUtf8().data(), |
- it.current().family().toUtf8().data(), |
- it.current().psName().toUtf8().data(), |
- it.current().subset(), |
- it.current().embedPs(), |
- it.current().fontFilePath().toUtf8().data() |
- ); |
- PyList_SetItem(l, cc, row); |
- cc++; |
- } // for |
- return l; |
-} |
- |
-// This function is fairly complex because it can either save its output to a |
-// file, or return it as a Python string. |
-PyObject *scribus_renderfont(PyObject* /*self*/, PyObject* args, PyObject* kw) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *FileName = const_cast<char*>(""); |
- char *Sample = const_cast<char*>(""); |
- char *format = nullptr; |
- int Size; |
- bool ret = false; |
- char *kwargs[] = {const_cast<char*>("fontname"), |
- const_cast<char*>("filename"), |
- const_cast<char*>("sample"), |
- const_cast<char*>("size"), |
- const_cast<char*>("format"), |
- nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "esesesi|es", kwargs, |
- "utf-8", &Name, "utf-8", &FileName, "utf-8", &Sample, &Size, "ascii", &format)) |
- return nullptr; |
- if (!PrefsManager::instance().appPrefs.fontPrefs.AvailFonts.contains(QString::fromUtf8(Name))) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Font not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QVector<uint> ts = QString::fromUtf8(Sample).toUcs4(); |
- if (ts.isEmpty()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot render an empty sample.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (!format) |
- // User specified no format, so use the historical default of PPM format. |
- format = const_cast<char*>("PPM"); |
- QPixmap pm = FontSample(PrefsManager::instance().appPrefs.fontPrefs.AvailFonts[QString::fromUtf8(Name)], Size, ts, Qt::white); |
- // If the user specified an empty filename, return the image data as bytes. Otherwise, save it to disk. |
- if (QString::fromUtf8(FileName).isEmpty()) |
- { |
- QByteArray buffer_string = ""; |
- QBuffer buffer(&buffer_string); |
- buffer.open(QIODevice::WriteOnly); |
- bool ret = pm.save(&buffer, format); |
- if (!ret) |
- { |
- PyErr_SetString(ScribusException, QObject::tr("Unable to save pixmap","scripter error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int bufferSize = buffer.size(); |
- buffer.close(); |
- // Now make a Python string from the data we generated |
- PyObject* stringPython = PyString_FromStringAndSize(buffer_string,bufferSize); |
- // Return even if the result is nullptr (error) since an exception will have been |
- // set in that case. |
- return stringPython; |
- } |
- |
- // Save the pixmap to a file, since the filename is non-empty |
- ret = pm.save(QString::fromUtf8(FileName), format); |
- if (!ret) |
- { |
- PyErr_SetString(PyExc_Exception, QObject::tr("Unable to save pixmap","scripter error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- // For historical reasons, we need to return true on success. |
- // Py_INCREF(Py_True); |
- // return Py_True; |
- // Py_RETURN_TRUE; |
- return PyBool_FromLong(static_cast<long>(true)); |
-} |
- |
-PyObject *scribus_getlayers(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* doc = ScCore->primaryMainWindow()->doc; |
- PyObject *l = PyList_New(doc->Layers.count()); |
- for (int i = 0; i < doc->Layers.count(); i++) |
- PyList_SetItem(l, i, PyString_FromString(doc->Layers[i].Name.toUtf8())); |
- return l; |
-} |
- |
-PyObject *scribus_setactivelayer(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (Name == nullptr) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = ScCore->primaryMainWindow()->doc->setActiveLayer(QString::fromUtf8(Name)); |
- if (found) |
- ScCore->primaryMainWindow()->changeLayer(ScCore->primaryMainWindow()->doc->activeLayer()); |
- else |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getactivelayer(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- return PyString_FromString(ScCore->primaryMainWindow()->doc->activeLayerName().toUtf8()); |
-} |
- |
-PyObject *scribus_loweractivelayer(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- int activeLayer = ScCore->primaryMainWindow()->doc->activeLayer(); |
- ScCore->primaryMainWindow()->doc->lowerLayer(activeLayer); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_raiseactivelayer(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- int activeLayer = ScCore->primaryMainWindow()->doc->activeLayer(); |
- ScCore->primaryMainWindow()->doc->raiseLayer(activeLayer); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_sendtolayer(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Layer = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Layer, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Layer) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
- if (item == nullptr) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- ScribusView* currentView = ScCore->primaryMainWindow()->view; |
- const ScLayer *scLayer = currentDoc->Layers.layerByName( QString::fromUtf8(Layer) ); |
- if (!scLayer) |
- { |
- PyErr_SetString(ScribusException, QString("Layer not found").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- // If no name have been specified in args, process whole selection |
- currentView->selectItem(item); |
- if (strlen(Name) == 0) |
- { |
- for (int i = 0; i < currentDoc->m_Selection->count(); ++i) |
- { |
- item = currentDoc->m_Selection->itemAt(i); |
- item->m_layerID = scLayer->ID; |
- } |
- } |
- else |
- { |
- item->m_layerID = scLayer->ID; |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlayervisible(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int vis = 1; |
- if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QString("Cannot have an empty layer name").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- ScCore->primaryMainWindow()->doc->Layers[lam].isViewable = vis; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlayerprintable(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int vis = 1; |
- if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- ScCore->primaryMainWindow()->doc->Layers[lam].isPrintable = vis; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlayerlocked(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int vis = 1; |
- if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- ScCore->primaryMainWindow()->doc->Layers[lam].isEditable = vis; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlayeroutlined(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int vis = 1; |
- if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- ScCore->primaryMainWindow()->doc->Layers[lam].outlineMode = vis; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlayerflow(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int vis = 1; |
- if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- ScCore->primaryMainWindow()->doc->Layers[lam].flowControl = vis; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlayerblendmode(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int vis = 0; |
- if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QString("Cannot have an empty layer name").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- ScCore->primaryMainWindow()->doc->Layers[lam].blendMode = vis; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlayertransparency(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double vis = 1.0; |
- if (!PyArg_ParseTuple(args, "esd", "utf-8", &Name, &vis)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QString("Cannot have an empty layer name").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- ScCore->primaryMainWindow()->doc->Layers[lam].transparency = vis; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_islayervisible(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int i = 0; |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); lam++) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- i = static_cast<int>(ScCore->primaryMainWindow()->doc->Layers[lam].isViewable); |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(i)); |
-} |
- |
-PyObject *scribus_islayerprintable(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int i = 0; |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- i = static_cast<int>(ScCore->primaryMainWindow()->doc->Layers[lam].isPrintable); |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(i)); |
-} |
- |
-PyObject *scribus_islayerlocked(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int i = 0; |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); lam++) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- i = static_cast<int>(ScCore->primaryMainWindow()->doc->Layers[lam].isEditable); |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(i)); |
-} |
- |
-PyObject *scribus_islayeroutlined(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int i = 0; |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); lam++) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- i = static_cast<int>(ScCore->primaryMainWindow()->doc->Layers[lam].outlineMode); |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(i)); |
-} |
- |
-PyObject *scribus_islayerflow(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int i = 0; |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); lam++) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- i = static_cast<int>(ScCore->primaryMainWindow()->doc->Layers[lam].flowControl); |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(i)); |
-} |
- |
-PyObject *scribus_getlayerblendmode(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int i = 0; |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); lam++) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- i = ScCore->primaryMainWindow()->doc->Layers[lam].blendMode; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(i)); |
-} |
- |
-PyObject *scribus_getlayertransparency(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- double i = 1.0; |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); lam++) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- i = ScCore->primaryMainWindow()->doc->Layers[lam].transparency; |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyFloat_FromDouble(i); |
-} |
- |
-PyObject *scribus_deletelayer(PyObject* /* self */, PyObject* args) |
-{ |
-//FIXME: Use the docs remove layer code |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (ScCore->primaryMainWindow()->doc->Layers.count() == 1) |
- { |
- PyErr_SetString(ScribusException, QObject::tr("Cannot remove the last layer.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- bool found = false; |
- for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam) |
- { |
- if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == QString::fromUtf8(Name)) |
- { |
- ScLayer it2 = ScCore->primaryMainWindow()->doc->Layers.at(lam); |
- int num2 = it2.ID; |
- if (!num2) |
- { |
- // FIXME: WTF DOES THIS DO? |
- Py_INCREF(Py_None); |
- return Py_None; |
- } |
- ScCore->primaryMainWindow()->doc->removeLayer(num2); |
- ScCore->primaryMainWindow()->doc->Layers.removeLayerByID(num2); |
- ScCore->primaryMainWindow()->doc->setActiveLayer(0); |
- ScCore->primaryMainWindow()->changeLayer(0); |
- found = true; |
- break; |
- } |
- } |
- if (!found) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_createlayer(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strlen(Name) == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create layer without a name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->doc->addLayer(QString::fromUtf8(Name), true); |
- ScCore->primaryMainWindow()->changeLayer(ScCore->primaryMainWindow()->doc->activeLayer()); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_filequit(PyObject* /* self */, PyObject* args) |
-{ |
- QMetaObject::invokeMethod(ScCore->primaryMainWindow(), "slotFileQuit", Qt::QueuedConnection); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getlanguage(PyObject* /* self */) |
-{ |
- return PyString_FromString(ScCore->getGuiLanguage().toUtf8()); |
-} |
- |
-/*! 04.01.2007 : Joachim Neu : Moves item selection to front. */ |
-PyObject *scribus_moveselectiontofront(PyObject*) |
-{ |
- ScCore->primaryMainWindow()->doc->bringItemSelectionToFront(); |
- Py_RETURN_NONE; |
-} |
- |
-/*! 04.01.2007 : Joachim Neu : Moves item selection to back. */ |
-PyObject *scribus_moveselectiontoback(PyObject*) |
-{ |
- ScCore->primaryMainWindow()->doc->sendItemSelectionToBack(); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_savepdfoptions(PyObject* /* self */, PyObject* args) |
-{ |
- char* file; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (!PyArg_ParseTuple(args, const_cast<char*>("es"), "utf-8", &file)) |
- return nullptr; |
- |
- PDFOptionsIO io(ScCore->primaryMainWindow()->doc->pdfOptions()); |
- if (!io.writeTo(file)) |
- { |
- PyErr_SetString(ScribusException, io.lastError().toUtf8()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_readpdfoptions(PyObject* /* self */, PyObject* args) |
-{ |
- char* file; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (!PyArg_ParseTuple(args, const_cast<char*>("es"), "utf-8", &file)) |
- return nullptr; |
- |
- PDFOptionsIO io(ScCore->primaryMainWindow()->doc->pdfOptions()); |
- if (!io.readFrom(file)) |
- { |
- PyErr_SetString(ScribusException, io.lastError().toUtf8()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmdmiscdocwarnings() |
-{ |
- QStringList s; |
- s << scribus_createlayer__doc__ |
- << scribus_deletelayer__doc__ |
- << scribus_filequit__doc__ |
- << scribus_getfontnames__doc__ |
- << scribus_getactivelayer__doc__ |
- << scribus_getlanguage__doc__ |
- << scribus_getlayerblendmode__doc__ |
- << scribus_getlayers__doc__ |
- << scribus_getlayertransparency__doc__ |
- << scribus_islayerflow__doc__ |
- << scribus_islayerlocked__doc__ |
- << scribus_islayeroutlined__doc__ |
- << scribus_islayerprintable__doc__ |
- << scribus_islayervisible__doc__ |
- << scribus_loweractivelayer__doc__ |
- << scribus_moveselectiontoback__doc__ |
- << scribus_moveselectiontofront__doc__ |
- << scribus_raiseactivelayer__doc__ |
- << scribus_readpdfoptions__doc__ |
- << scribus_renderfont__doc__ |
- << scribus_savepdfoptions__doc__ |
- << scribus_sendtolayer__doc__ |
- << scribus_setactivelayer__doc__ |
- << scribus_setlayerblendmode__doc__ |
- << scribus_setlayerflow__doc__ |
- << scribus_setlayerlocked__doc__ |
- << scribus_setlayeroutlined__doc__ |
- << scribus_setlayerprintable__doc__ |
- << scribus_setlayertransparency__doc__ |
- << scribus_setlayervisible__doc__ |
- << scribus_setredraw__doc__ |
- << scribus_xfontnames__doc__; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmisc.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/objimageexport.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/objimageexport.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/objimageexport.cpp (nonexistent) |
@@ -1,270 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "objimageexport.h" |
- |
-#include <QImageWriter> |
-#include <structmember.h> |
-#include <QFileInfo> |
-#include <vector> |
- |
-#include "cmdutil.h" |
-#include "scpage.h" |
-#include "scribuscore.h" |
-#include "scribusdoc.h" |
-#include "scribusview.h" |
- |
-typedef struct |
-{ |
- PyObject_HEAD |
- PyObject *name; // string - filename |
- PyObject *type; // string - image type (PNG, JPEG etc.) |
- PyObject *allTypes; // list - available types |
- int dpi; // DPI of the bitmap |
- int scale; // how is bitmap scaled 100 = 100% |
- int quality; // quality/compression <1; 100> |
- int transparentBkgnd; // background transparency |
-} ImageExport; |
- |
-static void ImageExport_dealloc(ImageExport* self) |
-{ |
- Py_XDECREF(self->name); |
- Py_XDECREF(self->type); |
- Py_XDECREF(self->allTypes); |
- self->ob_type->tp_free((PyObject *)self); |
-} |
- |
-static PyObject * ImageExport_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- ImageExport *self; |
- self = (ImageExport *)type->tp_alloc(type, 0); |
- if (self != nullptr) { |
- self->name = PyString_FromString("ImageExport.png"); |
- self->type = PyString_FromString("PNG"); |
- self->allTypes = PyList_New(0); |
- self->dpi = 72; |
- self->scale = 100; |
- self->quality = 100; |
- self->transparentBkgnd = 0; |
- } |
- return (PyObject *) self; |
-} |
- |
-static int ImageExport_init(ImageExport * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/) |
-{ |
- return 0; |
-} |
- |
-static PyMemberDef ImageExport_members[] = { |
- {const_cast<char*>("dpi"), T_INT, offsetof(ImageExport, dpi), 0, imgexp_dpi__doc__}, |
- {const_cast<char*>("scale"), T_INT, offsetof(ImageExport, scale), 0, imgexp_scale__doc__}, |
- {const_cast<char*>("quality"), T_INT, offsetof(ImageExport, quality), 0, imgexp_quality__doc__}, |
- {const_cast<char*>("transparentBkgnd"), T_INT, offsetof(ImageExport, transparentBkgnd), 0, imgexp_transparentBkgnd__doc__}, |
- {nullptr, 0, 0, 0, nullptr} // sentinel |
-}; |
- |
-static PyObject *ImageExport_getName(ImageExport *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->name); |
- return self->name; |
-} |
- |
-static int ImageExport_setName(ImageExport *self, PyObject *value, void * /*closure*/) |
-{ |
- if (!PyString_Check(value)) { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("The filename must be a string.", "python error").toLocal8Bit().constData()); |
- return -1; |
- } |
- if (PyString_Size(value) < 1) |
- { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("The filename should not be empty string.", "python error").toLocal8Bit().constData()); |
- return -1; |
- } |
- Py_DECREF(self->name); |
- Py_INCREF(value); |
- self->name = value; |
- return 0; |
-} |
- |
-static PyObject *ImageExport_getType(ImageExport *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->type); |
- return self->type; |
-} |
- |
-static int ImageExport_setType(ImageExport *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("Cannot delete image type settings.", "python error").toLocal8Bit().constData()); |
- return -1; |
- } |
- if (!PyString_Check(value)) { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("The image type must be a string.", "python error").toLocal8Bit().constData()); |
- return -1; |
- } |
- Py_DECREF(self->type); |
- Py_INCREF(value); |
- self->type = value; |
- return 0; |
-} |
- |
-static PyObject *ImageExport_getAllTypes(ImageExport * /*self*/, void * /*closure*/) |
-{ |
- PyObject *l; |
- int pos = 0; |
- QList<QByteArray> list = QImageWriter::supportedImageFormats(); |
- l = PyList_New(list.count()); |
- for (QList<QByteArray>::Iterator it = list.begin(); it != list.end(); ++it) |
- { |
- PyList_SetItem(l, pos, PyString_FromString(QString((*it)).toLatin1().constData())); |
- ++pos; |
- } |
- return l; |
-} |
- |
-static int ImageExport_setAllTypes(ImageExport * /*self*/, PyObject * /*value*/, void * /*closure*/) |
-{ |
- PyErr_SetString(PyExc_ValueError, QObject::tr("'allTypes' attribute is READ-ONLY", "python error").toLocal8Bit().constData()); |
- return -1; |
-} |
- |
-static PyGetSetDef ImageExport_getseters [] = { |
- {const_cast<char*>("name"), (getter)ImageExport_getName, (setter)ImageExport_setName, imgexp_filename__doc__, nullptr}, |
- {const_cast<char*>("type"), (getter)ImageExport_getType, (setter)ImageExport_setType, imgexp_type__doc__, nullptr}, |
- {const_cast<char*>("allTypes"), (getter)ImageExport_getAllTypes, (setter)ImageExport_setAllTypes, imgexp_alltypes__doc__, nullptr}, |
- {nullptr, nullptr, nullptr, nullptr, nullptr} // sentinel |
-}; |
- |
-static PyObject *ImageExport_save(ImageExport *self) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* doc = ScCore->primaryMainWindow()->doc; |
- ScribusView*view = ScCore->primaryMainWindow()->view; |
- |
- /* a little magic here - I need to compute the "maxGr" value... |
- * We need to know the right size of the page for landscape, |
- * portrait and user defined sizes. |
- */ |
- double pixmapSize = (doc->pageHeight() > doc->pageWidth()) ? doc->pageHeight() : doc->pageWidth(); |
- PageToPixmapFlags flags = Pixmap_DrawBackground; |
- if (self->transparentBkgnd) |
- flags &= ~Pixmap_DrawBackground; |
- QImage im = view->PageToPixmap(doc->currentPage()->pageNr(), qRound(pixmapSize * self->scale * (self->dpi / 72.0) / 100.0), flags); |
- int dpi = qRound(100.0 / 2.54 * self->dpi); |
- im.setDotsPerMeterY(dpi); |
- im.setDotsPerMeterX(dpi); |
- if (!im.save(PyString_AsString(self->name), PyString_AsString(self->type))) |
- { |
- PyErr_SetString(ScribusException, QObject::tr("Failed to export image", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
-// Py_INCREF(Py_True); // return True not None for backward compat |
- // return Py_True; |
-// Py_RETURN_TRUE; |
- return PyBool_FromLong(static_cast<long>(true)); |
-} |
- |
-static PyObject *ImageExport_saveAs(ImageExport *self, PyObject *args) |
-{ |
- char* value; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (!PyArg_ParseTuple(args, const_cast<char*>("es"), "utf-8", &value)) |
- return nullptr; |
- |
- ScribusDoc* doc = ScCore->primaryMainWindow()->doc; |
- ScribusView*view = ScCore->primaryMainWindow()->view; |
- |
- /* a little magic here - I need to compute the "maxGr" value... |
- * We need to know the right size of the page for landscape, |
- * portrait and user defined sizes. |
- */ |
- double pixmapSize = (doc->pageHeight() > doc->pageWidth()) ? doc->pageHeight() : doc->pageWidth(); |
- PageToPixmapFlags flags = Pixmap_DrawBackground; |
- if (self->transparentBkgnd) |
- flags &= ~Pixmap_DrawBackground; |
- QImage im = view->PageToPixmap(doc->currentPage()->pageNr(), qRound(pixmapSize * self->scale * (self->dpi / 72.0) / 100.0), flags); |
- int dpi = qRound(100.0 / 2.54 * self->dpi); |
- im.setDotsPerMeterY(dpi); |
- im.setDotsPerMeterX(dpi); |
- if (!im.save(value, PyString_AsString(self->type))) |
- { |
- PyErr_SetString(ScribusException, QObject::tr("Failed to export image", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
-// Py_INCREF(Py_True); // return True not None for backward compat |
- // return Py_True; |
-// Py_RETURN_TRUE; |
- return PyBool_FromLong(static_cast<long>(true)); |
-} |
- |
-static PyMethodDef ImageExport_methods[] = { |
- {const_cast<char*>("save"), (PyCFunction)ImageExport_save, METH_NOARGS, imgexp_save__doc__}, |
- {const_cast<char*>("saveAs"), (PyCFunction)ImageExport_saveAs, METH_VARARGS, imgexp_saveas__doc__}, |
- {nullptr, (PyCFunction)(nullptr), 0, nullptr} // sentinel |
-}; |
- |
-PyTypeObject ImageExport_Type = { |
- PyObject_HEAD_INIT(nullptr) // PyObject_VAR_HEAD |
- 0, |
- const_cast<char*>("scribus.ImageExport"), // char *tp_name; /* For printing, in format "<module>.<name>" */ |
- sizeof(ImageExport), // int tp_basicsize, /* For allocation */ |
- 0, // int tp_itemsize; /* For allocation */ |
- (destructor) ImageExport_dealloc, // destructor tp_dealloc; |
- nullptr, // printfunc tp_print; |
- nullptr, // getattrfunc tp_getattr; |
- nullptr, // setattrfunc tp_setattr; |
- nullptr, // cmpfunc tp_compare; |
- nullptr, // reprfunc tp_repr; |
- nullptr, // PyNumberMethods *tp_as_number; |
- nullptr, // PySequenceMethods *tp_as_sequence; |
- nullptr, // PyMappingMethods *tp_as_mapping; |
- nullptr, // hashfunc tp_hash; |
- nullptr, // ternaryfunc tp_call; |
- nullptr, // reprfunc tp_str; |
- nullptr, // getattrofunc tp_getattro; |
- nullptr, // setattrofunc tp_setattro; |
- nullptr, // PyBufferProcs *tp_as_buffer; |
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, // long tp_flags; |
- imgexp__doc__, // char *tp_doc; /* Documentation string */ |
- nullptr, // traverseproc tp_traverse; |
- nullptr, // inquiry tp_clear; |
- nullptr, // richcmpfunc tp_richcompare; |
- 0, // long tp_weaklistoffset; |
- nullptr, // getiterfunc tp_iter; |
- nullptr, // iternextfunc tp_iternext; |
- ImageExport_methods, // struct PyMethodDef *tp_methods; |
- ImageExport_members, // struct PyMemberDef *tp_members; |
- ImageExport_getseters, // struct PyGetSetDef *tp_getset; |
- nullptr, // struct _typeobject *tp_base; |
- nullptr, // PyObject *tp_dict; |
- nullptr, // descrgetfunc tp_descr_get; |
- nullptr, // descrsetfunc tp_descr_set; |
- 0, // long tp_dictoffset; |
- (initproc)ImageExport_init, // initproc tp_init; |
- nullptr, // allocfunc tp_alloc; |
- ImageExport_new, // newfunc tp_new; |
- nullptr, // freefunc tp_free; /* Low-level free-memory routine */ |
- nullptr, // inquiry tp_is_gc; /* For PyObject_IS_GC */ |
- nullptr, // PyObject *tp_bases; |
- nullptr, // PyObject *tp_mro; /* method resolution order */ |
- nullptr, // PyObject *tp_cache; |
- nullptr, // PyObject *tp_subclasses; |
- nullptr, // PyObject *tp_weaklist; |
- nullptr, // destructor tp_del; |
- |
-#ifdef COUNT_ALLOCS |
- /* these must be last and never explicitly initialized */ |
- // int tp_allocs; |
- // int tp_frees; |
- // int tp_maxalloc; |
- // struct _typeobject *tp_next; |
-#endif |
-}; |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/objimageexport.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdsetprop.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdsetprop.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdsetprop.cpp (nonexistent) |
@@ -1,566 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "cmdsetprop.h" |
-#include "cmdutil.h" |
-#include "scribuscore.h" |
-#include "scribusdoc.h" |
- |
-PyObject *scribus_setgradfill(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Color1; |
- char *Color2; |
- int typ, shade1, shade2; |
- if (!PyArg_ParseTuple(args, "iesiesi|es", &typ, "utf-8", &Color1, &shade1, "utf-8", &Color2, &shade2, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((shade1 < 0) || (shade1 > 100) || (shade2 < 0) || (shade2 > 100)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Stop shade out of bounds, must be 0 <= shade <= 100.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name)); |
- if (currItem == nullptr) |
- return nullptr; |
- QColor tmp; |
- currItem->fill_gradient.clearStops(); |
- QString c1 = QString::fromUtf8(Color1); |
- QString c2 = QString::fromUtf8(Color2); |
- currItem->SetQColor(&tmp, c1, shade1); |
- currItem->fill_gradient.addStop(tmp, 0.0, 0.5, 1.0, c1, shade1); |
- currItem->SetQColor(&tmp, c2, shade2); |
- currItem->fill_gradient.addStop(tmp, 1.0, 0.5, 1.0, c2, shade2); |
- currItem->GrType = typ; |
- switch (currItem->GrType) |
- { |
- case 0: |
- case 1: |
- currItem->GrStartX = 0; |
- currItem->GrStartY = currItem->height() / 2.0; |
- currItem->GrEndX = currItem->width(); |
- currItem->GrEndY = currItem->height() / 2.0; |
- break; |
- case 2: |
- currItem->GrStartX = currItem->width() / 2.0; |
- currItem->GrStartY = 0; |
- currItem->GrEndX = currItem->width() / 2.0; |
- currItem->GrEndY = currItem->height(); |
- break; |
- case 3: |
- currItem->GrStartX = 0; |
- currItem->GrStartY = 0; |
- currItem->GrEndX = currItem->width(); |
- currItem->GrEndY = currItem->height(); |
- break; |
- case 4: |
- currItem->GrStartX = 0; |
- currItem->GrStartY = currItem->height(); |
- currItem->GrEndX = currItem->width(); |
- currItem->GrEndY = 0; |
- break; |
- case 5: |
- currItem->GrStartX = currItem->width() / 2.0; |
- currItem->GrStartY = currItem->height() / 2.0; |
- if (currItem->width() >= currItem->height()) |
- { |
- currItem->GrEndX = currItem->width(); |
- currItem->GrEndY = currItem->height() / 2.0; |
- } |
- else |
- { |
- currItem->GrEndX = currItem->width() / 2.0; |
- currItem->GrEndY = currItem->height(); |
- } |
- break; |
- default: |
- break; |
- } |
- //ScCore->primaryMainWindow()->view->updateGradientVectors(currItem); |
- currItem->updateGradientVectors(); |
- currItem->update(); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setgradstop(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Color1; |
- int shade1; |
- double rampPoint, opacity; |
- if (!PyArg_ParseTuple(args, "esidd|es", "utf-8", &Color1, &shade1, &opacity, &rampPoint, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((shade1 < 0) || (shade1 > 100)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Stop shade out of bounds, must be 0 <= shade <= 100.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if ((rampPoint < 0.0) || (rampPoint > 1.0)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Ramp point out of bounds, must be 0 <= rampPoint <= 1.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if ((opacity < 0.0) || (opacity > 1.0)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Opacity out of bounds, must be 0 <= transparency <= 1.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name)); |
- if (currItem == nullptr) |
- return nullptr; |
- QColor tmp; |
- QString c1 = QString::fromUtf8(Color1); |
- currItem->SetQColor(&tmp, c1, shade1); |
- currItem->fill_gradient.setStop(tmp, rampPoint, 0.5, opacity, c1, shade1); |
- currItem->updateGradientVectors(); |
- currItem->update(); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setfillcolor(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Color; |
- if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Color, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->setFillColor(QString::fromUtf8(Color)); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setfilltrans(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double w; |
- if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((w < 0.0) || (w > 1.0)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Transparency out of bounds, must be 0 <= transparency <= 1.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->setFillTransparency(1.0 - w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setfillblend(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int w; |
- if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((w < 0) || (w > 15)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Blendmode out of bounds, must be 0 <= blendmode <= 15.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->setFillBlendmode(w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcustomlinestyle(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Style; |
- if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Style, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
- if (it == nullptr) |
- return nullptr; |
- QString qStyle = QString::fromUtf8(Style); |
- if (! ScCore->primaryMainWindow()->doc->docLineStyles.contains(qStyle)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Line Style not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- |
- } |
- it->setCustomLineStyle(qStyle); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlinecolor(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Color; |
- if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Color, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
- if (it == nullptr) |
- return nullptr; |
- it->setLineColor(QString::fromUtf8(Color)); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlinetrans(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double w; |
- if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((w < 0.0) || (w > 1.0)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Transparency out of bounds, must be 0 <= transparency <= 1.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->setLineTransparency(1.0 - w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlineblend(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int w; |
- if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((w < 0) || (w > 15)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Blendmode out of bounds, must be 0 <= blendmode <= 15.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->setLineBlendmode(w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlinewidth(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double w; |
- if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((w < 0.0) || (w > 300.0)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Line width out of bounds, must be 0 <= line_width <= 300.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->setLineWidth(w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlineshade(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int w; |
- if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((w < 0) || (w > 100)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Line shade out of bounds, must be 0 <= shade <= 100.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
- if (it == nullptr) |
- return nullptr; |
- it->setLineShade(w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setfillshade(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int w; |
- if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((w < 0) || (w > 100)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Fill shade out of bounds, must be 0 <= shade <= 100.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->setFillShade(w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlinejoin(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int w; |
- if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->PLineJoin = Qt::PenJoinStyle(w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlinecap(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int w; |
- if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->PLineEnd = Qt::PenCapStyle(w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setlinestyle(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int w; |
- if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- i->PLineArt = Qt::PenStyle(w); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcornerradius(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int w; |
- if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (w < 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Corner radius must be a positive number.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name)); |
- if (currItem == nullptr) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- // apply rounding |
- currItem->setCornerRadius(w); |
- currItem->SetFrameRound(); |
- currentDoc->setRedrawBounding(currItem); |
- currentDoc->setFrameRounded(); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setmultiline(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Style = nullptr; |
- if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Style, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name)); |
- if (currItem == nullptr) |
- return nullptr; |
- if (!ScCore->primaryMainWindow()->doc->docLineStyles.contains(QString::fromUtf8(Style))) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Line style not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- currItem->NamedLStyle = QString::fromUtf8(Style); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setitemname(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *newName = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es|es", "utf-8", &newName, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name)); |
- if (currItem == nullptr) |
- return nullptr; |
- currItem->setItemName(newName); |
- |
- return PyString_FromString(currItem->itemName().toUtf8()); |
-} |
- |
-PyObject *scribus_setobjectattributes(PyObject* /* self */, PyObject* args) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- char *Name = const_cast<char*>(""); |
- PyObject *attr; |
- if (!PyArg_ParseTuple(args, "O|es", &attr, "utf-8", &Name)) |
- return nullptr; |
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
- if (item == nullptr) |
- return nullptr; |
- |
- if (!PyList_Check(attr)) |
- { |
- PyErr_SetString(PyExc_TypeError, "argument must be list."); |
- return nullptr; |
- } |
- |
- ObjAttrVector attributes; |
- int n = PyList_Size(attr); |
- for (int i = 0; i < n; ++i) |
- { |
- PyObject *tmp = PyList_GetItem(attr, i); |
- if (!PyDict_Check(tmp)) |
- { |
- PyErr_SetString(PyExc_TypeError, "elements of 'attr' must be dictionary."); |
- return nullptr; |
- } |
- ObjectAttribute blank; |
- PyObject *val; |
- char* data; |
- |
- val = PyDict_GetItemString(tmp, "Name"); |
- if (!val) |
- { |
- PyErr_SetString(PyExc_TypeError, "attribute does not have 'Name' key."); |
- return nullptr; |
- } |
- data = PyString_AsString(val); |
- if (!data) |
- return nullptr; |
- blank.name = QString(data); |
- |
- val = PyDict_GetItemString(tmp, "Type"); |
- if (!val) |
- { |
- PyErr_SetString(PyExc_TypeError, "attribute does not have 'Type' key."); |
- return nullptr; |
- } |
- data = PyString_AsString(val); |
- if (!data) |
- return nullptr; |
- blank.type = QString(data); |
- |
- val = PyDict_GetItemString(tmp, "Value"); |
- if (!val) |
- { |
- PyErr_SetString(PyExc_TypeError, "attribute does not have 'Value' key."); |
- return nullptr; |
- } |
- data = PyString_AsString(val); |
- if (!data) |
- return nullptr; |
- blank.value = QString(data); |
- |
- val = PyDict_GetItemString(tmp, "Parameter"); |
- if (!val) |
- { |
- PyErr_SetString(PyExc_TypeError, "attribute does not have 'Parameter' key."); |
- return nullptr; |
- } |
- data = PyString_AsString(val); |
- if (!data) |
- return nullptr; |
- blank.parameter = QString(data); |
- |
- val = PyDict_GetItemString(tmp, "Relationship"); |
- if (!val) |
- { |
- PyErr_SetString(PyExc_TypeError, "attribute does not have 'Relationship' key."); |
- return nullptr; |
- } |
- data = PyString_AsString(val); |
- if (!data) |
- return nullptr; |
- blank.relationship = QString(data); |
- |
- val = PyDict_GetItemString(tmp, "RelationshipTo"); |
- if (!val) |
- { |
- PyErr_SetString(PyExc_TypeError, "attribute does not have 'RelationshipTo' key."); |
- return nullptr; |
- } |
- data = PyString_AsString(val); |
- if (!data) |
- return nullptr; |
- blank.relationshipto = QString(data); |
- |
- val = PyDict_GetItemString(tmp, "AutoAddTo"); |
- if (!val) |
- { |
- PyErr_SetString(PyExc_TypeError, "attribute does not have 'AutoAddTo' key."); |
- return nullptr; |
- } |
- data = PyString_AsString(val); |
- if (!data) |
- return nullptr; |
- blank.autoaddto = QString(data); |
- |
- attributes.append(blank); |
- } |
- |
- item->setObjectAttributes(&attributes); |
- Py_RETURN_NONE; |
-} |
- |
-/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmdsetpropdocwarnings() |
-{ |
- QStringList s; |
- s << scribus_setcornerradius__doc__ |
- << scribus_setcustomlinestyle__doc__ |
- << scribus_setfillblend__doc__ |
- << scribus_setfillcolor__doc__ |
- << scribus_setfillshade__doc__ |
- << scribus_setfilltrans__doc__ |
- << scribus_setgradfill__doc__ |
- << scribus_setgradstop__doc__ |
- << scribus_setitemname__doc__ |
- << scribus_setlineblend__doc__ |
- << scribus_setlinecap__doc__ |
- << scribus_setlinecolor__doc__ |
- << scribus_setlinejoin__doc__ |
- << scribus_setlineshade__doc__ |
- << scribus_setlinestyle__doc__ |
- << scribus_setlinetrans__doc__ |
- << scribus_setlinewidth__doc__ |
- << scribus_setmultiline__doc__ |
- << scribus_setobjectattributes__doc__; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdsetprop.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdgetsetprop.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdgetsetprop.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdgetsetprop.cpp (nonexistent) |
@@ -1,487 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "cmdgetsetprop.h" |
-#include "cmdutil.h" |
- |
-#include <QMetaObject> |
-#include <QMetaProperty> |
-#include <QList> |
-#include <QObject> |
-#include <QObjectList> |
- |
-QObject* getQObjectFromPyArg(PyObject* arg) |
-{ |
- if (PyString_Check(arg)) |
- // It's a string. Look for a pageItem by that name. Do NOT accept a |
- // selection. |
- return getPageItemByName(QString::fromUtf8(PyString_AsString(arg))); |
- if (PyCObject_Check(arg)) |
- { |
- // It's a PyCObject, ie a wrapped pointer. Check it's not nullptr |
- // and return it. |
- // FIXME: Try to check that its a pointer to a QObject instance |
- QObject* tempObject = (QObject*)PyCObject_AsVoidPtr(arg); |
- if (!tempObject) |
- { |
- PyErr_SetString(PyExc_TypeError, "INTERNAL: Passed nullptr PyCObject"); |
- return nullptr; |
- } |
- return tempObject; |
- } |
- // It's not a type we know what to do with |
- PyErr_SetString(PyExc_TypeError, QObject::tr("Argument must be page item name, or PyCObject instance").toLocal8Bit().constData()); |
- return nullptr; |
-} |
- |
- |
-PyObject* wrapQObject(QObject* obj) |
-{ |
- return PyCObject_FromVoidPtr((void*)obj, nullptr); |
-} |
- |
- |
-const char* getpropertytype(QObject* obj, const char* propname, bool includesuper) |
-{ |
- const QMetaObject* objmeta = obj->metaObject(); |
- int i = objmeta->indexOfProperty(propname); |
- if (i == -1) |
- return nullptr; |
- QMetaProperty propmeta = objmeta->property(i); |
- if (!propmeta.isValid()) |
- return nullptr; |
- const char* type = propmeta.typeName(); |
- return type; |
-} |
- |
- |
-PyObject* scribus_propertyctype(PyObject* /*self*/, PyObject* args, PyObject* kw) |
-{ |
- PyObject* objArg = nullptr; |
- char* propertyname = nullptr; |
- int includesuper = 1; |
- char* kwargs[] = {const_cast<char*>("object"), |
- const_cast<char*>("property"), |
- const_cast<char*>("includesuper"), |
- nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "Oes|i", kwargs, |
- &objArg, "ascii", &propertyname, &includesuper)) |
- return nullptr; |
- |
- // Get the QObject* the object argument refers to |
- QObject* obj = getQObjectFromPyArg(objArg); |
- if (!obj) |
- return nullptr; |
- objArg = nullptr; // no need to decref, it's borrowed |
- |
- // Look up the property and retrieve its type information |
- const char* type = getpropertytype( (QObject*)obj, propertyname, includesuper); |
- if (type == nullptr) |
- { |
- PyErr_SetString(PyExc_KeyError, QObject::tr("Property not found").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyString_FromString(type); |
-} |
- |
-PyObject* convert_QStringList_to_PyListObject(QStringList& origlist) |
-{ |
- PyObject* resultList = PyList_New(0); |
- if (!resultList) |
- return nullptr; |
- |
- for ( QStringList::Iterator it = origlist.begin(); it != origlist.end(); ++it ) |
- if (PyList_Append(resultList, PyString_FromString((*it).toUtf8().data())) == -1) |
- return nullptr; |
- |
- return resultList; |
-} |
- |
- |
-PyObject* convert_QObjectList_to_PyListObject(QObjectList* origlist) |
-{ |
- PyObject* resultList = PyList_New(0); |
- if (!resultList) |
- return nullptr; |
- |
- PyObject* objPtr = nullptr; |
- // Loop over the objects in the list and add them to the python |
- // list wrapped in PyCObjects . |
- for (int i = 0; i < origlist->count(); ++i) |
- { |
- // Wrap up the object pointer |
- objPtr = wrapQObject(origlist->at(i)); |
- if (!objPtr) |
- { |
- // Failed to wrap the object. An exception is already set. |
- Py_DECREF(resultList); |
- return nullptr; |
- } |
- // and add it to the list |
- if (PyList_Append(resultList, (PyObject*)objPtr) == -1) |
- return nullptr; |
- } |
- return resultList; |
-} |
- |
-/*Qt4 we either need to copy QObject::qChildHelper or rewrite this |
- |
-PyObject* scribus_getchildren(PyObject* , PyObject* args, PyObject* kw) |
-{ |
- PyObject* objArg = nullptr; |
- char* ofclass = nullptr; |
- char* ofname = nullptr; |
- int recursive = 0; |
- int regexpmatch = 0; |
- char* kwnames[] = {const_cast<char*>("object"), |
- const_cast<char*>("ofclass"), |
- const_cast<char*>("ofname"), |
- const_cast<char*>("regexpmatch"), |
- const_cast<char*>("recursive"), |
- nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "O|esesii", kwnames, |
- &objArg, "ascii", &ofclass, "ascii", &ofname, ®expmatch, &recursive)) |
- return nullptr; |
- |
- // Get the QObject* the object argument refers to |
- QObject* obj = getQObjectFromPyArg(objArg); |
- if (!obj) |
- return nullptr; |
- objArg = nullptr; // no need to decref, it's borrowed |
- |
- // Our job is to return a Python list containing the children of this |
- // widget (as PyCObjects). |
-//qt4 FIXME QObjectList* children; |
-//qt4 FIXME children = obj->queryList(ofclass, ofname, regexpmatch, recursive); |
- PyObject* itemlist = 0; |
-//qt4 FIXME itemlist = convert_QObjectList_to_PyListObject(children); |
-//qt4 FIXME delete children; |
- return itemlist; |
-} |
- |
- |
-// Perform a recursive (by default) search for the named child, possibly of a |
-// select class. |
-PyObject* scribus_getchild(PyObject* , PyObject* args, PyObject* kw) |
-{ |
- PyObject* objArg = nullptr; |
- char* childname = nullptr; |
- char* ofclass = nullptr; |
- bool recursive = true; |
- char* kwnames[] = {const_cast<char*>("object"), |
- const_cast<char*>("childname"), |
- const_cast<char*>("ofclass"), |
- const_cast<char*>("recursive"), |
- nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "Oes|esi", kwnames, |
- &objArg, "ascii", &childname, "ascii", &ofclass, &recursive)) |
- return nullptr; |
- |
- // Get the QObject* the object argument refers to |
- QObject* obj = getQObjectFromPyArg(objArg); |
- if (!obj) |
- return nullptr; |
- objArg = nullptr; // no need to decref, it's borrowed |
- |
- // Search for the child, possibly restricting the search to children |
- // of a particular type, and possibly recursively searching through |
- // grandchildren etc. |
- QObject* child = obj->child(childname, ofclass, recursive); |
- if (child == nullptr) |
- { |
- PyErr_SetString(PyExc_KeyError, QObject::tr("Child not found").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- return wrapQObject(child); |
-} |
-*/ |
- |
-PyObject* scribus_getpropertynames(PyObject* /*self*/, PyObject* args, PyObject* kw) |
-{ |
- PyObject* objArg = nullptr; |
- int includesuper = 1; |
- char* kwargs[] = {const_cast<char*>("object"), |
- const_cast<char*>("includesuper"), |
- nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "O|i", kwargs, |
- &objArg, &includesuper)) |
- return nullptr; |
- |
- // Get the QObject* the object argument refers to |
- QObject* obj = getQObjectFromPyArg(objArg); |
- if (!obj) |
- return nullptr; |
- objArg = nullptr; // no need to decref, it's borrowed |
- |
- // Retrieve the object's meta object so we can query it |
- const QMetaObject* objmeta = obj->metaObject(); |
- if (!objmeta) |
- return nullptr; |
- |
- // Return the list of properties |
- QStringList propertyNames; |
- int propertyOffset = includesuper ? 0 : objmeta->propertyOffset(); |
- for (int i = propertyOffset; i < objmeta->propertyCount(); ++i) |
- propertyNames << QString::fromLatin1(objmeta->property(i).name()); |
- |
- return convert_QStringList_to_PyListObject(propertyNames); |
-} |
- |
- |
-PyObject* scribus_getproperty(PyObject* /*self*/, PyObject* args, PyObject* kw) |
-{ |
- PyObject* objArg = nullptr; |
- char* propertyName = nullptr; |
- char* kwargs[] = {const_cast<char*>("object"), |
- const_cast<char*>("property"), |
- nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "Oes", kwargs, |
- &objArg, "ascii", &propertyName)) |
- return nullptr; |
- |
- // Get the QObject* the object argument refers to |
- QObject* obj = getQObjectFromPyArg(objArg); |
- if (!obj) |
- return nullptr; |
- objArg = nullptr; // no need to decref, it's borrowed |
- |
- // Get the QMetaProperty for the property, so we can check |
- // if it's a set/enum and do name/value translation. |
- const QMetaObject* objmeta = obj->metaObject(); |
- int i = objmeta->indexOfProperty(propertyName); |
- if (i == -1) |
- { |
- PyErr_SetString(PyExc_ValueError, |
- QObject::tr("Property not found").toLocal8Bit().data()); |
- return nullptr; |
- } |
- |
- QMetaProperty propmeta = objmeta->property(i); |
- if (!propmeta.isValid()) |
- { |
- PyErr_SetString(PyExc_ValueError, |
- QObject::tr("Invalid property").toLocal8Bit().data()); |
- return nullptr; |
- } |
- |
- // Get the property value as a variant type |
- QVariant prop = obj->property(propertyName); |
- |
- // Convert the property to an instance of the closest matching Python type. |
- PyObject* resultobj = nullptr; |
- // NUMERIC TYPES |
- if (prop.type() == QVariant::Int) |
- resultobj = PyLong_FromLong(prop.toInt()); |
- else if (prop.type() == QVariant::Double) |
- resultobj = PyFloat_FromDouble(prop.toDouble()); |
- // BOOLEAN |
- else if (prop.type() == QVariant::Bool) |
- resultobj = PyBool_FromLong(prop.toBool()); |
- // STRING TYPES |
- else if (prop.type() == QVariant::ByteArray) |
- resultobj = PyString_FromString(prop.toByteArray().data()); |
- else if (prop.type() == QVariant::String) |
- resultobj = PyString_FromString(prop.toString().toUtf8().data()); |
- // HIGHER ORDER TYPES |
- else if (prop.type() == QVariant::Point) |
- { |
- // Return a QPoint as an (x,y) tuple. |
- QPoint pt = prop.toPoint(); |
- return Py_BuildValue("(ii)", pt.x(), pt.y()); |
- } |
- else if (prop.type() == QVariant::Rect) |
- { |
- // Return a QRect as an (x,y,width,height) tuple. |
- // FIXME: We should really construct and return an object that |
- // matches the API of QRect and has properties to keep |
- // left/top/right/bottom and x/y/width/height in sync. |
- QRect r = prop.toRect(); |
- return Py_BuildValue("(iiii)", r.x(), r.y(), r.width(), r.height()); |
- } |
- else if (prop.type() == QVariant::StringList) |
- { |
- QStringList tmp = prop.toStringList(); |
- return convert_QStringList_to_PyListObject(tmp); |
- } |
- // UNHANDLED TYPE |
- else |
- { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("Couldn't convert result type '%1'.").arg(prop.typeName()).toLocal8Bit().constData() ); |
- return resultobj; |
- } |
- |
- // Return the resulting Python object |
- if (resultobj == nullptr) |
- { |
- // An exception was set while assigning to resultobj |
- assert(PyErr_Occurred()); |
- return nullptr; |
- } |
- return resultobj; |
-} |
- |
- |
- |
-PyObject* scribus_setproperty(PyObject* /*self*/, PyObject* args, PyObject* kw) |
-{ |
- PyObject* objArg = nullptr; |
- char* propertyName = nullptr; |
- PyObject* objValue = nullptr; |
- char* kwargs[] = {const_cast<char*>("object"), |
- const_cast<char*>("property"), |
- const_cast<char*>("value"), |
- nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "OesO", kwargs, |
- &objArg, "ascii", &propertyName, &objValue)) |
- return nullptr; |
- |
- // We're going to hang on to the value object for a while, so |
- // claim a reference to it. |
- Py_INCREF(objValue); |
- |
- // Get the QObject* the object argument refers to |
- QObject* obj = getQObjectFromPyArg(objArg); |
- if (!obj) |
- return nullptr; |
- objArg = nullptr; // no need to decref, it's borrowed |
- |
- const char* propertyTypeName = getpropertytype(obj, propertyName, true); |
- if (propertyTypeName == nullptr) |
- return nullptr; |
- QString propertyType = QString::fromLatin1(propertyTypeName); |
- |
- // Did we know how to convert the value argument to the right type? |
- bool matched = false; |
- // Did the set call succceed? |
- bool success = false; |
- |
- // Check the C++ type of the property, and try to convert the passed |
- // PyObject to something sensible looking for it. |
- // FIXME: handle enums/sets |
- // NUMERIC TYPES |
- // These are unfortuately a TOTAL PITA because of the multitude of |
- // C and Python numeric types. TODO This needs to be broken out into a subroutine. |
- if (propertyType == "bool") |
- { |
- matched = true; |
- if (PyObject_IsTrue(objValue) == 0) |
- success = obj->setProperty(propertyName, 0); |
- else if (PyObject_IsTrue(objValue) == 1) |
- success = obj->setProperty(propertyName, 1); |
- else if (PyInt_Check(objValue)) |
- success = obj->setProperty(propertyName, PyInt_AsLong(objValue) == 0); |
- else if (PyLong_Check(objValue)) |
- success = obj->setProperty(propertyName, PyLong_AsLong(objValue) == 0); |
- else |
- matched = false; |
- } |
- else if (propertyType == "int") |
- { |
- matched = true; |
- if (PyInt_Check(objValue)) |
- success = obj->setProperty(propertyName, (int)PyInt_AsLong(objValue)); |
- else if (PyLong_Check(objValue)) |
- success = obj->setProperty(propertyName, (int)PyLong_AsLong(objValue)); |
- else |
- matched = false; |
- } |
- else if (propertyType == "double") |
- { |
- matched = true; |
- // FIXME: handle int, long and bool too |
- if (PyFloat_Check(objValue)) |
- success = obj->setProperty(propertyName, PyFloat_AsDouble(objValue)); |
- else |
- matched = false; |
- } |
- // STRING TYPES |
- else if (propertyType == "QString") |
- { |
- matched = true; |
- if (PyString_Check(objValue)) |
- success = obj->setProperty(propertyName, QString::fromUtf8(PyString_AsString(objValue))); |
- else if (PyUnicode_Check(objValue)) |
- { |
- // Get a pointer to the internal buffer of the Py_Unicode object, which is UCS2 formatted |
- const unsigned short * ucs2Data = (const unsigned short *)PyUnicode_AS_UNICODE(objValue); |
- // and make a new QString from it (the string is copied) |
- success = obj->setProperty(propertyName, QString::fromUtf16(ucs2Data)); |
- } |
- else |
- matched = false; |
- } |
- else if (propertyType == "QCString") |
- { |
- matched = true; |
- if (PyString_Check(objValue)) |
- { |
- // FIXME: should raise an exception instead of mangling the string when |
- // out of charset chars present. |
- QString utfString = QString::fromUtf8(PyString_AsString(objValue)); |
- success = obj->setProperty(propertyName, utfString.toLatin1()); |
- } |
- else if (PyUnicode_Check(objValue)) |
- { |
- // Get a pointer to the internal buffer of the Py_Unicode object, which is UCS2 formatted |
- const unsigned short * utf16Data = (const unsigned short *)PyUnicode_AS_UNICODE(objValue); |
- // and make a new QString from it (the string is copied) |
- success = obj->setProperty(propertyName, QString::fromUtf16(utf16Data).toLatin1()); |
- } |
- else |
- matched = false; |
- } |
- // HIGHER ORDER TYPES |
- // ... which I can't be stuffed supporting yet. FIXME. |
- else |
- { |
- Py_DECREF(objValue); |
- PyErr_SetString(PyExc_TypeError, |
- QObject::tr("Property type '%1' not supported").arg(propertyType).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- // If `matched' is false, we recognised the C type but weren't able to |
- // convert the passed Python value to anything suitable. |
- if (!matched) |
- { |
- // Get a string representation of the object |
- PyObject* objRepr = PyObject_Repr(objValue); |
- Py_DECREF(objValue); // We're done with it now |
- if (!objRepr) |
- return nullptr; |
- // Extract the repr() string |
- QString reprString = QString::fromUtf8(PyString_AsString(objRepr)); |
- Py_DECREF(objRepr); |
- |
- // And return an error |
- PyErr_SetString(PyExc_TypeError, QObject::tr("Couldn't convert '%1' to property type '%2'").arg(reprString, propertyType).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- // `success' is the return value of the setProperty() call |
- if (!success) |
- { |
- Py_DECREF(objValue); |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Types matched, but setting property failed.").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- Py_DECREF(objValue); |
- Py_RETURN_NONE; |
-} |
- |
-/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmdgetsetpropdocwarnings() |
-{ |
- QStringList s; |
- s << scribus_getproperty__doc__ |
- << scribus_getpropertynames__doc__ |
- << scribus_propertyctype__doc__ |
- << scribus_setproperty__doc__; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdgetsetprop.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtable.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtable.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtable.h (nonexistent) |
@@ -1,241 +0,0 @@ |
-/* |
- * Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com> |
- * |
- * For general Scribus (>=1.3.2) copyright and licensing information please refer |
- * to the COPYING file provided with the program. Following this notice may exist |
- * a copyright and/or license notice that predates the release of Scribus 1.3.2 |
- * for which a new license (GPL+exception) is in place. |
- */ |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-/*! Table handling */ |
- |
-#ifndef CMDTABLE_H |
-#define CMDTABLE_H |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettablerows__doc__, |
-QT_TR_NOOP("getTableRows([\"name\"]) -> integer\n\ |
-\n\ |
-Gets the number of rows in the table \"name\". If \"name\" is not\n\ |
-given the currently selected item is used.\n\ |
-")); |
-/*! Get number of table rows */ |
-PyObject *scribus_gettablerows(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettablecolumns__doc__, |
-QT_TR_NOOP("getTableColumns([\"name\"]) -> integer\n\ |
-\n\ |
-Gets the number of columns in the table \"name\". If \"name\" is not\n\ |
-given the currently selected item is used.\n\ |
-")); |
-/*! Get number of table columns */ |
-PyObject *scribus_gettablecolumns(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_inserttablerows__doc__, |
-QT_TR_NOOP("insertTableRows(index, numRows, [\"name\"])\n\ |
-\n\ |
-Inserts \"numRows\" rows before the row at \"index\" in the table \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if number of rows is not at least one or index is out of bounds.\n\ |
-")); |
-/*! Insert table rows */ |
-PyObject *scribus_inserttablerows(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_removetablerows__doc__, |
-QT_TR_NOOP("removeTableRows(index, numRows, [\"name\"])\n\ |
-\n\ |
-Removes \"numRows\" rows from the table \"name\" starting with the row at \"index\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if number of rows is not at least one or the range to be deleted is out of bounds.\n\ |
-")); |
-/*! Remove table rows */ |
-PyObject *scribus_removetablerows(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettablerowheight__doc__, |
-QT_TR_NOOP("getTableRowHeight(row, [\"name\"]) -> float\n\ |
-\n\ |
-Returns the row height of \"row\" in the table \"name\" expressed in\n\ |
-points, or 0.0 if the row does not exist. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-")); |
-/*! Get table row height */ |
-PyObject *scribus_gettablerowheight(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_resizetablerow__doc__, |
-QT_TR_NOOP("resizeTableRow(row, height, [\"name\"])\n\ |
-\n\ |
-Resizes \"row\" to \"height\" in the table \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the height is less than 0 or the row does not exist.\n\ |
-")); |
-/*! Resize table row */ |
-PyObject *scribus_resizetablerow(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_inserttablecolumns__doc__, |
-QT_TR_NOOP("insertTableColumns(index, numColumns, [\"name\"])\n\ |
-\n\ |
-Inserts \"numColumns\" columns before the column at \"index\" in the table \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if number of columns is not at least one or index is out of bounds.\n\ |
-")); |
-/*! Insert table columns */ |
-PyObject *scribus_inserttablecolumns(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_removetablecolumns__doc__, |
-QT_TR_NOOP("removeTableColumns(index, numColumns, [\"name\"])\n\ |
-\n\ |
-Removes \"numColumns\" columns from the table \"name\" starting with the column at \"index\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if number of columns is not at least one or the range to be deleted is out of bounds.\n\ |
-")); |
-/*! Remove table columns */ |
-PyObject *scribus_removetablecolumns(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettablecolumnwidth__doc__, |
-QT_TR_NOOP("getTableColumnWidth(column, [\"name\"]) -> float\n\ |
-\n\ |
-Returns the column width of \"column\" in the table \"name\" expressed in\n\ |
-points, or 0.0 if the column does not exist. If \"name\" is not given the currently\n\ |
-selected item is used.\n\ |
-")); |
-/*! Get table column width */ |
-PyObject *scribus_gettablecolumnwidth(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_resizetablecolumn__doc__, |
-QT_TR_NOOP("resizeTableColumn(column, width, [\"name\"])\n\ |
-\n\ |
-Resizes \"column\" to \"width\" in the table \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if the width is less than 0 or the column does not exist.\n\ |
-")); |
-/*! Resize table column */ |
-PyObject *scribus_resizetablecolumn(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_mergetablecells__doc__, |
-QT_TR_NOOP("mergeTableCells(row, column, numRows, numColumns, [\"name\"])\n\ |
-\n\ |
-Merges the cell at the specified \"row\" and \"column\" with the adjacent cells into one cell.\n\ |
-\n\ |
-May throw ValueError if number if numRows or numColumns is less than 1 or the specified area is out of bounds.\n\ |
-")); |
-/*! Merge table cells */ |
-PyObject *scribus_mergetablecells(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettablestyle__doc__, |
-QT_TR_NOOP("getTableStyle([\"name\"]) -> string\n\ |
-\n\ |
-Returns the named style of the table \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get table style */ |
-PyObject *scribus_gettablestyle(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settablestyle__doc__, |
-QT_TR_NOOP("setTableStyle(style, [\"name\"])\n\ |
-\n\ |
-Sets the named style of the table \"name\" to \"style\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Set table style */ |
-PyObject *scribus_settablestyle(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettablefillcolor__doc__, |
-QT_TR_NOOP("getTableFillColor([\"name\"]) -> string\n\ |
-\n\ |
-Returns the fill color of the table \"name\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-")); |
-/*! Get table fill color */ |
-PyObject *scribus_gettablefillcolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settablefillcolor__doc__, |
-QT_TR_NOOP("setTableFillColor(color, [\"name\"])\n\ |
-\n\ |
-Sets the fill color of the table \"name\" to \"color\".\n\ |
-If \"name\" is not given the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError the table does not exist.\n\ |
-")); |
-/*! Set table fill color */ |
-PyObject *scribus_settablefillcolor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settableleftborder__doc__, |
-QT_TR_NOOP("setTableLeftBorder(borderLines, [\"name\"])\n\ |
-\n\ |
-Sets the left border of the table \"name\".\n\ |
-The border is specified as a list of \"(width, style, color)\" tuples.\n\ |
-\"style\" is one of the LINE_* constants. If \"name\" is not given\n\ |
-the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if \"borderLines\" is of the wrong format.\n\ |
-")); |
-/*! Set table left border */ |
-PyObject *scribus_settableleftborder(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settablerightborder__doc__, |
-QT_TR_NOOP("setTableRightBorder(borderLines, [\"name\"])\n\ |
-\n\ |
-Sets the right border of the table \"name\".\n\ |
-The border is specified as a list of \"(width, style, color)\" tuples.\n\ |
-\"style\" is one of the LINE_* constants. If \"name\" is not given\n\ |
-the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if \"borderLines\" is of the wrong format.\n\ |
-")); |
-/*! Set table right border */ |
-PyObject *scribus_settablerightborder(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settabletopborder__doc__, |
-QT_TR_NOOP("setTableTopBorder(borderLines, [\"name\"])\n\ |
-\n\ |
-Sets the top border of the table \"name\".\n\ |
-The border is specified as a list of \"(width, style, color)\" tuples.\n\ |
-\"style\" is one of the LINE_* constants. If \"name\" is not given\n\ |
-the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if \"borderLines\" is of the wrong format.\n\ |
-")); |
-/*! Set table top border */ |
-PyObject *scribus_settabletopborder(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settablebottomborder__doc__, |
-QT_TR_NOOP("setTableBottomBorder(borderLines, [\"name\"])\n\ |
-\n\ |
-Sets the bottom border of the table \"name\".\n\ |
-The border is specified as a list of \"(width, style, color)\" tuples.\n\ |
-\"style\" is one of the LINE_* constants. If \"name\" is not given\n\ |
-the currently selected item is used.\n\ |
-\n\ |
-May throw ValueError if \"borderLines\" is of the wrong format.\n\ |
-")); |
-/*! Set table bottom border */ |
-PyObject *scribus_settablebottomborder(PyObject * /*self*/, PyObject* args); |
- |
-#endif // CMDTABLE_H |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtable.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdvar.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdvar.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdvar.h (nonexistent) |
@@ -1,77 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef CMDVAR_H |
-#define CMDVAR_H |
- |
- |
-#include "scconfig.h" |
- |
-// PV - commented out - why it was here? |
-#if defined(_XOPEN_SOURCE) |
- #undef _XOPEN_SOURCE |
-#endif |
-#if defined(_POSIX_C_SOURCE) |
- #undef _POSIX_C_SOURCE |
-#endif |
- |
-#if defined(HAVE_BOOST_PYTHON) |
-#include <boost/python.hpp> |
-#else |
-#include <Python.h> |
-#endif |
- |
-#ifndef Py_RETURN_NONE |
- #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None |
-#endif |
- |
-#ifndef Py_RETURN_TRUE |
- #define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True |
-#endif |
- |
-#include <QString> |
- |
-#include "scribus.h" |
- |
- |
-class ScripterCore; |
- |
-// Globals for testing Qt properties and probably other more interesting future |
-// uses. |
-/** @brief A PyCObject containing a pointer to qApp */ |
-extern PyObject* wrappedQApp; |
-/** @brief A PyCObject containing a pointer to the main window ('mainWindow') */ |
-extern PyObject* wrappedMainWindow; |
- |
-/** @brief A pointer to the ScripterCore instance */ |
-extern ScripterCore* scripterCore; |
- |
-/** @brief Initialize the 'scribus' Python module in the currently active interpreter */ |
-extern "C" void initscribus(ScribusMainWindow *pl); |
- |
-/* Exceptions */ |
-/*! Common scribus Exception */ |
-extern PyObject* ScribusException; |
-/*! Exception raised when no document opened - see checkHaveDocument() in cmdutil.cpp */ |
-extern PyObject* NoDocOpenError; |
-/*! Exception raised when an operation is performed on a frame type that doesn't support it.*/ |
-extern PyObject* WrongFrameTypeError; |
-/*! Exception raised by GetUniqueItem when it can't find a valid frame or a suitable selection to use. */ |
-extern PyObject* NoValidObjectError; |
-/*! A general exception for when objects such as colors and fonts cannot be found. */ |
-extern PyObject* NotFoundError; |
-/*! Exception raised when the user tries to create an object with the same name as one that already exists */ |
-extern PyObject* NameExistsError; |
- |
-/*! A helper variable for better string comparisons to reduce warnings: |
-"warning: comparison with string literal results in unspecified behaviour" |
-what is criticised by some linux distributors */ |
-#ifndef EMPTY_STRING |
-#define EMPTY_STRING const_cast<char*>("") |
-#endif |
- |
-#endif |
- |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdvar.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdannotations.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdannotations.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdannotations.cpp (nonexistent) |
@@ -1,728 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
- |
-#include "cmdannotations.h" |
-#include "cmdutil.h" |
-#include "util.h" |
-#include "scribuscore.h" |
- |
-static PyObject *getLinkData(PyObject *rv, int page, const QString& action); |
-static void prepareannotation(PageItem *item); |
-static void setactioncoords(Annotation &a, int x, int y); |
-static bool testPageItem(PageItem *item); |
-static void add_text_to_dict(PyObject *drv, PageItem *item); |
- |
-PyObject *scribus_setjsactionscript(PyObject * /*self*/, PyObject* args) |
-{ |
- /* |
- Java_ReleaseButton = 0, |
- Java_PressButton = 1, |
- Java_EnterWidget = 2, |
- Java_LeaveWidget = 3, |
- Java_FocusIn = 4, |
- Java_FocusOut = 5, |
- Java_SelectionChg = 6, |
- Java_FieldFormat = 7, |
- Java_FieldValidate = 8, |
- Java_FieldCalculate = 9 |
- */ |
- int action; |
- char *script = const_cast<char*>(""); |
- char *name = const_cast<char*>(""); |
- |
- if (!PyArg_ParseTuple(args, "is|es",&action,&script,"utf-8", &name)) |
- return nullptr; |
- |
- if (action < 0 || action > 9) |
- { |
- QString qnum = QString("%1").arg(action); |
- PyErr_SetString(PyExc_RuntimeError, |
- QObject::tr("Action must be an integer in range 0-9 " + qnum.toUtf8(), "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
- if (item == nullptr) |
- return nullptr; |
- |
- if (!item->isAnnotation()) |
- { |
- PyErr_SetString(PyExc_RuntimeError, |
- QObject::tr("Page item must be an annotation", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- Annotation &annotation = item->annotation(); |
- annotation.setActionType(Annotation::Action_JavaScript); |
- QString javascript = QString::fromUtf8(script); |
- |
- switch (action) |
- { |
- case Annotation::Java_ReleaseButton: |
- annotation.setAction(javascript); |
- break; |
- case Annotation::Java_PressButton: |
- annotation.setD_act(javascript); |
- break; |
- case Annotation::Java_EnterWidget: |
- annotation.setE_act(javascript); |
- break; |
- case Annotation::Java_LeaveWidget: |
- annotation.setX_act(javascript); |
- break; |
- case Annotation::Java_FocusIn: |
- annotation.setFo_act(javascript); |
- break; |
- case Annotation::Java_FocusOut: |
- annotation.setBl_act(javascript); |
- break; |
- case Annotation::Java_SelectionChg: |
- annotation.setK_act(javascript); |
- break; |
- case Annotation::Java_FieldFormat: |
- annotation.setF_act(javascript); |
- break; |
- case Annotation::Java_FieldValidate: |
- annotation.setV_act(javascript); |
- break; |
- case Annotation::Java_FieldCalculate: |
- annotation.setC_act(javascript); |
- break; |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getjsactionscript(PyObject * /*self*/, PyObject* args) |
-{ |
- int action; |
- char *name = const_cast<char*>(""); |
- |
- if (!PyArg_ParseTuple(args, "i|es",&action,"utf-8", &name)) |
- return nullptr; |
- |
- if (action < 0 || action > 9) |
- { |
- QString qnum = QString("%1").arg(action); |
- PyErr_SetString(PyExc_RuntimeError, |
- QObject::tr("Action must be 0-9 " + qnum.toUtf8(), "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
- if (item == nullptr) |
- return nullptr; |
- |
- if (!item->isAnnotation()) |
- { |
- PyErr_SetString(PyExc_RuntimeError, |
- QObject::tr("Page item must be an annotation", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- Annotation &annotation = item->annotation(); |
- if (annotation.ActionType() != Annotation::Action_JavaScript) |
- Py_RETURN_NONE; |
- |
- QString rv; |
- switch (action) |
- { |
- case Annotation::Java_ReleaseButton: |
- rv = annotation.Action(); |
- break; |
- case Annotation::Java_PressButton: |
- rv = annotation.D_act(); |
- break; |
- case Annotation::Java_EnterWidget: |
- rv = annotation.E_act(); |
- break; |
- case Annotation::Java_LeaveWidget: |
- rv = annotation.X_act(); |
- break; |
- case Annotation::Java_FocusIn: |
- rv = annotation.Fo_act(); |
- break; |
- case Annotation::Java_FocusOut: |
- rv = annotation.Bl_act(); |
- break; |
- case Annotation::Java_SelectionChg: |
- rv = annotation.K_act(); |
- break; |
- case Annotation::Java_FieldFormat: |
- rv = annotation.F_act(); |
- break; |
- case Annotation::Java_FieldValidate: |
- rv = annotation.V_act(); |
- break; |
- case Annotation::Java_FieldCalculate: |
- rv = annotation.C_act(); |
- break; |
- } |
- |
- PyObject *rstr = PyString_FromString(rv.toUtf8()); |
- return rstr; |
-} |
- |
-PyObject *scribus_isannotated(PyObject * /*self*/, PyObject* args, PyObject *keywds) |
-{ |
- char *name = const_cast<char*>(""); |
- PyObject *deannotate = Py_False; |
- char *kwlist[] = {const_cast<char*>(""),const_cast<char*>("deannotate"), nullptr}; |
- |
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "|esO", kwlist, "utf-8", &name, &deannotate)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
- if (item == nullptr) |
- return nullptr; |
- |
- if (item->isAnnotation()) |
- { |
- if (PyObject_IsTrue(deannotate)==1) |
- { |
- item->setIsAnnotation(false); |
- Py_RETURN_NONE; |
- } |
- |
- Annotation a = item->annotation(); |
- int atype = a.Type(); |
- int actype = a.ActionType(); |
- |
- PyObject *drv = PyDict_New(); |
- if (atype == Annotation::Link && (actype == Annotation::Action_GoToR_FileAbs || actype == Annotation::Action_GoToR_FileRel)) |
- { |
- char *name3; |
- if (actype== Annotation::Action_GoToR_FileAbs) |
- name3 =const_cast<char*>("Link File Absolute"); |
- else |
- name3 =const_cast<char*>("Link File Relative"); |
- |
- getLinkData(drv, a.Ziel(), a.Action()); |
- const char path[] = "path"; |
- PyObject *pathkey = PyString_FromString(path); |
- PyObject *pathvalue = PyString_FromString(a.Extern().toUtf8()); |
- PyDict_SetItem(drv, pathkey, pathvalue); |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name3, drv); |
- return rv; |
- } |
- if (atype == Annotation::Link && actype == Annotation::Action_URI) |
- { |
- const char uri[] = "uri"; |
- PyObject *ukey = PyString_FromString(uri); |
- PyObject *uval = PyString_FromString(a.Extern().toUtf8()); |
- PyDict_SetItem(drv, ukey, uval); |
- add_text_to_dict(drv, item); |
- char *name4= const_cast<char*>("Link URI"); |
- PyObject *rv = Py_BuildValue("(sO)", name4, drv); |
- return rv; |
- } |
- if (atype == Annotation::Link) |
- { |
- getLinkData(drv, a.Ziel(), a.Action()); |
- const char name2[] = "Link"; |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name2, drv); |
- return rv; |
- } |
- if (atype == Annotation::Button) |
- { |
- const char name5[] = "Button"; |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name5, drv); |
- return rv; |
- } |
- if (atype == Annotation::RadioButton) |
- { |
- const char name4[] = "RadioButton"; |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name4, drv); |
- return rv; |
- } |
- if (atype == Annotation::Textfield) |
- { |
- const char name6[] = "Textfield"; |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name6, drv); |
- return rv; |
- } |
- if (atype == Annotation::Checkbox) |
- { |
- const char name7[] = "Checkbox"; |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name7, drv); |
- return rv; |
- } |
- if (atype == Annotation::Combobox) |
- { |
- const char name4[] = "Combobox"; |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name4, drv); |
- return rv; |
- } |
- if (atype == Annotation::Listbox) |
- { |
- const char name8[] = "Listbox"; |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name8, drv); |
- return rv; |
- } |
- if (atype == Annotation::Text) |
- { |
- /** icons: 0 "Note", 1 "Comment", 2 "Key", |
- 3 "Help", 4 "NewParagraph", 5 "Paragraph", 6 "Insert", |
- 7 "Cross", 8 "Circle" |
- */ |
- const char name9[] = "Text"; |
- int icon = a.Icon(); |
- const char *icons[] = {"Note","Comment", |
- "Key", "Help", |
- "NewParagraph","Paragraph", |
- "Insert","Cross", |
- "Circle", nullptr |
- }; |
- if (icon >= 0 && icon < 9) |
- { |
- PyObject *iconkey = PyString_FromString("icon"); |
- PyObject *iconvalue = PyString_FromString(icons[icon]); |
- PyDict_SetItem(drv, iconkey, iconvalue); |
- } |
- |
- PyObject *openkey = PyString_FromString("open"); |
- PyObject *open = Py_False; |
- if (a.IsAnOpen()) |
- open = Py_True; |
- PyDict_SetItem(drv, openkey, open); |
- |
- add_text_to_dict(drv, item); |
- PyObject *rv = Py_BuildValue("(sO)", name9, drv); |
- return rv; |
- } |
- if (atype == Annotation::Annot3D) |
- { |
- const char a3dname[] = "Annot3D"; |
- PyObject *rv = Py_BuildValue("(sO)",a3dname, drv); |
- return rv; |
- } |
- const char unknown[] = "Unknown Annotation"; |
- PyObject *rv = Py_BuildValue("(sO)", unknown, drv); |
- return rv; |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
- |
-PyObject *scribus_setlinkannotation(PyObject* /* self */, PyObject* args) |
-{ |
- char *name = const_cast<char*>(""); |
- int page, x, y; |
- |
- if (!PyArg_ParseTuple(args, "iii|es", &page, &x, &y, "utf-8", &name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
- if (!testPageItem(item)) |
- return nullptr; |
- |
- int numpages = ScCore->primaryMainWindow()->doc->Pages->count(); |
- if (page <= 0 || page > numpages){ |
- QString qnum = QString("%1").arg(numpages); |
- PyErr_SetString(PyExc_RuntimeError, |
- QObject::tr("which must be 1 to " + qnum.toUtf8(), "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- prepareannotation(item); |
- Annotation &a = item->annotation(); |
- a.setType(Annotation::Link); |
- page -= 1; |
- a.setZiel(page); |
- setactioncoords(a, x, y); |
- a.setExtern(QString::fromUtf8("")); |
- a.setActionType(Annotation::Action_GoTo); |
- |
- Py_RETURN_NONE; |
-} |
- |
- |
-PyObject *scribus_setfileannotation(PyObject * /*self*/, PyObject* args, PyObject *keywds) |
-{ |
- char *path; |
- int page, x, y; |
- char *name = const_cast<char*>(""); |
- PyObject *absolute = Py_True; |
- |
- char *kwlist[] = {const_cast<char*>("path"), const_cast<char*>("page"), |
- const_cast<char*>("x"), const_cast<char*>("y"), |
- const_cast<char*>("name"),const_cast<char*>("absolute"), nullptr}; |
- |
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "esiii|esO", kwlist, |
- "utf-8", &path, &page, &x, &y, |
- "utf-8", &name, &absolute)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
- if (!testPageItem(item)) |
- return nullptr; |
- |
- prepareannotation(item); |
- Annotation &a = item->annotation(); |
- a.setType(Annotation::Link); |
- a.setZiel(page - 1); |
- a.setExtern(QString::fromUtf8(path)); |
- setactioncoords(a, x, y); |
- |
- if (PyObject_IsTrue(absolute)==1) |
- a.setActionType(Annotation::Action_GoToR_FileAbs); |
- else |
- a.setActionType(Annotation::Action_GoToR_FileRel); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_seturiannotation(PyObject * /*self*/, PyObject* args) |
-{ |
- char *uri; |
- char *name = const_cast<char*>(""); |
- |
- if (!PyArg_ParseTuple(args, "es|es","utf-8" ,&uri,"utf-8", &name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
- if (!testPageItem(item)) |
- return nullptr; |
- |
- prepareannotation(item); |
- Annotation &a = item->annotation(); |
- a.setAction(QString::fromUtf8("")); |
- a.setExtern(QString::fromUtf8(uri)); |
- a.setActionType(Annotation::Action_URI); |
- a.setType(Annotation::Link); |
- |
- Py_RETURN_NONE; |
-} |
- |
- |
-PyObject *scribus_settextannotation(PyObject * /*self*/, PyObject* args) |
-{ |
- /** icons: 0 "Note", 1 "Comment", 2 "Key", |
- 3 "Help", 4 "NewParagraph", 5 "Paragraph", |
- 6 "Insert", 7 "Cross", 8 "Circle" |
- */ |
- int icon; |
- PyObject *isopen = Py_False; |
- char *name = const_cast<char*>(""); |
- /** icons: 0 "Note", 1 "Comment", 2 "Key", |
- 3 "Help", 4 "NewParagraph", 5 "Paragraph", 6 "Insert", |
- 7 "Cross", 8 "Circle" |
- |
- */ |
- |
- if (!PyArg_ParseTuple(args, "iO|es",&icon,&isopen,"utf-8", &name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (icon < 0 || icon > 8) |
- { |
- PyErr_SetString(PyExc_RuntimeError, |
- QObject::tr("Icon must be 0 to 8", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
- if (!testPageItem(item)) |
- return nullptr; |
- |
- prepareannotation(item); |
- |
- Annotation &a = item->annotation(); |
- a.setAnOpen(PyObject_IsTrue(isopen)); |
- a.setActionType(Annotation::Action_None); |
- a.setIcon(icon); |
- a.setExtern(QString::fromUtf8("")); |
- a.setAction(QString::fromUtf8("")); |
- a.setType(Annotation::Text); |
- |
- Py_RETURN_NONE; |
-} |
- |
- |
- |
-PyObject *scribus_createpdfannotation(PyObject * /*self*/, PyObject* args) |
-{ |
- enum{PDFBUTTON, PDFRADIOBUTTON, PDFTEXTFIELD, PDFCHECKBOX, PDFCOMBOBOX, PDFLISTBOX, |
- PDFTEXTANNOTATION, PDFLINKANNOTATION, PDF3DANNOTATION}; |
- |
- int which; |
- double x, y, w, h; |
- char *name = const_cast<char*>(""); |
- |
- if (!PyArg_ParseTuple(args, "idddd|es", &which, &x, &y, &w, &h, "utf-8", &name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- if (which < 0 || which > 8){ |
- PyErr_SetString(PyExc_RuntimeError, |
- QObject::tr("which must be 0 to 8", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- ScribusDoc *m_doc = ScCore->primaryMainWindow()->doc; |
- |
- int i; |
- if (which < 8) |
- { |
- i = m_doc->itemAdd(PageItem::TextFrame, |
- PageItem::Unspecified, |
- pageUnitXToDocX(x), |
- pageUnitYToDocY(y), |
- ValueToPoint(w), |
- ValueToPoint(h), |
- m_doc->itemToolPrefs().shapeLineWidth, |
- CommonStrings::None, |
- m_doc->itemToolPrefs().textColor); |
- } |
- else |
- { |
- bool hasOSG = false; |
- #ifdef HAVE_OSG |
- hasOSG = true; |
- #endif |
- if (hasOSG) |
- { |
- i = m_doc->itemAdd(PageItem::OSGFrame, |
- PageItem::Unspecified, |
- pageUnitXToDocX(x), |
- pageUnitYToDocY(y), |
- ValueToPoint(w), |
- ValueToPoint(h), |
- m_doc->itemToolPrefs().shapeLineWidth, |
- m_doc->itemToolPrefs().imageFillColor, |
- m_doc->itemToolPrefs().imageStrokeColor); |
- } |
- else |
- { |
- PyErr_SetString(PyExc_RuntimeError, |
- QObject::tr("Doesn't have OSG can't create 3DAnnotation", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- } |
- |
- PageItem *pi = m_doc->Items->at(i); |
- pi->AutoName=false; |
- |
- if (strlen(name) > 0) |
- { |
- QString objName = QString::fromUtf8(name); |
- if (!ItemExists(objName)) |
- m_doc->Items->at(i)->setItemName(objName); |
- } |
- else |
- { |
- QString inames[] = { |
- CommonStrings::itemName_PushButton, |
- CommonStrings::itemName_RadioButton, |
- CommonStrings::itemName_TextField, |
- CommonStrings::itemName_CheckBox, |
- CommonStrings::itemName_ComboBox, |
- CommonStrings::itemName_ListBox, |
- CommonStrings::itemName_TextAnnotation, |
- CommonStrings::itemName_LinkAnnotation, |
- QObject::tr("3DAnnot") |
- }; |
- QString iname = inames[which] + QString("%1").arg(m_doc->TotalItems); |
- pi->setItemName(iname); |
- } |
- |
- |
- pi->setIsAnnotation(true); |
- Annotation &a = pi->annotation(); |
- |
- Annotation::AnnotationType atypes[] = { |
- Annotation::Button, Annotation::RadioButton, |
- Annotation::Textfield, Annotation::Checkbox, |
- Annotation::Checkbox, Annotation::Combobox, |
- Annotation::Listbox, Annotation::Text, |
- Annotation::Link, Annotation::Annot3D |
- }; |
- a.setType(atypes[which]); |
- |
- switch (which) |
- { |
- case PDFBUTTON: |
- a.setFlag(Annotation::Flag_PushButton); |
- break; |
- case PDFRADIOBUTTON: |
- a.setFlag(Annotation::Flag_Radio | Annotation::Flag_NoToggleToOff); |
- break; |
- case PDFCOMBOBOX: |
- a.setFlag(Annotation::Flag_Combo); |
- break; |
- case PDFLINKANNOTATION: |
- a.setZiel(m_doc->currentPage()->pageNr()); |
- a.setAction("0 0"); |
- a.setActionType(Annotation::Action_GoTo); |
- pi->setTextFlowMode(PageItem::TextFlowDisabled); |
- break; |
- } |
- |
- return PyString_FromString(m_doc->Items->at(i)->itemName().toUtf8()); |
-} |
- |
- |
-/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmdannotationsdocwarnings() |
-{ |
- QStringList s; |
- s << scribus_setlinkannotation__doc__ |
- << scribus_isannotated__doc__ |
- << scribus_setfileannotation__doc__ |
- << scribus_seturiannotation__doc__ |
- << scribus_settextannotation__doc__ |
- << scribus_createpdfannotation__doc__ |
- << scribus_setjsactionscript__doc__ |
- << scribus_getjsactionscript__doc__; |
-} |
- |
- |
-//HELPER FUNCTIONS |
- |
-PyObject *getLinkData(PyObject *rv,int page, const QString& action) |
-{ |
- int x, y; |
- |
- const char pagenum[] = "page"; |
- PyObject *pagekey = PyString_FromString(pagenum); |
- PyObject *pagevalue = PyInt_FromLong((long)page); |
- PyDict_SetItem(rv, pagekey, pagevalue); |
- |
- QStringList qsl = action.split(" ", Qt::SkipEmptyParts); |
- |
- x = qsl[0].toInt(); |
- const char x2[] = "x"; |
- PyObject *xkey = PyString_FromString(x2); |
- PyObject *xvalue = PyInt_FromLong((long)x); |
- PyDict_SetItem(rv, xkey, xvalue); |
- |
- int height =ScCore->primaryMainWindow()->doc->pageHeight(); |
- y = height - qsl[1].toInt(); |
- const char y2[] = "y"; |
- PyObject *ykey = PyString_FromString(y2); |
- PyObject *yvalue = PyInt_FromLong((long)y); |
- PyDict_SetItem(rv, ykey, yvalue); |
- |
- return rv; |
- |
-} |
- |
-static void prepareannotation(PageItem *item) |
-{ |
- if (item->isBookmark) |
- { |
- item->isBookmark = false; |
- ScCore->primaryMainWindow()->DelBookMark(item); |
- } |
- item->setIsAnnotation(true); |
-} |
- |
-static void setactioncoords(Annotation &a, int x, int y) |
-{ |
- QString xstring, ystring; |
- int height =ScCore->primaryMainWindow()->doc->pageHeight(); |
- a.setAction(xstring.setNum(x) + " " + ystring.setNum(height - y) + " 0"); |
-} |
- |
-static bool testPageItem(PageItem *item) |
-{ |
- if (item == nullptr) |
- return false; |
- if (!item->isTextFrame()) |
- { |
- PyErr_SetString(WrongFrameTypeError, |
- QObject::tr("Can't set annotation on a non-text frame", "python error").toLocal8Bit().constData()); |
- return false; |
- } |
- |
- return true; |
-} |
- |
-static void add_text_to_dict(PyObject *drv, PageItem * item) |
-{ |
- const char text[] = "text"; |
- PyObject *textkey = PyString_FromString(text); |
- QString txt = item->itemText.text(0, item->itemText.length()); |
- PyObject *textvalue = PyString_FromString(txt.toUtf8()); |
- PyDict_SetItem(drv, textkey, textvalue); |
- |
- Annotation &a = item->annotation(); |
- int actype = a.ActionType(); |
- |
- if (actype == Annotation::Action_JavaScript) |
- { |
- const char text[] = "javascript"; |
- PyObject *jskey = PyString_FromString(text); |
- PyObject *jsvalue = PyString_FromString(item->annotation().Action().toUtf8()); |
- PyDict_SetItem(drv, jskey, jsvalue); |
- } |
- |
- const char *aactions[] = { "None", "JavaScript", |
- "Goto", "Submit Form", |
- "Reset Form", "Import Data", |
- "Unknown", "Goto File Relative", |
- "URI", "Goto File Relative" , |
- "Named", nullptr }; |
- |
- const char action[] = "action"; |
- PyObject *akey = PyString_FromString(action); |
- if (actype > 10) |
- actype = 6; |
- PyObject *avalue = PyString_FromString(aactions[actype]); |
- PyDict_SetItem(drv, akey, avalue); |
- |
- int atype = a.Type(); |
- if (atype == Annotation::Checkbox || atype == Annotation::RadioButton) |
- { |
- const char checked[] = "checked"; |
- PyObject *checkkey = PyString_FromString(checked); |
- PyObject *checkvalue = Py_False; |
- if (a.IsChk()) |
- checkvalue = Py_True; |
- PyDict_SetItem(drv, checkkey, checkvalue); |
- } |
- |
- if (atype == Annotation::Combobox || atype == Annotation::Listbox) |
- { |
- const char editable[] = "editable"; |
- PyObject *ekey = PyString_FromString(editable); |
- |
- PyObject *edit = Py_False; |
- int result = Annotation::Flag_Edit & a.Flag(); |
- if (result == Annotation::Flag_Edit) |
- edit = Py_True; |
- PyDict_SetItem(drv, ekey, edit); |
- } |
-} |
- |
- |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdannotations.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/pconsole.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/pconsole.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/pconsole.cpp (nonexistent) |
@@ -1,416 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-/* |
-This program is free software; you can redistribute it and/or modify |
-it under the terms of the GNU General Public License as published by |
-the Free Software Foundation; either version 2 of the License, or |
-(at your option) any later version. |
-*/ |
- |
-#include "pconsole.h" |
- |
-#include <QFileDialog> |
- |
-#include "commonstrings.h" |
-#include "iconmanager.h" |
-#include "prefscontext.h" |
-#include "prefsfile.h" |
-#include "prefsmanager.h" |
-#include "scribuscore.h" |
- |
- |
-PythonConsole::PythonConsole( QWidget* parent) |
- : QMainWindow( parent ) |
-{ |
- setupUi(this); |
- setWindowIcon(IconManager::instance().loadIcon("AppIcon.png")); |
- |
- changedLabel = new QLabel(this); |
- cursorTemplate = tr("Col: %1 Row: %2/%3"); |
- cursorLabel = new QLabel(this); |
- statusBar()->addPermanentWidget(changedLabel); |
- statusBar()->addPermanentWidget(cursorLabel); |
- |
- action_Open->setIcon(IconManager::instance().loadIcon("16/document-open.png")); |
- action_Save->setIcon(IconManager::instance().loadIcon("16/document-save.png")); |
- actionSave_As->setIcon(IconManager::instance().loadIcon("16/document-save-as.png")); |
- action_Exit->setIcon(IconManager::instance().loadIcon("exit.png")); |
- action_Run->setIcon(IconManager::instance().loadIcon("ok.png")); |
- |
- action_Open->setShortcut(tr("Ctrl+O")); |
- action_Save->setShortcut(tr("Ctrl+S")); |
- action_Run->setShortcut(Qt::Key_F9); |
- actionRun_As_Console->setShortcut(Qt::CTRL + Qt::Key_F9); |
- |
- commandEdit->setTabStopDistance(qRound(commandEdit->fontPointSize() * 4)); |
- |
- // install syntax highlighter. |
- new SyntaxHighlighter(commandEdit); |
- |
- languageChange(); |
- commandEdit_cursorPositionChanged(); |
- |
- // welcome note |
- QString welcomeText(R"(""")"); |
- welcomeText += tr("Scribus Python Console"); |
- welcomeText += "\n\n"; |
- welcomeText += tr( |
- "This is a standard Python console with some \n" |
- "known limitations. Please consult the Scribus \n" |
- "Scripter documentation for further information. "); |
- welcomeText += "\"\"\"\n"; |
- commandEdit->setText(welcomeText); |
- commandEdit->selectAll(); |
- |
- connect(commandEdit, SIGNAL(cursorPositionChanged()), this, SLOT(commandEdit_cursorPositionChanged())); |
- connect(commandEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(documentChanged(bool))); |
- |
- connect(action_Open, SIGNAL(triggered()), this, SLOT(slot_open())); |
- connect(action_Save, SIGNAL(triggered()), this, SLOT(slot_save())); |
- connect(actionSave_As, SIGNAL(triggered()), this, SLOT(slot_saveAs())); |
- connect(action_Exit, SIGNAL(triggered()), this, SLOT(slot_quit())); |
- connect(action_Run, SIGNAL(triggered()), this, SLOT(slot_runScript())); |
- connect(actionRun_As_Console, SIGNAL(triggered()), this, SLOT(slot_runScriptAsConsole())); |
- connect(action_Save_Output, SIGNAL(triggered()), this, SLOT(slot_saveOutput())); |
-} |
- |
-PythonConsole::~PythonConsole() = default; |
- |
-void PythonConsole::updateSyntaxHighlighter() |
-{ |
- new SyntaxHighlighter(commandEdit); |
-} |
- |
-void PythonConsole::setFonts() |
-{ |
- QFont font = QFont("Fixed"); |
- font.setStyleHint(QFont::TypeWriter); |
- font.setPointSize(PrefsManager::instance().appPrefs.uiPrefs.applicationFontSize); |
- commandEdit->setFont(font); |
- outputEdit->setFont(font); |
-} |
- |
-void PythonConsole::changeEvent(QEvent *e) |
-{ |
- if (e->type() == QEvent::LanguageChange) |
- { |
- languageChange(); |
- return; |
- } |
- QMainWindow::changeEvent(e); |
-} |
- |
-void PythonConsole::closeEvent(QCloseEvent *) |
-{ |
- emit paletteShown(false); |
-} |
- |
-void PythonConsole::commandEdit_cursorPositionChanged() |
-{ |
- QTextCursor cur(commandEdit->textCursor()); |
- cursorLabel->setText(cursorTemplate.arg(cur.columnNumber()+1) |
- .arg(cur.blockNumber()+1) |
- .arg(commandEdit->document()->blockCount())); |
-} |
- |
-void PythonConsole::documentChanged(bool state) |
-{ |
- changedLabel->setText(state ? "*" : " "); |
-} |
- |
-void PythonConsole::languageChange() |
-{ |
- Ui::PythonConsole::retranslateUi(this); |
- |
- cursorTemplate = tr("Col: %1 Row: %2/%3"); |
- commandEdit_cursorPositionChanged(); |
- |
- commandEdit->setToolTip( "<qt>" + tr("Write your commands here. A selection is processed as script.") + "</qt>"); |
- outputEdit->setToolTip( "<qt>" + tr("Output of your script") + "</qt>"); |
-} |
- |
-void PythonConsole::slot_runScript() |
-{ |
- outputEdit->clear(); |
- |
- //Prevent two scripts to be run concurrently or face crash! |
- if (ScCore->primaryMainWindow()->scriptIsRunning()) |
- { |
- outputEdit->append( tr("Another script is already running...") ); |
- outputEdit->append( tr("Please let it finish its task...") ); |
- return; |
- } |
- |
- parsePythonString(); |
- emit runCommand(); |
- commandEdit->textCursor().movePosition(QTextCursor::Start); |
-} |
- |
-void PythonConsole::slot_runScriptAsConsole() |
-{ |
- //Prevent two scripts to be run concurrently or face crash! |
- if (ScCore->primaryMainWindow()->scriptIsRunning()) |
- { |
- outputEdit->append( tr("\n>>> Another script is already running...") ); |
- outputEdit->append( tr("Please let it finish its task...") ); |
- return; |
- } |
- |
- parsePythonString(); |
- commandEdit->clear(); |
- // content is destroyed. This is to prevent overwriting |
- filename.clear(); |
- outputEdit->append("\n>>> " + m_command); |
- emit runCommand(); |
-} |
- |
-void PythonConsole::parsePythonString() |
-{ |
- if (commandEdit->textCursor().hasSelection()) |
- m_command = commandEdit->textCursor().selectedText(); |
- else |
- { |
- commandEdit->selectAll(); |
- m_command = commandEdit->textCursor().selectedText(); |
- } |
- // Per Qt doc, "If the selection obtained from an editor spans a line break, the text |
- // will contain a Unicode U+2029 paragraph separator character instead of a newline" |
- m_command.replace(QChar(0x2029), QChar('\n')); |
- // prevent user's wrong selection |
- m_command += '\n'; |
-} |
- |
-/* |
- * supplementary slots. Saving etc. |
- */ |
-void PythonConsole::slot_open() |
-{ |
- filename = QFileDialog::getOpenFileName(this, |
- tr("Open Python Script File"), |
- ".", |
- tr("Python Scripts (*.py *.PY)")); |
- if (filename.isNull()) |
- return; |
- QFile file(filename); |
- if (file.open(QIODevice::ReadOnly)) |
- { |
- QTextStream stream(&file); |
- commandEdit->setPlainText(stream.readAll()); |
- file.close(); |
- } |
-} |
- |
-void PythonConsole::slot_save() |
-{ |
- if (filename.isNull()) |
- { |
- slot_saveAs(); |
- return; |
- } |
- QFile f(filename); |
- if (f.open(QIODevice::WriteOnly)) |
- { |
- QTextStream stream(&f); |
- stream << commandEdit->toPlainText(); |
- f.close(); |
- } |
-} |
- |
-void PythonConsole::slot_saveAs() |
-{ |
- QString oldFname = filename; |
- QString dirName = QDir::homePath(); |
- if (!filename.isEmpty()) |
- { |
- QFileInfo fInfo(filename); |
- QDir fileDir = fInfo.absoluteDir(); |
- if (fileDir.exists()) |
- dirName = fileDir.absolutePath(); |
- } |
- filename = QFileDialog::getSaveFileName(this, |
- tr("Save the Python Commands in File"), |
- dirName, |
- tr("Python Scripts (*.py *.PY)")); |
- if (filename.isEmpty()) |
- { |
- filename = oldFname; |
- return; |
- } |
- slot_save(); |
-} |
- |
-void PythonConsole::slot_saveOutput() |
-{ |
- QString dname = QDir::homePath(); |
- QString fname = QFileDialog::getSaveFileName(this, |
- tr("Save Current Output"), |
- dname, |
- tr("Text Files (*.txt)")); |
- if (fname.isEmpty()) |
- return; |
- QFile f(fname); |
- // save |
- if (f.open(QIODevice::WriteOnly)) |
- { |
- QTextStream stream(&f); |
- stream << outputEdit->toPlainText(); |
- f.close(); |
- } |
-} |
- |
-void PythonConsole::slot_quit() |
-{ |
- emit paletteShown(false); |
-} |
- |
-/* |
- * Syntax highlighting |
- */ |
-SyntaxHighlighter::SyntaxHighlighter(QTextEdit *textEdit) : QSyntaxHighlighter(textEdit) |
-{ |
- // Reserved keywords in Python 2.4 |
- QStringList keywords; |
- HighlightingRule rule; |
- |
- keywords << "and" << "assert" << "break" << "class" << "continue" << "def" |
- << "del" << "elif" << "else" << "except" << "exec" << "finally" |
- << "for" << "from" << "global" << "if" << "import" << "in" |
- << "is" << "lambda" << "not" << "or" << "pass" << "print" << "raise" |
- << "return" << "try" << "while" << "yield"; |
- |
- keywordFormat.setForeground(colors.keywordColor); |
- keywordFormat.setFontWeight(QFont::Bold); |
- singleLineCommentFormat.setForeground(colors.commentColor); |
- singleLineCommentFormat.setFontItalic(true); |
- quotationFormat.setForeground(colors.stringColor); |
- numberFormat.setForeground(colors.numberColor); |
- operatorFormat.setForeground(colors.signColor); |
- |
- foreach (const QString& kw, keywords) |
- { |
- rule.pattern = QRegularExpression("\\b" + kw + "\\b", QRegularExpression::CaseInsensitiveOption); |
- rule.format = keywordFormat; |
- highlightingRules.append(rule); |
- } |
- |
- rule.pattern = QRegularExpression("#[^\n]*"); |
- rule.format = singleLineCommentFormat; |
- highlightingRules.append(rule); |
- |
- rule.pattern = QRegularExpression("\'.*\'". QRegularExpression::InvertedGreedinessOption); |
- |
- rule.format = quotationFormat; |
- highlightingRules.append(rule); |
- |
- rule.pattern = QRegularExpression("\".*\"", QRegularExpression::InvertedGreedinessOption); |
- rule.format = quotationFormat; |
- highlightingRules.append(rule); |
- |
- rule.pattern = QRegularExpression("\\b\\d+\\b", QRegularExpression::InvertedGreedinessOption); |
- rule.format = numberFormat; |
- highlightingRules.append(rule); |
- |
- rule.pattern = QRegularExpression("[\\\\|\\<|\\>|\\=|\\!|\\+|\\-|\\*|\\/|\\%]+"); |
- rule.pattern.setMinimal(true); |
- rule.format = operatorFormat; |
- highlightingRules.append(rule); |
-} |
- |
-void SyntaxHighlighter::highlightBlock(const QString &text) |
-{ |
- // Apply default text color |
- setFormat(0, text.length(), colors.textColor); |
- |
- foreach (HighlightingRule rule, highlightingRules) |
- { |
- QRegExp expression(rule.pattern); |
- int index = expression.indexIn(text); |
- while (index >= 0) |
- { |
- int length = expression.matchedLength(); |
- setFormat(index, length, rule.format); |
- index = expression.indexIn(text, index + length); |
- } |
- } |
- setCurrentBlockState(0); |
- |
- // multiline strings handling |
- int startIndex = 0; |
- if (previousBlockState() != 1) |
- startIndex = text.indexOf("\"\"\""); |
- |
- while (startIndex >= 0) |
- { |
- int endIndex = text.indexOf("\"\"\"", startIndex); |
- int commentLength; |
- |
- if (endIndex == -1) |
- { |
- setCurrentBlockState(1); |
- commentLength = text.length() - startIndex; |
- } |
- else |
- { |
- commentLength = endIndex - startIndex + 3;//commentEndExpression.matchedLength(); |
- } |
- setFormat(startIndex, commentLength, quotationFormat); |
- startIndex = text.indexOf("\"\"\"", startIndex + commentLength); |
- } |
-} |
- |
-SyntaxColors::SyntaxColors() |
-{ |
- PrefsContext* prefs = PrefsManager::instance().prefsFile->getPluginContext("scriptplugin"); |
- if (prefs) |
- { |
- errorColor.setNamedColor(prefs->get("syntaxerror", "#aa0000")); |
- commentColor.setNamedColor(prefs->get("syntaxcomment", "#A0A0A0")); |
- keywordColor.setNamedColor(prefs->get("syntaxkeyword", "#00007f")); |
- signColor.setNamedColor(prefs->get("syntaxsign", "#aa00ff")); |
- numberColor.setNamedColor(prefs->get("syntaxnumber", "#ffaa00")); |
- stringColor.setNamedColor(prefs->get("syntaxstring", "#005500")); |
- textColor.setNamedColor(prefs->get("syntaxtext", "#000000")); |
- } |
- else |
- { |
- errorColor.setNamedColor("#aa0000"); |
- commentColor.setNamedColor("#A0A0A0"); |
- keywordColor.setNamedColor("#00007f"); |
- signColor.setNamedColor("#aa00ff"); |
- numberColor.setNamedColor("#ffaa00"); |
- stringColor.setNamedColor("#005500"); |
- textColor.setNamedColor("#000000"); |
- } |
-} |
- |
-void SyntaxColors::saveToPrefs() |
-{ |
- PrefsContext* prefs = PrefsManager::instance().prefsFile->getPluginContext("scriptplugin"); |
- if (!prefs) |
- return; |
- prefs->set("syntaxerror", qcolor2named(errorColor)); |
- prefs->set("syntaxcomment", qcolor2named(commentColor)); |
- prefs->set("syntaxkeyword", qcolor2named(keywordColor)); |
- prefs->set("syntaxsign", qcolor2named(signColor)); |
- prefs->set("syntaxnumber", qcolor2named(numberColor)); |
- prefs->set("syntaxstring", qcolor2named(stringColor)); |
- prefs->set("syntaxtext", qcolor2named(textColor)); |
-} |
- |
-QString SyntaxColors::qcolor2named(const QColor& color) |
-{ |
- int r; |
- int g; |
- int b; |
- QString retval("#"); |
- QString oct; |
- color.getRgb(&r, &g, &b); |
- retval += oct.setNum(r, 16).rightJustified(2, '0'); |
- retval += oct.setNum(g, 16).rightJustified(2, '0'); |
- retval += oct.setNum(b, 16).rightJustified(2, '0'); |
- return retval; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/pconsole.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.h (nonexistent) |
@@ -1,30 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef OBJPRINTER_H |
-#define OBJPRINTER_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-extern PyTypeObject Printer_Type; |
- |
-// Nest items are not needed but are here for me to exercise |
-// writing complete python objects |
- |
-#define Printer_Check(op) ((op)->ob_type == &Printer_Type) |
- |
-PyDoc_STRVAR(printer__doc__,"Printing\n\ |
-\n\ |
-Class Printer() provides printing for Python scripting.\n\ |
-\n\ |
-Example:\n\ |
-p = Printer()\n\ |
-p.print()"); |
- |
-PyDoc_STRVAR(printer_printnow__doc__, "printNow() -> boolean\n\nPrints selected pages."); |
- |
-#endif /* OBJPRINTER_H */ |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/3columnA4.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/3columnA4.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/3columnA4.py (nonexistent) |
@@ -1,53 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" Creates 3 column layout on A4 paper and save it under 3columnA4.sla filename. This is a simple way to demonstrate creating a doc on the fly. """ |
- |
-try: |
- # Please do not use 'from scribus import *' . If you must use a 'from import', |
- # Do so _after_ the 'import scribus' and only import the names you need, such |
- # as commonly used constants. |
- import scribus |
-except ImportError,err: |
- print "This Python script is written for the Scribus scripting interface." |
- print "It can only be run from within Scribus." |
- sys.exit(1) |
- |
-def main(argv): |
- """This is a simple way to demonstrate creating a doc on the fly. """ |
- |
- pass # <--- Delete this line |
-######################### |
-# YOUR IMPORTS GO HERE # |
-######################### |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-margins = (50, 50, 50, 50) |
-size = (612, 792) |
- |
-def main(): |
- if newDocument(PAPER_A4, margins, LANDSCAPE, 1, UNIT_POINTS, NOFACINGPAGES, FIRSTPAGELEFT,1): |
- a = createText(50, 50, 230, 495) |
- setTextAlignment(1,a) |
- setText("Column A", a) |
- setFontSize(12, a) |
- b = createText(280, 50, 230, 495) |
- setTextAlignment(1,b) |
- setText("Column B", b) |
- setFontSize(12, b) |
- c = createText(510, 50, 230, 495) |
- setTextAlignment(1,b) |
- setText("Column C", c) |
- setFontSize(12, c) |
- saveDocAs("3columnA4.sla") |
- |
- |
-if __name__ == '__main__': |
- main() |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/ReadMe |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/ReadMe (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/ReadMe (nonexistent) |
@@ -1,22 +0,0 @@ |
-This folder contains some Example Scripts: |
- |
-3columnA4.py = Sample 3 column layout |
-3columnUSLTR.py = Sample 3 column layout |
-Calender.py = Creates a Calendar of the current Month in the current Document as a Group |
-ReadMe = this file |
-Sample1.py = Very simple Example, creates a Docmument with some Objects, saves the Document and closes it. |
-boilerplate.py = A template for your scripts |
-golden-mean.py = Creates a non printable marks in the Golden Mean of the page. |
-legende.py = Creates a legende for Image (filename) |
-moins_10_pourcent_group.py = Decrease size of the object by 10% |
-plus_10_pourcent_group.py = Increase size of the object by 10% |
-pochette_cd.py = Creates a CD/DVD pochette |
-quote.py = French quotation marks |
-sample_db_usage.py = Database HOWTO |
-trait_de_coupe.py |
-wordcount.py = Counts the count of the words :) |
- |
-Copy these Examples to any location you like and play with them. |
-Each script contains Docstring in the file header - this is a common Python |
-documentation text. You can see it by selecting Script->About Script... menu |
-entry. |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/sample_db_usage.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/sample_db_usage.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/sample_db_usage.py (nonexistent) |
@@ -1,90 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-"""OK. This is a sample Scribus database connection with Python HOWTO. |
- |
-DESCRIPTION: |
-I've got questions about DB and Scribus in my personal mailbox 3-4 |
-times in a month. So this is an common answer for asking people. |
- |
-Even through I'm an Oracle user/developer I choose MySQL for this |
-example, because of its presence in the Linux distributions and |
-hosting availability too. |
-But the DB server doesn't matter due the PEP 249 - standard DB interface |
-(http://www.python.org/peps/pep-0249.html). |
-There are various modules for database accessing: |
-http://www.python.org/topics/database/modules.html |
- |
-Anyway - this script provides connection to the database server by the |
-specified values in the hostname, dbname, username, and password variables. |
-Then it checks the system for table names in the specified databases |
-and it displays it in the new document finally. Easy and understandable. |
- |
- |
-CONTACT: |
-email : petr@yarpen.cz |
- |
- |
-LICENSE: |
-This program is free software; you can redistribute it and/or modify |
-it under the terms of the GNU General Public License as published by |
-the Free Software Foundation; either version 2 of the License, or |
-(at your option) any later version. |
- |
-This program is distributed in the hope that it will be useful, |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-GNU General Public License for more details. |
- |
-You should have received a copy of the GNU General Public License |
-along with this program; if not, write to the Free Software |
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
-""" |
- |
-import sys |
- |
-# environment checking |
-try: |
- import scribus |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-try: |
- import MySQLdb |
-except ImportError: |
- print "You must have 'MySQLdb' installed." |
- sys.exit(1) |
- |
- |
-# connection parameters |
-hostname = 'server.foo.org' |
-dbname = 'name' |
-username = 'username' |
-password = 'password' |
- |
-# connection to the network wide server would be time consuming. So get the hint to the user. |
-scribus.statusMessage('Connecting to the ' + hostname + ' server. Be patient, please...') |
- |
-# Database related issues |
-try: |
- conn = MySQLdb.connect(passwd=password, db=dbname, host=hostname, user=username) |
-except: |
- scribus.messageBox('DB connection example', 'Connection error. You should specify your login in the script') |
- sys.exit(1) |
- |
-cur = conn.cursor() |
-# get the list of the databases |
-# it's like 'select * from dba_tables' in Oracle |
-count = cur.execute('show tables') |
-# formatting the output |
-result = str(count) + ' table(s) in the ' + dbname + ' database.\n\n' |
-for i in cur.fetchall(): |
- result = result + i[0] + '\n' |
- |
-# Scribus presentation part |
-scribus.newDoc(scribus.PAPER_A5, (10, 10, 20, 20), scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT) |
-txtName = scribus.createText(10, 10, 200, 200) |
-scribus.setText(result, txtName) |
- |
-scribus.statusMessage('Script done.') |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/3columnUSLTR.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/3columnUSLTR.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/3columnUSLTR.py (nonexistent) |
@@ -1,51 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" Creates 3 column layout on US Letter paper and save it under 3columnUSLTR.sla filename. This is a simple way to demonstrate creating a doc on the fly. """ |
- |
-try: |
- # Please do not use 'from scribus import *' . If you must use a 'from import', |
- # Do so _after_ the 'import scribus' and only import the names you need, such |
- # as commonly used constants. |
- import scribus |
-except ImportError,err: |
- print "This Python script is written for the Scribus scripting interface." |
- print "It can only be run from within Scribus." |
- sys.exit(1) |
- |
-def main(argv): |
- """This is a simple way to demonstrate creating a doc on the fly. """ |
- |
- pass # <--- Delete this line |
- |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-margins = (50, 50, 50, 50) |
-size = (612, 792) |
- |
-def main(): |
- if newDocument(PAPER_LETTER, margins, LANDSCAPE, 1, UNIT_POINTS, NOFACINGPAGES, FIRSTPAGELEFT, 1): |
- a = createText(50, 50, 230, 512) |
- setTextAlignment(1,a) |
- setText("Column A", a) |
- setFontSize(12, a) |
- b = createText(280, 50, 230, 512) |
- setTextAlignment(1,b) |
- setText("Column B", b) |
- setFontSize(12, b) |
- c = createText(510, 50, 230, 512) |
- setTextAlignment(1,b) |
- setText("Column C", c) |
- setFontSize(12, c) |
- #saveDocAs("3columnUS.sla") |
- |
- |
-if __name__ == '__main__': |
- main() |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/Calender.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/Calender.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/Calender.py (nonexistent) |
@@ -1,75 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" This Script creates a Calendar Sheet for the Current Month """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-import calendar |
-import time |
- |
-def main(): |
- Month = time.localtime()[1] |
- Year = time.localtime()[0] |
- Objects = [] |
- MonthList = ["January","February","March","April","May","June","July","August","September","October","November","December"] |
- DaysList = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"] |
- Xcoor = 10 |
- Ycoor = 30 |
- DayC = 0 |
- Calend = calendar.monthcalendar(Year, Month) |
- ob = createText(10, 10, 245, 20) |
- Title = MonthList[Month-1] + " " + str(Year) |
- setText(Title, ob) |
- Objects.append(ob) |
- for lx in range(45, 245, 35): |
- ob = createLine(lx, 30, lx, 20*len(Calend)+50) |
- Objects.append(ob) |
- for ly in range(50, 20*len(Calend)+50, 20): |
- ob = createLine(10, ly, 255, ly) |
- Objects.append(ob) |
- ob = createRect(10, 30, 245, 20*len(Calend)+20) |
- setFillColor("None", ob) |
- Objects.append(ob) |
- for day in range(7): |
- ob = createText(Xcoor, Ycoor, 35, 20) |
- setTextAlignment(ALIGN_CENTERED, ob) |
- setFontSize(12, ob) |
- if day == 6: |
- setTextColor("Red", ob) |
- setText(DaysList[day], ob) |
- Objects.append(ob) |
- Xcoor = Xcoor + 35 |
- Ycoor = Ycoor + 20 |
- for lines in Calend: |
- Xcoor = 10 |
- DayC = 0 |
- for rows in lines: |
- if rows != 0: |
- ob = createText(Xcoor, Ycoor, 35, 20) |
- setTextAlignment(ALIGN_CENTERED, ob) |
- if DayC == 6: |
- setTextColor("Red", ob) |
- setText(str(rows), ob) |
- Objects.append(ob) |
- Xcoor = Xcoor + 35 |
- DayC = DayC + 1 |
- Ycoor = Ycoor + 20 |
- groupObjects(Objects) |
- |
-if __name__ == '__main__': |
- if haveDoc(): |
- try: |
- setRedraw(False) |
- main() |
- finally: |
- setRedraw(True) |
- redrawAll() |
- else: |
- messageBox("Calendar Script", "Please run this script with a document open.", ICON_INFORMATION); |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/plus_10_pourcent_group.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/plus_10_pourcent_group.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/plus_10_pourcent_group.py (nonexistent) |
@@ -1,17 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" Make selected group larger by 10% """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-if haveDoc() and selectionCount(): |
- scaleGroup(1.1) |
-else: |
- messageBox("plus_10_pourcent_group.py", "Please select an object to scale before running this script.", ICON_INFORMATION) |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/ExtractText.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/ExtractText.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/ExtractText.py (nonexistent) |
@@ -1,81 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" |
- |
-(C)2006.03.04 Gregory Pittman |
- |
-(C)2008.02.28 Petr Vanek - fileDialog replaces valueDialog |
- |
-this version 2008.02.28 |
- |
-This program is free software; you can redistribute it and/or modify |
-it under the terms of the GPL, v2 (GNU General Public License as published by |
-the Free Software Foundation, version 2 of the License), or any later version. |
-See the Scribus Copyright page in the Help Browser for further information |
-about GPL, v2. |
- |
-SYNOPSIS |
- |
-This script takes the current document and extracts all the text from text frames, |
-and also gets the pathnames to all images. This is then saved to a file named |
-by the user. |
- |
-REQUIREMENTS |
- |
-You must run from Scribus and must have a file open. |
- |
-USAGE |
- |
-Start the script. A file dialog appears for the name of the file |
-to save to. The above information is saved to the file. |
- |
-""" |
-# Craig Bradney, Scribus Team |
-# 10/3/08: Added to Scribus 1.3.3.12svn distribution "as was" from Scribus wiki for bug #6826, script is GPLd |
- |
-import scribus |
- |
- |
-def exportText(textfile): |
- page = 1 |
- pagenum = scribus.pageCount() |
- T = [] |
- content = [] |
- while (page <= pagenum): |
- scribus.gotoPage(page) |
- d = scribus.getPageItems() |
- strpage = str(page) |
- T.append('Page '+ strpage + '\n\n') |
- for item in d: |
- if (item[1] == 4): |
- contents = scribus.getAllText(item[0]) |
- if (contents in content): |
- contents = 'Duplication, perhaps linked-to frame' |
- T.append(item[0]+': '+ contents + '\n\n') |
- content.append(contents) |
- elif (item[1] == 2): |
- imgname = scribus.getImageFile(item[0]) |
- T.append(item[0]+': ' + imgname + '\n') |
- page += 1 |
- T.append('\n') |
- output_file = open(textfile,'w') |
- output_file.writelines(T) |
- output_file.close() |
- endmessage = textfile + ' was created' |
- scribus.messageBox("Finished", endmessage, scribus.ICON_NONE, scribus.BUTTON_OK) |
- |
- |
-if scribus.haveDoc(): |
- textfile = scribus.fileDialog('Enter name of file to save to', \ |
- filter='Text Files (*.txt);;All Files (*)') |
- try: |
- if textfile == '': |
- raise Exception |
- exportText(textfile) |
- except Exception, e: |
- print e |
- |
-else: |
- scribus.messageBox('Export Error', 'You need a Document open, and a frame selected.', \ |
- scribus.ICON_NONE, scribus.BUTTON_OK) |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/moins_10_pourcent_group.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/moins_10_pourcent_group.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/moins_10_pourcent_group.py (nonexistent) |
@@ -1,17 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" Make selected group smaller by 10% """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-if haveDoc() and selectionCount(): |
- scaleGroup(1/1.1) |
-else: |
- messageBox("moins_10_pourcent_group.py", "Please select an object to scale before running this script.", ICON_INFORMATION) |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/pochette_cd.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/pochette_cd.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/pochette_cd.py (nonexistent) |
@@ -1,117 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" This script creates a CD Pochette - a paper pocket for CD/DVD disc """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-margins = (0, 0, 0, 0) |
-paper = (210, 297) |
- |
-def main(): |
- if newDocument(paper, margins, 1, 1, 1, NOFACINGPAGES, FIRSTPAGELEFT,1): |
- setUnit(1) |
- newPage(-1) |
- gotoPage(1) |
- createLayer("normal") |
- setActiveLayer("normal") |
- a = createText(98.5, 20, 100, 10) |
- setText("CD pochette - front page", a) |
- setFontSize(11, a) |
- setTextAlignment(1, a) |
- b = createText(28.5, 45, 120, 120) |
- setFillColor("None", b) |
- c = createText(148.5, 45, 120, 120) |
- setFillColor("None", c) |
- createLayer("bords_perdus") |
- setActiveLayer("bords_perdus") |
- img1 = createImage(24.35, 41.25 , 124.20, 127.95,) |
- img2 = createImage(148.55, 41.25 , 124.20, 127.95,) |
- createLayer("coupe") |
- setActiveLayer("coupe") |
- t1 = createLine(28.5, 38, 28.5, 43) |
- setLineWidth(0.1, t1) |
- t2 = createLine(148.5, 38, 148.5, 43) |
- setLineWidth(0.1, t2) |
- t3 = createLine(268.5, 38, 268.5, 43) |
- setLineWidth(0.1, t3) |
- t4 = createLine(28.5, 172, 28.5, 167) |
- setLineWidth(0.1, t4) |
- t5 = createLine(148.5, 172, 148.5, 167) |
- setLineWidth(0.1, t5) |
- t6 = createLine(268.5, 172, 268.5, 167) |
- setLineWidth(0.1, t6) |
- t7 = createLine(21.5, 45, 26.5, 45) |
- setLineWidth(0.1, t7) |
- t8 = createLine(21.5, 165, 26.5, 165) |
- setLineWidth(0.1, t8) |
- t9 = createLine(270.5, 45, 275.5, 45) |
- setLineWidth(0.1, t9) |
- t10 = createLine(270.5, 165, 275.5, 165) |
- setLineWidth(0.1, t10) |
- gotoPage(2) |
- setActiveLayer("normal") |
- a2 = createText(98.5, 20, 100, 10) |
- setText("CD pochette - back page", a2) |
- setFontSize(11, a2) |
- setTextAlignment(1, a2) |
- a2t = createText(204, 44, 78, 9) |
- setText("Mode d'emploi :", a2t) |
- setFontSize(13, a2t) |
- setTextAlignment(1, a2t) |
- a21 = createText(204, 54, 78, 87) |
- setText("Usage. TODO: tranlslate it from french", a21) |
- setFontSize(11, a21) |
- setTextAlignment(0, a21) |
- b2 = createText(28.5, 162.10, 117, 6) |
- setText("Texte sur la tranche", b2) |
- setFontSize(9, b2) |
- setTextAlignment(1, b2) |
- rotateObjectAbs(90, b2) |
- setFillColor("None", b2) |
- c2 = createText(34.5, 45, 137.5, 117) |
- setFillColor("None", c2) |
- d2 = createText(28.5, 162.10, 117, 6) |
- setText("Texte sur la tranche", d2) |
- setFontSize(9, d2) |
- setTextAlignment(1, d2) |
- rotateObjectAbs(90, d2) |
- setFillColor("None", d2) |
- moveObject(143.5, 0, d2) |
- setActiveLayer("bords_perdus") |
- img3 = createImage(24.35, 41.25 , 157.50, 126.50,) |
- setActiveLayer("coupe") |
- t21 = createLine(28.5, 38, 28.5, 43) |
- setLineWidth(0.1, t21) |
- t22 = createLine(34.5, 38, 34.5, 43) |
- setLineWidth(0.1, t22) |
- t23 = createLine(172, 38, 172, 43) |
- setLineWidth(0.1, t23) |
- t24 = createLine(178, 38, 178, 43) |
- setLineWidth(0.1, t24) |
- t25 = createLine(28.5, 164.5, 28.5, 169.5) |
- setLineWidth(0.1, t25) |
- t26 = createLine(34.5, 164, 34.5, 169.5) |
- setLineWidth(0.1, t26) |
- t27 = createLine(172, 164, 172, 169.5) |
- setLineWidth(0.1, t27) |
- t28 = createLine(178, 164, 178, 169.5) |
- setLineWidth(0.1, t28) |
- t29 = createLine(22.5, 45, 27.5, 45) |
- setLineWidth(0.1, t29) |
- t30 = createLine(22.5, 162, 27.5, 162) |
- setLineWidth(0.1, t30) |
- t31 = createLine(179.5, 45, 184.5, 45) |
- setLineWidth(0.1, t31) |
- t32 = createLine(179.5, 162, 184.5, 162) |
- setLineWidth(0.1, t32) |
- saveDocAs("pochette_CD.sla") |
- |
-if __name__ == '__main__': |
- main() |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/wordcount.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/wordcount.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/wordcount.py (nonexistent) |
@@ -1,65 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" Counts the words in the whole document or in a textframe """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-import re |
- |
-TITLE = "Word count" |
- |
-def wordsplit(text): |
- word_pattern = "([A-Za-zäöüÄÖÜß]+)" |
- words = [] |
- for x in re.split(word_pattern, text): |
- if re.match(word_pattern, x): |
- words.append(x) |
- return words |
- |
- |
-def main(): |
- words = 0 |
- sel_count = selectionCount() |
- if sel_count: |
- source = "selected textframe" |
- if sel_count > 1: source += "s" #plural |
- for i in range(sel_count): |
- try: |
- text = getText(getSelectedObject(i)) |
- words += len(wordsplit(text)) |
- except WrongFrameTypeError: |
- if sel_count == 1: |
- # If there's only one object selected, display a message |
- messageBox(TITLE, "Can't count words in a non-text frame", ICON_INFORMATION); |
- sys.exit(1) |
- else: |
- # otherwise ignore |
- pass |
- else: |
- source = "whole document" |
- for page in range(1,pageCount() + 1): |
- gotoPage(page) |
- for obj in getAllObjects(): |
- try: |
- text = getText(obj) |
- words += len(wordsplit(text)) |
- except WrongFrameTypeError: |
- pass # ignore the error, it just wasn't a frame we can count |
- |
- if words == 0: words = "No" |
- messageBox(TITLE, "%s words counted in %s" % (words, source), |
- ICON_INFORMATION) |
- |
- |
-if __name__ == '__main__': |
- if haveDoc(): |
- main() |
- else: |
- messageBox(TITLE, "No document open", ICON_WARNING) |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/CMakeLists.txt |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/CMakeLists.txt (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/CMakeLists.txt (nonexistent) |
@@ -1,22 +0,0 @@ |
-include_directories( |
-"${CMAKE_SOURCE_DIR}/scribus" |
-) |
- |
-install(FILES |
-3columnUSLTR.py |
-3columnA4.py |
-boilerplate.py |
-Calender.py |
-ExtractText.py |
-golden-mean.py |
-legende.py |
-moins_10_pourcent_group.py |
-plus_10_pourcent_group.py |
-pochette_cd.py |
-quote.py |
-sample_db_usage.py |
-Sample1.py |
-trait_de_coupe.py |
-wordcount.py |
- DESTINATION ${SAMPLESDIR} |
-) |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/CMakeLists.txt |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/trait_de_coupe.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/trait_de_coupe.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/trait_de_coupe.py (nonexistent) |
@@ -1,42 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" Draws a "crop marks" around selected object """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-def main(): |
- userUnit = getUnit() |
- setUnit(1) |
- x,y = getPosition() |
- l,h = getSize() |
- t1 = createLine(x, y-2, x, y-7) |
- setLineWidth(0.1, t1) |
- t2 = createLine(x+l, y-2, x+l, y-7) |
- setLineWidth(0.1, t2) |
- t3 = createLine(x, y+7+h, x, y+2+h) |
- setLineWidth(0.1, t3) |
- t4 = createLine(x+l, y+7+h, x+l, y+2+h) |
- setLineWidth(0.1, t4) |
- t5 = createLine(x-2, y, x-7, y) |
- setLineWidth(0.1, t5) |
- t6 = createLine(x-2, y+h, x-7, y+h) |
- setLineWidth(0.1, t6) |
- t7 = createLine(x+l+2, y+h, x+l+7, y+h) |
- setLineWidth(0.1, t7) |
- t7 = createLine(x+l+2, y, x+l+7, y) |
- setLineWidth(0.1, t7) |
- deselectAll() |
- setUnit(userUnit) |
- |
-if __name__ == '__main__': |
- if haveDoc() and selectionCount(): |
- main() |
- else: |
- messageBox("trait_de_coupe.py", "Please select an object to put crop marks around<i>before</i> running this script.", ICON_INFORMATION) |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/golden-mean.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/golden-mean.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/golden-mean.py (nonexistent) |
@@ -1,75 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-"""Golden Mean for Scribus. |
- |
-This script creates supplementary guides on the page to |
-help design the "right" layout in golden mean (golden |
-ratio). |
- |
-See scribus.net and CVS for fresh versions to come... |
- |
-REQUIREMENTS: |
-Scribus - CVS version later 02/24/2004 or later release 1.5 |
- |
-MORE INFO: |
-See e.g. |
-http://home.att.net/~vmueller/prop/theo.html |
-or Google for more theory :) |
- |
-CONTACT: |
-email : petr@yarpen.cz |
-Feature requests and bug reports welcomed |
- |
- |
-LICENSE: |
- |
-This program is free software; you can redistribute it and/or modify |
-it under the terms of the GNU General Public License as published by |
-the Free Software Foundation; either version 2 of the License, or |
-(at your option) any later version. |
- |
-This program is distributed in the hope that it will be useful, |
-but WITHOUT ANY WARRANTY; without even the implied warranty of |
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-GNU General Public License for more details. |
- |
-You should have received a copy of the GNU General Public License |
-along with this program; if not, write to the Free Software |
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
-""" |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-from math import sqrt |
- |
- |
-def goldenMean(aSize=0): |
- """x = (?5-1)/2""" |
- return aSize * ((sqrt(5) - 1)/2) |
- |
- |
-def main(): |
- # remember user settings |
- unit = getUnit() |
- # set my environment - points needed |
- setUnit(0) |
- # Paper format |
- paper = pageDimension() |
- # set the guides. The get* functions are for "remembering" the old ones... |
- setVGuides(getVGuides() + [goldenMean(paper[0]), paper[0] - goldenMean(paper[0])]) |
- setHGuides(getHGuides() + [goldenMean(paper[1]), paper[1] - goldenMean(paper[1])]) |
- # restore user settings |
- setUnit(unit) |
- |
-if __name__ == '__main__': |
- if haveDoc(): |
- main() |
- else: |
- messageBox("Golden Mean.py", "Please run this script with a document already open", ICON_INFORMATION); |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/quote.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/quote.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/quote.py (nonexistent) |
@@ -1,75 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: iso-8859-1 -*- |
- |
-""" This script changes quotation marks from " " to french style """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-import re |
- |
-TITLE = "Text quoting" |
- |
-# These need to be declared as unicode strings until some |
-# charset issues in the scripter are worked out. |
-QUOTE_START = u"" |
-QUOTE_END = u"" |
- |
-def quote(textobj): |
- quoted_re = re.compile('"[^"]*"') |
- try: |
- text = getText(textobj) |
- except WrongFrameTypeError: |
- messageBox("quote.py", "Cannot quote text in a non-text frame", ICON_INFORMATION); |
- sys.exit(1) |
- if len(text) == 0: |
- return 0 # We can't very well change anything in an empty frame |
- count = 0 |
- i = 0 |
- selectText(0, 0, textobj) |
- while i < len(text): |
- match = quoted_re.match(text[i:]) |
- if match: |
- end = match.end() |
- selectText(i, 1, textobj) |
- deleteText(textobj) |
- insertText(QUOTE_START, i, textobj) |
- selectText(i + end - 1, 1, textobj) |
- deleteText(textobj) |
- insertText(QUOTE_END, i + end - 1, textobj) |
- count += 1 |
- i = i + end |
- else: |
- i = i + 1 |
- return count |
- |
- |
-def main(): |
- changed = 0 |
- sel_count = selectionCount() |
- if sel_count: |
- for i in range(sel_count): |
- changed += quote(getSelectedObject(i)) |
- else: |
- for page in range(pageCount()): |
- gotoPage(page) |
- for obj in getAllObjects(): |
- changed += quote(obj) |
- messageBox(TITLE, "%s quotations changed" % changed, |
- ICON_INFORMATION, BUTTON_OK) |
- |
-if __name__ == '__main__': |
- if haveDoc(): |
- try: |
- setRedraw(False) |
- main() |
- finally: |
- setRedraw(True) |
- redrawAll() |
- else: |
- messageBox(TITLE, "No document open", ICON_WARNING, BUTTON_OK) |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/Sample1.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/Sample1.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/Sample1.py (nonexistent) |
@@ -1,26 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" A sample script """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-margins = (10, 10, 10, 30) |
- |
-def main(): |
- if newDocument(PAPER_A4, margins, PORTRAIT, 1, UNIT_POINTS, NOFACINGPAGES, FIRSTPAGERIGHT, 1): |
- a = createText(50, 50, 200, 80) |
- setText("A Test for Scribus", a) |
- setFontSize(20, a) |
- b = createEllipse(267, 391, 60, 60) |
- setFillColor("Red", b) |
- saveDocAs("Sample1.sla") |
- |
-if __name__ == '__main__': |
- main() |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/boilerplate.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/boilerplate.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/boilerplate.py (nonexistent) |
@@ -1,51 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-import sys |
- |
-try: |
- # Please do not use 'from scribus import *' . If you must use a 'from import', |
- # Do so _after_ the 'import scribus' and only import the names you need, such |
- # as commonly used constants. |
- import scribus |
-except ImportError,err: |
- print "This Python script is written for the Scribus scripting interface." |
- print "It can only be run from within Scribus." |
- sys.exit(1) |
- |
-######################### |
-# YOUR IMPORTS GO HERE # |
-######################### |
- |
-def main(argv): |
- """This is a documentation string. Write a description of what your code |
- does here. You should generally put documentation strings ("docstrings") |
- on all your Python functions.""" |
- ######################### |
- # YOUR CODE GOES HERE # |
- ######################### |
- pass # <--- Delete this line |
- |
-def main_wrapper(argv): |
- """The main_wrapper() function disables redrawing, sets a sensible generic |
- status bar message, and optionally sets up the progress bar. It then runs |
- the main() function. Once everything finishes it cleans up after the main() |
- function, making sure everything is sane before the script terminates.""" |
- try: |
- scribus.statusMessage("Running script...") |
- scribus.progressReset() |
- main(argv) |
- finally: |
- # Exit neatly even if the script terminated with an exception, |
- # so we leave the progress bar and status bar blank and make sure |
- # drawing is enabled. |
- if scribus.haveDoc(): |
- scribus.setRedraw(True) |
- scribus.statusMessage("") |
- scribus.progressReset() |
- |
-# This code detects if the script is being run as a script, or imported as a module. |
-# It only runs main() if being run as a script. This permits you to import your script |
-# and control it manually for debugging. |
-if __name__ == '__main__': |
- main_wrapper(sys.argv) |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/legende.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/legende.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/samples/legende.py (nonexistent) |
@@ -1,39 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-""" When you have an image selected this script creates small text legende |
-(caption) below the image. The new textframe contains name of the file. """ |
- |
-import sys |
- |
-try: |
- from scribus import * |
-except ImportError: |
- print "This script only runs from within Scribus." |
- sys.exit(1) |
- |
-import os |
- |
-def main(): |
- userUnit = getUnit() |
- setUnit(1) |
- sel_count = selectionCount() |
- |
- if sel_count == 0: |
- messageBox("legende.py", |
- "Please select the object to add a caption to before running this script.", |
- ICON_INFORMATION) |
- sys.exit(1) |
- |
- x,y = getPosition() |
- l,h = getSize() |
- texte = getImageFile() |
- image = os.path.basename(texte) |
- a = createText(x,y+h+2,l,8) |
- insertText(image,0,a) |
- setTextAlignment(2,a) |
- setFontSize(7,a) |
- setUnit(userUnit) |
- |
-if __name__ == '__main__': |
- main() |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddialog.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddialog.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddialog.cpp (nonexistent) |
@@ -1,162 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "cmddialog.h" |
-#include "cmdutil.h" |
-#include "scribuscore.h" |
-#include "ui/customfdialog.h" |
-#include "ui/scmessagebox.h" |
-#include "ui/stylemanager.h" |
- |
-#include <QMessageBox> |
-#include <QCursor> |
-#include <QInputDialog> |
- |
- |
-PyObject *scribus_newdocdialog(PyObject* /* self */) |
-{ |
- QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor)); |
- bool ret = ScCore->primaryMainWindow()->slotFileNew(); |
- QApplication::changeOverrideCursor(Qt::ArrowCursor); |
- return PyInt_FromLong(static_cast<long>(ret)); |
-} |
- |
-PyObject *scribus_filedialog(PyObject* /* self */, PyObject* args, PyObject* kw) |
-{ |
- char *caption = const_cast<char*>(""); |
- char *filter = const_cast<char*>(""); |
- char *defName = const_cast<char*>(""); |
- int haspreview = 0; |
- int issave = 0; |
- int isdir = 0; |
- // FIXME: parsing named params failure. e.g. fileDialog(caption="foo", issave=True) |
- // FIXME: it's a bug in Python. I'm monitoring it |
- // https://sourceforge.net/tracker/index.php?func=detail&aid=893549&group_id=5470&atid=105470 |
- char* kwargs[] = {const_cast<char*>("caption"), const_cast<char*>("filter"), |
- const_cast<char*>("defaultname"), const_cast<char*>("haspreview"), |
- const_cast<char*>("issave"), const_cast<char*>("isdir"), |
- nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "es|esesiii", kwargs, |
- "utf-8", &caption, "utf-8", &filter, "utf-8", &defName, |
- &haspreview, &issave, &isdir)) |
- { |
- return nullptr; |
- } |
- QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor)); |
- /* nobool = Nothing doing boolean for CFileDialog last attrs. |
- Due the 'isdir' parameter. CFileDialog needs the last 2 pointers |
- initialized. */ |
- bool nobool = false; |
- int optionFlags = 0; |
- if (haspreview) |
- optionFlags |= fdShowPreview; |
- if (issave) |
- optionFlags |= fdExistingFiles; |
- if (isdir) |
- optionFlags |= fdDirectoriesOnly; |
- QString fName = ScCore->primaryMainWindow()->CFileDialog(".", |
- QString::fromUtf8(caption), |
- QString::fromUtf8(filter), |
- QString::fromUtf8(defName), |
- optionFlags, |
- &nobool, |
- &nobool, |
- &nobool |
- ); |
-// QApplication::restoreOverrideCursor(); |
- // FIXME: filename return unicode OK? |
- return PyString_FromString(fName.toUtf8()); |
-} |
- |
-PyObject *scribus_messagebox(PyObject* /* self */, PyObject* args, PyObject* kw) |
-{ |
- char *caption = const_cast<char*>(""); |
- char *message = const_cast<char*>(""); |
- uint result; |
- QMessageBox::Icon ico = QMessageBox::NoIcon; |
- int butt[3] = { QMessageBox::Ok|QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton }; |
- QMessageBox::StandardButtons buttons; |
- enum QMessageBox::StandardButton defaultButton = QMessageBox::NoButton; |
- char* kwargs[] = {const_cast<char*>("caption"), const_cast<char*>("message"), |
- const_cast<char*>("icon"), const_cast<char*>("button1"), |
- const_cast<char*>("button2"), const_cast<char*>("button3"), nullptr}; |
- if (!PyArg_ParseTupleAndKeywords(args, kw, "eses|iiii", kwargs, "utf-8", &caption, "utf-8", &message, &ico, &butt[0], &butt[1], &butt[2])) |
- return nullptr; |
- QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor)); |
- // ScMessageBox mb(ico, butt1, butt2, butt3, ScCore->primaryMainWindow()); |
- for (int bi = 0; bi < 3; bi++) { |
- enum QMessageBox::StandardButton b = static_cast<QMessageBox::StandardButton>(butt[bi]); |
- if (b != QMessageBox::NoButton) { |
- if ((b & QMessageBox::Default) != 0) { |
- b = QMessageBox::StandardButton(b & ~QMessageBox::Default); |
- defaultButton = b; |
- } |
- buttons |= b; |
- } |
- } |
- ScMessageBox mb(ico, QString::fromUtf8(caption), QString::fromUtf8(message), buttons, ScCore->primaryMainWindow()); |
- if (defaultButton != QMessageBox::NoButton) { |
- mb.setDefaultButton(defaultButton); |
- } |
- result = mb.exec(); |
-// QApplication::restoreOverrideCursor(); |
- return PyInt_FromLong(static_cast<long>(result)); |
-} |
- |
-PyObject *scribus_valuedialog(PyObject* /* self */, PyObject* args) |
-{ |
- char *caption = const_cast<char*>(""); |
- char *message = const_cast<char*>(""); |
- char *value = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "eses|es", "utf-8", &caption, "utf-8", &message, "utf-8", &value)) |
- return nullptr; |
- QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor)); |
- QString txt = QInputDialog::getText(ScCore->primaryMainWindow(), |
- QString::fromUtf8(caption), |
- QString::fromUtf8(message), |
- QLineEdit::Normal, |
- QString::fromUtf8(value)); |
-// QApplication::restoreOverrideCursor(); |
- return PyString_FromString(txt.toUtf8()); |
-} |
- |
-PyObject *scribus_newstyledialog(PyObject*, PyObject* args) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- ScribusDoc *d = ScCore->primaryMainWindow()->doc; |
- bool ok; |
- QString s = QInputDialog::getText(ScCore->primaryMainWindow(), "New Paragraph Style", |
- "Enter name of the new paragraph style:", QLineEdit::Normal, |
- QString(), &ok); |
- |
- if (ok && !s.isEmpty()) |
- { |
- StyleSet<ParagraphStyle> st; |
- st.redefine(d->paragraphStyles(), true); |
- ParagraphStyle p; |
- p.setName(s); |
- st.create(p); |
- d->redefineStyles(st, false); |
- ScCore->primaryMainWindow()->styleMgr()->setDoc(d); |
- return PyString_FromString(s.toUtf8()); |
- } |
- Py_RETURN_NONE; |
-} |
- |
-/*! HACK: this removes "warning: 'blash' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmddialogdocwarnings() |
-{ |
- QStringList s; |
- s << scribus_filedialog__doc__ |
- << scribus_messagebox__doc__ |
- << scribus_newdocdialog__doc__ |
- << scribus_newstyledialog__doc__ |
- << scribus_valuedialog__doc__ ; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddialog.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.h (nonexistent) |
@@ -1,50 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef SCRIPTPLUG_H |
-#define SCRIPTPLUG_H |
- |
-#include "cmdvar.h" |
-#include "scplugin.h" |
-#include "pluginapi.h" |
- |
-#include <QByteArray> |
-#include <QPixmap> |
- |
-class QString; |
-class QPixmap; |
-class QWidget; |
- |
-class PLUGIN_API ScriptPlugin : public ScPersistentPlugin |
-{ |
- Q_OBJECT |
- |
- public: |
- // Standard plugin implementation |
- ScriptPlugin(); |
- ~ScriptPlugin() override; |
- bool initPlugin() override; |
- bool cleanupPlugin() override; |
- QString fullTrName() const override; |
- const AboutData* getAboutData() const override; |
- void deleteAboutData(const AboutData* about) const override; |
- void languageChange() override; |
- bool newPrefsPanelWidget(QWidget* parent, Prefs_Pane*& panel) override; |
- void addToMainWindowMenu(ScribusMainWindow *) override; |
- |
- // Special features (none) |
- QByteArray pythonHome; |
-}; |
- |
-extern "C" PLUGIN_API int scriptplugin_py2x_getPluginAPIVersion(); |
-extern "C" PLUGIN_API ScPlugin* scriptplugin_py2x_getPlugin(); |
-extern "C" PLUGIN_API void scriptplugin_py2x_freePlugin(ScPlugin* plugin); |
- |
-/** Some useful Subroutines */ |
-/*static */PyObject *scribus_py2x_retval(PyObject *self, PyObject* args); |
-/*static */PyObject *scribus_py2x_getval(PyObject *self); |
- |
-#endif // CMSPLUG_H |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdstyle.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdstyle.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdstyle.h (nonexistent) |
@@ -1,161 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-02.01.2008: Joachim Neu - joachim_neu@web.de - http://www.joachim-neu.de |
-*/ |
-#ifndef CMDSTYLE_H |
-#define CMDSTYLE_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
-//Added by qt3to4: |
-#include <QPixmap> |
- |
-/** Style-related Commands */ |
- |
-/* PARAGRAPH STYLES */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createparagraphstyle__doc__, |
-QT_TR_NOOP("createParagraphStyle(...)\n\n\ |
-Creates a paragraph style. This function takes the following keyword parameters:\n\n\ |
-\"name\" [required] -> specifies the name of the paragraphstyle to create\n\n\ |
-linespacingmode [optional] -> specifies the linespacing mode; possible modes are:\n\n\ |
-fixed linespacing: 0\n\n\ |
-automatic linespacing: 1\n\n\ |
-baseline grid linespacing: 2\n\n\ |
-linespacing [optional] -> specifies the linespacing if using fixed linespacing\n\n\ |
-alignment [optional] -> specifies the alignment of the paragraph\n\n\ |
--> left: 0\n\n\ |
--> center: 1\n\n\ |
--> right: 2\n\n\ |
--> justify: 3\n\n\ |
--> extend: 4\n\n\ |
-leftmargin [optional], rightmargin [optional] -> specify the margin\n\n\ |
-gapbefore [optional], gapafter [optional] -> specify the gaps to the heading and following paragraphs\n\n\ |
-firstindent [optional] -> the indent of the first line\n\n\ |
-hasdropcap [optional] -> specifies if there are caps (1 = yes, 0 = no)\n\n\ |
-dropcaplines [optional] -> height (in lines) of the caps if used\n\n\ |
-dropcapoffset [optional] -> offset of the caps if used\n\n\ |
-\"charstyle\" [optional] -> char style to use\n\n\ |
-\"bullet\" [optional] -> string to use as bullet\n\n\ |
-\"tabs\" [optional] -> a list containing tab definitions\n\n\ |
--> a tab is defined as a tuple with the following format (position,type,fillchar)\"\n\n\ |
--> position [required] -> float value for the position\n\n\ |
--> type [optional] -> left: 0 [default], right: 1, period: 2, comma: 3, center: 4\n\n\ |
--> fillchar [optional] -> the char to fill the space; default is none\n\n\ |
-")); |
-/*! 02.01.2007 - 05.01.2007 : Joachim Neu : Create a paragraph style. |
- Special thanks go to avox for helping me! */ |
-PyObject *scribus_createparagraphstyle(PyObject * /* self */, PyObject* args, PyObject* keywords); |
- |
-/* CHAR STYLES */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createcharstyle__doc__, |
-QT_TR_NOOP("createCharStyle(...)\n\n\ |
-Creates a character style. This function takes the following keyword parameters:\n\n\ |
-\"name\" [required] -> name of the char style to create\n\n\ |
-\"font\" [optional] -> name of the font to use\n\n\ |
-fontsize [optional] -> font size to set (double)\n\n\ |
-\"features\" [optional] -> nearer typographic details can be defined by a string that might contain the following phrases comma-separated (without spaces!):\n\n\ |
--> inherit\n\n\ |
--> bold\n\n\ |
--> italic\n\n\ |
--> underline\n\n\ |
--> underlinewords\n\n\ |
--> strike\n\n\ |
--> superscript\n\n\ |
--> subscript\n\n\ |
--> outline\n\n\ |
--> shadowed\n\n\ |
--> allcaps\n\n\ |
--> smallcaps\n\n\ |
-\"fillcolor\" [optional], \"fillshade\" [optional] -> specify fill options\n\n\ |
-\"strokecolor\" [optional], \"strokeshade\" [optional] -> specify stroke options\n\n\ |
-baselineoffset [optional] -> offset of the baseline\n\n\ |
-shadowxoffset [optional], shadowyoffset [optional] -> offset of the shadow if used\n\n\ |
-outlinewidth [optional] -> width of the outline if used\n\n\ |
-underlineoffset [optional], underlinewidth [optional] -> underline options if used\n\n\ |
-strikethruoffset [optional], strikethruwidth [optional] -> strikethru options if used\n\n\ |
-scaleh [optional], scalev [optional] -> scale of the chars\n\n\ |
-tracking [optional] -> tracking of the text\n\n\ |
-\"language\" [optional] -> language code\n\n\ |
-")); |
-/*! 03.01.2007 - 05.01.2007 : Joachim Neu : Create a char style. |
- Special thanks go to avox for helping me! */ |
-PyObject *scribus_createcharstyle(PyObject * /* self */, PyObject* args, PyObject* keywords); |
- |
-/* LINE STYLES */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createcustomlinestyle__doc__, |
-QT_TR_NOOP("createCustomLineStyle(styleName, style)\n\n\ |
-Creates the custom line style 'styleName'.\n\n\ |
-styleName -> name of the custom line style to create\n\n\ |
-This function takes list of dictionary\n\ |
-as parameter for \"style\". Each dictionary represent\n\ |
-one subline within style. Dictionary can have those keys:\n\n\ |
-\tColor [optional] -> name of the color to use (string)\n\n\ |
-\tDash [optional] -> type of line to use (integer)\n\n\ |
-\tLineEnd [optional] -> type of LineEnd to use (integer)\n\n\ |
-\tLineJoin [optional] -> type of LineJoin to use (integer)\n\n\ |
-\tShade [optional] -> opacity of line (integer)\n\n\ |
-\tWidth [optional] -> width of line (double)\n\ |
-")); |
-PyObject *scribus_createcustomlinestyle(PyObject * /* self */, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getparagraphstyles__doc__, |
-QT_TR_NOOP("getParagraphStyles() -> list\n\ |
-\n\ |
-Return a list of the names of all paragraph styles in the current document.\n\ |
-")); |
- |
-PyDoc_STRVAR(scribus_getallstyles__doc__, |
-QT_TR_NOOP("getAllStyles() -> list\n\ |
-\n\ |
-Deprecated. Use getParagraphStyles() instead.\n\ |
-")); |
-/** |
- Craig Ringer, 2004-09-09 |
- Enumerate all known paragraph styles |
-*/ |
-PyObject *scribus_getparagraphstyles(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcharstyles__doc__, |
-QT_TR_NOOP("getCharStyles() -> list\n\ |
-\n\ |
-Return a list of the names of all character styles in the current document.\n\ |
-")); |
-PyObject *scribus_getcharstyles(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getlinestyles__doc__, |
-QT_TR_NOOP("getLineStyles() -> list\n\ |
-\n\ |
-Return a list of the names of all line styles in the current document.\n\ |
-")); |
-PyObject *scribus_getlinestyles(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcellstyles__doc__, |
-QT_TR_NOOP("getCellStyles() -> list\n\ |
-\n\ |
-Return a list of the names of all cell styles in the current document.\n\ |
-")); |
-PyObject *scribus_getcellstyles(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_gettablestyles__doc__, |
-QT_TR_NOOP("getTableStyles() -> list\n\ |
-\n\ |
-Return a list of the names of all table styles in the current document.\n\ |
-")); |
-PyObject *scribus_gettablestyles(PyObject * /*self*/); |
- |
-#endif |
- |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdstyle.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp (nonexistent) |
@@ -1,519 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "cmddoc.h" |
-#include "cmdutil.h" |
-#include "units.h" |
-#include "documentinformation.h" |
-#include "scribuscore.h" |
-#include "scribusdoc.h" |
-#include "scribusview.h" |
- |
-#include <QApplication> |
- |
-/* |
-newDocument(size, margins, orientation, firstPageNumber, |
- unit, pagesType, firstPageOrder)*/ |
-PyObject *scribus_newdocument(PyObject* /* self */, PyObject* args) |
-{ |
- double topMargin, bottomMargin, leftMargin, rightMargin; |
- double pageWidth, pageHeight; |
-// int orientation, firstPageNr, unit, pagesType, facingPages, firstPageOrder, numPages; |
- int orientation, firstPageNr, unit, pagesType, firstPageOrder, numPages; |
- |
- PyObject *p, *m; |
- |
- if ((!PyArg_ParseTuple(args, "OOiiiiii", &p, &m, &orientation, |
- &firstPageNr, &unit, |
- &pagesType, |
- &firstPageOrder, |
- &numPages)) || |
- (!PyArg_ParseTuple(p, "dd", &pageWidth, &pageHeight)) || |
- (!PyArg_ParseTuple(m, "dddd", &leftMargin, &rightMargin, |
- &topMargin, &bottomMargin))) |
- return nullptr; |
- if (numPages <= 0) |
- numPages = 1; |
- if (pagesType == 0) |
- { |
- // facingPages = 0; |
- firstPageOrder = 0; |
- } |
-// else |
-// facingPages = 1; |
- // checking the bounds |
- if (pagesType < firstPageOrder) |
- { |
- PyErr_SetString(ScribusException, QObject::tr("firstPageOrder is bigger than allowed.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- |
- pageWidth = value2pts(pageWidth, unit); |
- pageHeight = value2pts(pageHeight, unit); |
- if (orientation == 1) |
- { |
- double x = pageWidth; |
- pageWidth = pageHeight; |
- pageHeight = x; |
- } |
- leftMargin = value2pts(leftMargin, unit); |
- rightMargin = value2pts(rightMargin, unit); |
- topMargin = value2pts(topMargin, unit); |
- bottomMargin = value2pts(bottomMargin, unit); |
- |
- bool ret = ScCore->primaryMainWindow()->doFileNew(pageWidth, pageHeight, |
- topMargin, leftMargin, rightMargin, bottomMargin, |
- // autoframes. It's disabled in python |
- // columnDistance, numberCols, autoframes, |
- 0, 1, false, |
- pagesType, unit, firstPageOrder, |
- orientation, firstPageNr, "Custom", true, numPages); |
- ScCore->primaryMainWindow()->doc->setPageSetFirstPage(pagesType, firstPageOrder); |
- |
- return PyInt_FromLong(static_cast<long>(ret)); |
-} |
- |
-PyObject *scribus_newdoc(PyObject* /* self */, PyObject* args) |
-{ |
- qDebug("WARNING: newDoc() procedure is obsolete, it will be removed in a forthcoming release. Use newDocument() instead."); |
- double b, h, lr, tpr, btr, rr, ebr; |
- int unit, ds, fsl, fNr, ori; |
- PyObject *p, *m; |
- if ((!PyArg_ParseTuple(args, "OOiiiii", &p, &m, &ori, &fNr, &unit, &ds, &fsl)) || |
- (!PyArg_ParseTuple(p, "dd", &b, &h)) || |
- (!PyArg_ParseTuple(m, "dddd", &lr, &rr, &tpr, &btr))) |
- return nullptr; |
- b = value2pts(b, unit); |
- h = value2pts(h, unit); |
- if (ori == 1) |
- { |
- ebr = b; |
- b = h; |
- h = ebr; |
- } |
- /*! \todo Obsolete! In the case of no facing pages use only firstpageleft |
- scripter is not new-page-size ready. |
- What is it: don't allow to use wrong FSL constant in the case of |
- onesided document. */ |
- if (ds!=1 && fsl>0) |
- fsl = 0; |
- // end of hack |
- |
- tpr = value2pts(tpr, unit); |
- lr = value2pts(lr, unit); |
- rr = value2pts(rr, unit); |
- btr = value2pts(btr, unit); |
- bool ret = ScCore->primaryMainWindow()->doFileNew(b, h, tpr, lr, rr, btr, 0, 1, false, ds, unit, fsl, ori, fNr, "Custom", true); |
- // qApp->processEvents(); |
- return PyInt_FromLong(static_cast<long>(ret)); |
-} |
- |
-PyObject *scribus_setbleeds(PyObject */* self */, PyObject *args) |
-{ |
- double lr, tpr, btr, rr; |
- if (!PyArg_ParseTuple(args, "dddd", &lr, &rr, &tpr, &btr)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- MarginStruct bleeds(ValueToPoint(tpr), ValueToPoint(lr), ValueToPoint(btr), ValueToPoint(rr)); |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- ScribusView* currentView = ScCore->primaryMainWindow()->view; |
- currentDoc->setBleeds(bleeds); |
- currentView->reformPages(); |
- currentDoc->setModified(true); |
- currentView->DrawNew(); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setmargins(PyObject* /* self */, PyObject* args) |
-{ |
- double lr, tpr, btr, rr; |
- if (!PyArg_ParseTuple(args, "dddd", &lr, &rr, &tpr, &btr)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- MarginStruct margins(ValueToPoint(tpr), ValueToPoint(lr), ValueToPoint(btr), ValueToPoint(rr)); |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- ScribusView* currentView = ScCore->primaryMainWindow()->view; |
- currentDoc->setMargins(margins); |
- currentView->reformPages(); |
- currentDoc->setModified(true); |
- currentView->GotoPage(currentDoc->currentPageNumber()); |
- currentView->DrawNew(); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setbaseline(PyObject* /* self */, PyObject* args) |
-{ |
- double grid, offset; |
- if (!PyArg_ParseTuple(args, "dd", &grid, &offset)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- ScribusView* currentView = ScCore->primaryMainWindow()->view; |
- currentDoc->guidesPrefs().valueBaselineGrid = ValueToPoint(grid); |
- currentDoc->guidesPrefs().offsetBaselineGrid = ValueToPoint(offset); |
- //currentView->reformPages(); |
- currentDoc->setModified(true); |
- //currentView->GotoPage(currentDoc->currentPageNumber()); |
- currentView->DrawNew(); |
- |
- Py_RETURN_NONE; |
-} |
- |
- |
-PyObject *scribus_closedoc(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScCore->primaryMainWindow()->doc->setModified(false); |
- bool ret = ScCore->primaryMainWindow()->slotFileClose(); |
- qApp->processEvents(); |
- return PyInt_FromLong(static_cast<long>(ret)); |
-} |
- |
-PyObject *scribus_havedoc(PyObject* /* self */) |
-{ |
- return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->HaveDoc)); |
-} |
- |
-PyObject *scribus_opendoc(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name; |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- bool ret = ScCore->primaryMainWindow()->loadDoc(QString::fromUtf8(Name)); |
- if (!ret) |
- { |
- PyErr_SetString(ScribusException, QObject::tr("Failed to open document: %1","python error").arg(Name).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyBool_FromLong(static_cast<long>(true)); |
-// Py_INCREF(Py_True); // compatibility: return true, not none, on success |
-// return Py_True; |
-// Py_RETURN_TRUE; |
-} |
- |
-PyObject *scribus_savedoc(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScCore->primaryMainWindow()->slotFileSave(); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_revertdoc(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScCore->primaryMainWindow()->slotFileRevert(); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getdocname(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (! ScCore->primaryMainWindow()->doc->hasName) |
- { |
- return PyString_FromString(""); |
- } |
- return PyString_FromString(ScCore->primaryMainWindow()->doc->documentFileName().toUtf8()); |
-} |
- |
-PyObject *scribus_savedocas(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name; |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- bool ret = ScCore->primaryMainWindow()->DoFileSave(QString::fromUtf8(Name)); |
- if (!ret) |
- { |
- PyErr_SetString(ScribusException, QObject::tr("Failed to save document.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyBool_FromLong(static_cast<long>(true)); |
-// Py_INCREF(Py_True); // compatibility: return true, not none, on success |
-// return Py_True; |
-// Py_RETURN_TRUE; |
-} |
- |
-PyObject *scribus_setinfo(PyObject* /* self */, PyObject* args) |
-{ |
- char *Author; |
- char *Title; |
- char *Desc; |
- // z means string, but None becomes a nullptr value. QString() |
- // will correctly handle nullptr. |
- if (!PyArg_ParseTuple(args, "zzz", &Author, &Title, &Desc)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- DocumentInformation& docInfo = ScCore->primaryMainWindow()->doc->documentInfo(); |
- docInfo.setAuthor(QString::fromUtf8(Author)); |
- docInfo.setTitle(QString::fromUtf8(Title)); |
- docInfo.setComments(QString::fromUtf8(Desc)); |
- ScCore->primaryMainWindow()->slotDocCh(); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getinfo(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (! ScCore->primaryMainWindow()->doc->hasName) |
- { |
- return PyUnicode_FromString(""); |
- } |
- |
- DocumentInformation& docInfo = ScCore->primaryMainWindow()->doc->documentInfo(); |
- return Py_BuildValue("(sss)", |
- docInfo.author().toUtf8().data(), |
- docInfo.title().toUtf8().data(), |
- docInfo.comments().toUtf8().data()); |
-} |
- |
-PyObject *scribus_setunit(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- if (!PyArg_ParseTuple(args, "i", &e)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if ((e < UNITMIN) || (e > UNITMAX)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Unit out of range. Use one of the scribus.UNIT_* constants.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->slotChangeUnit(e); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getunit(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->unitIndex())); |
-} |
- |
-PyObject *scribus_loadstylesfromfile(PyObject* /* self */, PyObject *args) |
-{ |
- char *fileName; |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &fileName)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScCore->primaryMainWindow()->doc->loadStylesFromFile(QString::fromUtf8(fileName)); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setdoctype(PyObject* /* self */, PyObject* args) |
-{ |
- int fp, fsl; |
- if (!PyArg_ParseTuple(args, "ii", &fp, &fsl)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- ScribusView* currentView = ScCore->primaryMainWindow()->view; |
- |
- if (currentDoc->pagePositioning() == fp) |
- currentDoc->setPageSetFirstPage(currentDoc->pagePositioning(), fsl); |
- currentView->reformPages(); |
- currentView->GotoPage(currentDoc->currentPageNumber()); // is this needed? |
- currentView->DrawNew(); // is this needed? |
- //CB TODO ScCore->primaryMainWindow()->pagePalette->RebuildPage(); // is this needed? |
- ScCore->primaryMainWindow()->slotDocCh(); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_closemasterpage(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScCore->primaryMainWindow()->view->hideMasterPage(); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_masterpagenames(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- PyObject* names = PyList_New(currentDoc->MasterPages.count()); |
- QMap<QString,int>::const_iterator it(currentDoc->MasterNames.constBegin()); |
- QMap<QString,int>::const_iterator itEnd(currentDoc->MasterNames.constEnd()); |
- int n = 0; |
- for ( ; it != itEnd; ++it ) |
- { |
- PyList_SET_ITEM(names, n++, PyString_FromString(it.key().toUtf8().data()) ); |
- } |
- return names; |
-} |
- |
-PyObject *scribus_editmasterpage(PyObject* /* self */, PyObject* args) |
-{ |
- char* name = nullptr; |
- if (!PyArg_ParseTuple(args, "es", const_cast<char*>("utf-8"), &name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- const QString masterPageName(name); |
- const QMap<QString,int>& masterNames(ScCore->primaryMainWindow()->doc->MasterNames); |
- const QMap<QString,int>::const_iterator it(masterNames.find(masterPageName)); |
- if ( it == masterNames.constEnd() ) |
- { |
- PyErr_SetString(PyExc_ValueError, "Master page not found"); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->view->showMasterPage(*it); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject* scribus_createmasterpage(PyObject* /* self */, PyObject* args) |
-{ |
- char* name = nullptr; |
- if (!PyArg_ParseTuple(args, "es", const_cast<char*>("utf-8"), &name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- const QString masterPageName(name); |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- if (currentDoc->MasterNames.contains(masterPageName)) |
- { |
- PyErr_SetString(PyExc_ValueError, "Master page already exists"); |
- return nullptr; |
- } |
- currentDoc->addMasterPage(currentDoc->MasterPages.count(), masterPageName); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject* scribus_deletemasterpage(PyObject* /* self */, PyObject* args) |
-{ |
- char* name = nullptr; |
- if (!PyArg_ParseTuple(args, "es", const_cast<char*>("utf-8"), &name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- const QString masterPageName(name); |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- if (!currentDoc->MasterNames.contains(masterPageName)) |
- { |
- PyErr_SetString(PyExc_ValueError, "Master page does not exist"); |
- return nullptr; |
- } |
- if (masterPageName == "Normal") |
- { |
- PyErr_SetString(PyExc_ValueError, "Can not delete the Normal master page"); |
- return nullptr; |
- } |
- bool oldMode = currentDoc->masterPageMode(); |
- currentDoc->setMasterPageMode(true); |
- ScCore->primaryMainWindow()->deletePage2(currentDoc->MasterNames[masterPageName]); |
- currentDoc->setMasterPageMode(oldMode); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getmasterpage(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- if (!PyArg_ParseTuple(args, "i", &e)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- e--; |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- if ((e < 0) || (e > static_cast<int>(currentDoc->Pages->count())-1)) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range: '%1'.","python error").arg(e+1).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyString_FromString(currentDoc->DocPages.at(e)->masterPageName().toUtf8()); |
-} |
- |
-PyObject* scribus_applymasterpage(PyObject* /* self */, PyObject* args) |
-{ |
- char* name = nullptr; |
- int page = 0; |
- if (!PyArg_ParseTuple(args, "esi", const_cast<char*>("utf-8"), &name, &page)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- const QString masterPageName(name); |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- if (!currentDoc->MasterNames.contains(masterPageName)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Master page does not exist: '%1'","python error").arg(masterPageName).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if ((page < 1) || (page > static_cast<int>(currentDoc->Pages->count()))) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range: %1.","python error").arg(page).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- if (!currentDoc->applyMasterPage(masterPageName, page-1)) |
- { |
- PyErr_SetString(ScribusException, QObject::tr("Failed to apply masterpage '%1' on page: %2","python error").arg(masterPageName).arg(page).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmddocdocwarnings() |
-{ |
- QStringList s; |
- s << scribus_applymasterpage__doc__ |
- << scribus_closedoc__doc__ |
- << scribus_closemasterpage__doc__ |
- << scribus_createmasterpage__doc__ |
- << scribus_deletemasterpage__doc__ |
- << scribus_editmasterpage__doc__ |
- << scribus_getdocname__doc__ |
- << scribus_getmasterpage__doc__ |
- << scribus_getunit__doc__ |
- << scribus_havedoc__doc__ |
- << scribus_loadstylesfromfile__doc__ |
- << scribus_masterpagenames__doc__ |
- << scribus_newdoc__doc__ |
- << scribus_newdocument__doc__ |
- << scribus_opendoc__doc__ |
- << scribus_revertdoc__doc__ |
- << scribus_savedoc__doc__ |
- << scribus_savedocas__doc__ |
- << scribus_setbaseline__doc__ |
- << scribus_setbleeds__doc__ |
- << scribus_setdoctype__doc__ |
- << scribus_setinfo__doc__ |
- << scribus_setmargins__doc__ |
- << scribus_setunit__doc__; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/prefs_scripter.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/prefs_scripter.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/prefs_scripter.cpp (nonexistent) |
@@ -1,164 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
- |
-// include the python header first because on OSX that uses the name "slots" |
-#include "cmdvar.h" |
- |
-#include <QColorDialog> |
-#include <QFileDialog> |
-#include <QPalette> |
- |
-#include "prefs_scripter.h" |
-#include "scriptercore.h" |
-#include "prefsfile.h" |
-#include "prefscontext.h" |
-#include "prefsmanager.h" |
-#include "prefsstructs.h" |
- |
-Prefs_Scripter::Prefs_Scripter(QWidget* parent) |
- : Prefs_Pane(parent) |
-{ |
- setupUi(this); |
- languageChange(); |
- |
- m_caption = tr("Scripter"); |
- m_icon = "python_16.png"; |
- |
- setupSyntaxColors(); |
- |
- // Set the state of the ext script enable checkbox |
- extensionScriptsChk->setChecked(scripterCore->extensionsEnabled()); |
- // The startup script box should be disabled if ext scripts are off |
- startupScriptEdit->setEnabled(extensionScriptsChk->isChecked()); |
- startupScriptEdit->setText(scripterCore->startupScript()); |
- // signals and slots connections |
- connect(extensionScriptsChk, SIGNAL(toggled(bool)), startupScriptEdit, SLOT(setEnabled(bool))); |
- // colors |
- connect(textButton, SIGNAL(clicked()), this, SLOT(setColor())); |
- connect(commentButton, SIGNAL(clicked()), this, SLOT(setColor())); |
- connect(keywordButton, SIGNAL(clicked()), this, SLOT(setColor())); |
- connect(errorButton, SIGNAL(clicked()), this, SLOT(setColor())); |
- connect(signButton, SIGNAL(clicked()), this, SLOT(setColor())); |
- connect(stringButton, SIGNAL(clicked()), this, SLOT(setColor())); |
- connect(numberButton, SIGNAL(clicked()), this, SLOT(setColor())); |
- connect(extensionScriptsChk, SIGNAL(toggled(bool)), startupScriptChangeButton, SLOT(setEnabled(bool))); |
- connect(startupScriptChangeButton, SIGNAL(clicked()), this, SLOT(changeStartupScript())); |
-} |
- |
-Prefs_Scripter::~Prefs_Scripter() = default; |
- |
-void Prefs_Scripter::languageChange() |
-{ |
-} |
- |
-void Prefs_Scripter::restoreDefaults(struct ApplicationPrefs *prefsData) |
-{ |
-} |
- |
-void Prefs_Scripter::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const |
-{ |
-} |
- |
-// Apply changes to prefs. Auto connected. |
-void Prefs_Scripter::apply() |
-{ |
- scripterCore->setExtensionsEnabled(extensionScriptsChk->isChecked()); |
- scripterCore->setStartupScript(startupScriptEdit->text()); |
- // colors |
- PrefsContext* prefs = PrefsManager::instance().prefsFile->getPluginContext("scriptplugin"); |
- if (prefs) |
- { |
- prefs->set("syntaxerror", errorColor.name()); |
- prefs->set("syntaxcomment", commentColor.name()); |
- prefs->set("syntaxkeyword", keywordColor.name()); |
- prefs->set("syntaxsign", signColor.name()); |
- prefs->set("syntaxnumber", numberColor.name()); |
- prefs->set("syntaxstring", stringColor.name()); |
- prefs->set("syntaxtext", textColor.name()); |
- |
- emit prefsChanged(); |
- } |
-} |
- |
-void Prefs_Scripter::setColor() |
-{ |
- QPushButton* button = (QPushButton*) sender(); |
- |
- QColor oldColor; |
- if (button == textButton) oldColor = textColor; |
- if (button == commentButton) oldColor = commentColor; |
- if (button == keywordButton) oldColor = keywordColor; |
- if (button == errorButton) oldColor = errorColor; |
- if (button == signButton) oldColor = signColor; |
- if (button == stringButton) oldColor = stringColor; |
- if (button == numberButton) oldColor = numberColor; |
- |
- QColor color = QColorDialog::getColor(oldColor, this); |
- if (color.isValid() && button) |
- { |
- QPixmap pm(54, 14); |
- pm.fill(color); |
- button->setIcon(pm); |
- if (button==textButton) |
- textColor=color; |
- if (button==commentButton) |
- commentColor=color; |
- if (button==keywordButton) |
- keywordColor=color; |
- if (button==errorButton) |
- errorColor=color; |
- if (button==signButton) |
- signColor=color; |
- if (button==stringButton) |
- stringColor=color; |
- if (button==numberButton) |
- numberColor=color; |
- } |
-} |
- |
-void Prefs_Scripter::setupSyntaxColors() |
-{ |
- SyntaxColors *syntax = new SyntaxColors(); |
- textColor=syntax->textColor; |
- commentColor=syntax->commentColor; |
- keywordColor=syntax->keywordColor; |
- errorColor=syntax->errorColor; |
- signColor=syntax->signColor; |
- stringColor=syntax->stringColor; |
- numberColor=syntax->numberColor; |
- |
- QPixmap pm(54, 14); |
- pm.fill(textColor); |
- textButton->setIcon(pm); |
- pm.fill(commentColor); |
- commentButton->setIcon(pm); |
- pm.fill(keywordColor); |
- keywordButton->setIcon(pm); |
- pm.fill(errorColor); |
- errorButton->setIcon(pm); |
- pm.fill(signColor); |
- signButton->setIcon(pm); |
- pm.fill(stringColor); |
- stringButton->setIcon(pm); |
- pm.fill(numberColor); |
- numberButton->setIcon(pm); |
- |
- delete(syntax); |
-} |
- |
-void Prefs_Scripter::changeStartupScript() |
-{ |
- QString currentScript=startupScriptEdit->text(); |
- QFileInfo fi(startupScriptEdit->text()); |
- if (!fi.exists()) |
- currentScript = QDir::homePath(); |
- |
- QString s = QFileDialog::getOpenFileName(this, tr("Locate Startup Script"), currentScript, "Python Scripts (*.py *.PY)"); |
- if (!s.isEmpty()) |
- startupScriptEdit->setText(s); |
-} |
- |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/prefs_scripter.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/guiapp.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/guiapp.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/guiapp.h (nonexistent) |
@@ -1,113 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef GUIAPP_H |
-#define GUIAPP_H |
- |
-// Brings in <Python.h> first |
-#include "cmdvar.h" |
- |
-/*! Scribus GUI tool */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_statusmessage__doc__, |
-QT_TR_NOOP("messagebarText(\"string\")\n\ |
-\n\ |
-Writes the \"string\" into the Scribus message bar (status line). The text\n\ |
-must be UTF8 encoded or 'unicode' string(recommended).\n\ |
-")); |
-/** |
-Changes the status bar string. |
-(Petr Vanek 02/19/04) |
-*/ |
-PyObject *scribus_statusmessage(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_progressreset__doc__, |
-QT_TR_NOOP("progressReset()\n\ |
-\n\ |
-Cleans up the Scribus progress bar previous settings. It is called before the\n\ |
-new progress bar use. See progressSet.\n\ |
-")); |
-/* |
-Progressbar handling |
-(Petr Vanek 02/19/04) |
-*/ |
-PyObject *scribus_progressreset(PyObject * /*self*/); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_progresssettotalsteps__doc__, |
-QT_TR_NOOP("progressTotal(max)\n\ |
-\n\ |
-Sets the progress bar's maximum steps value to the specified number.\n\ |
-See progressSet.\n\ |
-")); |
-PyObject *scribus_progresssettotalsteps(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_progresssetprogress__doc__, |
-QT_TR_NOOP("progressSet(nr)\n\ |
-\n\ |
-Set the progress bar position to \"nr\", a value relative to the previously set\n\ |
-progressTotal. The progress bar uses the concept of steps; you give it the\n\ |
-total number of steps and the number of steps completed so far and it will\n\ |
-display the percentage of steps that have been completed. You can specify the\n\ |
-total number of steps with progressTotal(). The current number of steps is set\n\ |
-with progressSet(). The progress bar can be rewound to the beginning with\n\ |
-progressReset(). [based on info taken from Trolltech's Qt docs]\n\ |
-")); |
-PyObject *scribus_progresssetprogress(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcursor__doc__, |
-QT_TR_NOOP("setCursor()\n\ |
-\n\ |
-[UNSUPPORTED!] This might break things, so steer clear for now.\n\ |
-")); |
-/** |
-Cursor handling |
-(Petr Vanek 02/19/04) |
-*/ |
-PyObject *scribus_setcursor(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_docchanged__doc__, |
-QT_TR_NOOP("docChanged(bool)\n\ |
-\n\ |
-Enable/disable save icon in the Scribus icon bar and the Save menu item. It's\n\ |
-useful to call this procedure when you're changing the document, because Scribus\n\ |
-won't automatically notice when you change the document using a script.\n\ |
-")); |
-/** |
-Enable/disable save icon |
-(Petr Vanek 02/20/04) |
-*/ |
-PyObject *scribus_docchanged(PyObject * /*self*/, PyObject* args); |
- |
-PyDoc_STRVAR(scribus_zoomdocument__doc__, |
-QT_TR_NOOP("zoomDocument(double)\n\ |
-\n\ |
-Zoom the document in main GUI window. Actions have whole number\n\ |
-values like 20.0, 100.0, etc. Zoom to Fit uses -100 as a marker.\n\ |
-")); |
-/** |
-Zooming the document |
-\author Petr Vanek <petr@yarpen.cz> |
-*/ |
-PyObject *scribus_zoomdocument(PyObject * /*self*/, PyObject* args); |
- |
-PyDoc_STRVAR(scribus_scrolldocument__doc__, |
-QT_TR_NOOP("scrollDocument(x,y)\n\ |
-\n\ |
-Scroll the document in main GUI window by x and y.\n\ |
-")); |
-/* |
- * Gives the possibility to scroll the document. |
- * 13.12.2007: Joachim Neu |
- */ |
-PyObject *scribus_scrolldocument(PyObject*, PyObject* args); |
- |
-#endif |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/guiapp.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/svgimport.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/svgimport.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/svgimport.cpp (nonexistent) |
@@ -1,81 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "svgimport.h" |
-#include "cmdvar.h" |
-#include "cmdutil.h" |
- |
-// 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" |
-#include "scribusview.h" |
-#include "selection.h" |
-#include "ui/propertiespalette.h" |
-#include "ui/propertiespalette_line.h" |
- |
-#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 nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- QStringList allFormatsV = LoadSavePlugin::getExtensionsForImport(FORMATID_FIRSTUSER); |
- QString fName = QString::fromUtf8(Image); |
- QFileInfo fi = QFileInfo(fName); |
- QString ext = fi.suffix().toLower(); |
- if (!allFormatsV.contains(ext)) |
- { |
- PyErr_SetString(PyExc_Exception, "Requested Import plugin not available"); |
- return nullptr; |
- } |
- FileLoader *fileLoader = new FileLoader(fName); |
- int testResult = fileLoader->testFile(); |
- delete fileLoader; |
- if ((testResult != -1) && (testResult >= FORMATID_FIRSTUSER)) |
- { |
- 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()->requestUpdate(reqColorsUpdate | reqLineStylesUpdate | reqTextStylesUpdate); |
- } |
- } |
- } |
- else |
- { |
- PyErr_SetString(PyExc_Exception, "Requested File cannot be imported"); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
-/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void svgimportdocwarnings() |
-{ |
- QStringList s; |
- s << scribus_placeeps__doc__ |
- << scribus_placeodg__doc__ |
- << scribus_placesvg__doc__ |
- << scribus_placesxd__doc__ |
- << scribus_placevec__doc__; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/svgimport.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/CMakeLists.txt |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/CMakeLists.txt (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/CMakeLists.txt (nonexistent) |
@@ -1,66 +0,0 @@ |
-include_directories( |
- ${CMAKE_SOURCE_DIR} |
- ${CMAKE_SOURCE_DIR}/scribus |
- ${Python2_INCLUDE_DIRS} |
- ${SCRIBUS_AUTOGEN_INCLUDE_PATH} |
-) |
- |
-# Gentoo has an option for no examples. Let's make the ebuild simpler and open up the option to others, but leave as a default for us |
-if (NOT WANT_NOEXAMPLES) |
- add_subdirectory(samples) |
-endif () |
-add_subdirectory(scripts) |
- |
-set(SCRIPTER_PLUGIN_SOURCES |
- cmdannotations.cpp |
- cmdcell.cpp |
- cmdcolor.cpp |
- cmddialog.cpp |
- cmddoc.cpp |
- cmdgetprop.cpp |
- cmdgetsetprop.cpp |
- cmdmani.cpp |
- cmdmisc.cpp |
- cmdobj.cpp |
- cmdpage.cpp |
- cmdsetprop.cpp |
- cmdstyle.cpp |
- cmdtable.cpp |
- cmdtext.cpp |
- cmdutil.cpp |
- guiapp.cpp |
- objimageexport.cpp |
- objpdffile.cpp |
- objprinter.cpp |
- pconsole.cpp |
- prefs_scripter.cpp |
- runscriptdialog.cpp |
- scriptercore.cpp |
- scriptplugin.cpp |
- svgimport.cpp |
-) |
- |
-set(SCRIBUS_SCRIPTER_PLUGIN "scriptplugin_py2x") |
- |
-add_library(${SCRIBUS_SCRIPTER_PLUGIN} MODULE |
- ${SCRIPTER_PLUGIN_SOURCES} |
-) |
- |
-target_link_libraries(${SCRIBUS_SCRIPTER_PLUGIN} |
- ${Python2_LIBRARIES} |
- ${SCRIBUS_API_LIB} |
-) |
- |
-target_link_libraries(${SCRIBUS_SCRIPTER_PLUGIN} ${EXE_NAME}) |
- |
-if(WANT_PCH) |
- target_precompile_headers(${SCRIBUS_SCRIPTER_PLUGIN} PRIVATE "../plugins_pch.h") |
-endif() |
- |
-install(TARGETS ${SCRIBUS_SCRIPTER_PLUGIN} |
- LIBRARY |
- DESTINATION ${PLUGINDIR} |
- PERMISSIONS ${PLUGIN_PERMISSIONS} |
-) |
- |
-add_dependencies(Plugins ${SCRIBUS_SCRIPTER_PLUGIN}) |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/CMakeLists.txt |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdpage.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdpage.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdpage.cpp (nonexistent) |
@@ -1,547 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "cmdpage.h" |
-#include "cmdutil.h" |
-#include "commonstrings.h" |
-#include "scpage.h" |
-#include "scribuscore.h" |
-#include "scribusdoc.h" |
-#include "scribusview.h" |
- |
-#include <QApplication> |
- |
-PyObject *scribus_currentpage(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->currentPageNumber() + 1)); |
-} |
- |
-PyObject *scribus_redraw(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScCore->primaryMainWindow()->view->DrawNew(); |
- qApp->processEvents(); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getpagetype(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- if (!PyArg_ParseTuple(args, "i", &e)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- e--; |
- if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1)) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->locationOfPage(e))); |
-} |
- |
-PyObject *scribus_savepageeps(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name; |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- QString epsError; |
- bool ret = ScCore->primaryMainWindow()->DoSaveAsEps(QString::fromUtf8(Name), epsError); |
- if (!ret) |
- { |
- QString message = QObject::tr("Failed to save EPS.","python error"); |
- if (!epsError.isEmpty()) |
- message += QString("\n%1").arg(epsError); |
- PyErr_SetString(ScribusException, message.toLocal8Bit().constData()); |
- return nullptr; |
- } |
-// Py_INCREF(Py_True); // return True not None for backward compat |
-// return Py_True; |
-// Py_RETURN_TRUE; |
- return PyBool_FromLong(static_cast<long>(true)); |
-} |
- |
-PyObject *scribus_deletepage(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- if (!PyArg_ParseTuple(args, "i", &e)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- e--; |
- if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1)) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->deletePage2(e); |
-// Py_INCREF(Py_None); |
-// return Py_None; |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_gotopage(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- if (!PyArg_ParseTuple(args, "i", &e)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- e--; |
- if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1)) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->view->GotoPage(e); |
-// Py_INCREF(Py_None); |
-// return Py_None; |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_newpage(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- char *name = const_cast<char*>(""); |
- QString qName(CommonStrings::trMasterPageNormal); |
- if (!PyArg_ParseTuple(args, "i|es", &e, "utf-8", &name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- ScribusMainWindow* mainWin = ScCore->primaryMainWindow(); |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- int loc = (e > -1) ? e : currentDoc->Pages->count(); |
- if (currentDoc->pageSets()[currentDoc->pagePositioning()].Columns != 1) |
- { |
- switch (currentDoc->locationOfPage(loc)) |
- { |
- case LeftPage: |
- qName = CommonStrings::trMasterPageNormalLeft; |
- break; |
- case RightPage: |
- qName = CommonStrings::trMasterPageNormalRight; |
- break; |
- case MiddlePage: |
- qName = CommonStrings::trMasterPageNormalMiddle; |
- break; |
- } |
- } |
- if (QString(name).length() != 0) |
- qName = QString::fromUtf8(name); |
- |
- if (!currentDoc->MasterNames.contains(qName)) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Given master page name does not match any existing.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (e < 0) |
- mainWin->slotNewPageP(loc, qName); |
- else |
- { |
- e--; |
- if ((e < 0) || (e > static_cast<int>(loc - 1))) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- mainWin->slotNewPageP(e, qName); |
- } |
-// Py_INCREF(Py_None); |
- // return Py_None; |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_pagecount(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->Pages->count())); |
-} |
- |
-PyObject *scribus_getpagesize(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- PyObject *t; |
- t = Py_BuildValue( |
- "(dd)", |
- PointToValue(currentDoc->pageWidth()), // it's just view scale... * ScCore->primaryMainWindow()->doc->Scale), |
- PointToValue(currentDoc->pageHeight()) // * ScCore->primaryMainWindow()->doc->Scale) |
- ); |
- return t; |
-} |
- |
-PyObject *scribus_getpagensize(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- if (!PyArg_ParseTuple(args, "i", &e)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- e--; |
- if ((e < 0) || (e > static_cast<int>(currentDoc->Pages->count())-1)) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PyObject *t; |
- t = Py_BuildValue( |
- "(dd)", |
- PointToValue(currentDoc->Pages->at(e)->width()), |
- PointToValue(currentDoc->Pages->at(e)->height()) |
- ); |
- return t; |
-} |
- |
-PyObject *scribus_getpagenmargins(PyObject* /* self */, PyObject* args) |
-{ |
- int e; |
- if (!PyArg_ParseTuple(args, "i", &e)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- e--; |
- if ((e < 0) || (e > static_cast<int>(currentDoc->Pages->count())-1)) |
- { |
- PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- PyObject *margins = nullptr; |
- margins = Py_BuildValue("ffff", PointToValue(currentDoc->Pages->at(e)->Margins.top()), |
- PointToValue(currentDoc->Pages->at(e)->Margins.left()), |
- PointToValue(currentDoc->Pages->at(e)->Margins.right()), |
- PointToValue(currentDoc->Pages->at(e)->Margins.bottom())); |
- return margins; |
-} |
- |
-PyObject *scribus_getpageitems(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- if (currentDoc->Items->isEmpty()) |
- return Py_BuildValue((char*)"[]"); |
- uint counter = 0; |
- int pageNr = currentDoc->currentPageNumber(); |
- for (int lam2 = 0; lam2 < currentDoc->Items->count(); ++lam2) |
- { |
- if (pageNr == currentDoc->Items->at(lam2)->OwnPage) |
- counter++; |
- } |
- PyObject *l = PyList_New(counter); |
- PyObject *row; |
- counter = 0; |
- for (int i = 0; i<currentDoc->Items->count(); ++i) |
- { |
- if (pageNr == currentDoc->Items->at(i)->OwnPage) |
- { |
- row = Py_BuildValue((char*)"(sii)", |
- currentDoc->Items->at(i)->itemName().toUtf8().constData(), |
- currentDoc->Items->at(i)->itemType(), |
- currentDoc->Items->at(i)->uniqueNr |
- ); |
- PyList_SetItem(l, counter, row); |
- counter++; |
- } |
- } // for |
- return l; |
-} |
- |
-PyObject *scribus_getHguides(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- Guides g = ScCore->primaryMainWindow()->doc->currentPage()->guides.horizontals(GuideManagerCore::Standard); |
- int n = g.count();//ScCore->primaryMainWindow()->doc->currentPage->YGuides.count(); |
- if (n == 0) |
- return Py_BuildValue((char*)"[]"); |
- int i; |
- double tmp; |
- PyObject *l, *guide; |
- l = PyList_New(0); |
- for (i=0; i<n; i++) |
- { |
- tmp = g[i]; |
- guide = Py_BuildValue("d", PointToValue(tmp)); |
- PyList_Append(l, guide); |
- } |
- return l; |
-} |
- |
-PyObject *scribus_setHguides(PyObject* /* self */, PyObject* args) |
-{ |
- PyObject *l; |
- if (!PyArg_ParseTuple(args, "O", &l)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- if (!PyList_Check(l)) |
- { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("argument is not list: must be list of float values.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int i, n; |
- n = PyList_Size(l); |
- double guide; |
- currentDoc->currentPage()->guides.clearHorizontals(GuideManagerCore::Standard); |
- for (i=0; i<n; i++) |
- { |
- if (!PyArg_Parse(PyList_GetItem(l, i), "d", &guide)) |
- { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("argument contains non-numeric values: must be list of float values.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- currentDoc->currentPage()->guides.addHorizontal(ValueToPoint(guide), GuideManagerCore::Standard); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getVguides(PyObject* /* self */) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- Guides g = ScCore->primaryMainWindow()->doc->currentPage()->guides.verticals(GuideManagerCore::Standard); |
- int n = g.count();//ScCore->primaryMainWindow()->doc->currentPage->XGuides.count(); |
- if (n == 0) |
- return Py_BuildValue((char*)"[]"); |
- int i; |
- double tmp; |
- PyObject *l, *guide; |
- l = PyList_New(0); |
- for (i=0; i<n; i++) |
- { |
- tmp = g[i]; |
- guide = Py_BuildValue("d", PointToValue(tmp)); |
- PyList_Append(l, guide); |
- } |
- return l; |
-} |
- |
-PyObject *scribus_setVguides(PyObject* /* self */, PyObject* args) |
-{ |
- PyObject *l; |
- if (!PyArg_ParseTuple(args, "O", &l)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- if (!PyList_Check(l)) |
- { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("argument is not list: must be list of float values.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- int i, n; |
- n = PyList_Size(l); |
- double guide; |
- currentDoc->currentPage()->guides.clearVerticals(GuideManagerCore::Standard); |
- for (i=0; i<n; i++) |
- { |
- if (!PyArg_Parse(PyList_GetItem(l, i), "d", &guide)) |
- { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("argument contains no-numeric values: must be list of float values.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- currentDoc->currentPage()->guides.addVertical(ValueToPoint(guide), GuideManagerCore::Standard); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getpagemargins(PyObject* /* self */) |
-{ |
- PyObject *margins = nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- margins = Py_BuildValue("ffff", PointToValue(currentDoc->margins()->top()), |
- PointToValue(currentDoc->margins()->left()), |
- PointToValue(currentDoc->margins()->right()), |
- PointToValue(currentDoc->margins()->bottom())); |
- return margins; |
-} |
- |
-/*! |
- \fn import_addpages(int total, int pos) |
- \author Alessandro Pira <alex@alessandropira.org> |
- \date 11-11-2007 |
- \param total number of pages to add, pos: position in the document |
- \param pos position of the imported pages |
- \retval void |
- */ |
-// This function is used by scribus_importpage() to add new pages |
-void import_addpages(int total, int pos) |
-{ |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- |
- for (int i=0; i<total; i++) |
- { |
- int locreal = pos + i; |
- int loc = pos + i + 1; |
- |
- if (loc > currentDoc->Pages->count()) |
- loc = currentDoc->Pages->count(); |
- |
- QString qName(CommonStrings::trMasterPageNormal); |
- |
- if (currentDoc->pageSets()[currentDoc->pagePositioning()].Columns != 1) { |
- currentDoc->locationOfPage(loc); |
- switch (currentDoc->locationOfPage(loc)) |
- { |
- case LeftPage: |
- qName = CommonStrings::trMasterPageNormalLeft; |
- break; |
- case RightPage: |
- qName = CommonStrings::trMasterPageNormalRight; |
- break; |
- case MiddlePage: |
- qName = CommonStrings::trMasterPageNormalMiddle; |
- break; |
- } |
- } |
- ScCore->primaryMainWindow()->slotNewPageP(locreal, qName); |
- } |
-} |
- |
-/*! |
- \fn scribus_importpage(PyObject*, PyObject* args) |
- \author Alessandro Pira <alex@alessandropira.org> |
- \date 11-11-2007 |
- \param PyObject unused reference |
- \param args Python function args ("fromDoc", (pageList), [create, imortwhere, importwherePage]) |
- \retval Py_RETURN_NONE if ok, null if error |
- */ |
-PyObject *scribus_importpage(PyObject* /* self */, PyObject* args) |
-{ |
- char *doc = nullptr; |
- PyObject *pages = nullptr; |
- int createPageI = 1; |
- int importWhere = 2; |
- int importWherePage = 0; |
- |
- if (!PyArg_ParseTuple(args, "sO|iii", &doc, &pages, &createPageI, &importWhere, &importWherePage)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- if (!PyTuple_Check(pages)) |
- { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("second argument is not tuple: must be tuple of integer values.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- Py_INCREF(pages); |
- std::vector<int> pageNs; |
- int i, n, p; |
- n = PyTuple_Size(pages); |
- for (i=0; i<n; i++) |
- { |
- if (!PyArg_Parse(PyTuple_GetItem(pages, i), "i", &p)) |
- { |
- PyErr_SetString(PyExc_TypeError, QObject::tr("second argument contains non-numeric values: must be list of integer values.","python error").toLocal8Bit().constData()); |
- Py_DECREF(pages); |
- return nullptr; |
- } |
- pageNs.push_back(p); |
- } |
- Py_DECREF(pages); |
- |
- QString fromDoc = QString(doc); |
- bool createPage = (createPageI != 0); |
- |
- int startPage=0, nrToImport=pageNs.size(); |
- bool doIt = true; |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- if (currentDoc->masterPageMode()) |
- { |
- if (nrToImport > 1) |
- ScCore->primaryMainWindow()->loadPage(fromDoc, pageNs[0] - 1, false); |
- doIt = false; |
- } |
- else if (createPage) |
- { |
- if (importWhere == 0) //Before page |
- startPage = importWherePage; |
- else if (importWhere == 1) //After page |
- startPage = importWherePage + 1; |
- else //at end |
- startPage = currentDoc->DocPages.count();// + 1; |
- |
- import_addpages(nrToImport, startPage); |
- } |
- else |
- { |
- startPage = currentDoc->currentPage()->pageNr() + 1; |
- if (nrToImport > (currentDoc->DocPages.count() - currentDoc->currentPage()->pageNr())) |
- { |
- int tmp=nrToImport - (currentDoc->DocPages.count() - currentDoc->currentPage()->pageNr()); |
- import_addpages(tmp, currentDoc->DocPages.count()); |
- } |
- } |
- |
- if (doIt) |
- { |
- if (nrToImport > 0) |
- { |
- int counter = startPage + 1; |
- for (int i = 0; i < nrToImport; ++i) |
- { |
- ScCore->primaryMainWindow()->view->GotoPa(counter); |
- ScCore->primaryMainWindow()->loadPage(fromDoc, pageNs[i] - 1, false); |
- counter++; |
- } |
- } |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
- |
-/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmdpagedocwarnings() |
-{ |
- QStringList s; |
- s << scribus_currentpage__doc__ |
- << scribus_deletepage__doc__ |
- << scribus_getHguides__doc__ |
- << scribus_getVguides__doc__ |
- << scribus_getpageitems__doc__ |
- << scribus_getpagemargins__doc__ |
- << scribus_getpagensize__doc__ |
- << scribus_getpagetype__doc__ |
- << scribus_gotopage__doc__ |
- << scribus_importpage__doc__ |
- << scribus_newpage__doc__ |
- << scribus_pagecount__doc__ |
- << scribus_getpagesize__doc__ |
- << scribus_getpagenmargins__doc__ |
- << scribus_redraw__doc__ |
- << scribus_savepageeps__doc__ |
- << scribus_setHguides__doc__ |
- << scribus_setVguides__doc__; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdpage.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/README.BOOST |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/README.BOOST (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/README.BOOST (nonexistent) |
@@ -1,50 +0,0 @@ |
-Experimental support for the use of Boost::Python has been added to the Python |
-interface. All Boost code is exported in a separate module, scribus2, that is |
-only created if Boost::Python is available. |
- |
-Currently there's no autotools support for this in Scribus, so to compile the |
-scripter with this highly experimental feature you must: |
- |
-$ make clean |
-$ make CXXFLAGS=" -Wno-extra -Wno-unused -DHAVE_BOOST_PYTHON -fexceptions " LDFLAGS=" -lboost_python " |
-$ make install |
- |
-For more information on Boost::Python see: |
- http://www.boost.org/libs/python/doc/ |
- http://www-eleves-isia.cma.fr/documentation/BoostDoc/boost_1_29_0/libs/python/doc/tutorial/ |
- |
-It's strongly recommended that you read the FAQ at: |
- http://www.boost.org/libs/python/doc/v2/faq.html |
-(probably once before reading the code, and again after). |
- |
-All the fun stuff is in the `scribus2' module and is used for manipulating |
-paragraph styles. There are currently two (dirty hack) interfaces. One is a |
-"value based" interface - ask for a /copy of/ a style, add a style by /copying/ |
-it into the style list, etc. The other interface is reference based - get a |
-dict of references to the existing styles and modify them directly. Soon, |
-hopefully, add and remove styles from the dict as if it was a Python one too. |
-The value based interface is safer but clumsier; the reference based one |
-can be a tad dangerous but is very handy. |
- |
-Examples: |
- |
->>> import scribus2 |
->>> p = scribus2.ParagraphStyle() |
->>> p.Vname = "testing" |
->>> scribus2.addStyle(p) |
->>> scribus2.getStyleNames() |
-[ blah, blah, blah , "testing" ] |
->>> scribus2.getStylesRef()['testing'].Vname = "newname" |
->>> scribus2.getStyleNames() |
-[ blah, blah, blah, "newname"] |
->>> ref = scribus2.getStyleRef("newname") |
->>> ref.Vname = "renamed" |
->>> scribus2.getStyleNames() |
-[ blah, blah, blah, "renamed"] |
->>> val = scribus2.getStyleVal("renamed") |
->>> val.Vname = "doesnothing" |
->>> scribus2.getStyleNames() |
-[ blah, blah, blah, "renamed"] |
->>> scribus2.addStyle(val) |
->>> scribus2.getStyleNames() |
-[ blah, blah, blah, "renamed", "doesnothing"] |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdutil.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdutil.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdutil.cpp (nonexistent) |
@@ -1,264 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
- |
-#include "cmdutil.h" |
-#include "prefsmanager.h" |
-#include "resourcecollection.h" |
-#include "scpage.h" |
-#include "scribuscore.h" |
-#include "scribusdoc.h" |
-#include "scribusview.h" |
-#include "selection.h" |
-#include "tableborder.h" |
-#include "units.h" |
- |
-#include <QMap> |
- |
-/// Convert a value in points to a value in the current document units |
-double PointToValue(double Val) |
-{ |
- return pts2value(Val, ScCore->primaryMainWindow()->doc->unitIndex()); |
-} |
- |
-/// Convert a value in the current document units to a value in points |
-double ValueToPoint(double Val) |
-{ |
- return value2pts(Val, ScCore->primaryMainWindow()->doc->unitIndex()); |
-} |
- |
-/// Convert an X coordinate part in page units to a document coordinate |
-/// in system units. |
-double pageUnitXToDocX(double pageUnitX) |
-{ |
- return ValueToPoint(pageUnitX) + ScCore->primaryMainWindow()->doc->currentPage()->xOffset(); |
-} |
- |
-// Convert doc units to page units |
-double docUnitXToPageX(double pageUnitX) |
-{ |
- return PointToValue(pageUnitX - ScCore->primaryMainWindow()->doc->currentPage()->xOffset()); |
-} |
- |
-/// Convert a Y coordinate part in page units to a document coordinate |
-/// in system units. The document coordinates have their origin somewhere |
-/// up and left of the first page, where page coordinates have their |
-/// origin on the top left of the current page. |
-double pageUnitYToDocY(double pageUnitY) |
-{ |
- return ValueToPoint(pageUnitY) + ScCore->primaryMainWindow()->doc->currentPage()->yOffset(); |
-} |
- |
-double docUnitYToPageY(double pageUnitY) |
-{ |
- return PointToValue(pageUnitY - ScCore->primaryMainWindow()->doc->currentPage()->yOffset()); |
-} |
- |
-PageItem *GetItem(const QString& name) |
-{ |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- if (!name.isEmpty()) |
- { |
- for (int i = 0; i < currentDoc->Items->count(); ++i) |
- { |
- if (currentDoc->Items->at(i)->itemName() == name) |
- return currentDoc->Items->at(i); |
- } |
- } |
- else |
- { |
- if (currentDoc->m_Selection->count() != 0) |
- return currentDoc->m_Selection->itemAt(0); |
- } |
- return nullptr; |
-} |
- |
-void ReplaceColor(const QString& col, const QString& rep) |
-{ |
- QMap<QString, QString> colorMap; |
- colorMap.insert(col, rep); |
- |
- ResourceCollection colorRsc; |
- colorRsc.mapColor(col, rep); |
- |
- if (!ScCore->primaryMainWindow()->HaveDoc) |
- return; |
- ScribusDoc* doc = ScCore->primaryMainWindow()->doc; |
- |
- // Update tools colors |
- PrefsManager::replaceToolColors(doc->itemToolPrefs(), colorRsc.colors()); |
- // Update objects and styles colors |
- doc->replaceNamedResources(colorRsc); |
- // Temporary code until LineStyle is effectively used |
- doc->replaceLineStyleColors(colorMap); |
-} |
- |
-/* 04/07/10 returns selection if is not name specified pv */ |
-PageItem* GetUniqueItem(const QString& name) |
-{ |
- if (name.length() == 0) |
- { |
- if (ScCore->primaryMainWindow()->doc->m_Selection->count() != 0) |
- return ScCore->primaryMainWindow()->doc->m_Selection->itemAt(0); |
- PyErr_SetString(NoValidObjectError, QString("Cannot use empty string for object name when there is no selection").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return getPageItemByName(name); |
-} |
- |
-PageItem* getPageItemByName(const QString& name) |
-{ |
- if (name.length() == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QString("Cannot accept empty name for pageitem").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- for (int i = 0; i < currentDoc->Items->count(); ++i) |
- { |
- if (name == currentDoc->Items->at(i)->itemName()) |
- return currentDoc->Items->at(i); |
- } |
- |
- PyErr_SetString(NoValidObjectError, QString("Object not found").toLocal8Bit().constData()); |
- return nullptr; |
-} |
- |
- |
-/*! |
- * Checks to see if a pageItem named 'name' exists and return true |
- * if it does exist. Returns false if there is no such object, or |
- * if the empty string ("") is passed. |
- */ |
-bool ItemExists(const QString& name) |
-{ |
- if (name.length() == 0) |
- return false; |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- for (int i = 0; i < currentDoc->Items->count(); ++i) |
- { |
- if (name == currentDoc->Items->at(i)->itemName()) |
- return true; |
- } |
- return false; |
-} |
- |
-/*! |
- * Checks to see if there is a document open. |
- * If there is an open document, returns true. |
- * If there is no open document, sets a Python |
- * exception and returns false. |
- * 2004-10-27 Craig Ringer |
- */ |
-bool checkHaveDocument() |
-{ |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- return true; |
- // Caller is required to check for false return from this function |
- // and return nullptr. |
- PyErr_SetString(NoDocOpenError, QString("Command does not make sense without an open document").toLocal8Bit().constData()); |
- return false; |
-} |
- |
-bool checkValidPageNumber(int page) |
-{ |
- const int numPages = ScCore->primaryMainWindow()->doc->Pages->count(); |
- if (page < 0 || page >= numPages) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("%1 is not a valid page number.", "python error").arg(page).toLocal8Bit().constData()); |
- return false; |
- } |
- return true; |
-} |
- |
-QStringList getSelectedItemsByName() |
-{ |
- /* |
- QStringList names; |
- QPtrListIterator<PageItem> it(ScCore->primaryMainWindow()->view->SelItem); |
- for ( ; it.current() != 0 ; ++it) |
- names.append(it.current()->itemName()); |
- return names; |
- */ |
- return ScCore->primaryMainWindow()->doc->m_Selection->getSelectedItemsByName(); |
-} |
- |
-bool setSelectedItemsByName(const QStringList& itemNames) |
-{ |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- ScribusView* currentView = ScCore->primaryMainWindow()->view; |
- |
- currentView->deselectItems(); |
- |
- // For each named item |
- for (auto it = itemNames.begin() ; it != itemNames.end() ; it++) |
- { |
- // Search for the named item |
- PageItem* item = nullptr; |
- for (int j = 0; j < currentDoc->Items->count(); j++) |
- { |
- if (*it == currentDoc->Items->at(j)->itemName()) |
- item = currentDoc->Items->at(j); |
- } |
- if (!item) |
- return false; |
- // And select it |
- currentView->selectItem(item); |
- } |
- return true; |
-} |
- |
-TableBorder parseBorder(PyObject* borderLines, bool* ok) |
-{ |
- TableBorder border; |
- |
- if (!PyList_Check(borderLines)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Expected a list of border lines", "python error").toLocal8Bit().constData()); |
- *ok = false; |
- return border; |
- } |
- |
- // Get the sequence of border lines. |
- PyObject* borderLinesList = PySequence_List(borderLines); |
- if (borderLinesList == nullptr) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Expected a list of border lines", "python error").toLocal8Bit().constData()); |
- *ok = false; |
- return border; |
- } |
- |
- // Parse each tuple describing a border line and append it to the border. |
- int nBorderLines = PyList_Size(borderLinesList); |
- for (int i = 0; i < nBorderLines; ++i) |
- { |
- double width = 0.0; |
- double shade = 100.0; |
- int style; |
- char* color; |
- PyObject* props = PyList_GET_ITEM(borderLinesList, i); |
- if (!PyArg_ParseTuple(props, "dies|d", &width, &style, "utf-8", &color, &shade)) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Border lines are specified as (width,style,color,shade) tuples", "python error").toLocal8Bit().constData()); |
- *ok = false; |
- return border; |
- } |
- if (width <= 0.0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Border line width must be > 0.0", "python error").toLocal8Bit().constData()); |
- *ok = false; |
- return border; |
- } |
- border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), QString::fromUtf8(color), shade)); |
- } |
- Py_DECREF(borderLinesList); |
- |
- *ok = true; |
- return border; |
-} |
- |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdutil.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcolor.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcolor.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcolor.cpp (nonexistent) |
@@ -1,709 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-//#include "api/api_color.h" |
-#include "cmdcolor.h" |
-#include "cmdutil.h" |
-#include "prefsmanager.h" |
-#include "commonstrings.h" |
-#include "scribuscore.h" |
-#include "scribusdoc.h" |
-#include "sccolorengine.h" |
- |
-PyObject *scribus_getcolornames(PyObject* /* self */) |
-{ |
- ColorList edc; |
- PyObject *l; |
- int cc = 0; |
- edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance().colorSet(); |
- ColorList::Iterator it; |
- l = PyList_New(edc.count()); |
- for (it = edc.begin(); it != edc.end(); ++it) |
- { |
- PyList_SetItem(l, cc, PyString_FromString(it.key().toUtf8())); |
- cc++; |
- } |
- return l; |
-} |
- |
-PyObject *scribus_getcolor(PyObject* /* self */, PyObject* args) |
-{ |
- ColorList edc; |
- char *Name = const_cast<char*>(""); |
- int c, m, y, k; |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot get a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance().colorSet(); |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc : nullptr; |
- QString col = QString::fromUtf8(Name); |
- if (!edc.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- CMYKColor cmykValues; |
- ScColorEngine::getCMYKValues(edc[col], currentDoc, cmykValues); |
- cmykValues.getValues(c, m, y, k); |
- return Py_BuildValue("(iiii)", static_cast<long>(c), static_cast<long>(m), static_cast<long>(y), static_cast<long>(k)); |
-} |
- |
-PyObject *scribus_getcolorfloat(PyObject* /* self */, PyObject* args) |
-{ |
- ColorList edc; |
- char *Name = const_cast<char*>(""); |
- double c, m, y, k; |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot get a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance().colorSet(); |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc : nullptr; |
- QString col = QString::fromUtf8(Name); |
- if (!edc.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- CMYKColorF cmykValues; |
- ScColorEngine::getCMYKValues(edc[col], currentDoc, cmykValues); |
- cmykValues.getValues(c, m, y, k); |
- return Py_BuildValue("(dddd)", c * 100.0, m * 100.0, y * 100.0, k * 100.0); |
-} |
- |
-PyObject *scribus_getcolorasrgb(PyObject* /* self */, PyObject* args) |
-{ |
- ColorList edc; |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot get a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance().colorSet(); |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc : nullptr; |
- QString col = QString::fromUtf8(Name); |
- if (!edc.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QColor rgb = ScColorEngine::getRGBColor(edc[col], currentDoc); |
- return Py_BuildValue("(iii)", static_cast<long>(rgb.red()), static_cast<long>(rgb.green()), static_cast<long>(rgb.blue())); |
-} |
- |
-PyObject *scribus_getcolorasrgbfloat(PyObject* /* self */, PyObject* args) |
-{ |
- ColorList edc; |
- double r, g, b; |
- char *Name = const_cast<char*>(""); |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot get a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance().colorSet(); |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc : nullptr; |
- QString col = QString::fromUtf8(Name); |
- if (!edc.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- RGBColorF rgbValues; |
- ScColorEngine::getRGBValues(edc[col], currentDoc, rgbValues); |
- rgbValues.getValues(r, g, b); |
- return Py_BuildValue("(ddd)", r * 255.0, g * 255.0, b * 255.0); |
-} |
- |
-PyObject *scribus_setcolor(PyObject* self, PyObject* args) |
-{ |
- return scribus_setcolorcmyk(self, args); |
-} |
- |
-PyObject *scribus_setcolorcmyk(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int c, m, y, k; |
- if (!PyArg_ParseTuple(args, "esiiii", "utf-8", &Name, &c, &m, &y, &k)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->doc->PageColors[col].setCmykColor(c, m, y, k); |
- } |
- else |
- { |
- ColorList* colorList=PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- (*colorList)[col].setCmykColor(c, m, y, k); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcolorcmykfloat(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double c, m, y, k; |
- if (!PyArg_ParseTuple(args, "esdddd", "utf-8", &Name, &c, &m, &y, &k)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- c = qMax(0.0, qMin(c , 100.0)) / 100.0; |
- m = qMax(0.0, qMin(m , 100.0)) / 100.0; |
- y = qMax(0.0, qMin(y , 100.0)) / 100.0; |
- k = qMax(0.0, qMin(k , 100.0)) / 100.0; |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->doc->PageColors[col].setCmykColorF(c, m, y, k); |
- } |
- else |
- { |
- ColorList* colorList=PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- (*colorList)[col].setCmykColorF(c, m, y, k); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcolorrgb(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int r, g, b; |
- if (!PyArg_ParseTuple(args, "esiii", "utf-8", &Name, &r, &g, &b)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->doc->PageColors[col].setRgbColor(r, g, b); |
- } |
- else |
- { |
- ColorList* colorList=PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- (*colorList)[col].setRgbColor(r, g, b); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcolorrgbfloat(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double r, g, b; |
- if (!PyArg_ParseTuple(args, "esddd", "utf-8", &Name, &r, &g, &b)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- r = qMax(0.0, qMin(r, 255.0)) / 255.0; |
- g = qMax(0.0, qMin(g, 255.0)) / 255.0; |
- b = qMax(0.0, qMin(b, 255.0)) / 255.0; |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->doc->PageColors[col].setRgbColorF(r, g, b); |
- } |
- else |
- { |
- ColorList* colorList = PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- (*colorList)[col].setRgbColorF(r, g, b); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcolorlab(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double L, a, b; |
- if (!PyArg_ParseTuple(args, "esddd", "utf-8", &Name, &L, &a, &b)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- L = qMax(0.0, qMin(L, 100.0)); |
- a = qMax(-128.0, qMin(a, 128.0)); |
- b = qMax(-128.0, qMin(b, 128.0)); |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- ScCore->primaryMainWindow()->doc->PageColors[col].setLabColor(L, a, b); |
- } |
- else |
- { |
- ColorList* colorList = PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- (*colorList)[col].setLabColor(L, a, b); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_newcolor(PyObject* self, PyObject* args) |
-{ |
- return scribus_newcolorcmyk(self, args); |
-} |
- |
-PyObject *scribus_newcolorcmyk(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int c, m, y, k; |
- if (!PyArg_ParseTuple(args, "esiiii", "utf-8", &Name, &c, &m, &y, &k)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- ScCore->primaryMainWindow()->doc->PageColors.insert(col, ScColor(c, m, y, k)); |
- else |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- ScCore->primaryMainWindow()->doc->PageColors[col].setCmykColor(c, m, y, k); |
- } |
- else |
- { |
- ColorList* colorList=PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- colorList->insert(col, ScColor(c, m, y, k)); |
- else |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- (*colorList)[col].setCmykColor(c, m, y, k); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_newcolorcmykfloat(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double c, m, y, k; |
- if (!PyArg_ParseTuple(args, "esdddd", "utf-8", &Name, &c, &m, &y, &k)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- c = qMax(0.0, qMin(c , 100.0)) / 100.0; |
- m = qMax(0.0, qMin(m , 100.0)) / 100.0; |
- y = qMax(0.0, qMin(y , 100.0)) / 100.0; |
- k = qMax(0.0, qMin(k , 100.0)) / 100.0; |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- ScColor tmp; |
- tmp.setCmykColorF(c, m, y, k); |
- ScCore->primaryMainWindow()->doc->PageColors.insert(col, tmp); |
- } |
- else |
- { |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- ScCore->primaryMainWindow()->doc->PageColors[col].setCmykColorF(c, m, y, k); |
- } |
- } |
- else |
- { |
- ColorList* colorList = PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- { |
- ScColor tmp; |
- tmp.setCmykColorF(c, m, y, k); |
- colorList->insert(col, tmp); |
- } |
- else |
- { |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- (*colorList)[col].setCmykColorF(c, m, y, k); |
- } |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_newcolorrgb(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int r, g, b; |
- if (!PyArg_ParseTuple(args, "esiii", "utf-8", &Name, &r, &g, &b)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- ScCore->primaryMainWindow()->doc->PageColors.insert(col, ScColor(r, g, b)); |
- else |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- ScCore->primaryMainWindow()->doc->PageColors[col].setRgbColor(r, g, b); |
- } |
- else |
- { |
- ColorList* colorList=PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- colorList->insert(col, ScColor(r, g, b)); |
- else |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- (*colorList)[col].setRgbColor(r, g, b); |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_newcolorrgbfloat(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double r, g, b; |
- if (!PyArg_ParseTuple(args, "esddd", "utf-8", &Name, &r, &g, &b)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- r = qMax(0.0, qMin(r, 255.0)) / 255.0; |
- g = qMax(0.0, qMin(g, 255.0)) / 255.0; |
- b = qMax(0.0, qMin(b, 255.0)) / 255.0; |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- ScColor tmp; |
- tmp.setRgbColorF(r, g, b); |
- ScCore->primaryMainWindow()->doc->PageColors.insert(col, tmp); |
- } |
- else |
- { |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- ScCore->primaryMainWindow()->doc->PageColors[col].setRgbColorF(r, g, b); |
- } |
- } |
- else |
- { |
- ColorList* colorList = PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- { |
- ScColor tmp; |
- tmp.setRgbColorF(r, g, b); |
- colorList->insert(col, tmp); |
- } |
- else |
- { |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- (*colorList)[col].setRgbColorF(r, g, b); |
- } |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_newcolorlab(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- double L, a, b; |
- if (!PyArg_ParseTuple(args, "esddd", "utf-8", &Name, &L, &a, &b)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- L = qMax(0.0, qMin(L, 100.0)); |
- a = qMax(-128.0, qMin(a, 128.0)); |
- b = qMax(-128.0, qMin(b, 128.0)); |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- ScColor tmp; |
- tmp.setLabColor(L, a, b); |
- ScCore->primaryMainWindow()->doc->PageColors.insert(col, tmp); |
- } |
- else |
- { |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- ScCore->primaryMainWindow()->doc->PageColors[col].setLabColor(L, a, b); |
- } |
- } |
- else |
- { |
- ColorList* colorList = PrefsManager::instance().colorSetPtr(); |
- if (!colorList->contains(col)) |
- { |
- ScColor tmp; |
- tmp.setLabColor(L, a, b); |
- colorList->insert(col, tmp); |
- } |
- else |
- { |
- // FIXME: Given that we have a changeColour function, should we really be |
- // silently changing colours in newColour? |
- (*colorList)[col].setLabColor(L, a, b); |
- } |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_deletecolor(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Repl = const_cast<char*>(CommonStrings::None.toLatin1().constData()); |
- if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Name, "utf-8", &Repl)) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot delete a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- QString rep = QString::fromUtf8(Repl); |
- if (ScCore->primaryMainWindow()->HaveDoc) |
- { |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- if (currentDoc->PageColors.contains(col) && (currentDoc->PageColors.contains(rep) || (rep == CommonStrings::None))) |
- { |
- currentDoc->PageColors.remove(col); |
- ReplaceColor(col, rep); |
- } |
- else |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- } |
- else |
- { |
- ColorList* colorList=PrefsManager::instance().colorSetPtr(); |
- if (colorList->contains(col)) |
- colorList->remove(col); |
- else |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_replcolor(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- char *Repl = const_cast<char*>(CommonStrings::None.toLatin1().constData()); |
- //FIXME: this should definitely use keyword arguments |
- if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Name, "utf-8", &Repl)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot replace a color with an empty name.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- QString rep = QString::fromUtf8(Repl); |
- if (ScCore->primaryMainWindow()->doc->PageColors.contains(col) && (ScCore->primaryMainWindow()->doc->PageColors.contains(rep) || (rep == CommonStrings::None))) |
- ReplaceColor(col, rep); |
- else |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_isspotcolor(PyObject * /*self*/, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- |
- if (!PyArg_ParseTuple(args, "es", "utf-8", &Name)) |
- return nullptr; |
- |
-// QString errorMsg; |
-// QString colorName = QString::fromUtf8(Name); |
-// if (!ScribusAPI::existsColor(colorName, errorMsg)) |
-// { |
-// PyErr_SetString(PyExc_ValueError, errorMsg.toLocal8Bit().constData()); |
-// return nullptr; |
-// } |
-// return PyBool_FromLong(static_cast<long>(ScribusAPI::isSpotColor(Name))); |
- |
- |
- |
- |
- |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Color name cannot be an empty string.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- if (ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- return PyBool_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->PageColors[col].isSpotColor())); |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
-// Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setspotcolor(PyObject * /*self*/, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int enable; |
- |
- if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &enable)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- if (strcmp(Name, "") == 0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Color name cannot be an empty string.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- QString col = QString::fromUtf8(Name); |
- if (ScCore->primaryMainWindow()->doc->PageColors.contains(col)) |
- { |
- ScCore->primaryMainWindow()->doc->PageColors[col].setSpotColor(static_cast<bool>(enable)); |
- } |
- else |
- { |
- PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- Py_RETURN_NONE; |
-} |
- |
- |
- |
-/*! HACK: this removes "warning: 'blash' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmdcolordocswarnings() |
-{ |
- QStringList s; |
- s << scribus_getcolornames__doc__ |
- << scribus_deletecolor__doc__ |
- << scribus_getcolor__doc__ |
- << scribus_getcolorasrgb__doc__ |
- << scribus_getcolorasrgbfloat__doc__ |
- << scribus_getcolorfloat__doc__ |
- << scribus_isspotcolor__doc__ |
- << scribus_newcolor__doc__ |
- << scribus_newcolorcmyk__doc__ |
- << scribus_newcolorcmykfloat__doc__ |
- << scribus_newcolorlab__doc__ |
- << scribus_newcolorrgb__doc__ |
- << scribus_newcolorrgbfloat__doc__ |
- << scribus_replcolor__doc__ |
- << scribus_setcolor__doc__ |
- << scribus_setcolorcmyk__doc__ |
- << scribus_setcolorcmykfloat__doc__ |
- << scribus_setcolorlab__doc__ |
- << scribus_setcolorrgb__doc__ |
- << scribus_setcolorrgbfloat__doc__ |
- << scribus_setspotcolor__doc__; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcolor.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.h |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.h (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.h (nonexistent) |
@@ -1,405 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#ifndef CMDOBJ_H |
-#define CMDOBJ_H |
- |
-// Pulls in <Python.h> first |
-#include "cmdvar.h" |
- |
-/** Object related Commands */ |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createrect__doc__, |
-QT_TR_NOOP("createRect(x, y, width, height, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new rectangle on the current page and returns its name. The\n\ |
-coordinates are given in the current measurement units of the document\n\ |
-(see UNIT constants). \"name\" should be a unique identifier for the object\n\ |
-because you need this name to reference that object in future. If \"name\"\n\ |
-is not given Scribus will create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-")); |
-/** Creates a rectangular with params X, Y (base position) |
- b, h (width, height) and optional name of the object. |
- */ |
-PyObject *scribus_createrect(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createellipse__doc__, |
-QT_TR_NOOP("createEllipse(x, y, width, height, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new ellipse on the current page and returns its name.\n\ |
-The coordinates are given in the current measurement units of the document\n\ |
-(see UNIT constants). \"name\" should be a unique identifier for the object\n\ |
-because you need this name for further referencing of that object. If \"name\"\n\ |
-is not given Scribus will create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-")); |
-/** Creates an ellipse with x, y, b and h - name optionally |
- params. |
- */ |
-PyObject *scribus_createellipse(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createimage__doc__, |
-QT_TR_NOOP("createImage(x, y, width, height, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new picture frame on the current page and returns its name. The\n\ |
-coordinates are given in the current measurement units of the document.\n\ |
-\"name\" should be a unique identifier for the object because you need this\n\ |
-name for further access to that object. If \"name\" is not given Scribus will\n\ |
-create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-")); |
-/** Creates an image frame - x, y, b, h and opt. name. */ |
-PyObject *scribus_createimage(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createtext__doc__, |
-QT_TR_NOOP("createText(x, y, width, height, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new text frame on the actual page and returns its name.\n\ |
-The coordinates are given in the actual measurement unit of the document (see\n\ |
-UNIT constants). \"name\" should be a unique identifier for the object because\n\ |
-you need this name for further referencing of that object. If \"name\" is not\n\ |
-given Scribus will create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-")); |
-/** Creates a text frame - x, y, b, h and opt. name. */ |
-PyObject *scribus_createtext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createtable__doc__, |
-QT_TR_NOOP("createTable(x, y, width, height, numRows, numColumns, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new table with the given number of rows and columns on the actual page\n\ |
-and returns its name. The coordinates are given in the actual measurement unit of\n\ |
-the document (see UNIT constants). \"name\" should be a unique identifier for\n\ |
-the object because you need this name for further referencing of that object. If\n\ |
-\"name\" is not given Scribus will create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-May raise ValueError if an insufficient number of rows or columns is passed.\n\ |
-")); |
-/** Creates a table - x, y, width, height, numRows, numColumns and opt. name. */ |
-PyObject *scribus_createtable(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createline__doc__, |
-QT_TR_NOOP("createLine(x1, y1, x2, y2, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new line from the point(x1, y1) to the point(x2, y2) and returns\n\ |
-its name. The coordinates are given in the current measurement unit of the\n\ |
-document (see UNIT constants). \"name\" should be a unique identifier for the\n\ |
-object because you need this name for further access to that object. If\n\ |
-\"name\" is not given Scribus will create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-")); |
-/** Creates a line object - x, y, b, h and opt. name. */ |
-PyObject *scribus_createline(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createpolyline__doc__, |
-QT_TR_NOOP("createPolyLine(list, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new polyline and returns its name. The points for the polyline are\n\ |
-stored in the list \"list\" in the following order: [x1, y1, x2, y2...xn. yn].\n\ |
-The coordinates are given in the current measurement units of the document (see\n\ |
-UNIT constants). \"name\" should be a unique identifier for the object because\n\ |
-you need this name for further access to that object. If \"name\" is not given\n\ |
-Scribus will create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-May raise ValueError if an insufficient number of points is passed or if\n\ |
-the number of values passed don't group into points without leftovers.\n\ |
-")); |
-/** Creates a polygon line - list with points and opt. name as params. */ |
-PyObject *scribus_createpolyline(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createpolygon__doc__, |
-QT_TR_NOOP("createPolygon(list, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new polygon and returns its name. The points for the polygon are\n\ |
-stored in the list \"list\" in the following order: [x1, y1, x2, y2...xn. yn].\n\ |
-At least three points are required. There is no need to repeat the first point\n\ |
-to close the polygon. The polygon is automatically closed by connecting the\n\ |
-first and the last point. The coordinates are given in the current measurement\n\ |
-units of the document (see UNIT constants). \"name\" should be a unique\n\ |
-identifier for the object because you need this name for further access to that\n\ |
-object. If \"name\" is not given Scribus will create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-May raise ValueError if an insufficient number of points is passed or if\n\ |
-the number of values passed don't group into points without leftovers.\n\ |
-")); |
-/** Creates a polygon - list with points and opt. name as params. */ |
-PyObject *scribus_createpolygon(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createbezierline__doc__, |
-QT_TR_NOOP("createBezierLine(list, [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new bezier curve and returns its name. The points for the bezier\n\ |
-curve are stored in the list \"list\" in the following order:\n\ |
-[x1, y1, kx1, ky1, x2, y2, kx2, ky2...xn. yn, kxn. kyn]\n\ |
-In the points list, x and y mean the x and y coordinates of the point and kx\n\ |
-and ky meaning the control point for the curve. The coordinates are given in\n\ |
-the current measurement units of the document (see UNIT constants). \"name\"\n\ |
-should be a unique identifier for the object because you need this name for\n\ |
-further access to that object. If \"name\" is not given Scribus will create one\n\ |
-for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-May raise ValueError if an insufficient number of points is passed or if\n\ |
-the number of values passed don't group into points without leftovers.\n\ |
-")); |
-/** Creates a Bezier line - list with points and opt. name as params. */ |
-PyObject *scribus_createbezierline(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_createpathtext__doc__, |
-QT_TR_NOOP("createPathText(x, y, \"textbox\", \"beziercurve\", [\"name\"]) -> string\n\ |
-\n\ |
-Creates a new pathText by merging the two objects \"textbox\" and\n\ |
-\"beziercurve\" and returns its name. The coordinates are given in the current\n\ |
-measurement unit of the document (see UNIT constants). \"name\" should be a\n\ |
-unique identifier for the object because you need this name for further access\n\ |
-to that object. If \"name\" is not given Scribus will create one for you.\n\ |
-\n\ |
-May raise NameExistsError if you explicitly pass a name that's already used.\n\ |
-May raise NotFoundError if one or both of the named base object don't exist.\n\ |
-")); |
-/** Joins 2 objects - textframe and line - into text on path. |
- Uses x, y (base of the new object), name of the text frame, |
- name of the line and opt. new name as params. */ |
-PyObject *scribus_createpathtext(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_deleteobject__doc__, |
-QT_TR_NOOP("deleteObject([\"name\"])\n\ |
-\n\ |
-Deletes the item with the name \"name\". If \"name\" is not given the currently\n\ |
-selected item is deleted.\n\ |
-")); |
-/** Deletes an object - if is the name given the named object is |
- deleted else the active object erased. */ |
-PyObject *scribus_deleteobject(PyObject * /*self*/, PyObject* args); |
- |
-PyDoc_STRVAR(scribus_gettextflowmode__doc__, |
-QT_TR_NOOP("getTextFlowMode([\"name\"]) -> integer\n\ |
-\n\ |
-Return the current text flow mode used by item \"name\" as an integer.\n\ |
-If \"name\" is not given, the currently selected object is used.\n\ |
-\n\ |
-The function will return one of the following value:\n\ |
-- 0 : text flow around frame is disabled\n\ |
-- 1 : text flow around frame shape\n\ |
-- 2 : text flow around frame bounding box\n\ |
-- 3 : text flow around frame contour line\n\ |
-- 4 : text flow around image clip path\n\ |
-")); |
-PyObject *scribus_gettextflowmode(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_settextflowmode__doc__, |
-QT_TR_NOOP("setTextFlowMode(\"name\" [, state])\n\ |
-\n\ |
-Enables/disables \"Text Flows Around Frame\" feature for object \"name\".\n\ |
-Called with parameters string name and optional int \"state\" (0 <= state <= 3).\n\ |
-Setting \"state\" to 0 will disable text flow.\n\ |
-Setting \"state\" to 1 will make text flow around object frame.\n\ |
-Setting \"state\" to 2 will make text flow around bounding box.\n\ |
-Setting \"state\" to 3 will make text flow around contour line.\n\ |
-If \"state\" is not passed, text flow is toggled.\n\ |
-")); |
-PyDoc_STRVAR(scribus_textflowmode__doc__, |
-QT_TR_NOOP("textFlowMode(\"name\" [, state])\n\ |
-\n\ |
-Deprecated. Use setTextFlowMode() instead.\n\ |
-")); |
-/** |
-Enables/disables "Text Flows Around Object" feature for object. |
-Called with params string objectName and state 0|1|2|3. |
-When set to 0 disable flowing, 1 text flows around frame, |
-2 around bounding box, 3 around contour line. When is second param |
-empty flowing is reverted. |
-02/28/2004 petr vanek |
- */ |
-PyObject *scribus_settextflowmode(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_objectexists__doc__, |
-QT_TR_NOOP("objectExists([\"name\"]) -> bool\n\ |
-\n\ |
-Test if an object with specified name really exists in the document.\n\ |
-The optional parameter is the object name. When no object name is given,\n\ |
-returns True if there is something selected.\n\ |
-")); |
-/** |
-User test if an object with specified name really exists in |
-the doc. Object name as param. |
-03/29/2004 petr vanek |
-ObjectName is now optional. When none set, search for selection... |
-07/11/2004 pv |
-*/ |
-PyObject *scribus_objectexists(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getcharacterstyle__doc__, |
-QT_TR_NOOP("getCharacterStyle([\"name\"])\n\ |
-\n\ |
-Return name of character style applied to object named \"name\". If \"name\" is not given,\n\ |
-the currently selected object is used. If current object has a text selection, \n\ |
-the name of style applied to start of selection is returned. Otherwise the name \n\ |
-of the item default character style is returned.\n\ |
-")); |
-PyObject *scribus_getcharacterstyle(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_getparagraphstyle__doc__, |
-QT_TR_NOOP("getParagraphStyle([\"name\"])\n\ |
-\n\ |
-Return name of paragraph style applied to object named \"name\". If \"name\" is not given,\n\ |
-the currently selected object is used. If current object has a text selection, \n\ |
-the name of style applied to start of selection is returned. Otherwise the name \n\ |
-of the item default style is returned.\n\ |
-")); |
- |
-PyDoc_STRVAR(scribus_getstyle__doc__, |
-QT_TR_NOOP("getStyle([\"name\"])\n\ |
-\n\ |
-Deprecated. Use getParagraphStyle() instead.\n\ |
-")); |
-/** |
- Vaclav Smilauer, 2017-12-21 |
- Return style name of the object (or currently selected object) |
- */ |
-PyObject *scribus_getparagraphstyle(PyObject * /*self*/, PyObject* args); |
- |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setparagraphstyle__doc__, |
-QT_TR_NOOP("setParagraphStyle(\"style\" [, \"name\"])\n\ |
-\n\ |
-Apply the named paragraph \"style\" to the object named \"name\".\n\ |
-If object name is not provided, style is applied on current object selection.\n\ |
-If multiple objects are selected or if selected object has no text selection,\n\ |
-style is applied on selected objects. Otherwise style is applied to the current\n\ |
-text selection.\n\ |
-")); |
- |
-PyDoc_STRVAR(scribus_setstyle__doc__, |
-QT_TR_NOOP("setStyle(\"style\" [, \"name\"])\n\ |
-\n\ |
-Deprecated. Use setParagraphStyle() instead.\n\ |
-")); |
-/** |
- Craig Ringer, 2004-09-09 |
- Apply the named style to the currently selected object. |
- pv, 2004-09-13, optionally param objectName + "check the page" stuff |
- */ |
-PyObject *scribus_setparagraphstyle(PyObject * /*self*/, PyObject* args); |
- |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_setcharstyle__doc__, |
-QT_TR_NOOP("setCharacterStyle(\"style\" [, \"name\"])\n\ |
-\n\ |
-Apply the named character \"style\" to the object named \"name\".\n\ |
-If object name is not provided, style is applied on current object selection.\n\ |
-If multiple objects are selected or if selected object has no text selection,\n\ |
-style is applied on selected objects. Otherwise style is applied to the current\n\ |
-text selection.\n\ |
-")); |
-/** |
-Apply the named character style to the currently selected object. |
-*/ |
-PyObject *scribus_setcharstyle(PyObject * /*self*/, PyObject* args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_duplicateobject__doc__, |
-QT_TR_NOOP("duplicateObject([\"name\"]) -> string\n\ |
-\n\ |
-Creates a duplicate of the specified object or of first item of selection if \"name\" is not given.\n\ |
-Returns name of new object.\n\ |
-Deprecated. Use duplicateObjects() instead.\n\ |
-")); |
-/** |
- Christian Hausknecht, 2006-07-12 |
- duplicate an object |
-*/ |
-PyObject *scribus_duplicateobject(PyObject * /* self */, PyObject *args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_duplicateobjects__doc__, |
-QT_TR_NOOP("duplicateObjects([names]) -> list\n\ |
-\n\ |
-Creates a duplicate of the specified objects or of the current selection if no names are given.\n\ |
-The names of objects to duplicate can be provided as a string to duplicate a single object\n\ |
-or as a list of strings to duplicate several objects at once.\n\ |
-Returns a list of the names of the newly created objects.\n\ |
-")); |
-PyObject *scribus_duplicateobjects(PyObject * /* self */, PyObject *args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_copyobject__doc__, |
-QT_TR_NOOP("copyObject([\"name\"]) -> string\n\ |
-\n\ |
-Copies the specified object or first item of selection if \"name\" is not given.\n\ |
-Deprecated. Use copyObjects instead.\n\ |
-")); |
-/** |
- Gregory Pittman, 2012-01-12 |
- copy an object |
-*/ |
-PyObject *scribus_copyobject(PyObject * /* self */, PyObject *args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_copyobjects__doc__, |
-QT_TR_NOOP("copyObjects([names])\n\ |
-\n\ |
-Copies the specified objects or the current object selection if no item names are given.\n\ |
-The names of objects to copy can be provided as a string for copying a single object\n\ |
-or as a list of strings to copy several objects at once.\n\ |
-")); |
-PyObject *scribus_copyobjects(PyObject * /* self */, PyObject *args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_pasteobject__doc__, |
-QT_TR_NOOP("pasteObject() -> string\n\ |
-\n\ |
-Pastes an object from the clipboard. This will be used only or most\n\ |
-sensibly following copyObject(...), since otherwise there will likely\n\ |
-be nothing in the clipboard to paste.\n\ |
-Returns the names of the newly created object in a comma separated string.\n\ |
-Deprecated. Use pasteObjects() instead.\n\ |
-")); |
-/** |
- Gregory Pittman, 2012-01-29 |
- pastes an object |
-*/ |
-PyObject *scribus_pasteobject(PyObject * /* self */, PyObject *args); |
- |
-/*! docstring */ |
-PyDoc_STRVAR(scribus_pasteobjects__doc__, |
-QT_TR_NOOP("pasteObjects() -> list\n\ |
-\n\ |
-Pastes the content of clipboard to canvas. This will be used only or most\n\ |
-sensibly following copyObjects(...), since otherwise there will likely\n\ |
-be nothing in the clipboard to paste.\n\ |
-Returns the names of the newly created object in a list.\n\ |
-")); |
-PyObject *scribus_pasteobjects(PyObject * /* self */, PyObject *args); |
- |
-#endif |
- |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.h |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcell.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcell.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcell.cpp (nonexistent) |
@@ -1,519 +0,0 @@ |
-/* |
- * Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com> |
- * |
- * For general Scribus (>=1.3.2) copyright and licensing information please refer |
- * to the COPYING file provided with the program. Following this notice may exist |
- * a copyright and/or license notice that predates the release of Scribus 1.3.2 |
- * for which a new license (GPL+exception) is in place. |
- */ |
- |
-#include "cmdcell.h" |
-#include "cmdutil.h" |
-#include "pageitem_table.h" |
-#include "pageitem_textframe.h" |
-#include "tableborder.h" |
- |
-PyObject *scribus_getcelltext(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- if (!PyArg_ParseTuple(args, "ii|es", &row, &column, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get cell text on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- PageItem* textFrame = table->cellAt(row, column).textFrame(); |
- const StoryText& story = textFrame->itemText; |
- QString text; |
- text.reserve(story.hasSelection() ? story.selectionLength() : story.length()); |
- for (int i = 0; i < story.length(); i++) |
- { |
- if (textFrame->HasSel) |
- { |
- if (story.selected(i)) |
- text += story.text(i); |
- } |
- else |
- { |
- text += story.text(i); |
- } |
- } |
- return PyString_FromString(text.toUtf8()); |
-} |
- |
-PyObject *scribus_setcelltext(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- char *text; |
- if (!PyArg_ParseTuple(args, "iies|es", &row, &column, "utf-8", &text, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell text on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- table->cellAt(row, column).setText(QString::fromUtf8(text)); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getcellstyle(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- if (!PyArg_ParseTuple(args, "ii|es", &row, &column, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get cell style on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyString_FromString(table->cellAt(row, column).styleName().toUtf8()); |
-} |
- |
-PyObject *scribus_setcellstyle(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- char *style; |
- if (!PyArg_ParseTuple(args, "iies|es", &row, &column, "utf-8", &style, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell style on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- table->cellAt(row, column).setStyle(QString::fromUtf8(style)); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_getcellrowspan(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- if (!PyArg_ParseTuple(args, "ii|es", &row, &column, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get cell row span from non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(table->cellAt(row, column).rowSpan())); |
-} |
- |
-PyObject *scribus_getcellcolumnspan(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- if (!PyArg_ParseTuple(args, "ii|es", &row, &column, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get cell column span from non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyInt_FromLong(static_cast<long>(table->cellAt(row, column).columnSpan())); |
-} |
- |
-PyObject *scribus_getcellfillcolor(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- if (!PyArg_ParseTuple(args, "ii|es", &row, &column, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get cell fill color on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- return PyString_FromString(table->cellAt(row, column).fillColor().toUtf8()); |
-} |
- |
-PyObject *scribus_setcellfillcolor(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- char *color; |
- if (!PyArg_ParseTuple(args, "iies|es", &row, &column, "utf-8", &color, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell fill color on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- table->cellAt(row, column).setFillColor(QString::fromUtf8(color)); |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcellleftborder(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- PyObject* borderLines; |
- if (!PyArg_ParseTuple(args, "iiO|es", &row, &column, &borderLines, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell left border on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- bool ok = false; |
- TableBorder border = parseBorder(borderLines, &ok); |
- if (ok) |
- table->cellAt(row, column).setLeftBorder(border); |
- else |
- return nullptr; |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcellrightborder(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- PyObject* borderLines; |
- if (!PyArg_ParseTuple(args, "iiO|es", &row, &column, &borderLines, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell right border on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- bool ok = false; |
- TableBorder border = parseBorder(borderLines, &ok); |
- if (ok) |
- table->cellAt(row, column).setRightBorder(border); |
- else |
- return nullptr; |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcelltopborder(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- PyObject* borderLines; |
- if (!PyArg_ParseTuple(args, "iiO|es", &row, &column, &borderLines, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell top border on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- bool ok = false; |
- TableBorder border = parseBorder(borderLines, &ok); |
- if (ok) |
- table->cellAt(row, column).setTopBorder(border); |
- else |
- return nullptr; |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcellbottomborder(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- PyObject* borderLines; |
- if (!PyArg_ParseTuple(args, "iiO|es", &row, &column, &borderLines, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell bottom border on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- |
- bool ok = false; |
- TableBorder border = parseBorder(borderLines, &ok); |
- if (ok) |
- table->cellAt(row, column).setBottomBorder(border); |
- else |
- return nullptr; |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcellleftpadding(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- double padding; |
- if (!PyArg_ParseTuple(args, "iid|es", &row, &column, &padding, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell left padding on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (padding < 0.0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cell padding must be >= 0.0", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- table->cellAt(row, column).setLeftPadding(padding); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcellrightpadding(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- double padding; |
- if (!PyArg_ParseTuple(args, "iid|es", &row, &column, &padding, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell right padding on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (padding < 0.0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cell padding must be >= 0.0", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- table->cellAt(row, column).setRightPadding(padding); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcelltoppadding(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- double padding; |
- if (!PyArg_ParseTuple(args, "iid|es", &row, &column, &padding, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell top padding on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (padding < 0.0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cell padding must be >= 0.0", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- table->cellAt(row, column).setTopPadding(padding); |
- |
- Py_RETURN_NONE; |
-} |
- |
-PyObject *scribus_setcellbottompadding(PyObject* /* self */, PyObject* args) |
-{ |
- char *Name = const_cast<char*>(""); |
- int row, column; |
- double padding; |
- if (!PyArg_ParseTuple(args, "iid|es", &row, &column, &padding, "utf-8", &Name)) |
- return nullptr; |
- if (!checkHaveDocument()) |
- return nullptr; |
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
- if (i == nullptr) |
- return nullptr; |
- PageItem_Table *table = i->asTable(); |
- if (!table) |
- { |
- PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set cell bottom padding on a non-table item.","python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (column < 0 || column >= table->columns() || row < 0 || row >= table->rows()) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("The cell %1,%2 does not exist in table", "python error").arg(row).arg(column).toLocal8Bit().constData()); |
- return nullptr; |
- } |
- if (padding < 0.0) |
- { |
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cell padding must be >= 0.0", "python error").toLocal8Bit().constData()); |
- return nullptr; |
- } |
- table->cellAt(row, column).setBottomPadding(padding); |
- |
- Py_RETURN_NONE; |
-} |
- |
-/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
-with header files structure untouched (docstrings are kept near declarations) |
-PV */ |
-void cmdcelldocwarnings() |
-{ |
- QStringList s; |
- s << scribus_getcellcolumnspan__doc__ |
- << scribus_getcellfillcolor__doc__ |
- << scribus_getcellrowspan__doc__ |
- << scribus_getcellstyle__doc__ |
- << scribus_getcelltext__doc__ |
- << scribus_setcellbottomborder__doc__ |
- << scribus_setcellbottompadding__doc__ |
- << scribus_setcellfillcolor__doc__ |
- << scribus_setcellleftborder__doc__ |
- << scribus_setcellleftpadding__doc__ |
- << scribus_setcellrightborder__doc__ |
- << scribus_setcellrightpadding__doc__ |
- << scribus_setcellstyle__doc__ |
- << scribus_setcelltext__doc__ |
- << scribus_setcelltopborder__doc__ |
- << scribus_setcelltoppadding__doc__; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdcell.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptercore.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptercore.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptercore.cpp (nonexistent) |
@@ -1,647 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "scriptercore.h" |
- |
-#include <QGlobalStatic> |
-#include <QWidget> |
-#include <QString> |
-#include <QStringList> |
-#include <QApplication> |
-#include <QMessageBox> |
-#include <QTextCodec> |
-#include <QByteArray> |
-#include <QPixmap> |
-#include <cstdlib> |
- |
-#include "cmdutil.h" |
-#include "runscriptdialog.h" |
-#include "ui/helpbrowser.h" |
-#include "ui/marksmanager.h" |
-#include "ui/notesstyleseditor.h" |
-#include "ui/propertiespalette.h" //TODO Move the calls to this to a signal |
-#include "ui/contentpalette.h" //TODO Move the calls to this to a signal |
-#include "ui/pagepalette.h" //TODO Move the calls to this to a signal |
-#include "ui/layers.h" //TODO Move the calls to this to a signal |
-#include "ui/outlinepalette.h" //TODO Move the calls to this to a signal |
-#include "ui/scmessagebox.h" |
-#include "ui/scmwmenumanager.h" |
-#include "pconsole.h" |
-#include "scraction.h" |
-#include "scribuscore.h" |
-#include "scribusdoc.h" |
-#include "scribusview.h" |
-#include "scpaths.h" |
-#include "selection.h" |
-#include "prefsfile.h" |
-#include "prefscontext.h" |
-#include "prefstable.h" |
-#include "prefsmanager.h" |
-#include "scribusapp.h" // need it to access ScQApp->pythonScript & ScQApp->pythonScriptArgs |
- |
-ScripterCore::ScripterCore(QWidget* parent) |
-{ |
- m_pyConsole = new PythonConsole(parent); |
- m_scripterActions.clear(); |
- m_recentScriptActions.clear(); |
- returnString = "init"; |
- |
- m_scripterActions.insert("scripterExecuteScript", new ScrAction(QObject::tr("&Execute Script..."), QKeySequence(), this)); |
- m_scripterActions.insert("scripterShowConsole", new ScrAction(QObject::tr("Show &Console"), QKeySequence(), this)); |
- m_scripterActions.insert("scripterAboutScript", new ScrAction(QObject::tr("&About Script..."), QKeySequence(), this)); |
- |
- m_scripterActions["scripterExecuteScript"]->setMenuRole(QAction::NoRole); |
- m_scripterActions["scripterShowConsole"]->setMenuRole(QAction::NoRole); |
- m_scripterActions["scripterAboutScript"]->setMenuRole(QAction::NoRole); |
- |
- m_scripterActions["scripterShowConsole"]->setToggleAction(true); |
- m_scripterActions["scripterShowConsole"]->setChecked(false); |
- |
- QObject::connect( m_scripterActions["scripterExecuteScript"], SIGNAL(triggered()) , this, SLOT(runScriptDialog()) ); |
- QObject::connect( m_scripterActions["scripterShowConsole"], SIGNAL(toggled(bool)) , this, SLOT(slotInteractiveScript(bool)) ); |
- QObject::connect( m_scripterActions["scripterAboutScript"], SIGNAL(triggered()) , this, SLOT(aboutScript()) ); |
- |
- m_savedRecentScripts.clear(); |
- readPlugPrefs(); |
- |
- QObject::connect(m_pyConsole, SIGNAL(runCommand()), this, SLOT(slotExecute())); |
- QObject::connect(m_pyConsole, SIGNAL(paletteShown(bool)), this, SLOT(slotInteractiveScript(bool))); |
- |
- QObject::connect(ScQApp, SIGNAL(appStarted()) , this, SLOT(runStartupScript()) ); |
- QObject::connect(ScQApp, SIGNAL(appStarted()) , this, SLOT(slotRunPythonScript()) ); |
-} |
- |
-ScripterCore::~ScripterCore() |
-{ |
- savePlugPrefs(); |
- delete m_pyConsole; |
-} |
- |
-void ScripterCore::addToMainWindowMenu(ScribusMainWindow *mw) |
-{ |
- m_menuMgr = mw->scrMenuMgr; |
- m_menuMgr->createMenu("Scripter", QObject::tr("&Script")); |
- m_menuMgr->createMenu("ScribusScripts", QObject::tr("&Scribus Scripts"), "Scripter"); |
- m_menuMgr->addMenuItemString("ScribusScripts", "Scripter"); |
- m_menuMgr->addMenuItemString("scripterExecuteScript", "Scripter"); |
- m_menuMgr->createMenu("RecentScripts", QObject::tr("&Recent Scripts"), "Scripter", false, true); |
- m_menuMgr->addMenuItemString("RecentScripts", "Scripter"); |
- m_menuMgr->addMenuItemString("scripterExecuteScript", "Scripter"); |
- m_menuMgr->addMenuItemString("SEPARATOR", "Scripter"); |
- m_menuMgr->addMenuItemString("scripterShowConsole", "Scripter"); |
- m_menuMgr->addMenuItemString("scripterAboutScript", "Scripter"); |
- |
- buildScribusScriptsMenu(); |
- |
- m_menuMgr->addMenuStringToMenuBarBefore("Scripter", "Windows"); |
- m_menuMgr->addMenuItemStringsToMenuBar("Scripter", m_scripterActions); |
- m_recentScripts = m_savedRecentScripts; |
- rebuildRecentScriptsMenu(); |
-} |
- |
-void ScripterCore::enableMainWindowMenu() |
-{ |
- if (!m_menuMgr) |
- return; |
- m_menuMgr->setMenuEnabled("ScribusScripts", true); |
- m_menuMgr->setMenuEnabled("RecentScripts", true); |
- m_scripterActions["scripterExecuteScript"]->setEnabled(true); |
-} |
- |
-void ScripterCore::disableMainWindowMenu() |
-{ |
- if (!m_menuMgr) |
- return; |
- m_menuMgr->setMenuEnabled("ScribusScripts", false); |
- m_menuMgr->setMenuEnabled("RecentScripts", false); |
- m_scripterActions["scripterExecuteScript"]->setEnabled(false); |
-} |
- |
-void ScripterCore::buildScribusScriptsMenu() |
-{ |
- QString pfad = ScPaths::instance().scriptDir(); |
- QString pfad2 = QDir::toNativeSeparators(pfad); |
- QDir ds(pfad2, "*.py", QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks); |
- if ((!ds.exists()) || (ds.count() == 0)) |
- return; |
- |
- for (uint dc = 0; dc < ds.count(); ++dc) |
- { |
- QFileInfo fs(ds[dc]); |
- QString strippedName=fs.baseName(); |
- m_scripterActions.insert(strippedName, new ScrAction( ScrAction::RecentScript, strippedName, QKeySequence(), this, strippedName)); |
- connect( m_scripterActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(StdScript(QString)) ); |
- m_menuMgr->addMenuItemString(strippedName, "ScribusScripts"); |
- } |
-} |
- |
-void ScripterCore::rebuildRecentScriptsMenu() |
-{ |
- m_menuMgr->clearMenuStrings("RecentScripts"); |
- m_recentScriptActions.clear(); |
- uint max = qMin(PrefsManager::instance().appPrefs.uiPrefs.recentDocCount, m_recentScripts.count()); |
- for (uint m = 0; m < max; ++m) |
- { |
- QString strippedName=m_recentScripts[m]; |
- strippedName.remove(QDir::separator()); |
- m_recentScriptActions.insert(strippedName, new ScrAction( ScrAction::RecentScript, m_recentScripts[m], QKeySequence(), this, m_recentScripts[m])); |
- connect( m_recentScriptActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(RecentScript(QString)) ); |
- m_menuMgr->addMenuItemString(strippedName, "RecentScripts"); |
- } |
- m_menuMgr->addMenuItemStringsToRememberedMenu("RecentScripts", m_recentScriptActions); |
-} |
- |
-void ScripterCore::finishScriptRun() |
-{ |
- ScribusMainWindow* mainWin = ScCore->primaryMainWindow(); |
- if (!mainWin->HaveDoc) |
- return; |
- |
- mainWin->propertiesPalette->setDoc(mainWin->doc); |
- mainWin->contentPalette->setDoc(mainWin->doc); |
- mainWin->marksManager->setDoc(mainWin->doc); |
- mainWin->nsEditor->setDoc(mainWin->doc); |
- mainWin->layerPalette->setDoc(mainWin->doc); |
- mainWin->outlinePalette->setDoc(mainWin->doc); |
- mainWin->outlinePalette->BuildTree(); |
- mainWin->pagePalette->setView(mainWin->view); |
- mainWin->pagePalette->rebuild(); |
- mainWin->doc->RePos = false; |
- if (mainWin->doc->m_Selection->count() != 0) |
- mainWin->doc->m_Selection->itemAt(0)->emitAllToGUI(); |
- mainWin->HaveNewSel(); |
- mainWin->view->DrawNew(); |
- //CB Really only need (want?) this for new docs, but we need it after a call to ScMW doFileNew. |
- //We don't want it in cmddoc calls as itll interact with the GUI before a script may be finished. |
- mainWin->HaveNewDoc(); |
-} |
- |
-void ScripterCore::runScriptDialog() |
-{ |
- QString fileName; |
- RunScriptDialog dia( ScCore->primaryMainWindow(), m_enableExtPython ); |
- if (dia.exec()) |
- { |
- fileName = dia.selectedFile(); |
- slotRunScriptFile(fileName, dia.extensionRequested()); |
- |
- if (m_recentScripts.indexOf(fileName) == -1) |
- m_recentScripts.prepend(fileName); |
- else |
- { |
- m_recentScripts.removeAll(fileName); |
- m_recentScripts.prepend(fileName); |
- } |
- rebuildRecentScriptsMenu(); |
- } |
- finishScriptRun(); |
-} |
- |
-void ScripterCore::StdScript(const QString& baseFilename) |
-{ |
- QString pfad = ScPaths::instance().scriptDir(); |
- QString pfad2; |
- pfad2 = QDir::toNativeSeparators(pfad); |
- QString fn = pfad2+baseFilename+".py"; |
- QFileInfo fd(fn); |
- if (!fd.exists()) |
- return; |
- slotRunScriptFile(fn); |
- finishScriptRun(); |
-} |
- |
-void ScripterCore::RecentScript(const QString& fn) |
-{ |
- QFileInfo fd(fn); |
- if (!fd.exists()) |
- { |
- m_recentScripts.removeAll(fn); |
- rebuildRecentScriptsMenu(); |
- return; |
- } |
- slotRunScriptFile(fn); |
- finishScriptRun(); |
-} |
- |
-void ScripterCore::slotRunScriptFile(const QString& fileName, bool inMainInterpreter) |
-{ |
- slotRunScriptFile(fileName, QStringList(), inMainInterpreter); |
-} |
- |
-void ScripterCore::slotRunScriptFile(const QString& fileName, QStringList arguments, bool inMainInterpreter) |
-/** run "filename" python script with the additional arguments provided in "arguments" */ |
-{ |
- // Prevent two scripts to be run concurrently or face crash! |
- if (ScCore->primaryMainWindow()->scriptIsRunning()) |
- return; |
- disableMainWindowMenu(); |
- |
- PyThreadState *state = nullptr; |
- QFileInfo fi(fileName); |
- QByteArray na = fi.fileName().toLocal8Bit(); |
- // Set up a sub-interpreter if needed: |
- PyThreadState* global_state = nullptr; |
- if (!inMainInterpreter) |
- { |
- ScCore->primaryMainWindow()->propertiesPalette->unsetDoc(); |
- ScCore->primaryMainWindow()->contentPalette->unsetDoc(); |
- ScCore->primaryMainWindow()->pagePalette->setView(nullptr); |
- ScCore->primaryMainWindow()->setScriptRunning(true); |
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); |
- // Create the sub-interpreter |
- // FIXME: This calls abort() in a Python debug build. We're doing something wrong. |
- //stateo = PyEval_SaveThread(); |
- global_state = PyThreadState_Get(); |
- state = Py_NewInterpreter(); |
- // Init the scripter module in the sub-interpreter |
- initscribus(ScCore->primaryMainWindow()); |
- } |
- |
- // Make sure sys.argv[0] is the path to the script |
- arguments.prepend(na.data()); |
- //convert arguments (QListString) to char** for Python bridge |
- /* typically arguments == ['path/to/script.py','--argument1','valueforarg1','--flag']*/ |
- char **comm = new char*[arguments.size()]; |
- for (int i = 0; i < arguments.size(); i++) |
- { |
- QByteArray localStr = arguments.at(i).toLocal8Bit(); |
- comm[i] = new char[localStr.size() + 1]; //+1 to allow adding '\0'. may be useless, don't know how to check. |
- comm[i][localStr.size()] = 0; |
- strncpy(comm[i], localStr.data(), localStr.size()); |
- } |
- PySys_SetArgv(arguments.size(), comm); |
- |
- for (int i = 0; i < arguments.size(); i++) |
- delete[] comm[i]; |
- delete[] comm; |
- |
- // call python script |
- PyObject* m = PyImport_AddModule((char*)"__main__"); |
- if (m == nullptr) |
- qDebug("Failed to get __main__ - aborting script"); |
- else |
- { |
- // Path separators need to be escaped on Windows |
- QString escapedAbsPath = QDir::toNativeSeparators(fi.absolutePath()).replace("\\", "\\\\"); |
- QString escapedAbsFilePath = QDir::toNativeSeparators(fi.absoluteFilePath()).replace("\\", "\\\\"); |
- QString escapedFileName = QDir::toNativeSeparators(fileName).replace("\\", "\\\\"); |
- // FIXME: If filename contains chars outside 7bit ascii, might be problems |
- PyObject* globals = PyModule_GetDict(m); |
- // Build the Python code to run the script |
- //QString cm = QString("from __future__ import division\n"); removed due #5252 PV |
- QString cm = QString("import sys\n"); |
- cm += QString("import cStringIO\n"); |
- /* Implementation of the help() in pydoc.py reads some OS variables |
- * for output settings. I use ugly hack to stop freezing calling help() |
- * in script. pv. */ |
- cm += QString("import os\nos.environ['PAGER'] = '/bin/false'\n"); // HACK |
- cm += QString("sys.path[0] = \"%1\"\n").arg(escapedAbsPath); |
- // Replace sys.stdin with a dummy StringIO that always returns |
- // "" for read |
- cm += QString("sys.stdin = cStringIO.StringIO()\n"); |
- // Provide script path to the interpreter |
- cm += QString("__file__ = \"%1\"\n").arg(escapedAbsFilePath); |
- // tell the script if it's running in the main interpreter or a subinterpreter |
- cm += QString("import scribus\n"); |
- if (inMainInterpreter) |
- cm+= QString("scribus.mainInterpreter = True\n"); |
- else |
- cm+= QString("scribus.mainInterpreter = False\n"); |
- cm += QString("try:\n"); |
- cm += QString(" execfile(\"%1\")\n").arg(escapedFileName); |
- cm += QString("except SystemExit:\n"); |
- cm += QString(" pass\n"); |
- // Capture the text of any other exception that's raised by the interpreter |
- // into a StringIO buffer for later extraction. |
- cm += QString("except:\n"); |
- cm += QString(" import traceback\n"); |
- cm += QString(" _errorMsg = traceback.format_exc()\n"); |
- if (!ScCore->usingGUI()) |
- cm += QString(" traceback.print_exc()\n"); |
- // We re-raise the exception so the return value of PyRun_StringFlags reflects |
- // the fact that an exception has occurred. |
- cm += QString(" raise\n"); |
- // FIXME: if cmd contains chars outside 7bit ascii, might be problems |
- QByteArray cmd = cm.toUtf8(); |
- // Now run the script in the interpreter's global scope. It'll run in a |
- // sub-interpreter if we created and switched to one earlier, otherwise |
- // it'll run in the main interpreter. |
- PyObject* result = PyRun_String(cmd.data(), Py_file_input, globals, globals); |
- // nullptr is returned if an exception is set. We don't care about any |
- // other return value (most likely None anyway) and can ignore it. |
- if (result == nullptr) |
- { |
- PyObject* errorMsgPyStr = PyMapping_GetItemString(globals, (char*)"_errorMsg"); |
- if (errorMsgPyStr == nullptr) |
- { |
- // It's rather unlikely that this will ever be reached - to get here |
- // we'd have to fail to retrieve the string we just created. |
- qDebug("Error retrieving error message content after script exception!"); |
- qDebug("Exception was:"); |
- PyErr_Print(); |
- } |
- else if (ScCore->usingGUI()) |
- { |
- QString errorMsg = PyString_AsString(errorMsgPyStr); |
- // Display a dialog to the user with the exception |
- QClipboard *cp = QApplication::clipboard(); |
- cp->setText(errorMsg); |
- ScCore->closeSplash(); |
- qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); |
- ScMessageBox::warning(ScCore->primaryMainWindow(), |
- tr("Script error"), |
- "<qt><p>" |
- + tr("If you are running an official script report it at <a href=\"http://bugs.scribus.net\">bugs.scribus.net</a> please.") |
- + "</p><pre>" + errorMsg.toHtmlEscaped() + "</pre><p>" |
- + tr("This message is in your clipboard too. Use Ctrl+V to paste it into bug tracker.") |
- + "</p></qt>"); |
- } |
- // We've already processed the exception text, so clear the exception |
- PyErr_Clear(); |
- } // end if result == nullptr |
- // Because 'result' may be nullptr, not a PyObject*, we must call PyXDECREF not Py_DECREF |
- Py_XDECREF(result); |
- } // end if m == nullptr |
- if (!inMainInterpreter) |
- { |
- Py_EndInterpreter(state); |
- PyThreadState_Swap(global_state); |
- //PyEval_RestoreThread(stateo); |
- qApp->restoreOverrideCursor(); |
- ScCore->primaryMainWindow()->setScriptRunning(false); |
- } |
- |
- enableMainWindowMenu(); |
-} |
- |
-// needed for running script from CLI |
-void ScripterCore::slotRunPythonScript() |
-{ |
- if (!ScQApp->pythonScript.isNull()) |
- { |
- slotRunScriptFile(ScQApp->pythonScript, ScQApp->pythonScriptArgs, true); |
- finishScriptRun(); |
- } |
-} |
- |
-void ScripterCore::slotRunScript(const QString& Script) |
-{ |
- // Prevent two scripts to be run concurrently or face crash! |
- if (ScCore->primaryMainWindow()->scriptIsRunning()) |
- return; |
- disableMainWindowMenu(); |
- |
- ScCore->primaryMainWindow()->propertiesPalette->unsetDoc(); |
- ScCore->primaryMainWindow()->contentPalette->unsetDoc(); |
- ScCore->primaryMainWindow()->pagePalette->setView(nullptr); |
- ScCore->primaryMainWindow()->setScriptRunning(true); |
- inValue = Script; |
- QString cm; |
- cm = "# -*- coding: utf8 -*- \n"; |
- if (PyThreadState_Get() != nullptr) |
- { |
- initscribus(ScCore->primaryMainWindow()); |
- /* HACK: following loop handles all input line by line. |
- It *should* use I.C. because of docstrings etc. I.I. cannot |
- handle docstrings right. |
- Calling all code in one command: |
- ia = code.InteractiveInterpreter() ia.runsource(getval()) |
- works fine in plain Python. Not here. WTF? */ |
- cm += ( |
- "try:\n" |
- " import cStringIO\n" |
- " scribus._bu = cStringIO.StringIO()\n" |
- " sys.stdout = scribus._bu\n" |
- " sys.stderr = scribus._bu\n" |
- " sys.argv = ['scribus']\n" // this is the PySys_SetArgv replacement |
- " scribus.mainInterpreter = True\n" // the scripter console runs everything in the main interpreter |
- " for scribus._i_str in scribus.getval().splitlines():\n" |
- " scribus._ia.push(scribus._i_str)\n" |
- " scribus.retval(scribus._bu.getvalue())\n" |
- " sys.stdout = sys.__stdout__\n" |
- " sys.stderr = sys.__stderr__\n" |
- "except SystemExit:\n" |
- " print 'Catched SystemExit - it is not good for Scribus'\n" |
- "except KeyboardInterrupt:\n" |
- " print 'Catched KeyboardInterrupt - it is not good for Scribus'\n" |
- ); |
- } |
- // Set up sys.argv |
- /* PV - WARNING: THIS IS EVIL! This code summons a crash - see |
- bug #3510. I don't know why as the Python C API is a little |
- bit magic for me. It looks like it replaces the cm QString or what... |
- "In file tools/qgarray.cpp, line 147: Out of memory" |
- Anyway - sys.argv is set above |
- char* comm[1]; |
- comm[0] = const_cast<char*>("scribus"); |
- PySys_SetArgv(1, comm); */ |
- // then run the code |
- PyObject* m = PyImport_AddModule((char*)"__main__"); |
- if (m == nullptr) |
- qDebug("Failed to get __main__ - aborting script"); |
- else |
- { |
- PyObject* globals = PyModule_GetDict(m); |
- PyObject* result = PyRun_String(cm.toUtf8().data(), Py_file_input, globals, globals); |
- if (result == nullptr) |
- { |
- PyErr_Print(); |
- ScMessageBox::warning(ScCore->primaryMainWindow(), tr("Script error"), |
- "<qt>" + tr("There was an internal error while trying the " |
- "command you entered. Details were printed to " |
- "stderr. ") + "</qt>"); |
- } |
- else |
- // Because 'result' may be nullptr, not a PyObject*, we must call PyXDECREF not Py_DECREF |
- Py_XDECREF(result); |
- } |
- ScCore->primaryMainWindow()->setScriptRunning(false); |
- |
- enableMainWindowMenu(); |
-} |
- |
-void ScripterCore::slotInteractiveScript(bool visible) |
-{ |
- QObject::disconnect( m_scripterActions["scripterShowConsole"], SIGNAL(toggled(bool)) , this, SLOT(slotInteractiveScript(bool)) ); |
- |
- m_scripterActions["scripterShowConsole"]->setChecked(visible); |
- m_pyConsole->setFonts(); |
- m_pyConsole->setVisible(visible); |
- |
- QObject::connect( m_scripterActions["scripterShowConsole"], SIGNAL(toggled(bool)) , this, SLOT(slotInteractiveScript(bool)) ); |
-} |
- |
-void ScripterCore::slotExecute() |
-{ |
- slotRunScript(m_pyConsole->command()); |
- m_pyConsole->outputEdit->append(returnString); |
- m_pyConsole->commandEdit->ensureCursorVisible(); |
- finishScriptRun(); |
-} |
- |
-void ScripterCore::readPlugPrefs() |
-{ |
- PrefsContext* prefs = PrefsManager::instance().prefsFile->getPluginContext("scriptplugin"); |
- if (!prefs) |
- { |
- qDebug("scriptplugin: Unable to load prefs"); |
- return; |
- } |
- PrefsTable* prefRecentScripts = prefs->getTable("recentscripts"); |
- if (!prefRecentScripts) |
- { |
- qDebug("scriptplugin: Unable to get recent scripts"); |
- return; |
- } |
- // Load recent scripts from the prefs |
- for (int i = 0; i < prefRecentScripts->getRowCount(); i++) |
- { |
- QString rs(prefRecentScripts->get(i,0)); |
- m_savedRecentScripts.append(rs); |
- } |
- // then get more general preferences |
- m_enableExtPython = prefs->getBool("extensionscripts",false); |
- m_importAllNames = prefs->getBool("importall",true); |
- m_startupScript = prefs->get("startupscript", QString()); |
- // and have the console window set up its position |
-} |
- |
-void ScripterCore::savePlugPrefs() |
-{ |
- PrefsContext* prefs = PrefsManager::instance().prefsFile->getPluginContext("scriptplugin"); |
- if (!prefs) |
- { |
- qDebug("scriptplugin: Unable to load prefs"); |
- return; |
- } |
- PrefsTable* prefRecentScripts = prefs->getTable("recentscripts"); |
- if (!prefRecentScripts) |
- { |
- qDebug("scriptplugin: Unable to get recent scripts"); |
- return; |
- } |
- for (int i = 0; i < m_recentScripts.count(); i++) |
- { |
- prefRecentScripts->set(i, 0, m_recentScripts[i]); |
- } |
- // then save more general preferences |
- prefs->set("extensionscripts", m_enableExtPython); |
- prefs->set("importall", m_importAllNames); |
- prefs->set("startupscript", m_startupScript); |
-} |
- |
-void ScripterCore::aboutScript() |
-{ |
- QString fname = ScCore->primaryMainWindow()->CFileDialog(".", tr("Examine Script"), tr("Python Scripts (*.py *.PY);;All Files (*)"), "", fdNone); |
- if (fname.isNull()) |
- return; |
- QString html("<html><body>"); |
- QFileInfo fi = QFileInfo(fname); |
- QFile input(fname); |
- if (!input.open(QIODevice::ReadOnly)) |
- return; |
- QTextStream intputstream(&input); |
- QString content = intputstream.readAll(); |
- QString docstring = content.section(R"(""")", 1, 1); |
- if (!docstring.isEmpty()) |
- { |
- html += QString("<h1>%1 %2</h1>").arg( tr("Documentation for:"), fi.fileName()); |
- html += QString("<p>%1</p>").arg(docstring.replace("\n\n", "<br><br>")); |
- } |
- else |
- { |
- html += QString("<p><b>%1 %2 %3</b></p>").arg( tr("Script"), fi.fileName(), tr(" doesn't contain any docstring!")); |
- html += QString("<pre>%4</pre>").arg(content); |
- } |
- html += "</body></html>"; |
- input.close(); |
- HelpBrowser *dia = new HelpBrowser(nullptr, QObject::tr("About Script") + " " + fi.fileName(), "en"); |
- dia->setHtml(html); |
- dia->show(); |
-} |
- |
-void ScripterCore::initExtensionScripts() |
-{ |
- // Nothing to do currently |
-} |
- |
-void ScripterCore::runStartupScript() |
-{ |
- if ((m_enableExtPython) && (!m_startupScript.isEmpty())) |
- { |
- if (QFile::exists(this->m_startupScript)) |
- { |
- // run the script in the main interpreter. The user will be informed |
- // with a dialog if something has gone wrong. |
- this->slotRunScriptFile(this->m_startupScript, true); |
- } |
- else |
- ScMessageBox::warning(ScCore->primaryMainWindow(), tr("Startup Script error"), |
- tr("Could not find script: %1.").arg( m_startupScript)); |
- } |
-} |
- |
-void ScripterCore::languageChange() |
-{ |
- m_scripterActions["scripterExecuteScript"]->setText(QObject::tr("&Execute Script...")); |
- m_scripterActions["scripterShowConsole"]->setText(QObject::tr("Show &Console")); |
- m_scripterActions["scripterAboutScript"]->setText(QObject::tr("&About Script...")); |
- |
- m_menuMgr->setText("Scripter", QObject::tr("&Script")); |
- m_menuMgr->setText("ScribusScripts", QObject::tr("&Scribus Scripts")); |
- m_menuMgr->setText("RecentScripts", QObject::tr("&Recent Scripts")); |
-} |
- |
-bool ScripterCore::setupMainInterpreter() |
-{ |
- QString cm = QString( |
- "# -*- coding: utf-8 -*-\n" |
- "import scribus\n" |
- "import sys\n" |
- "import code\n" |
- "sys.path.insert(0, \"%1\")\n" |
- "import cStringIO\n" |
- "sys.stdin = cStringIO.StringIO()\n" |
- "scribus._ia = code.InteractiveConsole(globals())\n" |
- ).arg(ScPaths::instance().scriptDir()); |
- if (m_importAllNames) |
- cm += "from scribus import *\n"; |
- QByteArray cmd = cm.toUtf8(); |
- if (PyRun_SimpleString(cmd.data())) |
- { |
- PyErr_Print(); |
- ScMessageBox::warning(ScCore->primaryMainWindow(), tr("Script error"), |
- tr("Setting up the Python plugin failed. " |
- "Error details were printed to stderr. ")); |
- return false; |
- } |
- return true; |
-} |
- |
-void ScripterCore::setStartupScript(const QString& newScript) |
-{ |
- m_startupScript = newScript; |
-} |
- |
-void ScripterCore::setExtensionsEnabled(bool enable) |
-{ |
- m_enableExtPython = enable; |
-} |
- |
-void ScripterCore::updateSyntaxHighlighter() |
-{ |
- m_pyConsole->updateSyntaxHighlighter(); |
-} |
- |
-const QString & ScripterCore::startupScript() const |
-{ |
- return m_startupScript; |
-} |
- |
-bool ScripterCore::extensionsEnabled() const |
-{ |
- return m_enableExtPython; |
-} |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptercore.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp (nonexistent) |
@@ -1,1740 +0,0 @@ |
-/* |
-For general Scribus (>=1.3.2) copyright and licensing information please refer |
-to the COPYING file provided with the program. Following this notice may exist |
-a copyright and/or license notice that predates the release of Scribus 1.3.2 |
-for which a new license (GPL+exception) is in place. |
-*/ |
-#include "objpdffile.h" |
-#include "colormgmt/sccolormgmtengine.h" |
-#include "cmdutil.h" |
-#include "prefsmanager.h" |
-#include "scribusdoc.h" |
-#include "scribuscore.h" |
-#include "scribusview.h" |
-#include <structmember.h> |
-#include "ui/bookmarkpalette.h" |
- |
-#include <QFileInfo> |
-#include <QImage> |
-#include <QList> |
-#include <vector> |
- |
-// these functions are located at utils.cpp |
-void SCRIBUS_API ReOrderText(ScribusDoc *doc, ScribusView *view); |
-// end of utils.cpp |
-//this is in file scribus.cpp |
- |
- |
-static int minmaxi(int val, int min, int max) |
-{ |
- if (val < min) |
- return min; |
- if (val > max) |
- return max; |
- return val; |
-} |
- |
-static double minmaxd(double val, double min, double max) |
-{ |
- if (val < min) |
- return min; |
- if (val > max) |
- return max; |
- return val; |
-} |
- |
-typedef struct |
-{ |
- PyObject_HEAD |
- PyObject *file; // string - file to save into |
- PyObject *fontEmbedding; // int - 0: Embed fonts, 1:Outline fonts, 2:Dont embed any font |
- PyObject *fonts; // list of string - fonts to embed |
- PyObject *subsetList; // list of string - fonts to outline |
- PyObject *pages; // list of int - pages to print |
- int thumbnails; // bool - |
- int cropMarks; // bool - |
- int bleedMarks; // bool - |
- int registrationMarks; // bool - |
- int colorMarks; // bool - |
- int docInfoMarks; // bool - |
- double markOffset; // double - |
- double markLength; // double - |
- int compress; // bool - |
- int compressmtd; // int - 0=automatic 1=jpeg 2=zip 3=none |
- int quality; // int - 0=Maximum 4=minimum |
- PyObject *resolution; // int - 35 - 4000 default=300 dpi |
- PyObject *downsample; // int - 35 - 4000 default=0 do not downsample ; other downsample to this resolution |
- int bookmarks; // bool - |
- int binding; // bool - 0 -left margin 1 -right margin |
- int presentation; // bool - |
- PyObject *effval; // list of list of 5 int - effect to apply to each page during presentation |
- int article; // bool - |
- int encrypt; // bool - |
- int uselpi; // bool - |
- int usespot; |
- int domulti; |
- PyObject *lpival; // list of elements which has structure [siii] |
- PyObject *owner; // string - owner's password |
- PyObject *user; // string - user's password |
- int allowPrinting; // bool - allow printing |
- int allowChange; // bool - allow changing |
- int allowCopy; // bool - allow copying |
- int allowAnnots; // bool - allow adding annotation and fields |
- int version; // int - version of pdf (12=1.2; 13=1.3; 14=1.4; 15=1.5) |
- int outdst; // int - output destination 0 - screen, 1 - printer |
- |
- int profiles; // bool |
- int profilei; // bool |
- int intents; // int - 0 - 3 QString tmp_ip[] = { tr("Perceptual"), tr("Relative Colorimetric"), tr("Saturation"), tr("Absolute Colorimetric")}; |
- int intenti; // int - 0 - 3 QString tmp_ip[] = { tr("Perceptual"), tr("Relative Colorimetric"), tr("Saturation"), tr("Absolute Colorimetric")}; |
- int noembicc; // bool - "Don't use embedded ICC profiles" |
- PyObject *solidpr; // string |
- PyObject *imagepr; // string |
- PyObject *printprofc; // string |
- PyObject *info; // string |
- double bleedt; // double - 0 to height of page |
- double bleedl; // double - 0 to width of page |
- double bleedr; // double - 0 to width of page |
- double bleedb; // double - 0 to height of page |
- int useDocBleeds; // bool |
- int useLayers; |
- int embedPDF; |
- int mirrorH; |
- int mirrorV; |
- int doClip; |
- PyObject * rotateDeg; // int |
- int isGrayscale; |
- int pageLayout; |
- int displayBookmarks; |
- int displayThumbs; |
- int displayLayers; |
- int displayFullscreen; |
- int hideToolBar; |
- int hideMenuBar; |
- int fitWindow; |
- PyObject *openAction; |
- |
-} PDFfile; |
- |
-static void PDFfile_dealloc(PDFfile *self) |
-{ |
- Py_XDECREF(self->file); |
- Py_XDECREF(self->fontEmbedding); |
- Py_XDECREF(self->fonts); |
- Py_XDECREF(self->subsetList); |
- Py_XDECREF(self->pages); |
- Py_XDECREF(self->resolution); |
- Py_XDECREF(self->downsample); |
- Py_XDECREF(self->effval); |
- Py_XDECREF(self->lpival); |
- Py_XDECREF(self->owner); |
- Py_XDECREF(self->user); |
- Py_XDECREF(self->solidpr); |
- Py_XDECREF(self->imagepr); |
- Py_XDECREF(self->printprofc); |
- Py_XDECREF(self->info); |
- Py_XDECREF(self->rotateDeg); |
- Py_XDECREF(self->openAction); |
- self->ob_type->tp_free((PyObject *)self); |
-} |
- |
-static PyObject * PDFfile_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) |
-{ |
- // Do not create new object if there is no opened document |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- PDFfile *self; |
- |
- self = (PDFfile *)type->tp_alloc(type, 0); |
- if (self) |
- { |
- // Set file attribute |
- self->file = PyString_FromString(""); |
- if (!self->file) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set font embedding mode attribute |
- self->fontEmbedding = PyInt_FromLong(0); |
- if (!self->fontEmbedding) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set fonts attribute |
- self->fonts = PyList_New(0); |
- if (!self->fonts) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- self->subsetList = PyList_New(0); |
- if (!self->subsetList) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set pages attribute |
- self->pages = PyList_New(0); |
- if (self->pages == nullptr) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set thumbnails attribute |
- self->thumbnails = 0; |
- // Set cropMarks attribute |
- self->cropMarks = 0; |
- // Set bleedMarks attribute |
- self->bleedMarks = 0; |
- // Set registrationMarks attribute |
- self->registrationMarks = 0; |
- // Set colorMarks attribute |
- self->colorMarks = 0; |
- // Set docInfoMarks attribute |
- self->docInfoMarks = 0; |
- // Set mark offset attribute |
- self->markOffset = 0; |
- // Set mark length attribute |
- self->markLength = 0; |
- // Set compress attribute |
- self->compress = 0; |
- // Set compressmtd attribute |
- self->compressmtd = 0; |
- // Set quality attribute |
- self->quality = 0; |
- // Set resolution attribute |
- self->resolution = PyInt_FromLong(300); |
- if (!self->resolution) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set downsample attribute |
- self->downsample = PyInt_FromLong(0); |
- if (!self->downsample) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set bookmarks attribute |
- self->bookmarks = 0; |
- // Set binding attribute |
- self->binding = 0; |
- // Set presentation attribute |
- self->presentation = 0; |
- // Set effval attribute |
- self->effval = PyList_New(0); |
- if (!self->effval) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set article attribute |
- self->article = 0; |
- // Set encrypt attribute |
- self->encrypt = 0; |
- // Set uselpi attribute |
- self->uselpi = 0; |
- self->usespot = 1; |
- self->domulti = 0; |
- // Set lpival attribute |
- self->lpival = PyList_New(0); |
- if (!self->lpival) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set owner attribute |
- self->owner = PyString_FromString(""); |
- if (!self->owner) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set user attribute |
- self->user = PyString_FromString(""); |
- if (!self->user) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- // Set allowPrinting attribute |
- self->allowPrinting = 1; |
- // Set allowChange attribute |
- self->allowChange = 1; |
- // Set allowCopy attribute |
- self->allowCopy = 1; |
- // Set allowAnnots attribute |
- self->allowAnnots = 1; |
- // Set version attribute |
- self->version = 14; |
- // Set output attribute |
- self->outdst = 0; |
- |
- self->profiles = 0; // bool |
- self->profilei = 0; // bool |
- self->intents = 0; // int - 0 - ? |
- self->intenti = 0; // int - 0 - ? |
- self->noembicc = 0; // bool |
- self->solidpr = PyString_FromString(""); |
- if (!self->solidpr) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- self->imagepr = PyString_FromString(""); |
- if (!self->imagepr) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- self->printprofc = PyString_FromString(""); |
- if (!self->printprofc) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- self->info = PyString_FromString(""); |
- if (!self->info) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- self->bleedt = 0; // double - |
- self->bleedl = 0; // double - |
- self->bleedr = 0; // double - |
- self->bleedb = 0; // double - |
- self->useDocBleeds = 1; // bool |
- self->useLayers = 0; |
- self->embedPDF = 0; |
- self->mirrorH = 0; |
- self->mirrorV = 0; |
- self->doClip = 0; |
- self->rotateDeg = PyInt_FromLong(0); |
- if (!self->rotateDeg) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- self->isGrayscale = 0; |
- self->pageLayout = 0; |
- self->displayBookmarks = 0; |
- self->displayThumbs = 0; |
- self->displayLayers = 0; |
- self->displayFullscreen = 0; |
- self->hideToolBar = 0; |
- self->hideMenuBar = 0; |
- self->fitWindow = 0; |
- self->openAction = PyString_FromString(""); |
- if (!self->openAction) |
- { |
- Py_DECREF(self); |
- return nullptr; |
- } |
- } |
- return (PyObject *) self; |
-} |
- |
-static int PDFfile_init(PDFfile *self, PyObject * /*args*/, PyObject * /*kwds*/) |
-{ |
- int i; |
- if (!checkHaveDocument()) |
- return -1; |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- PDFOptions& pdfOptions = currentDoc->pdfOptions(); |
- |
- // Default save into file |
- QString tf = pdfOptions.fileName; |
- if (tf.isEmpty()) |
- { |
- QFileInfo fi = QFileInfo(currentDoc->documentFileName()); |
- tf = fi.path() + "/" + fi.baseName() + ".pdf"; |
- } |
- |
- PyObject *file = PyString_FromString(tf.toLatin1()); |
- if (file) |
- { |
- Py_DECREF(self->file); |
- self->file = file; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'file' attribute"); |
- return -1; |
- } |
- |
- // Font embedding mode |
- PyObject *embeddingMode = PyInt_FromLong(pdfOptions.FontEmbedding); |
- if (embeddingMode) |
- { |
- Py_DECREF(self->fontEmbedding); |
- self->fontEmbedding = embeddingMode; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'fontEmbedding' attribute"); |
- return -1; |
- } |
- |
- // Embed all used fonts |
- PyObject *fonts = PyList_New(0); |
- if (fonts) |
- { |
- Py_DECREF(self->fonts); |
- self->fonts = fonts; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'fonts' attribute"); |
- return -1; |
- } |
- |
- // Get all used fonts |
- QMap<QString,int> ReallyUsed = currentDoc->UsedFonts; |
- // Create list of all used fonts |
- QList<QString> tmpEm = ReallyUsed.keys(); |
- for (int i = 0; i < tmpEm.count(); ++i) |
- { |
- const QString& fontName = tmpEm.at(i); |
- PyObject *tmp = PyString_FromString(fontName.toLatin1()); |
- if (tmp) |
- { |
- PyList_Append(self->fonts, tmp); |
- // Do i need Py_DECREF(tmp) here? |
- // Does PyList_Append increase reference or 'steal' one from provided argument |
- // If it 'steal' reference comment next line |
- Py_DECREF(tmp); |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'fonts' attribute"); |
- return -1; |
- } |
- } |
- |
- // Init subsetList |
- fonts = PyList_New(0); |
- if (fonts) |
- { |
- Py_DECREF(self->subsetList); |
- self->subsetList = fonts; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'subsetList' attribute"); |
- return -1; |
- } |
- |
- // Copied from TabPDFOptions::restoreDefaults() |
- for (int fe = 0; fe < pdfOptions.SubsetList.count(); ++fe) |
- { |
- PyObject *tmp= nullptr; |
- tmp = PyString_FromString(pdfOptions.SubsetList[fe].toLatin1().data()); |
- if (tmp) |
- { |
- PyList_Append(self->subsetList, tmp); |
- Py_DECREF(tmp); |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'subsetList' attribute"); |
- return -1; |
- } |
- } |
- |
- // Set to print all pages |
- int num = currentDoc->Pages->count(); |
- PyObject *pages = PyList_New(num); |
- if (!pages) |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'pages' attribute"); |
- return -1; |
- } |
- for (i = 0; i < num; ++i) |
- { |
- PyObject *tmp = PyInt_FromLong((long)i + 1L); |
- if (tmp) |
- PyList_SetItem(pages, i, tmp); |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'pages' attribute"); |
- return -1; |
- } |
- } |
- Py_DECREF(self->pages); |
- self->pages = pages; |
- // Print thumbnails ? |
- self->thumbnails = pdfOptions.Thumbnails; |
- // Output crop marks ? |
- self->cropMarks = pdfOptions.cropMarks; |
- // Output bleed marks ? |
- self->bleedMarks = pdfOptions.bleedMarks; |
- // Output registration marks ? |
- self->registrationMarks = pdfOptions.registrationMarks; |
- // Output color bars ? |
- self->colorMarks = pdfOptions.colorMarks; |
- // Output doc info marks ? |
- self->docInfoMarks = pdfOptions.docInfoMarks; |
- // Cropmarks offset |
- self->markOffset = pdfOptions.markOffset * currentDoc->unitRatio(); |
- // Cropmarks length |
- self->markLength = pdfOptions.markLength * currentDoc->unitRatio(); |
- // Set automatic compression |
- self->compress = pdfOptions.Compress; |
- self->compressmtd = pdfOptions.CompressMethod; |
- // Use maximum image quality |
- self->quality = pdfOptions.Quality; |
- // Default resolution |
- PyObject *resolution = nullptr; |
- resolution = PyInt_FromLong(300); |
- if (resolution) |
- { |
- Py_DECREF(self->resolution); |
- self->resolution = resolution; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'resolution' attribute"); |
- return -1; |
- } |
- // Do not downsample images |
- int down = pdfOptions.RecalcPic ? pdfOptions.PicRes : 0; |
- PyObject *downsample = nullptr; |
- downsample = PyInt_FromLong(down); |
- if (downsample) |
- { |
- Py_DECREF(self->downsample); |
- self->downsample = downsample; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'downsamle' attribute"); |
- return -1; |
- } |
- // No bookmarks |
- self->bookmarks = pdfOptions.Bookmarks; |
- // Left margin binding |
- self->binding = pdfOptions.Binding; |
- // Do not enable presentation effects |
- self->presentation = pdfOptions.PresentMode; |
- // Set effects values for all pages |
- PyObject *effval = nullptr; |
- num = currentDoc->Pages->count(); |
- effval = PyList_New(num); |
- if (!effval) |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' attribute"); |
- return -1; |
- } |
- for (i = 0; i < num; ++i) |
- { |
- PyObject *tmp; |
- PDFPresentationData t = currentDoc->Pages->at(i)->PresentVals; |
- tmp = Py_BuildValue(const_cast<char*>("[iiiiii]"), t.pageEffectDuration, t.pageViewDuration, t.effectType, t.Dm, t.M, t.Di ); |
- if (tmp) |
- PyList_SetItem(effval, i, tmp); |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' attribute"); |
- return -1; |
- } |
- for (; i < num; ++i) |
- { |
- PyObject *tmp = Py_BuildValue(const_cast<char*>("[iiiiii]"), 1, 1, 0, 0, 0, 0); |
- if (tmp) |
- PyList_SetItem(effval, i, tmp); |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' attribute"); |
- return -1; |
- } |
- } |
- } |
- Py_DECREF(self->effval); |
- self->effval = effval; |
- // Do not save linked text frames as PDF article |
- self->article = pdfOptions.Articles; |
- // Do not encrypt file |
- self->encrypt = pdfOptions.Encrypt; |
- // Do not Use Custom Rendering Settings |
- self->uselpi = pdfOptions.UseLPI; |
- self->usespot = pdfOptions.UseSpotColors; |
- self->domulti = pdfOptions.doMultiFile; |
- // Get default values for lpival |
- int n = pdfOptions.LPISettings.size(); |
- PyObject *lpival=PyList_New(n); |
- if (!lpival) |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'lpival' attribute"); |
- return -1; |
- } |
- QMap<QString,LPIData>::Iterator it = pdfOptions.LPISettings.begin(); |
- while (it != pdfOptions.LPISettings.end()) |
- { |
- PyObject *tmp; |
- tmp = Py_BuildValue(const_cast<char*>("[siii]"), it.key().toLatin1().constData(), it.value().Frequency, it.value().Angle, it.value().SpotFunc); |
- if (!tmp) |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'lpival' attribute"); |
- return -1; |
- } |
- PyList_SetItem(lpival, --n, tmp); |
- ++it; |
- } |
- PyList_Reverse(lpival); |
- Py_DECREF(self->lpival); |
- self->lpival = lpival; |
- // Set owner's password |
- PyObject *owner = PyString_FromString(pdfOptions.PassOwner.toLatin1()); |
- if (owner) |
- { |
- Py_DECREF(self->owner); |
- self->owner = owner; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'owner' attribute"); |
- return -1; |
- } |
- // Set user'a password |
- PyObject *user = PyString_FromString(pdfOptions.PassUser.toLatin1()); |
- if (user) |
- { |
- Py_DECREF(self->user); |
- self->user = user; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'user' attribute"); |
- return -1; |
- } |
- // Allow printing document |
- self->allowPrinting = pdfOptions.Permissions & 4; |
- // Allow changing document |
- self->allowChange = pdfOptions.Permissions & 8; |
- // Allow copying document |
- self->allowCopy = pdfOptions.Permissions & 16; |
- // Allow adding annotation and fields |
- self->allowAnnots = pdfOptions.Permissions & 32; |
- // Use 1.4 pdf version *aka. Acrobat 5) |
- self->version = pdfOptions.Version; |
- // Output destination is screen |
- self->outdst = pdfOptions.UseRGB ? 0 : 1; |
- |
- self->profiles = pdfOptions.UseProfiles; // bool |
- self->profilei = pdfOptions.UseProfiles2; // bool |
- self->noembicc = pdfOptions.EmbeddedI; // bool |
- self->intents = pdfOptions.Intent; // int - 0 - 3 |
- self->intenti = pdfOptions.Intent2; // int - 0 - 3 |
- QString tp = pdfOptions.SolidProf; |
- if (!ScCore->InputProfiles.contains(tp)) |
- tp = currentDoc->cmsSettings().DefaultSolidColorRGBProfile; |
- PyObject *solidpr = PyString_FromString(tp.toLatin1()); |
- if (solidpr) |
- { |
- Py_DECREF(self->solidpr); |
- self->solidpr = solidpr; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'solidpr' attribute"); |
- return -1; |
- } |
- QString tp2 = pdfOptions.ImageProf; |
- if (!ScCore->InputProfiles.contains(tp2)) |
- tp2 = currentDoc->cmsSettings().DefaultSolidColorRGBProfile; |
- PyObject *imagepr = PyString_FromString(tp2.toLatin1()); |
- if (imagepr) |
- { |
- Py_DECREF(self->imagepr); |
- self->imagepr = imagepr; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'imagepr' attribute"); |
- return -1; |
- } |
- QString tp3 = pdfOptions.PrintProf; |
- if (!ScCore->PDFXProfiles.contains(tp3)) |
- tp3 = currentDoc->cmsSettings().DefaultPrinterProfile; |
- PyObject *printprofc = nullptr; |
- printprofc = PyString_FromString(tp3.toLatin1()); |
- if (printprofc) |
- { |
- Py_DECREF(self->printprofc); |
- self->printprofc = printprofc; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'printprofc' attribute"); |
- return -1; |
- } |
- QString tinfo = pdfOptions.Info; |
- PyObject *info = PyString_FromString(tinfo.toLatin1()); |
- if (info) |
- { |
- Py_DECREF(self->info); |
- self->info = info; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'info' attribute"); |
- return -1; |
- } |
- self->bleedt = pdfOptions.bleeds.top() * currentDoc->unitRatio(); // double - |
- self->bleedl = pdfOptions.bleeds.left() * currentDoc->unitRatio(); // double - |
- self->bleedr = pdfOptions.bleeds.right() * currentDoc->unitRatio(); // double - |
- self->bleedb = pdfOptions.bleeds.bottom() * currentDoc->unitRatio(); // double - |
- self->useDocBleeds = pdfOptions.useDocBleeds; // bool |
- self->useLayers = pdfOptions.useLayers; // bool |
- self->embedPDF = pdfOptions.embedPDF; // bool |
- self->mirrorH = pdfOptions.MirrorH; // bool |
- self->mirrorV = pdfOptions.MirrorV; // bool |
- self->doClip = pdfOptions.doClip; // bool |
- PyObject *rotateDeg = PyInt_FromLong(0); |
- if (rotateDeg) |
- { |
- Py_DECREF(self->rotateDeg); |
- self->rotateDeg = rotateDeg; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'rotateDeg' attribute"); |
- return -1; |
- } |
- self->isGrayscale = pdfOptions.isGrayscale; // bool |
- self->pageLayout = pdfOptions.PageLayout; // int |
- self->displayBookmarks = pdfOptions.displayBookmarks; // bool |
- self->displayThumbs = pdfOptions.displayThumbs; // bool |
- self->displayLayers = pdfOptions.displayLayers; // bool |
- self->displayFullscreen = pdfOptions.displayFullscreen; // bool |
- self->hideToolBar = pdfOptions.hideToolBar; // bool |
- self->hideMenuBar = pdfOptions.hideMenuBar; // bool |
- self->fitWindow = pdfOptions.fitWindow; // bool |
- |
- PyObject *openAction = PyString_FromString(pdfOptions.openAction.toLatin1().data()); |
- if (openAction) |
- { |
- Py_DECREF(self->openAction); |
- self->openAction = openAction; |
- } |
- else |
- { |
- PyErr_SetString(PyExc_SystemError, "Can not initialize 'openAction' attribute"); |
- return -1; |
- } |
- |
- return 0; |
-} |
- |
-static PyMemberDef PDFfile_members[] = { |
- {const_cast<char*>("thumbnails"), T_INT, offsetof(PDFfile, thumbnails), 0, const_cast<char*>("Generate thumbnails. Bool value.")}, |
- {const_cast<char*>("cropMarks"), T_INT, offsetof(PDFfile, cropMarks), 0, const_cast<char*>("Create crop marks in the PDF indicating where the paper should be cut or trimmed after printing.")}, |
- {const_cast<char*>("bleedMarks"), T_INT, offsetof(PDFfile, bleedMarks), 0, const_cast<char*>("Create marks delimiting the bleed area.")}, |
- {const_cast<char*>("registrationMarks"), T_INT, offsetof(PDFfile, registrationMarks), 0, const_cast<char*>("Add registration marks to each separation.")}, |
- {const_cast<char*>("colorMarks"), T_INT, offsetof(PDFfile, colorMarks), 0, const_cast<char*>("Add color calibration bars.")}, |
- {const_cast<char*>("docInfoMarks"), T_INT, offsetof(PDFfile, docInfoMarks), 0, const_cast<char*>("Add document information which includes the document title and page numbers.")}, |
- {const_cast<char*>("markOffset"), T_DOUBLE, offsetof(PDFfile, markOffset), 0, const_cast<char*>("Indicate the distance offset between mark and page area.")}, |
- {const_cast<char*>("markLength"), T_DOUBLE, offsetof(PDFfile, markLength), 0, const_cast<char*>("Indicate the length of crop and bleed marks.")}, |
- {const_cast<char*>("compress"), T_INT, offsetof(PDFfile, compress), 0, const_cast<char*>("Compression switch. Bool value.")}, |
- {const_cast<char*>("compressmtd"), T_INT, offsetof(PDFfile, compressmtd), 0, const_cast<char*>("Compression method.\n\t0 - Automatic\n\t1 - JPEG\n\t2 - zip\n\t3 - None.")}, |
- {const_cast<char*>("quality"), T_INT, offsetof(PDFfile, quality), 0, const_cast<char*>("Image quality\n\t0 - Maximum\n\t1 - High\n\t2 - Medium\n\t3 - Low\n\t4 - Minimum")}, |
- {const_cast<char*>("bookmarks"), T_INT, offsetof(PDFfile, bookmarks), 0, const_cast<char*>("Embed the bookmarks you created in your document.\nThese are useful for navigating long PDF documents.\nBool value")}, |
- {const_cast<char*>("binding"), T_INT, offsetof(PDFfile, binding), 0, const_cast<char*>("Choose binding.\n\t0 - Left binding\n\t1 - Right binding")}, |
- {const_cast<char*>("presentation"), T_INT, offsetof(PDFfile, presentation), 0, const_cast<char*>("Enable Presentation Effects.Bool value")}, |
- {const_cast<char*>("article"), T_INT, offsetof(PDFfile, article), 0, const_cast<char*>("Save Linked Text Frames as PDF Articles\n\tBool value")}, |
- {const_cast<char*>("encrypt"), T_INT, offsetof(PDFfile, encrypt), 0, const_cast<char*>("Use Encription. Bool value")}, |
- {const_cast<char*>("uselpi"), T_INT, offsetof(PDFfile, uselpi), 0, const_cast<char*>("Use Custom Rendering Settings. Bool value")}, |
- {const_cast<char*>("usespot"), T_INT, offsetof(PDFfile, usespot), 0, const_cast<char*>("Use Spot Colors. Bool value")}, |
- {const_cast<char*>("domulti"), T_INT, offsetof(PDFfile, domulti), 0, const_cast<char*>("Produce a PDF File for every Page. Bool value")}, |
- {const_cast<char*>("allowPrinting"), T_INT, offsetof(PDFfile, allowPrinting), 0, const_cast<char*>("Allow Printing the Document. Bool value")}, |
- {const_cast<char*>("allowChange"), T_INT, offsetof(PDFfile, allowChange), 0, const_cast<char*>("Allow Changing the Document. Bool value")}, |
- {const_cast<char*>("allowCopy"), T_INT, offsetof(PDFfile, allowCopy), 0, const_cast<char*>("Allow Copying Text and Graphics. Bool value")}, |
- {const_cast<char*>("allowAnnots"), T_INT, offsetof(PDFfile, allowAnnots), 0, const_cast<char*>("Allow Adding Annotations and Fields. Bool value")}, |
- {const_cast<char*>("version"), T_INT, offsetof(PDFfile, version), 0, const_cast<char*>("Choose PDF version to use:\n\t10 = PDF/X4\n\t11 = PDF/X1a\n\t12 = PDF/X-3\n\t13 = PDF 1.3 (Acrobat 4)\n\t14 = PDF 1.4 (Acrobat 5)\n\t15 = PDF 1.5 (Acrobat 6)")}, |
- {const_cast<char*>("outdst"), T_INT, offsetof(PDFfile, outdst), 0, const_cast<char*>("Output destination.\n\t0 - screen\n\t1 - printer")}, |
- {const_cast<char*>("profiles"), T_INT, offsetof(PDFfile, profiles), 0, const_cast<char*>("Embed a color profile for solid colors. Bool value.")}, |
- {const_cast<char*>("profilei"), T_INT, offsetof(PDFfile, profilei), 0, const_cast<char*>("Embed a color profile for images. Bool value.")}, |
- {const_cast<char*>("intents"), T_INT, offsetof(PDFfile, intents), 0, const_cast<char*>("Rendering intent for solid colors\n\t0 - Perceptual\n\t1 - Relative Colorimetric\n\t2 - Saturation\n\t3 - Absolute Colorimetric")}, |
- {const_cast<char*>("intenti"), T_INT, offsetof(PDFfile, intenti), 0, const_cast<char*>("Rendering intent for images\n\t0 - Perceptual\n\t1 - Relative Colorimetric\n\t2 - Saturation\n\t3 - Absolute Colorimetric")}, |
- {const_cast<char*>("noembicc"), T_INT, offsetof(PDFfile, noembicc), 0, const_cast<char*>("Don't use embedded ICC profiles. Bool value")}, |
- {const_cast<char*>("bleedt"), T_DOUBLE, offsetof(PDFfile, bleedt), 0, const_cast<char*>("Bleed Top\n""Distance for bleed from the top of the physical page")}, |
- {const_cast<char*>("bleedl"), T_DOUBLE, offsetof(PDFfile, bleedl), 0, const_cast<char*>("Bleed Left\n""Distance for bleed from the left of the physical page")}, |
- {const_cast<char*>("bleedr"), T_DOUBLE, offsetof(PDFfile, bleedr), 0, const_cast<char*>("Bleed Right\n""Distance for bleed from the right of the physical page")}, |
- {const_cast<char*>("bleedb"), T_DOUBLE, offsetof(PDFfile, bleedb), 0, const_cast<char*>("Bleed Bottom\n""Distance for bleed from the bottom of the physical page")}, |
- {const_cast<char*>("useDocBleeds"), T_INT, offsetof(PDFfile, useDocBleeds), 0, const_cast<char*>("Use the existing bleed settings from the document preferences. Bool value")}, |
- {const_cast<char*>("useLayers"), T_INT, offsetof(PDFfile, useLayers), 0, const_cast<char*>("Layers in your document are exported to the PDF. Only available if PDF 1.5 is chosen.")}, |
- {const_cast<char*>("embedPDF"), T_INT, offsetof(PDFfile, embedPDF), 0, const_cast<char*>("Export EPS and PDFs in image frames as embedded PDFs. This does *not* yet take care of colorspaces, so you should know what you are doing before setting this to 'true'.")}, |
- {const_cast<char*>("mirrorH"), T_INT, offsetof(PDFfile, mirrorH), 0, const_cast<char*>("Mirror Page(s) horizontally")}, |
- {const_cast<char*>("mirrorV"), T_INT, offsetof(PDFfile, mirrorV), 0, const_cast<char*>("Mirror Page(s) vertically")}, |
- {const_cast<char*>("doClip"), T_INT, offsetof(PDFfile, doClip), 0, const_cast<char*>("Do not show objects outside the margins in the exported file")}, |
- {const_cast<char*>("isGrayscale"), T_INT, offsetof(PDFfile, isGrayscale), 0, const_cast<char*>("Export PDF in grayscale")}, |
- {const_cast<char*>("pageLayout"), T_INT, offsetof(PDFfile, pageLayout), 0, const_cast<char*>("Document layout in PDF viewer:\n" |
- "\t0 - Show the document in single page mode\n" |
- "\t1 - Show the document in single page mode with the pages displayed continuously end to end like a scroll\n" |
- "\t2 - Show the document with facing pages, starting with the first page displayed on the left\n" |
- "\t3 - Show the document with facing pages, starting with the first page displayed on the right" |
- )}, |
- {const_cast<char*>("displayBookmarks"), T_INT, offsetof(PDFfile, displayBookmarks), 0, const_cast<char*>("Display the bookmarks upon opening")}, |
- {const_cast<char*>("displayThumbs"), T_INT, offsetof(PDFfile, displayThumbs), 0, const_cast<char*>("Display the page thumbnails upon opening")}, |
- {const_cast<char*>("displayLayers"), T_INT, offsetof(PDFfile, displayLayers), 0, const_cast<char*>("Display the layer list upon opening. Useful only for PDF 1.5+.")}, |
- {const_cast<char*>("displayFullscreen"), T_INT, offsetof(PDFfile, displayFullscreen), 0, const_cast<char*>("Display the document in full screen mode upon opening.")}, |
- {const_cast<char*>("hideToolBar"), T_INT, offsetof(PDFfile, hideToolBar), 0, const_cast<char*>("Hide the viewer toolbar. The toolbar has usually selection and other editing capabilities.")}, |
- {const_cast<char*>("hideMenuBar"), T_INT, offsetof(PDFfile, hideMenuBar), 0, const_cast<char*>("Hide the viewer menu bar, the PDF will display in a plain window.")}, |
- {const_cast<char*>("fitWindow"), T_INT, offsetof(PDFfile, fitWindow), 0, const_cast<char*>("Fit the document page or pages to the available space in the viewer window.")}, |
- /** Deprecated members */ |
- {const_cast<char*>("aprint"), T_INT, offsetof(PDFfile, allowPrinting), 0, const_cast<char*>("Deprecated. Use 'allowPrinting' instead.")}, |
- {const_cast<char*>("achange"), T_INT, offsetof(PDFfile, allowChange), 0, const_cast<char*>("Deprecated. Use 'allowChange' instead.")}, |
- {const_cast<char*>("acopy"), T_INT, offsetof(PDFfile, allowCopy), 0, const_cast<char*>("Deprecated. Use 'allowCopy' instead.")}, |
- {const_cast<char*>("aanot"), T_INT, offsetof(PDFfile, allowAnnots), 0, const_cast<char*>("Deprecated. Use 'allowAnnots' instead.")}, |
- {nullptr, 0, 0, 0, nullptr} // sentinel |
-}; |
- |
- |
-/* Here begins Getter & Setter functions */ |
- |
-static PyObject *PDFfile_getfile(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->file); |
- return self->file; |
-} |
- |
-static int PDFfile_setfile(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'file' attribute."); |
- return -1; |
- } |
- if (!PyString_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'file' attribute value must be string."); |
- return -1; |
- } |
- Py_DECREF(self->file); |
- Py_INCREF(value); |
- self->file = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getFontEmbeddingMode(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->fontEmbedding); |
- return self->fontEmbedding; |
-} |
- |
-static int PDFfile_setFontEmbeddingMode(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'fontEmbedding' attribute."); |
- return -1; |
- } |
- if (!PyInt_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'fontEmbedding' attribute value must be integer."); |
- return -1; |
- } |
- int n = PyInt_AsLong(value); |
- if (n < 0 || n > 2) |
- { |
- PyErr_SetString(PyExc_ValueError, "'fontEmbedding' value must be an integer between 0 and 2"); |
- return -1; |
- } |
- Py_DECREF(self->fontEmbedding); |
- Py_INCREF(value); |
- self->fontEmbedding = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getfonts(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->fonts); |
- return self->fonts; |
-} |
- |
-static int PDFfile_setfonts(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'fonts' attribute."); |
- return -1; |
- } |
- if (!PyList_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'fonts' attribute value must be list of strings."); |
- return -1; |
- } |
- int n = PyList_Size(value); |
- for (int i = 0; i < n; ++i) |
- { |
- if (!PyString_Check(PyList_GetItem(value, i))) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'fonts' list must contain only strings."); |
- return -1; |
- } |
- } |
- // Do I need to check if supplied string is really |
- // name of available font??? |
- // this is not implemented yet |
- Py_DECREF(self->fonts); |
- Py_INCREF(value); |
- self->fonts = value; |
- PyList_Sort(self->fonts); |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getSubsetList(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->subsetList); |
- return self->subsetList; |
-} |
- |
-static int PDFfile_setSubsetList(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'subsetList' attribute."); |
- return -1; |
- } |
- if (!PyList_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'subsetList' attribute value must be list of strings."); |
- return -1; |
- } |
- int n = PyList_Size(value); |
- for (int i = 0; i < n; ++i) |
- { |
- if (!PyString_Check(PyList_GetItem(value, i))) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'subsetList' list must contain only strings."); |
- return -1; |
- } |
- } |
- Py_DECREF(self->subsetList); |
- Py_INCREF(value); |
- self->subsetList = value; |
- PyList_Sort(self->subsetList); |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getpages(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->pages); |
- return self->pages; |
-} |
- |
-static int PDFfile_setpages(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'pages' attribute."); |
- return -1; |
- } |
- if (!PyList_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'pages' attribute value must be list of integers."); |
- return -1; |
- } |
- int len = PyList_Size(value); |
- for (int i = 0; i < len; i++) |
- { |
- PyObject *tmp = PyList_GetItem(value, i); |
- // I did not check if tmp is nullptr |
- // how can PyList_GetItem fail in this case (my guess: short of available memory?) |
- // Also do I need Py_INCREF or Py_DECREF here? |
- if (!PyInt_Check(tmp)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'pages' list must contain only integers."); |
- return -1; |
- } |
- if (PyInt_AsLong(tmp) > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count()) || PyInt_AsLong(tmp) < 1) |
- { |
- PyErr_SetString(PyExc_ValueError, "'pages' value out of range."); |
- return -1; |
- } |
- } |
- Py_DECREF(self->pages); |
- Py_INCREF(value); |
- self->pages = value; |
- return 0; |
-} |
- |
- |
-static PyObject *PDFfile_getresolution(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->resolution); |
- return self->resolution; |
-} |
- |
-static int PDFfile_setresolution(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'resolution' attribute."); |
- return -1; |
- } |
- if (!PyInt_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'resolution' attribute value must be integer."); |
- return -1; |
- } |
- int n = PyInt_AsLong(value); |
- if (n < 35 || n > 4000) |
- { |
- PyErr_SetString(PyExc_ValueError, "'resolution' value must be in interval from 35 to 4000"); |
- return -1; |
- } |
- Py_DECREF(self->resolution); |
- Py_INCREF(value); |
- self->resolution = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getdownsample(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->downsample); |
- return self->downsample; |
-} |
- |
-static int PDFfile_setdownsample(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'downsample' attribute."); |
- return -1; |
- } |
- if (!PyInt_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'downsample' attribute value must be integer."); |
- return -1; |
- } |
- int n = PyInt_AsLong(value); |
- if (n != 0 && (n < 35 || n > PyInt_AsLong(self->resolution))) |
- { |
- PyErr_SetString(PyExc_TypeError, "'downsample' value must be 0 or in interval from 35 to value of 'resolution'"); |
- return -1; |
- } |
- Py_DECREF(self->downsample); |
- Py_INCREF(value); |
- self->downsample = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_geteffval(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->effval); |
- return self->effval; |
-} |
- |
-static int PDFfile_seteffval(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'effval' attribute."); |
- return -1; |
- } |
- if (!PyList_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'effval' must be list."); |
- return -1; |
- } |
- int n = PyList_Size(value); |
- for (int i = 0; i < n; ++i) |
- { |
- PyObject *tmp = PyList_GetItem(value, i); |
- if (!PyList_Check(tmp)) |
- { |
- PyErr_SetString(PyExc_TypeError, "elements of 'effval' must be list of five integers."); |
- return -1; |
- } |
- int j = PyList_Size(tmp); |
- if (j != 6) |
- { |
- PyErr_SetString(PyExc_TypeError, "elements of 'effval' must have exactly six integers."); |
- return -1; |
- } |
- for (--j; j > -1; --j) |
- { |
- if (!PyInt_Check(PyList_GetItem(tmp, j))) |
- { |
- PyErr_SetString(PyExc_TypeError, "innermost element of 'effval' must be integers."); |
- return -1; |
- } |
- } |
- } |
- Py_DECREF(self->effval); |
- Py_INCREF(value); |
- self->effval = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getlpival(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->lpival); |
- return self->lpival; |
-} |
- |
-static int PDFfile_setlpival(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'lpival' attribute."); |
- return -1; |
- } |
- if (!PyList_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'lpival' must be list."); |
- return -1; |
- } |
- // Do I need Py_INCREF or Py_DECREF here? |
- int n = PyList_Size(value); |
- for (int i = 0; i < n; ++i) |
- { |
- PyObject *tmp = PyList_GetItem(value, i); |
- if (!PyList_Check(tmp)) |
- { |
- PyErr_SetString(PyExc_TypeError, "elements of 'lpival' must be list of five integers."); |
- return -1; |
- } |
- int j = PyList_Size(tmp); |
- if (j != 4) |
- { |
- PyErr_SetString(PyExc_TypeError, "elements of 'lpival' must have exactly four members."); |
- return -1; |
- } |
- for (--j; j > 0; --j) |
- { |
- if (!PyInt_Check(PyList_GetItem(tmp, j))) |
- { |
- PyErr_SetString(PyExc_TypeError, "'lpival'elements must have structure [siii]"); |
- return -1; |
- } |
- } |
- if (!PyString_Check(PyList_GetItem(tmp, 0))) |
- { |
- PyErr_SetString(PyExc_TypeError, "'lpival'elements must have structure [siii]"); |
- return -1; |
- } |
- } |
- Py_DECREF(self->lpival); |
- Py_INCREF(value); |
- self->lpival = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getowner(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->owner); |
- return self->owner; |
-} |
- |
-static int PDFfile_setowner(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'owner' attribute."); |
- return -1; |
- } |
- if (!PyString_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'owner' attribute value must be string."); |
- return -1; |
- } |
- Py_DECREF(self->owner); |
- Py_INCREF(value); |
- self->owner = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getuser(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->user); |
- return self->user; |
-} |
- |
-static int PDFfile_setuser(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'user' attribute."); |
- return -1; |
- } |
- if (!PyString_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'user' attribute value must be string."); |
- return -1; |
- } |
- Py_DECREF(self->user); |
- Py_INCREF(value); |
- self->user = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getsolidpr(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->solidpr); |
- return self->solidpr; |
-} |
- |
-static int PDFfile_setsolidpr(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'solidpr' attribute."); |
- return -1; |
- } |
- if (!PyString_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'solidpr' attribute value must be string."); |
- return -1; |
- } |
- Py_DECREF(self->solidpr); |
- Py_INCREF(value); |
- self->solidpr = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getimagepr(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->imagepr); |
- return self->imagepr; |
-} |
- |
-static int PDFfile_setimagepr(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'imagepr' attribute."); |
- return -1; |
- } |
- if (!PyString_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'imagepr' attribute value must be string."); |
- return -1; |
- } |
- Py_DECREF(self->imagepr); |
- Py_INCREF(value); |
- self->imagepr = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getprintprofc(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->printprofc); |
- return self->printprofc; |
-} |
- |
-static int PDFfile_setprintprofc(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'printprofc' attribute."); |
- return -1; |
- } |
- if (!PyString_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'printprofc' attribute value must be string."); |
- return -1; |
- } |
- Py_DECREF(self->printprofc); |
- Py_INCREF(value); |
- self->printprofc = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getinfo(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->info); |
- return self->info; |
-} |
- |
-static int PDFfile_setinfo(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'info' attribute."); |
- return -1; |
- } |
- if (!PyString_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "The 'info' attribute value must be string."); |
- return -1; |
- } |
- Py_DECREF(self->info); |
- Py_INCREF(value); |
- self->info = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getRotateDeg(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->rotateDeg); |
- return self->rotateDeg; |
-} |
- |
-static int PDFfile_setRotateDeg(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'rotateDeg' attribute."); |
- return -1; |
- } |
- if (!PyInt_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'rotateDeg' attribute value must be integer."); |
- return -1; |
- } |
- int n = PyInt_AsLong(value); |
- if (n != 0 && n != 90 && n != 180 && n != 270) |
- { |
- PyErr_SetString(PyExc_TypeError, "'rotateDeg' value must be 0 or 90 or 180 or 270"); |
- return -1; |
- } |
- Py_DECREF(self->rotateDeg); |
- Py_INCREF(value); |
- self->rotateDeg = value; |
- return 0; |
-} |
- |
-static PyObject *PDFfile_getopenAction(PDFfile *self, void * /*closure*/) |
-{ |
- Py_INCREF(self->openAction); |
- return self->openAction; |
-} |
- |
-static int PDFfile_setopenAction(PDFfile *self, PyObject *value, void * /*closure*/) |
-{ |
- if (value == nullptr) |
- { |
- PyErr_SetString(PyExc_TypeError, "Cannot delete 'openAction' attribute."); |
- return -1; |
- } |
- if (!PyString_Check(value)) |
- { |
- PyErr_SetString(PyExc_TypeError, "'openAction' attribute value must be string."); |
- return -1; |
- } |
- Py_DECREF(self->openAction); |
- Py_INCREF(value); |
- self->openAction = value; |
- return 0; |
-} |
- |
-static char *effval_doc = const_cast<char*>( |
-"List of effection values for each saved page.\n" |
-"It is a list of list of six integers. Those int has the following meaning:\n\t" |
-"- Length of time the page is shown before the presentation\n\tstarts on the selected page. (1-3600)\n\t" |
-"- Length of time the effect runs. (1 - 3600)\n\t\tA shorter time will speed up the effect,\n\t\ta longer one will slow it down\n\t" |
-"- Type of the display effect\n\t\t0 - No Effect\n\t\t1 - Blinds\n\t\t2 - Box\n\t\t3 - Dissolve\n\t\t4 - Glitter\n\t\t5 - Split\n\t\t6 - Wipe\n\t" |
-"- Direction of the effect of moving lines\n\tfor the split and blind effects.\n\t\t0 - Horizontal\n\t\t1 - Vertical\n\t" |
-"- Starting position for the box and split effects.\n\t\t0 - Inside\n\t\t1 - Outside\n\t" |
-"- Direction of the glitter or wipe effects.\n\t\t0 - Left to Right\n\t\t1 - Top to Bottom\n\t\t2 - Bottom to Top\n\t\t3 - Right to Left\n\t\t4 - Top-left to Bottom-Right"); |
- |
-static char *lpival_doc = const_cast<char*>( |
-"Rendering Settings for individual colors.\n\n" |
-"This is a list of values for each color\n" |
-"Color values have structure [siii] which stand for:\n\t" |
-"s - Color name ('Black', 'Cyan', 'Magenta', 'Yellow')\n\t" |
-"i - Frequency (10 to 1000)\n\t" |
-"i - Angle (-180 to 180)\n\t" |
-"i - Spot Function\n\t\t0 - Simple Dot\n\t\t1 - Line\n\t\t2 - Round\n\t\t3 - Ellipse\n" |
-"Be careful when supplying these values as they\nare not checked for validity."); |
- |
-static PyGetSetDef PDFfile_getseters [] = { |
- {const_cast<char*>("file"), (getter)PDFfile_getfile, (setter)PDFfile_setfile, const_cast<char*>("Name of file to save into"), nullptr}, |
- {const_cast<char*>("fontEmbedding"), (getter)PDFfile_getFontEmbeddingMode, (setter)PDFfile_setFontEmbeddingMode, const_cast<char*>("Font embedding mode.\n\tValue must be one of integers: 0 (Embed), 1 (Outline), 2 (No embedding)."), nullptr}, |
- {const_cast<char*>("fonts"), (getter)PDFfile_getfonts, (setter)PDFfile_setfonts, const_cast<char*>("List of fonts to embed."), nullptr}, |
- {const_cast<char*>("subsetList"), (getter)PDFfile_getSubsetList, (setter)PDFfile_setSubsetList, const_cast<char*>("List of fonts to subsetted."), nullptr}, |
- {const_cast<char*>("pages"), (getter)PDFfile_getpages, (setter)PDFfile_setpages, const_cast<char*>("List of pages to print"), nullptr}, |
- {const_cast<char*>("resolution"), (getter)PDFfile_getresolution, (setter)PDFfile_setresolution, const_cast<char*>("Resolution of output file. Values from 35 to 4000."), nullptr}, |
- {const_cast<char*>("downsample"), (getter)PDFfile_getdownsample, (setter)PDFfile_setdownsample, const_cast<char*>("Downsample image resolusion to this value. Values from 35 to 4000\nSet 0 for not to downsample"), nullptr}, |
- {const_cast<char*>("effval"), (getter)PDFfile_geteffval, (setter)PDFfile_seteffval, effval_doc, nullptr}, |
- {const_cast<char*>("lpival"), (getter)PDFfile_getlpival, (setter)PDFfile_setlpival, lpival_doc, nullptr}, |
- {const_cast<char*>("owner"), (getter)PDFfile_getowner, (setter)PDFfile_setowner, const_cast<char*>("Owner's password"), nullptr}, |
- {const_cast<char*>("user"), (getter)PDFfile_getuser, (setter)PDFfile_setuser, const_cast<char*>("User's password"), nullptr}, |
- {const_cast<char*>("solidpr"), (getter)PDFfile_getsolidpr, (setter)PDFfile_setsolidpr, const_cast<char*>("Color profile for solid colors"), nullptr}, |
- {const_cast<char*>("imagepr"), (getter)PDFfile_getimagepr, (setter)PDFfile_setimagepr, const_cast<char*>("Color profile for images"), nullptr}, |
- {const_cast<char*>("printprofc"), (getter)PDFfile_getprintprofc, (setter)PDFfile_setprintprofc, const_cast<char*>("Output profile for printing. If possible, get some guidance from your printer on profile selection."), nullptr}, |
- {const_cast<char*>("info"), (getter)PDFfile_getinfo, (setter)PDFfile_setinfo, const_cast<char*>("Mandatory string for PDF/X or the PDF will fail\nPDF/X conformance. We recommend you use the title of the document."), nullptr}, |
- {const_cast<char*>("rotateDeg"), (getter)PDFfile_getRotateDeg, (setter)PDFfile_setRotateDeg, const_cast<char*>("Automatically rotate the exported pages\n\tValue must be one of integers: 0, 90, 180 or 270"), nullptr}, |
- {const_cast<char*>("openAction"), (getter)PDFfile_getopenAction, (setter)PDFfile_setopenAction, const_cast<char*>("Javascript to be executed when PDF document is opened."), nullptr}, |
- {nullptr, nullptr, nullptr, nullptr, nullptr} // sentinel |
-}; |
- |
-static PyObject *PDFfile_save(PDFfile *self) |
-{ |
- if (!checkHaveDocument()) |
- return nullptr; |
- |
- ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; |
- PDFOptions& pdfOptions = currentDoc->pdfOptions(); |
- |
- // Copied from file scribus.cpp |
- // void ScribusMainWindow::SaveAsPDF() |
- if (ScCore->primaryMainWindow()->bookmarkPalette->BView->topLevelItemCount() == 0) |
- pdfOptions.Bookmarks = false; |
- |
- // Get PDF version |
- self->version = minmaxi(self->version, PDFVersion::PDFVersion_Min, PDFVersion::PDFVersion_Max); |
- pdfOptions.Version = (PDFVersion::Version) self->version; |
- |
- // Update used fonts |
- currentDoc->reorganiseFonts(); |
- |
- // Apply fonts attribute |
- pdfOptions.EmbedList.clear(); |
- int n = PyList_Size(self->fonts); |
- for (int i = 0; i < n; ++i) |
- { |
- QString tmpFon; |
- tmpFon = QString(PyString_AsString(PyList_GetItem(self->fonts, i))); |
- pdfOptions.EmbedList.append(tmpFon); |
- } |
- // Apply SubsetList attribute |
- pdfOptions.SubsetList.clear(); |
- n = PyList_Size(self->subsetList); |
- for (int i = 0; i < n; ++i) |
- { |
- QString tmpFon; |
- tmpFon = QString(PyString_AsString(PyList_GetItem(self->subsetList, i))); |
- pdfOptions.SubsetList.append(tmpFon); |
- } |
- // Apply font embedding mode |
- pdfOptions.FontEmbedding = (PDFOptions::PDFFontEmbedding) PyLong_AsLong(self->fontEmbedding); |
- if (pdfOptions.Version == PDFVersion::PDF_X1a || |
- pdfOptions.Version == PDFVersion::PDF_X3 || |
- pdfOptions.Version == PDFVersion::PDF_X4) |
- { |
- pdfOptions.FontEmbedding = PDFOptions::EmbedFonts; |
- } |
- if (pdfOptions.FontEmbedding == PDFOptions::EmbedFonts) |
- { |
- QStringList docFonts = currentDoc->UsedFonts.keys(); |
- for (int i = 0; i < docFonts.count(); ++i) |
- { |
- const QString& fontName = docFonts.at(i); |
- if (pdfOptions.SubsetList.contains(fontName)) |
- continue; |
- if (pdfOptions.EmbedList.contains(fontName)) |
- continue; |
- pdfOptions.SubsetList.append(fontName); |
- } |
- pdfOptions.OutlineList = QStringList(); |
- } |
- else if (pdfOptions.FontEmbedding == PDFOptions::OutlineFonts) |
- { |
- pdfOptions.EmbedList = QStringList(); |
- pdfOptions.SubsetList = QStringList(); |
- pdfOptions.OutlineList = currentDoc->UsedFonts.keys(); |
- } |
- else |
- { |
- pdfOptions.EmbedList = QStringList(); |
- pdfOptions.SubsetList = QStringList(); |
- pdfOptions.OutlineList = QStringList(); |
- } |
- // Apply file attribute |
- QString fn = QString(PyString_AsString(self->file)); |
- pdfOptions.fileName = fn; |
- // Apply pages attribute |
- std::vector<int> pageNs; |
- int nn = PyList_Size(self->pages); |
- for (int i = 0; i < nn; ++i) { |
- pageNs.push_back((int) PyInt_AsLong(PyList_GetItem(self->pages, i))); |
- } |
- // Apply thumbnails attribute |
- pdfOptions.Thumbnails = self->thumbnails; |
- // Apply cropmarks attribute |
- pdfOptions.cropMarks = self->cropMarks; |
- // Apply bleedmarks attribute |
- pdfOptions.bleedMarks = self->bleedMarks; |
- // Apply registrationmarks attribute |
- pdfOptions.registrationMarks = self->registrationMarks; |
- // Apply colormarks attribute |
- pdfOptions.colorMarks = self->colorMarks; |
- // Apply docInfoMark attribute |
- pdfOptions.docInfoMarks = self->docInfoMarks; |
- // Apply mark offset attribute |
- pdfOptions.markOffset = qMax(0.0, self->markOffset / currentDoc->unitRatio()); |
- // Apply mark length attribute |
- pdfOptions.markLength = qMax(0.0, self->markLength / currentDoc->unitRatio()); |
- // Apply compress attribute |
- self->compressmtd = minmaxi(self->compressmtd, 0, 3); |
- pdfOptions.Compress = self->compress; |
- pdfOptions.CompressMethod = (PDFOptions::PDFCompression) self->compressmtd; |
- // Apply quality attribute |
- self->quality = minmaxi(self->quality, 0, 4); |
- pdfOptions.Quality = self->quality; |
- // Apply resolusion attribute |
- pdfOptions.Resolution = PyInt_AsLong(self->resolution); |
- // Apply downsample attribute |
- pdfOptions.RecalcPic = PyInt_AsLong(self->downsample); |
- if (pdfOptions.RecalcPic) |
- pdfOptions.PicRes = PyInt_AsLong(self->downsample); |
- else |
- pdfOptions.PicRes = pdfOptions.Resolution; |
- // Apply bookmarks attribute |
- pdfOptions.Bookmarks = self->bookmarks; |
- // Apply binding attribute |
- pdfOptions.Binding = self->binding; |
- // Apply presentation attribute |
- pdfOptions.PresentMode = self->presentation; |
- |
- int tmpnum = PyList_Size(self->effval); |
- for (int i = 0; i < tmpnum; ++i) |
- { |
- PDFPresentationData t; |
- PyObject *ti = PyList_GetItem(self->effval, i); |
- if (!ti) |
- continue; |
- // Do I Need to check if every PyInt_AsLong and PyList_GetItem function succeed??? |
- t.pageEffectDuration = PyInt_AsLong(PyList_GetItem(ti, 0)); |
- t.pageViewDuration = PyInt_AsLong(PyList_GetItem(ti, 1)); |
- t.effectType = PyInt_AsLong(PyList_GetItem(ti, 2)); |
- t.Dm = PyInt_AsLong(PyList_GetItem(ti, 3)); |
- t.M = PyInt_AsLong(PyList_GetItem(ti, 4)); |
- t.Di = PyInt_AsLong(PyList_GetItem(ti, 5)); |
- // PresentVals.append(t); |
- } |
-// pdfOptions.PresentVals = PresentVals; |
- |
- // Apply lpival |
- int n2 = PyList_Size(self->lpival); |
- for (int i = 0; i < n2; ++i) |
- { |
- LPIData lpi; |
- PyObject *t = PyList_GetItem(self->lpival, i); |
-// This code always raise exception - WHY??? |
-// char *s; |
-// if (!PyArg_ParseTuple(t, "[siii]", &s, &lpi.Frequency, |
-// &lpi.Angle, &lpi.SpotFunc)) { |
-// PyErr_SetString(PyExc_SystemError, "while parsing 'lpival'. WHY THIS HAPPENED????"); |
-// return nullptr; |
-// } |
-// pdfOptions.LPISettings[QString(s)]=lpi; |
- QString st = QString(PyString_AsString(PyList_GetItem(t,0))); |
- lpi.Frequency = PyInt_AsLong(PyList_GetItem(t, 1)); |
- lpi.Angle = PyInt_AsLong(PyList_GetItem(t, 2)); |
- lpi.SpotFunc = PyInt_AsLong(PyList_GetItem(t, 3)); |
- pdfOptions.LPISettings[st] = lpi; |
- } |
- |
- pdfOptions.Articles = self->article; |
- pdfOptions.Encrypt = self->encrypt; |
- pdfOptions.UseLPI = self->uselpi; |
- pdfOptions.UseSpotColors = self->usespot; |
- pdfOptions.doMultiFile = self->domulti; |
- |
- if (self->encrypt) |
- { |
- int Perm = -64; |
- if (pdfOptions.Version == PDFVersion::PDF_14) |
- Perm &= ~0x00240000; |
- if (self->allowPrinting) |
- Perm += 4; |
- if (self->allowChange) |
- Perm += 8; |
- if (self->allowCopy) |
- Perm += 16; |
- if (self->allowAnnots) |
- Perm += 32; |
- pdfOptions.Permissions = Perm; |
- pdfOptions.PassOwner = QString(PyString_AsString(self->owner)); |
- pdfOptions.PassUser = QString(PyString_AsString(self->user)); |
- } |
- if (self->outdst == 0) |
- { |
- pdfOptions.UseRGB = true; |
- pdfOptions.UseProfiles = false; |
- pdfOptions.UseProfiles2 = false; |
- } |
- else |
- { |
- pdfOptions.UseRGB = false; |
- if (ScCore->primaryMainWindow()->doc->HasCMS) |
- { |
- pdfOptions.UseProfiles = self->profiles; |
- pdfOptions.UseProfiles2 = self->profilei; |
- self->intents = minmaxi(self->intents, 0, 3); |
- pdfOptions.Intent = self->intents; |
- self->intenti = minmaxi(self->intenti, 0, 3); |
- pdfOptions.Intent2 = self->intenti; |
- pdfOptions.EmbeddedI = self->noembicc; |
- pdfOptions.SolidProf = PyString_AsString(self->solidpr); |
- pdfOptions.ImageProf = PyString_AsString(self->imagepr); |
- pdfOptions.PrintProf = PyString_AsString(self->printprofc); |
- if (pdfOptions.Version == PDFVersion::PDF_X1a || |
- pdfOptions.Version == PDFVersion::PDF_X3 || |
- pdfOptions.Version == PDFVersion::PDF_X4) |
- { |
- pdfOptions.Info = PyString_AsString(self->info); |
- pdfOptions.Encrypt = false; |
- pdfOptions.PresentMode = false; |
- } |
- } |
- else |
- { |
- pdfOptions.UseProfiles = false; |
- pdfOptions.UseProfiles2 = false; |
- } |
- } |
- |
- QMap<int, QImage> thumbs; |
- PageToPixmapFlags pixmapFlags = Pixmap_DontReloadImages | Pixmap_DrawWhiteBackground; |
- for (uint ap = 0; ap < pageNs.size(); ++ap) |
- { |
- QImage thumb(10, 10, QImage::Format_ARGB32_Premultiplied ); |
- if (pdfOptions.Thumbnails) |
- thumb = ScCore->primaryMainWindow()->view->PageToPixmap(pageNs[ap] - 1, 100, pixmapFlags); |
- thumbs.insert(pageNs[ap], thumb); |
- } |
- |
- ReOrderText(ScCore->primaryMainWindow()->doc, ScCore->primaryMainWindow()->view); |
- |
- MarginStruct optBleeds(pdfOptions.bleeds); |
- pdfOptions.useDocBleeds = self->useDocBleeds; |
- if (self->useDocBleeds) |
- pdfOptions.bleeds = ScCore->primaryMainWindow()->doc->bleedsVal(); |
- else |
- { |
- self->bleedt = minmaxd(self->bleedt, 0, currentDoc->pageHeight() * currentDoc->unitRatio()); |
- pdfOptions.bleeds.setTop(self->bleedt / currentDoc->unitRatio()); |
- self->bleedl = minmaxd(self->bleedl, 0, currentDoc->pageWidth() * currentDoc->unitRatio()); |
- pdfOptions.bleeds.setLeft(self->bleedl / currentDoc->unitRatio()); |
- self->bleedr = minmaxd(self->bleedr, 0, currentDoc->pageWidth() * currentDoc->unitRatio()); |
- pdfOptions.bleeds.setRight(self->bleedr / currentDoc->unitRatio()); |
- self->bleedb = minmaxd(self->bleedb, 0, currentDoc->pageHeight() * currentDoc->unitRatio()); |
- pdfOptions.bleeds.setBottom(self->bleedb / currentDoc->unitRatio()); |
- } |
- pdfOptions.useLayers = self->useLayers; |
- pdfOptions.embedPDF = self->embedPDF; |
- pdfOptions.MirrorH = self->mirrorH; |
- pdfOptions.MirrorV = self->mirrorV; |
- pdfOptions.doClip = self->doClip; |
- pdfOptions.RotateDeg = PyInt_AsLong(self->rotateDeg); |
- pdfOptions.isGrayscale = self->isGrayscale; |
- pdfOptions.PageLayout = minmaxi(self->pageLayout, 0, 3); |
- pdfOptions.displayBookmarks = self->displayBookmarks; |
- pdfOptions.displayThumbs = self->displayThumbs; |
- pdfOptions.displayLayers = self->displayLayers; |
- pdfOptions.displayFullscreen = self->displayFullscreen; |
- pdfOptions.hideToolBar = self->hideToolBar; |
- pdfOptions.hideMenuBar = self->hideMenuBar; |
- pdfOptions.fitWindow = self->fitWindow; |
- pdfOptions.openAction = QString(PyString_AsString(self->openAction)); |
- pdfOptions.firstUse = false; |
- |
- QString errorMessage; |
- bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, pageNs, thumbs, errorMessage); |
- if (!success) |
- { |
- fn = "Cannot write the File: " + fn; |
- if (!errorMessage.isEmpty()) |
- fn += QString("\n%1").arg(errorMessage); |
- PyErr_SetString(PyExc_SystemError, fn.toLatin1()); |
- } |
- |
- if (self->useDocBleeds) |
- pdfOptions.bleeds = optBleeds; |
- |
- if (success) |
- Py_RETURN_NONE; |
- return nullptr; |
-} |
- |
-static PyMethodDef PDFfile_methods[] = { |
- {const_cast<char*>("save"), (PyCFunction)PDFfile_save, METH_NOARGS, pdffile_save__doc__}, |
- {nullptr, (PyCFunction)(nullptr), 0, nullptr} // sentinel |
-}; |
- |
-PyTypeObject PDFfile_Type = { |
- PyObject_HEAD_INIT(nullptr) // PyObject_VAR_HEAD |
- 0, // |
- const_cast<char*>("scribus.PDFfile"), // char *tp_name; /* For printing, in format "<module>.<name>" */ |
- sizeof(PDFfile), // int tp_basicsize, /* For allocation */ |
- 0, // int tp_itemsize; /* For allocation */ |
- |
- /* Methods to implement standard operations */ |
- |
- (destructor) PDFfile_dealloc, // destructor tp_dealloc; |
- nullptr, // printfunc tp_print; |
- nullptr, // getattrfunc tp_getattr; |
- nullptr, // setattrfunc tp_setattr; |
- nullptr, // cmpfunc tp_compare; |
- nullptr, // reprfunc tp_repr; |
- |
- /* Method suites for standard classes */ |
- |
- nullptr, // PyNumberMethods *tp_as_number; |
- nullptr, // PySequenceMethods *tp_as_sequence; |
- nullptr, // PyMappingMethods *tp_as_mapping; |
- |
- /* More standard operations (here for binary compatibility) */ |
- |
- nullptr, // hashfunc tp_hash; |
- nullptr, // ternaryfunc tp_call; |
- nullptr, // reprfunc tp_str; |
- nullptr, // getattrofunc tp_getattro; |
- nullptr, // setattrofunc tp_setattro; |
- |
- /* Functions to access object as input/output buffer */ |
- nullptr, // PyBufferProcs *tp_as_buffer; |
- |
- /* Flags to define presence of optional/expanded features */ |
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, // long tp_flags; |
- |
- pdffile__doc__, // char *tp_doc; /* Documentation string */ |
- |
- /* Assigned meaning in release 2.0 */ |
- /* call function for all accessible objects */ |
- nullptr, // traverseproc tp_traverse; |
- |
- /* delete references to contained objects */ |
- nullptr, // inquiry tp_clear; |
- |
- /* Assigned meaning in release 2.1 */ |
- /* rich comparisons */ |
- nullptr, // richcmpfunc tp_richcompare; |
- |
- /* weak reference enabler */ |
- 0, // long tp_weaklistoffset; |
- |
- /* Added in release 2.2 */ |
- /* Iterators */ |
- nullptr, // getiterfunc tp_iter; |
- nullptr, // iternextfunc tp_iternext; |
- |
- /* Attribute descriptor and subclassing stuff */ |
- PDFfile_methods, // struct PyMethodDef *tp_methods; |
- PDFfile_members, // struct PyMemberDef *tp_members; |
- PDFfile_getseters, // struct PyGetSetDef *tp_getset; |
- nullptr, // struct _typeobject *tp_base; |
- nullptr, // PyObject *tp_dict; |
- nullptr, // descrgetfunc tp_descr_get; |
- nullptr, // descrsetfunc tp_descr_set; |
- 0, // long tp_dictoffset; |
- (initproc)PDFfile_init, // initproc tp_init; |
- nullptr, // allocfunc tp_alloc; |
- PDFfile_new, // newfunc tp_new; |
- nullptr, // freefunc tp_free; /* Low-level free-memory routine */ |
- nullptr, // inquiry tp_is_gc; /* For PyObject_IS_GC */ |
- nullptr, // PyObject *tp_bases; |
- nullptr, // PyObject *tp_mro; /* method resolution order */ |
- nullptr, // PyObject *tp_cache; |
- nullptr, // PyObject *tp_subclasses; |
- nullptr, // PyObject *tp_weaklist; |
- nullptr, // destructor tp_del; |
- |
-#ifdef COUNT_ALLOCS |
- /* these must be last and never explicitly initialized */ |
- // int tp_allocs; |
- // int tp_frees; |
- // int tp_maxalloc; |
- // struct _typeobject *tp_next; |
-#endif |
-}; |
/trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp |
---|
Property changes: |
Deleted: svn:eol-style |
## -1 +0,0 ## |
-native |
\ No newline at end of property |
Index: trunk/Scribus/scribus/plugins/scriptplugin_py2x/scripts/FontSample.py |
=================================================================== |
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/scripts/FontSample.py (revision 25080) |
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/scripts/FontSample.py (nonexistent) |
@@ -1,1578 +0,0 @@ |
-#!/usr/bin/env python |
-# -*- coding: utf-8 -*- |
- |
-# **************************************************************************** |
-# This program is free software; you can redistribute it and/or modify |
-# it under the terms of the GNU General Public License as published by |
-# the Free Software Foundation; either version 2 of the License, or |
-# (at your option) any later version. |
-# |
-# This program is distributed in the hope that it will be useful, |
-# but WITHOUT ANY WARRANTY; without even the implied warranty of |
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-# GNU General Public License for more details. |
-# |
-# You should have received a copy of the GNU General Public License |
-# along with this program; if not, write to the Free Software |
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
-# |
-# **************************************************************************** |
- |
-""" |
-****************************************************************************** |
- |
-DESCRIPTION & USAGE: |
-This script needs Tkinter. It will create a GUI with an alphabetical list |
-of fonts using the names as they will be shown in Scribus. User can select |
-one or more fonts and create an example sheet(s) to print or create a PDF |
-from. It is heavily commented to make it easier for the user to adjust it |
-for his / her own needs. |
- |
-Note: this version needs read/write access to .scribus directory in users |
-home. You will also need Python Imaging Library (PIL) installed. |
-If your system does not meet these requirements then change showPreviewPanel |
-to a value of 0. This will disable the new preview features. |
- |
-****************************************************************************** |
- |
-First release : 30/12/2003 |
-This release : v0.8.1tk (released 4th Dec 2005) |
-Copyright : (C) 2003 - 2005 Steve Callcott |
-Latest releases |
-and support : www.firstwish.co.uk/sjc/scribus/index.php |
-Maintainer : Steve Callcott 2003 - 2005 |
-Email : stotte@firstwish.co.uk |
- |
-For revision history see the ChangeLog file. |
-Bugs and future plans are listed in the TODO file. |
-See NEWS for new features since last version. |
- |
-WHATS NEW v0.8.2tk: |
-A one liner change by Jean Ghali to line #734 to add the extra parameter missing. |
-See: http://bugs.scribus.net/view.php?id=4377 |
- |
-WHATS NEW v0.8.1tk: |
-After reloading users saved preferences the status bar was not showing |
-correct calculations. |
-Changed text in settings menu. |
- |
-WHATS NEW v0.8tk Final: |
-Cleaned up the checkbox labels and layout. |
- |
-WHATS NEW v0.8tk Preview 3: |
-Calls the new Scribus zoomDocument() function to make the completed font |
-sample document fit in Scribus window. |
- |
-Grey out "Start page number count from first page" when "Print TOC" is |
-not checked as without a table of contents the first page would always |
-start on the same page number making this option irrelevant. |
- |
-WHATS NEW v0.8tk Preview 2: |
-Replaced the newDoc() with newDocument(). Have not put any fallback code |
-for use with earlier Scribus versions. |
- |
-When using double sided option we now make use of Scribus ability to display |
-pages side by side as default. You may need to zoom out to view the |
-complete document width. |
- |
-WHATS NEW v0.8tk Preview 1: |
-Rearanged the initialisation. If no fonts are found for the Table of |
-Contents, page numbers and font sample labels, the script shows a |
-message box listing the problem and a possible solution as well as a message |
-to the console. |
- |
-A Scribus messagebox alerts the user if Tkinter is not found. Previously |
-this message was only printed to the console. |
- |
-Now able to do a dummy run to calculate and report the amount of samples |
-that will fit on a page. This enables the script to correctly calculate |
-how many sheets will be required. Previously it was always assumed that |
-there would be 3 sample blocks on a sheet. This is now not always the case. |
- |
-Added menu. Also added "about" and "settings" dialogs. |
- |
-Sample rows can be selected or unselected to save on paper. The settings are |
-automatically saved when changed and can be set as user defaults. |
- |
-User can choose to have page numbers count from first page of the toc instead |
-of the first page of samples. This can be helpful if wanting to quickly look |
-up a font in the toc and then using the Scribus page navigator dialog to go to |
-the actual page on the screen to view it without printing it out. |
- |
-Added initial support for a sample paragraph. The sample paragraph defaults |
-to "off" due to the amount of space it uses on the page. |
- |
-Some widgets read their defaults from a config dictionary. |
- |
-Many code cleanups. Classes used for settings storage have been replaced with |
-dictionaries to make it easier for users to customise. |
- |
-****************************************************************************** |
-""" |
- |
-import sys |
-import os |
-import cPickle |
- |
- |
-showPreviewPanel = 1 # change to 0 to permanently hide the preview |
-TEMP_PATH = os.path.join(os.path.expanduser('~'), '.scribus') |
-CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.scribus/fontsampler') |
- |
- |
-try: |
- import scribus |
-except ImportError,err: |
- print 'This Python script is written for the Scribus scripting interface.' |
- print 'It can only be run from within Scribus.' |
- sys.exit(1) |
- |
- |
-try: |
- from Tkinter import * |
-except ImportError,err: |
- print 'This script will not work without Tkinter' |
- scribus.messageBox('Error','This script will not work without Tkinter\nPlease install and try again', |
- scribus.ICON_WARNING) |
- sys.exit(1) |
- |
- |
-if not os.path.exists(CONFIG_PATH): |
- try: |
- print 'Attempting to creating configuration file directory...' |
- os.mkdir(CONFIG_PATH) |
- print 'Success, now testing for write access of new directory...' |
- if os.access(CONFIG_PATH, os.W_OK): |
- print 'Write access ok.' |
- else: |
- print 'Error, unable to write to .scribus/fontsampler directory.' |
- except: |
- CONFIG_PATH = '' |
- print 'Failed to make configuration file directory,' |
- print 'do you have a .scribus directory in your home directory?' |
- print 'font sampler will not be able to save your preferences' |
- |
- |
-try: |
- from PIL import Image |
-except ImportError,err: |
- print 'You need to install Python Imaging Library (PIL).' |
- print 'If using gentoo then you need to emerge /dev-python/imaging' |
- print 'If using an RPM based linux distribution then you add python-imaging or similar.' |
- print 'Script will continue without the font preview panel.' |
- showPreviewPanel = 0 |
- |
- |
-try: |
- from PIL import ImageTk |
-except ImportError,err: |
- print 'Module ImageTk not found, font preview disabled' |
- showPreviewPanel = 0 |
- |
- |
-if showPreviewPanel: |
- if not os.path.exists(TEMP_PATH): |
- print '.scribus folder not found, disabling font preview panel' |
- showPreviewPanel = 0 |
- if not os.access(TEMP_PATH, os.W_OK): |
- print 'Unable to write to .scribus folder, disabling font preview panel' |
- showPreviewPanel = 0 |
- |
- |
-# A few globals for use later... |
-gSamplePic = None |
-gPreviewId = None |
- |
-#************************************************************************* |
- |
-WINDOW_TITLE = 'Font Sampler v0.8.1tk - Steve Callcott' |
-SUPPORT_PAGE = 'www.firstwish.co.uk/sjc/scribus/index.php' |
- |
-fontsListFixed = ( |
- 'Luxi Mono Regular', |
- 'Nimbus Mono L Regular', |
- 'Courier 10 Pitch Regular', |
- 'Courier New Regular', |
- 'Courier Regular', |
- 'Andale Mono Regular', |
- 'Larabiefont Regular' |
-) |
- |
-fontsListProportional = ( |
- 'Nimbus Sans L Regular', |
- 'Luxi Sans Regular', |
- 'Bitstream Vera Sans', |
- 'Helvetica', |
- 'Arial Regular' |
-) |
- |
-defaultPrefs = { |
- 'wantDoubleSided': 0, |
- 'paperSize':'A4', # currently PAPER_LETTER or PAPER_A4 |
- 'wantTOC': 1, |
- 'wantBindingOffset': 0, |
- 'wantPageNumbers': 1, |
- 'wantPageOneOnFirst': 0, |
- 'wantAlphabet' : 1, |
- 'want6Point' : 1, |
- 'want8Point' : 1, |
- 'want10Point' : 1, |
- 'want12Point' : 1, |
- 'want16Point' : 1, |
- 'want20Point' : 1, |
- 'want32Point' : 1, |
- 'wantParagraph' : 0 # Uses a lot of space so default is off |
-} |
- |
-userPrefs = {} |
- |
-geometriesList = [ |
- { |
- 'paperName' : 'A4', |
- 'paperSize' : scribus.PAPER_A4, |
- 'paperWidth' : 595, |
- 'paperHeight' : 842, |
- 'paperTopMargin' : 60, |
- 'paperBottomMargin' : 50, |
- 'paperLeftMargin' : 50, |
- 'paperRightMargin' : 50, |
- 'paperBinding' : 16, |
- 'tocRowsPerPage' : 57, |
- 'paperPageNumVertOffset' : 16 |
- }, |
- { |
- 'paperName' : 'US Letter', |
- 'paperSize' : scribus.PAPER_LETTER, |
- 'paperWidth' : 612, |
- 'paperHeight' : 792, |
- 'paperTopMargin' : 27, |
- 'paperBottomMargin' : 45, |
- 'paperLeftMargin' : 50, |
- 'paperRightMargin' : 50, |
- 'paperBinding' : 18, |
- 'tocRowsPerPage' : 56, |
- 'paperPageNumVertOffset' : 16 |
- } |
-] |
- |
-# define our data dictionary and some of the data... |
-dD = { |
- 'tocHeaderTitle' : 'Table of Contents', |
- 'tocCharsInRow' : 75, |
- 'previewpanelFontHeight' : 28, |
- 'previewpanelSampleText' : 'Woven silk pyjamas exchanged for blue quartz' |
-} |
- |
-samplesHeader = { |
- 'fontSize' : 16, |
- 'lineSpace' : 15, |
- 'textHeight' : 23 |
-} |
- |
-# Use \xBC etc to insert Hex ascii chars into the sample strings below. |
-sampleAlphabet = { |
- 'fontSize' : 10.5, |
- 'lineSpace' : 12, |
- 'textString' : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#?$*&', |
- 'textHeight' : 18 |
-} |
- |
-sample6Point = { |
- 'fontSize' : 6, |
- 'lineSpace' : 6, |
- 'textString' : 'This line is in 6 point', |
- 'textHeight' : 13 |
-} |
- |
-sample8Point = { |
- 'fontSize' : 8, |
- 'lineSpace' : 8, |
- 'textString' : 'This line is in 8 point', |
- 'textHeight' : 16 |
-} |
- |
-sample10Point = { |
- 'fontSize' : 10, |
- 'lineSpace' : 11, |
- 'textString' : 'This line is in 10 point', |
- 'textHeight' : 19 |
-} |
- |
-sample12Point = { |
- 'fontSize' : 12, |
- 'lineSpace' : 11, |
- 'textString' : 'This line is in 12 point', |
- 'textHeight' : 21 |
-} |
- |
-sample16Point = { |
- 'fontSize' : 16, |
- 'lineSpace' : 13, |
- 'textString' : 'This line is in 16 point', |
- 'textHeight' : 26 |
-} |
- |
-sample20Point = { |
- 'fontSize' : 20, |
- 'lineSpace' : 16, |
- 'textString' : 'This line is in 20 point', |
- 'textHeight' : 31 |
-} |
- |
-sample32Point = { |
- 'fontSize' : 32, |
- 'lineSpace' : 29, |
- 'textString' : 'This line is in 32 point', |
- 'textHeight' : 49 |
-} |
- |
-sampleParagraph = { |
- 'fontSize' : 9, |
- 'lineSpace' : 10.8, |
- 'textHeight' : 175 |
-} |
- |
-sampleParagraphText = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut a sapien. \ |
-Aliquam aliquet purus molestie dolor. Integer quis eros ut erat posuere dictum. \ |
-Curabitur dignissim. Integer orci. Fusce vulputate lacus at ipsum. Quisque in libero \ |
-nec mi laoreet volutpat. Aliquam eros pede, scelerisque quis, tristique cursus, \ |
-placerat convallis, velit. Nam condimentum. Nulla ut mauris. Curabitur adipiscing, \ |
-mauris non dictum aliquam, arcu risus dapibus diam, nec sollicitudin quam erat quis \ |
-ligula. Aenean massa nulla, volutpat eu, accumsan et, fringilla eget, odio. \ |
-Nulla placerat porta justo. Nulla vitae turpis.\n\nPraesent lacus.Lorem ipsum dolor sit \ |
-amet, consectetuer adipiscing elit. Pellentesque habitant morbi tristique senectus \ |
-et netus et malesuada fames ac turpis egestas. Quisque vel erat eget diam \ |
-consectetuer iaculis. Cras ante velit, suscipit et, porta tempus, dignissim quis, \ |
-magna. Vivamus viverra, turpis nec rhoncus ultricies, diam turpis eleifend nisl, a \ |
-eleifend ante felis ac sapien. Integer bibendum. Suspendisse in mi non neque \ |
-bibendum convallis. Suspendisse potenti. Sed sit amet purus at felis adipiscing \ |
-aliquam. Vivamus et nisl sit amet mauris aliquet molestie. Integer tortor massa, \ |
-aliquam a, lacinia nonummy, sagittis nec, eros.' |
- |
-#************************************************************************* |
- |
-def set_font_fixed(fontList): |
- """Find a matching font for the Table of Contents.""" |
- availableFonts = scribus.getFontNames() |
- found = 0 |
- for f in fontList: |
- if found: |
- break |
- for i in availableFonts: |
- if not found: |
- if f == i: |
- return f |
- found = 1 |
- break |
- if not found: |
- errorList = '' |
- for j in fontList: |
- errorList = errorList + j + '\n' |
- errorMessage ='No suitable fixed width font found.\nPlease install at least one of these fixed width fonts:\n'+errorList |
- print errorMessage |
- raise Exception(errorMessage) |
- |
- |
-def set_font_proportional(fontList): |
- """Find a matching font for the page numbers and font names above samples.""" |
- availableFonts = scribus.getFontNames() |
- found = 0 |
- for p in fontList: |
- if found: |
- break |
- for i in availableFonts: |
- if not found: |
- if p == i: |
- return p |
- found = 1 |
- break |
- if not found: |
- errorList = '' |
- for j in fontList: |
- errorList = errorList + j + '\n' |
- errorMessage = 'No suitable proportional font found.\nPlease install at least one of these proportional fonts:\n'+errorList |
- print errorMessage |
- raise Exception(errorMessage) |
- |
- |
-def save_user_conf(path): |
- """Save the data to the save file on the path specified by CONFIG_PATH. |
- |
- Note initialisation unsets the CONFIG_PATH if it failed to verify or create""" |
- if not path == '': |
- try: |
- file = open(os.path.join(path,'fontsampler.conf'), 'w') |
- data = { |
- 'a' : defaultPrefs, |
- 'b' : userPrefs |
- } |
- cPickle.dump(data, file) |
- file.close() |
- except: |
- print 'failed to save data' |
- |
- |
-def restore_user_conf(path): |
- """Restore the data from the save file on the path specified by CONFIG_PATH.""" |
- try: |
- file = open(os.path.join(path,'fontsampler.conf'), 'r') |
- data = cPickle.load(file) |
- file.close() |
- defaultPrefs.update(data['a']) |
- userPrefs.update(data['b']) |
- except: |
- userPrefs.update(defaultPrefs) |
- print 'failed to load saved data so using default values defined in the script' |
- |
- |
-def set_page_geometry(dD, geometriesList, paperSize, wantBindingOffset): |
- """This is the experimental replacement paper size setting function. |
- |
- Each paper size and other associated data are stored in a dictionary. |
- The dictionaries are stored in a list. We copy appropriate dictionary |
- and custom calculations into a work dictionary for use. |
- The advantage of this is its easier to add new paper definitions. |
- Returns a new dictionary, use .update to merge in new values into dD. |
- """ |
- try: |
- result={} |
- for i in geometriesList: |
- if i['paperName'] == paperSize: |
- dD.update(i) |
- |
- result['paperLeftMarginOdd'] = dD['paperLeftMargin'] + \ |
- dD['paperBinding'] |
- result['paperRightMarginEven'] = dD['paperRightMargin'] + \ |
- dD['paperBinding'] |
- result['paperTextHeight'] = dD['paperHeight'] - \ |
- dD['paperTopMargin'] - \ |
- dD['paperBottomMargin'] |
- result['paperMargins'] = dD['paperLeftMargin'],dD['paperRightMargin'],dD['paperTopMargin'],dD['paperBottomMargin'] |
- |
- # if we are adding a binding offset to the margins then we will have less width for our text... |
- if wantBindingOffset: |
- result['paperTextWidth'] = dD['paperWidth'] - \ |
- dD['paperLeftMargin'] - \ |
- dD['paperRightMargin'] - \ |
- dD['paperBinding'] - \ |
- 2 |
- else: |
- result['paperTextWidth'] = dD['paperWidth'] - \ |
- dD['paperLeftMargin'] - \ |
- dD['paperRightMargin'] - \ |
- 2 |
- return result |
- except: |
- errorMessage = 'set_page_geometry() failure: %s' % sys.exc_info()[1] |
- print errorMessage |
- |
- |
-def set_odd_even(pageNum): |
- """ Sets the left margin position. |
- |
- Checks the number passed to it and sets left margin accordingly. |
- Call once after each new page is created. |
- Returns 1 if even and 0 if odd page. |
- """ |
- if pageNum % 2 == 0: |
- isEvenPage = 1 # Even side |
- else: |
- isEvenPage = 0 # Odd side |
- |
- if userPrefs['wantBindingOffset']: |
- if isEvenPage and userPrefs['wantDoubleSided']: # Even (when double sided) |
- dD['paperLeftSide'] = dD['paperLeftMargin'] + 1 |
- else: # Odd side |
- dD['paperLeftSide'] = dD['paperLeftMarginOdd'] + 1 |
- else: # No binding |
- dD['paperLeftSide'] = dD['paperLeftMargin'] + 1 |
- return isEvenPage |
- |
- |
-def draw_sample_row(font, fontSize, lineSpace, textString, x, y, w, h, getSizeOnly): |
- """Creates one row of samples or a header for the top of the block. |
-< |