- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

WPSPageSpan.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
11 * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
12 * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13 *
14 * For minor contributions see the git repository.
15 *
16 * Alternatively, the contents of this file may be used under the terms
17 * of the GNU Lesser General Public License Version 2.1 or later
18 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19 * applicable instead of those above.
20 *
21 * For further information visit http://libwps.sourceforge.net
22 */
23
24 #ifndef WPSPAGESPAN_H
25 #define WPSPAGESPAN_H
26 #include <vector>
27 #include "libwps_internal.h"
28
29 class WPXPropertyList;
30 class WPXDocumentProperty;
31 class WPSContentListener;
32
33 class WPSSubDocument;
34 typedef shared_ptr<WPSSubDocument> WPSSubDocumentPtr;
35
36 namespace WPSPageSpanInternal
37 {
38 class HeaderFooter;
39 typedef shared_ptr<HeaderFooter> HeaderFooterPtr;
40 }
41
42 class WPSPageSpan
43 {
44 friend class WPSContentListener;
45 public:
46 enum FormOrientation { PORTRAIT, LANDSCAPE };
47
48 enum HeaderFooterType { HEADER, FOOTER };
49 enum HeaderFooterOccurence { ODD, EVEN, ALL, NEVER };
50
51 enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, TopLeftAndRight, TopInsideLeftAndRight,
52 BottomLeft, BottomCenter, BottomRight, BottomLeftAndRight, BottomInsideLeftAndRight
53 };
54 public:
55 WPSPageSpan();
56 virtual ~WPSPageSpan();
57
58 double getFormLength() const
59 {
60 return m_formLength;
61 }
62 double getFormWidth() const
63 {
64 return m_formWidth;
65 }
66 FormOrientation getFormOrientation() const
67 {
68 return m_formOrientation;
69 }
70 double getMarginLeft() const
71 {
72 return m_marginLeft;
73 }
74 double getMarginRight() const
75 {
76 return m_marginRight;
77 }
78 double getMarginTop() const
79 {
80 return m_marginTop;
81 }
82 double getMarginBottom() const
83 {
84 return m_marginBottom;
85 }
86 PageNumberPosition getPageNumberPosition() const
87 {
88 return m_pageNumberPosition;
89 }
90 int getPageNumber() const
91 {
92 return m_pageNumber;
93 }
94 libwps::NumberingType getPageNumberingType() const
95 {
96 return m_pageNumberingType;
97 }
98 double getPageNumberingFontSize() const
99 {
100 return m_pageNumberingFontSize;
101 }
102 WPXString getPageNumberingFontName() const
103 {
104 return m_pageNumberingFontName;
105 }
106 int getPageSpan() const
107 {
108 return m_pageSpan;
109 }
110 const std::vector<WPSPageSpanInternal::HeaderFooterPtr> &getHeaderFooterList() const
111 {
112 return m_headerFooterList;
113 }
114
115 void setHeaderFooter(const HeaderFooterType type, const HeaderFooterOccurence occurence,
116 WPSSubDocumentPtr &subDocument);
117 void setFormLength(const double formLength)
118 {
119 m_formLength = formLength;
120 }
121 void setFormWidth(const double formWidth)
122 {
123 m_formWidth = formWidth;
124 }
125 void setFormOrientation(const FormOrientation formOrientation)
126 {
127 m_formOrientation = formOrientation;
128 }
129 void setMarginLeft(const double marginLeft)
130 {
131 m_marginLeft = marginLeft;
132 }
133 void setMarginRight(const double marginRight)
134 {
135 m_marginRight = marginRight;
136 }
137 void setMarginTop(const double marginTop)
138 {
139 m_marginTop = marginTop;
140 }
141 void setMarginBottom(const double marginBottom)
142 {
143 m_marginBottom = marginBottom;
144 }
145 void setPageNumberPosition(const PageNumberPosition pageNumberPosition)
146 {
147 m_pageNumberPosition = pageNumberPosition;
148 }
149 void setPageNumber(const int pageNumber)
150 {
151 m_pageNumber = pageNumber;
152 }
153 void setPageNumberingType(const libwps::NumberingType pageNumberingType)
154 {
155 m_pageNumberingType = pageNumberingType;
156 }
157 void setPageNumberingFontSize(const double pageNumberingFontSize)
158 {
159 m_pageNumberingFontSize = pageNumberingFontSize;
160 }
161 void setPageNumberingFontName(const WPXString &pageNumberingFontName)
162 {
163 m_pageNumberingFontName = pageNumberingFontName;
164 }
165 void setPageSpan(const int pageSpan)
166 {
167 m_pageSpan = pageSpan;
168 }
169
170 bool operator==(shared_ptr<WPSPageSpan> const &pageSpan) const;
171 bool operator!=(shared_ptr<WPSPageSpan> const &pageSpan) const
172 {
173 return !operator==(pageSpan);
174 }
175 protected:
176 // interface with WPSContentListener
177 void getPageProperty(WPXPropertyList &pList) const;
178 void sendHeaderFooters(WPSContentListener *listener,
179 WPXDocumentInterface *documentInterface);
180
181 protected:
182
183 int _getHeaderFooterPosition(HeaderFooterType type, HeaderFooterOccurence occurence);
184 void _setHeaderFooter(HeaderFooterType type, HeaderFooterOccurence occurence, WPSSubDocumentPtr &doc);
185 void _removeHeaderFooter(HeaderFooterType type, HeaderFooterOccurence occurence);
186 bool _containsHeaderFooter(HeaderFooterType type, HeaderFooterOccurence occurence);
187
188 void _insertPageNumberParagraph(WPXDocumentInterface *documentInterface);
189 private:
190 double m_formLength, m_formWidth;
191 FormOrientation m_formOrientation;
192 double m_marginLeft, m_marginRight;
193 double m_marginTop, m_marginBottom;
194 PageNumberPosition m_pageNumberPosition;
195 int m_pageNumber;
196 libwps::NumberingType m_pageNumberingType;
197 WPXString m_pageNumberingFontName;
198 double m_pageNumberingFontSize;
199 std::vector<WPSPageSpanInternal::HeaderFooterPtr> m_headerFooterList;
200
201 int m_pageSpan;
202 };
203
204 #endif
205 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */