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  * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
00004  * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
00005  * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00020  *
00021  * For further information visit http://libwpd.sourceforge.net
00022  */
00023 
00024 /* "This product is not manufactured, approved, or supported by
00025  * Corel Corporation or Corel Corporation Limited."
00026  */
00027 
00028 #ifndef WPSPAGESPAN_H
00029 #define WPSPAGESPAN_H
00030 #include <vector>
00031 #include "libwps_internal.h"
00032 
00033 class WPXPropertyList;
00034 class WPXDocumentProperty;
00035 class WPSContentListener;
00036 
00037 class WPSSubDocument;
00038 typedef shared_ptr<WPSSubDocument> WPSSubDocumentPtr;
00039 
00040 namespace WPSPageSpanInternal
00041 {
00042 class HeaderFooter;
00043 typedef shared_ptr<HeaderFooter> HeaderFooterPtr;
00044 }
00045 
00046 class WPSPageSpan
00047 {
00048         friend class WPSContentListener;
00049 public:
00050         enum FormOrientation { PORTRAIT, LANDSCAPE };
00051 
00052         enum HeaderFooterType { HEADER, FOOTER };
00053         enum HeaderFooterOccurence { ODD, EVEN, ALL, NEVER };
00054 
00055         enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, TopLeftAndRight, TopInsideLeftAndRight,
00056                                   BottomLeft, BottomCenter, BottomRight, BottomLeftAndRight, BottomInsideLeftAndRight
00057                                 };
00058 public:
00059         WPSPageSpan();
00060         WPSPageSpan(const WPSPageSpan &page);
00061         virtual ~WPSPageSpan();
00062 
00063         double getFormLength() const
00064         {
00065                 return m_formLength;
00066         }
00067         double getFormWidth() const
00068         {
00069                 return m_formWidth;
00070         }
00071         FormOrientation getFormOrientation() const
00072         {
00073                 return m_formOrientation;
00074         }
00075         double getMarginLeft() const
00076         {
00077                 return m_marginLeft;
00078         }
00079         double getMarginRight() const
00080         {
00081                 return m_marginRight;
00082         }
00083         double getMarginTop() const
00084         {
00085                 return m_marginTop;
00086         }
00087         double getMarginBottom() const
00088         {
00089                 return m_marginBottom;
00090         }
00091         PageNumberPosition getPageNumberPosition() const
00092         {
00093                 return m_pageNumberPosition;
00094         }
00095         int getPageNumber() const
00096         {
00097                 return m_pageNumber;
00098         }
00099         libwps::NumberingType getPageNumberingType() const
00100         {
00101                 return m_pageNumberingType;
00102         }
00103         double getPageNumberingFontSize() const
00104         {
00105                 return m_pageNumberingFontSize;
00106         }
00107         WPXString getPageNumberingFontName() const
00108         {
00109                 return m_pageNumberingFontName;
00110         }
00111         int getPageSpan() const
00112         {
00113                 return m_pageSpan;
00114         }
00115         const std::vector<WPSPageSpanInternal::HeaderFooterPtr> & getHeaderFooterList() const
00116         {
00117                 return m_headerFooterList;
00118         }
00119 
00120         void setHeaderFooter(const HeaderFooterType type, const HeaderFooterOccurence occurence,
00121                              WPSSubDocumentPtr &subDocument);
00122         void setFormLength(const double formLength)
00123         {
00124                 m_formLength = formLength;
00125         }
00126         void setFormWidth(const double formWidth)
00127         {
00128                 m_formWidth = formWidth;
00129         }
00130         void setFormOrientation(const FormOrientation formOrientation)
00131         {
00132                 m_formOrientation = formOrientation;
00133         }
00134         void setMarginLeft(const double marginLeft)
00135         {
00136                 m_marginLeft = marginLeft;
00137         }
00138         void setMarginRight(const double marginRight)
00139         {
00140                 m_marginRight = marginRight;
00141         }
00142         void setMarginTop(const double marginTop)
00143         {
00144                 m_marginTop = marginTop;
00145         }
00146         void setMarginBottom(const double marginBottom)
00147         {
00148                 m_marginBottom = marginBottom;
00149         }
00150         void setPageNumberPosition(const PageNumberPosition pageNumberPosition)
00151         {
00152                 m_pageNumberPosition = pageNumberPosition;
00153         }
00154         void setPageNumber(const int pageNumber)
00155         {
00156                 m_pageNumber = pageNumber;
00157         }
00158         void setPageNumberingType(const libwps::NumberingType pageNumberingType)
00159         {
00160                 m_pageNumberingType = pageNumberingType;
00161         }
00162         void setPageNumberingFontSize(const double pageNumberingFontSize)
00163         {
00164                 m_pageNumberingFontSize = pageNumberingFontSize;
00165         }
00166         void setPageNumberingFontName(const WPXString &pageNumberingFontName)
00167         {
00168                 m_pageNumberingFontName = pageNumberingFontName;
00169         }
00170         void setPageSpan(const int pageSpan)
00171         {
00172                 m_pageSpan = pageSpan;
00173         }
00174 
00175         bool operator==(shared_ptr<WPSPageSpan> const &pageSpan) const;
00176         bool operator!=(shared_ptr<WPSPageSpan> const &pageSpan) const
00177         {
00178                 return !operator==(pageSpan);
00179         }
00180 protected:
00181         // interface with WPSContentListener
00182         void getPageProperty(WPXPropertyList &pList) const;
00183         void sendHeaderFooters(WPSContentListener *listener,
00184                                WPXDocumentInterface *documentInterface);
00185 
00186 protected:
00187 
00188         int _getHeaderFooterPosition(HeaderFooterType type, HeaderFooterOccurence occurence);
00189         void _setHeaderFooter(HeaderFooterType type, HeaderFooterOccurence occurence, WPSSubDocumentPtr &doc);
00190         void _removeHeaderFooter(HeaderFooterType type, HeaderFooterOccurence occurence);
00191         bool _containsHeaderFooter(HeaderFooterType type, HeaderFooterOccurence occurence);
00192 
00193         void _insertPageNumberParagraph(WPXDocumentInterface *documentInterface);
00194 private:
00195         double m_formLength, m_formWidth;
00196         FormOrientation m_formOrientation;
00197         double m_marginLeft, m_marginRight;
00198         double m_marginTop, m_marginBottom;
00199         PageNumberPosition m_pageNumberPosition;
00200         int m_pageNumber;
00201         libwps::NumberingType m_pageNumberingType;
00202         WPXString m_pageNumberingFontName;
00203         double m_pageNumberingFontSize;
00204         std::vector<WPSPageSpanInternal::HeaderFooterPtr> m_headerFooterList;
00205 
00206         int m_pageSpan;
00207 };
00208 
00209 #endif
00210 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */