00001
00002
00003
00004
00005
00006
00007 #include "objpdffile.h"
00008 #include "cmdutil.h"
00009 #include "bookmarkpalette.h"
00010 #include "prefsmanager.h"
00011 #include "scribusdoc.h"
00012 #include "scribuscore.h"
00013
00014 #include <structmember.h>
00015 #include <QFileInfo>
00016 #include <QList>
00017 #include <QPixmap>
00018 #include <vector>
00019
00020
00021 void SCRIBUS_API ReOrderText(ScribusDoc *doc, ScribusView *view);
00022
00023
00024
00025
00026 static int minmaxi(int val, int min, int max)
00027 {
00028 if (val < min)
00029 return min;
00030 else if (val > max)
00031 return max;
00032 else return val;
00033 }
00034
00035 static double minmaxd(double val, double min, double max)
00036 {
00037 if (val < min)
00038 return min;
00039 else if (val > max)
00040 return max;
00041 else return val;
00042 }
00043
00044 typedef struct
00045 {
00046 PyObject_HEAD
00047 PyObject *file;
00048 PyObject *fonts;
00049 PyObject *pages;
00050 int thumbnails;
00051 int compress;
00052 int compressmtd;
00053 int quality;
00054 PyObject *resolution;
00055 PyObject *downsample;
00056 int bookmarks;
00057 int binding;
00058 int presentation;
00059 PyObject *effval;
00060 int article;
00061 int encrypt;
00062 int uselpi;
00063 int usespot;
00064 int domulti;
00065 PyObject *lpival;
00066 PyObject *owner;
00067 PyObject *user;
00068 int aprint;
00069 int achange;
00070 int acopy;
00071 int aanot;
00072 int version;
00073 int outdst;
00074
00075 int profiles;
00076 int profilei;
00077 int intents;
00078 int intenti;
00079 int noembicc;
00080 PyObject *solidpr;
00081 PyObject *imagepr;
00082 PyObject *printprofc;
00083 PyObject *info;
00084 double bleedt;
00085 double bleedl;
00086 double bleedr;
00087 double bleedb;
00088
00089 } PDFfile;
00090
00091 static void PDFfile_dealloc(PDFfile *self)
00092 {
00093 Py_XDECREF(self->file);
00094 Py_XDECREF(self->fonts);
00095 Py_XDECREF(self->pages);
00096 Py_XDECREF(self->resolution);
00097 Py_XDECREF(self->downsample);
00098 Py_XDECREF(self->effval);
00099 Py_XDECREF(self->lpival);
00100 Py_XDECREF(self->owner);
00101 Py_XDECREF(self->user);
00102 Py_XDECREF(self->solidpr);
00103 Py_XDECREF(self->imagepr);
00104 Py_XDECREF(self->printprofc);
00105 Py_XDECREF(self->info);
00106 self->ob_type->tp_free((PyObject *)self);
00107 }
00108
00109 static PyObject * PDFfile_new(PyTypeObject *type, PyObject * , PyObject * )
00110 {
00111
00112 if (!ScCore->primaryMainWindow()->HaveDoc) {
00113 PyErr_SetString(PyExc_SystemError, "Need to open document first");
00114 return NULL;
00115 }
00116
00117 PDFfile *self;
00118
00119 self = (PDFfile *)type->tp_alloc(type, 0);
00120 if (self) {
00121
00122 self->file = PyString_FromString("");
00123 if (!self->file){
00124 Py_DECREF(self);
00125 return NULL;
00126 }
00127
00128 self->fonts = PyList_New(0);
00129 if (!self->fonts){
00130 Py_DECREF(self);
00131 return NULL;
00132 }
00133
00134 self->pages = PyList_New(0);
00135 if (self->pages == NULL){
00136 Py_DECREF(self);
00137 return NULL;
00138 }
00139
00140 self->thumbnails = 0;
00141
00142 self->compress = 0;
00143
00144 self->compressmtd = 0;
00145
00146 self->quality = 0;
00147
00148 self->resolution = PyInt_FromLong(300);
00149 if (!self->resolution){
00150 Py_DECREF(self);
00151 return NULL;
00152 }
00153
00154 self->downsample = PyInt_FromLong(0);
00155 if (!self->downsample){
00156 Py_DECREF(self);
00157 return NULL;
00158 }
00159
00160 self->bookmarks = 0;
00161
00162 self->binding = 0;
00163
00164 self->presentation = 0;
00165
00166 self->effval = PyList_New(0);
00167 if (!self->effval){
00168 Py_DECREF(self);
00169 return NULL;
00170 }
00171
00172 self->article = 0;
00173
00174 self->encrypt = 0;
00175
00176 self->uselpi = 0;
00177 self->usespot = 1;
00178 self->domulti = 0;
00179
00180 self->lpival = PyList_New(0);
00181 if (!self->lpival){
00182 Py_DECREF(self);
00183 return NULL;
00184 }
00185
00186 self->owner = PyString_FromString("");
00187 if (!self->owner){
00188 Py_DECREF(self);
00189 return NULL;
00190 }
00191
00192 self->user = PyString_FromString("");
00193 if (!self->user){
00194 Py_DECREF(self);
00195 return NULL;
00196 }
00197
00198 self->aprint = 1;
00199
00200 self->achange = 1;
00201
00202 self->acopy = 1;
00203
00204 self->aanot = 1;
00205
00206 self->version = 14;
00207
00208 self->outdst = 0;
00209
00210
00211 self->profiles = 0;
00212 self->profilei = 0;
00213 self->intents = 0;
00214 self->intenti = 0;
00215 self->noembicc = 0;
00216 self->solidpr = PyString_FromString("");
00217 if (!self->solidpr){
00218 Py_DECREF(self);
00219 return NULL;
00220 }
00221 self->imagepr = PyString_FromString("");
00222 if (!self->imagepr){
00223 Py_DECREF(self);
00224 return NULL;
00225 }
00226 self->printprofc = PyString_FromString("");
00227 if (!self->printprofc){
00228 Py_DECREF(self);
00229 return NULL;
00230 }
00231 self->info = PyString_FromString("");
00232 if (!self->info){
00233 Py_DECREF(self);
00234 return NULL;
00235 }
00236 self->bleedt = 0;
00237 self->bleedl = 0;
00238 self->bleedr = 0;
00239 self->bleedb = 0;
00240 }
00241 return (PyObject *) self;
00242 }
00243
00244 static int PDFfile_init(PDFfile *self, PyObject * , PyObject * )
00245 {
00246 int i;
00247 if (!ScCore->primaryMainWindow()->HaveDoc) {
00248 PyErr_SetString(PyExc_SystemError, "Must open doc first");
00249 return -1;
00250 }
00251
00252 QString tf = ScCore->primaryMainWindow()->doc->PDF_Options.Datei;
00253 if (tf.isEmpty()) {
00254 QFileInfo fi = QFileInfo(ScCore->primaryMainWindow()->doc->DocName);
00255 tf = fi.path()+"/"+fi.baseName()+".pdf";
00256 }
00257 PyObject *file = NULL;
00258 file = PyString_FromString(tf.toAscii());
00259 if (file){
00260 Py_DECREF(self->file);
00261 self->file = file;
00262 } else {
00263 PyErr_SetString(PyExc_SystemError, "Can not initialize 'file' attribute");
00264 return -1;
00265 }
00266
00267 PyObject *fonts = NULL;
00268 fonts = PyList_New(0);
00269 if (fonts){
00270 Py_DECREF(self->fonts);
00271 self->fonts = fonts;
00272 } else {
00273 PyErr_SetString(PyExc_SystemError, "Can not initialize 'fonts' attribute");
00274 return -1;
00275 }
00276
00277 QMap<QString,int> ReallyUsed = ScCore->primaryMainWindow()->doc->UsedFonts;
00278
00279 QList<QString> tmpEm;
00280 tmpEm = ReallyUsed.keys();
00281 QList<QString>::Iterator itef;
00282 for (itef = tmpEm.begin(); itef != tmpEm.end(); ++itef) {
00283
00284
00285 PyObject *tmp= NULL;
00286 tmp = PyString_FromString((*itef).toAscii());
00287 if (tmp) {
00288 PyList_Append(self->fonts, tmp);
00289
00290
00291
00292 Py_DECREF(tmp);
00293 }
00294 else {
00295 PyErr_SetString(PyExc_SystemError, "Can not initialize 'fonts' attribute");
00296 return -1;
00297 }
00298
00299 }
00300
00301 PyObject *pages = NULL;
00302 int num = 0;
00303
00304
00305 num = ScCore->primaryMainWindow()->doc->Pages->count();
00306 pages = PyList_New(num);
00307 if (!pages){
00308 PyErr_SetString(PyExc_SystemError, "Can not initialize 'pages' attribute");
00309 return -1;
00310 }
00311 for (i = 0; i<num; ++i) {
00312 PyObject *tmp;
00313 tmp = PyInt_FromLong((long)i+1L);
00314 if (tmp)
00315 PyList_SetItem(pages, i, tmp);
00316 else {
00317 PyErr_SetString(PyExc_SystemError, "Can not initialize 'pages' attribute");
00318 return -1;
00319 }
00320 }
00321 Py_DECREF(self->pages);
00322 self->pages = pages;
00323
00324 self->thumbnails = ScCore->primaryMainWindow()->doc->PDF_Options.Thumbnails;
00325
00326 self->compress = ScCore->primaryMainWindow()->doc->PDF_Options.Compress;
00327 self->compressmtd = ScCore->primaryMainWindow()->doc->PDF_Options.CompressMethod;
00328
00329 self->quality = ScCore->primaryMainWindow()->doc->PDF_Options.Quality;
00330
00331 PyObject *resolution = NULL;
00332 resolution = PyInt_FromLong(300);
00333 if (resolution){
00334 Py_DECREF(self->resolution);
00335 self->resolution = resolution;
00336 } else {
00337 PyErr_SetString(PyExc_SystemError, "Can not initialize 'resolutin' attribute");
00338 return -1;
00339 }
00340
00341 int down = ScCore->primaryMainWindow()->doc->PDF_Options.RecalcPic ? ScCore->primaryMainWindow()->doc->PDF_Options.PicRes : 0;
00342 PyObject *downsample = NULL;
00343 downsample = PyInt_FromLong(down);
00344 if (downsample){
00345 Py_DECREF(self->downsample);
00346 self->downsample = downsample;
00347 } else {
00348 PyErr_SetString(PyExc_SystemError, "Can not initialize 'downsamle' attribute");
00349 return -1;
00350 }
00351
00352 self->bookmarks = ScCore->primaryMainWindow()->doc->PDF_Options.Bookmarks;
00353
00354 self->binding = ScCore->primaryMainWindow()->doc->PDF_Options.Binding;
00355
00356 self->presentation = ScCore->primaryMainWindow()->doc->PDF_Options.PresentMode;
00357
00358 PyObject *effval = NULL;
00359 num = 0;
00360
00361
00362 num = ScCore->primaryMainWindow()->doc->Pages->count();
00363 effval = PyList_New(num);
00364 if (!effval){
00365 PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' attribute");
00366 return -1;
00367 }
00368 int num2 = ScCore->primaryMainWindow()->doc->PDF_Options.PresentVals.count();
00369 for (i = 0; i<num2; ++i) {
00370 PyObject *tmp;
00371 PDFPresentationData t = ScCore->primaryMainWindow()->doc->PDF_Options.PresentVals[i];
00372 tmp = Py_BuildValue(const_cast<char*>("[iiiiii]"), t.pageEffectDuration, t.pageViewDuration, t.effectType, t.Dm, t.M, t.Di );
00373 if (tmp)
00374 PyList_SetItem(effval, i, tmp);
00375 else {
00376 PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' attribute");
00377 return -1;
00378 }
00379 for (; i<num; ++i) {
00380 PyObject *tmp;
00381 tmp = Py_BuildValue(const_cast<char*>("[iiiiii]"), 1, 1, 0, 0, 0, 0);
00382 if (tmp)
00383 PyList_SetItem(effval, i, tmp);
00384 else {
00385 PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' attribute");
00386 return -1;
00387 }
00388 }
00389 }
00390 Py_DECREF(self->effval);
00391 self->effval = effval;
00392
00393 self->article = ScCore->primaryMainWindow()->doc->PDF_Options.Articles;
00394
00395 self->encrypt = ScCore->primaryMainWindow()->doc->PDF_Options.Encrypt;
00396
00397 self->uselpi = ScCore->primaryMainWindow()->doc->PDF_Options.UseLPI;
00398 self->usespot = ScCore->primaryMainWindow()->doc->PDF_Options.UseSpotColors;
00399 self->domulti = ScCore->primaryMainWindow()->doc->PDF_Options.doMultiFile;
00400
00401 int n = ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings.size();
00402 PyObject *lpival=PyList_New(n);
00403 if (!lpival){
00404 PyErr_SetString(PyExc_SystemError, "Can not initialize 'lpival' attribute");
00405 return -1;
00406 }
00407 QMap<QString,LPIData>::Iterator it = ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings.begin();
00408 while (it != ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings.end()) {
00409 PyObject *tmp;
00410 tmp = Py_BuildValue(const_cast<char*>("[siii]"), it.key().toAscii().constData(), it.value().Frequency, it.value().Angle, it.value().SpotFunc);
00411 if (!tmp) {
00412 PyErr_SetString(PyExc_SystemError, "Can not initialize 'lpival' attribute");
00413 return -1;
00414 }
00415 PyList_SetItem(lpival, --n, tmp);
00416 ++it;
00417 }
00418 PyList_Reverse(lpival);
00419 Py_DECREF(self->lpival);
00420 self->lpival = lpival;
00421
00422 PyObject *owner = NULL;
00423 owner = PyString_FromString(ScCore->primaryMainWindow()->doc->PDF_Options.PassOwner.toAscii());
00424 if (owner){
00425 Py_DECREF(self->owner);
00426 self->owner = owner;
00427 } else {
00428 PyErr_SetString(PyExc_SystemError, "Can not initialize 'owner' attribute");
00429 return -1;
00430 }
00431
00432 PyObject *user = NULL;
00433 user = PyString_FromString(ScCore->primaryMainWindow()->doc->PDF_Options.PassUser.toAscii());
00434 if (user){
00435 Py_DECREF(self->user);
00436 self->user = user;
00437 } else {
00438 PyErr_SetString(PyExc_SystemError, "Can not initialize 'user' attribute");
00439 return -1;
00440 }
00441
00442 self->aprint = ScCore->primaryMainWindow()->doc->PDF_Options.Permissions & 4;
00443
00444 self->achange = ScCore->primaryMainWindow()->doc->PDF_Options.Permissions & 8;
00445
00446 self->acopy = ScCore->primaryMainWindow()->doc->PDF_Options.Permissions & 16;
00447
00448 self->aanot = ScCore->primaryMainWindow()->doc->PDF_Options.Permissions & 32;
00449
00450 self->version = ScCore->primaryMainWindow()->doc->PDF_Options.Version;
00451
00452 self->outdst = ScCore->primaryMainWindow()->doc->PDF_Options.UseRGB ? 0 : 1;
00453
00454 self->profiles = ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles;
00455 self->profilei = ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2;
00456 self->noembicc = ScCore->primaryMainWindow()->doc->PDF_Options.EmbeddedI;
00457 self->intents = ScCore->primaryMainWindow()->doc->PDF_Options.Intent;
00458 self->intenti = ScCore->primaryMainWindow()->doc->PDF_Options.Intent2;
00459 QString tp = ScCore->primaryMainWindow()->doc->PDF_Options.SolidProf;
00460 if (!ScCore->InputProfiles.contains(tp))
00461 tp = ScCore->primaryMainWindow()->view->Doc->CMSSettings.DefaultSolidColorRGBProfile;
00462 PyObject *solidpr = NULL;
00463 solidpr = PyString_FromString(tp.toAscii());
00464 if (solidpr){
00465 Py_DECREF(self->solidpr);
00466 self->solidpr = solidpr;
00467 } else {
00468 PyErr_SetString(PyExc_SystemError, "Can not initialize 'solidpr' attribute");
00469 return -1;
00470 }
00471 QString tp2 = ScCore->primaryMainWindow()->doc->PDF_Options.ImageProf;
00472 if (!ScCore->InputProfiles.contains(tp2))
00473 tp2 = ScCore->primaryMainWindow()->view->Doc->CMSSettings.DefaultSolidColorRGBProfile;
00474 PyObject *imagepr = NULL;
00475 imagepr = PyString_FromString(tp2.toAscii());
00476 if (imagepr){
00477 Py_DECREF(self->imagepr);
00478 self->imagepr = imagepr;
00479 } else {
00480 PyErr_SetString(PyExc_SystemError, "Can not initialize 'imagepr' attribute");
00481 return -1;
00482 }
00483 QString tp3 = ScCore->primaryMainWindow()->doc->PDF_Options.PrintProf;
00484 if (!ScCore->PDFXProfiles.contains(tp3))
00485 tp3 = ScCore->primaryMainWindow()->view->Doc->CMSSettings.DefaultPrinterProfile;
00486 PyObject *printprofc = NULL;
00487 printprofc = PyString_FromString(tp3.toAscii());
00488 if (printprofc){
00489 Py_DECREF(self->printprofc);
00490 self->printprofc = printprofc;
00491 } else {
00492 PyErr_SetString(PyExc_SystemError, "Can not initialize 'printprofc' attribute");
00493 return -1;
00494 }
00495 QString tinfo = ScCore->primaryMainWindow()->doc->PDF_Options.Info;
00496 PyObject *info = NULL;
00497 info = PyString_FromString(tinfo.toAscii());
00498 if (info){
00499 Py_DECREF(self->info);
00500 self->info = info;
00501 } else {
00502 PyErr_SetString(PyExc_SystemError, "Can not initialize 'info' attribute");
00503 return -1;
00504 }
00505 self->bleedt = ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Top*ScCore->primaryMainWindow()->doc->unitRatio();
00506 self->bleedl = ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Left*ScCore->primaryMainWindow()->doc->unitRatio();
00507 self->bleedr = ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Right*ScCore->primaryMainWindow()->doc->unitRatio();
00508 self->bleedb = ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Bottom*ScCore->primaryMainWindow()->doc->unitRatio();
00509
00510 return 0;
00511 }
00512
00513 static PyMemberDef PDFfile_members[] = {
00514 {const_cast<char*>("thumbnails"), T_INT, offsetof(PDFfile, thumbnails), 0, const_cast<char*>("Generate thumbnails. Bool value.")},
00515 {const_cast<char*>("compress"), T_INT, offsetof(PDFfile, compress), 0, const_cast<char*>("Compression switch. Bool value.")},
00516 {const_cast<char*>("compressmtd"), T_INT, offsetof(PDFfile, compressmtd), 0, const_cast<char*>("Compression method.\n\t0 - Automatic\n\t1 - JPEG\n\t2 - zip\n\t3 - None.")},
00517 {const_cast<char*>("quality"), T_INT, offsetof(PDFfile, quality), 0, const_cast<char*>("Image quality\n\t0 - Maximum\n\t1 - High\n\t2 - Medium\n\t3 - Low\n\t4 - Minimum")},
00518 {const_cast<char*>("bookmarks"), T_INT, offsetof(PDFfile, bookmarks), 0, const_cast<char*>("Embed the bookmarks you created in your document.\nThese are useful for navigating long PDF documents.\nBool value")},
00519 {const_cast<char*>("binding"), T_INT, offsetof(PDFfile, binding), 0, const_cast<char*>("Choose binding.\n\t0 - Left binding\n\t1 - Right binding")},
00520 {const_cast<char*>("presentation"), T_INT, offsetof(PDFfile, presentation), 0, const_cast<char*>("Enable Presentation Effects.Bool value")},
00521 {const_cast<char*>("article"), T_INT, offsetof(PDFfile, article), 0, const_cast<char*>("Save Linked Text Frames as PDF Articles\n\tBool value")},
00522 {const_cast<char*>("encrypt"), T_INT, offsetof(PDFfile, encrypt), 0, const_cast<char*>("Use Encription. Bool value")},
00523 {const_cast<char*>("uselpi"), T_INT, offsetof(PDFfile, uselpi), 0, const_cast<char*>("Use Custom Rendering Settings. Bool value")},
00524 {const_cast<char*>("usespot"), T_INT, offsetof(PDFfile, usespot), 0, const_cast<char*>("Use Spot Colors. Bool value")},
00525 {const_cast<char*>("domulti"), T_INT, offsetof(PDFfile, domulti), 0, const_cast<char*>("Produce a PDF File for every Page. Bool value")},
00526 {const_cast<char*>("aprint"), T_INT, offsetof(PDFfile, aprint), 0, const_cast<char*>("Allow Printing the Document. Bool value")},
00527 {const_cast<char*>("achange"), T_INT, offsetof(PDFfile, achange), 0, const_cast<char*>("Allow Changing the Document. Bool value")},
00528 {const_cast<char*>("acopy"), T_INT, offsetof(PDFfile, acopy), 0, const_cast<char*>("Allow Copying Text and Graphics. Bool value")},
00529 {const_cast<char*>("aanot"), T_INT, offsetof(PDFfile, aanot), 0, const_cast<char*>("Allow Adding Annotations and Fields. Bool value")},
00530 {const_cast<char*>("version"), T_INT, offsetof(PDFfile, version), 0, const_cast<char*>("Choose PDF version to use:\n\t12 = PDF/X-3\n\t13 = PDF 1.3 (Acrobat 4)\n\t14 = PDF 1.4 (Acrobat 5)")},
00531 {const_cast<char*>("outdst"), T_INT, offsetof(PDFfile, outdst), 0, const_cast<char*>("Output destination.\n\t0 - screen\n\t1 - printer")},
00532 {const_cast<char*>("profiles"), T_INT, offsetof(PDFfile, profiles), 0, const_cast<char*>("Embed a color profile for solid colors. Bool value.")},
00533 {const_cast<char*>("profilei"), T_INT, offsetof(PDFfile, profilei), 0, const_cast<char*>("Embed a color profile for images. Bool value.")},
00534 {const_cast<char*>("intents"), T_INT, offsetof(PDFfile, intents), 0, const_cast<char*>("Rendering intent for solid colors\n\t0 - Perceptual\n\t1 - Relative Colorimetric\n\t2 - Saturation\n\t3 - Absolute Colorimetric")},
00535 {const_cast<char*>("intenti"), T_INT, offsetof(PDFfile, intenti), 0, const_cast<char*>("Rendering intent for images\n\t0 - Perceptual\n\t1 - Relative Colorimetric\n\t2 - Saturation\n\t3 - Absolute Colorimetric")},
00536 {const_cast<char*>("noembicc"), T_INT, offsetof(PDFfile, noembicc), 0, const_cast<char*>("Don't use embedded ICC profiles. Bool value")},
00537 {const_cast<char*>("bleedt"), T_DOUBLE, offsetof(PDFfile, bleedt), 0, const_cast<char*>("Bleed Top\n""Distance for bleed from the top of the physical page")},
00538 {const_cast<char*>("bleedl"), T_DOUBLE, offsetof(PDFfile, bleedl), 0, const_cast<char*>("Bleed Left\n""Distance for bleed from the left of the physical page")},
00539 {const_cast<char*>("bleedr"), T_DOUBLE, offsetof(PDFfile, bleedr), 0, const_cast<char*>("Bleed Right\n""Distance for bleed from the right of the physical page")},
00540 {const_cast<char*>("bleedb"), T_DOUBLE, offsetof(PDFfile, bleedb), 0, const_cast<char*>("Bleed Bottom\n""Distance for bleed from the bottom of the physical page")},
00541 {NULL, 0, 0, 0, NULL}
00542 };
00543
00544
00545
00546
00547 static PyObject *PDFfile_getfile(PDFfile *self, void * )
00548 {
00549 Py_INCREF(self->file);
00550 return self->file;
00551 }
00552
00553 static int PDFfile_setfile(PDFfile *self, PyObject *value, void * )
00554 {
00555 if (value == NULL) {
00556 PyErr_SetString(PyExc_TypeError, "Cannot delete 'file' attribute.");
00557 return -1;
00558 }
00559 if (!PyString_Check(value)) {
00560 PyErr_SetString(PyExc_TypeError, "The 'file' attribute value must be string.");
00561 return -1;
00562 }
00563 Py_DECREF(self->file);
00564 Py_INCREF(value);
00565 self->file = value;
00566 return 0;
00567 }
00568
00569 static PyObject *PDFfile_getfonts(PDFfile *self, void * )
00570 {
00571 Py_INCREF(self->fonts);
00572 return self->fonts;
00573 }
00574
00575 static int PDFfile_setfonts(PDFfile *self, PyObject *value, void * )
00576 {
00577 if (value == NULL) {
00578 PyErr_SetString(PyExc_TypeError, "Cannot delete 'fonts' attribute.");
00579 return -1;
00580 }
00581 if (!PyList_Check(value)) {
00582 PyErr_SetString(PyExc_TypeError, "The 'fonts' attribute value must be list of strings.");
00583 return -1;
00584 }
00585 int n;
00586 n = PyList_Size(value);
00587 for (int i=0; i<n; ++i)
00588 if (!PyString_Check(PyList_GetItem(value, i))) {
00589 PyErr_SetString(PyExc_TypeError, "The 'fonts' list must contain only strings.");
00590 return -1;
00591 }
00592
00593
00594
00595 Py_DECREF(self->fonts);
00596 Py_INCREF(value);
00597 self->fonts = value;
00598 PyList_Sort(self->fonts);
00599 return 0;
00600 }
00601
00602 static PyObject *PDFfile_getpages(PDFfile *self, void * )
00603 {
00604 Py_INCREF(self->pages);
00605 return self->pages;
00606 }
00607
00608 static int PDFfile_setpages(PDFfile *self, PyObject *value, void * )
00609 {
00610 if (value == NULL) {
00611 PyErr_SetString(PyExc_TypeError, "Cannot delete 'pages' attribute.");
00612 return -1;
00613 }
00614 if (!PyList_Check(value)) {
00615 PyErr_SetString(PyExc_TypeError, "'pages' attribute value must be list of integers.");
00616 return -1;
00617 }
00618 int len = PyList_Size(value);
00619 for (int i = 0; i<len; i++){
00620 PyObject *tmp = PyList_GetItem(value, i);
00621
00622
00623
00624 if (!PyInt_Check(tmp)){
00625 PyErr_SetString(PyExc_TypeError, "'pages' list must contain only integers.");
00626 return -1;
00627 }
00628 if (PyInt_AsLong(tmp) > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count()) || PyInt_AsLong(tmp) < 1) {
00629 PyErr_SetString(PyExc_ValueError, "'pages' value out of range.");
00630 return -1;
00631 }
00632 }
00633 Py_DECREF(self->pages);
00634 Py_INCREF(value);
00635 self->pages = value;
00636 PyList_Sort(self->pages);
00637 return 0;
00638 }
00639
00640
00641 static PyObject *PDFfile_getresolution(PDFfile *self, void * )
00642 {
00643 Py_INCREF(self->resolution);
00644 return self->resolution;
00645 }
00646
00647 static int PDFfile_setresolution(PDFfile *self, PyObject *value, void * )
00648 {
00649 if (value == NULL) {
00650 PyErr_SetString(PyExc_TypeError, "Cannot delete 'resolution' attribute.");
00651 return -1;
00652 }
00653 if (!PyInt_Check(value)) {
00654 PyErr_SetString(PyExc_TypeError, "'resolution' attribute value must be integer.");
00655 return -1;
00656 }
00657 int n = PyInt_AsLong(value);
00658 if (n<35 || n>4000) {
00659 PyErr_SetString(PyExc_ValueError, "'compress' value must be in interval from 35 to 4000");
00660 return -1;
00661 }
00662 Py_DECREF(self->resolution);
00663 Py_INCREF(value);
00664 self->resolution = value;
00665 return 0;
00666 }
00667
00668 static PyObject *PDFfile_getdownsample(PDFfile *self, void * )
00669 {
00670 Py_INCREF(self->downsample);
00671 return self->downsample;
00672 }
00673
00674 static int PDFfile_setdownsample(PDFfile *self, PyObject *value, void * )
00675 {
00676 if (value == NULL) {
00677 PyErr_SetString(PyExc_TypeError, "Cannot delete 'downsample' attribute.");
00678 return -1;
00679 }
00680 if (!PyInt_Check(value)) {
00681 PyErr_SetString(PyExc_TypeError, "'downsample' attribute value must be integer.");
00682 return -1;
00683 }
00684 int n = PyInt_AsLong(value);
00685 if (n!=0 && (n<35 || n>PyInt_AsLong(self->resolution))) {
00686 PyErr_SetString(PyExc_TypeError, "'downsample' value must be 0 or in interval from 35 to value of 'resolutin'");
00687 return -1;
00688 }
00689 Py_DECREF(self->downsample);
00690 Py_INCREF(value);
00691 self->downsample = value;
00692 return 0;
00693 }
00694
00695 static PyObject *PDFfile_geteffval(PDFfile *self, void * )
00696 {
00697 Py_INCREF(self->effval);
00698 return self->effval;
00699 }
00700
00701 static int PDFfile_seteffval(PDFfile *self, PyObject *value, void * )
00702 {
00703 if (value == NULL) {
00704 PyErr_SetString(PyExc_TypeError, "Cannot delete 'effval' attribute.");
00705 return -1;
00706 }
00707 if (!PyList_Check(value)) {
00708 PyErr_SetString(PyExc_TypeError, "'effval' must be list.");
00709 return -1;
00710 }
00711 int n = PyList_Size(value);
00712 for (int i=0; i<n; ++i) {
00713 PyObject *tmp = PyList_GetItem(value, i);
00714 if (!PyList_Check(tmp)) {
00715 PyErr_SetString(PyExc_TypeError, "elemets of 'effval' must be list of five integers.");
00716 return -1;
00717 }
00718 int j = PyList_Size(tmp);
00719 if (j != 6) {
00720 PyErr_SetString(PyExc_TypeError, "elemets of 'effval' must have exactly six integers.");
00721 return -1;
00722 }
00723 for ( --j; j > -1; --j) {
00724 if (!PyInt_Check(PyList_GetItem(tmp, j))) {
00725 PyErr_SetString(PyExc_TypeError, "innermost element of 'effval' must be integers.");
00726 return -1;
00727 }
00728 }
00729 }
00730 Py_DECREF(self->effval);
00731 Py_INCREF(value);
00732 self->effval = value;
00733 return 0;
00734 }
00735
00736 static PyObject *PDFfile_getlpival(PDFfile *self, void * )
00737 {
00738 Py_INCREF(self->lpival);
00739 return self->lpival;
00740 }
00741
00742 static int PDFfile_setlpival(PDFfile *self, PyObject *value, void * )
00743 {
00744 if (value == NULL) {
00745 PyErr_SetString(PyExc_TypeError, "Cannot delete 'lpival' attribute.");
00746 return -1;
00747 }
00748 if (!PyList_Check(value)) {
00749 PyErr_SetString(PyExc_TypeError, "'lpival' must be list.");
00750 return -1;
00751 }
00752
00753 int n = PyList_Size(value);
00754 for (int i=0; i<n; ++i) {
00755 PyObject *tmp = PyList_GetItem(value, i);
00756 if (!PyList_Check(tmp)) {
00757 PyErr_SetString(PyExc_TypeError, "elemets of 'lpival' must be list of five integers.");
00758 return -1;
00759 }
00760 int j = PyList_Size(tmp);
00761 if (j != 4) {
00762 PyErr_SetString(PyExc_TypeError, "elemets of 'lpival' must have exactly four members.");
00763 return -1;
00764 }
00765 for ( --j; j > 0; --j) {
00766 if (!PyInt_Check(PyList_GetItem(tmp, j))) {
00767 PyErr_SetString(PyExc_TypeError, "'lpival'elements must have structure [siii]");
00768 return -1;
00769 }
00770 }
00771 if (!PyString_Check(PyList_GetItem(tmp, 0))) {
00772 PyErr_SetString(PyExc_TypeError, "'lpival'elements must have structure [siii]");
00773 return -1;
00774 }
00775 }
00776 Py_DECREF(self->lpival);
00777 Py_INCREF(value);
00778 self->lpival = value;
00779 return 0;
00780 }
00781
00782 static PyObject *PDFfile_getowner(PDFfile *self, void * )
00783 {
00784 Py_INCREF(self->owner);
00785 return self->owner;
00786 }
00787
00788 static int PDFfile_setowner(PDFfile *self, PyObject *value, void * )
00789 {
00790 if (value == NULL) {
00791 PyErr_SetString(PyExc_TypeError, "Cannot delete 'owner' attribute.");
00792 return -1;
00793 }
00794 if (!PyString_Check(value)) {
00795 PyErr_SetString(PyExc_TypeError, "'owner' attribute value must be string.");
00796 return -1;
00797 }
00798 Py_DECREF(self->owner);
00799 Py_INCREF(value);
00800 self->owner = value;
00801 return 0;
00802 }
00803
00804 static PyObject *PDFfile_getuser(PDFfile *self, void * )
00805 {
00806 Py_INCREF(self->user);
00807 return self->user;
00808 }
00809
00810 static int PDFfile_setuser(PDFfile *self, PyObject *value, void * )
00811 {
00812 if (value == NULL) {
00813 PyErr_SetString(PyExc_TypeError, "Cannot delete 'user' attribute.");
00814 return -1;
00815 }
00816 if (!PyString_Check(value)) {
00817 PyErr_SetString(PyExc_TypeError, "'user' attribute value must be string.");
00818 return -1;
00819 }
00820 Py_DECREF(self->user);
00821 Py_INCREF(value);
00822 self->user = value;
00823 return 0;
00824 }
00825
00826 static PyObject *PDFfile_getsolidpr(PDFfile *self, void * )
00827 {
00828 Py_INCREF(self->solidpr);
00829 return self->solidpr;
00830 }
00831
00832 static int PDFfile_setsolidpr(PDFfile *self, PyObject *value, void * )
00833 {
00834 if (value == NULL) {
00835 PyErr_SetString(PyExc_TypeError, "Cannot delete 'solidpr' attribute.");
00836 return -1;
00837 }
00838 if (!PyString_Check(value)) {
00839 PyErr_SetString(PyExc_TypeError, "The 'solidpr' attribute value must be string.");
00840 return -1;
00841 }
00842 Py_DECREF(self->solidpr);
00843 Py_INCREF(value);
00844 self->solidpr = value;
00845 return 0;
00846 }
00847
00848 static PyObject *PDFfile_getimagepr(PDFfile *self, void * )
00849 {
00850 Py_INCREF(self->imagepr);
00851 return self->imagepr;
00852 }
00853
00854 static int PDFfile_setimagepr(PDFfile *self, PyObject *value, void * )
00855 {
00856 if (value == NULL) {
00857 PyErr_SetString(PyExc_TypeError, "Cannot delete 'imagepr' attribute.");
00858 return -1;
00859 }
00860 if (!PyString_Check(value)) {
00861 PyErr_SetString(PyExc_TypeError, "The 'imagepr' attribute value must be string.");
00862 return -1;
00863 }
00864 Py_DECREF(self->imagepr);
00865 Py_INCREF(value);
00866 self->imagepr = value;
00867 return 0;
00868 }
00869
00870 static PyObject *PDFfile_getprintprofc(PDFfile *self, void * )
00871 {
00872 Py_INCREF(self->printprofc);
00873 return self->printprofc;
00874 }
00875
00876 static int PDFfile_setprintprofc(PDFfile *self, PyObject *value, void * )
00877 {
00878 if (value == NULL) {
00879 PyErr_SetString(PyExc_TypeError, "Cannot delete 'printprofc' attribute.");
00880 return -1;
00881 }
00882 if (!PyString_Check(value)) {
00883 PyErr_SetString(PyExc_TypeError, "The 'printprofc' attribute value must be string.");
00884 return -1;
00885 }
00886 Py_DECREF(self->printprofc);
00887 Py_INCREF(value);
00888 self->printprofc = value;
00889 return 0;
00890 }
00891
00892 static PyObject *PDFfile_getinfo(PDFfile *self, void *