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 
45 {
46 public:
48  enum Type { HEADER, FOOTER, UNDEF };
50  enum Occurrence { ODD, EVEN, ALL, NEVER };
53 
55  MWAWHeaderFooter(Type const type=UNDEF, Occurrence const occurrence=NEVER);
56  MWAWHeaderFooter(MWAWHeaderFooter const &)=default;
61  bool isDefined() const
62  {
63  return m_type != UNDEF;
64  }
66  void send(MWAWListener *listener) const;
68  bool operator==(MWAWHeaderFooter const &headerFooter) const;
70  bool operator!=(MWAWHeaderFooter const &headerFooter) const
71  {
72  return !operator==(headerFooter);
73  }
75  void insertPageNumberParagraph(MWAWListener *listener) const;
76 
77 public:
83  double m_height;
92 };
93 
94 typedef std::shared_ptr<MWAWHeaderFooter> MWAWHeaderFooterPtr;
95 
98 {
99 public:
105  };
106 public:
108  MWAWPageSpan();
109  MWAWPageSpan(MWAWPageSpan const &)=default;
110  MWAWPageSpan &operator=(MWAWPageSpan const &)=default;
112  ~MWAWPageSpan();
113 
115  double getFormLength() const
116  {
117  return m_formLength;
118  }
120  double getFormWidth() const
121  {
122  return m_formWidth;
123  }
126  {
127  return m_formOrientation;
128  }
130  double getMarginLeft() const
131  {
132  return m_margins[libmwaw::Left];
133  }
135  double getMarginRight() const
136  {
137  return m_margins[libmwaw::Right];
138  }
140  double getMarginTop() const
141  {
142  return m_margins[libmwaw::Top];
143  }
145  double getMarginBottom() const
146  {
147  return m_margins[libmwaw::Bottom];
148  }
150  double getPageLength() const
151  {
153  }
155  double getPageWidth() const
156  {
158  }
161  {
162  return m_backgroundColor;
163  }
164  int getPageNumber() const
165  {
166  return m_pageNumber;
167  }
168  int getPageSpan() const
169  {
170  return m_pageSpan;
171  }
172 
174  void setHeaderFooter(MWAWHeaderFooter const &headerFooter);
176  void setFormLength(const double formLength)
177  {
178  m_formLength = formLength;
179  }
181  void setFormWidth(const double formWidth)
182  {
183  m_formWidth = formWidth;
184  }
186  void setFormOrientation(const FormOrientation formOrientation)
187  {
188  m_formOrientation = formOrientation;
189  }
191  void setMarginLeft(const double marginLeft)
192  {
193  m_margins[libmwaw::Left] = (marginLeft >= 0) ? marginLeft : 0.01;
194  }
196  void setMarginRight(const double marginRight)
197  {
198  m_margins[libmwaw::Right] = (marginRight >= 0) ? marginRight : 0.01;
199  }
201  void setMarginTop(const double marginTop)
202  {
203  m_margins[libmwaw::Top] =(marginTop >= 0) ? marginTop : 0.01;
204  }
206  void setMarginBottom(const double marginBottom)
207  {
208  m_margins[libmwaw::Bottom] = (marginBottom >= 0) ? marginBottom : 0.01;
209  }
212  {
213  if (margin < 0.0) margin = 0.01;
214  if (wh&libmwaw::LeftBit)
215  m_margins[libmwaw::Left]=margin;
216  if (wh&libmwaw::RightBit)
217  m_margins[libmwaw::Right]=margin;
218  if (wh&libmwaw::TopBit)
219  m_margins[libmwaw::Top]=margin;
220  if (wh&libmwaw::BottomBit)
221  m_margins[libmwaw::Bottom]=margin;
222  }
224  void checkMargins();
226  void setPageName(librevenge::RVNGString const &name)
227  {
228  m_name=name;
229  }
231  bool hasPageName() const
232  {
233  return !m_name.empty();
234  }
236  librevenge::RVNGString const &getPageName() const
237  {
238  return m_name;
239  }
241  void setMasterPageName(librevenge::RVNGString const &name)
242  {
243  m_masterName=name;
244  }
246  bool hasMasterPageName() const
247  {
248  return !m_masterName.empty();
249  }
251  librevenge::RVNGString const &getMasterPageName() const
252  {
253  return m_masterName;
254  }
257  {
258  m_backgroundColor=color;
259  }
261  void setPageNumber(const int pageNumber)
262  {
263  m_pageNumber = pageNumber;
264  }
266  void setPageSpan(const int pageSpan)
267  {
268  m_pageSpan = pageSpan;
269  }
271  bool operator==(std::shared_ptr<MWAWPageSpan> const &pageSpan) const;
273  bool operator!=(std::shared_ptr<MWAWPageSpan> const &pageSpan) const
274  {
275  return !operator==(pageSpan);
276  }
277 
278  // interface with MWAWListener
280  void getPageProperty(librevenge::RVNGPropertyList &pList, bool isPresentation=false) const;
282  void sendHeaderFooters(MWAWListener *listener) const;
284  void sendHeaderFooters(MWAWListener *listener, MWAWHeaderFooter::Occurrence occurrence) const;
285 
286 protected:
293 private:
296  double m_margins[4];
298  librevenge::RVNGString m_name;
300  librevenge::RVNGString m_masterName;
306  std::vector<MWAWHeaderFooter> m_headerFooterList;
311 };
312 
313 #endif
314 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void sendHeaderFooters(MWAWListener *listener) const
send the page&#39;s headers/footers if some exists
Definition: MWAWPageSpan.cxx:283
double getPageLength() const
returns the page length (form width without margin )
Definition: MWAWPageSpan.hxx:150
PageNumberPosition
a fixed page number position
Definition: MWAWPageSpan.hxx:52
double m_formWidth
the form width
Definition: MWAWPageSpan.hxx:294
double getFormLength() const
returns the page length
Definition: MWAWPageSpan.hxx:115
FormOrientation getFormOrientation() const
returns the page orientation
Definition: MWAWPageSpan.hxx:125
double getFormWidth() const
returns the page width
Definition: MWAWPageSpan.hxx:120
NumberingType
Definition: libmwaw_internal.hxx:180
double m_height
the height ( if known )
Definition: MWAWPageSpan.hxx:83
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:206
Definition: MWAWPageSpan.hxx:48
Definition: MWAWPageSpan.hxx:104
Definition: MWAWPageSpan.hxx:50
Definition: MWAWPageSpan.hxx:48
double getMarginBottom() const
returns the bottom margin
Definition: MWAWPageSpan.hxx:145
Occurrence
the header/footer occurrence in the file
Definition: MWAWPageSpan.hxx:50
Definition: libmwaw_internal.hxx:178
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:266
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:97
int m_pageNumber
the page number ( or -1)
Definition: MWAWPageSpan.hxx:308
bool operator==(MWAWHeaderFooter const &headerFooter) const
operator==
Definition: MWAWPageSpan.cxx:112
void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
remove a header footer
Definition: MWAWPageSpan.cxx:380
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:201
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:250
int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
return the header footer positions in m_headerFooterList
Definition: MWAWPageSpan.cxx:394
bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
return true if we have a header footer in this position
Definition: MWAWPageSpan.cxx:387
bool isDefined() const
returns true if the header footer is defined
Definition: MWAWPageSpan.hxx:61
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWPageSpan.hxx:155
librevenge::RVNGString const & getPageName() const
return the page name
Definition: MWAWPageSpan.hxx:236
Definition: MWAWPageSpan.hxx:104
Type
the header/footer type
Definition: MWAWPageSpan.hxx:48
librevenge::RVNGString m_masterName
the page master name
Definition: MWAWPageSpan.hxx:300
int getPageSpan() const
Definition: MWAWPageSpan.hxx:168
PageNumberPosition
a fixed page number position
Definition: MWAWPageSpan.hxx:103
Definition: libmwaw_internal.hxx:176
void checkMargins()
check if the page margins are consistent with the page dimension, if not update them ...
Definition: MWAWPageSpan.cxx:271
FormOrientation
the page orientation
Definition: MWAWPageSpan.hxx:101
bool operator!=(std::shared_ptr< MWAWPageSpan > const &pageSpan) const
operator!=
Definition: MWAWPageSpan.hxx:273
Definition: libmwaw_internal.hxx:176
void send(MWAWListener *listener) const
send to header to the listener
Definition: MWAWPageSpan.cxx:135
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:196
Definition: libmwaw_internal.hxx:176
Definition: MWAWPageSpan.hxx:50
MWAWFont m_pageNumberFont
the page numbering font
Definition: MWAWPageSpan.hxx:89
the class to store a color
Definition: libmwaw_internal.hxx:192
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:211
Definition: libmwaw_internal.hxx:176
bool hasMasterPageName() const
return true if the masterPage has a name
Definition: MWAWPageSpan.hxx:246
Definition: MWAWPageSpan.hxx:52
Class to store font.
Definition: MWAWFont.hxx:43
MWAWPageSpan & operator=(MWAWPageSpan const &)=default
MWAWColor backgroundColor() const
returns the background color
Definition: MWAWPageSpan.hxx:160
Occurrence m_occurrence
the actual occurrence
Definition: MWAWPageSpan.hxx:81
Definition: MWAWPageSpan.hxx:52
std::shared_ptr< MWAWHeaderFooter > MWAWHeaderFooterPtr
Definition: MWAWPageSpan.hxx:94
Definition: MWAWPageSpan.hxx:103
bool operator!=(MWAWHeaderFooter const &headerFooter) const
operator!=
Definition: MWAWPageSpan.hxx:70
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:181
MWAWHeaderFooter(Type const type=UNDEF, Occurrence const occurrence=NEVER)
constructor
Definition: MWAWPageSpan.cxx:97
MWAWPageSpan()
constructor
Definition: MWAWPageSpan.cxx:209
Definition: MWAWPageSpan.hxx:101
Definition: MWAWPageSpan.hxx:50
librevenge::RVNGString const & getMasterPageName() const
return the page master name
Definition: MWAWPageSpan.hxx:251
void setPageName(librevenge::RVNGString const &name)
set the page name
Definition: MWAWPageSpan.hxx:226
void insertPageNumberParagraph(MWAWListener *listener) const
insert a page number
Definition: MWAWPageSpan.cxx:175
Definition: MWAWPageSpan.hxx:52
Definition: MWAWPageSpan.hxx:103
Definition: libmwaw_internal.hxx:178
Definition: MWAWPageSpan.hxx:101
int getPageNumber() const
Definition: MWAWPageSpan.hxx:164
void setFormOrientation(const FormOrientation formOrientation)
set the form orientation
Definition: MWAWPageSpan.hxx:186
Definition: libmwaw_internal.hxx:178
libmwaw::NumberingType m_pageNumberType
the page numbering type
Definition: MWAWPageSpan.hxx:87
~MWAWPageSpan()
destructor
Definition: MWAWPageSpan.cxx:223
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition: MWAWPageSpan.cxx:227
bool operator==(std::shared_ptr< MWAWPageSpan > const &pageSpan) const
operator==
Definition: MWAWPageSpan.cxx:339
Definition: MWAWPageSpan.hxx:103
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:191
MWAWHeaderFooter & operator=(MWAWHeaderFooter const &)=default
double m_formLength
the form length
Definition: MWAWPageSpan.hxx:294
std::vector< MWAWHeaderFooter > m_headerFooterList
the list of header
Definition: MWAWPageSpan.hxx:306
double m_margins[4]
the margins: libmwaw::Left, ...
Definition: MWAWPageSpan.hxx:296
MWAWColor m_backgroundColor
the page background color: default white
Definition: MWAWPageSpan.hxx:304
void getPageProperty(librevenge::RVNGPropertyList &pList, bool isPresentation=false) const
add the page properties in pList
Definition: MWAWPageSpan.cxx:310
Definition: MWAWPageSpan.hxx:48
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:44
Definition: MWAWPageSpan.hxx:103
Definition: MWAWPageSpan.hxx:52
Definition: MWAWPageSpan.hxx:52
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:49
void setPageNumber(const int pageNumber)
set the page number
Definition: MWAWPageSpan.hxx:261
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:563
Definition: MWAWPageSpan.hxx:50
FormOrientation m_formOrientation
the form orientation
Definition: MWAWPageSpan.hxx:302
void setMasterPageName(librevenge::RVNGString const &name)
set the page master name
Definition: MWAWPageSpan.hxx:241
int m_pageSpan
the number of page
Definition: MWAWPageSpan.hxx:310
PageNumberPosition m_pageNumberPosition
the page number position ( or none)
Definition: MWAWPageSpan.hxx:85
Definition: MWAWPageSpan.hxx:52
double getMarginLeft() const
returns the left margin
Definition: MWAWPageSpan.hxx:130
MWAWSubDocumentPtr m_subDocument
the document data
Definition: MWAWPageSpan.hxx:91
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:176
Type m_type
the type header/footer
Definition: MWAWPageSpan.hxx:79
Definition: libmwaw_internal.hxx:178
double getMarginTop() const
returns the top margin
Definition: MWAWPageSpan.hxx:140
~MWAWHeaderFooter()
destructor
Definition: MWAWPageSpan.cxx:108
bool hasPageName() const
return true if the page has a name
Definition: MWAWPageSpan.hxx:231
Definition: MWAWPageSpan.hxx:52
Definition: MWAWPageSpan.hxx:104
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition: MWAWPageSpan.hxx:256
double getMarginRight() const
returns the right margin
Definition: MWAWPageSpan.hxx:135
librevenge::RVNGString m_name
the page name
Definition: MWAWPageSpan.hxx:298

Generated on Mon Oct 12 2020 05:19:39 for libmwaw by doxygen 1.8.14