Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
3 paul 1
/***************************************************************************
2
                          scribusdoc.h  -  description
3
                             -------------------
4
    begin                : Fre Apr  6 21:47:55 CEST 2001
5
    copyright            : (C) 2001 by Franz Schmid
6
    email                : Franz.Schmid@altmuehlnet.de
7
 ***************************************************************************/
8
 
9
/***************************************************************************
10
 *                                                                         *
11
 *   This program is free software; you can redistribute it and/or modify  *
12
 *   it under the terms of the GNU General Public License as published by  *
13
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 *   (at your option) any later version.                                   *
15
 *                                                                         *
16
 ***************************************************************************/
17
#ifndef SCRIBUSDOC_H
18
#define SCRIBUSDOC_H
19
#ifdef HAVE_CONFIG_H
2688 craig 20
#include "scconfig.h"
3 paul 21
#endif
22
// include files for QT
23
#include <qobject.h>
24
#include <qdict.h>
25
#include <qcolor.h>
26
#include <qvaluelist.h>
27 Franz 27
#include <qvaluevector.h>
1179 tsoots 28
#include <qpixmap.h>
3 paul 29
#include <qptrlist.h>
30
#include <qfont.h>
31
#include <qmap.h>
32
#include <qpointarray.h>
33
#include <qstringlist.h>
34
#include <qtimer.h>
838 cbradney 35
 
2969 craig 36
#include "scribusapi.h"
2948 cbradney 37
#include "scribusstructs.h"
2834 cbradney 38
#include "prefsstructs.h"
2016 cbradney 39
#include "documentinformation.h"
1179 tsoots 40
#include "undoobject.h"
3670 cbradney 41
//#include "page.h"
3263 cbradney 42
#include "pageitem.h"
3617 cbradney 43
#include "pageitem_line.h"
44
#include "pageitem_textframe.h"
3179 cbradney 45
 
3 paul 46
#ifdef HAVE_CMS
44 Franz 47
        #include CMS_INC
3 paul 48
#endif
49
 
68 Franz 50
#include <ft2build.h>
51
#include FT_FREETYPE_H
3020 cbradney 52
 
3 paul 53
class Page;
1190 tsoots 54
class UndoManager;
55
class UndoState;
1972 craig 56
class PDFOptions;
3252 craig 57
class Hyphenator;
3 paul 58
 
59
 
60
/**
61
  * the Document Class
62
  */
63
 
2969 craig 64
class SCRIBUS_API ScribusDoc : public QObject, public UndoObject
3 paul 65
{
3082 fschmid 66
        Q_OBJECT
67
 
3 paul 68
public:
2891 cbradney 69
        ScribusDoc();
70
        ~ScribusDoc();
2901 fschmid 71
        void setup(const int, const int, const int, const int, const int, const QString&, const QString&);
2891 cbradney 72
        void setLoading(const bool);
73
        const bool isLoading();
74
        void setModified(const bool);
75
        bool isModified() const;
76
/** Setzt die Seitenattribute */
2894 fschmid 77
        void setPage(double b, double h, double t, double l, double r, double bo, double sp, double ab, bool atf, int fp);
78
        void resetPage(double t, double l, double r, double bo, int fp);
2937 cbradney 79
        // Add, delete and move pages
2893 cbradney 80
        Page* addPage(const int);
2895 cbradney 81
        bool deletePage(const int);
3531 cbradney 82
        /**
83
         * @brief Move page(s) within the document
84
         * @param From page index
85
         * @param To page index
86
         * @param Position to move to (page index)
87
         * @param Before, After or at the end
88
         */
2895 cbradney 89
        void movePage(const int, const int, const int, const int);
2937 cbradney 90
        // Add, delete and move layers
3201 subik 91
        /**
2947 cbradney 92
         * @brief Add a layer to the current document
93
         * @param Name of layer
94
         * @param Mark the layer active
95
         * @return Number of the layer created
96
         */
2944 cbradney 97
        const int addLayer(const QString&, const bool);
3201 subik 98
        /**
2947 cbradney 99
         * @brief Delete a layer from the current document
100
         * @param Number of layer
101
         * @param Delete the items on the layer too?
102
         * @return Success or failure
103
         */
2937 cbradney 104
        const bool deleteLayer(const int, const bool);
2947 cbradney 105
        /**
106
         * @brief Return the number of the current layer
107
         * @return Active layer number
108
         */
2937 cbradney 109
        const int activeLayer();
3201 subik 110
 
2947 cbradney 111
        /**
112
         * @brief Return the name of the current layer
113
         * @return Name of the layer
114
         */
2937 cbradney 115
        const QString& activeLayerName();
2947 cbradney 116
        /**
117
         * @brief Set the active layer via the layer number
118
         * @param Number of the layer
119
         * @return Success or failure
120
         */
2937 cbradney 121
        const bool setActiveLayer(const int);
2947 cbradney 122
        /**
123
         * @brief Set the active layer via the layer name
124
         * @param Name of the layer
125
         * @return Success or failure
126
         */
2937 cbradney 127
        const bool setActiveLayer(const QString &);
2947 cbradney 128
        /**
129
         * @brief Set the layer printable via the layer number
130
         * @param Number of the layer
131
         * @param Printable bool
132
         * @return Success or failure
133
         */
2937 cbradney 134
        const bool setLayerPrintable(const int, const bool);
2947 cbradney 135
        /**
136
         * @brief Is the layer printable
137
         * @param Number of the layer
138
         * @return Printable or not
139
         */
2937 cbradney 140
        const bool layerPrintable(const int);
2947 cbradney 141
        /**
142
         * @brief Set the layer visible via the layer number
143
         * @param Number of the layer
144
         * @param Visible bool
145
         * @return Success or failure
146
         */
2937 cbradney 147
        const bool setLayerVisible(const int, const bool);
2947 cbradney 148
        /**
149
         * @brief Is the layer visible
150
         * @param Number of the layer
151
         * @return Visible or not
152
         */
2937 cbradney 153
        const bool layerVisible(const int);
2947 cbradney 154
        /**
155
         * @brief Return the level of the requested layer
156
         * @param Number of the layer
157
         * @return Level of the layer
158
         */
2937 cbradney 159
        const int layerLevelFromNumber(const int);
2947 cbradney 160
        /**
161
         * @brief Return the number of the layer at a certain level
162
         * @param Layer level
163
         * @return Layer number
164
         */
2937 cbradney 165
        const int layerNumberFromLevel(const int);
2947 cbradney 166
        /**
167
         * @brief Return the layer count
168
         * @return Number of layers in doc
169
         */
2937 cbradney 170
        const int layerCount();
2947 cbradney 171
        /**
172
         * @brief Lower a layer
173
         * @param Number of the layer
174
         * @return Success or failure
175
         */
2937 cbradney 176
        const bool lowerLayer(const int);
2947 cbradney 177
        /**
178
         * @brief Lower a layer using the level
179
         * @param Level of the layer
180
         * @return Success or failure
181
         */
2941 cbradney 182
        const bool lowerLayerByLevel(const int);
2947 cbradney 183
        /**
184
         * @brief Raise a layer
185
         * @param Number of the layer
186
         * @return Success or failure
187
         */
2937 cbradney 188
        const bool raiseLayer(const int);
2947 cbradney 189
        /**
190
         * @brief Raise a layer using the level
191
         * @param Level of the layer
192
         * @return Success or failure
193
         */
2941 cbradney 194
        const bool raiseLayerByLevel(const int);
2947 cbradney 195
        /**
196
         * @brief Return the layer name
197
         * @param Number of the layer
3201 subik 198
         * @return Name of the layer
2947 cbradney 199
         */
2937 cbradney 200
        const QString &layerName(const int);
2947 cbradney 201
        /**
202
         * @brief Change the name of a layer
203
         * @param Number of the layer
204
         * @param New name of the layer
205
         * @return Success or failure
206
         */
2937 cbradney 207
        const bool changeLayerName(const int, const QString&);
2947 cbradney 208
        /**
209
         * @brief Does the layer have items on it?
210
         * @param Number of the layer
211
         * @return Layer contains items bool
212
         */
2937 cbradney 213
        const bool layerContainsItems(const int);
2947 cbradney 214
        /**
215
         * @brief Renumber a layer. Used in particular for reinsertion for undo/redo
216
         * @param Existing layer number
217
         * @param New layer number
218
         * @return Success or failure
219
         */
2944 cbradney 220
        const bool renumberLayer(const int, const int);
2947 cbradney 221
        /**
222
         * @brief Return a list of the layers in their order
223
         * @param QStringList to insert the layer names into
224
         */
2937 cbradney 225
        void orderedLayerList(QStringList*);
226
        //Items
227
        const bool deleteTaggedItems();
3201 subik 228
 
3544 avox 229
        bool AddFont(QString name, int fsize = 10);
1330 fschmid 230
        void OpenCMSProfiles(ProfilesL InPo, ProfilesL MoPo, ProfilesL PrPo);
231
        void CloseCMSProfiles();
1065 cbradney 232
        void loadStylesFromFile(QString fileName, QValueList<ParagraphStyle> *tempStyles = NULL);
3201 subik 233
        /**
1179 tsoots 234
         * @brief Should guides be locked or not
235
         * @param isLocked If true guides on pages cannot be moved if false they
236
         * can be dragged to new positions.
237
         * @author Riku Leino
238
         */
239
        void lockGuides(bool isLocked);
1190 tsoots 240
        /**
1179 tsoots 241
         * @brief Method used when an undo/redo is requested.
242
         * @param state State describing the action that is wanted to be undone/redone
243
         * @param isUndo If true undo is wanted else if false redo.
244
         * @author Riku Leino
245
         */
246
        void restore(UndoState* state, bool isUndo);
247
        /**
248
         * @brief Sets the name of the document
249
         * @param name Name for the document
250
         * @author Riku Leino
251
         */
252
        void setName(const QString& name);
1694 cbradney 253
        /*!
254
         * @brief Returns a stringlist of the item attributes within the document
255
         */
256
        QStringList getItemAttributeNames();
3201 subik 257
 
2960 cbradney 258
        /*!
259
         * @brief Returns a qmap of the fonts used within the document
260
         */
3544 avox 261
        void getUsedFonts(QMap<QString,int> *Really);
2960 cbradney 262
        /*!
3057 fschmid 263
        * @brief Builds a qmap of the colours used within the document
264
        */
3068 fschmid 265
        void getUsedColors(ColorList &colorsToUse, bool spot = false);
3057 fschmid 266
        /*!
2960 cbradney 267
         * @brief TODO: Reorganise the fonts.. how? Moved from scribus.cpp
268
         */
269
        void reorganiseFonts();
2965 cbradney 270
        /**
271
         * @brief Set and get the document's unit index
272
         */
273
        void setUnitIndex(const int);
274
        const int unitIndex();
275
        const double unitRatio();
3004 cbradney 276
        /**
277
         * @brief Apply a master page
278
         */
279
        const bool applyMasterPage(const QString& in, const int);
280
        /**
281
         * @brief Undo function for applying a master page
282
         */
283
        void restoreMasterPageApplying(SimpleState *state, bool isUndo);
3020 cbradney 284
        /**
285
         * @brief Save function
286
         */
287
        const bool save(const QString&);
3025 cbradney 288
        /**
289
         * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
290
         */
3554 fschmid 291
        const bool changePageMargins(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 pageNumber=-1, const int pageType = 0);
3123 cbradney 292
        /**
293
         * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
294
         */
295
         void recalculateColors();
3179 cbradney 296
        /**
297
         * @brief Sets up the ScText defaults from the document
298
         */
299
        void setScTextDefaultsFromDoc(ScText *);
3200 cbradney 300
        /**
301
         * @brief Copies a normal page to be a master pages
302
         */
3650 cbradney 303
        const bool copyPageToMasterPage(const int, const int, const int, const QString&);
3263 cbradney 304
        /**
305
         * @brief Paste an item to the document.
306
         * The bulk of a paste item process runs here for want of a better place, but its a better place
307
         * than the view where it used to be.
308
         * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the
309
         * unnecessary part from the view for now which is overloaded with non ScrollView code.
310
         */
311
        //TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
312
 
313
        /**
314
         * @brief Add an Item to the document.
315
         * A simple function to create an item of a defined type and add it to the document
316
         * Will need extensive rewriting once we have various classes of PageItems, at a guess.
317
         *
318
         * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
319
         * @return Number of created item, -1 on failure.
320
         */
321
        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, const bool itemFinalised);
322
 
323
        /**
324
         * @brief Commit item creation when a user has click-drag created an item
325
         * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
326
         * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
327
         */
328
        bool itemAddCommit(const int itemNumber);
329
 
330
        /**
331
         * @brief Finalise item creation. Simply split off code from itemAdd
332
         * Only to be called from itemAdd()
333
         */
334
        void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
335
 
336
        //itemDelete
337
        //itemBlah...
3628 cbradney 338
 
339
        /**
340
         * @brief Run this common frame item update code
341
         */
342
        void updateFrameItems();
3648 cbradney 343
 
344
        /**
345
         * @brief Doc uses automatic text frames?
346
         */
347
        const bool usesAutomaticTextFrames();
348
        void setUsesAutomaticTextFrames(const bool);
3650 cbradney 349
 
350
        /**
351
         * @brief Load images into an image frame, moved from the view
352
         * @retval Return false on failure
353
         */
354
        const bool LoadPict(QString fn, int ItNr, bool reload = false);
355
        const bool loadPict(QString fn, PageItem *pageItem, bool reload = false);
3656 cbradney 356
 
357
        /**
358
         * @brief Find the minX,MinY and maxX,maxY for the canvas required for the doc
359
         */
360
        void canvasMinMax(FPoint&, FPoint&);
3657 cbradney 361
 
362
        int OnPage(double x2, double  y2);
363
        int OnPage(PageItem *currItem);
364
        void GroupOnPage(PageItem *currItem);
365
        void reformPages(double& maxX, double& maxY, bool moveObjects = true);
3664 cbradney 366
 
367
        /**
3670 cbradney 368
         * @brief Return the x or y offset for a page on the canvas
369
         * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
370
         * Mostly saves bringing in extra includes into files that already have scribusdoc.h
3664 cbradney 371
         */
372
        const double getXOffsetForPage(const int);
373
        const double getYOffsetForPage(const int);
3670 cbradney 374
 
375
        /**
376
         * @brief Item type conversion functions
377
         */
3673 cbradney 378
        PageItem* convertItemTo(PageItem *, PageItem::ItemType);
3670 cbradney 379
 
380
        /**
381
         * @brief The page number of the current page
382
         */
383
        const int currentPageNumber();
3201 subik 384
 
168 Franz 385
protected:
2891 cbradney 386
        void addSymbols();
387
        bool loading;
2937 cbradney 388
        bool modified;
389
        int ActiveLayer;
2965 cbradney 390
        int docUnitIndex;
391
        double docUnitRatio;
2937 cbradney 392
        UndoManager *undoManager;
3648 cbradney 393
        bool automaticTextFrames; // Flag for automatic Textframes
168 Franz 394
 
395
public: // Public attributes
2937 cbradney 396
        bool is12doc; //public for now, it will be removed later
1330 fschmid 397
        int NrItems;
398
        int First;
399
        int Last;
400
        int viewCount;
401
        int viewID;
3 paul 402
        bool SnapGuides;
403
        bool GuideLock;
456 fschmid 404
        /** Scratch space around Pages */
405
        double ScratchLeft;
406
        double ScratchRight;
407
        double ScratchTop;
408
        double ScratchBottom;
2837 fschmid 409
/** Minimum and Maximum Points of Document */
410
        FPoint minCanvasCoordinate;
411
        FPoint maxCanvasCoordinate;
2867 fschmid 412
        double rulerXoffset;
413
        double rulerYoffset;
456 fschmid 414
  /** List of Pages */
415
        QPtrList<Page> Pages;
2093 cbradney 416
  /** List of Master Pages */
456 fschmid 417
        QPtrList<Page> MasterPages;
418
  /** List of Document Pages */
419
        QPtrList<Page> DocPages;
2093 cbradney 420
  /** Mapping Master Page Name to Master Page numbers */
456 fschmid 421
        QMap<QString,int> MasterNames;
422
  /** List of Objects */
423
        QPtrList<PageItem> Items;
424
        QPtrList<PageItem> MasterItems;
425
        QPtrList<PageItem> DocItems;
2447 fschmid 426
        QPtrList<PageItem> FrameItems;
456 fschmid 427
  /** Pagewidth  */
2142 cbradney 428
        double pageWidth;
456 fschmid 429
  /** Pageheight */
2142 cbradney 430
        double pageHeight;
456 fschmid 431
  /** Number of Pages */
2142 cbradney 432
        int pageCount;
456 fschmid 433
  /** Margins */
2142 cbradney 434
        MarginStruct pageMargins;
3016 fschmid 435
        QValueList<PageSet> pageSets;
456 fschmid 436
  /** Number of Columns */
168 Franz 437
        double PageSp;
456 fschmid 438
  /** Distance of Columns */
168 Franz 439
        double PageSpa;
3032 fschmid 440
 /** current Pagelayout */
441
        int currentPageLayout;
3 paul 442
        /** Flag fuer Hoch- oder Querformat 0 = Hochformat */
3032 fschmid 443
        int PageOri;
519 cbradney 444
        QString PageSize;
3 paul 445
        /** Erste Seitennummer im Dokument */
446
        int FirstPnum;
447
  /** Flag fuer Rasterbenutzung */
168 Franz 448
        bool useRaster;
3 paul 449
  /** Im Dokument benutzte Farben */
1065 cbradney 450
        ColorList PageColors;
451
        Page* currentPage;
3 paul 452
  /** InfoStrings fuer das aktuelle Dokument */
2016 cbradney 453
        DocumentInformation documentInfo;
1065 cbradney 454
        int appMode;
123 Franz 455
        int SubMode;
456
        double *ShapeValues;
457
        int ValCount;
168 Franz 458
        QString DocName;
3544 avox 459
        QMap<QString,int> UsedFonts;
168 Franz 460
        SCFonts *AllFonts;
461
        QColor papColor;
462
        int CurrentSel;
463
        int CurrentStyle;
1065 cbradney 464
        int currentParaStyle;
68 Franz 465
        QString CurrFont;
466
        int CurrFontSize;
467
        QString CurrTextFill;
468
        int CurrTextFillSh;
469
        QString CurrTextStroke;
470
        int CurrTextStrokeSh;
471
        int CurrTextScale;
2230 fschmid 472
        int CurrTextScaleV;
2234 fschmid 473
        int CurrTextBase;
2247 fschmid 474
        int CurrTextShadowX;
475
        int CurrTextShadowY;
2257 fschmid 476
        int CurrTextOutline;
2262 fschmid 477
        int CurrTextUnderPos;
478
        int CurrTextUnderWidth;
2272 fschmid 479
        int CurrTextStrikePos;
480
        int CurrTextStrikeWidth;
168 Franz 481
        bool EditClip;
482
        int EditClipMode;
2889 cbradney 483
        typoPrefs typographicSettings;
1065 cbradney 484
        guidesPrefs guidesSettings;
1194 fschmid 485
        toolPrefs toolSettings;
3097 cbradney 486
        QMap<QString, checkerPrefs> checkerProfiles;
1261 fschmid 487
        QString curCheckProfile;
3 paul 488
  /** Letztes Element fuer AutoTextrahmen */
168 Franz 489
        PageItem *LastAuto;
3 paul 490
  /** Erstes Element fuer AutoTextrahmen */
168 Franz 491
        PageItem *FirstAuto;
492
        bool DragP;
227 Franz 493
        bool leaveDrag;
168 Franz 494
        PageItem *DraggedElem;
495
        PageItem *ElemToLink;
496
        QValueList<uint> DragElements;
1065 cbradney 497
        QValueList<ParagraphStyle> docParagraphStyles;
3 paul 498
        QValueList<Layer> Layers;
1065 cbradney 499
        bool marginColored;
168 Franz 500
        int GroupCounter;
1065 cbradney 501
        CMSData CMSSettings;
3 paul 502
#ifdef HAVE_CMS
503
        cmsHPROFILE DocInputProf;
504
        cmsHPROFILE DocOutputProf;
505
        cmsHPROFILE DocPrinterProf;
1330 fschmid 506
        cmsHTRANSFORM stdTrans;
507
        cmsHTRANSFORM stdProof;
508
        cmsHTRANSFORM stdTransImg;
509
        cmsHTRANSFORM stdProofImg;
1488 fschmid 510
        cmsHTRANSFORM stdTransCMYK;
511
        cmsHTRANSFORM stdProofCMYK;
512
        cmsHTRANSFORM stdTransRGB;
3046 fschmid 513
        cmsHTRANSFORM stdProofGC;
514
        cmsHTRANSFORM stdProofCMYKGC;
1330 fschmid 515
        bool SoftProofing;
516
        bool Gamut;
517
        int IntentMonitor;
518
        int IntentPrinter;
3 paul 519
#endif
168 Franz 520
        bool HasCMS;
3 paul 521
        QMap<QString,QString> JavaScripts;
522
        int TotalItems;
1065 cbradney 523
        Hyphenator *docHyphenator;
3 paul 524
        int MinWordLen;
249 Franz 525
        int HyCount;
3 paul 526
        QString Language;
527
        bool Automatic;
528
        bool AutoCheck;
2093 cbradney 529
        bool masterPageMode;
1545 cbradney 530
        PDFOptions PDF_Options;
3 paul 531
        bool RePos;
3201 subik 532
        struct BookMa {
168 Franz 533
                                        QString Title;
534
                                        QString Text;
535
                                        QString Aktion;
536
                                        int Parent;
537
                                        int Seite;
538
                                        int Element;
539
                                        int ItemNr;
540
                                        int First;
541
                                        int Last;
542
                                        int Prev;
543
                                        int Next;
544
                                        };
3 paul 545
        QValueList<BookMa> BookMarks;
546
        bool OldBM;
547
        bool hasName;
548
        int RotMode;
549
        bool AutoSave;
734 fschmid 550
        int AutoSaveTime;
2891 cbradney 551
        QTimer *autoSaveTimer;
3 paul 552
        FT_Library   library;
168 Franz 553
        QMap<QString,FT_Face> FFonts;
27 Franz 554
        QMap<QString,multiLine> MLineStyles;
1065 cbradney 555
        QValueList<ArrowDesc> arrowStyles;
59 Franz 556
        QWidget* WinHan;
63 Franz 557
        bool DoDrawing;
168 Franz 558
        QValueList<int> OpenNodes;
139 Franz 559
        QTimer *CurTimer;
1229 fschmid 560
        QMap<int, errorCodes> docItemErrors;
1232 fschmid 561
        QMap<int, errorCodes> masterItemErrors;
1641 cbradney 562
        //Attributes to be applied to frames
1649 cbradney 563
        ObjAttrVector docItemAttributes;
1694 cbradney 564
        ToCSetupVector docToCSetups;
2353 fschmid 565
        FPointArray symReturn;
566
        FPointArray symNewLine;
567
        FPointArray symTab;
568
        FPointArray symNonBreak;
2389 fschmid 569
        FPointArray symNewCol;
570
        FPointArray symNewFrame;
3263 cbradney 571
 
572
private:
573
        bool _itemCreationTransactionStarted;
3 paul 574
};
575
 
576
#endif