// This function is used by scribus_importpage() to add new pages void import_addpages(int total, int pos) { ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; for (int i=0; i<total; i++) { int locreal = pos + i; int loc = pos + i + 1; if (loc > currentDoc->Pages->count()) loc = currentDoc->Pages->count(); QString qName(CommonStrings::trMasterPageNormal); if (currentDoc->pageSets()[currentDoc->pagePositioning()].Columns != 1) { currentDoc->locationOfPage(loc); switch (currentDoc->locationOfPage(loc)) { case LeftPage: qName = CommonStrings::trMasterPageNormalLeft; break; case RightPage: qName = CommonStrings::trMasterPageNormalRight; break; case MiddlePage: qName = CommonStrings::trMasterPageNormalMiddle; break; } } ScCore->primaryMainWindow()->slotNewPageP(locreal, qName); } }
PyObject *scribus_setdoctype(PyObject* /* self */, PyObject* args) { int fp, fsl; if (!PyArg_ParseTuple(args, "ii", &fp, &fsl)) return nullptr; if (!checkHaveDocument()) return nullptr; ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; ScribusView* currentView = ScCore->primaryMainWindow()->view; if (currentDoc->pagePositioning() == fp) currentDoc->setPageSetFirstPage(currentDoc->pagePositioning(), fsl); currentView->reformPages(); currentView->GotoPage(currentDoc->currentPageNumber()); // is this needed? currentView->DrawNew(); // is this needed? //CB TODO ScCore->primaryMainWindow()->pagePalette->RebuildPage(); // is this needed? ScCore->primaryMainWindow()->slotDocCh(); Py_RETURN_NONE; }
PyObject *scribus_newpage(PyObject* /* self */, PyObject* args) { int e; char *name = const_cast<char*>(""); QString qName(CommonStrings::trMasterPageNormal); if (!PyArg_ParseTuple(args, "i|es", &e, "utf-8", &name)) return nullptr; if (!checkHaveDocument()) return nullptr; ScribusMainWindow* mainWin = ScCore->primaryMainWindow(); ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; int loc = (e > -1) ? e : currentDoc->Pages->count(); if (currentDoc->pageSets()[currentDoc->pagePositioning()].Columns != 1) { switch (currentDoc->locationOfPage(loc)) { case LeftPage: qName = CommonStrings::trMasterPageNormalLeft; break; case RightPage: qName = CommonStrings::trMasterPageNormalRight; break; case MiddlePage: qName = CommonStrings::trMasterPageNormalMiddle; break; } } if (QString(name).length() != 0) qName = QString::fromUtf8(name); if (!currentDoc->MasterNames.contains(qName)) { PyErr_SetString(PyExc_IndexError, QObject::tr("Given master page name does not match any existing.","python error").toLocal8Bit().constData()); return nullptr; } if (e < 0) mainWin->slotNewPageP(loc, qName); else { e--; if ((e < 0) || (e > static_cast<int>(loc - 1))) { PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData()); return nullptr; } mainWin->slotNewPageP(e, qName); } // Py_INCREF(Py_None); // return Py_None; Py_RETURN_NONE; }
PyObject *scribus_setmargins(PyObject* /* self */, PyObject* args) { double lr, tpr, btr, rr; if (!PyArg_ParseTuple(args, "dddd", &lr, &rr, &tpr, &btr)) return nullptr; if (!checkHaveDocument()) return nullptr; MarginStruct margins(ValueToPoint(tpr), ValueToPoint(lr), ValueToPoint(btr), ValueToPoint(rr)); ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; ScribusView* currentView = ScCore->primaryMainWindow()->view; currentDoc->resetPage(currentDoc->pagePositioning(), &margins); currentView->reformPages(); currentDoc->setModified(true); currentView->GotoPage(currentDoc->currentPageNumber()); currentView->DrawNew(); Py_RETURN_NONE; }