MWAWPageSpan.hxx Source File documentation

MWAWPageSpan.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3/* libmwaw
4* Version: MPL 2.0 / LGPLv2+
5*
6* The contents of this file are subject to the Mozilla Public License Version
7* 2.0 (the "License"); you may not use this file except in compliance with
8* the License or as specified alternatively below. You may obtain a copy of
9* the License at http://www.mozilla.org/MPL/
10*
11* Software distributed under the License is distributed on an "AS IS" basis,
12* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13* for the specific language governing rights and limitations under the
14* License.
15*
16* Major Contributor(s):
17* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20* Copyright (C) 2006, 2007 Andrew Ziem
21* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22*
23*
24* All Rights Reserved.
25*
26* For minor contributions see the git repository.
27*
28* Alternatively, the contents of this file may be used under the terms of
29* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30* in which case the provisions of the LGPLv2+ are applicable
31* instead of those above.
32*/
33
34#ifndef MWAWPAGESPAN_H
35#define MWAWPAGESPAN_H
36
37#include <vector>
38
39#include "libmwaw_internal.hxx"
40
41#include "MWAWFont.hxx"
42
44 class MWAWHeaderFooter
45{
46public:
48 enum Type { HEADER, FOOTER, UNDEF };
50 enum Occurrence { ODD, EVEN, ALL, NEVER };
52 enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight };
53
55 explicit MWAWHeaderFooter(Type const type=UNDEF, Occurrence const occurrence=NEVER);
56 MWAWHeaderFooter(MWAWHeaderFooter const &)=default;
57 MWAWHeaderFooter &operator=(MWAWHeaderFooter const &)=default;
58 MWAWHeaderFooter &operator=(MWAWHeaderFooter &&)=default;
60 ~MWAWHeaderFooter();
62 bool isDefined() const
63 {
64 return m_type != UNDEF;
65 }
66
67 void send(MWAWListener *listener) const;
69 bool operator==(MWAWHeaderFooter const &headerFooter) const;
71 bool operator!=(MWAWHeaderFooter const &headerFooter) const
72 {
73 return !operator==(headerFooter);
74 }
75
76 void insertPageNumberParagraph(MWAWListener *listener) const;
77
78public:
80 Type m_type;
82 Occurrence m_occurrence;
84 double m_height;
86 PageNumberPosition m_pageNumberPosition;
88 libmwaw::NumberingType m_pageNumberType;
90 MWAWFont m_pageNumberFont;
92 MWAWSubDocumentPtr m_subDocument;
93};
94
95 typedef std::shared_ptr<MWAWHeaderFooter> MWAWHeaderFooterPtr;
96
98 class MWAWPageSpan
99{
100public:
102 enum FormOrientation { PORTRAIT, LANDSCAPE };
104 enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight,
105 BottomLeft, BottomCenter, BottomRight
106 };
107public:
109 MWAWPageSpan();
110 MWAWPageSpan(MWAWPageSpan const &)=default;
111 MWAWPageSpan &operator=(MWAWPageSpan const &)=default;
112 MWAWPageSpan &operator=(MWAWPageSpan &&)=default;
114 ~MWAWPageSpan();
115
117 double getFormLength() const
118 {
119 return m_formLength;
120 }
121
122 double getFormWidth() const
123 {
124 return m_formWidth;
125 }
126
127 FormOrientation getFormOrientation() const
128 {
129 return m_formOrientation;
130 }
131
132 double getMarginLeft() const
133 {
134 return m_margins[libmwaw::Left];
135 }
136
137 double getMarginRight() const
138 {
139 return m_margins[libmwaw::Right];
140 }
141
142 double getMarginTop() const
143 {
144 return m_margins[libmwaw::Top];
145 }
146
147 double getMarginBottom() const
148 {
149 return m_margins[libmwaw::Bottom];
150 }
151
152 double getPageLength() const
153 {
154 return m_formLength-m_margins[libmwaw::Top]-m_margins[libmwaw::Bottom];
155 }
156
157 double getPageWidth() const
158 {
159 return m_formWidth-m_margins[libmwaw::Left]-m_margins[libmwaw::Right];
160 }
161
162 MWAWColor backgroundColor() const
163 {
164 return m_backgroundColor;
165 }
166 int getPageNumber() const
167 {
168 return m_pageNumber;
169 }
170 int getPageSpan() const
171 {
172 return m_pageSpan;
173 }
174
176 void setHeaderFooter(MWAWHeaderFooter const &headerFooter);
178 void setFormLength(const double formLength)
179 {
180 m_formLength = formLength;
181 }
182
183 void setFormWidth(const double formWidth)
184 {
185 m_formWidth = formWidth;
186 }
187
188 void setFormOrientation(const FormOrientation formOrientation)
189 {
190 m_formOrientation = formOrientation;
191 }
192
193 void setMarginLeft(const double marginLeft)
194 {
195 m_margins[libmwaw::Left] = (marginLeft >= 0) ? marginLeft : 0.01;
196 }
197
198 void setMarginRight(const double marginRight)
199 {
200 m_margins[libmwaw::Right] = (marginRight >= 0) ? marginRight : 0.01;
201 }
202
203 void setMarginTop(const double marginTop)
204 {
205 m_margins[libmwaw::Top] =(marginTop >= 0) ? marginTop : 0.01;
206 }
207
208 void setMarginBottom(const double marginBottom)
209 {
210 m_margins[libmwaw::Bottom] = (marginBottom >= 0) ? marginBottom : 0.01;
211 }
212
213 void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
214 {
215 if (margin < 0.0) margin = 0.01;
216 if (wh&libmwaw::LeftBit)
217 m_margins[libmwaw::Left]=margin;
218 if (wh&libmwaw::RightBit)
219 m_margins[libmwaw::Right]=margin;
220 if (wh&libmwaw::TopBit)
221 m_margins[libmwaw::Top]=margin;
222 if (wh&libmwaw::BottomBit)
223 m_margins[libmwaw::Bottom]=margin;
224 }
225
226 void checkMargins();
228 void setPageName(librevenge::RVNGString const &name)
229 {
230 m_name=name;
231 }
232
233 bool hasPageName() const
234 {
235 return !m_name.empty();
236 }
237
238 librevenge::RVNGString const &getPageName() const
239 {
240 return m_name;
241 }
242
243 void setMasterPageName(librevenge::RVNGString const &name)
244 {
245 m_masterName=name;
246 }
247
248 bool hasMasterPageName() const
249 {
250 return !m_masterName.empty();
251 }
252
253 librevenge::RVNGString const &getMasterPageName() const
254 {
255 return m_masterName;
256 }
257
258 void setBackgroundColor(MWAWColor color=MWAWColor::white())
259 {
260 m_backgroundColor=color;
261 }
262
263 void setPageNumber(const int pageNumber)
264 {
265 m_pageNumber = pageNumber;
266 }
267
268 void setPageSpan(const int pageSpan)
269 {
270 m_pageSpan = pageSpan;
271 }
272
273 bool operator==(std::shared_ptr<MWAWPageSpan> const &pageSpan) const;
275 bool operator!=(std::shared_ptr<MWAWPageSpan> const &pageSpan) const
276 {
277 return !operator==(pageSpan);
278 }
279
280 // interface with MWAWListener
282 void getPageProperty(librevenge::RVNGPropertyList &pList, bool isPresentation=false) const;
284 void sendHeaderFooters(MWAWListener *listener) const;
286 void sendHeaderFooters(MWAWListener *listener, MWAWHeaderFooter::Occurrence occurrence) const;
287
288protected:
290 int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence);
292 void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence);
294 bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence);
295private:
296 double m_formLength, m_formWidth ;
298 double m_margins[4];
300 librevenge::RVNGString m_name;
302 librevenge::RVNGString m_masterName;
304 FormOrientation m_formOrientation;
306 MWAWColor m_backgroundColor;
308 std::vector<MWAWHeaderFooter> m_headerFooterList;
310 int m_pageNumber;
312 int m_pageSpan;
313};
314
315#endif
316// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWFont.hxx
MWAWHeaderFooterPtr
std::shared_ptr< MWAWHeaderFooter > MWAWHeaderFooterPtr
Definition MWAWPageSpan.hxx:95
MWAWFont
Class to store font.
Definition MWAWFont.hxx:44
MWAWHeaderFooter
a class which stores the header/footer data
Definition MWAWPageSpan.hxx:45
MWAWHeaderFooter::m_height
double m_height
the height ( if known )
Definition MWAWPageSpan.hxx:84
MWAWHeaderFooter::m_pageNumberFont
MWAWFont m_pageNumberFont
the page numbering font
Definition MWAWPageSpan.hxx:90
MWAWHeaderFooter::operator==
bool operator==(MWAWHeaderFooter const &headerFooter) const
operator==
Definition MWAWPageSpan.cxx:112
MWAWHeaderFooter::insertPageNumberParagraph
void insertPageNumberParagraph(MWAWListener *listener) const
insert a page number
Definition MWAWPageSpan.cxx:175
MWAWHeaderFooter::Type
Type
the header/footer type
Definition MWAWPageSpan.hxx:48
MWAWHeaderFooter::UNDEF
@ UNDEF
Definition MWAWPageSpan.hxx:48
MWAWHeaderFooter::FOOTER
@ FOOTER
Definition MWAWPageSpan.hxx:48
MWAWHeaderFooter::HEADER
@ HEADER
Definition MWAWPageSpan.hxx:48
MWAWHeaderFooter::operator=
MWAWHeaderFooter & operator=(MWAWHeaderFooter &&)=default
MWAWHeaderFooter::m_pageNumberType
libmwaw::NumberingType m_pageNumberType
the page numbering type
Definition MWAWPageSpan.hxx:88
MWAWHeaderFooter::isDefined
bool isDefined() const
returns true if the header footer is defined
Definition MWAWPageSpan.hxx:62
MWAWHeaderFooter::MWAWHeaderFooter
MWAWHeaderFooter(MWAWHeaderFooter const &)=default
MWAWHeaderFooter::m_occurrence
Occurrence m_occurrence
the actual occurrence
Definition MWAWPageSpan.hxx:82
MWAWHeaderFooter::m_subDocument
MWAWSubDocumentPtr m_subDocument
the document data
Definition MWAWPageSpan.hxx:92
MWAWHeaderFooter::Occurrence
Occurrence
the header/footer occurrence in the file
Definition MWAWPageSpan.hxx:50
MWAWHeaderFooter::ALL
@ ALL
Definition MWAWPageSpan.hxx:50
MWAWHeaderFooter::ODD
@ ODD
Definition MWAWPageSpan.hxx:50
MWAWHeaderFooter::EVEN
@ EVEN
Definition MWAWPageSpan.hxx:50
MWAWHeaderFooter::NEVER
@ NEVER
Definition MWAWPageSpan.hxx:50
MWAWHeaderFooter::operator=
MWAWHeaderFooter & operator=(MWAWHeaderFooter const &)=default
MWAWHeaderFooter::PageNumberPosition
PageNumberPosition
a fixed page number position
Definition MWAWPageSpan.hxx:52
MWAWHeaderFooter::BottomRight
@ BottomRight
Definition MWAWPageSpan.hxx:52
MWAWHeaderFooter::TopRight
@ TopRight
Definition MWAWPageSpan.hxx:52
MWAWHeaderFooter::TopLeft
@ TopLeft
Definition MWAWPageSpan.hxx:52
MWAWHeaderFooter::None
@ None
Definition MWAWPageSpan.hxx:52
MWAWHeaderFooter::BottomLeft
@ BottomLeft
Definition MWAWPageSpan.hxx:52
MWAWHeaderFooter::BottomCenter
@ BottomCenter
Definition MWAWPageSpan.hxx:52
MWAWHeaderFooter::TopCenter
@ TopCenter
Definition MWAWPageSpan.hxx:52
MWAWHeaderFooter::~MWAWHeaderFooter
~MWAWHeaderFooter()
destructor
Definition MWAWPageSpan.cxx:108
MWAWHeaderFooter::operator!=
bool operator!=(MWAWHeaderFooter const &headerFooter) const
operator!=
Definition MWAWPageSpan.hxx:71
MWAWHeaderFooter::send
void send(MWAWListener *listener) const
send to header to the listener
Definition MWAWPageSpan.cxx:135
MWAWHeaderFooter::m_pageNumberPosition
PageNumberPosition m_pageNumberPosition
the page number position ( or none)
Definition MWAWPageSpan.hxx:86
MWAWHeaderFooter::MWAWHeaderFooter
MWAWHeaderFooter(Type const type=UNDEF, Occurrence const occurrence=NEVER)
constructor
Definition MWAWPageSpan.cxx:97
MWAWHeaderFooter::m_type
Type m_type
the type header/footer
Definition MWAWPageSpan.hxx:80
MWAWListener
This class contains a virtual interface to all listener.
Definition MWAWListener.hxx:50
MWAWPageSpan::backgroundColor
MWAWColor backgroundColor() const
returns the background color
Definition MWAWPageSpan.hxx:162
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition MWAWPageSpan.hxx:268
MWAWPageSpan::setMarginTop
void setMarginTop(const double marginTop)
set the page top margin
Definition MWAWPageSpan.hxx:203
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition MWAWPageSpan.hxx:208
MWAWPageSpan::containsHeaderFooter
bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
return true if we have a header footer in this position
Definition MWAWPageSpan.cxx:387
MWAWPageSpan::hasMasterPageName
bool hasMasterPageName() const
return true if the masterPage has a name
Definition MWAWPageSpan.hxx:248
MWAWPageSpan::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition MWAWPageSpan.hxx:157
MWAWPageSpan::getPageProperty
void getPageProperty(librevenge::RVNGPropertyList &pList, bool isPresentation=false) const
add the page properties in pList
Definition MWAWPageSpan.cxx:310
MWAWPageSpan::operator=
MWAWPageSpan & operator=(MWAWPageSpan const &)=default
MWAWPageSpan::operator==
bool operator==(std::shared_ptr< MWAWPageSpan > const &pageSpan) const
operator==
Definition MWAWPageSpan.cxx:339
MWAWPageSpan::FormOrientation
FormOrientation
the page orientation
Definition MWAWPageSpan.hxx:102
MWAWPageSpan::LANDSCAPE
@ LANDSCAPE
Definition MWAWPageSpan.hxx:102
MWAWPageSpan::PORTRAIT
@ PORTRAIT
Definition MWAWPageSpan.hxx:102
MWAWPageSpan::hasPageName
bool hasPageName() const
return true if the page has a name
Definition MWAWPageSpan.hxx:233
MWAWPageSpan::MWAWPageSpan
MWAWPageSpan(MWAWPageSpan const &)=default
MWAWPageSpan::m_margins
double m_margins[4]
the margins: libmwaw::Left, ...
Definition MWAWPageSpan.hxx:298
MWAWPageSpan::PageNumberPosition
PageNumberPosition
a fixed page number position
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::TopCenter
@ TopCenter
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::BottomRight
@ BottomRight
Definition MWAWPageSpan.hxx:105
MWAWPageSpan::BottomLeft
@ BottomLeft
Definition MWAWPageSpan.hxx:105
MWAWPageSpan::BottomCenter
@ BottomCenter
Definition MWAWPageSpan.hxx:105
MWAWPageSpan::TopRight
@ TopRight
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::None
@ None
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::TopLeft
@ TopLeft
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::getPageNumber
int getPageNumber() const
Definition MWAWPageSpan.hxx:166
MWAWPageSpan::m_pageNumber
int m_pageNumber
the page number ( or -1)
Definition MWAWPageSpan.hxx:310
MWAWPageSpan::getPageLength
double getPageLength() const
returns the page length (form width without margin )
Definition MWAWPageSpan.hxx:152
MWAWPageSpan::getMasterPageName
librevenge::RVNGString const & getMasterPageName() const
return the page master name
Definition MWAWPageSpan.hxx:253
MWAWPageSpan::getFormWidth
double getFormWidth() const
returns the page width
Definition MWAWPageSpan.hxx:122
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition MWAWPageSpan.hxx:183
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition MWAWPageSpan.hxx:198
MWAWPageSpan::getMarginTop
double getMarginTop() const
returns the top margin
Definition MWAWPageSpan.hxx:142
MWAWPageSpan::setBackgroundColor
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition MWAWPageSpan.hxx:258
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition MWAWPageSpan.hxx:193
MWAWPageSpan::MWAWPageSpan
MWAWPageSpan()
constructor
Definition MWAWPageSpan.cxx:209
MWAWPageSpan::m_pageSpan
int m_pageSpan
the number of page
Definition MWAWPageSpan.hxx:312
MWAWPageSpan::m_formWidth
double m_formWidth
the form width
Definition MWAWPageSpan.hxx:296
MWAWPageSpan::m_formLength
double m_formLength
the form length
Definition MWAWPageSpan.hxx:296
MWAWPageSpan::setMasterPageName
void setMasterPageName(librevenge::RVNGString const &name)
set the page master name
Definition MWAWPageSpan.hxx:243
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition MWAWPageSpan.hxx:178
MWAWPageSpan::m_masterName
librevenge::RVNGString m_masterName
the page master name
Definition MWAWPageSpan.hxx:302
MWAWPageSpan::getMarginLeft
double getMarginLeft() const
returns the left margin
Definition MWAWPageSpan.hxx:132
MWAWPageSpan::removeHeaderFooter
void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
remove a header footer
Definition MWAWPageSpan.cxx:380
MWAWPageSpan::m_backgroundColor
MWAWColor m_backgroundColor
the page background color: default white
Definition MWAWPageSpan.hxx:306
MWAWPageSpan::sendHeaderFooters
void sendHeaderFooters(MWAWListener *listener) const
send the page's headers/footers if some exists
Definition MWAWPageSpan.cxx:283
MWAWPageSpan::getFormLength
double getFormLength() const
returns the page length
Definition MWAWPageSpan.hxx:117
MWAWPageSpan::m_name
librevenge::RVNGString m_name
the page name
Definition MWAWPageSpan.hxx:300
MWAWPageSpan::getHeaderFooterPosition
int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
return the header footer positions in m_headerFooterList
Definition MWAWPageSpan.cxx:394
MWAWPageSpan::checkMargins
void checkMargins()
check if the page margins are consistent with the page dimension, if not update them
Definition MWAWPageSpan.cxx:271
MWAWPageSpan::m_formOrientation
FormOrientation m_formOrientation
the form orientation
Definition MWAWPageSpan.hxx:304
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition MWAWPageSpan.hxx:213
MWAWPageSpan::getFormOrientation
FormOrientation getFormOrientation() const
returns the page orientation
Definition MWAWPageSpan.hxx:127
MWAWPageSpan::m_headerFooterList
std::vector< MWAWHeaderFooter > m_headerFooterList
the list of header
Definition MWAWPageSpan.hxx:308
MWAWPageSpan::operator!=
bool operator!=(std::shared_ptr< MWAWPageSpan > const &pageSpan) const
operator!=
Definition MWAWPageSpan.hxx:275
MWAWPageSpan::~MWAWPageSpan
~MWAWPageSpan()
destructor
Definition MWAWPageSpan.cxx:223
MWAWPageSpan::operator=
MWAWPageSpan & operator=(MWAWPageSpan &&)=default
MWAWPageSpan::getPageSpan
int getPageSpan() const
Definition MWAWPageSpan.hxx:170
MWAWPageSpan::getMarginBottom
double getMarginBottom() const
returns the bottom margin
Definition MWAWPageSpan.hxx:147
MWAWPageSpan::setPageName
void setPageName(librevenge::RVNGString const &name)
set the page name
Definition MWAWPageSpan.hxx:228
MWAWPageSpan::setHeaderFooter
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition MWAWPageSpan.cxx:227
MWAWPageSpan::getPageName
librevenge::RVNGString const & getPageName() const
return the page name
Definition MWAWPageSpan.hxx:238
MWAWPageSpan::setFormOrientation
void setFormOrientation(const FormOrientation formOrientation)
set the form orientation
Definition MWAWPageSpan.hxx:188
MWAWPageSpan::getMarginRight
double getMarginRight() const
returns the right margin
Definition MWAWPageSpan.hxx:137
MWAWPageSpan::setPageNumber
void setPageNumber(const int pageNumber)
set the page number
Definition MWAWPageSpan.hxx:263
libmwaw_internal.hxx
MWAWSubDocumentPtr
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition libmwaw_internal.hxx:565
libmwaw::LeftBit
@ LeftBit
Definition libmwaw_internal.hxx:178
libmwaw::BottomBit
@ BottomBit
Definition libmwaw_internal.hxx:178
libmwaw::TopBit
@ TopBit
Definition libmwaw_internal.hxx:178
libmwaw::RightBit
@ RightBit
Definition libmwaw_internal.hxx:178
libmwaw::NumberingType
NumberingType
Definition libmwaw_internal.hxx:180
libmwaw::Top
@ Top
Definition libmwaw_internal.hxx:176
libmwaw::Bottom
@ Bottom
Definition libmwaw_internal.hxx:176
libmwaw::Left
@ Left
Definition libmwaw_internal.hxx:176
libmwaw::Right
@ Right
Definition libmwaw_internal.hxx:176
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192
MWAWColor::white
static MWAWColor white()
return the white color
Definition libmwaw_internal.hxx:250