1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 /*************************************************************************** 8 scribusdoc.h - description 9 ------------------- 10 begin : Fre Apr 6 21:47:55 CEST 2001 11 copyright : (C) 2001 by Franz Schmid 12 email : Franz.Schmid@altmuehlnet.de 13 ***************************************************************************/ 14 15 /*************************************************************************** 16 * * 17 * This program is free software; you can redistribute it and/or modify * 18 * it under the terms of the GNU General Public License as published by * 19 * the Free Software Foundation; either version 2 of the License, or * 20 * (at your option) any later version. * 21 * * 22 ***************************************************************************/ 23 #ifndef SCRIBUSDOC_H 24 #define SCRIBUSDOC_H 25 #ifdef HAVE_CONFIG_H 26 #include "scconfig.h" 27 #endif 28 // include files for QT 29 #include <QColor> 30 #include <QFont> 31 #include <QList> 32 #include <QMap> 33 #include <QHash> 34 #include <QObject> 35 #include <QPixmap> 36 #include <QRectF> 37 #include <QStringList> 38 #include <QTimer> 39 #include <QFile> 40 41 #include "appmodes.h" 42 #include "gtgettext.h" //CB For the ImportSetup struct and itemadduserframe 43 #include "scribusapi.h" 44 #include "colormgmt/sccolormgmtengine.h" 45 #include "documentinformation.h" 46 #include "numeration.h" 47 #include "marks.h" 48 #include "nodeeditcontext.h" 49 #include "notesstyles.h" 50 #include "observable.h" 51 #include "pageitem.h" 52 #include "pageitem_group.h" 53 #include "pageitem_latexframe.h" 54 #include "pageitem_textframe.h" 55 #include "pagestructs.h" 56 #include "prefsstructs.h" 57 #include "scguardedptr.h" 58 #include "scpage.h" 59 #include "sclayer.h" 60 #include "styles/styleset.h" 61 #include "styles/tablestyle.h" 62 #include "styles/cellstyle.h" 63 #include "undoobject.h" 64 #include "undostate.h" 65 #include "undotransaction.h" 66 #include "updatemanager.h" 67 #include "usertaskstructs.h" 68 69 class DocUpdater; 70 class FPoint; 71 class UndoManager; 72 // class UndoState; 73 class PDFOptions; 74 class Hyphenator; 75 class Selection; 76 class ScribusView; 77 class ScribusMainWindow; 78 class ResourceCollection; 79 class PageSize; 80 class ScPattern; 81 class Serializer; 82 class QProgressBar; 83 class MarksManager; 84 class NotesStyle; 85 class TextNote; 86 87 88 89 /**! \brief the Document Class 90 */ 91 class SCRIBUS_API ScribusDoc : public QObject, public UndoObject, public Observable<ScribusDoc> 92 { 93 Q_OBJECT 94 95 public: 96 ScribusDoc(); 97 ScribusDoc(const QString& docName, int unitIndex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup); 98 ~ScribusDoc(); 99 100 void init(); 101 bool inAnEditMode() const; 102 bool inASpecialEditMode() const; 103 QList<PageItem*> getAllItems(QList<PageItem*> &items); 104 QList<PageItem*> *parentGroup(PageItem* item, QList<PageItem*> *list); 105 void setup(int, int, int, int, int, const QString&, const QString&); 106 void setLoading(bool); 107 bool isLoading() const; 108 void setModified(bool); 109 bool isModified() const; 110 bool isUndoRedoOngoing() const; 111 /** Setzt die Seitenattribute */ 112 void setPage(double w, double h, double t, double l, double r, double b, double sp, double ab, bool atf, int fp); 113 114 /** 115 * @brief Return the view associated with the document 116 */ 117 ScribusView* view() const; scMW()118 ScribusMainWindow* scMW() const {return m_ScMW;} 119 void setGUI(bool hasgui, ScribusMainWindow* mw, ScribusView* view); 120 void createHyphenator(); 121 122 /** 123 * @brief Return the guarded object associated with the document 124 */ 125 const ScGuardedPtr<ScribusDoc>& guardedPtr() const; 126 updateManager()127 UpdateManager* updateManager() { return &m_updateManager; } itemsChanged()128 MassObservable<PageItem*>* itemsChanged() { return &m_itemsChanged; } pagesChanged()129 MassObservable<ScPage*>* pagesChanged() { return &m_pagesChanged; } regionsChanged()130 MassObservable<QRectF>* regionsChanged() { return &m_regionsChanged; } 131 132 void invalidateAll(); 133 void invalidateLayer(int layerID); 134 void invalidateRegion(QRectF region); 135 scratch()136 MarginStruct* scratch() { return &m_docPrefsData.displayPrefs.scratch; } bleeds()137 MarginStruct* bleeds() { return &m_docPrefsData.docSetupPrefs.bleeds; } bleedsVal()138 MarginStruct& bleedsVal() { return m_docPrefsData.docSetupPrefs.bleeds; } setBleeds(MarginStruct & newBleeds)139 void setBleeds(MarginStruct& newBleeds) { m_docPrefsData.docSetupPrefs.bleeds = newBleeds; } margins()140 MarginStruct* margins() { return &m_docPrefsData.docSetupPrefs.margins; } marginsVal()141 MarginStruct& marginsVal() { return m_docPrefsData.docSetupPrefs.margins; } setMargins(MarginStruct & newMargins)142 void setMargins(MarginStruct& newMargins) { m_docPrefsData.docSetupPrefs.margins = newMargins; } pageGapHorizontal()143 double pageGapHorizontal() const { return m_docPrefsData.displayPrefs.pageGapHorizontal; } pageGapVertical()144 double pageGapVertical() const { return m_docPrefsData.displayPrefs.pageGapVertical; } setPageGapHorizontal(double h)145 void setPageGapHorizontal(double h) { m_docPrefsData.displayPrefs.pageGapHorizontal=h; } setPageGapVertical(double v)146 void setPageGapVertical(double v) { m_docPrefsData.displayPrefs.pageGapVertical=v; } pageSets()147 const QList<PageSet>& pageSets() const { return m_docPrefsData.pageSets; } 148 void setPageSetFirstPage(int layout, int fp); clearPageSets()149 void clearPageSets() { m_docPrefsData.pageSets.clear(); } appendToPageSets(const PageSet & ps)150 void appendToPageSets(const PageSet& ps) { m_docPrefsData.pageSets.append(ps); } setPaperColor(const QColor & c)151 void setPaperColor(const QColor &c) { m_docPrefsData.displayPrefs.paperColor=c; } paperColor()152 const QColor& paperColor() const { return m_docPrefsData.displayPrefs.paperColor; } hyphAutomatic()153 bool hyphAutomatic() const { return m_docPrefsData.hyphPrefs.Automatic; } hyphAutoCheck()154 bool hyphAutoCheck() const { return m_docPrefsData.hyphPrefs.AutoCheck; } setHyphAutomatic(bool b)155 void setHyphAutomatic(bool b) { m_docPrefsData.hyphPrefs.Automatic=b; } setHyphAutoCheck(bool b)156 void setHyphAutoCheck(bool b) { m_docPrefsData.hyphPrefs.AutoCheck=b; } autoSave()157 bool autoSave() const { return m_docPrefsData.docSetupPrefs.AutoSave; } autoSaveTime()158 int autoSaveTime() const { return m_docPrefsData.docSetupPrefs.AutoSaveTime; } autoSaveCount()159 int autoSaveCount() const { return m_docPrefsData.docSetupPrefs.AutoSaveCount; } autoSaveKeep()160 bool autoSaveKeep() const { return m_docPrefsData.docSetupPrefs.AutoSaveKeep; } autoSaveInDocDir()161 bool autoSaveInDocDir() const { return m_docPrefsData.docSetupPrefs.AutoSaveLocation; } autoSaveDir()162 QString autoSaveDir() const { return m_docPrefsData.docSetupPrefs.AutoSaveDir; } autoSaveClockDisplay()163 bool autoSaveClockDisplay() const { return m_docPrefsData.displayPrefs.showAutosaveClockOnCanvas; } setAutoSave(bool b)164 void setAutoSave(bool b) { m_docPrefsData.docSetupPrefs.AutoSave=b; } setAutoSaveTime(int i)165 void setAutoSaveTime(int i) { m_docPrefsData.docSetupPrefs.AutoSaveTime=i; } setAutoSaveCount(int i)166 void setAutoSaveCount(int i) { m_docPrefsData.docSetupPrefs.AutoSaveCount=i; } setAutoSaveKeep(bool i)167 void setAutoSaveKeep(bool i) { m_docPrefsData.docSetupPrefs.AutoSaveKeep=i; } setAutoSaveInDocDir(bool i)168 void setAutoSaveInDocDir(bool i) { m_docPrefsData.docSetupPrefs.AutoSaveLocation=i; } setAutoSaveDir(const QString & autoDaveDir)169 void setAutoSaveDir(const QString& autoDaveDir) { m_docPrefsData.docSetupPrefs.AutoSaveDir = autoDaveDir; } 170 //FIXME (maybe) :non const, the loaders make a mess here pdfOptions()171 PDFOptions& pdfOptions() { return m_docPrefsData.pdfPrefs; } 172 itemAttributes()173 ObjAttrVector& itemAttributes() { return m_docPrefsData.itemAttrPrefs.defaultItemAttributes; } setItemAttributes(ObjAttrVector & oav)174 void setItemAttributes(ObjAttrVector& oav) { m_docPrefsData.itemAttrPrefs.defaultItemAttributes=oav;} clearItemAttributes()175 void clearItemAttributes() { m_docPrefsData.itemAttrPrefs.defaultItemAttributes.clear(); } appendToItemAttributes(const ObjectAttribute & oa)176 void appendToItemAttributes(const ObjectAttribute& oa) { m_docPrefsData.itemAttrPrefs.defaultItemAttributes.append(oa); } 177 tocSetups()178 ToCSetupVector& tocSetups() { return m_docPrefsData.tocPrefs.defaultToCSetups; } setTocSetups(ToCSetupVector & tsv)179 void setTocSetups(ToCSetupVector& tsv) { m_docPrefsData.tocPrefs.defaultToCSetups=tsv; } clearTocSetups()180 void clearTocSetups() { m_docPrefsData.tocPrefs.defaultToCSetups.clear(); } appendToTocSetups(const ToCSetup & ts)181 void appendToTocSetups(const ToCSetup& ts) { m_docPrefsData.tocPrefs.defaultToCSetups.append(ts); } 182 setArrowStyles(QList<ArrowDesc> & as)183 void setArrowStyles(QList<ArrowDesc>& as) { m_docPrefsData.arrowStyles = as; } arrowStyles()184 QList<ArrowDesc>& arrowStyles() { return m_docPrefsData.arrowStyles; } 185 ArrowDesc* arrowStyle(const QString& name); 186 bool hasArrowStyle(const QString& name) const; appendToArrowStyles(const struct ArrowDesc & as)187 void appendToArrowStyles(const struct ArrowDesc& as) { m_docPrefsData.arrowStyles.append(as); } 188 marginColored()189 bool marginColored() const { return m_docPrefsData.displayPrefs.marginColored; } setMarginColored(bool b)190 void setMarginColored(bool b) { m_docPrefsData.displayPrefs.marginColored = b; } 191 checkerProfiles()192 QMap<QString, CheckerPrefs>& checkerProfiles() { return m_docPrefsData.verifierPrefs.checkerPrefsList; } setCheckerProfiles(const QMap<QString,CheckerPrefs> & cl)193 void setCheckerProfiles(const QMap<QString, CheckerPrefs>& cl) { m_docPrefsData.verifierPrefs.checkerPrefsList = cl; } set1CheckerProfile(const QString & profileName,const struct CheckerPrefs & cs)194 void set1CheckerProfile(const QString& profileName, const struct CheckerPrefs& cs) { m_docPrefsData.verifierPrefs.checkerPrefsList[profileName] = cs; } clearCheckerProfiles()195 void clearCheckerProfiles() { m_docPrefsData.verifierPrefs.checkerPrefsList.clear(); } curCheckProfile()196 const QString& curCheckProfile() const { return m_docPrefsData.verifierPrefs.curCheckProfile; } setCurCheckProfile(const QString & s)197 void setCurCheckProfile(const QString& s) { m_docPrefsData.verifierPrefs.curCheckProfile = s; } 198 language()199 const QString& language() const { return m_docPrefsData.docSetupPrefs.language; } setLanguage(const QString & s)200 void setLanguage(const QString& s) { m_docPrefsData.docSetupPrefs.language = s; } 201 pageOrientation()202 int pageOrientation() const { return m_docPrefsData.docSetupPrefs.pageOrientation; } setPageOrientation(int o)203 void setPageOrientation(int o) { m_docPrefsData.docSetupPrefs.pageOrientation = o; } pagePositioning()204 int pagePositioning() const { return m_docPrefsData.docSetupPrefs.pagePositioning; } setPagePositioning(int p)205 void setPagePositioning(int p) { m_docPrefsData.docSetupPrefs.pagePositioning = p; } 206 pageHeight()207 double pageHeight() const { return m_docPrefsData.docSetupPrefs.pageHeight; } pageWidth()208 double pageWidth() const { return m_docPrefsData.docSetupPrefs.pageWidth; } pageSize()209 const QString& pageSize() const { return m_docPrefsData.docSetupPrefs.pageSize; } setPageHeight(double h)210 void setPageHeight(double h) { m_docPrefsData.docSetupPrefs.pageHeight = h; } setPageWidth(double w)211 void setPageWidth(double w) { m_docPrefsData.docSetupPrefs.pageWidth = w; } setPageSize(const QString & s)212 void setPageSize(const QString& s) { m_docPrefsData.docSetupPrefs.pageSize = s; } 213 marginPreset()214 int marginPreset() const { return m_docPrefsData.docSetupPrefs.marginPreset; } setMarginPreset(int mp)215 void setMarginPreset(int mp) { m_docPrefsData.docSetupPrefs.marginPreset = mp; } 216 typographicPrefs()217 TypoPrefs& typographicPrefs() { return m_docPrefsData.typoPrefs; } guidesPrefs()218 GuidesPrefs& guidesPrefs() { return m_docPrefsData.guidesPrefs; } itemToolPrefs()219 ItemToolPrefs& itemToolPrefs() { return m_docPrefsData.itemToolPrefs; } opToolPrefs()220 OperatorToolPrefs& opToolPrefs() { return m_docPrefsData.opToolPrefs; } colorPrefs()221 ColorPrefs& colorPrefs() { return m_docPrefsData.colorPrefs; } cmsSettings()222 CMSData& cmsSettings() { return m_docPrefsData.colorPrefs.DCMSset; } documentInfo()223 DocumentInformation& documentInfo() { return m_docPrefsData.docInfo; } setDocumentInfo(DocumentInformation di)224 void setDocumentInfo(DocumentInformation di) { m_docPrefsData.docInfo = di; } sections()225 DocumentSectionMap& sections() { return m_docPrefsData.docSectionMap; } setSections(DocumentSectionMap dsm)226 void setSections(DocumentSectionMap dsm) { m_docPrefsData.docSectionMap = std::move(dsm); } usedFonts()227 const QMap<QString, int> & usedFonts() { return UsedFonts; } 228 prefsData()229 const ApplicationPrefs& prefsData() { return m_docPrefsData; } 230 void setNewPrefs(const ApplicationPrefs& prefsData, const ApplicationPrefs& oldPrefsData, bool resizePages, bool resizeMasterPages, bool resizePageMargins, bool resizeMasterPageMargins); 231 232 // Add, delete and move pages 233 234 ScPage* addPage(int pageNumber, const QString& masterPageName=QString(), bool addAutoFrame=false); 235 void deletePage(int); 236 //! @brief Add a master page with this function, do not use addPage 237 ScPage* addMasterPage(int, const QString&); 238 void deleteMasterPage(int); 239 //! @brief Rebuild master name list 240 void rebuildMasterNames(); 241 //! @brief Replace a master page by default one 242 void replaceMasterPage(const QString& oldMasterPage); 243 //! @brief Rename a master page 244 bool renameMasterPage(const QString& oldPageName, const QString& newPageName); 245 //! @brief Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc. 246 void createDefaultMasterPages(); 247 //! @brief Create the requested pages in a new document, run after createDefaultMasterPages() 248 void createNewDocPages(int pageCount); 249 /** 250 * @brief Add the automatic text frame to the page 251 * @param pageNumber page number 252 * @return number of frame 253 */ 254 int addAutomaticTextFrame(int pageNumber); 255 /** 256 * Set the left and right margins based on the location of the page 257 * @param pageIndex 258 */ 259 void setLocationBasedPageLRMargins(uint pageIndex); 260 /** 261 * @brief Swap two pages 262 * @param a page index 263 * @param b page index 264 */ 265 void swapPage(int a, int b); 266 /** 267 * @brief Move page(s) within the document 268 * @param fromPage page index 269 * @param toPage page index 270 * @param count target to move to (page index) 271 * @param position Before, After or at the end 272 */ 273 void movePage(int fromPage, int toPage, int dest, int position); 274 275 /** 276 * @brief Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end. 277 * @param pageNumberToCopy 278 * @param existingPage 279 * @param whereToInsert 280 * @param copyCount 281 */ 282 void copyPage(int pageNumberToCopy, int existingPage, int whereToInsert, int copyCount); 283 284 // Add, delete and move layers 285 /** 286 * @brief Add a layer to the current document 287 * @param layerName name of layer 288 * @param activate the layer active 289 * @return Number of the layer created 290 */ 291 int addLayer(const QString& layerName, bool activate=false); 292 /** 293 * @brief Copies a layer from the current document 294 * @param layerIDToCopy source layer 295 * @param whereToInsert target layer 296 * @return Success or failure 297 */ 298 void copyLayer(int layerIDToCopy, int whereToInsert); 299 /** 300 * @brief Delete a layer from the current document 301 * @param layerID of layer 302 * @param deleteItems the items on the layer too? 303 * @return Success or failure 304 */ 305 bool deleteLayer(int layerID, bool deleteItems); 306 /** 307 * @brief Return the number of the current layer 308 * @return Active layer number 309 */ 310 int activeLayer(); 311 312 /** 313 * @brief Return the name of the current layer 314 * @return Name of the layer 315 */ 316 const QString& activeLayerName(); 317 /** 318 * @brief Set the active layer via the layer number 319 * @param layerToActivate Number of the layer 320 * @return Success or failure 321 */ 322 bool setActiveLayer(int layerToActivate); 323 /** 324 * @brief Set the active layer via the layer name 325 * @param layerNameToActivate Name of the layer 326 * @return Success or failure 327 */ 328 bool setActiveLayer(const QString & layerNameToActivate); 329 /** 330 * @brief Set the layer printable via the layer number 331 * @param layerID ID of the layer 332 * @param isPrintable bool true = layer is prantable 333 * @return Success or failure 334 */ 335 bool setLayerPrintable(int layerID, bool isPrintable); 336 /** 337 * @brief Is the layer printable 338 * @param layerID ID of the layer 339 * @return Printable or not 340 */ 341 bool layerPrintable(int layerID) const; 342 /** 343 * @brief Set the layer visible via the layer number 344 * @param layerID ID of the layer 345 * @param isViewable true = layer is visible 346 * @return Success or failure 347 */ 348 bool setLayerVisible(int layerID, bool isViewable); 349 /** 350 * @brief Is the layer visible 351 * @param layerID ID of the layer 352 * @return Visible or not 353 */ 354 bool layerVisible(int layerID) const; 355 /** 356 * @brief are objects on the layer selectable 357 * @param layerID ID of the layer 358 * @return Items selectable or not 359 */ 360 bool layerSelectable(int layerID) const; 361 /** 362 * @brief Set objects on the layer selectable via the layer ID 363 * @param layerID ID of the layer 364 * @param isSelectable true = layer objects are selectable 365 * @return bool Success or failure 366 */ 367 bool setLayerSelectable(int layerID, bool isSelectable); 368 /** 369 * @brief Set the layer locked via the layer number 370 * @param layerID ID of the layer 371 * @param isLocked true = layer is locked 372 * @return Success or failure 373 */ 374 bool setLayerLocked(int layerID, bool isLocked); 375 /** 376 * @brief Is the layer locked 377 * @param layerID ID of the layer 378 * @return Locked or not 379 */ 380 bool layerLocked(int layerID) const; 381 /** 382 * @brief Set the layer flow via the layer number 383 * @param layerID ID of the layer 384 * @param flow true = Text flows around objects on this layer 385 * @return Success or failure 386 */ 387 bool setLayerFlow(int layerID, bool flow); 388 /** 389 * @brief does text flow around objects on this layer 390 * @param layerID ID of the layer 391 * @return flow or not 392 */ 393 bool layerFlow(int layerID) const; 394 /** 395 * @brief Set the layer transparency via the layer number 396 * @param layerID ID of the layer 397 * @param trans transparency value 0.0 - 1.0 398 * @return Success or failure 399 */ 400 bool setLayerTransparency(int layerID, double trans); 401 /** 402 * @brief returns the layer transparency 403 * @param layerID ID of the layer 404 * @return transparency value 0.0 - 1.0 405 */ 406 double layerTransparency(int layerID) const; 407 /** 408 * @brief Set the layer layerBlendMode via the layer number 409 * @param layerID ID of the layer 410 * @param blend layerBlendMode 411 * @return Success or failure 412 */ 413 bool setLayerBlendMode(int ID, int blend); 414 /** 415 * @brief returns the layer BlendMode 416 * @param layerID ID of the layer 417 * @return layerBlendMode 418 */ 419 int layerBlendMode(int ID) const; 420 /** 421 * @brief Return the level of the requested layer 422 * @param layerID ID of the layer 423 * @return Level of the layer 424 */ 425 int layerLevelFromID(int layerID) const; 426 /** 427 * @brief Set the layer marker color 428 * @param ID Number of the layer 429 * @param color color of the marker 430 * @return Success or failure 431 */ 432 bool setLayerMarker(int layerID, const QColor& color); 433 /** 434 * @brief returns the layer marker color 435 * @param layerID ID of the layer 436 * @return marker color 437 */ 438 QColor layerMarker(int layerID) const; 439 /** 440 * @brief Set the layer outline mode via the layer number 441 * @param layerID ID of the layer 442 * @param outline true = layer is displayed in outlines only 443 * @return Success or failure 444 */ 445 bool setLayerOutline(int layerID, bool outline); 446 /** 447 * @brief is this layer in outline mode 448 * @param layerID ID of the layer 449 * @return outline or not 450 */ 451 bool layerOutline(int layerID) const; 452 /** 453 * @brief Return the number of the layer at a certain level 454 * @param layerLevel Layer level 455 * @return Layer ID 456 */ 457 int layerIDFromLevel(int layerLevel) const; 458 /** 459 * @brief Return the layer count 460 * @return Number of layers in doc 461 */ 462 int layerIDFromName(const QString& name) const; 463 int layerCount() const; 464 /** 465 * @brief Lower a layer 466 * @param layerID ID of the layer 467 * @return Success or failure 468 */ 469 bool lowerLayer(int layerID); 470 /** 471 * @brief Lower a layer using the level 472 * @param layerLevel Level of the layer 473 * @return Success or failure 474 */ 475 bool lowerLayerByLevel(int layerLevel); 476 /** 477 * @brief Raise a layer 478 * @param layerID ID of the layer 479 * @return Success or failure 480 */ 481 bool raiseLayer(int layerID); 482 /** 483 * @brief Raise a layer using the level 484 * @param layerLevel Level of the layer 485 * @return Success or failure 486 */ 487 bool raiseLayerByLevel(int layerLevel); 488 /** 489 * @brief Return the layer name 490 * @param layerID ID of the layer 491 * @return Name of the layer 492 */ 493 QString layerName(int layerID) const; 494 /** 495 * @brief Change the name of a layer 496 * @param layerID ID of the layer 497 * @param newName new name of the layer 498 * @return Success or failure 499 */ 500 bool changeLayerName(int layerID, const QString& newName); 501 /** 502 * @brief Test if items can be selected on a specific layer 503 * 504 * This function check if items can be selected on the specified layer 505 * by checking layer visibility and selectable property etc... 506 * 507 * @param layerID ID of the layer 508 * @return a boolean 509 */ 510 bool canSelectItemOnLayer(int layerID) const; 511 /** 512 * @brief Does the layer have items on it? 513 * @param layerID ID of the layer 514 * @return Layer contains items bool 515 */ 516 bool layerContainsItems(int layerID) const; 517 /** 518 * @brief Renumber a layer. Used in particular for reinsertion for undo/redo 519 * @param layerID old layer ID 520 * @param newLayerID New layer ID 521 * @return Success or failure 522 */ 523 bool renumberLayer(int layerID, int newLayerID); 524 /** 525 * @brief Return a list of the layers in their order 526 * @param list QStringList to insert the layer names into 527 */ 528 void orderedLayerList(QStringList* list) const; 529 530 int firstLayerID() const; 531 532 /*! 533 * @brief Builds a qmap of the icc profiles used within the document 534 */ 535 void getUsedProfiles(ProfilesL& usedProfiles) const; 536 bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo); 537 void CloseCMSProfiles(); 538 void SetDefaultCMSParams(); 539 /** 540 * @brief Switch Colormanagement on or of 541 * @param enable bool, if true Colormanagement is switched on, else off 542 */ 543 void enableCMS(bool enable); 544 paragraphStyle(const QString & name)545 const ParagraphStyle& paragraphStyle(const QString& name) const { return m_docParagraphStyles.get(name); } paragraphStyles()546 const StyleSet<ParagraphStyle>& paragraphStyles() const { return m_docParagraphStyles; } isDefaultStyle(const ParagraphStyle & p)547 bool isDefaultStyle( const ParagraphStyle& p ) const { return m_docParagraphStyles.isDefault(p); } isDefaultStyle(const CharStyle & c)548 bool isDefaultStyle( const CharStyle& c ) const { return m_docCharStyles.isDefault(c); } 549 // bool isDefaultStyle( LineStyle& l ) const { return docLineStyles......; } 550 lineStyles()551 const QHash<QString, multiLine>& lineStyles() const { return docLineStyles; } 552 553 /** 554 * Returns the table style named @a name. 555 */ tableStyle(const QString & name)556 const TableStyle& tableStyle(const QString& name) { return m_docTableStyles.get(name); } 557 /** 558 * Returns the set of table styles in the document. 559 */ tableStyles()560 const StyleSet<TableStyle>& tableStyles() { return m_docTableStyles; } 561 /** 562 * Returns <code>true</code> if @a style is the default table style. 563 */ isDefaultStyle(const TableStyle & style)564 bool isDefaultStyle(const TableStyle& style) const { return m_docTableStyles.isDefault(style); } 565 /** 566 * Redefines the set of table styles in the document using styles in @a newStyles. 567 * Removes unused table styles if @a removeUnused is <code>true</code>. 568 */ 569 void redefineTableStyles(const StyleSet<TableStyle>& newStyles, bool removeUnused = false); 570 /** 571 * Remove any reference to old table styles and replace with new name. 572 * This needs to be called when a style was removed. New name may be "". 573 * @a newNameForOld is a map which maps the name of any style to remove 574 * to a new table style name 575 */ 576 void replaceTableStyles(const QMap<QString, QString>& newNameForOld); 577 578 /** 579 * Returns the table cell style named @a name. 580 */ cellStyle(const QString & name)581 const CellStyle& cellStyle(const QString& name) { return m_docCellStyles.get(name); } 582 /** 583 * Returns the set of table cell styles in the document. 584 */ cellStyles()585 const StyleSet<CellStyle>& cellStyles() { return m_docCellStyles; } 586 /** 587 * Returns <code>true</code> if @a style is the default table cell style. 588 */ isDefaultStyle(const CellStyle & style)589 bool isDefaultStyle(const CellStyle& style) const { return m_docCellStyles.isDefault(style); } 590 /** 591 * Redefines the set of table cell styles in the document using styles in @a newStyles. 592 * Removes unused table cell styles if @a removeUnused is <code>true</code>. 593 */ 594 void redefineCellStyles(const StyleSet<CellStyle>& newStyles, bool removeUnused = false); 595 /** 596 * Remove any reference to old table cell styles and replace with new name. 597 * This needs to be called when a style was removed. New name may be "". 598 * @a newNameForOld is a map which maps the name of any style to remove 599 * to a new table cell style name 600 */ 601 void replaceCellStyles(const QMap<QString, QString>& newNameForOld); 602 603 void getNamedResources(ResourceCollection& lists) const; 604 struct ResMapped 605 { ResMappedResMapped606 ResMapped(ResourceCollection& newNames) { m_newNames = newNames;} 607 operatorResMapped608 void operator()(PageItem *item) 609 { 610 item->replaceNamedResources(m_newNames); 611 } 612 613 ResourceCollection m_newNames; 614 }; 615 void replaceNamedResources(ResourceCollection& newNames); 616 617 bool styleExists(const QString& styleName) const; 618 bool charStyleExists(const QString& styleName) const; 619 620 QList<int> getSortedStyleList(); 621 QList<int> getSortedCharStyleList(); 622 QList<int> getSortedTableStyleList(); 623 QList<int> getSortedCellStyleList(); 624 625 void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false); 626 /** 627 * @brief Remove any reference to old styles and replace with new name. This needs to be 628 * called when a style was removed. New name may be "". 629 * @param newNameForOld a map which maps the name of any style to remove to a new stylename 630 */ 631 void replaceStyles(const QMap<QString,QString>& newNameForOld); 632 /** 633 * @brief Insert styles from another document in this document. 634 * 635 * @param fileName The path of the document we want to extract its styles 636 */ 637 void loadStylesFromFile(const QString& fileName); 638 /** 639 * @brief Gather styles from another document. 640 * 641 * @param fileName The path of the document we want to extract its styles 642 * @param tempStyles A pointer to a StyleSet which will be filled by paragraph styles 643 * @param tempCharStyles A pointer to a StyleSet which will be filled by character styles 644 * @param tempLineStyles A map which will be filled by line styles 645 */ 646 void loadStylesFromFile(const QString& fileName, StyleSet<ParagraphStyle> *tempStyles, 647 StyleSet<CharStyle> *tempCharStyles, 648 QHash<QString, multiLine> *tempLineStyles); 649 charStyle(const QString & name)650 const CharStyle& charStyle(const QString& name) const { return m_docCharStyles.get(name); } charStyles()651 const StyleSet<CharStyle>& charStyles() const { return m_docCharStyles; } 652 void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false); 653 /** 654 * @brief Remove any reference to old styles and replace with new name. This needs to be 655 * called when a style was removed. New name may be "". 656 * @param newNameForOld a map which maps the name of any style to remove to a new stylename 657 */ 658 void replaceCharStyles(const QMap<QString,QString>& newNameForOld); 659 660 /** 661 * @brief Should guides be locked or not 662 * @param isLocked If true guides on pages cannot be moved if false they 663 * can be dragged to new positions. 664 * @author Riku Leino 665 */ 666 void lockGuides(bool isLocked); 667 /** 668 * @brief Method used when an undo/redo is requested. 669 * @param state State describing the action that is wanted to be undone/redone 670 * @param isUndo If true undo is wanted else if false redo. 671 * @author Riku Leino 672 */ 673 void restore(UndoState* state, bool isUndo); 674 675 /*! 676 * @brief Returns a stringlist of the item attributes within the document 677 */ 678 QStringList getItemAttributeNames(); 679 680 bool AddFont(const QString& name, int fsize = 10); 681 /*! 682 * @brief TODO: Reorganise the fonts.. how? Moved from scribus.cpp 683 * CB: almost the same as getUsedFonts??? 684 */ 685 QMap<QString,int> reorganiseFonts(); 686 /*! 687 * @brief Returns a qmap of the fonts and their glyphs used within the document 688 */ 689 void getUsedFonts(QMap<QString,QMap<uint, QString> > &Really); 690 void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, QString> > & Really, uint lc); 691 692 /*! 693 * @brief Replace line style colors 694 */ 695 void replaceLineStyleColors(const QMap<QString, QString>& colorMap); 696 /*! 697 * @brief Builds a qmap of the colours used within the document 698 */ 699 void getUsedColors(ColorList &colorsToUse, bool spot = false) const; 700 /*! 701 * @brief Return if a specific color is used by line styles 702 */ 703 bool lineStylesUseColor(const QString& colorName) const; 704 /*! 705 * @brief Builds a qmap of the gradients used within the document 706 */ 707 void getUsedGradients(QHash<QString, VGradient> &Gradients) const; 708 /*! 709 * @brief Set the gradients for a document 710 */ 711 bool addGradient(QString &name, const VGradient &gradient); 712 void setGradients(const QHash<QString, VGradient> &gradients); 713 /*! 714 * @brief Set the patterns for a document 715 */ 716 bool addPattern(QString &name, ScPattern& pattern); 717 void removePattern(const QString& name); 718 void setPatterns(const QHash<QString, ScPattern> &patterns); 719 /*! 720 * @brief Check pattern with specified name and return it if valid 721 */ 722 ScPattern* checkedPattern(const QString &name); 723 /*! 724 * @brief Get a unique pattern name 725 */ 726 QString getUniquePatternName(const QString& originalName) const; 727 /*! 728 * @brief Builds a QStringList of the patterns used within the document 729 */ 730 QStringList getUsedPatterns() const; 731 QStringList getUsedPatternsSelection(Selection* customSelection) const; 732 QStringList getUsedPatternsHelper(const QString& pattern, QStringList &results) const; 733 QStringList getPatternDependencyList(const QStringList& used) const; 734 /*! 735 * @brief Builds a QStringList of the symbols used within the document 736 */ 737 QStringList getUsedSymbols() const; 738 QStringList getUsedSymbolsHelper(const QString& pattern, QStringList &results) const; 739 740 /*! 741 * @brief Check if document use Acrobat Form Fields 742 */ 743 bool useAcroFormFields() const; 744 745 /*! 746 * @brief Check if document use PDF Annotations 747 */ 748 bool useAnnotations() const; 749 750 /*! 751 * @brief Check if document use effects on images 752 */ 753 bool useImageEffects() const; 754 755 /*! 756 * @brief Check if document use effects on images 757 */ 758 bool useImageColorEffects() const; 759 760 /** 761 * @brief Set and get the document's unit index 762 */ 763 void setUnitIndex(int); 764 int unitIndex() const; 765 double unitRatio() const; 766 /** 767 * @brief Apply a master page 768 */ 769 bool applyMasterPage(const QString& pageName, int pageNumber); 770 /** 771 * @brief Undo function for applying a master page 772 */ 773 void restoreMasterPageApplying(SimpleState* ss, bool isUndo); 774 void restoreMasterPageRenaming(SimpleState* ss, bool isUndo); 775 void restoreCopyPage(SimpleState* ss, bool isUndo); 776 void restoreMovePage(SimpleState* ss, bool isUndo); 777 void restoreSwapPage(SimpleState* ss, bool isUndo); 778 void restoreAddMasterPage(SimpleState* ss, bool isUndo); 779 void restoreChangePageProperties(SimpleState* ss, bool isUndo); 780 /** 781 * @brief Undo function for grouping/ungrouping 782 */ 783 void restoreGrouping(SimpleState* ss, bool isUndo); 784 /** 785 * @brief Undo function for level 786 */ 787 void restoreLevelDown(SimpleState* ss, bool isUndo); 788 void restoreLevelBottom(SimpleState* ss, bool isUndo); 789 void restoreGuideLock(SimpleState* ss, bool isUndo); 790 791 /** 792 * @brief Undo functions for marks / notes 793 */ 794 void restoreMarks(UndoState* ss, bool isUndo); 795 void restoreNoteStyle(SimpleState* ss, bool isUndo); 796 void restoreDeleteNote(UndoState* ss, bool isUndo); 797 798 /** 799 * @brief Save function 800 */ 801 bool save(const QString& fileName, QString* savedFile = nullptr); 802 /** 803 * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this. 804 */ 805 bool changePageProperties(double initialTop, double initialBottom, double initialLeft, double initialRight, double initialHeight, double initialWidth, double Height, double width, int orientation, const QString& pageSize, int marginPreset, bool moveObjects, int pageNumber=-1, int pageType = 0); 806 /** 807 * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly. 808 */ 809 void recalculateColorsList(QList<PageItem *> *itemList); 810 static void recalculateColorItem(PageItem *item); 811 void recalculateColors(); 812 /** 813 * @brief Copies a normal page to be a master pages 814 */ 815 bool copyPageToMasterPage(int, int, int, const QString&, bool); 816 817 818 /** 819 * @brief Just create but don't add to items list and don't create undo record 820 */ 821 PageItem* createPageItem(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, double x, double y, double b, double h, double w, const QString& fill, const QString& outline); 822 823 /** 824 * @brief Add an Item to the document. 825 * A simple function to create an item of a defined type and add it to the document 826 * Will need extensive rewriting once we have various classes of PageItems, at a guess. 827 * 828 * @param itemFinalised Used to handle item creation for undo while the user is still dragging. 829 * @return Number of created item, -1 on failure. 830 \param itemType type 831 \param frameType frame type 832 \param x X pos 833 \param y Y pos 834 \param b width 835 \param h height 836 \param w ? 837 \param fill fill color name 838 \param outline outline color name 839 \param noteFrame optional (default false) indicates that noteframes should be created, not text frame 840 */ 841 int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, double x, double y, double b, double h, double w, const QString& fill, const QString& outline, PageItem::ItemKind itemKind = PageItem::StandardItem); 842 843 /** Add an item to the page based on the x/y position. Item will be fitted to the closest guides/margins */ 844 int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, double x, double y, double w, const QString& fill, const QString& outline, PageItem::ItemKind itemKind = PageItem::StandardItem); 845 846 /** 847 * @brief Allow the user to create a frame easily with some simple placement and sizing options 848 * @param iafData a InsertAFrameData structure with params 849 * @return int item id? FIXME 850 */ 851 int itemAddUserFrame(InsertAFrameData &iafData); 852 853 /** 854 * @brief Commit item creation when a user has click-drag created an item 855 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now. 856 * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO. 857 */ 858 bool itemAddCommit(PageItem* item); 859 860 /** 861 * @brief Finalise item creation. Simply split off code from itemAdd 862 * Only to be called from itemAdd() 863 */ 864 void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, PageItem* newItem); 865 866 int getItemNrFromUniqueID(uint unique); 867 //return pointer to item 868 PageItem* getItemFromName(const QString& name) const; 869 //itemDelete 870 //itemBlah... 871 872 /** 873 * @brief Rebuild item lists taking into account layer order. 874 * Utility function used in various places, basically handles keeping items numbered in the way 875 * they are layered. When layer is a property and not a fuction of storage, this should be removed. 876 * @sa updateFrameItems(); 877 */ 878 void rebuildItemLists(); 879 /** 880 * @brief Doc uses automatic text frames? 881 */ 882 bool usesAutomaticTextFrames() const; 883 void setUsesAutomaticTextFrames(bool); 884 885 /** 886 * 887 * @param fn 888 * @param pageItem 889 * @param reload 890 * @return 891 */ 892 bool loadPict(const QString& fn, PageItem *pageItem, bool reload = false, bool showMsg = false); 893 /** 894 * \brief Handle image with color profiles 895 * @param Pr profile 896 @param PrCMYK cmyk profile 897 @param dia optional progress widget 898 */ 899 void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0); 900 /** 901 * \brief Handle image with color profiles 902 * @param items list of page items to update 903 * @param Pr profile 904 * @param PrCMYK cmyk profile 905 * @param dia optional progress widget 906 */ 907 void RecalcPictures(QList<PageItem*>* items, ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = nullptr); 908 909 /** 910 * @brief Find the minX,MinY and maxX,maxY for the canvas required for the doc 911 */ 912 void canvasMinMax(FPoint&, FPoint&); 913 914 /** 915 * @brief Find the optimal area for canvas 916 */ 917 QRectF canvasOptimalRect(); 918 919 int OnPage(double x2, double y2); 920 int OnPage(PageItem *currItem); 921 void GroupOnPage(PageItem *currItem); 922 923 void reformPages(bool moveObjects = true); 924 /** @brief Refresh automatic guides once Margin struct has been properly configure by reformPages() */ 925 void refreshGuides(); 926 927 /** @brief Check and fix if needed PageItem OwnPage member */ 928 void fixItemPageOwner(); 929 /** @brief Fix character styles */ 930 void fixCharacterStyles(); 931 /** @brief Fix paragraph styles */ 932 void fixParagraphStyles(); 933 /** @brief Fix notes styles */ 934 void fixNotesStyles(); 935 936 /** 937 * @brief Return the x or y offset for a page on the canvas 938 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible). 939 * Mostly saves bringing in extra includes into files that already have scribusdoc.h 940 */ 941 double getXOffsetForPage(int); 942 double getYOffsetForPage(int); 943 void getBleeds(int pageNumber, MarginStruct& bleedData); 944 void getBleeds(const ScPage* page, MarginStruct& bleedData); 945 void getBleeds(const ScPage* page, const MarginStruct& baseValues, MarginStruct& bleedData); 946 947 /** 948 * @brief Item type conversion functions 949 */ 950 PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=nullptr); 951 952 /** 953 * @brief The page number of the current page 954 */ 955 int currentPageNumber(); 956 957 /** 958 * @brief Return true iff the passed name is not used by any existing PageItem 959 * in the same document as this PageItem. 960 * @author Craig Ringer 961 ** CB Moved from PageItem 962 */ 963 bool itemNameExists(const QString& itemName); 964 965 /** 966 * @brief Set the doc into Master page mode 967 * Do we need to return if the move to master page mode was successful? 968 */ 969 void setMasterPageMode(bool); 970 void assignPageModeLists(); 971 972 /*** Is the document in master page mode? */ masterPageMode()973 bool masterPageMode() const { return m_masterPageMode; } 974 /** 975 * @brief Set the doc into symbol edit mode 976 */ 977 void setSymbolEditMode(bool mode, const QString& symbolName = ""); 978 979 /*** Is the document in symbol edit mode? */ symbolEditMode()980 bool symbolEditMode() const { return m_symbolEditMode; } 981 982 /*** get the name of the symbol currently in editing */ getEditedSymbol()983 QString getEditedSymbol() const { return m_currentEditedSymbol; } 984 /** 985 * @brief Set the doc into inline edit mode 986 */ 987 void setInlineEditMode(bool mode, int id = -1); 988 989 /*** Is the document in symbol edit mode? */ inlineEditMode()990 bool inlineEditMode() const { return m_inlineEditMode; } 991 992 /** 993 * @brief Add a section to the document sections list 994 * Set number to -1 to add in the default section if the map is empty 995 */ 996 void addSection(int number=0, const QString& name=QString(), const uint fromindex=0, const uint toindex=0, const NumFormat type=Type_1_2_3, const uint sectionstartindex=0, bool reversed=false, bool active=true, const QChar fillChar=QChar(), int fieldWidth=0); 997 /** 998 * @brief Delete a section from the document sections list 999 */ 1000 bool deleteSection(uint); 1001 /** 1002 * @brief Gets the page number to be printed based on the section it is in. 1003 * Returns QString() on failure to find the pageIndex 1004 */ 1005 const QString getSectionPageNumberForPageIndex(uint) const; 1006 /** 1007 * @brief Gets the page number fill character to be printed based on the section it is in. 1008 * Returns QString() on failure to find the pageIndex 1009 */ 1010 const QChar getSectionPageNumberFillCharForPageIndex(uint) const; 1011 /** 1012 * @brief Gets the page number fill character to be printed based on the section it is in. 1013 * Returns QString() on failure to find the pageIndex 1014 */ 1015 int getSectionPageNumberWidthForPageIndex(uint) const; 1016 /** 1017 * @brief Gets the key of the sections map based on the section the page index is in. 1018 * Returns -1 on failure to find the pageIndex 1019 */ 1020 int getSectionKeyForPageIndex(uint pageIndex) const; 1021 /** 1022 * 1023 * 1024 */ 1025 void updateSectionPageNumbersToPages(); 1026 /** 1027 * @param otherPageIndex 1028 * @param location 1029 * @param count 1030 */ 1031 void addPageToSection(uint otherPageIndex, uint location, uint count=1); 1032 /** 1033 * 1034 * @param pageIndex 1035 */ 1036 void removePageFromSection(uint pageIndex); 1037 /** 1038 * 1039 */ 1040 void setFirstSectionFromFirstPageNumber(); 1041 /** 1042 * @param pageIndex page nr 1043 * @brief Returns name of section where page is located 1044 */ 1045 QString getSectionNameForPageIndex(uint pageIndex) const; 1046 1047 /** 1048 * Update annotation links when a page is added 1049 */ 1050 void addPageToAnnotLinks(int otherPageIndex, int location, int count=1); 1051 1052 /** 1053 * Update annotation links when a page is removed 1054 */ 1055 void removePageFromAnnotLinks(int pageIndex); 1056 1057 //! @brief Some internal align tools 1058 typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo; 1059 typedef enum {alignByMoving, alignByResizing } AlignMethod; 1060 void buildAlignItemList(Selection* customSelection = nullptr); 1061 bool startAlign(uint minObjects = 1); 1062 void endAlign(); 1063 /** 1064 * \brief Insert a color into the documents color list 1065 * @param nam Name of the colour 1066 * @param c Cyan component 1067 * @param m Magenta component 1068 * @param y Yellow component 1069 * @param k Black component 1070 */ 1071 void insertColor(const QString& name, double c, double m, double y, double k); 1072 constants()1073 QMap<QString, double>& constants() { return m_constants; } 1074 /** 1075 * \brief Get the location of the page on the canvas, ie, left, middle, or right 1076 * Does not give information about middle left, etc. 1077 * @param pageIndex Index of page to find location for 1078 * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h 1079 */ 1080 PageLocation locationOfPage(int pageIndex) const; 1081 /** 1082 * \brief Get the column of the page on the canvas, ie, left, middle, or right 1083 * @param pageIndex Index of page to find location for 1084 * @return int of 0,1,2,3 1085 */ 1086 int columnOfPage(int pageIndex) const; 1087 1088 1089 QList<PageItem*>* groupOfItem(QList<PageItem*>* itemList, PageItem* item); 1090 PageItem* groupObjectsSelection(Selection* customSelection = nullptr); 1091 PageItem* groupObjectsList(QList<PageItem*> &itemList); 1092 void groupObjectsToItem(PageItem* groupItem, QList<PageItem*> &itemList); 1093 PageItem * itemSelection_GroupObjects (bool changeLock, bool lock, Selection* customSelection = nullptr, PageItem_Group* groupItem = nullptr); 1094 void itemSelection_UnGroupObjects(Selection* customSelection = nullptr); 1095 void addToGroup(PageItem* group, PageItem* item); 1096 void removeFromGroup(PageItem* item); 1097 void rescaleGroup(PageItem* group, double scale); 1098 void resizeGroupToContents(PageItem* group); 1099 void itemSelection_resizeGroupToContents(Selection* customSelection = nullptr); 1100 void itemSelection_convertItemsTo(const PageItem::ItemType newType, Selection* restoredSelection=0, Selection* customSelection = nullptr); 1101 void itemSelection_convertItemsToSymbol(QString& patternName); 1102 void itemSelection_ApplyParagraphStyle(const ParagraphStyle & newstyle, Selection* customSelection = nullptr, bool rmDirectFormatting = false); 1103 void itemSelection_SetParagraphStyle(const ParagraphStyle & newstyle, Selection* customSelection = nullptr); 1104 void itemSelection_ApplyCharStyle(const CharStyle & newstyle, Selection* customSelection = nullptr, const QString& ETEA = ""); 1105 void itemSelection_SetCharStyle(const CharStyle & newstyle, Selection* customSelection = nullptr); 1106 void itemSelection_EraseParagraphStyle(Selection* customSelection = nullptr); 1107 void itemSelection_EraseCharStyle(Selection* customSelection = nullptr); 1108 void itemSelection_SetNamedParagraphStyle(const QString & name, Selection* customSelection = nullptr); 1109 void itemSelection_SetNamedCharStyle(const QString & name, Selection* customSelection = nullptr); 1110 void itemSelection_SetNamedLineStyle(const QString & name, Selection* customSelection = nullptr); 1111 void itemSelection_SetSoftShadow(bool has, QString color, double dx, double dy, double radius, int shade, double opac, int blend, bool erase, bool objopa); 1112 void itemSelection_SetLineWidth(double w, Selection* customSelection = nullptr); 1113 void itemSelection_SetLineArt(Qt::PenStyle w, Selection* customSelection = nullptr); 1114 void itemSelection_SetLineJoin(Qt::PenJoinStyle w, Selection* customSelection = nullptr); 1115 void itemSelection_SetLineEnd(Qt::PenCapStyle w, Selection* customSelection = nullptr); 1116 void itemSelection_SetAlignment(int w, Selection* customSelection = nullptr); 1117 void itemSelection_SetDirection(int w, Selection* customSelection = nullptr); 1118 void itemSelection_SetLineSpacing(double w, Selection* customSelection = nullptr); 1119 void itemSelection_SetLineSpacingMode(int w, Selection* customSelection = nullptr); 1120 void itemSelection_SetLanguage(const QString& w, Selection* customSelection = nullptr); 1121 void itemSelection_SetFont(const QString& font, Selection* customSelection = nullptr); 1122 void itemSelection_SetFontSize(int size, Selection* customSelection = nullptr); 1123 void itemSelection_SetFontFeatures(const QString& fontfeature, Selection* customSelection = nullptr); 1124 void itemSelection_SetParBackgroundColor(QString farbe, Selection* customSelection = nullptr); 1125 void itemSelection_SetParBackgroundShade(int sha, Selection* customSelection = nullptr); 1126 void itemSelection_SetBackgroundColor(QString farbe, Selection* customSelection = nullptr); 1127 void itemSelection_SetBackgroundShade(int sha, Selection* customSelection = nullptr); 1128 void itemSelection_SetFillColor(QString farbe, Selection* customSelection = nullptr); 1129 void itemSelection_SetFillShade(int sha, Selection* customSelection = nullptr); 1130 void itemSelection_SetStrokeColor(QString farbe, Selection* customSelection = nullptr); 1131 void itemSelection_SetStrokeShade(int sha, Selection* customSelection = nullptr); 1132 void itemSelection_SetScaleV(int, Selection* customSelection = nullptr); 1133 void itemSelection_SetScaleH(int, Selection* customSelection = nullptr); 1134 void itemSelection_SetBaselineOffset(int, Selection* customSelection = nullptr); 1135 void itemSelection_SetOutlineWidth(int, Selection* customSelection = nullptr); 1136 void itemSelection_SetShadowOffsets(int shx, int shy, Selection* customSelection = nullptr); 1137 void itemSelection_SetUnderline(int pos, int wid, Selection* customSelection = nullptr); 1138 void itemSelection_SetStrikethru(int pos, int wid, Selection* customSelection = nullptr); 1139 void itemSelection_SetEffects(int s, Selection* customSelection = nullptr); 1140 void itemSelection_SetOpticalMargins(int i, Selection* customSelection = nullptr); 1141 void itemSelection_resetOpticalMargins(Selection* customSelection = nullptr); 1142 void itemSelection_SetColorProfile(const QString& profileName, Selection* customSelection = nullptr); 1143 void itemSelection_SetRenderIntent(int intentIndex, Selection* customSelection = nullptr); 1144 void itemSelection_SetCompressionMethod(int cmIndex, Selection* customSelection = nullptr); 1145 void itemSelection_SetCompressionQuality(int cqIndex, Selection* customSelection = nullptr); 1146 void itemSelection_SetTracking(int us, Selection* customSelection = nullptr); 1147 void MirrorPolyH(PageItem *currItem); 1148 void MirrorPolyV(PageItem *currItem); 1149 bool getItem(PageItem **currItem, int nr = -1); 1150 void setFrameRect(); 1151 void setFrameRounded(); 1152 void setFrameOval(); 1153 1154 void setRedrawBounding(PageItem *currItem); 1155 void adjustCanvas(const FPoint& minPos, const FPoint& maxPos, bool absolute = false); 1156 struct PicResMapped 1157 { PicResMappedPicResMapped1158 PicResMapped(bool applyNewRes, int lowResType) { m_applyNewRes = applyNewRes; m_lowResType = lowResType;} 1159 operatorPicResMapped1160 void operator()(PageItem *item) 1161 { 1162 QList<PageItem*> allItems; 1163 if (item->isGroup()) 1164 allItems = item->asGroupFrame()->getAllChildren(); 1165 else 1166 allItems.append(item); 1167 for (int ii = 0; ii < allItems.count(); ii++) 1168 { 1169 item = allItems.at(ii); 1170 if (item->imageIsAvailable) 1171 { 1172 bool fho = item->imageFlippedH(); 1173 bool fvo = item->imageFlippedV(); 1174 if (m_applyNewRes) 1175 item->pixm.imgInfo.lowResType = m_lowResType; 1176 if (item->isLatexFrame()) 1177 item->asLatexFrame()->rerunApplication(false); 1178 else 1179 item->loadImage(item->Pfile, true, -1, false); 1180 item->setImageFlippedH(fho); 1181 item->setImageFlippedV(fvo); 1182 item->adjustPictScale(); 1183 } 1184 } 1185 allItems.clear(); 1186 } 1187 1188 bool m_applyNewRes; 1189 int m_lowResType; 1190 }; 1191 1192 enum RecalcPictureResFlags 1193 { 1194 RecalcPicRes_ApplyNewRes = 1, 1195 RecalcPicRes_ImageWithEffectsOnly = 2, 1196 RecalcPicRes_ImageWithColorEffectsOnly = 4, 1197 }; 1198 void recalcPicturesRes(int recalcFlags = 0); 1199 1200 int previewQuality(); 1201 void connectDocSignals(); 1202 void disconnectDocSignals(); 1203 void removeLayer(int l, bool dl = false); //FIXME: Make protected once scripter function no longer uses this directly 1204 /*! \brief We call changed() whenever the document needs to know it has been changed. 1205 * If the document is the primary document in a main window, it will signal to enable/disable 1206 * certain operations. 1207 */ 1208 void changed(); 1209 /*! \brief Get pointer to the current page 1210 \retval Page* current page object */ 1211 ScPage* currentPage(); 1212 /*! \brief Set new current page 1213 \param newPage New current page */ 1214 void setCurrentPage(ScPage *newPage); hasGUI()1215 bool hasGUI() const {return m_hasGUI;} 1216 /*! \brief Apply grid to a QPoint, from ScribusView */ 1217 QPoint ApplyGrid(const QPoint& in); 1218 /*! \brief Apply grid to an FPoint, from ScribusView */ 1219 FPoint ApplyGridF(const FPoint& in); 1220 /*! \brief Apply grid to an QRectF, from ScribusView */ 1221 QRectF ApplyGridF(const QRectF& in); 1222 /*! \brief Does this doc have any TOC setups and potentially a TOC to generate */ hasTOCSetup()1223 bool hasTOCSetup() { return !m_docPrefsData.tocPrefs.defaultToCSetups.empty(); } 1224 1225 enum SelectionSkipBehavior 1226 { 1227 IncludeSelection = 0, 1228 ExcludeSelection = 1 1229 }; 1230 1231 //! \brief Get the closest guide to the given point 1232 void getClosestGuides(double xin, double yin, double *xout, double *yout, ScPage* refPage = nullptr); 1233 //! \brief Get the closest border of another element to the given point 1234 void getClosestElementBorder(double xin, double yin, double *xout, double *yout, SelectionSkipBehavior behavior = IncludeSelection); 1235 //! \brief Get the closest page margin or bleed 1236 void getClosestPageBoundaries(double xin, double yin, double &xout, double &yout, ScPage* refPage); 1237 //! \brief Snap an item to the guides 1238 void SnapToGuides(PageItem *currItem); 1239 bool ApplyGuides(double *x, double *y, bool elementSnap = false); 1240 bool ApplyGuides(FPoint* point, bool elementSnap = false); 1241 1242 bool moveItem(double newX, double newY, PageItem* ite); 1243 void rotateItem(double win, PageItem *currItem); 1244 void moveRotated(PageItem *currItem, const FPoint& npv); 1245 bool sizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true); 1246 bool moveSizeItem(const FPoint& newX, const FPoint& newY, PageItem* currItem, bool fromMP = false, bool constrainRotation = false); 1247 void adjustItemSize(PageItem *currItem, bool includeGroup = false); 1248 void moveGroup(double x, double y, Selection* customSelection = nullptr); 1249 void rotateGroup(double angle, Selection* customSelection = nullptr); 1250 void rotateGroup(double angle, const FPoint& RCenter, Selection* customSelection = nullptr); 1251 void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = nullptr, bool scaleLine = false); 1252 //! \brief Get a list of frames of certain type 1253 QHash<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType); 1254 //! \brief Returns a serializer for this document 1255 Serializer *serializer(); 1256 //! \brief Returns a text serializer for this document, used to paste text chunks 1257 Serializer *textSerializer(); 1258 1259 //! \brief Retrieve canvas position of text char in specified text chain 1260 bool textCanvasPosition(PageItem* item, int textPos, QPointF& canvasPos); 1261 1262 //! \brief Get rotation mode rotationMode()1263 int rotationMode() const {return m_rotMode;} 1264 //! \brief Set rotation mode 1265 void setRotationMode(int val); 1266 1267 //! \brief Fonctions which avoid doc updater and update manager to send too much 1268 // unncessary signals when doing updates on multiple items 1269 void beginUpdate(); 1270 void endUpdate(); 1271 1272 int addToInlineFrames(PageItem *item); 1273 void removeInlineFrame(int fIndex); 1274 void checkItemForFrames(PageItem *it, int fIndex); 1275 bool hasPreflightErrors(); filePermissions()1276 QFileDevice::Permissions filePermissions() { return m_docFilePermissions; } saveFilePermissions(QFileDevice::Permissions p)1277 void saveFilePermissions(QFileDevice::Permissions p) { m_docFilePermissions=p; } 1278 1279 protected: 1280 void addSymbols(); 1281 void applyPrefsPageSizingAndMargins(bool resizePages, bool resizeMasterPages, bool resizePageMargins, bool resizeMasterPageMargins); 1282 bool m_hasGUI {false}; 1283 QFileDevice::Permissions m_docFilePermissions {QFileDevice::ReadOwner|QFileDevice::WriteOwner}; 1284 ApplicationPrefs& m_appPrefsData; 1285 ApplicationPrefs m_docPrefsData; 1286 UndoManager * const m_undoManager; 1287 bool m_loading {false}; 1288 bool m_modified {false}; 1289 int m_undoRedoOngoing {0}; 1290 int m_ActiveLayer {0}; 1291 double m_docUnitRatio; 1292 int m_rotMode {0}; 1293 bool m_automaticTextFrames; // Flag for automatic Textframes 1294 bool m_masterPageMode {false}; 1295 bool m_symbolEditMode {false}; 1296 bool m_inlineEditMode {false}; 1297 int m_storedLayerID {0}; 1298 bool m_storedLayerLock {false}; 1299 bool m_storedLayerVis {false}; 1300 QMap<QString, double> m_constants; 1301 ScribusMainWindow* m_ScMW {nullptr}; 1302 ScribusView* m_View {nullptr}; 1303 ScGuardedObject<ScribusDoc> m_guardedObject; 1304 Serializer *m_serializer {nullptr}; 1305 Serializer *m_tserializer {nullptr}; 1306 QString m_currentEditedSymbol; 1307 int m_currentEditedIFrame {0}; 1308 QString m_documentFileName; 1309 1310 public: // Public attributes 1311 bool is12doc {false}; //public for now, it will be removed later 1312 int NrItems {0}; 1313 int First {1}; 1314 int Last {0}; 1315 int viewCount {0}; 1316 int viewID {0}; 1317 bool SnapGrid {false}; 1318 bool SnapGuides {false}; 1319 bool SnapElement {false}; 1320 bool GuideLock {false}; 1321 bool dontResize {false}; 1322 /** \brief Minimum and Maximum Points of Document */ 1323 FPoint minCanvasCoordinate; 1324 FPoint maxCanvasCoordinate; 1325 double rulerXoffset {0.0}; 1326 double rulerYoffset {0.0}; 1327 //! Pages is a pointer to the lists of pages that exist in a document. In Normal mode, it points to DocPages. In Master Page mode it points to MasterPages. See ScribusDoc::assignPageModeLists() 1328 QList<ScPage*>* Pages {nullptr}; 1329 /** \brief List of Master Pages */ 1330 QList<ScPage*> MasterPages; 1331 /** \brief List of Document Pages */ 1332 QList<ScPage*> DocPages; 1333 /** \brief List for temporary Pages */ 1334 QList<ScPage*> TempPages; 1335 /** \brief Mapping Master Page Name to Master Page numbers */ 1336 QMap<QString,int> MasterNames; 1337 /** \brief List of Objects */ 1338 //! Items is a pointer to the lists of items that exist in a document. In Normal mode, it points to DocItems. In Master Page mode it points to MasterItems. See ScribusDoc::assignPageModeLists() 1339 QList<PageItem*>* Items {nullptr}; 1340 //! The list of master page items 1341 QList<PageItem*> MasterItems; 1342 //! The list of page items 1343 QList<PageItem*> DocItems; 1344 QHash<int, PageItem*> FrameItems; 1345 QList<PageItem*> EditFrameItems; 1346 1347 Selection* const m_Selection; 1348 /** \brief Number of Columns */ 1349 double PageSp {1.0}; 1350 /** \brief Distance of Columns */ 1351 double PageSpa {0.0}; 1352 ///** \brief current Pagelayout */ 1353 //int currentPageLayout; 1354 /** \brief First page number in document */ 1355 int FirstPnum {1}; 1356 /** \brief Im Dokument benutzte Farben */ 1357 ColorList PageColors; 1358 int appMode {modeNormal}; 1359 int SubMode {-1}; 1360 double *ShapeValues {nullptr}; 1361 int ValCount {0}; 1362 QMap<QString,int> UsedFonts; 1363 SCFonts * const AllFonts; 1364 QList<AlignObjs> AObjects; 1365 ParagraphStyle currentStyle; 1366 NodeEditContext nodeEdit; 1367 /** \brief Letztes Element fuer AutoTextrahmen */ 1368 PageItem *LastAuto {nullptr}; 1369 /** \brief Erstes Element fuer AutoTextrahmen */ 1370 PageItem *FirstAuto {nullptr}; 1371 bool DragP {false}; 1372 bool leaveDrag {false}; 1373 PageItem *DraggedElem {nullptr}; 1374 PageItem *ElemToLink {nullptr}; 1375 QList<PageItem*> DragElements; 1376 1377 private: 1378 StyleSet<ParagraphStyle> m_docParagraphStyles; 1379 StyleSet<CharStyle> m_docCharStyles; 1380 StyleSet<TableStyle> m_docTableStyles; 1381 StyleSet<CellStyle> m_docCellStyles; 1382 1383 public: 1384 ScLayers Layers; 1385 //bool marginColored; 1386 int GroupCounter {1}; 1387 1388 ScColorMgmtEngine colorEngine; 1389 ScColorProfile DocInputImageRGBProf; 1390 ScColorProfile DocInputImageCMYKProf; 1391 ScColorProfile DocInputRGBProf; 1392 ScColorProfile DocInputCMYKProf; 1393 ScColorProfile DocDisplayProf; 1394 ScColorProfile DocPrinterProf; 1395 ScColorTransform stdTransRGBMon; 1396 ScColorTransform stdTransCMYKMon; 1397 ScColorTransform stdProof; 1398 ScColorTransform stdTransImg; 1399 ScColorTransform stdProofImg; 1400 ScColorTransform stdProofImgCMYK; 1401 ScColorTransform stdTransCMYK; 1402 ScColorTransform stdProofCMYK; 1403 ScColorTransform stdTransRGB; 1404 ScColorTransform stdProofGC; 1405 ScColorTransform stdProofCMYKGC; 1406 ScColorTransform stdLabToRGBTrans; 1407 ScColorTransform stdLabToCMYKTrans; 1408 ScColorTransform stdLabToScreenTrans; 1409 ScColorTransform stdProofLab; 1410 ScColorTransform stdProofLabGC; 1411 bool BlackPoint {true}; 1412 bool SoftProofing {false}; 1413 bool Gamut {false}; 1414 eRenderIntent IntentColors; 1415 eRenderIntent IntentImages; 1416 bool HasCMS {false}; 1417 QMap<QString,QString> JavaScripts; 1418 int TotalItems {0}; 1419 PrintOptions Print_Options; 1420 bool RePos {false}; 1421 struct BookMa { 1422 QString Title; 1423 QString Text; 1424 QString Aktion; 1425 PageItem *PageObject; 1426 int Parent; 1427 int ItemNr; 1428 int First; 1429 int Last; 1430 int Prev; 1431 int Next; 1432 1433 bool operator<(const BookMa& other) const { return ItemNr < other.ItemNr; } 1434 }; 1435 QList<BookMa> BookMarks; 1436 bool hasName {false}; 1437 bool isConverted {false}; 1438 QTimer * const autoSaveTimer; 1439 QList<QString> autoSaveFiles; 1440 QHash<QString, multiLine> docLineStyles; 1441 QHash<QString, ScPattern> docPatterns; 1442 QHash<QString, VGradient> docGradients; 1443 QWidget* WinHan {nullptr}; 1444 bool DoDrawing {true}; 1445 bool drawAsPreview {false}; 1446 bool viewAsPreview {false}; 1447 bool editOnPreview {false}; 1448 int previewVisual {0}; 1449 struct OpenNodesList 1450 { 1451 int type; 1452 ScPage *page; 1453 PageItem *item; 1454 }; 1455 QList<OpenNodesList> OpenNodes; 1456 QTimer *CurTimer {nullptr}; 1457 QMap<int, errorCodes> pageErrors; 1458 QMap<int, errorCodes> docLayerErrors; 1459 QMap<PageItem*, errorCodes> docItemErrors; 1460 QMap<PageItem*, errorCodes> masterItemErrors; 1461 FPointArray symReturn; 1462 FPointArray symNewLine; 1463 FPointArray symTab; 1464 FPointArray symNonBreak; 1465 FPointArray symNewCol; 1466 FPointArray symNewFrame; 1467 1468 Hyphenator* docHyphenator {nullptr}; 1469 void itemResizeToMargin(PageItem* item, int direction); //direction reflect enum numbers from Canvas::FrameHandle 1470 1471 private: 1472 UndoTransaction m_itemCreationTransaction; 1473 UndoTransaction m_alignTransaction; 1474 1475 ScPage* m_currentPage {nullptr}; 1476 UpdateManager m_updateManager; 1477 MassObservable<PageItem*> m_itemsChanged; 1478 MassObservable<ScPage*> m_pagesChanged; 1479 MassObservable<QRectF> m_regionsChanged; 1480 DocUpdater* m_docUpdater {nullptr}; 1481 1482 signals: 1483 //Lets make our doc talk to our GUI rather than confusing all our normal stuff 1484 /** 1485 * @brief Let the document tell whatever is listening that it has changed 1486 */ 1487 void docChanged(); 1488 void updateContents(); 1489 void updateContents(const QRect &r); 1490 void firstSelectedItemType(int); 1491 1492 void updateEditItem(); 1493 void updateAutoSaveClock(); 1494 void addBookmark(PageItem *); 1495 void deleteBookmark(PageItem *); 1496 1497 public slots: 1498 void selectionChanged(); 1499 void itemSelection_ToggleLock(); 1500 void itemSelection_ToggleSizeLock(); 1501 void itemSelection_ToggleImageShown(); 1502 void itemSelection_TogglePrintEnabled(); 1503 void itemSelection_ToggleBookMark(Selection* customSelection = nullptr); 1504 void itemSelection_ToggleAnnotation(Selection* customSelection = nullptr); 1505 void itemSelection_Transform(int nrOfCopies, const QTransform& matrix, int basepoint); 1506 void itemSelection_ChangePreviewResolution(int id); 1507 1508 /*! \brief Change display quality of all images in document. 1509 \author OssiLehtinen 1510 */ 1511 void allItems_ChangePreviewResolution(int id); 1512 1513 //FIXME : change to process a selection 1514 void item_setFrameShape(PageItem* item, int frameType, int count, double* points); 1515 1516 void itemSelection_ClearItem(Selection* customSelection = nullptr, bool useWarning=false); 1517 void itemSelection_TruncateItem(Selection* customSelection = nullptr); 1518 //! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation 1519 void itemSelection_DeleteItem(Selection* customSelection = nullptr, bool forceDeletion=false); 1520 void itemSelection_SetItemFillTransparency(double t, Selection* customSelection = nullptr); 1521 void itemSelection_SetHyphenWordMin(int wordMin, Selection* customSelection = nullptr); 1522 void itemSelection_SetHyphenConsecutiveLines(int consecutiveLines, Selection* customSelection = nullptr); 1523 void itemSelection_SetHyphenChar(uint hyphenChar, Selection* customSelection = nullptr); 1524 void itemSelection_SetItemLineTransparency(double t, Selection* customSelection = nullptr); 1525 void itemSelection_SetItemFillBlend(int t); 1526 void itemSelection_SetItemLineBlend(int t); 1527 void itemSelection_SetLineGradient(VGradient& newGradient, Selection* customSelection = nullptr); 1528 void itemSelection_SetFillGradient(VGradient& newGradient, Selection* customSelection = nullptr); 1529 void itemSelection_SetMaskGradient(VGradient& newGradient, Selection* customSelection = nullptr); 1530 void itemSelection_SetOverprint(bool overprint, Selection* customSelection = nullptr); 1531 void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection = nullptr); 1532 void itemSelection_FlipH(Selection* customSelection = nullptr); 1533 void itemSelection_FlipV(Selection* customSelection = nullptr); 1534 void itemSelection_Rotate(double angle, Selection* customSelection = nullptr); 1535 void itemSelection_DoHyphenate(); 1536 void itemSelection_DoDeHyphenate(); 1537 void itemSelection_UnlinkTextFrameAndCutText(Selection* customSelection = nullptr); 1538 void itemSelection_SendToLayer(int layerID); 1539 void itemSelection_SetImageOffset(double x, double y, Selection* customSelection = nullptr); 1540 void itemSelection_SetImageScale(double x, double y, Selection* customSelection = nullptr); 1541 void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection = nullptr); 1542 void itemSelection_SetImageRotation(double rot, Selection* customSelection = nullptr); 1543 void itemSelection_AlignItemLeft(int i, double newX, ScribusDoc::AlignMethod how); 1544 void itemSelection_AlignItemRight(int i, double newX, ScribusDoc::AlignMethod how); 1545 void itemSelection_AlignItemTop(int i, double newY, ScribusDoc::AlignMethod how); 1546 void itemSelection_AlignItemBottom(int i, double newY, ScribusDoc::AlignMethod how); 1547 void itemSelection_AlignLeftOut(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1548 void itemSelection_AlignRightOut(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1549 void itemSelection_AlignBottomIn(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1550 void itemSelection_AlignRightIn(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1551 void itemSelection_AlignBottomOut(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1552 void itemSelection_AlignCenterHor(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1553 void itemSelection_AlignLeftIn(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1554 void itemSelection_AlignCenterVer(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1555 void itemSelection_AlignTopOut(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1556 void itemSelection_AlignTopIn(ScribusDoc::AlignTo currAlignTo, ScribusDoc::AlignMethod currAlignMethod, double guidePosition); 1557 1558 void sendItemSelectionToBack(); 1559 void bringItemSelectionToFront(); 1560 void itemSelection_LowerItem(); 1561 void itemSelection_RaiseItem(); 1562 void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0, bool reverseDistribute=false); 1563 void itemSelection_DistributeAcrossPage(bool useMargins=false); 1564 void itemSelection_DistributeRight(); 1565 void itemSelection_DistributeBottom(); 1566 void itemSelection_DistributeCenterH(); 1567 void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0, bool reverseDistribute=false); 1568 void itemSelection_DistributeDownPage(bool useMargins=false); 1569 void itemSelection_DistributeLeft(); 1570 void itemSelection_DistributeCenterV(); 1571 void itemSelection_DistributeTop(); 1572 void itemSelection_SwapLeft(); 1573 void itemSelection_SwapRight(); 1574 void itemSelection_Duplicate(double shiftX, double shiftY, Selection* customSelection = nullptr); 1575 void itemSelection_MultipleDuplicate(const ItemMultipleDuplicateData&, Selection* customSelection = nullptr); 1576 void itemSelection_UniteItems(Selection* customSelection = nullptr); 1577 void itemSelection_SplitItems(Selection* customSelection = nullptr); 1578 /** 1579 * Adjust an image frame's size to fit the size of the image in it 1580 */ 1581 void itemSelection_AdjustFrametoImageSize(Selection* customSelection = nullptr); 1582 /** 1583 * Adjust an image size to fit the size of the frame 1584 */ 1585 void itemSelection_AdjustImagetoFrameSize(Selection* customSelection = nullptr); 1586 void itemSelection_AdjustFrameHeightToText( Selection *customSelection = nullptr); 1587 //! @brief startArrowID or endArrowID of -1 mean not applying a selection at this point. 1588 void itemSelection_ApplyArrowHead(int startArrowID=-1, int endArrowID=-1, Selection* customSelection = nullptr); 1589 void itemSelection_ApplyArrowScale(int startArrowSc, int endArrowSc, Selection* customSelection); 1590 1591 void itemSelection_SetItemPen(QString color, Selection* customSelection = nullptr); 1592 void itemSelection_SetItemPenShade(int sha, Selection* customSelection = nullptr); 1593 void itemSelection_SetItemGradStroke(int typ, Selection* customSelection = nullptr); 1594 void itemSelection_SetItemBrush(QString colorName, Selection* customSelection = nullptr); 1595 void itemSelection_SetItemBrushShade(int sha, Selection* customSelection = nullptr); 1596 void itemSelection_SetItemGradMask(int typ, Selection* customSelection = nullptr); 1597 void itemSelection_SetItemGradFill(int typp, Selection* customSelection = nullptr); 1598 void itemSelection_SetItemPatternFill(const QString& pattern, Selection* customSelection = nullptr); 1599 void itemSelection_SetItemPatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY); 1600 void itemSelection_SetItemStrokePattern(const QString& pattern, Selection* customSelection = nullptr); 1601 void itemSelection_SetItemStrokePatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, double space, bool mirrorX, bool mirrorY, Selection* customSelection = nullptr); 1602 void itemSelection_SetItemStrokePatternType(bool type, Selection* customSelection = nullptr); 1603 void itemSelection_SetItemPatternMask(const QString& pattern, Selection* customSelection = nullptr); 1604 void itemSelection_SetItemPatternMaskProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY, Selection* customSelection = nullptr); 1605 1606 // Table related slots. 1607 1608 /** 1609 * Inserts rows in a table. 1610 * 1611 * The user will be prompted by a dialog for the number of rows and where they should 1612 * be inserted. If in table edit mode, rows may be inserted before or after the active 1613 * cell. If in normal mode, rows may be inserted at the beginning or end of the selected 1614 * table. 1615 * 1616 * If no table is selected, then this slot does nothing. 1617 */ 1618 void itemSelection_InsertTableRows(); 1619 1620 /** 1621 * Inserts columns in a table. 1622 * 1623 * The user will be prompted by a dialog for the number of columns and where they should 1624 * be inserted. If in table edit mode, columns may be inserted before or after the active 1625 * cell. If in normal mode, columns may be inserted at the beginning or end of the selected 1626 * table. 1627 * 1628 * If no table is selected, then this slot does nothing. 1629 */ 1630 void itemSelection_InsertTableColumns(); 1631 1632 /** 1633 * Deletes rows in a table. 1634 * 1635 * If the there is a cell selection, all rows spanned by the selection will be deleted. 1636 * If there is no cell selection, the rows spanned by the active cell will be deleted. 1637 * 1638 * If no table is selected, or if the application is not in table edit mode, then this slot 1639 * does nothing. 1640 */ 1641 void itemSelection_DeleteTableRows(); 1642 1643 /** 1644 * Deletes columns in a table. 1645 * 1646 * If the there is a cell selection, all columns spanned by the selection will be deleted. 1647 * If there is no cell selection, the columns spanned by the active cell will be deleted. 1648 * 1649 * If no table is selected, or if the application is not in table edit mode, then this slot 1650 * does nothing. 1651 */ 1652 void itemSelection_DeleteTableColumns(); 1653 1654 /** 1655 * Merges the selected cells in a table. 1656 * 1657 * The merged area will span from the top left to the bottom right of the selected cells. 1658 * 1659 * If no table is selected, or if the application is not in table edit mode, or if less 1660 * than two cells is selected, then this slot does nothing. 1661 */ 1662 void itemSelection_MergeTableCells(); 1663 1664 /** 1665 * Splits cells in a table. 1666 * 1667 * TODO: Implement this. 1668 */ itemSelection_SplitTableCells()1669 void itemSelection_SplitTableCells() {} 1670 1671 /** 1672 * Sets the height of rows in a table. 1673 * 1674 * The user will be prompted by a dialog for entering a row height. If in table editing 1675 * mode, all rows of the table will get their height set. If the there is a cell selection, 1676 * all rows spanned by the selection will get their height set. If there is no cell 1677 * selection, the rows spanned by the active cell will get their height set. 1678 * 1679 * If no table is selected, then this slot does nothing. 1680 */ 1681 void itemSelection_SetTableRowHeights(); 1682 1683 /** 1684 * Sets the width of columns in a table. 1685 * 1686 * The user will be prompted by a dialog for entering a column width. If in table editing 1687 * mode, all columns of the table will get their width set. If the there is a cell selection, 1688 * all columns spanned by the selection will get their width set. If there is no cell 1689 * selection, the columns spanned by the active cell will get their width set. 1690 * 1691 * If no table is selected, then this slot does nothing. 1692 */ 1693 void itemSelection_SetTableColumnWidths(); 1694 1695 /** 1696 * Distributes rows in a table evenly. 1697 * 1698 * If in table edit mode and there is a cell selection, each contigous range of selected rows 1699 * is distributed. If there is no cell selection, all rows in the table are distributed. 1700 * 1701 * If there is no table selected, then this slot does nothing. 1702 */ 1703 void itemSelection_DistributeTableRowsEvenly(); 1704 1705 /** 1706 * Distributes columns in a table evenly. 1707 * 1708 * If in table edit mode and there is a cell selection, each contigous range of selected columns 1709 * is distributed. If there is no cell selection, all columns in the table are distributed. 1710 * 1711 * If there is no table selected, then this slot does nothing. 1712 */ 1713 void itemSelection_DistributeTableColumnsEvenly(); 1714 1715 /** 1716 * Adjusts the size of the frames of any selected tables to fit the size of the tables they contain. 1717 * 1718 * If there are no tables in the current selection, then this slot does nothing. 1719 */ 1720 void itemSelection_AdjustFrameToTable(); 1721 1722 /** 1723 * Adjusts the size of any selected tables to fit the size of their frames. 1724 * 1725 * If there are no tables in the current selection, then this slot does nothing. 1726 */ 1727 void itemSelection_AdjustTableToFrame(); 1728 1729 void undoRedoBegin(); 1730 void undoRedoDone(); 1731 1732 void updatePic(); 1733 void updatePict(const QString& name); 1734 void updatePictDir(const QString& name); 1735 void removePict(const QString& name); 1736 1737 // Marks and notes 1738 public: 1739 /** 1740 * Explanation 1741 * master frame - text frame with marks for notes 1742 * notesframe - frame with notes 1743 * master & note mark - master is mark in "master" text, note mark is at beginning of note in noteframe 1744 */ 1745 1746 //return page where endnotesframe should be located depending of notes style range and location of master mark 1747 const ScPage* page4EndNotes(NotesStyle* NS, PageItem* item); 1748 1749 //data handling structures 1750 private: 1751 QList<Mark*> m_docMarksList; 1752 QList<TextNote*> m_docNotesList; 1753 //flags used for indicating needs of updates 1754 bool m_flag_notesChanged {false}; 1755 1756 void multipleDuplicateByPage(const ItemMultipleDuplicateData& mdData, Selection& selection, QString& tooltip); 1757 1758 public: marksList()1759 const QList<Mark*>& marksList() { return m_docMarksList; } notesList()1760 const QList<TextNote*>& notesList() { return m_docNotesList; } 1761 QList<NotesStyle*> m_docNotesStylesList; 1762 QMap<PageItem_NoteFrame*, rangeItem> m_docEndNotesFramesMap; 1763 QList<NotesStyle*> ns2Update; //list of notes styles to update 1764 1765 //returns list of notesframes for given Notes Style 1766 QList<PageItem_NoteFrame*> listNotesFrames(NotesStyle* NS); 1767 1768 //flags used for indicating needs of updates notesChanged()1769 bool notesChanged() { return m_flag_notesChanged; } setNotesChanged(bool on)1770 void setNotesChanged(bool on) { m_flag_notesChanged = on; } 1771 bool flag_restartMarksRenumbering {false}; 1772 bool flag_updateMarksLabels {false}; 1773 bool flag_updateEndNotes {false}; 1774 bool flag_layoutNotesFrames {true}; 1775 1776 //returns list of marks labels for given mark type 1777 QStringList marksLabelsList(MarkType type); 1778 1779 //return mark with given label and given type 1780 Mark* getMark(const QString& label, MarkType type); //returns mark with label and type (labels are unique only for same type marks) 1781 Mark* newMark(Mark* mrk = nullptr); 1782 TextNote* newNote(NotesStyle* NS); 1783 1784 bool isMarkUsed(const Mark* mrk, bool visible = false) const; 1785 //set cursor in text where given mark will be found 1786 void setCursor2MarkPos(const Mark* mark); 1787 //return false if mark was not found 1788 bool eraseMark(Mark* mrk, bool fromText=false, PageItem* item = nullptr, bool force = false); //force is used only for deleting non-unique marks by MarksManager 1789 void setUndoDelMark(Mark* mrk); 1790 //invalidate all text frames where given mark will found 1791 //useful spacially for varaible text marks after changing its text definition 1792 //if forceUpdate then found master frames are relayouted 1793 bool invalidateVariableTextFrames(Mark* mrk, bool forceUpdate = false); //returns if any text was changed 1794 1795 //for foot/endnotes 1796 NotesStyle* newNotesStyle(const NotesStyle& NS); 1797 void renameNotesStyle(NotesStyle* NS, const QString& newName); 1798 //delete whole notes style with its notesframes and notes 1799 void deleteNotesStyle(const QString& nsName); 1800 void undoSetNotesStyle(SimpleState* ss, NotesStyle* ns); 1801 NotesStyle* getNotesStyle(const QString& nsName); 1802 //delete note, if fromText than marks for given note will be removed 1803 void deleteNote(TextNote* note); 1804 void setUndoDelNote(TextNote* note); 1805 PageItem_NoteFrame* createNoteFrame(PageItem_TextFrame* inFrame, NotesStyle *nStyle, int index = -1); 1806 PageItem_NoteFrame* createNoteFrame(NotesStyle *nStyle, double x, double y, double w, double h, double w2, const QString& fill, const QString& outline); 1807 //delete noteframe 1808 void delNoteFrame(PageItem_NoteFrame *nF, bool removeMarks=true, bool forceDeletion = true); 1809 //renumber notes for given notes style 1810 //return true if doc needs update after changing numbers of notes 1811 bool updateNotesNums(NotesStyle* nStyle); 1812 //set new text styles for notes marks 1813 void updateNotesFramesStyles(NotesStyle* nStyle); 1814 //check conflicts beetween notes styles 1815 bool validateNSet(const NotesStyle& NS, QString newName = ""); 1816 //update layout remove empty notesframes 1817 bool notesFramesUpdate(); 1818 //update notesframes after changing automatic features of notes style 1819 void updateNotesFramesSettings(NotesStyle* NS); 1820 1821 //search for endnotesframe for given notes style and item holding master mark 1822 PageItem_NoteFrame* endNoteFrame(NotesStyle* nStyle, PageItem_TextFrame* master); 1823 // setEndNoteFrame(PageItem_NoteFrame * nF,void * ptr)1824 void setEndNoteFrame(PageItem_NoteFrame* nF, void* ptr) { rangeItem rI={ptr}; m_docEndNotesFramesMap.insert(nF,rI); } setEndNoteFrame(PageItem_NoteFrame * nF,int section)1825 void setEndNoteFrame(PageItem_NoteFrame* nF, int section) { rangeItem rI; rI.sectionIndex = section; m_docEndNotesFramesMap.insert(nF, rI); } 1826 //update all endnotesframes content for given notes style 1827 void updateEndnotesFrames(NotesStyle* nStyle = nullptr, bool invalidate = false); 1828 //update endnotesframe content 1829 void updateEndNotesFrameContent(PageItem_NoteFrame* nF, bool invalidate = false); 1830 //insert noteframe into list of changed endNoteFrameChanged(PageItem_NoteFrame * nF)1831 void endNoteFrameChanged(PageItem_NoteFrame* nF) { m_docEndNotesFramesChanged.append(nF); } 1832 //update content for changed endnotesframes 1833 void updateChangedEndNotesFrames(); 1834 1835 //finds mark position in text 1836 //return true if mark was found, CPos is set for mark`s position 1837 //if item==nullptr then search in all items and if mark is found than item is set 1838 int findMarkCPos(const Mark* mrk, PageItem* &item, int start = 0) const; 1839 QList<PageItem_NoteFrame*> m_docEndNotesFramesChanged; 1840 1841 //finds item which holds given mark, start searching from next to lastItem index in DocItems 1842 PageItem* findMarkItem(const Mark* mrk, PageItem* &lastItem) const; 1843 1844 private: 1845 //QMap<PageItem_NoteFrame*, QList<TextNote *> > map of notesframes and its list of notes 1846 NotesInFrameMap m_docNotesInFrameMap; 1847 findFirstMarkItem(const Mark * mrk)1848 PageItem* findFirstMarkItem(const Mark* mrk) const { PageItem* tmp = nullptr; return findMarkItem(mrk, tmp); } 1849 1850 //search for endnotesframe for given notes style and item holding master mark or section number 1851 PageItem_NoteFrame* endNoteFrame(NotesStyle* nStyle, void* item = nullptr); 1852 //clear list of notes for given notesframe clearNotesInFrameList(PageItem_NoteFrame * nF)1853 void clearNotesInFrameList(PageItem_NoteFrame* nF) { m_docNotesInFrameMap.insert(nF, QList<TextNote*>()); } 1854 //renumber notes with given notes style for given frame starting from number num 1855 void updateItemNotesNums(PageItem_TextFrame *frame, NotesStyle* nStyle, int &num); 1856 //update notesframes text styles 1857 void updateItemNotesFramesStyles(PageItem *item, const ParagraphStyle& newStyle); 1858 1859 //not used? 1860 bool updateEndNotesNums(); //return true if doc needs update 1861 void invalidateNoteFrames(NotesStyle* nStyle); 1862 void invalidateMasterFrames(NotesStyle* nStyle); 1863 1864 public slots: 1865 //update strings (page numbers) for marks 1866 bool updateMarks(bool updateNotesMarks = false); 1867 1868 //welding two items 1869 public slots: 1870 void itemSelection_UnWeld(); 1871 void itemSelection_Weld(); 1872 void itemSelection_EditWeld(); 1873 void restartAutoSaveTimer(); 1874 1875 protected slots: 1876 void slotAutoSave(); 1877 1878 //auto-numerations 1879 public: 1880 QMap<QString, NumStruct*> numerations; 1881 QStringList orgNumNames; //orgNumerations keeps original settings read from paragraph styles for reset settings overrided localy 1882 void setupNumerations(); //read styles for used auto-numerations, initialize numCounters 1883 QString getNumberStr(const QString& numName, int level, bool reset, const ParagraphStyle &style); 1884 void setNumerationCounter(const QString& numName, int level, int number); 1885 bool flag_Renumber {false}; 1886 bool flag_NumUpdateRequest {false}; 1887 // for local numeration of paragraphs 1888 int updateLocalNums(StoryText& itemText); //return first invalidated char 1889 void updateNumbers(bool updateNumerations = false); 1890 void itemSelection_ClearBulNumStrings(Selection *customSelection); 1891 /* Functions for PDF Form Actions */ 1892 1893 public: 1894 void SubmitForm(); 1895 void ImportData(); 1896 void ResetFormFields(); 1897 QString documentFileName() const; 1898 void setDocumentFileName(const QString& documentFileName); 1899 }; 1900 1901 Q_DECLARE_METATYPE(ScribusDoc*); 1902 1903 #endif 1904