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:

Generated on Wed May 22 2013 18:12:38 for libmwaw by doxygen 1.8.1.2