Author: jghali
Date: Fri Jul 17 13:41:08 2020
New Revision: 23926

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23926
Log:
Code style fixes

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23926&path=/trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp   (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp   Fri Jul 17 
13:41:08 2020
@@ -140,129 +140,139 @@
 
 static PyObject * PDFfile_new(PyTypeObject *type, PyObject * /*args*/, 
PyObject * /*kwds*/)
 {
-// do not create new object if there is no opened document
-       if (!checkHaveDocument()) {
+       // 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
+       if (self)
+       {
+               // Set file attribute
                self->file = PyUnicode_FromString("");
-               if (!self->file) {
+               if (!self->file)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set font embedding mode attribute
+               // Set font embedding mode attribute
                self->fontEmbedding = PyLong_FromLong(0);
-               if (!self->fontEmbedding) {
+               if (!self->fontEmbedding)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set fonts attribute
+               // Set fonts attribute
                self->fonts = PyList_New(0);
-               if (!self->fonts){
+               if (!self->fonts)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
                self->subsetList = PyList_New(0);
-               if (!self->subsetList){
+               if (!self->subsetList)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set pages attribute
+               // Set pages attribute
                self->pages = PyList_New(0);
-               if (self->pages == nullptr){
+               if (self->pages == nullptr)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set thumbnails attribute
+               // Set thumbnails attribute
                self->thumbnails = 0;
-// set cropMarks attribute
+               // Set cropMarks attribute
                self->cropMarks = 0;
-// set bleedMarks attribute
+               // Set bleedMarks attribute
                self->bleedMarks = 0;
-// set registrationMarks attribute
+               // Set registrationMarks attribute
                self->registrationMarks = 0;
-// set colorMarks attribute
+               // Set colorMarks attribute
                self->colorMarks = 0;
-// set docInfoMarks attribute
+               // Set docInfoMarks attribute
                self->docInfoMarks = 0;
-// set mark offset attribute
+               // Set mark offset attribute
                self->markOffset = 0;
-// set mark length attribute
+               // Set mark length attribute
                self->markLength = 0;
-// set compress attribute
+               // Set compress attribute
                self->compress = 0;
-// set compressmtd attribute
+               // Set compressmtd attribute
                self->compressmtd = 0;
-// set quality attribute
+               // Set quality attribute
                self->quality = 0;
-// set resolution attribute
+               // Set resolution attribute
                self->resolution = PyLong_FromLong(300);
-               if (!self->resolution){
+               if (!self->resolution)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set downsample attribute
+               // Set downsample attribute
                self->downsample = PyLong_FromLong(0);
-               if (!self->downsample){
+               if (!self->downsample)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set bookmarks attribute
+               // Set bookmarks attribute
                self->bookmarks = 0;
-// set binding attribute
+               // Set binding attribute
                self->binding = 0;
-// set presentation attribute
+               // Set presentation attribute
                self->presentation = 0;
-// set effval attribute
+               // Set effval attribute
                self->effval = PyList_New(0);
-               if (!self->effval){
+               if (!self->effval)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set article attribute
+               // Set article attribute
                self->article = 0;
-// set encrypt attribute
+               // Set encrypt attribute
                self->encrypt = 0;
-// set uselpi attribute
+               // Set uselpi attribute
                self->uselpi = 0;
                self->usespot = 1;
                self->domulti = 0;
-// set lpival attribute
+               // Set lpival attribute
                self->lpival = PyList_New(0);
-               if (!self->lpival){
+               if (!self->lpival)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set owner attribute
+               // Set owner attribute
                self->owner = PyUnicode_FromString("");
-               if (!self->owner){
+               if (!self->owner)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set user attribute
+               // Set user attribute
                self->user = PyUnicode_FromString("");
-               if (!self->user){
+               if (!self->user)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set allowPrinting attribute
+               // Set allowPrinting attribute
                self->allowPrinting = 1;
-// set allowChange attribute
+               // Set allowChange attribute
                self->allowChange = 1;
-// set allowCopy attribute
+               // Set allowCopy attribute
                self->allowCopy = 1;
-// set allowAnnots attribute
+               // Set allowAnnots attribute
                self->allowAnnots = 1;
-// set version attribute
+               // Set version attribute
                self->version = 14;
-// set output attribute
+               // Set output attribute
                self->outdst = 0;
-
 
                self->profiles = 0; // bool
                self->profilei = 0; // bool
@@ -270,22 +280,26 @@
                self->intenti = 0; // int - 0 - ?
                self->noembicc = 0; // bool
                self->solidpr = PyUnicode_FromString("");
-               if (!self->solidpr){
+               if (!self->solidpr)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
                self->imagepr = PyUnicode_FromString("");
-               if (!self->imagepr){
+               if (!self->imagepr)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
                self->printprofc = PyUnicode_FromString("");
-               if (!self->printprofc){
+               if (!self->printprofc)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
                self->info = PyUnicode_FromString("");
-               if (!self->info){
+               if (!self->info)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
@@ -300,7 +314,8 @@
                self->mirrorV = 0;
                self->doClip = 0;
                self->rotateDeg = PyLong_FromLong(0);
-               if (!self->rotateDeg){
+               if (!self->rotateDeg)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
@@ -314,7 +329,8 @@
                self->hideMenuBar = 0;
                self->fitWindow = 0;
                self->openAction = PyUnicode_FromString("");
-               if (!self->openAction){
+               if (!self->openAction)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
@@ -325,170 +341,192 @@
 static int PDFfile_init(PDFfile *self, PyObject * /*args*/, PyObject * 
/*kwds*/)
 {
        int i;
-       if (!checkHaveDocument()) {
-               return -1;
-       }
+       if (!checkHaveDocument())
+               return -1;
 
        ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
        PDFOptions& pdfOptions = currentDoc->pdfOptions();
 
-// defaut save into file
+       // Defaut save into file
        QString tf = pdfOptions.fileName;
-       if (tf.isEmpty()) {
+       if (tf.isEmpty())
+       {
                QFileInfo fi = QFileInfo(currentDoc->documentFileName());
                tf = fi.path() + "/" + fi.baseName() + ".pdf";
        }
-       PyObject *file = nullptr;
-       file = PyUnicode_FromString(tf.toUtf8());
-       if (file){
+
+       PyObject *file = PyUnicode_FromString(tf.toUtf8());
+       if (file)
+       {
                Py_DECREF(self->file);
                self->file = file;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'file' 
attribute");
                return -1;
        }
-// font embedding mode
-       PyObject *embeddingMode = nullptr;
-       embeddingMode = PyLong_FromLong(pdfOptions.FontEmbedding);
-       if (embeddingMode){
+
+       // Font embedding mode
+       PyObject *embeddingMode = PyLong_FromLong(pdfOptions.FontEmbedding);
+       if (embeddingMode)
+       {
                Py_DECREF(self->fontEmbedding);
                self->fontEmbedding = embeddingMode;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'fontEmbedding' attribute");
                return -1;
        }
-// embed all used fonts
-       PyObject *fonts = nullptr;
-       fonts = PyList_New(0);
-       if (fonts){
+
+       // Embed all used fonts
+       PyObject *fonts = PyList_New(0);
+       if (fonts)
+       {
                Py_DECREF(self->fonts);
                self->fonts = fonts;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'fonts' 
attribute");
                return -1;
        }
-       // get all used fonts
+
+       // Get all used fonts
        QMap<QString,int> ReallyUsed = currentDoc->UsedFonts;
-       // create list of all used fonts
+       // 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= nullptr;
-               tmp = PyUnicode_FromString(fontName.toUtf8());
-               if (tmp) {
+               PyObject *tmp = PyUnicode_FromString(fontName.toUtf8());
+               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
+                       // 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 {
+               else
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'fonts' attribute");
                        return -1;
                }
        }
-// init subsetList
+
+       // Init subsetList
        fonts = PyList_New(0);
-       if (fonts){
+       if (fonts)
+       {
                Py_DECREF(self->subsetList);
                self->subsetList = fonts;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'subsetList' attribute");
                return -1;
        }
-// copied from TabPDFOptions::restoreDefaults()
+
+       // Copied from TabPDFOptions::restoreDefaults()
        for (int fe = 0; fe < pdfOptions.SubsetList.count(); ++fe)
        {
                PyObject *tmp= nullptr;
                tmp = 
PyUnicode_FromString(pdfOptions.SubsetList[fe].toUtf8().data());
-               if (tmp) {
+               if (tmp)
+               {
                        PyList_Append(self->subsetList, tmp);
                        Py_DECREF(tmp);
                }
-               else {
+               else
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'subsetList' attribute");
                        return -1;
                }
        }
 
-// set to print all pages
-       PyObject *pages = nullptr;
-       // which one should I use ???
-       // new = ScCore->primaryMainWindow()->view->Pages.count()
+       // Set to print all pages
        int num = currentDoc->Pages->count();
-       pages = PyList_New(num);
-       if (!pages){
+       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;
-               tmp = PyLong_FromLong((long)i+1L);
+       for (i = 0; i < num; ++i)
+       {
+               PyObject *tmp = PyLong_FromLong((long) i + 1L);
                if (tmp)
                        PyList_SetItem(pages, i, tmp);
-               else {
+               else
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'pages' attribute");
                        return -1;
                }
        }
        Py_DECREF(self->pages);
        self->pages = pages;
-// print thumbnails ?
+       // Print thumbnails ?
        self->thumbnails = pdfOptions.Thumbnails;
-// output crop marks ?
+       // Output crop marks ?
        self->cropMarks = pdfOptions.cropMarks;
-// output bleed marks ?
+       // Output bleed marks ?
        self->bleedMarks = pdfOptions.bleedMarks;
-// output registration marks ?
+       // Output registration marks ?
        self->registrationMarks = pdfOptions.registrationMarks;
-// output color bars ?
+       // Output color bars ?
        self->colorMarks = pdfOptions.colorMarks;
-// output doc info marks ?
+       // Output doc info marks ?
        self->docInfoMarks = pdfOptions.docInfoMarks;
-// cropmarks offset 
+       // Cropmarks offset 
        self->markOffset = pdfOptions.markOffset * currentDoc->unitRatio();
-// cropmarks length 
+       // Cropmarks length 
        self->markLength = pdfOptions.markLength * currentDoc->unitRatio();
-// set automatic compression
+       // Set automatic compression
        self->compress = pdfOptions.Compress;
        self->compressmtd = pdfOptions.CompressMethod;
-// use maximum image quality
+       // Use maximum image quality
        self->quality = pdfOptions.Quality;
-// default resolution
+       // Default resolution
        PyObject *resolution = nullptr;
        resolution = PyLong_FromLong(300);
-       if (resolution){
+       if (resolution)
+       {
                Py_DECREF(self->resolution);
                self->resolution = resolution;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'resolution' attribute");
                return -1;
        }
-// do not downsample images
+       // Do not downsample images
        int down = pdfOptions.RecalcPic ? pdfOptions.PicRes : 0;
        PyObject *downsample = nullptr;
        downsample = PyLong_FromLong(down);
-       if (downsample){
+       if (downsample)
+       {
                Py_DECREF(self->downsample);
                self->downsample = downsample;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'downsamle' attribute");
                return -1;
        }
-       // no bookmarks
+       // No bookmarks
        self->bookmarks = pdfOptions.Bookmarks;
-       // left margin binding
+       // Left margin binding
        self->binding = pdfOptions.Binding;
-       // do not enable presentation effects
+       // Do not enable presentation effects
        self->presentation = pdfOptions.PresentMode;
-       // set effects values for all pages
+       // Set effects values for all pages
        PyObject *effval = nullptr;
-       // which one should I use ???
-       // new = ScCore->primaryMainWindow()->view->Pages.count();
        num = currentDoc->Pages->count();
        effval = PyList_New(num);
-       if (!effval){
+       if (!effval)
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' 
attribute");
                return -1;
        }
@@ -499,16 +537,18 @@
                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 {
+               else
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'effval' attribute");
                        return -1;
                }
-               for (; i<num; ++i) {
-                       PyObject *tmp;
-                       tmp = Py_BuildValue(const_cast<char*>("[iiiiii]"), 1, 
1, 0, 0, 0, 0);
+               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 {
+                       else
+                       {
                                PyErr_SetString(PyExc_SystemError, "Can not 
initialize 'effval' attribute");
                                return -1;
                        }
@@ -516,26 +556,29 @@
        }
        Py_DECREF(self->effval);
        self->effval = effval;
-// do not save linked text frames as PDF article
+       // Do not save linked text frames as PDF article
        self->article = pdfOptions.Articles;
-// do not encrypt file
+       // Do not encrypt file
        self->encrypt = pdfOptions.Encrypt;
-// do not Use Custom Rendering Settings
+       // Do not Use Custom Rendering Settings
        self->uselpi = pdfOptions.UseLPI;
        self->usespot = pdfOptions.UseSpotColors;
        self->domulti = pdfOptions.doMultiFile;
-// get default values for lpival
+       // Get default values for lpival
        int n = pdfOptions.LPISettings.size();
        PyObject *lpival=PyList_New(n);
-       if (!lpival){
+       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()) {
+       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) {
+               if (!tmp)
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'lpival' attribute");
                        return -1;
                }
@@ -545,37 +588,41 @@
        PyList_Reverse(lpival);
        Py_DECREF(self->lpival);
        self->lpival = lpival;
-// set owner's password
-       PyObject *owner = nullptr;
-       owner = PyUnicode_FromString(pdfOptions.PassOwner.toUtf8());
-       if (owner){
+       // Set owner's password
+       PyObject *owner = PyUnicode_FromString(pdfOptions.PassOwner.toUtf8());
+       if (owner)
+       {
                Py_DECREF(self->owner);
                self->owner = owner;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'owner' 
attribute");
                return -1;
        }
-// set user'a password
-       PyObject *user = nullptr;
-       user = PyUnicode_FromString(pdfOptions.PassUser.toUtf8());
-       if (user){
+       // Set user'a password
+       PyObject *user = PyUnicode_FromString(pdfOptions.PassUser.toUtf8());
+       if (user)
+       {
                Py_DECREF(self->user);
                self->user = user;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'user' 
attribute");
                return -1;
        }
-// allow printing document
+       // Allow printing document
        self->allowPrinting = pdfOptions.Permissions & 4;
-// allow changing document
+       // Allow changing document
        self->allowChange = pdfOptions.Permissions & 8;
-// allow copying document
+       // Allow copying document
        self->allowCopy = pdfOptions.Permissions & 16;
-// allow adding annotation and fields
+       // Allow adding annotation and fields
        self->allowAnnots = pdfOptions.Permissions & 32;
-// use 1.4 pdf version *aka. Acrobat 5)
+       // Use 1.4 pdf version *aka. Acrobat 5)
        self->version = pdfOptions.Version;
-// output destination is screen
+       // Output destination is screen
        self->outdst = pdfOptions.UseRGB ? 0 : 1;
 
        self->profiles = pdfOptions.UseProfiles; // bool
@@ -586,24 +633,28 @@
        QString tp = pdfOptions.SolidProf;
        if (!ScCore->InputProfiles.contains(tp))
                tp = currentDoc->cmsSettings().DefaultSolidColorRGBProfile;
-       PyObject *solidpr = nullptr;
-       solidpr = PyUnicode_FromString(tp.toUtf8());
-       if (solidpr){
+       PyObject *solidpr = PyUnicode_FromString(tp.toUtf8());
+       if (solidpr)
+       {
                Py_DECREF(self->solidpr);
                self->solidpr = solidpr;
-       } else {
+       }
+       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 = nullptr;
-       imagepr = PyUnicode_FromString(tp2.toUtf8());
-       if (imagepr){
+       PyObject *imagepr = PyUnicode_FromString(tp2.toUtf8());
+       if (imagepr)
+       {
                Py_DECREF(self->imagepr);
                self->imagepr = imagepr;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'imagepr' attribute");
                return -1;
        }
@@ -612,20 +663,25 @@
                tp3 = currentDoc->cmsSettings().DefaultPrinterProfile;
        PyObject *printprofc = nullptr;
        printprofc = PyUnicode_FromString(tp3.toUtf8());
-       if (printprofc){
+       if (printprofc)
+       {
                Py_DECREF(self->printprofc);
                self->printprofc = printprofc;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'printprofc' attribute");
                return -1;
        }
        QString tinfo = pdfOptions.Info;
-       PyObject *info = nullptr;
-       info = PyUnicode_FromString(tinfo.toUtf8());
-       if (info){
+       PyObject *info = PyUnicode_FromString(tinfo.toUtf8());
+       if (info)
+       {
                Py_DECREF(self->info);
                self->info = info;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'info' 
attribute");
                return -1;
        }
@@ -639,12 +695,14 @@
        self->mirrorH = pdfOptions.MirrorH; // bool
        self->mirrorV = pdfOptions.MirrorV; // bool
        self->doClip = pdfOptions.doClip; // bool
-       PyObject *rotateDeg = nullptr;
-       rotateDeg = PyLong_FromLong(0);
-       if (rotateDeg){
+       PyObject *rotateDeg = PyLong_FromLong(0);
+       if (rotateDeg)
+       {
                Py_DECREF(self->rotateDeg);
                self->rotateDeg = rotateDeg;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'rotateDeg' attribute");
                return -1;
        }
@@ -658,12 +716,14 @@
        self->hideMenuBar = pdfOptions.hideMenuBar; // bool
        self->fitWindow = pdfOptions.fitWindow; // bool
 
-       PyObject *openAction = nullptr;
-       openAction = 
PyUnicode_FromString(pdfOptions.openAction.toUtf8().data());
-       if (openAction){
+       PyObject *openAction = 
PyUnicode_FromString(pdfOptions.openAction.toUtf8().data());
+       if (openAction)
+       {
                Py_DECREF(self->openAction);
                self->openAction = openAction;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'openAction' attribute");
                return -1;
        }
@@ -745,11 +805,13 @@
 
 static int PDFfile_setfile(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'file' 
attribute.");
                return -1;
        }
-       if (!PyUnicode_Check(value)) {
+       if (!PyUnicode_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'file' attribute value 
must be string.");
                return -1;
        }
@@ -767,16 +829,19 @@
 
 static int PDFfile_setFontEmbeddingMode(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'fontEmbedding' 
attribute.");
                return -1;
        }
-       if (!PyLong_Check(value)) {
+       if (!PyLong_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'fontEmbedding' attribute 
value must be integer.");
                return -1;
        }
        int n = PyLong_AsLong(value);
-       if (n < 0 || n > 2) {
+       if (n < 0 || n > 2)
+       {
                PyErr_SetString(PyExc_ValueError, "'fontEmbedding' value must 
be an integer between 0 and 2");
                return -1;
        }
@@ -794,24 +859,28 @@
 
 static int PDFfile_setfonts(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'fonts' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       if (!PyList_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'fonts' attribute value 
must be list of strings.");
                return -1;
        }
-       int n;
-       n = PyList_Size(value);
-       for (int i=0; i<n; ++i)
-               if (!PyUnicode_Check(PyList_GetItem(value, i))) {
+       int n = PyList_Size(value);
+       for (int i = 0; i < n; ++i)
+       {
+               if (!PyUnicode_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
+       }
+       // 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;
@@ -827,21 +896,25 @@
 
 static int PDFfile_setSubsetList(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'subsetList' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       if (!PyList_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'subsetList' attribute 
value must be list of strings.");
                return -1;
        }
-       int n;
-       n = PyList_Size(value);
-       for (int i=0; i<n; ++i)
-               if (!PyUnicode_Check(PyList_GetItem(value, i))) {
+       int n = PyList_Size(value);
+       for (int i = 0; i < n; ++i)
+       {
+               if (!PyUnicode_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;
@@ -857,25 +930,30 @@
 
 static int PDFfile_setpages(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'pages' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       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++){
+       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 (!PyLong_Check(tmp)){
+               if (!PyLong_Check(tmp))
+               {
                        PyErr_SetString(PyExc_TypeError, "'pages' list must 
contain only integers.");
                        return -1;
                }
-               if (PyLong_AsLong(tmp) > 
static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count()) || 
PyLong_AsLong(tmp) < 1) {
+               if (PyLong_AsLong(tmp) > 
static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count()) || 
PyLong_AsLong(tmp) < 1)
+               {
                        PyErr_SetString(PyExc_ValueError, "'pages' value out of 
range.");
                        return -1;
                }
@@ -895,16 +973,19 @@
 
 static int PDFfile_setresolution(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'resolution' 
attribute.");
                return -1;
        }
-       if (!PyLong_Check(value)) {
+       if (!PyLong_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'resolution' attribute value 
must be integer.");
                return -1;
        }
        int n = PyLong_AsLong(value);
-       if (n<35 || n>4000) {
+       if (n < 35 || n > 4000)
+       {
                PyErr_SetString(PyExc_ValueError, "'resolution' value must be 
in interval from 35 to 4000");
                return -1;
        }
@@ -922,16 +1003,19 @@
 
 static int PDFfile_setdownsample(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'downsample' 
attribute.");
                return -1;
        }
-       if (!PyLong_Check(value)) {
+       if (!PyLong_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'downsample' attribute value 
must be integer.");
                return -1;
        }
        int n = PyLong_AsLong(value);
-       if (n!=0 && (n < 35 || n > PyLong_AsLong(self->resolution))) {
+       if (n != 0 && (n < 35 || n > PyLong_AsLong(self->resolution)))
+       {
                PyErr_SetString(PyExc_TypeError, "'downsample' value must be 0 
or in interval from 35 to value of 'resolution'");
                return -1;
        }
@@ -949,28 +1033,35 @@
 
 static int PDFfile_seteffval(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'effval' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       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) {
+       for (int i = 0; i < n; ++i)
+       {
                PyObject *tmp = PyList_GetItem(value, i);
-               if (!PyList_Check(tmp)) {
+               if (!PyList_Check(tmp))
+               {
                        PyErr_SetString(PyExc_TypeError, "elemets of 'effval' 
must be list of five integers.");
                        return -1;
                }
                int j = PyList_Size(tmp);
-               if (j != 6) {
+               if (j != 6)
+               {
                        PyErr_SetString(PyExc_TypeError, "elemets of 'effval' 
must have exactly six integers.");
                        return -1;
                }
-               for ( --j; j > -1; --j) {
-                       if (!PyLong_Check(PyList_GetItem(tmp, j))) {
+               for (--j; j > -1; --j)
+               {
+                       if (!PyLong_Check(PyList_GetItem(tmp, j)))
+                       {
                                PyErr_SetString(PyExc_TypeError, "innermost 
element of 'effval' must be integers.");
                                return -1;
                        }
@@ -990,34 +1081,42 @@
 
 static int PDFfile_setlpival(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'lpival' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       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) {
+       for (int i = 0; i < n; ++i)
+       {
                PyObject *tmp = PyList_GetItem(value, i);
-               if (!PyList_Check(tmp)) {
+               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) {
+               if (j != 4)
+               {
                        PyErr_SetString(PyExc_TypeError, "elements of 'lpival' 
must have exactly four members.");
                        return -1;
                }
-               for ( --j; j > 0; --j) {
-                       if (!PyLong_Check(PyList_GetItem(tmp, j))) {
+               for (--j; j > 0; --j)
+               {
+                       if (!PyLong_Check(PyList_GetItem(tmp, j)))
+                       {
                                PyErr_SetString(PyExc_TypeError, 
"'lpival'elements must have structure [siii]");
                                return -1;
                        }
                }
-               if (!PyUnicode_Check(PyList_GetItem(tmp, 0))) {
+               if (!PyUnicode_Check(PyList_GetItem(tmp, 0)))
+               {
                        PyErr_SetString(PyExc_TypeError, "'lpival'elements must 
have structure [siii]");
                        return -1;
                }
@@ -1036,11 +1135,13 @@
 
 static int PDFfile_setowner(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'owner' 
attribute.");
                return -1;
        }
-       if (!PyUnicode_Check(value)) {
+       if (!PyUnicode_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'owner' attribute value must 
be string.");
                return -1;
        }
@@ -1058,11 +1159,13 @@
 
 static int PDFfile_setuser(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'user' 
attribute.");
                return -1;
        }
-       if (!PyUnicode_Check(value)) {
+       if (!PyUnicode_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'user' attribute value must 
be string.");
                return -1;
        }
@@ -1080,11 +1183,13 @@
 
 static int PDFfile_setsolidpr(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'solidpr' 
attribute.");
                return -1;
        }
-       if (!PyUnicode_Check(value)) {
+       if (!PyUnicode_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'solidpr' attribute value 
must be string.");
                return -1;
        }
@@ -1102,11 +1207,13 @@
 
 static int PDFfile_setimagepr(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'imagepr' 
attribute.");
                return -1;
        }
-       if (!PyUnicode_Check(value)) {
+       if (!PyUnicode_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'imagepr' attribute value 
must be string.");
                return -1;
        }
@@ -1124,11 +1231,13 @@
 
 static int PDFfile_setprintprofc(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'printprofc' 
attribute.");
                return -1;
        }
-       if (!PyUnicode_Check(value)) {
+       if (!PyUnicode_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'printprofc' attribute 
value must be string.");
                return -1;
        }
@@ -1146,11 +1255,13 @@
 
 static int PDFfile_setinfo(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'info' 
attribute.");
                return -1;
        }
-       if (!PyUnicode_Check(value)) {
+       if (!PyUnicode_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'info' attribute value 
must be string.");
                return -1;
        }
@@ -1168,16 +1279,19 @@
 
 static int PDFfile_setRotateDeg(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'rotateDeg' 
attribute.");
                return -1;
        }
-       if (!PyLong_Check(value)) {
+       if (!PyLong_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'rotateDeg' attribute value 
must be integer.");
                return -1;
        }
        int n = PyLong_AsLong(value);
-       if (n!=0 && n!=90 && n!=180 && n!=270) {
+       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;
        }
@@ -1195,11 +1309,13 @@
 
 static int PDFfile_setopenAction(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'openAction' 
attribute.");
                return -1;
        }
-       if (!PyUnicode_Check(value)) {
+       if (!PyUnicode_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'openAction' attribute value 
must be string.");
                return -1;
        }
@@ -1252,9 +1368,8 @@
 
 static PyObject *PDFfile_save(PDFfile *self)
 {
-       if (!checkHaveDocument()) {
+       if (!checkHaveDocument())
                return nullptr;
-       }
 
        ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
        PDFOptions& pdfOptions = currentDoc->pdfOptions();
@@ -1324,8 +1439,7 @@
                pdfOptions.OutlineList = QStringList();
        }
        // Apply file attribute
-       QString fn;
-       fn = PyUnicode_asQString(self->file);
+       QString fn = PyUnicode_asQString(self->file);
        pdfOptions.fileName = fn;
        // Apply pages attribute
        std::vector<int> pageNs;
@@ -1387,8 +1501,8 @@
                t.Di = PyLong_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)
@@ -1476,7 +1590,7 @@
        {
                QImage thumb(10, 10, QImage::Format_ARGB32_Premultiplied );
                if (pdfOptions.Thumbnails)
-                       thumb = 
ScCore->primaryMainWindow()->view->PageToPixmap(pageNs[ap]-1, 100, pixmapFlags);
+                       thumb = 
ScCore->primaryMainWindow()->view->PageToPixmap(pageNs[ap] - 1, 100, 
pixmapFlags);
                thumbs.insert(pageNs[ap], thumb);
        }
 
@@ -1486,7 +1600,8 @@
        pdfOptions.useDocBleeds = self->useDocBleeds;
        if (self->useDocBleeds)
                pdfOptions.bleeds = 
ScCore->primaryMainWindow()->doc->bleedsVal();
-       else {
+       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());
@@ -1516,7 +1631,8 @@
 
        QString errorMessage;
        bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, pageNs, 
thumbs, errorMessage);
-       if (!success) {
+       if (!success)
+       {
                fn  = "Cannot write the File: " + fn;
                if (!errorMessage.isEmpty())
                        fn += QString("\n%1").arg(errorMessage);

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23926&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp      
(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/objpdffile.cpp      Fri Jul 
17 13:41:08 2020
@@ -140,129 +140,139 @@
 
 static PyObject * PDFfile_new(PyTypeObject *type, PyObject * /*args*/, 
PyObject * /*kwds*/)
 {
-// do not create new object if there is no opened document
-       if (!checkHaveDocument()) {
+       // 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
+       if (self)
+       {
+               // Set file attribute
                self->file = PyString_FromString("");
-               if (!self->file) {
+               if (!self->file)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set font embedding mode attribute
+               // Set font embedding mode attribute
                self->fontEmbedding = PyInt_FromLong(0);
-               if (!self->fontEmbedding) {
+               if (!self->fontEmbedding)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set fonts attribute
+               // Set fonts attribute
                self->fonts = PyList_New(0);
-               if (!self->fonts){
+               if (!self->fonts)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
                self->subsetList = PyList_New(0);
-               if (!self->subsetList){
+               if (!self->subsetList)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set pages attribute
+               // Set pages attribute
                self->pages = PyList_New(0);
-               if (self->pages == nullptr){
+               if (self->pages == nullptr)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set thumbnails attribute
+               // Set thumbnails attribute
                self->thumbnails = 0;
-// set cropMarks attribute
+               // Set cropMarks attribute
                self->cropMarks = 0;
-// set bleedMarks attribute
+               // Set bleedMarks attribute
                self->bleedMarks = 0;
-// set registrationMarks attribute
+               // Set registrationMarks attribute
                self->registrationMarks = 0;
-// set colorMarks attribute
+               // Set colorMarks attribute
                self->colorMarks = 0;
-// set docInfoMarks attribute
+               // Set docInfoMarks attribute
                self->docInfoMarks = 0;
-// set mark offset attribute
+               // Set mark offset attribute
                self->markOffset = 0;
-// set mark length attribute
+               // Set mark length attribute
                self->markLength = 0;
-// set compress attribute
+               // Set compress attribute
                self->compress = 0;
-// set compressmtd attribute
+               // Set compressmtd attribute
                self->compressmtd = 0;
-// set quality attribute
+               // Set quality attribute
                self->quality = 0;
-// set resolution attribute
+               // Set resolution attribute
                self->resolution = PyInt_FromLong(300);
-               if (!self->resolution){
+               if (!self->resolution)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set downsample attribute
+               // Set downsample attribute
                self->downsample = PyInt_FromLong(0);
-               if (!self->downsample){
+               if (!self->downsample)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set bookmarks attribute
+               // Set bookmarks attribute
                self->bookmarks = 0;
-// set binding attribute
+               // Set binding attribute
                self->binding = 0;
-// set presentation attribute
+               // Set presentation attribute
                self->presentation = 0;
-// set effval attribute
+               // Set effval attribute
                self->effval = PyList_New(0);
-               if (!self->effval){
+               if (!self->effval)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set article attribute
+               // Set article attribute
                self->article = 0;
-// set encrypt attribute
+               // Set encrypt attribute
                self->encrypt = 0;
-// set uselpi attribute
+               // Set uselpi attribute
                self->uselpi = 0;
                self->usespot = 1;
                self->domulti = 0;
-// set lpival attribute
+               // Set lpival attribute
                self->lpival = PyList_New(0);
-               if (!self->lpival){
+               if (!self->lpival)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set owner attribute
+               // Set owner attribute
                self->owner = PyString_FromString("");
-               if (!self->owner){
+               if (!self->owner)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set user attribute
+               // Set user attribute
                self->user = PyString_FromString("");
-               if (!self->user){
+               if (!self->user)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
-// set allowPrinting attribute
+               // Set allowPrinting attribute
                self->allowPrinting = 1;
-// set allowChange attribute
+               // Set allowChange attribute
                self->allowChange = 1;
-// set allowCopy attribute
+               // Set allowCopy attribute
                self->allowCopy = 1;
-// set allowAnnots attribute
+               // Set allowAnnots attribute
                self->allowAnnots = 1;
-// set version attribute
+               // Set version attribute
                self->version = 14;
-// set output attribute
+               // Set output attribute
                self->outdst = 0;
-
 
                self->profiles = 0; // bool
                self->profilei = 0; // bool
@@ -270,22 +280,26 @@
                self->intenti = 0; // int - 0 - ?
                self->noembicc = 0; // bool
                self->solidpr = PyString_FromString("");
-               if (!self->solidpr){
+               if (!self->solidpr)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
                self->imagepr = PyString_FromString("");
-               if (!self->imagepr){
+               if (!self->imagepr)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
                self->printprofc = PyString_FromString("");
-               if (!self->printprofc){
+               if (!self->printprofc)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
                self->info = PyString_FromString("");
-               if (!self->info){
+               if (!self->info)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
@@ -300,7 +314,8 @@
                self->mirrorV = 0;
                self->doClip = 0;
                self->rotateDeg = PyInt_FromLong(0);
-               if (!self->rotateDeg){
+               if (!self->rotateDeg)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
@@ -314,7 +329,8 @@
                self->hideMenuBar = 0;
                self->fitWindow = 0;
                self->openAction = PyString_FromString("");
-               if (!self->openAction){
+               if (!self->openAction)
+               {
                        Py_DECREF(self);
                        return nullptr;
                }
@@ -325,170 +341,192 @@
 static int PDFfile_init(PDFfile *self, PyObject * /*args*/, PyObject * 
/*kwds*/)
 {
        int i;
-       if (!checkHaveDocument()) {
-               return -1;
-       }
+       if (!checkHaveDocument())
+               return -1;
 
        ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
        PDFOptions& pdfOptions = currentDoc->pdfOptions();
 
-// defaut save into file
+       // Defaut save into file
        QString tf = pdfOptions.fileName;
-       if (tf.isEmpty()) {
+       if (tf.isEmpty())
+       {
                QFileInfo fi = QFileInfo(currentDoc->documentFileName());
                tf = fi.path() + "/" + fi.baseName() + ".pdf";
        }
-       PyObject *file = nullptr;
-       file = PyString_FromString(tf.toLatin1());
-       if (file){
+
+       PyObject *file = PyString_FromString(tf.toLatin1());
+       if (file)
+       {
                Py_DECREF(self->file);
                self->file = file;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'file' 
attribute");
                return -1;
        }
-// font embedding mode
-       PyObject *embeddingMode = nullptr;
-       embeddingMode = PyInt_FromLong(pdfOptions.FontEmbedding);
-       if (embeddingMode){
+
+       // Font embedding mode
+       PyObject *embeddingMode = PyInt_FromLong(pdfOptions.FontEmbedding);
+       if (embeddingMode)
+       {
                Py_DECREF(self->fontEmbedding);
                self->fontEmbedding = embeddingMode;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'fontEmbedding' attribute");
                return -1;
        }
-// embed all used fonts
-       PyObject *fonts = nullptr;
-       fonts = PyList_New(0);
-       if (fonts){
+
+       // Embed all used fonts
+       PyObject *fonts = PyList_New(0);
+       if (fonts)
+       {
                Py_DECREF(self->fonts);
                self->fonts = fonts;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'fonts' 
attribute");
                return -1;
        }
-       // get all used fonts
+
+       // Get all used fonts
        QMap<QString,int> ReallyUsed = currentDoc->UsedFonts;
-       // create list of all used fonts
+       // 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= nullptr;
-               tmp = PyString_FromString(fontName.toLatin1());
-               if (tmp) {
+               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
+                       // 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 {
+               else
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'fonts' attribute");
                        return -1;
                }
        }
-// init subsetList
+
+       // Init subsetList
        fonts = PyList_New(0);
-       if (fonts){
+       if (fonts)
+       {
                Py_DECREF(self->subsetList);
                self->subsetList = fonts;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'subsetList' attribute");
                return -1;
        }
-// copied from TabPDFOptions::restoreDefaults()
+
+       // 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) {
+               if (tmp)
+               {
                        PyList_Append(self->subsetList, tmp);
                        Py_DECREF(tmp);
                }
-               else {
+               else
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'subsetList' attribute");
                        return -1;
                }
        }
 
-// set to print all pages
-       PyObject *pages = nullptr;
-       // which one should I use ???
-       // new = ScCore->primaryMainWindow()->view->Pages.count()
+       // Set to print all pages
        int num = currentDoc->Pages->count();
-       pages = PyList_New(num);
-       if (!pages){
+       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;
-               tmp = PyInt_FromLong((long)i+1L);
+       for (i = 0; i < num; ++i)
+       {
+               PyObject *tmp = PyInt_FromLong((long)i + 1L);
                if (tmp)
                        PyList_SetItem(pages, i, tmp);
-               else {
+               else
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'pages' attribute");
                        return -1;
                }
        }
        Py_DECREF(self->pages);
        self->pages = pages;
-// print thumbnails ?
+       // Print thumbnails ?
        self->thumbnails = pdfOptions.Thumbnails;
-// output crop marks ?
+       // Output crop marks ?
        self->cropMarks = pdfOptions.cropMarks;
-// output bleed marks ?
+       // Output bleed marks ?
        self->bleedMarks = pdfOptions.bleedMarks;
-// output registration marks ?
+       // Output registration marks ?
        self->registrationMarks = pdfOptions.registrationMarks;
-// output color bars ?
+       // Output color bars ?
        self->colorMarks = pdfOptions.colorMarks;
-// output doc info marks ?
+       // Output doc info marks ?
        self->docInfoMarks = pdfOptions.docInfoMarks;
-// cropmarks offset 
+       // Cropmarks offset 
        self->markOffset = pdfOptions.markOffset * currentDoc->unitRatio();
-// cropmarks length 
+       // Cropmarks length 
        self->markLength = pdfOptions.markLength * currentDoc->unitRatio();
-// set automatic compression
+       // Set automatic compression
        self->compress = pdfOptions.Compress;
        self->compressmtd = pdfOptions.CompressMethod;
-// use maximum image quality
+       // Use maximum image quality
        self->quality = pdfOptions.Quality;
-// default resolution
+       // Default resolution
        PyObject *resolution = nullptr;
        resolution = PyInt_FromLong(300);
-       if (resolution){
+       if (resolution)
+       {
                Py_DECREF(self->resolution);
                self->resolution = resolution;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'resolution' attribute");
                return -1;
        }
-// do not downsample images
+       // Do not downsample images
        int down = pdfOptions.RecalcPic ? pdfOptions.PicRes : 0;
        PyObject *downsample = nullptr;
        downsample = PyInt_FromLong(down);
-       if (downsample){
+       if (downsample)
+       {
                Py_DECREF(self->downsample);
                self->downsample = downsample;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'downsamle' attribute");
                return -1;
        }
-       // no bookmarks
+       // No bookmarks
        self->bookmarks = pdfOptions.Bookmarks;
-       // left margin binding
+       // Left margin binding
        self->binding = pdfOptions.Binding;
-       // do not enable presentation effects
+       // Do not enable presentation effects
        self->presentation = pdfOptions.PresentMode;
-       // set effects values for all pages
+       // Set effects values for all pages
        PyObject *effval = nullptr;
-       // which one should I use ???
-       // new = ScCore->primaryMainWindow()->view->Pages.count();
        num = currentDoc->Pages->count();
        effval = PyList_New(num);
-       if (!effval){
+       if (!effval)
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' 
attribute");
                return -1;
        }
@@ -499,16 +537,18 @@
                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 {
+               else
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'effval' attribute");
                        return -1;
                }
-               for (; i<num; ++i) {
-                       PyObject *tmp;
-                       tmp = Py_BuildValue(const_cast<char*>("[iiiiii]"), 1, 
1, 0, 0, 0, 0);
+               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 {
+                       else
+                       {
                                PyErr_SetString(PyExc_SystemError, "Can not 
initialize 'effval' attribute");
                                return -1;
                        }
@@ -516,26 +556,29 @@
        }
        Py_DECREF(self->effval);
        self->effval = effval;
-// do not save linked text frames as PDF article
+       // Do not save linked text frames as PDF article
        self->article = pdfOptions.Articles;
-// do not encrypt file
+       // Do not encrypt file
        self->encrypt = pdfOptions.Encrypt;
-// do not Use Custom Rendering Settings
+       // Do not Use Custom Rendering Settings
        self->uselpi = pdfOptions.UseLPI;
        self->usespot = pdfOptions.UseSpotColors;
        self->domulti = pdfOptions.doMultiFile;
-// get default values for lpival
+       // Get default values for lpival
        int n = pdfOptions.LPISettings.size();
        PyObject *lpival=PyList_New(n);
-       if (!lpival){
+       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()) {
+       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) {
+               if (!tmp)
+               {
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 
'lpival' attribute");
                        return -1;
                }
@@ -545,37 +588,41 @@
        PyList_Reverse(lpival);
        Py_DECREF(self->lpival);
        self->lpival = lpival;
-// set owner's password
-       PyObject *owner = nullptr;
-       owner = PyString_FromString(pdfOptions.PassOwner.toLatin1());
-       if (owner){
+       // Set owner's password
+       PyObject *owner = PyString_FromString(pdfOptions.PassOwner.toLatin1());
+       if (owner)
+       {
                Py_DECREF(self->owner);
                self->owner = owner;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'owner' 
attribute");
                return -1;
        }
-// set user'a password
-       PyObject *user = nullptr;
-       user = PyString_FromString(pdfOptions.PassUser.toLatin1());
-       if (user){
+       // Set user'a password
+       PyObject *user = PyString_FromString(pdfOptions.PassUser.toLatin1());
+       if (user)
+       {
                Py_DECREF(self->user);
                self->user = user;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'user' 
attribute");
                return -1;
        }
-// allow printing document
+       // Allow printing document
        self->allowPrinting = pdfOptions.Permissions & 4;
-// allow changing document
+       // Allow changing document
        self->allowChange = pdfOptions.Permissions & 8;
-// allow copying document
+       // Allow copying document
        self->allowCopy = pdfOptions.Permissions & 16;
-// allow adding annotation and fields
+       // Allow adding annotation and fields
        self->allowAnnots = pdfOptions.Permissions & 32;
-// use 1.4 pdf version *aka. Acrobat 5)
+       // Use 1.4 pdf version *aka. Acrobat 5)
        self->version = pdfOptions.Version;
-// output destination is screen
+       // Output destination is screen
        self->outdst = pdfOptions.UseRGB ? 0 : 1;
 
        self->profiles = pdfOptions.UseProfiles; // bool
@@ -586,24 +633,28 @@
        QString tp = pdfOptions.SolidProf;
        if (!ScCore->InputProfiles.contains(tp))
                tp = currentDoc->cmsSettings().DefaultSolidColorRGBProfile;
-       PyObject *solidpr = nullptr;
-       solidpr = PyString_FromString(tp.toLatin1());
-       if (solidpr){
+       PyObject *solidpr = PyString_FromString(tp.toLatin1());
+       if (solidpr)
+       {
                Py_DECREF(self->solidpr);
                self->solidpr = solidpr;
-       } else {
+       }
+       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 = nullptr;
-       imagepr = PyString_FromString(tp2.toLatin1());
-       if (imagepr){
+       PyObject *imagepr = PyString_FromString(tp2.toLatin1());
+       if (imagepr)
+       {
                Py_DECREF(self->imagepr);
                self->imagepr = imagepr;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'imagepr' attribute");
                return -1;
        }
@@ -612,20 +663,25 @@
                tp3 = currentDoc->cmsSettings().DefaultPrinterProfile;
        PyObject *printprofc = nullptr;
        printprofc = PyString_FromString(tp3.toLatin1());
-       if (printprofc){
+       if (printprofc)
+       {
                Py_DECREF(self->printprofc);
                self->printprofc = printprofc;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'printprofc' attribute");
                return -1;
        }
        QString tinfo = pdfOptions.Info;
-       PyObject *info = nullptr;
-       info = PyString_FromString(tinfo.toLatin1());
-       if (info){
+       PyObject *info = PyString_FromString(tinfo.toLatin1());
+       if (info)
+       {
                Py_DECREF(self->info);
                self->info = info;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'info' 
attribute");
                return -1;
        }
@@ -639,12 +695,14 @@
        self->mirrorH = pdfOptions.MirrorH; // bool
        self->mirrorV = pdfOptions.MirrorV; // bool
        self->doClip = pdfOptions.doClip; // bool
-       PyObject *rotateDeg = nullptr;
-       rotateDeg = PyInt_FromLong(0);
-       if (rotateDeg){
+       PyObject *rotateDeg = PyInt_FromLong(0);
+       if (rotateDeg)
+       {
                Py_DECREF(self->rotateDeg);
                self->rotateDeg = rotateDeg;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'rotateDeg' attribute");
                return -1;
        }
@@ -658,12 +716,14 @@
        self->hideMenuBar = pdfOptions.hideMenuBar; // bool
        self->fitWindow = pdfOptions.fitWindow; // bool
 
-       PyObject *openAction = nullptr;
-       openAction = 
PyString_FromString(pdfOptions.openAction.toLatin1().data());
-       if (openAction){
+       PyObject *openAction = 
PyString_FromString(pdfOptions.openAction.toLatin1().data());
+       if (openAction)
+       {
                Py_DECREF(self->openAction);
                self->openAction = openAction;
-       } else {
+       }
+       else
+       {
                PyErr_SetString(PyExc_SystemError, "Can not initialize 
'openAction' attribute");
                return -1;
        }
@@ -745,11 +805,13 @@
 
 static int PDFfile_setfile(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'file' 
attribute.");
                return -1;
        }
-       if (!PyString_Check(value)) {
+       if (!PyString_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'file' attribute value 
must be string.");
                return -1;
        }
@@ -767,16 +829,19 @@
 
 static int PDFfile_setFontEmbeddingMode(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'fontEmbedding' 
attribute.");
                return -1;
        }
-       if (!PyInt_Check(value)) {
+       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) {
+       if (n < 0 || n > 2)
+       {
                PyErr_SetString(PyExc_ValueError, "'fontEmbedding' value must 
be an integer between 0 and 2");
                return -1;
        }
@@ -794,24 +859,28 @@
 
 static int PDFfile_setfonts(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'fonts' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       if (!PyList_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'fonts' attribute value 
must be list of strings.");
                return -1;
        }
-       int n;
-       n = PyList_Size(value);
-       for (int i=0; i<n; ++i)
-               if (!PyString_Check(PyList_GetItem(value, i))) {
+       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
+       }
+       // 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;
@@ -827,21 +896,25 @@
 
 static int PDFfile_setSubsetList(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'subsetList' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       if (!PyList_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'subsetList' attribute 
value must be list of strings.");
                return -1;
        }
-       int n;
-       n = PyList_Size(value);
-       for (int i=0; i<n; ++i)
-               if (!PyString_Check(PyList_GetItem(value, i))) {
+       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;
@@ -857,25 +930,30 @@
 
 static int PDFfile_setpages(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'pages' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       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++){
+       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)){
+               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) {
+               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;
                }
@@ -895,16 +973,19 @@
 
 static int PDFfile_setresolution(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'resolution' 
attribute.");
                return -1;
        }
-       if (!PyInt_Check(value)) {
+       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) {
+       if (n < 35 || n > 4000)
+       {
                PyErr_SetString(PyExc_ValueError, "'resolution' value must be 
in interval from 35 to 4000");
                return -1;
        }
@@ -922,16 +1003,19 @@
 
 static int PDFfile_setdownsample(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'downsample' 
attribute.");
                return -1;
        }
-       if (!PyInt_Check(value)) {
+       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))) {
+       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;
        }
@@ -949,28 +1033,35 @@
 
 static int PDFfile_seteffval(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'effval' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       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) {
+       for (int i = 0; i < n; ++i)
+       {
                PyObject *tmp = PyList_GetItem(value, i);
-               if (!PyList_Check(tmp)) {
+               if (!PyList_Check(tmp))
+               {
                        PyErr_SetString(PyExc_TypeError, "elemets of 'effval' 
must be list of five integers.");
                        return -1;
                }
                int j = PyList_Size(tmp);
-               if (j != 6) {
+               if (j != 6)
+               {
                        PyErr_SetString(PyExc_TypeError, "elemets of 'effval' 
must have exactly six integers.");
                        return -1;
                }
-               for ( --j; j > -1; --j) {
-                       if (!PyInt_Check(PyList_GetItem(tmp, j))) {
+               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;
                        }
@@ -990,34 +1081,42 @@
 
 static int PDFfile_setlpival(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'lpival' 
attribute.");
                return -1;
        }
-       if (!PyList_Check(value)) {
+       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) {
+       for (int i = 0; i < n; ++i)
+       {
                PyObject *tmp = PyList_GetItem(value, i);
-               if (!PyList_Check(tmp)) {
+               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) {
+               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))) {
+               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))) {
+               if (!PyString_Check(PyList_GetItem(tmp, 0)))
+               {
                        PyErr_SetString(PyExc_TypeError, "'lpival'elements must 
have structure [siii]");
                        return -1;
                }
@@ -1036,11 +1135,13 @@
 
 static int PDFfile_setowner(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'owner' 
attribute.");
                return -1;
        }
-       if (!PyString_Check(value)) {
+       if (!PyString_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'owner' attribute value must 
be string.");
                return -1;
        }
@@ -1058,11 +1159,13 @@
 
 static int PDFfile_setuser(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'user' 
attribute.");
                return -1;
        }
-       if (!PyString_Check(value)) {
+       if (!PyString_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'user' attribute value must 
be string.");
                return -1;
        }
@@ -1080,11 +1183,13 @@
 
 static int PDFfile_setsolidpr(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'solidpr' 
attribute.");
                return -1;
        }
-       if (!PyString_Check(value)) {
+       if (!PyString_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'solidpr' attribute value 
must be string.");
                return -1;
        }
@@ -1102,11 +1207,13 @@
 
 static int PDFfile_setimagepr(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'imagepr' 
attribute.");
                return -1;
        }
-       if (!PyString_Check(value)) {
+       if (!PyString_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'imagepr' attribute value 
must be string.");
                return -1;
        }
@@ -1124,11 +1231,13 @@
 
 static int PDFfile_setprintprofc(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'printprofc' 
attribute.");
                return -1;
        }
-       if (!PyString_Check(value)) {
+       if (!PyString_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'printprofc' attribute 
value must be string.");
                return -1;
        }
@@ -1146,11 +1255,13 @@
 
 static int PDFfile_setinfo(PDFfile *self, PyObject *value, void * /*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'info' 
attribute.");
                return -1;
        }
-       if (!PyString_Check(value)) {
+       if (!PyString_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "The 'info' attribute value 
must be string.");
                return -1;
        }
@@ -1168,16 +1279,19 @@
 
 static int PDFfile_setRotateDeg(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'rotateDeg' 
attribute.");
                return -1;
        }
-       if (!PyInt_Check(value)) {
+       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) {
+       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;
        }
@@ -1195,11 +1309,13 @@
 
 static int PDFfile_setopenAction(PDFfile *self, PyObject *value, void * 
/*closure*/)
 {
-       if (value == nullptr) {
+       if (value == nullptr)
+       {
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'openAction' 
attribute.");
                return -1;
        }
-       if (!PyString_Check(value)) {
+       if (!PyString_Check(value))
+       {
                PyErr_SetString(PyExc_TypeError, "'openAction' attribute value 
must be string.");
                return -1;
        }
@@ -1252,9 +1368,8 @@
 
 static PyObject *PDFfile_save(PDFfile *self)
 {
-       if (!checkHaveDocument()) {
+       if (!checkHaveDocument())
                return nullptr;
-       }
 
        ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
        PDFOptions& pdfOptions = currentDoc->pdfOptions();
@@ -1324,14 +1439,13 @@
                pdfOptions.OutlineList = QStringList();
        }
        // Apply file attribute
-       QString fn;
-       fn = QString(PyString_AsString(self->file));
+       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)));
+               pageNs.push_back((int) PyInt_AsLong(PyList_GetItem(self->pages, 
i)));
        }
        // Apply thumbnails attribute
        pdfOptions.Thumbnails = self->thumbnails;
@@ -1387,8 +1501,8 @@
                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)
@@ -1476,7 +1590,7 @@
        {
                QImage thumb(10, 10, QImage::Format_ARGB32_Premultiplied );
                if (pdfOptions.Thumbnails)
-                       thumb = 
ScCore->primaryMainWindow()->view->PageToPixmap(pageNs[ap]-1, 100, pixmapFlags);
+                       thumb = 
ScCore->primaryMainWindow()->view->PageToPixmap(pageNs[ap] - 1, 100, 
pixmapFlags);
                thumbs.insert(pageNs[ap], thumb);
        }
 
@@ -1486,7 +1600,8 @@
        pdfOptions.useDocBleeds = self->useDocBleeds;
        if (self->useDocBleeds)
                pdfOptions.bleeds = 
ScCore->primaryMainWindow()->doc->bleedsVal();
-       else {
+       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());
@@ -1516,7 +1631,8 @@
 
        QString errorMessage;
        bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, pageNs, 
thumbs, errorMessage);
-       if (!success) {
+       if (!success)
+       {
                fn  = "Cannot write the File: " + fn;
                if (!errorMessage.isEmpty())
                        fn += QString("\n%1").arg(errorMessage);


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to