Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef MWAWPAGESPAN_H
00035 #define MWAWPAGESPAN_H
00036
00037 #include <vector>
00038
00039 #include "libmwaw_internal.hxx"
00040
00041 #include "MWAWFont.hxx"
00042
00043 class WPXPropertyList;
00044
00046 class MWAWHeaderFooter
00047 {
00048 public:
00050 enum Type { HEADER, FOOTER, UNDEF };
00052 enum Occurence { ODD, EVEN, ALL, NEVER };
00054 enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight };
00055
00057 MWAWHeaderFooter(Type const type=UNDEF, Occurence const occurence=NEVER);
00059 ~MWAWHeaderFooter();
00061 bool isDefined() const {
00062 return m_type != UNDEF;
00063 }
00065 void send(MWAWContentListener *listener) const;
00067 bool operator==(MWAWHeaderFooter const &headerFooter) const;
00069 bool operator!=(MWAWHeaderFooter const &headerFooter) const {
00070 return !operator==(headerFooter);
00071 }
00073 void insertPageNumberParagraph(MWAWContentListener *listener) const;
00074
00075 public:
00077 Type m_type;
00079 Occurence m_occurence;
00081 double m_height;
00083 PageNumberPosition m_pageNumberPosition;
00085 libmwaw::NumberingType m_pageNumberType;
00087 MWAWFont m_pageNumberFont;
00089 MWAWSubDocumentPtr m_subDocument;
00090 };
00091
00092 typedef shared_ptr<MWAWHeaderFooter> MWAWHeaderFooterPtr;
00093
00095 class MWAWPageSpan
00096 {
00097 friend class MWAWContentListener;
00098 public:
00100 enum FormOrientation { PORTRAIT, LANDSCAPE };
00102 enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight,
00103 BottomLeft, BottomCenter, BottomRight
00104 };
00105 public:
00107 MWAWPageSpan();
00109 virtual ~MWAWPageSpan();
00110
00112 double getFormLength() const {
00113 return m_formLength;
00114 }
00116 double getFormWidth() const {
00117 return m_formWidth;
00118 }
00120 FormOrientation getFormOrientation() const {
00121 return m_formOrientation;
00122 }
00124 double getMarginLeft() const {
00125 return m_margins[libmwaw::Left];
00126 }
00128 double getMarginRight() const {
00129 return m_margins[libmwaw::Right];
00130 }
00132 double getMarginTop() const {
00133 return m_margins[libmwaw::Top];
00134 }
00136 double getMarginBottom() const {
00137 return m_margins[libmwaw::Bottom];
00138 }
00140 double getPageLength() const {
00141 return m_formLength-m_margins[libmwaw::Top]-m_margins[libmwaw::Bottom];
00142 }
00144 double getPageWidth() const {
00145 return m_formWidth-m_margins[libmwaw::Left]-m_margins[libmwaw::Right];
00146 }
00148 MWAWColor backgroundColor() const {
00149 return m_backgroundColor;
00150 }
00151 int getPageNumber() const {
00152 return m_pageNumber;
00153 }
00154 int getPageSpan() const {
00155 return m_pageSpan;
00156 }
00157
00159 void setHeaderFooter(MWAWHeaderFooter const &headerFooter);
00161 void setFormLength(const double formLength) {
00162 m_formLength = formLength;
00163 }
00165 void setFormWidth(const double formWidth) {
00166 m_formWidth = formWidth;
00167 }
00169 void setFormOrientation(const FormOrientation formOrientation) {
00170 m_formOrientation = formOrientation;
00171 }
00173 void setMarginLeft(const double marginLeft) {
00174 m_margins[libmwaw::Left] = (marginLeft > 0) ? marginLeft : 0.01;
00175 }
00177 void setMarginRight(const double marginRight) {
00178 m_margins[libmwaw::Right] = (marginRight > 0) ? marginRight : 0.01;
00179 }
00181 void setMarginTop(const double marginTop) {
00182 m_margins[libmwaw::Top] =(marginTop > 0) ? marginTop : 0.01;
00183 }
00185 void setMarginBottom(const double marginBottom) {
00186 m_margins[libmwaw::Bottom] = (marginBottom > 0) ? marginBottom : 0.01;
00187 }
00189 void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit) {
00190 if (margin <= 0.0) margin = 0.01;
00191 if (wh&libmwaw::LeftBit)
00192 m_margins[libmwaw::Left]=margin;
00193 if (wh&libmwaw::RightBit)
00194 m_margins[libmwaw::Right]=margin;
00195 if (wh&libmwaw::TopBit)
00196 m_margins[libmwaw::Top]=margin;
00197 if (wh&libmwaw::BottomBit)
00198 m_margins[libmwaw::Bottom]=margin;
00199 }
00201 void checkMargins();
00203 void setBackgroundColor(MWAWColor color=MWAWColor::white()) {
00204 m_backgroundColor=color;
00205 }
00207 void setPageNumber(const int pageNumber) {
00208 m_pageNumber = pageNumber;
00209 }
00211 void setPageSpan(const int pageSpan) {
00212 m_pageSpan = pageSpan;
00213 }
00215 bool operator==(shared_ptr<MWAWPageSpan> const &pageSpan) const;
00217 bool operator!=(shared_ptr<MWAWPageSpan> const &pageSpan) const {
00218 return !operator==(pageSpan);
00219 }
00220 protected:
00221
00223 void getPageProperty(WPXPropertyList &pList) const;
00225 void sendHeaderFooters(MWAWContentListener *listener) const;
00226
00227 protected:
00229 int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence);
00231 void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence);
00233 bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence);
00234 private:
00235 double m_formLength, m_formWidth ;
00237 FormOrientation m_formOrientation;
00239 double m_margins[4];
00241 MWAWColor m_backgroundColor;
00243 int m_pageNumber;
00245 std::vector<MWAWHeaderFooter> m_headerFooterList;
00247 int m_pageSpan;
00248 };
00249
00250 #endif
00251