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 
43 class WPXPropertyList;
44 
47 {
48 public:
50  enum Type { HEADER, FOOTER, UNDEF };
52  enum Occurence { ODD, EVEN, ALL, NEVER };
55 
57  MWAWHeaderFooter(Type const type=UNDEF, Occurence const occurence=NEVER);
61  bool isDefined() const {
62  return m_type != UNDEF;
63  }
65  void send(MWAWContentListener *listener) const;
67  bool operator==(MWAWHeaderFooter const &headerFooter) const;
69  bool operator!=(MWAWHeaderFooter const &headerFooter) const {
70  return !operator==(headerFooter);
71  }
73  void insertPageNumberParagraph(MWAWContentListener *listener) const;
74 
75 public:
81  double m_height;
87  MWAWFont m_pageNumberFont;
90 };
91 
92 typedef shared_ptr<MWAWHeaderFooter> MWAWHeaderFooterPtr;
93 
96 {
97  friend class MWAWContentListener;
98 public:
104  };
105 public:
107  MWAWPageSpan();
109  virtual ~MWAWPageSpan();
110 
112  double getFormLength() const {
113  return m_formLength;
114  }
116  double getFormWidth() const {
117  return m_formWidth;
118  }
121  return m_formOrientation;
122  }
124  double getMarginLeft() const {
125  return m_margins[libmwaw::Left];
126  }
128  double getMarginRight() const {
129  return m_margins[libmwaw::Right];
130  }
132  double getMarginTop() const {
133  return m_margins[libmwaw::Top];
134  }
136  double getMarginBottom() const {
137  return m_margins[libmwaw::Bottom];
138  }
140  double getPageLength() const {
142  }
144  double getPageWidth() const {
146  }
149  return m_backgroundColor;
150  }
151  int getPageNumber() const {
152  return m_pageNumber;
153  }
154  int getPageSpan() const {
155  return m_pageSpan;
156  }
157 
159  void setHeaderFooter(MWAWHeaderFooter const &headerFooter);
161  void setFormLength(const double formLength) {
162  m_formLength = formLength;
163  }
165  void setFormWidth(const double formWidth) {
166  m_formWidth = formWidth;
167  }
169  void setFormOrientation(const FormOrientation formOrientation) {
170  m_formOrientation = formOrientation;
171  }
173  void setMarginLeft(const double marginLeft) {
174  m_margins[libmwaw::Left] = (marginLeft > 0) ? marginLeft : 0.01;
175  }
177  void setMarginRight(const double marginRight) {
178  m_margins[libmwaw::Right] = (marginRight > 0) ? marginRight : 0.01;
179  }
181  void setMarginTop(const double marginTop) {
182  m_margins[libmwaw::Top] =(marginTop > 0) ? marginTop : 0.01;
183  }
185  void setMarginBottom(const double marginBottom) {
186  m_margins[libmwaw::Bottom] = (marginBottom > 0) ? marginBottom : 0.01;
187  }
190  if (margin <= 0.0) margin = 0.01;
191  if (wh&libmwaw::LeftBit)
192  m_margins[libmwaw::Left]=margin;
193  if (wh&libmwaw::RightBit)
194  m_margins[libmwaw::Right]=margin;
195  if (wh&libmwaw::TopBit)
196  m_margins[libmwaw::Top]=margin;
197  if (wh&libmwaw::BottomBit)
198  m_margins[libmwaw::Bottom]=margin;
199  }
201  void checkMargins();
204  m_backgroundColor=color;
205  }
207  void setPageNumber(const int pageNumber) {
208  m_pageNumber = pageNumber;
209  }
211  void setPageSpan(const int pageSpan) {
212  m_pageSpan = pageSpan;
213  }
215  bool operator==(shared_ptr<MWAWPageSpan> const &pageSpan) const;
217  bool operator!=(shared_ptr<MWAWPageSpan> const &pageSpan) const {
218  return !operator==(pageSpan);
219  }
220 protected:
221  // interface with MWAWContentListener
223  void getPageProperty(WPXPropertyList &pList) const;
225  void sendHeaderFooters(MWAWContentListener *listener) const;
226 
227 protected:
234 private:
239  double m_margins[4];
245  std::vector<MWAWHeaderFooter> m_headerFooterList;
248 };
249 
250 #endif
251 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
bool operator!=(MWAWHeaderFooter const &headerFooter) const
operator!=
Definition: MWAWPageSpan.hxx:69
Occurence m_occurence
the actual occurence
Definition: MWAWPageSpan.hxx:79
PageNumberPosition
a fixed page number position
Definition: MWAWPageSpan.hxx:54
double m_formWidth
the form width
Definition: MWAWPageSpan.hxx:235
NumberingType
Definition: libmwaw_internal.hxx:159
int getPageSpan() const
Definition: MWAWPageSpan.hxx:154
double m_height
the height ( if known )
Definition: MWAWPageSpan.hxx:81
Occurence
the header/footer occurence in the file
Definition: MWAWPageSpan.hxx:52
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:185
Definition: MWAWPageSpan.hxx:50
Definition: MWAWPageSpan.hxx:103
Definition: MWAWPageSpan.hxx:50
Definition: libmwaw_internal.hxx:157
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:211
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
int m_pageNumber
the page number ( or -1)
Definition: MWAWPageSpan.hxx:243
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:181
int getPageNumber() const
Definition: MWAWPageSpan.hxx:151
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:184
MWAWHeaderFooter(Type const type=UNDEF, Occurence const occurence=NEVER)
constructor
Definition: MWAWPageSpan.cxx:98
Definition: MWAWPageSpan.hxx:103
Type
the header/footer type
Definition: MWAWPageSpan.hxx:50
double getMarginLeft() const
returns the left margin
Definition: MWAWPageSpan.hxx:124
bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence)
return true if we have a header footer in this position
Definition: MWAWPageSpan.cxx:348
PageNumberPosition
a fixed page number position
Definition: MWAWPageSpan.hxx:102
Definition: libmwaw_internal.hxx:155
void checkMargins()
check if the page margins are consistent with the page dimension, if not update them ...
Definition: MWAWPageSpan.cxx:256
FormOrientation
the page orientation
Definition: MWAWPageSpan.hxx:100
Definition: libmwaw_internal.hxx:155
void sendHeaderFooters(MWAWContentListener *listener) const
send the page&#39;s headers/footers if some exists
Definition: MWAWPageSpan.cxx:268
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:177
Definition: libmwaw_internal.hxx:155
MWAWFont m_pageNumberFont
the page numbering font
Definition: MWAWPageSpan.hxx:87
bool operator==(MWAWHeaderFooter const &headerFooter) const
operator==
Definition: MWAWPageSpan.cxx:109
void send(MWAWContentListener *listener) const
send to header to the listener
Definition: MWAWPageSpan.cxx:132
the class to store a color
Definition: libmwaw_internal.hxx:166
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:358
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:189
void insertPageNumberParagraph(MWAWContentListener *listener) const
insert a page number
Definition: MWAWPageSpan.cxx:170
MWAWColor backgroundColor() const
returns the background color
Definition: MWAWPageSpan.hxx:148
Definition: libmwaw_internal.hxx:155
double getPageLength() const
returns the page length (form width without margin )
Definition: MWAWPageSpan.hxx:140
double getMarginRight() const
returns the right margin
Definition: MWAWPageSpan.hxx:128
Definition: MWAWPageSpan.hxx:54
Definition: MWAWPageSpan.hxx:54
FormOrientation getFormOrientation() const
returns the page orientation
Definition: MWAWPageSpan.hxx:120
double getFormWidth() const
returns the page width
Definition: MWAWPageSpan.hxx:116
Definition: MWAWPageSpan.hxx:52
Definition: MWAWPageSpan.hxx:102
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:165
bool operator==(shared_ptr< MWAWPageSpan > const &pageSpan) const
operator==
Definition: MWAWPageSpan.cxx:301
MWAWPageSpan()
constructor
Definition: MWAWPageSpan.cxx:202
Definition: MWAWPageSpan.hxx:100
Definition: MWAWPageSpan.hxx:52
Definition: MWAWPageSpan.hxx:54
Definition: MWAWPageSpan.hxx:102
int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence)
return the header footer positions in m_headerFooterList
Definition: MWAWPageSpan.cxx:355
Definition: libmwaw_internal.hxx:157
shared_ptr< MWAWHeaderFooter > MWAWHeaderFooterPtr
Definition: MWAWPageSpan.hxx:92
double getFormLength() const
returns the page length
Definition: MWAWPageSpan.hxx:112
Definition: MWAWPageSpan.hxx:100
bool isDefined() const
returns true if the header footer is defined
Definition: MWAWPageSpan.hxx:61
bool operator!=(shared_ptr< MWAWPageSpan > const &pageSpan) const
operator!=
Definition: MWAWPageSpan.hxx:217
void setFormOrientation(const FormOrientation formOrientation)
set the form orientation
Definition: MWAWPageSpan.hxx:169
Definition: MWAWPageSpan.hxx:52
void getPageProperty(WPXPropertyList &pList) const
add the page properties in pList
Definition: MWAWPageSpan.cxx:282
double getMarginTop() const
returns the top margin
Definition: MWAWPageSpan.hxx:132
Definition: libmwaw_internal.hxx:157
libmwaw::NumberingType m_pageNumberType
the page numbering type
Definition: MWAWPageSpan.hxx:85
virtual ~MWAWPageSpan()
destructor
Definition: MWAWPageSpan.cxx:212
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition: MWAWPageSpan.cxx:216
Definition: MWAWPageSpan.hxx:102
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:173
double m_formLength
the form length
Definition: MWAWPageSpan.hxx:235
std::vector< MWAWHeaderFooter > m_headerFooterList
the list of header
Definition: MWAWPageSpan.hxx:245
double m_margins[4]
the margins: libmwaw::Left, ...
Definition: MWAWPageSpan.hxx:239
MWAWColor m_backgroundColor
the page background color: default white
Definition: MWAWPageSpan.hxx:241
Definition: MWAWPageSpan.hxx:50
Definition: MWAWPageSpan.hxx:52
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:46
Definition: MWAWPageSpan.hxx:102
Definition: MWAWPageSpan.hxx:54
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWPageSpan.hxx:144
Definition: MWAWPageSpan.hxx:54
void setPageNumber(const int pageNumber)
set the page number
Definition: MWAWPageSpan.hxx:207
FormOrientation m_formOrientation
the form orientation
Definition: MWAWPageSpan.hxx:237
int m_pageSpan
the number of page
Definition: MWAWPageSpan.hxx:247
PageNumberPosition m_pageNumberPosition
the page number position ( or none)
Definition: MWAWPageSpan.hxx:83
Definition: MWAWPageSpan.hxx:54
void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence)
remove a header footer
Definition: MWAWPageSpan.cxx:341
This class contents the main functions needed to create a Writer Document.
Definition: MWAWContentListener.hxx:57
MWAWSubDocumentPtr m_subDocument
the document data
Definition: MWAWPageSpan.hxx:89
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:161
Type m_type
the type header/footer
Definition: MWAWPageSpan.hxx:77
Definition: libmwaw_internal.hxx:157
~MWAWHeaderFooter()
destructor
Definition: MWAWPageSpan.cxx:105
double getMarginBottom() const
returns the bottom margin
Definition: MWAWPageSpan.hxx:136
Definition: MWAWPageSpan.hxx:54
Definition: MWAWPageSpan.hxx:103
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition: MWAWPageSpan.hxx:203

Generated on Tue Mar 10 2015 17:32:09 for libmwaw by doxygen 1.8.5