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 
46 
48 typedef shared_ptr<MWAWSubDocument> MWAWSubDocumentPtr;
49 
52 {
53 public:
55  enum Type { HEADER, FOOTER, UNDEF };
57  enum Occurence { ODD, EVEN, ALL, NEVER };
60 
62  MWAWHeaderFooter(Type const type=UNDEF, Occurence const occurence=NEVER);
66  bool isDefined() const {
67  return m_type != UNDEF;
68  }
70  void send(MWAWContentListener *listener) const;
72  bool operator==(MWAWHeaderFooter const &headerFooter) const;
74  bool operator!=(MWAWHeaderFooter const &headerFooter) const {
75  return !operator==(headerFooter);
76  }
78  void insertPageNumberParagraph(MWAWContentListener *listener) const;
79 
80 public:
86  double m_height;
95 };
96 
97 typedef shared_ptr<MWAWHeaderFooter> MWAWHeaderFooterPtr;
98 
101 {
102  friend class MWAWContentListener;
103 public:
109  };
110 public:
112  MWAWPageSpan();
114  virtual ~MWAWPageSpan();
115 
117  double getFormLength() const {
118  return m_formLength;
119  }
121  double getFormWidth() const {
122  return m_formWidth;
123  }
126  return m_formOrientation;
127  }
129  double getMarginLeft() const {
130  return m_margins[libmwaw::Left];
131  }
133  double getMarginRight() const {
134  return m_margins[libmwaw::Right];
135  }
137  double getMarginTop() const {
138  return m_margins[libmwaw::Top];
139  }
141  double getMarginBottom() const {
142  return m_margins[libmwaw::Bottom];
143  }
145  double getPageLength() const {
147  }
149  double getPageWidth() const {
151  }
154  return m_backgroundColor;
155  }
156  int getPageNumber() const {
157  return m_pageNumber;
158  }
159  int getPageSpan() const {
160  return m_pageSpan;
161  }
162 
164  void setHeaderFooter(MWAWHeaderFooter const &headerFooter);
166  void setFormLength(const double formLength) {
167  m_formLength = formLength;
168  }
170  void setFormWidth(const double formWidth) {
171  m_formWidth = formWidth;
172  }
174  void setFormOrientation(const FormOrientation formOrientation) {
175  m_formOrientation = formOrientation;
176  }
178  void setMarginLeft(const double marginLeft) {
179  m_margins[libmwaw::Left] = (marginLeft > 0) ? marginLeft : 0.01;
180  }
182  void setMarginRight(const double marginRight) {
183  m_margins[libmwaw::Right] = (marginRight > 0) ? marginRight : 0.01;
184  }
186  void setMarginTop(const double marginTop) {
187  m_margins[libmwaw::Top] =(marginTop > 0) ? marginTop : 0.01;
188  }
190  void setMarginBottom(const double marginBottom) {
191  m_margins[libmwaw::Bottom] = (marginBottom > 0) ? marginBottom : 0.01;
192  }
195  if (margin <= 0.0) margin = 0.01;
196  if (wh&libmwaw::LeftBit)
197  m_margins[libmwaw::Left]=margin;
198  if (wh&libmwaw::RightBit)
199  m_margins[libmwaw::Right]=margin;
200  if (wh&libmwaw::TopBit)
201  m_margins[libmwaw::Top]=margin;
202  if (wh&libmwaw::BottomBit)
203  m_margins[libmwaw::Bottom]=margin;
204  }
206  void checkMargins();
209  m_backgroundColor=color;
210  }
212  void setPageNumber(const int pageNumber) {
213  m_pageNumber = pageNumber;
214  }
216  void setPageSpan(const int pageSpan) {
217  m_pageSpan = pageSpan;
218  }
220  bool operator==(shared_ptr<MWAWPageSpan> const &pageSpan) const;
222  bool operator!=(shared_ptr<MWAWPageSpan> const &pageSpan) const {
223  return !operator==(pageSpan);
224  }
225 protected:
226  // interface with MWAWContentListener
228  void getPageProperty(WPXPropertyList &pList) const;
230  void sendHeaderFooters(MWAWContentListener *listener) const;
231 
232 protected:
239 private:
244  double m_margins[4];
250  std::vector<MWAWHeaderFooter> m_headerFooterList;
253 };
254 
255 #endif
256 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
bool operator!=(MWAWHeaderFooter const &headerFooter) const
operator!=
Definition: MWAWPageSpan.hxx:74
Occurence m_occurence
the actual occurence
Definition: MWAWPageSpan.hxx:84
PageNumberPosition
a fixed page number position
Definition: MWAWPageSpan.hxx:59
double m_formWidth
the form width
Definition: MWAWPageSpan.hxx:240
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
Definition: MSK4Zone.hxx:47
NumberingType
Definition: libmwaw_internal.hxx:154
int getPageSpan() const
Definition: MWAWPageSpan.hxx:159
double m_height
the height ( if known )
Definition: MWAWPageSpan.hxx:86
Occurence
the header/footer occurence in the file
Definition: MWAWPageSpan.hxx:57
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:190
Definition: MWAWPageSpan.hxx:55
Definition: MWAWPageSpan.hxx:108
Definition: MWAWPageSpan.hxx:55
Definition: libmwaw_internal.hxx:152
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:216
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:100
int m_pageNumber
the page number ( or -1)
Definition: MWAWPageSpan.hxx:248
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:186
int getPageNumber() const
Definition: MWAWPageSpan.hxx:156
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:179
MWAWHeaderFooter(Type const type=UNDEF, Occurence const occurence=NEVER)
constructor
Definition: MWAWPageSpan.cxx:98
Definition: MWAWPageSpan.hxx:108
Type
the header/footer type
Definition: MWAWPageSpan.hxx:55
double getMarginLeft() const
returns the left margin
Definition: MWAWPageSpan.hxx:129
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:107
Definition: libmwaw_internal.hxx:150
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:105
Definition: libmwaw_internal.hxx:150
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:182
Definition: libmwaw_internal.hxx:150
MWAWFont m_pageNumberFont
the page numbering font
Definition: MWAWPageSpan.hxx:92
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:161
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:194
void insertPageNumberParagraph(MWAWContentListener *listener) const
insert a page number
Definition: MWAWPageSpan.cxx:170
MWAWColor backgroundColor() const
returns the background color
Definition: MWAWPageSpan.hxx:153
Definition: libmwaw_internal.hxx:150
double getPageLength() const
returns the page length (form width without margin )
Definition: MWAWPageSpan.hxx:145
double getMarginRight() const
returns the right margin
Definition: MWAWPageSpan.hxx:133
Definition: MWAWPageSpan.hxx:59
Class to store font.
Definition: MWAWFont.hxx:47
Definition: MWAWPageSpan.hxx:59
FormOrientation getFormOrientation() const
returns the page orientation
Definition: MWAWPageSpan.hxx:125
double getFormWidth() const
returns the page width
Definition: MWAWPageSpan.hxx:121
Definition: MWAWPageSpan.hxx:57
Definition: MWAWPageSpan.hxx:107
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:170
bool operator==(shared_ptr< MWAWPageSpan > const &pageSpan) const
operator==
Definition: MWAWPageSpan.cxx:301
MWAWPageSpan()
constructor
Definition: MWAWPageSpan.cxx:202
Definition: MWAWPageSpan.hxx:105
abstract class used to store a subdocument (with a comparison function)
Definition: MWAWSubDocument.hxx:49
Definition: MWAWPageSpan.hxx:57
Definition: MWAWPageSpan.hxx:59
Definition: MWAWPageSpan.hxx:107
int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence)
return the header footer positions in m_headerFooterList
Definition: MWAWPageSpan.cxx:355
Definition: libmwaw_internal.hxx:152
shared_ptr< MWAWHeaderFooter > MWAWHeaderFooterPtr
Definition: MWAWPageSpan.hxx:97
double getFormLength() const
returns the page length
Definition: MWAWPageSpan.hxx:117
Definition: MWAWPageSpan.hxx:105
bool isDefined() const
returns true if the header footer is defined
Definition: MWAWPageSpan.hxx:66
bool operator!=(shared_ptr< MWAWPageSpan > const &pageSpan) const
operator!=
Definition: MWAWPageSpan.hxx:222
void setFormOrientation(const FormOrientation formOrientation)
set the form orientation
Definition: MWAWPageSpan.hxx:174
Definition: MWAWPageSpan.hxx:57
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:137
Definition: libmwaw_internal.hxx:152
libmwaw::NumberingType m_pageNumberType
the page numbering type
Definition: MWAWPageSpan.hxx:90
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:107
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:178
double m_formLength
the form length
Definition: MWAWPageSpan.hxx:240
std::vector< MWAWHeaderFooter > m_headerFooterList
the list of header
Definition: MWAWPageSpan.hxx:250
double m_margins[4]
the margins: libmwaw::Left, ...
Definition: MWAWPageSpan.hxx:244
MWAWColor m_backgroundColor
the page background color: default white
Definition: MWAWPageSpan.hxx:246
Definition: MWAWPageSpan.hxx:55
Definition: MWAWPageSpan.hxx:57
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:51
Definition: MWAWPageSpan.hxx:107
Definition: MWAWPageSpan.hxx:59
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWPageSpan.hxx:149
Definition: MWAWPageSpan.hxx:59
void setPageNumber(const int pageNumber)
set the page number
Definition: MWAWPageSpan.hxx:212
FormOrientation m_formOrientation
the form orientation
Definition: MWAWPageSpan.hxx:242
int m_pageSpan
the number of page
Definition: MWAWPageSpan.hxx:252
PageNumberPosition m_pageNumberPosition
the page number position ( or none)
Definition: MWAWPageSpan.hxx:88
Definition: MWAWPageSpan.hxx:59
void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence)
remove a header footer
Definition: MWAWPageSpan.cxx:341
Definition: MWAWContentListener.hxx:68
MWAWSubDocumentPtr m_subDocument
the document data
Definition: MWAWPageSpan.hxx:94
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:166
Type m_type
the type header/footer
Definition: MWAWPageSpan.hxx:82
Definition: libmwaw_internal.hxx:152
~MWAWHeaderFooter()
destructor
Definition: MWAWPageSpan.cxx:105
double getMarginBottom() const
returns the bottom margin
Definition: MWAWPageSpan.hxx:141
Definition: MWAWPageSpan.hxx:59
Definition: MWAWPageSpan.hxx:108
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition: MWAWPageSpan.hxx:208

Generated for libmwaw by doxygen 1.8.5