Back to index

scribus-ng  1.3.4.dfsg+svn20071115
cmdgetprop.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "cmdgetprop.h"
00008 #include "cmdutil.h"
00009 #include "scribuscore.h"
00010 
00011 PyObject *scribus_getfillcolor(PyObject* /* self */, PyObject* args)
00012 {
00013        char *Name = const_cast<char*>("");
00014        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00015               return NULL;
00016        if(!checkHaveDocument())
00017               return NULL;
00018        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00019        return i != NULL ? PyString_FromString(i->fillColor().utf8()) : NULL;
00020 }
00021 
00022 PyObject *scribus_getfilltrans(PyObject* /* self */, PyObject* args)
00023 {
00024        char *Name = const_cast<char*>("");
00025        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00026               return NULL;
00027        if(!checkHaveDocument())
00028               return NULL;
00029        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00030        return i != NULL ? PyFloat_FromDouble(static_cast<double>(1.0 - i->fillTransparency())) : NULL;
00031 }
00032 
00033 PyObject *scribus_getfillblend(PyObject* /* self */, PyObject* args)
00034 {
00035        char *Name = const_cast<char*>("");
00036        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00037               return NULL;
00038        if(!checkHaveDocument())
00039               return NULL;
00040        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00041        return i != NULL ? PyInt_FromLong(static_cast<long>(i->fillBlendmode())) : NULL;
00042 }
00043 
00044 PyObject *scribus_getlinecolor(PyObject* /* self */, PyObject* args)
00045 {
00046        char *Name = const_cast<char*>("");
00047        PageItem *it;
00048        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00049               return NULL;
00050        if(!checkHaveDocument())
00051               return NULL;
00052        it = GetUniqueItem(QString::fromUtf8(Name));
00053        if (it == NULL)
00054               return NULL;
00055        if ((it->HasSel) && ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText)))
00056        {
00057               for (int b = 0; b < it->itemText.length(); ++b)
00058               {
00059                      if (it->itemText.selected(b))
00060                             return PyString_FromString(it->itemText.charStyle(b).fillColor().utf8());
00061               }
00062        }
00063        else
00064               return PyString_FromString(it->lineColor().utf8());
00065        PyErr_SetString(NotFoundError, QObject::tr("Color not found - python error", "python error"));
00066        return NULL;
00067 }
00068 
00069 PyObject *scribus_getlinetrans(PyObject* /* self */, PyObject* args)
00070 {
00071        char *Name = const_cast<char*>("");
00072        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00073               return NULL;
00074        if(!checkHaveDocument())
00075               return NULL;
00076        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00077        return i != NULL ? PyFloat_FromDouble(static_cast<double>(1.0 - i->lineTransparency())) : NULL;
00078 }
00079 
00080 PyObject *scribus_getlineblend(PyObject* /* self */, PyObject* args)
00081 {
00082        char *Name = const_cast<char*>("");
00083        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00084               return NULL;
00085        if(!checkHaveDocument())
00086               return NULL;
00087        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00088        return i != NULL ? PyInt_FromLong(static_cast<long>(i->lineBlendmode())) : NULL;
00089 }
00090 
00091 PyObject *scribus_getlinewidth(PyObject* /* self */, PyObject* args)
00092 {
00093        char *Name = const_cast<char*>("");
00094        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00095               return NULL;
00096        if(!checkHaveDocument())
00097               return NULL;
00098        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00099        return i != NULL ? PyFloat_FromDouble(static_cast<double>(i->lineWidth())) : NULL;
00100 }
00101 
00102 PyObject *scribus_getlineshade(PyObject* /* self */, PyObject* args)
00103 {
00104        char *Name = const_cast<char*>("");
00105        PageItem *it;
00106        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00107               return NULL;
00108        if(!checkHaveDocument())
00109               return NULL;
00110        it = GetUniqueItem(QString::fromUtf8(Name));
00111        if (it == NULL)
00112               return NULL;
00113        if ((it->HasSel) && ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText)))
00114        {
00115               for (int b = 0; b < it->itemText.length(); ++b)
00116               {
00117                      if (it->itemText.selected(b))
00118                             return PyInt_FromLong(static_cast<long>(it->itemText.charStyle(b).fillShade()));
00119               }
00120        }
00121        else
00122               return PyInt_FromLong(static_cast<long>(it->lineShade()));
00123        return PyInt_FromLong(0L);
00124 }
00125 
00126 PyObject *scribus_getlinejoin(PyObject* /* self */, PyObject* args)
00127 {
00128        char *Name = const_cast<char*>("");
00129        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00130               return NULL;
00131        if(!checkHaveDocument())
00132               return NULL;
00133        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00134        return i != NULL ? PyInt_FromLong(static_cast<long>(i->PLineJoin)) : NULL;
00135 }
00136 
00137 PyObject *scribus_getlineend(PyObject* /* self */, PyObject* args)
00138 {
00139        char *Name = const_cast<char*>("");
00140        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00141               return NULL;
00142        if(!checkHaveDocument())
00143               return NULL;
00144        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00145        return i != NULL ? PyInt_FromLong(static_cast<long>(i->PLineEnd)) : NULL;
00146 }
00147 
00148 PyObject *scribus_getlinestyle(PyObject* /* self */, PyObject* args)
00149 {
00150        char *Name = const_cast<char*>("");
00151        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00152               return NULL;
00153        if(!checkHaveDocument())
00154               return NULL;
00155        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00156        return i != NULL ? PyInt_FromLong(static_cast<long>(i->PLineArt)) : NULL;
00157 }
00158 
00159 PyObject *scribus_getfillshade(PyObject* /* self */, PyObject* args)
00160 {
00161        char *Name = const_cast<char*>("");
00162        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00163               return NULL;
00164        if(!checkHaveDocument())
00165               return NULL;
00166        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00167        return i != NULL ? PyInt_FromLong(static_cast<long>(i->fillShade())) : NULL;
00168 }
00169 
00170 PyObject *scribus_getcornerrad(PyObject* /* self */, PyObject* args)
00171 {
00172        char *Name = const_cast<char*>("");
00173        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00174               return NULL;
00175        if(!checkHaveDocument())
00176               return NULL;
00177        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00178        return i != NULL ? PyInt_FromLong(static_cast<long>(i->cornerRadius())) : NULL;
00179 }
00180 
00181 PyObject *scribus_getimgscale(PyObject* /* self */, PyObject* args)
00182 {
00183        char *Name = const_cast<char*>("");
00184        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00185               return NULL;
00186        if(!checkHaveDocument())
00187               return NULL;
00188        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00189        return i != NULL ? Py_BuildValue("(ff)", i->imageXScale(), i->imageYScale()) : NULL;
00190 }
00191 
00192 PyObject *scribus_getimgname(PyObject* /* self */, PyObject* args)
00193 {
00194        char *Name = const_cast<char*>("");
00195        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00196               return NULL;
00197        if(!checkHaveDocument())
00198               return NULL;
00199        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00200        return i != NULL ? PyString_FromString(i->Pfile.utf8()) : NULL;
00201 }
00202 
00203 PyObject *scribus_getposi(PyObject* /* self */, PyObject* args)
00204 {
00205        char *Name = const_cast<char*>("");
00206        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00207               return NULL;
00208        if(!checkHaveDocument())
00209               return NULL;
00210        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00211        if (!i)
00212               return NULL;
00213        return Py_BuildValue("(ff)", docUnitXToPageX(i->xPos()),
00214                                                          docUnitYToPageY(i->yPos()));
00215 }
00216 
00217 PyObject *scribus_getsize(PyObject* /* self */, PyObject* args)
00218 {
00219        char *Name = const_cast<char*>("");
00220        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00221               return NULL;
00222        if(!checkHaveDocument())
00223               return NULL;
00224        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00225        return (i != NULL) ? Py_BuildValue("(ff)", PointToValue(i->width()), PointToValue(i->height())) : NULL;
00226 }
00227 
00228 PyObject *scribus_getrotation(PyObject* /* self */, PyObject* args)
00229 {
00230        char *Name = const_cast<char*>("");
00231        if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
00232               return NULL;
00233        if(!checkHaveDocument())
00234               return NULL;
00235        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
00236        return i != NULL ? PyFloat_FromDouble(static_cast<double>(i->rotation() * -1)) : NULL;
00237 }
00238 
00239 PyObject *scribus_getallobj(PyObject* /* self */, PyObject* args)
00240 {
00241        PyObject *l;
00242        int typ = -1;
00243        uint counter = 0;
00244        uint counter2 = 0;
00245        uint pageNr = ScCore->primaryMainWindow()->doc->currentPageNumber();
00246        if (!PyArg_ParseTuple(args, "|i", &typ))
00247               return NULL;
00248        if(!checkHaveDocument())
00249               return NULL;
00250        // have doc already
00251        if (typ != -1)
00252        {
00253               for (uint lam2 = 0; lam2 < ScCore->primaryMainWindow()->doc->Items->count(); ++lam2)
00254               {
00255                      if ((ScCore->primaryMainWindow()->doc->Items->at(lam2)->itemType() == typ) && (pageNr == static_cast<uint>(ScCore->primaryMainWindow()->doc->Items->at(lam2)->OwnPage)))
00256                             counter++;
00257               }
00258        }
00259        else
00260        {
00261               for (uint lam2 = 0; lam2 < ScCore->primaryMainWindow()->doc->Items->count(); ++lam2)
00262               {
00263                      if (pageNr == static_cast<uint>(ScCore->primaryMainWindow()->doc->Items->at(lam2)->OwnPage))
00264                             counter++;
00265               }
00266        }
00267 
00268        l = PyList_New(counter);
00269        for (uint lam=0; lam < ScCore->primaryMainWindow()->doc->Items->count(); ++lam)
00270        {
00271               if  (pageNr == static_cast<uint>(ScCore->primaryMainWindow()->doc->Items->at(lam)->OwnPage))
00272               {
00273                      if (typ != -1)
00274                      {
00275                             if (ScCore->primaryMainWindow()->doc->Items->at(lam)->itemType() == typ)
00276                             {
00277                                    PyList_SetItem(l, counter2, PyString_FromString(ScCore->primaryMainWindow()->doc->Items->at(lam)->itemName().utf8()));
00278                                    counter2++;
00279                             }
00280                      }
00281                      else
00282                      {
00283                             PyList_SetItem(l, counter2, PyString_FromString(ScCore->primaryMainWindow()->doc->Items->at(lam)->itemName().utf8()));
00284                             counter2++;
00285                      }
00286               }
00287        }
00288        return l;
00289 }
00290 
00294 void cmdgetpropdocwarnings()
00295 {
00296     QStringList s;
00297     s << scribus_getfillcolor__doc__ <<scribus_getfilltrans__doc__ << scribus_getfillblend__doc__ << scribus_getlinecolor__doc__ << scribus_getlinetrans__doc__ << scribus_getlineblend__doc__ << scribus_getlinewidth__doc__ << scribus_getlineshade__doc__ <<scribus_getlinejoin__doc__ <<scribus_getlineend__doc__ <<scribus_getlinestyle__doc__ <<scribus_getfillshade__doc__ <<scribus_getcornerrad__doc__ <<scribus_getimgscale__doc__ <<scribus_getimgname__doc__ <<scribus_getposi__doc__ <<scribus_getsize__doc__ <<scribus_getrotation__doc__ <<  scribus_getallobj__doc__;
00298 }