Subversion Repositories Scribus

Rev

Rev 23174 | Rev 23179 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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