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 WKSContentListener;
30 class WPSContentListener;
31 
32 namespace WPSPageSpanInternal
33 {
34 class HeaderFooter;
35 typedef shared_ptr<HeaderFooter> HeaderFooterPtr;
36 }
37 
38 class WPSPageSpan
39 {
40 public:
41 	enum FormOrientation { PORTRAIT, LANDSCAPE };
42 
43 	enum HeaderFooterType { HEADER, FOOTER };
44 	enum HeaderFooterOccurrence { ODD, EVEN, ALL, NEVER };
45 
46 	enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, TopLeftAndRight, TopInsideLeftAndRight,
47 	                          BottomLeft, BottomCenter, BottomRight, BottomLeftAndRight, BottomInsideLeftAndRight
48 	                        };
49 public:
50 	WPSPageSpan();
51 	virtual ~WPSPageSpan();
52 
getFormLength()53 	double getFormLength() const
54 	{
55 		return m_formLength;
56 	}
getFormWidth()57 	double getFormWidth() const
58 	{
59 		return m_formWidth;
60 	}
getFormOrientation()61 	FormOrientation getFormOrientation() const
62 	{
63 		return m_formOrientation;
64 	}
getMarginLeft()65 	double getMarginLeft() const
66 	{
67 		return m_marginLeft;
68 	}
getMarginRight()69 	double getMarginRight() const
70 	{
71 		return m_marginRight;
72 	}
getMarginTop()73 	double getMarginTop() const
74 	{
75 		return m_marginTop;
76 	}
getMarginBottom()77 	double getMarginBottom() const
78 	{
79 		return m_marginBottom;
80 	}
getPageNumberPosition()81 	PageNumberPosition getPageNumberPosition() const
82 	{
83 		return m_pageNumberPosition;
84 	}
getPageNumber()85 	int getPageNumber() const
86 	{
87 		return m_pageNumber;
88 	}
getPageNumberingType()89 	libwps::NumberingType getPageNumberingType() const
90 	{
91 		return m_pageNumberingType;
92 	}
getPageNumberingFontSize()93 	double getPageNumberingFontSize() const
94 	{
95 		return m_pageNumberingFontSize;
96 	}
getPageNumberingFontName()97 	librevenge::RVNGString getPageNumberingFontName() const
98 	{
99 		return m_pageNumberingFontName;
100 	}
getPageSpan()101 	int getPageSpan() const
102 	{
103 		return m_pageSpan;
104 	}
getHeaderFooterList()105 	const std::vector<WPSPageSpanInternal::HeaderFooterPtr> &getHeaderFooterList() const
106 	{
107 		return m_headerFooterList;
108 	}
109 
110 	void setHeaderFooter(const HeaderFooterType type, const HeaderFooterOccurrence occurrence,
111 	                     WPSSubDocumentPtr &subDocument);
setFormLength(const double formLength)112 	void setFormLength(const double formLength)
113 	{
114 		m_formLength = formLength;
115 	}
setFormWidth(const double formWidth)116 	void setFormWidth(const double formWidth)
117 	{
118 		m_formWidth = formWidth;
119 	}
setFormOrientation(const FormOrientation formOrientation)120 	void setFormOrientation(const FormOrientation formOrientation)
121 	{
122 		m_formOrientation = formOrientation;
123 	}
setMarginLeft(const double marginLeft)124 	void setMarginLeft(const double marginLeft)
125 	{
126 		m_marginLeft = marginLeft;
127 	}
setMarginRight(const double marginRight)128 	void setMarginRight(const double marginRight)
129 	{
130 		m_marginRight = marginRight;
131 	}
setMarginTop(const double marginTop)132 	void setMarginTop(const double marginTop)
133 	{
134 		m_marginTop = marginTop;
135 	}
setMarginBottom(const double marginBottom)136 	void setMarginBottom(const double marginBottom)
137 	{
138 		m_marginBottom = marginBottom;
139 	}
setPageNumberPosition(const PageNumberPosition pageNumberPosition)140 	void setPageNumberPosition(const PageNumberPosition pageNumberPosition)
141 	{
142 		m_pageNumberPosition = pageNumberPosition;
143 	}
setPageNumber(const int pageNumber)144 	void setPageNumber(const int pageNumber)
145 	{
146 		m_pageNumber = pageNumber;
147 	}
setPageNumberingType(const libwps::NumberingType pageNumberingType)148 	void setPageNumberingType(const libwps::NumberingType pageNumberingType)
149 	{
150 		m_pageNumberingType = pageNumberingType;
151 	}
setPageNumberingFontSize(const double pageNumberingFontSize)152 	void setPageNumberingFontSize(const double pageNumberingFontSize)
153 	{
154 		m_pageNumberingFontSize = pageNumberingFontSize;
155 	}
setPageNumberingFontName(const librevenge::RVNGString & pageNumberingFontName)156 	void setPageNumberingFontName(const librevenge::RVNGString &pageNumberingFontName)
157 	{
158 		m_pageNumberingFontName = pageNumberingFontName;
159 	}
setPageSpan(const int pageSpan)160 	void setPageSpan(const int pageSpan)
161 	{
162 		m_pageSpan = pageSpan;
163 	}
164 
165 	bool operator==(shared_ptr<WPSPageSpan> const &pageSpan) const;
166 	bool operator!=(shared_ptr<WPSPageSpan> const &pageSpan) const
167 	{
168 		return !operator==(pageSpan);
169 	}
170 
171 	// interface with the listeners
172 	void getPageProperty(librevenge::RVNGPropertyList &pList) const;
173 	void sendHeaderFooters(WPSContentListener *listener, librevenge::RVNGTextInterface *documentInterface);
174 	void sendHeaderFooters(WKSContentListener *listener, librevenge::RVNGSpreadsheetInterface *documentInterface);
175 
176 protected:
177 
178 	int _getHeaderFooterPosition(HeaderFooterType type, HeaderFooterOccurrence occurrence);
179 	void _setHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence, WPSSubDocumentPtr &doc);
180 	void _removeHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence);
181 	bool _containsHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence);
182 
183 	void _insertPageNumberParagraph(librevenge::RVNGTextInterface *documentInterface);
184 private:
185 	double m_formLength, m_formWidth;
186 	FormOrientation m_formOrientation;
187 	double m_marginLeft, m_marginRight;
188 	double m_marginTop, m_marginBottom;
189 	PageNumberPosition m_pageNumberPosition;
190 	int m_pageNumber;
191 	libwps::NumberingType m_pageNumberingType;
192 	librevenge::RVNGString m_pageNumberingFontName;
193 	double m_pageNumberingFontSize;
194 	std::vector<WPSPageSpanInternal::HeaderFooterPtr> m_headerFooterList;
195 
196 	int m_pageSpan;
197 };
198 
199 #endif
200 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
201