Subversion Repositories Scribus

Rev

Rev 6403 | Rev 6414 | 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
29
#include <qobject.h>
30
#include <qdict.h>
31
#include <qcolor.h>
32
#include <qvaluelist.h>
27 Franz 33
#include <qvaluevector.h>
1179 tsoots 34
#include <qpixmap.h>
3 paul 35
#include <qptrlist.h>
36
#include <qfont.h>
37
#include <qmap.h>
38
#include <qpointarray.h>
39
#include <qstringlist.h>
40
#include <qtimer.h>
838 cbradney 41
 
6132 cbradney 42
#include "gtgettext.h" //CB For the ImportSetup struct and itemadduserframe
2969 craig 43
#include "scribusapi.h"
2948 cbradney 44
#include "scribusstructs.h"
5789 cbradney 45
#include "pagesize.h"
2834 cbradney 46
#include "prefsstructs.h"
2016 cbradney 47
#include "documentinformation.h"
1179 tsoots 48
#include "undoobject.h"
3724 cbradney 49
#include "page.h"
3263 cbradney 50
#include "pageitem.h"
3617 cbradney 51
#include "pageitem_line.h"
52
#include "pageitem_textframe.h"
3757 cbradney 53
#include "pagestructs.h"
6403 cbradney 54
#include "usertaskstructs.h"
5980 avox 55
#include "styles/styleset.h"
6368 fschmid 56
#include "scpattern.h"
3179 cbradney 57
 
3 paul 58
#ifdef HAVE_CMS
44 Franz 59
        #include CMS_INC
3 paul 60
#endif
61
 
68 Franz 62
#include <ft2build.h>
63
#include FT_FREETYPE_H
3020 cbradney 64
 
1190 tsoots 65
class UndoManager;
66
class UndoState;
1972 craig 67
class PDFOptions;
3252 craig 68
class Hyphenator;
3903 cbradney 69
class Selection;
4320 cbradney 70
class ScribusView;
5781 cbradney 71
class ScribusMainWindow;
3 paul 72
 
3942 cbradney 73
class QProgressBar;
3 paul 74
 
3942 cbradney 75
 
4650 subik 76
/**! \brief the Document Class
3 paul 77
  */
2969 craig 78
class SCRIBUS_API ScribusDoc : public QObject, public UndoObject
3 paul 79
{
3082 fschmid 80
        Q_OBJECT
81
 
3 paul 82
public:
2891 cbradney 83
        ScribusDoc();
5789 cbradney 84
        ScribusDoc(const QString& docName, int unitIndex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup);
2891 cbradney 85
        ~ScribusDoc();
5789 cbradney 86
        void init();
2901 fschmid 87
        void setup(const int, const int, const int, const int, const int, const QString&, const QString&);
2891 cbradney 88
        void setLoading(const bool);
3985 cbradney 89
        bool isLoading() const;
2891 cbradney 90
        void setModified(const bool);
91
        bool isModified() const;
92
/** Setzt die Seitenattribute */
2894 fschmid 93
        void setPage(double b, double h, double t, double l, double r, double bo, double sp, double ab, bool atf, int fp);
94
        void resetPage(double t, double l, double r, double bo, int fp);
4320 cbradney 95
 
96
        /**
97
         * @brief Return the view associated with the document
98
         */
99
        ScribusView* view() const;
5781 cbradney 100
        ScribusMainWindow* scMW() const {return m_ScMW;}
5824 cbradney 101
        void setGUI(bool hasgui, ScribusMainWindow* mw, ScribusView* view);
3792 cbradney 102
 
2937 cbradney 103
        // Add, delete and move pages
3852 cbradney 104
 
105
        Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
4069 craig 106
        void deleteMasterPage(const int);
107
        void deletePage(const int);
3792 cbradney 108
        /**
109
         * @brief Add a master page with this function, do not use addPage
110
         */
3695 cbradney 111
        Page* addMasterPage(const int, const QString&);
5685 cbradney 112
        //! @brief Rename a master page
113
        bool renameMasterPage(const QString& oldPageName, const QString& newPageName);
3860 cbradney 114
 
3852 cbradney 115
        /**
3860 cbradney 116
         * @brief Add the automatic text frame to the page
4645 subik 117
         * @param pageNumber page number
3860 cbradney 118
         * @return number of frame
3852 cbradney 119
         */
4645 subik 120
        int addAutomaticTextFrame(const int pageNumber);
3531 cbradney 121
        /**
3852 cbradney 122
         * Set the left and right margins based on the location of the page
123
         * @param pageIndex
124
         */
125
        void setLocationBasedPageLRMargins(uint pageIndex);
126
        /**
3531 cbradney 127
         * @brief Move page(s) within the document
4650 subik 128
         * @param from page index
129
         * @param to page index
130
         * @param ziel target to move to (page index)
131
         * @param art Before, After or at the end
3531 cbradney 132
         */
4650 subik 133
        void movePage(const int from, const int to, const int ziel, const int art);
3843 cbradney 134
 
135
        /**
136
         * @brief Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
137
         * @param pageNumberToCopy
138
         * @param existingPage
139
         * @param whereToInsert
140
         * @param copyCount
141
         */
142
        void copyPage(int pageNumberToCopy, int existingPage, int whereToInsert, int copyCount);
143
 
2937 cbradney 144
        // Add, delete and move layers
3201 subik 145
        /**
2947 cbradney 146
         * @brief Add a layer to the current document
4645 subik 147
         * @param layerName name of layer
4650 subik 148
         * @param activate the layer active
2947 cbradney 149
         * @return Number of the layer created
150
         */
4645 subik 151
        int addLayer(const QString& layerName=QString::null, const bool activate=false);
3201 subik 152
        /**
6290 fschmid 153
         * @brief Copies a layer from the current document
154
         * @param layerNumberToCopy source layer
155
         * @param whereToInsert target layer
156
         * @return Success or failure
157
         */
158
        void copyLayer(int layerNumberToCopy, int whereToInsert);
159
        /**
2947 cbradney 160
         * @brief Delete a layer from the current document
4645 subik 161
         * @param layerNumber of layer
162
         * @param deleteItems the items on the layer too?
2947 cbradney 163
         * @return Success or failure
164
         */
4645 subik 165
        bool deleteLayer(const int layerNumber, const bool deleteItems);
2947 cbradney 166
        /**
167
         * @brief Return the number of the current layer
168
         * @return Active layer number
169
         */
3985 cbradney 170
        int activeLayer();
3201 subik 171
 
2947 cbradney 172
        /**
173
         * @brief Return the name of the current layer
174
         * @return Name of the layer
175
         */
2937 cbradney 176
        const QString& activeLayerName();
2947 cbradney 177
        /**
178
         * @brief Set the active layer via the layer number
4650 subik 179
         * @param layerToActivate Number of the layer
2947 cbradney 180
         * @return Success or failure
181
         */
4650 subik 182
        bool setActiveLayer(const int layerToActivate);
2947 cbradney 183
        /**
184
         * @brief Set the active layer via the layer name
4650 subik 185
         * @param layerNameToActivate Name of the layer
2947 cbradney 186
         * @return Success or failure
187
         */
4650 subik 188
        bool setActiveLayer(const QString & layerNameToActivate);
2947 cbradney 189
        /**
190
         * @brief Set the layer printable via the layer number
4650 subik 191
         * @param layerNumber Number of the layer
192
         * @param isPrintable bool true = layer is prantable
2947 cbradney 193
         * @return Success or failure
194
         */
4650 subik 195
        bool setLayerPrintable(const int layerNumber, const bool isPrintable);
2947 cbradney 196
        /**
197
         * @brief Is the layer printable
4650 subik 198
         * @param layerNumber Number of the layer
2947 cbradney 199
         * @return Printable or not
200
         */
4650 subik 201
        bool layerPrintable(const int layerNumber);
2947 cbradney 202
        /**
203
         * @brief Set the layer visible via the layer number
4650 subik 204
         * @param layerNumber Number of the layer
205
         * @param isViewable true = layer is visible
2947 cbradney 206
         * @return Success or failure
207
         */
4650 subik 208
        bool setLayerVisible(const int layerNumber, const bool isViewable);
2947 cbradney 209
        /**
210
         * @brief Is the layer visible
4650 subik 211
         * @param layerNumber Number of the layer
2947 cbradney 212
         * @return Visible or not
213
         */
4650 subik 214
        bool layerVisible(const int layerNumber);
2947 cbradney 215
        /**
4832 fschmid 216
         * @brief Set the layer locked via the layer number
217
         * @param layerNumber Number of the layer
218
         * @param isViewable true = layer is locked
219
         * @return Success or failure
220
         */
221
        bool setLayerLocked(const int layerNumber, const bool isViewable);
222
        /**
223
         * @brief Is the layer locked
224
         * @param layerNumber Number of the layer
225
         * @return Locked or not
226
         */
227
        bool layerLocked(const int layerNumber);
228
        /**
5359 fschmid 229
         * @brief Set the layer flow via the layer number
230
         * @param layerNumber Number of the layer
231
         * @param flow true = Text flows around objects on this layer
232
         * @return Success or failure
233
         */
234
        bool setLayerFlow(const int layerNumber, const bool flow);
235
        /**
236
         * @brief does text flow around objects on this layer
237
         * @param layerNumber Number of the layer
238
         * @return flow or not
239
         */
240
        bool layerFlow(const int layerNumber);
241
        /**
5373 fschmid 242
         * @brief Set the layer transparency via the layer number
243
         * @param layerNumber Number of the layer
244
         * @param trans transparency value 0.0 - 1.0
245
         * @return Success or failure
246
         */
247
        bool setLayerTransparency(const int layerNumber, double trans);
248
        /**
249
         * @brief returns the layer transparency
250
         * @param layerNumber Number of the layer
251
         * @return transparency value 0.0 - 1.0
252
         */
253
        double layerTransparency(const int layerNumber);
254
        /**
5375 fschmid 255
         * @brief Set the layer layerBlendMode via the layer number
256
         * @param layerNumber Number of the layer
257
         * @param trans layerBlendMode
258
         * @return Success or failure
259
         */
260
        bool setLayerBlendMode(const int layerNumber, int blend);
261
        /**
262
         * @brief returns the layer BlendMode
263
         * @param layerNumber Number of the layer
264
         * @return layerBlendMode
265
         */
266
        int layerBlendMode(const int layerNumber);
267
        /**
2947 cbradney 268
         * @brief Return the level of the requested layer
4650 subik 269
         * @param layerNumber Number of the layer
2947 cbradney 270
         * @return Level of the layer
271
         */
4650 subik 272
        int layerLevelFromNumber(const int layerNumber);
2947 cbradney 273
        /**
5572 fschmid 274
         * @brief Set the layer marker color
275
         * @param layerNumber Number of the layer
276
         * @param color color of the marker
277
         * @return Success or failure
278
         */
279
        bool setLayerMarker(const int layerNumber, QColor color);
280
        /**
281
         * @brief returns the layer marker color
282
         * @param layerNumber Number of the layer
283
         * @return marker color
284
         */
285
        QColor layerMarker(const int layerNumber);
286
        /**
287
         * @brief Set the layer outline mode via the layer number
288
         * @param layerNumber Number of the layer
289
         * @param outline true = layer is displayed in outlines only
290
         * @return Success or failure
291
         */
292
        bool setLayerOutline(const int layerNumber, const bool outline);
293
        /**
294
         * @brief is this layer in outline mode
295
         * @param layerNumber Number of the layer
296
         * @return outline or not
297
         */
298
        bool layerOutline(const int layerNumber);
299
        /**
2947 cbradney 300
         * @brief Return the number of the layer at a certain level
4650 subik 301
         * @param layerLevel Layer level
2947 cbradney 302
         * @return Layer number
303
         */
4650 subik 304
        int layerNumberFromLevel(const int layerLevel);
2947 cbradney 305
        /**
306
         * @brief Return the layer count
307
         * @return Number of layers in doc
308
         */
3985 cbradney 309
        int layerCount() const;
2947 cbradney 310
        /**
311
         * @brief Lower a layer
4650 subik 312
         * @param layerNumber Number of the layer
2947 cbradney 313
         * @return Success or failure
314
         */
4650 subik 315
        bool lowerLayer(const int layerNumber);
2947 cbradney 316
        /**
317
         * @brief Lower a layer using the level
4650 subik 318
         * @param layerLevel Level of the layer
2947 cbradney 319
         * @return Success or failure
320
         */
4650 subik 321
        bool lowerLayerByLevel(const int layerLevel);
2947 cbradney 322
        /**
323
         * @brief Raise a layer
4650 subik 324
         * @param layerNumber Number of the layer
2947 cbradney 325
         * @return Success or failure
326
         */
4650 subik 327
        bool raiseLayer(const int layerNumber);
2947 cbradney 328
        /**
329
         * @brief Raise a layer using the level
4650 subik 330
         * @param layerLevel Level of the layer
2947 cbradney 331
         * @return Success or failure
332
         */
4650 subik 333
        bool raiseLayerByLevel(const int layerLevel);
2947 cbradney 334
        /**
335
         * @brief Return the layer name
4650 subik 336
         * @param layerNumber Number of the layer
3201 subik 337
         * @return Name of the layer
2947 cbradney 338
         */
4650 subik 339
        const QString &layerName(const int layerNumber) const;
2947 cbradney 340
        /**
341
         * @brief Change the name of a layer
4645 subik 342
         * @param layerNumber number of the layer
343
         * @param newName new name of the layer
2947 cbradney 344
         * @return Success or failure
345
         */
4645 subik 346
        bool changeLayerName(const int layerNumber, const QString& newName);
2947 cbradney 347
        /**
348
         * @brief Does the layer have items on it?
4650 subik 349
         * @param layerNumber Number of the layer
2947 cbradney 350
         * @return Layer contains items bool
351
         */
4650 subik 352
        bool layerContainsItems(const int layerNumber);
2947 cbradney 353
        /**
354
         * @brief Renumber a layer. Used in particular for reinsertion for undo/redo
4650 subik 355
         * @param layerNumber old layer number
356
         * @param newLayerNumber New layer number
2947 cbradney 357
         * @return Success or failure
358
         */
4650 subik 359
        bool renumberLayer(const int layerNumber, const int newLayerNumber);
2947 cbradney 360
        /**
361
         * @brief Return a list of the layers in their order
4650 subik 362
         * @param list QStringList to insert the layer names into
2947 cbradney 363
         */
4650 subik 364
        void orderedLayerList(QStringList* list);
2937 cbradney 365
        //Items
3985 cbradney 366
        bool deleteTaggedItems();
3201 subik 367
 
3544 avox 368
        bool AddFont(QString name, int fsize = 10);
5345 mrdocs 369
        bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
1330 fschmid 370
        void CloseCMSProfiles();
1065 cbradney 371
        void loadStylesFromFile(QString fileName, QValueList<ParagraphStyle> *tempStyles = NULL);
3201 subik 372
        /**
1179 tsoots 373
         * @brief Should guides be locked or not
374
         * @param isLocked If true guides on pages cannot be moved if false they
375
         * can be dragged to new positions.
376
         * @author Riku Leino
377
         */
378
        void lockGuides(bool isLocked);
1190 tsoots 379
        /**
1179 tsoots 380
         * @brief Method used when an undo/redo is requested.
381
         * @param state State describing the action that is wanted to be undone/redone
382
         * @param isUndo If true undo is wanted else if false redo.
383
         * @author Riku Leino
384
         */
385
        void restore(UndoState* state, bool isUndo);
386
        /**
387
         * @brief Sets the name of the document
388
         * @param name Name for the document
389
         * @author Riku Leino
390
         */
391
        void setName(const QString& name);
1694 cbradney 392
        /*!
393
         * @brief Returns a stringlist of the item attributes within the document
394
         */
395
        QStringList getItemAttributeNames();
3201 subik 396
 
2960 cbradney 397
        /*!
5387 avox 398
         * @brief Returns a qmap of the fonts and  their glyphs used within the document
2960 cbradney 399
         */
5387 avox 400
        void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
6407 fschmid 401
        void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
2960 cbradney 402
        /*!
3057 fschmid 403
        * @brief Builds a qmap of the colours used within the document
404
        */
3068 fschmid 405
        void getUsedColors(ColorList &colorsToUse, bool spot = false);
3057 fschmid 406
        /*!
6400 fschmid 407
        * @brief Builds a QStringList of the patterns used within the document
408
        */
409
        QStringList getUsedPatterns();
6402 fschmid 410
        QStringList getUsedPatternsSelection();
6400 fschmid 411
        QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
412
        /*!
5843 jghali 413
        * @brief Builds a qmap of the icc profiles used within the document
414
        */
415
        void getUsedProfiles(ProfilesL& usedProfiles);
416
        /*!
2960 cbradney 417
         * @brief TODO: Reorganise the fonts.. how? Moved from scribus.cpp
418
         */
419
        void reorganiseFonts();
2965 cbradney 420
        /**
421
         * @brief Set and get the document's unit index
422
         */
423
        void setUnitIndex(const int);
3985 cbradney 424
        int unitIndex() const;
425
        double unitRatio() const;
3004 cbradney 426
        /**
427
         * @brief Apply a master page
428
         */
3985 cbradney 429
        bool applyMasterPage(const QString& in, const int);
3004 cbradney 430
        /**
431
         * @brief Undo function for applying a master page
432
         */
433
        void restoreMasterPageApplying(SimpleState *state, bool isUndo);
3020 cbradney 434
        /**
435
         * @brief Save function
436
         */
3985 cbradney 437
        bool save(const QString&);
3025 cbradney 438
        /**
439
         * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
440
         */
3985 cbradney 441
        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 442
        /**
443
         * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
444
         */
445
         void recalculateColors();
3179 cbradney 446
        /**
447
         * @brief Sets up the ScText defaults from the document
448
         */
449
        void setScTextDefaultsFromDoc(ScText *);
3200 cbradney 450
        /**
451
         * @brief Copies a normal page to be a master pages
452
         */
3650 cbradney 453
        const bool copyPageToMasterPage(const int, const int, const int, const QString&);
3263 cbradney 454
        /**
455
         * @brief Paste an item to the document.
456
         * The bulk of a paste item process runs here for want of a better place, but its a better place
457
         * than the view where it used to be.
458
         * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the
459
         * unnecessary part from the view for now which is overloaded with non ScrollView code.
460
         */
461
        //TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
462
 
463
        /**
464
         * @brief Add an Item to the document.
465
         * A simple function to create an item of a defined type and add it to the document
466
         * Will need extensive rewriting once we have various classes of PageItems, at a guess.
467
         *
468
         * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
469
         * @return Number of created item, -1 on failure.
4650 subik 470
        \param itemType type
471
        \param frameType frame type
472
        \param x X pos
473
        \param y Y pos
474
        \param b width
475
        \param h height
476
        \param w ?
477
        \param fill fill color name
478
        \param outline outline color name
479
        */
3263 cbradney 480
        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);
5164 tsoots 481
 
482
        /** Add an item to the page based on the x/y position. Item will be fitted to the closest guides/margins */
483
        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, const bool itemFinalised);
6115 cbradney 484
 
6137 cbradney 485
        /**
486
         * @brief Allow the user to create a frame easily with some simple placement and sizing options
487
         * @param type Type of frame. @sa PageItem::ItemType
488
         * @param locationType Whether the item is only created on the current page or a range
489
         * @param positionType Location of frame. 0 for 0,0 of page. 1 for 0,0 of page margins, 2, for custom
490
         * @param sizeType Size of frame. 0 for page size, 1 for margin size, 2 for custom
491
         * @param fX X position
492
         * @param fY Y position
493
         * @param fWidth Width of frame
494
         * @param fHeight Height of frame
495
         * @param source Source image or text file for image or text frames
496
         * @param impsetup Import setup for text frames for gtGetText
497
         * @param columnCount Number of columns if created item is a text frame
498
         * @param columnGap Gap between columns if created item is a text frame
499
         * @return
500
         */
6403 cbradney 501
        int itemAddUserFrame(insertAFrameData &iafData);
5164 tsoots 502
 
3263 cbradney 503
        /**
504
         * @brief Commit item creation when a user has click-drag created an item
505
         * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
506
         * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
507
         */
508
        bool itemAddCommit(const int itemNumber);
509
 
510
        /**
511
         * @brief Finalise item creation. Simply split off code from itemAdd
512
         * Only to be called from itemAdd()
513
         */
514
        void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
515
 
516
        //itemDelete
517
        //itemBlah...
3628 cbradney 518
 
519
        /**
520
         * @brief Run this common frame item update code
521
         */
522
        void updateFrameItems();
3648 cbradney 523
 
524
        /**
525
         * @brief Doc uses automatic text frames?
526
         */
3985 cbradney 527
        bool usesAutomaticTextFrames() const;
3648 cbradney 528
        void setUsesAutomaticTextFrames(const bool);
3650 cbradney 529
 
530
        /**
531
         * @brief Load images into an image frame, moved from the view
532
         * @retval Return false on failure
533
         */
5977 jghali 534
        bool LoadPict(QString fn, int ItNr, bool reload = false, bool showMsg = false);
3942 cbradney 535
        /**
536
         *
537
         * @param fn
538
         * @param pageItem
539
         * @param reload
540
         * @return
541
         */
5977 jghali 542
        bool loadPict(QString fn, PageItem *pageItem, bool reload = false, bool showMsg = false);
3656 cbradney 543
        /**
4650 subik 544
         * \brief Handle image with color profiles
545
         * @param Pr profile
546
           @param PrCMYK cmyk profile
547
           @param dia optional progress widget
3942 cbradney 548
         */
549
        void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
550
        /**
3656 cbradney 551
         * @brief Find the minX,MinY and maxX,maxY for the canvas required for the doc
552
         */
553
        void canvasMinMax(FPoint&, FPoint&);
3657 cbradney 554
 
555
        int OnPage(double x2, double  y2);
556
        int OnPage(PageItem *currItem);
557
        void GroupOnPage(PageItem *currItem);
4672 cbradney 558
        //void reformPages(double& maxX, double& maxY, bool moveObjects = true);
559
        void reformPages(bool moveObjects = true);
3664 cbradney 560
 
561
        /**
3670 cbradney 562
         * @brief Return the x or y offset for a page on the canvas
563
         * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
564
         * Mostly saves bringing in extra includes into files that already have scribusdoc.h
3664 cbradney 565
         */
566
        const double getXOffsetForPage(const int);
567
        const double getYOffsetForPage(const int);
3670 cbradney 568
 
569
        /**
570
         * @brief Item type conversion functions
571
         */
3676 cbradney 572
        PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
3670 cbradney 573
 
574
        /**
575
         * @brief The page number of the current page
576
         */
577
        const int currentPageNumber();
3689 cbradney 578
 
579
        /**
580
         * @brief Return true iff the passed name is not used by any existing PageItem
581
         *        in the same document as this PageItem.
582
         * @author Craig Ringer
583
         ** CB Moved from PageItem
584
         */
585
        bool itemNameExists(const QString itemName);
3724 cbradney 586
 
587
        /**
588
         * @brief Set the doc into Master page mode
589
         * Do we need to return if the move to master page mode was successful?
590
         */
4738 cbradney 591
        void setMasterPageMode(bool);
4061 craig 592
 
593
        /*** Is the document in master page mode? */
594
        bool masterPageMode() const { return m_masterPageMode; }
3757 cbradney 595
 
596
        /**
597
         * @brief Add a section to the document sections list
3776 cbradney 598
         * Set number to -1 to add in the default section if the map is empty
3757 cbradney 599
         */
3776 cbradney 600
        void addSection(const int number=0, const QString& name=QString::null, const uint fromindex=0, const uint toindex=0, const  DocumentSectionType type=Type_1_2_3, const uint sectionstartindex=0, const bool reversed=false, const bool active=true);
3757 cbradney 601
        /**
602
         * @brief Delete a section from the document sections list
603
         */
3985 cbradney 604
        bool deleteSection(const uint);
3757 cbradney 605
        /**
606
         * @brief Gets the page number to be printed based on the section it is in.
607
         * Returns QString::null on failure to find the pageIndex
608
         */
609
        const QString getSectionPageNumberForPageIndex(const uint) const;
3776 cbradney 610
        /**
611
         * @brief Gets the key of the sections map based on the section the page index is in.
612
         * Returns -1 on failure to find the pageIndex
613
         */
3985 cbradney 614
        int getSectionKeyForPageIndex(const uint pageIndex) const;
3778 cbradney 615
        /**
616
         *
617
         *
618
         */
619
        void updateSectionPageNumbersToPages();
3792 cbradney 620
        /**
621
         *
622
         *
623
         */
3894 cbradney 624
        /**
625
         *
626
         * @param otherPageIndex
627
         * @param location
628
         * @param count
629
         */
3792 cbradney 630
        void addPageToSection(const uint otherPageIndex, const uint location, const uint count=1);
3894 cbradney 631
        /**
632
         *
633
         * @param pageIndex
634
         */
3793 cbradney 635
        void removePageFromSection(const uint pageIndex);
3894 cbradney 636
        /**
637
         *
638
         */
3793 cbradney 639
        void setFirstSectionFromFirstPageNumber();
3894 cbradney 640
        /**
641
         * @brief Update the fill and line QColors for all items in the doc
642
         */
643
        void updateAllItemQColors();
5334 cbradney 644
        //! @brief Some internal align tools
645
        typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo;
646
        void buildAlignItemList(Selection* customSelection=0);
647
        bool startAlign();
5355 cbradney 648
        void endAlign();
3942 cbradney 649
        /**
4650 subik 650
         * \brief Insert a color into the documents color list
4010 cbradney 651
         * @param nam Name of the colour
652
         * @param c Cyan component
653
         * @param m Magenta component
654
         * @param y Yellow component
655
         * @param k Black component
656
         */
657
        void insertColor(QString nam, double c, double m, double y, double k);
4110 cbradney 658
 
659
        QMap<QString, double>& constants() { return m_constants; }
4122 cbradney 660
        /**
4650 subik 661
         * \brief Get the location of the page on the canvas, ie, left, middle, or right
4122 cbradney 662
         * Does not give information about middle left, etc.
4650 subik 663
         * @param pageIndex Index of page to find location for
4122 cbradney 664
         * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
665
         */
4650 subik 666
        PageLocation locationOfPage(int pageIndex);
4301 cbradney 667
 
668
        bool sendItemSelectionToBack();
669
        bool bringItemSelectionToFront();
5184 avox 670
 
671
        /** Workhorse for the following methods */
672
        void itemSelection_ApplyTextStyle(const CharStyle & newstyle);
673
 
4584 cbradney 674
        void ChLineWidth(double w);
6398 cbradney 675
        void ChLineArt(Qt::PenStyle w);
676
        void ChLineJoin(Qt::PenJoinStyle w);
677
        void ChLineEnd(Qt::PenCapStyle w);
4584 cbradney 678
        void ChLineSpa(double w);
679
        void ChLineSpaMode(int w);
4830 cbradney 680
        //void ChLocalXY(double x, double y);
681
        //void ChLocalSc(double x, double y);
4584 cbradney 682
        void ItemFont(QString fon);
683
        void ItemTextBrush(QString farbe);
684
        void ItemTextBrushS(int sha);
685
        void ItemTextPen(QString farbe);
686
        void ItemTextPenS(int sha);
687
        void ItemTextScaleV(int sha);
688
        void ItemTextScale(int sha);
689
        void setItemTextBase(int sha);
690
        void setItemTextOutline(int sha);
691
        void setItemTextShadow(int shx, int shy);
692
        void setItemTextUnderline(int pos, int wid);
693
        void setItemTextStrike(int pos, int wid);
694
        void chTyStyle(int s);
695
        void chAbStyle(PageItem *currItem, int s);
696
        void chKerning(int us);
697
        void chFSize(int size);
4699 cbradney 698
        //void FlipImageH();
699
        //void FlipImageV();
700
        void MirrorPolyH(PageItem *currItem);
701
        void MirrorPolyV(PageItem *currItem);
4584 cbradney 702
 
4672 cbradney 703
        void setRedrawBounding(PageItem *currItem);
704
        void adjustCanvas(FPoint minPos, FPoint maxPos, bool absolute = false);
4688 cbradney 705
        void recalcPicturesRes();
4672 cbradney 706
        void connectDocSignals();
4713 cbradney 707
        void removeLayer(int l, bool dl = false); //FIXME: Make protected once scripter function no longer uses this directly
5781 cbradney 708
        /*! \brief We call changed() whenever the document needs to know it has been changed.
709
         *  If the document is the primary document in a main window, it will signal to enable/disable
710
         * certain operations.
711
         */
4738 cbradney 712
        void changed();
5087 subik 713
        /*! \brief Get pointer to the current page
714
        \retval Page* current page object */
715
        Page* currentPage();
716
        /*! \brief Set new current page
717
        \param newPage New current page */
718
        void setCurrentPage(Page *newPage);
5823 cbradney 719
        bool hasGUI() const {return m_hasGUI;}
6137 cbradney 720
        /*! \brief Apply grid to a QPoint, from ScribusView */
721
        QPoint ApplyGrid(const QPoint& in);
722
        /*! \brief Apply grid to an FPoint, from ScribusView */
723
        FPoint ApplyGridF(const FPoint& in);
724
 
4672 cbradney 725
 
168 Franz 726
protected:
2891 cbradney 727
        void addSymbols();
5823 cbradney 728
        bool m_hasGUI;
3983 craig 729
        ApplicationPrefs& prefsData;
730
        UndoManager * const undoManager;
2891 cbradney 731
        bool loading;
2937 cbradney 732
        bool modified;
733
        int ActiveLayer;
2965 cbradney 734
        int docUnitIndex;
735
        double docUnitRatio;
3648 cbradney 736
        bool automaticTextFrames; // Flag for automatic Textframes
3724 cbradney 737
        bool m_masterPageMode;
4110 cbradney 738
        QMap<QString, double> m_constants;
5781 cbradney 739
        ScribusMainWindow* m_ScMW;
740
        ScribusView* m_View;
3757 cbradney 741
 
168 Franz 742
public: // Public attributes
2937 cbradney 743
        bool is12doc; //public for now, it will be removed later
1330 fschmid 744
        int NrItems;
745
        int First;
746
        int Last;
747
        int viewCount;
748
        int viewID;
3 paul 749
        bool SnapGuides;
750
        bool GuideLock;
5087 subik 751
        /** \brief Scratch space around Pages */
456 fschmid 752
        double ScratchLeft;
753
        double ScratchRight;
754
        double ScratchTop;
755
        double ScratchBottom;
5087 subik 756
        /** \brief Minimum and Maximum Points of Document */
2837 fschmid 757
        FPoint minCanvasCoordinate;
758
        FPoint maxCanvasCoordinate;
2867 fschmid 759
        double rulerXoffset;
760
        double rulerYoffset;
5087 subik 761
        /** \brief List of Pages */
3724 cbradney 762
        QPtrList<Page>* Pages;
5087 subik 763
        /** \brief List of Master Pages */
456 fschmid 764
        QPtrList<Page> MasterPages;
5087 subik 765
        /** \brief List of Document Pages */
456 fschmid 766
        QPtrList<Page> DocPages;
5087 subik 767
        /** \brief Mapping Master Page Name to Master Page numbers */
456 fschmid 768
        QMap<QString,int> MasterNames;
5087 subik 769
        /** \brief List of Objects */
3727 cbradney 770
        QPtrList<PageItem>* Items;
456 fschmid 771
        QPtrList<PageItem> MasterItems;
772
        QPtrList<PageItem> DocItems;
2447 fschmid 773
        QPtrList<PageItem> FrameItems;
4847 cbradney 774
        Selection* const m_Selection;
5087 subik 775
        /** \brief Pagewidth  */
2142 cbradney 776
        double pageWidth;
5087 subik 777
        /** \brief Pageheight */
2142 cbradney 778
        double pageHeight;
5087 subik 779
        /* Number of Pages */
4069 craig 780
        // int pageCount; Disabled CR no longer required
5087 subik 781
        /** \brief Margins */
2142 cbradney 782
        MarginStruct pageMargins;
3016 fschmid 783
        QValueList<PageSet> pageSets;
5087 subik 784
        /** \brief Number of Columns */
168 Franz 785
        double PageSp;
5087 subik 786
        /** \brief Distance of Columns */
168 Franz 787
        double PageSpa;
5087 subik 788
        /** \brief current Pagelayout */
3032 fschmid 789
        int currentPageLayout;
5087 subik 790
        /** \brief Flag fuer Hoch- oder Querformat 0 = Hochformat */
3032 fschmid 791
        int PageOri;
5789 cbradney 792
        QString m_pageSize;
5087 subik 793
        /** \brief Erste Seitennummer im Dokument */
3 paul 794
        int FirstPnum;
5087 subik 795
        /** \brief Flag fuer Rasterbenutzung */
168 Franz 796
        bool useRaster;
5087 subik 797
        /** \brief Im Dokument benutzte Farben */
1065 cbradney 798
        ColorList PageColors;
5087 subik 799
        /** \brief InfoStrings fuer das aktuelle Dokument */
2016 cbradney 800
        DocumentInformation documentInfo;
1065 cbradney 801
        int appMode;
123 Franz 802
        int SubMode;
803
        double *ShapeValues;
804
        int ValCount;
168 Franz 805
        QString DocName;
3544 avox 806
        QMap<QString,int> UsedFonts;
3983 craig 807
        SCFonts * const AllFonts;
808
        QValueList<AlignObjs> AObjects;
168 Franz 809
        QColor papColor;
810
        int CurrentSel;
5559 avox 811
        ParagraphStyle currentStyle;
812
 
168 Franz 813
        bool EditClip;
814
        int EditClipMode;
2889 cbradney 815
        typoPrefs typographicSettings;
1065 cbradney 816
        guidesPrefs guidesSettings;
1194 fschmid 817
        toolPrefs toolSettings;
3097 cbradney 818
        QMap<QString, checkerPrefs> checkerProfiles;
1261 fschmid 819
        QString curCheckProfile;
5087 subik 820
        /** \brief Letztes Element fuer AutoTextrahmen */
168 Franz 821
        PageItem *LastAuto;
5087 subik 822
        /** \brief Erstes Element fuer AutoTextrahmen */
168 Franz 823
        PageItem *FirstAuto;
824
        bool DragP;
227 Franz 825
        bool leaveDrag;
168 Franz 826
        PageItem *DraggedElem;
827
        PageItem *ElemToLink;
828
        QValueList<uint> DragElements;
5980 avox 829
        StyleSet<ParagraphStyle> docParagraphStyles;
830
        StyleSet<CharStyle> docCharStyles;
3 paul 831
        QValueList<Layer> Layers;
1065 cbradney 832
        bool marginColored;
168 Franz 833
        int GroupCounter;
1065 cbradney 834
        CMSData CMSSettings;
3 paul 835
#ifdef HAVE_CMS
5345 mrdocs 836
        cmsHPROFILE DocInputRGBProf;
837
        cmsHPROFILE DocInputCMYKProf;
3 paul 838
        cmsHPROFILE DocOutputProf;
839
        cmsHPROFILE DocPrinterProf;
5369 mrdocs 840
        cmsHTRANSFORM stdTransRGBMon;
841
        cmsHTRANSFORM stdTransCMYKMon;
1330 fschmid 842
        cmsHTRANSFORM stdProof;
843
        cmsHTRANSFORM stdTransImg;
844
        cmsHTRANSFORM stdProofImg;
1488 fschmid 845
        cmsHTRANSFORM stdTransCMYK;
846
        cmsHTRANSFORM stdProofCMYK;
847
        cmsHTRANSFORM stdTransRGB;
3046 fschmid 848
        cmsHTRANSFORM stdProofGC;
849
        cmsHTRANSFORM stdProofCMYKGC;
1330 fschmid 850
        bool SoftProofing;
851
        bool Gamut;
5345 mrdocs 852
        int IntentColors;
853
        int IntentImages;
3 paul 854
#endif
168 Franz 855
        bool HasCMS;
3 paul 856
        QMap<QString,QString> JavaScripts;
857
        int TotalItems;
858
        int MinWordLen;
249 Franz 859
        int HyCount;
3 paul 860
        QString Language;
861
        bool Automatic;
862
        bool AutoCheck;
3724 cbradney 863
 
1545 cbradney 864
        PDFOptions PDF_Options;
3 paul 865
        bool RePos;
3201 subik 866
        struct BookMa {
168 Franz 867
                                        QString Title;
868
                                        QString Text;
869
                                        QString Aktion;
4679 fschmid 870
                                        PageItem *PageObject;
168 Franz 871
                                        int Parent;
872
                                        int ItemNr;
873
                                        int First;
874
                                        int Last;
875
                                        int Prev;
876
                                        int Next;
877
                                        };
3 paul 878
        QValueList<BookMa> BookMarks;
879
        bool OldBM;
880
        bool hasName;
881
        int RotMode;
882
        bool AutoSave;
734 fschmid 883
        int AutoSaveTime;
3984 craig 884
        QTimer * const autoSaveTimer;
27 Franz 885
        QMap<QString,multiLine> MLineStyles;
1065 cbradney 886
        QValueList<ArrowDesc> arrowStyles;
6368 fschmid 887
        QMap<QString, ScPattern> docPatterns;
59 Franz 888
        QWidget* WinHan;
63 Franz 889
        bool DoDrawing;
168 Franz 890
        QValueList<int> OpenNodes;
139 Franz 891
        QTimer *CurTimer;
5674 fschmid 892
        QMap<int, errorCodes> docLayerErrors;
1229 fschmid 893
        QMap<int, errorCodes> docItemErrors;
1232 fschmid 894
        QMap<int, errorCodes> masterItemErrors;
1641 cbradney 895
        //Attributes to be applied to frames
1649 cbradney 896
        ObjAttrVector docItemAttributes;
1694 cbradney 897
        ToCSetupVector docToCSetups;
3757 cbradney 898
        DocumentSectionMap sections;
2353 fschmid 899
        FPointArray symReturn;
900
        FPointArray symNewLine;
901
        FPointArray symTab;
902
        FPointArray symNonBreak;
2389 fschmid 903
        FPointArray symNewCol;
904
        FPointArray symNewFrame;
3263 cbradney 905
 
5781 cbradney 906
        Hyphenator * docHyphenator;
3263 cbradney 907
private:
908
        bool _itemCreationTransactionStarted;
5087 subik 909
        Page* _currentPage;
3695 cbradney 910
 
911
signals:
912
        //Lets make our doc talk to our GUI rather than confusing all our normal stuff
913
        /**
4584 cbradney 914
         * @brief Let the document tell whatever is listening that it has changed
915
         */
4738 cbradney 916
        void docChanged();
4688 cbradney 917
        void updateContents();
4585 cbradney 918
        void refreshItem(PageItem *);
4672 cbradney 919
        void canvasAdjusted(double width, double height, double dX, double dY);
4688 cbradney 920
        void firstSelectedItemType(int);
921
        void setApplicationMode(int);
4584 cbradney 922
        /**
3695 cbradney 923
         * @brief A signal for when the outline palette needs to rebuild itself
924
         * Emit when:
925
         * - An item is created or deleted
926
         * - An item changes page
927
         * - An page is created or deleted
928
         * - Some items are grouped or a group is ungrouped
929
         * This also applies to Master Pages
930
         */
931
        void signalRebuildOutLinePalette();
4688 cbradney 932
 
933
public slots:
934
        void itemSelection_ToggleLock();
935
        void itemSelection_ToggleSizeLock();
936
        void itemSelection_ToggleImageShown();
4698 cbradney 937
        void itemSelection_TogglePrintEnabled();
4705 cbradney 938
        void itemSelection_ChangePreviewResolution(int id);
4855 cbradney 939
        void itemSelection_ClearItem(Selection* customSelection=0);
4859 cbradney 940
        void itemSelection_DeleteItem(Selection* customSelection=0);
4713 cbradney 941
        void itemSelection_SetItemFillTransparency(double t);
942
        void itemSelection_SetItemLineTransparency(double t);
5746 fschmid 943
        void itemSelection_SetItemFillBlend(int t);
944
        void itemSelection_SetItemLineBlend(int t);
4699 cbradney 945
        void itemSelection_FlipH();
946
        void itemSelection_FlipV();
4713 cbradney 947
        void itemSelection_DoHyphenate();
948
        void itemSelection_DoDeHyphenate();
949
        void itemSelection_SendToLayer(int layerNumber);
4813 cbradney 950
        void itemSelection_SetParagraphStyle(int s);
4847 cbradney 951
        void itemSelection_SetImageOffset(double x, double y, Selection* customSelection=0);
952
        void itemSelection_SetImageScale(double x, double y, Selection* customSelection=0);
953
        void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection=0);
5334 cbradney 954
        void itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition);
955
        void itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition);
956
        void itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition);
957
        void itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition);
958
        void itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition);
959
        void itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition);
960
        void itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition);
961
        void itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition);
962
        void itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition);
963
        void itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition);
964
        void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0);
965
        void itemSelection_DistributeRight();
966
        void itemSelection_DistributeBottom();
967
        void itemSelection_DistributeCenterH();
968
        void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0);
969
        void itemSelection_DistributeLeft();
970
        void itemSelection_DistributeCenterV();
971
        void itemSelection_DistributeTop();
4714 cbradney 972
 
973
        void ItemPen(QString farbe);
974
        void ItemPenShade(int sha);
975
        void ItemBrush(QString farbe);
976
        void ItemBrushShade(int sha);
977
        void ItemGradFill(int typ);
6368 fschmid 978
        void ItemPatternFill(QString pattern);
4714 cbradney 979
 
4688 cbradney 980
        void updatePic();
981
        void updatePict(QString name);
982
        void removePict(QString name);
3 paul 983
};
984
 
985
#endif