WPSPageSpan.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwps
00003  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Major Contributor(s):
00010  * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
00011  * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
00012  * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00013  *
00014  * For minor contributions see the git repository.
00015  *
00016  * Alternatively, the contents of this file may be used under the terms
00017  * of the GNU Lesser General Public License Version 2.1 or later
00018  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00019  * applicable instead of those above.
00020  *
00021  * For further information visit http://libwps.sourceforge.net
00022  */
00023 
00024 #ifndef WPSPAGESPAN_H
00025 #define WPSPAGESPAN_H
00026 #include <vector>
00027 #include "libwps_internal.h"
00028 
00029 class WKSContentListener;
00030 class WPSContentListener;
00031 
00032 namespace WPSPageSpanInternal
00033 {
00034 class HeaderFooter;
00035 typedef shared_ptr<HeaderFooter> HeaderFooterPtr;
00036 }
00037 
00038 class WPSPageSpan
00039 {
00040 public:
00041         enum FormOrientation { PORTRAIT, LANDSCAPE };
00042 
00043         enum HeaderFooterType { HEADER, FOOTER };
00044         enum HeaderFooterOccurrence { ODD, EVEN, ALL, NEVER };
00045 
00046         enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, TopLeftAndRight, TopInsideLeftAndRight,
00047                                   BottomLeft, BottomCenter, BottomRight, BottomLeftAndRight, BottomInsideLeftAndRight
00048                                 };
00049 public:
00050         WPSPageSpan();
00051         virtual ~WPSPageSpan();
00052 
00053         double getFormLength() const
00054         {
00055                 return m_formLength;
00056         }
00057         double getFormWidth() const
00058         {
00059                 return m_formWidth;
00060         }
00061         FormOrientation getFormOrientation() const
00062         {
00063                 return m_formOrientation;
00064         }
00065         double getMarginLeft() const
00066         {
00067                 return m_marginLeft;
00068         }
00069         double getMarginRight() const
00070         {
00071                 return m_marginRight;
00072         }
00073         double getMarginTop() const
00074         {
00075                 return m_marginTop;
00076         }
00077         double getMarginBottom() const
00078         {
00079                 return m_marginBottom;
00080         }
00081         PageNumberPosition getPageNumberPosition() const
00082         {
00083                 return m_pageNumberPosition;
00084         }
00085         int getPageNumber() const
00086         {
00087                 return m_pageNumber;
00088         }
00089         libwps::NumberingType getPageNumberingType() const
00090         {
00091                 return m_pageNumberingType;
00092         }
00093         double getPageNumberingFontSize() const
00094         {
00095                 return m_pageNumberingFontSize;
00096         }
00097         librevenge::RVNGString getPageNumberingFontName() const
00098         {
00099                 return m_pageNumberingFontName;
00100         }
00101         int getPageSpan() const
00102         {
00103                 return m_pageSpan;
00104         }
00105         const std::vector<WPSPageSpanInternal::HeaderFooterPtr> &getHeaderFooterList() const
00106         {
00107                 return m_headerFooterList;
00108         }
00109 
00110         void setHeaderFooter(const HeaderFooterType type, const HeaderFooterOccurrence occurrence,
00111                              WPSSubDocumentPtr &subDocument);
00112         void setFormLength(const double formLength)
00113         {
00114                 m_formLength = formLength;
00115         }
00116         void setFormWidth(const double formWidth)
00117         {
00118                 m_formWidth = formWidth;
00119         }
00120         void setFormOrientation(const FormOrientation formOrientation)
00121         {
00122                 m_formOrientation = formOrientation;
00123         }
00124         void setMarginLeft(const double marginLeft)
00125         {
00126                 m_marginLeft = marginLeft;
00127         }
00128         void setMarginRight(const double marginRight)
00129         {
00130                 m_marginRight = marginRight;
00131         }
00132         void setMarginTop(const double marginTop)
00133         {
00134                 m_marginTop = marginTop;
00135         }
00136         void setMarginBottom(const double marginBottom)
00137         {
00138                 m_marginBottom = marginBottom;
00139         }
00140         void setPageNumberPosition(const PageNumberPosition pageNumberPosition)
00141         {
00142                 m_pageNumberPosition = pageNumberPosition;
00143         }
00144         void setPageNumber(const int pageNumber)
00145         {
00146                 m_pageNumber = pageNumber;
00147         }
00148         void setPageNumberingType(const libwps::NumberingType pageNumberingType)
00149         {
00150                 m_pageNumberingType = pageNumberingType;
00151         }
00152         void setPageNumberingFontSize(const double pageNumberingFontSize)
00153         {
00154                 m_pageNumberingFontSize = pageNumberingFontSize;
00155         }
00156         void setPageNumberingFontName(const librevenge::RVNGString &pageNumberingFontName)
00157         {
00158                 m_pageNumberingFontName = pageNumberingFontName;
00159         }
00160         void setPageSpan(const int pageSpan)
00161         {
00162                 m_pageSpan = pageSpan;
00163         }
00164 
00165         bool operator==(shared_ptr<WPSPageSpan> const &pageSpan) const;
00166         bool operator!=(shared_ptr<WPSPageSpan> const &pageSpan) const
00167         {
00168                 return !operator==(pageSpan);
00169         }
00170 
00171         // interface with the listeners
00172         void getPageProperty(librevenge::RVNGPropertyList &pList) const;
00173         void sendHeaderFooters(WPSContentListener *listener, librevenge::RVNGTextInterface *documentInterface);
00174         void sendHeaderFooters(WKSContentListener *listener, librevenge::RVNGSpreadsheetInterface *documentInterface);
00175 
00176 protected:
00177 
00178         int _getHeaderFooterPosition(HeaderFooterType type, HeaderFooterOccurrence occurrence);
00179         void _setHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence, WPSSubDocumentPtr &doc);
00180         void _removeHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence);
00181         bool _containsHeaderFooter(HeaderFooterType type, HeaderFooterOccurrence occurrence);
00182 
00183         void _insertPageNumberParagraph(librevenge::RVNGTextInterface *documentInterface);
00184 private:
00185         double m_formLength, m_formWidth;
00186         FormOrientation m_formOrientation;
00187         double m_marginLeft, m_marginRight;
00188         double m_marginTop, m_marginBottom;
00189         PageNumberPosition m_pageNumberPosition;
00190         int m_pageNumber;
00191         libwps::NumberingType m_pageNumberingType;
00192         librevenge::RVNGString m_pageNumberingFontName;
00193         double m_pageNumberingFontSize;
00194         std::vector<WPSPageSpanInternal::HeaderFooterPtr> m_headerFooterList;
00195 
00196         int m_pageSpan;
00197 };
00198 
00199 #endif
00200 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */