1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8                           page.h  -  description
9                              -------------------
10     begin                : Sat Apr 7 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 
24 #ifndef SCPAGE_H
25 #define SCPAGE_H
26 
27 #include <utility>
28 
29 #include <QList>
30 #include <QPair>
31 #include <QRectF>
32 #include <QString>
33 
34 #include "scribusapi.h"
35 #include "undostate.h"
36 #include "scribusstructs.h"
37 #include "guidemanagercore.h"
38 
39 class PageItem;
40 class UndoManager;
41 class UndoState;
42 class ScribusDoc;
43 
44 
45 /**
46   *@author Franz Schmid
47   */
48 class SCRIBUS_API ScPage : public UndoObject, public SingleObservable<ScPage>
49 {
50 public:
51 	ScPage(const double x, const double y, const double b, const double h);
52 	~ScPage();
53 
xOffset()54 	double xOffset() const { return m_xOffset; }
yOffset()55 	double yOffset() const { return m_yOffset; }
width()56 	double width() const { return m_width; }
height()57 	double height() const { return m_height; }
initialWidth()58 	double initialWidth() const { return m_initialWidth; }
initialHeight()59 	double initialHeight() const { return m_initialHeight; }
orientation()60 	int orientation() const { return m_orientation; }
61 	void setXOffset(const double);
62 	void setYOffset(const double);
63 	void setWidth(const double);
64 	void setHeight(const double);
65 	void setInitialWidth(const double);
66 	void setInitialHeight(const double);
67 	void setOrientation(int);
68 	void copySizingProperties(ScPage *sourcePage, const MarginStruct& pageMargins);
margins()69 	MarginStruct margins() const { return Margins; }
leftMargin()70 	double leftMargin() const { return Margins.left(); }
topMargin()71 	double topMargin() const { return Margins.top(); }
bottomMargin()72 	double bottomMargin() const { return Margins.bottom(); }
rightMargin()73 	double rightMargin() const { return Margins.right(); }
74 
75 	MarginStruct Margins;
76 	MarginStruct initialMargins;
77 	int LeftPg {0};
78 	int marginPreset {0};
79 
doc()80 	ScribusDoc* doc() const { return m_Doc; }
81 	void setDocument(ScribusDoc* doc);
pageNr()82 	int pageNr() const { return m_pageNr; }
83 	void setPageNr(int pageNr);
pageSectionNumber()84 	const QString& pageSectionNumber() const { return m_pageSectionNumber; }
85 	void setPageSectionNumber(const QString&);
86 	//! Return the page's name
pageName()87 	const QString& pageName() const {return m_pageName;}
pageNameEmpty()88 	bool pageNameEmpty() const {return m_pageName.isEmpty();}
89 	void setPageName(const QString& newName);
90 	void resetPageName();
masterPageName()91 	const QString& masterPageName() const {return m_masterPageName;}
masterPageNameEmpty()92 	bool masterPageNameEmpty() const {return m_masterPageName.isEmpty();}
93 	void setMasterPageName(const QString& newName);
94 	void setMasterPageNameNormal();
95 	void clearMasterPageName();
size()96 	const QString& size() const {return m_pageSize;}
97 	void setSize(const QString& newSize);
98 	void restore(UndoState* state, bool isUndo);
99 
100 	QRectF bleedRect() const;
101 	QRectF trimRect() const;
102 
103 	/*! \brief As a bit of a dirty hack, we declare this mutable so it can be altered
104 	even while the object is `const'. That's normally only for internal
105 	implementation, but in this case it at least lets us guarantee the rest
106 	of the object is unchanged in (eg) pdflib. This should be replaced with
107 	proper access methods later. */
108 	mutable QList<PageItem*> FromMaster;
109 	//! \brief Guides lists and basic operations
110 	GuideManagerCore guides;
111 	PDFPresentationData PresentVals;
112 
113 protected:
114 	UndoManager* const undoManager;
115 	void restorePageItemCreation(ScItemState<PageItem*> *state, bool isUndo);
116 	void restorePageItemDeletion(ScItemState< QList<PageItem*> > *state, bool isUndo);
117 	void restorePageAttributes(SimpleState *state, bool isUndo);
118 	void restorePageItemConversion(ScItemState<QPair<PageItem*, PageItem*> >*state, bool isUndo);
119 	void restorePageItemConversionToSymbol(ScItemState<QPair<PageItem*, PageItem*> >*state, bool isUndo);
120 
121 	double m_xOffset {0.0};
122 	double m_yOffset {0.0};
123 	double m_width {0.0};
124 	double m_height {0.0};
125 	double m_initialWidth {0.0};
126 	double m_initialHeight {0.0};
127 	int m_pageNr {0};
128 	int m_orientation {0};
129 	//! Name of this page, currently only allowed to be used by a master page
130 	QString m_pageName;
131 	QString m_masterPageName;
132 	QString m_pageSize;
133 	QString m_pageSectionNumber;
134 	ScribusDoc* m_Doc {nullptr};
135 };
136 
137 Q_DECLARE_METATYPE(ScPage*);
138 
139 #endif
140