MWAWPageSpan.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
#ifndef MWAWPAGESPAN_H
#define MWAWPAGESPAN_H
#include <vector>
#include "libmwaw_internal.hxx"
#include "MWAWFont.hxx"
class WPXPropertyList;
class MWAWHeaderFooter
{
public:
enum Type { HEADER, FOOTER, UNDEF };
enum Occurence { ODD, EVEN, ALL, NEVER };
enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight };
MWAWHeaderFooter(Type const type=UNDEF, Occurence const occurence=NEVER);
~MWAWHeaderFooter();
bool isDefined() const {
return m_type != UNDEF;
}
void send(MWAWContentListener *listener) const;
bool operator==(MWAWHeaderFooter const &headerFooter) const;
bool operator!=(MWAWHeaderFooter const &headerFooter) const {
return !operator==(headerFooter);
}
void insertPageNumberParagraph(MWAWContentListener *listener) const;
public:
Type m_type;
Occurence m_occurence;
double m_height;
PageNumberPosition m_pageNumberPosition;
libmwaw::NumberingType m_pageNumberType;
MWAWFont m_pageNumberFont;
MWAWSubDocumentPtr m_subDocument;
};
typedef shared_ptr<MWAWHeaderFooter> MWAWHeaderFooterPtr;
class MWAWPageSpan
{
friend class MWAWContentListener;
public:
enum FormOrientation { PORTRAIT, LANDSCAPE };
enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight,
BottomLeft, BottomCenter, BottomRight
};
public:
MWAWPageSpan();
virtual ~MWAWPageSpan();
double getFormLength() const {
return m_formLength;
}
double getFormWidth() const {
return m_formWidth;
}
FormOrientation getFormOrientation() const {
return m_formOrientation;
}
double getMarginLeft() const {
return m_margins[libmwaw::Left];
}
double getMarginRight() const {
return m_margins[libmwaw::Right];
}
double getMarginTop() const {
return m_margins[libmwaw::Top];
}
double getMarginBottom() const {
return m_margins[libmwaw::Bottom];
}
double getPageLength() const {
return m_formLength-m_margins[libmwaw::Top]-m_margins[libmwaw::Bottom];
}
double getPageWidth() const {
return m_formWidth-m_margins[libmwaw::Left]-m_margins[libmwaw::Right];
}
MWAWColor backgroundColor() const {
return m_backgroundColor;
}
int getPageNumber() const {
return m_pageNumber;
}
int getPageSpan() const {
return m_pageSpan;
}
void setHeaderFooter(MWAWHeaderFooter const &headerFooter);
void setFormLength(const double formLength) {
m_formLength = formLength;
}
void setFormWidth(const double formWidth) {
m_formWidth = formWidth;
}
void setFormOrientation(const FormOrientation formOrientation) {
m_formOrientation = formOrientation;
}
void setMarginLeft(const double marginLeft) {
m_margins[libmwaw::Left] = (marginLeft > 0) ? marginLeft : 0.01;
}
void setMarginRight(const double marginRight) {
m_margins[libmwaw::Right] = (marginRight > 0) ? marginRight : 0.01;
}
void setMarginTop(const double marginTop) {
m_margins[libmwaw::Top] =(marginTop > 0) ? marginTop : 0.01;
}
void setMarginBottom(const double marginBottom) {
m_margins[libmwaw::Bottom] = (marginBottom > 0) ? marginBottom : 0.01;
}
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit) {
if (margin <= 0.0) margin = 0.01;
if (wh&libmwaw::LeftBit)
m_margins[libmwaw::Left]=margin;
if (wh&libmwaw::RightBit)
m_margins[libmwaw::Right]=margin;
if (wh&libmwaw::TopBit)
m_margins[libmwaw::Top]=margin;
if (wh&libmwaw::BottomBit)
m_margins[libmwaw::Bottom]=margin;
}
void checkMargins();
void setBackgroundColor(MWAWColor color=MWAWColor::white()) {
m_backgroundColor=color;
}
void setPageNumber(const int pageNumber) {
m_pageNumber = pageNumber;
}
void setPageSpan(const int pageSpan) {
m_pageSpan = pageSpan;
}
bool operator==(shared_ptr<MWAWPageSpan> const &pageSpan) const;
bool operator!=(shared_ptr<MWAWPageSpan> const &pageSpan) const {
return !operator==(pageSpan);
}
protected:
// interface with MWAWContentListener
void getPageProperty(WPXPropertyList &pList) const;
void sendHeaderFooters(MWAWContentListener *listener) const;
protected:
int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence);
void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence);
bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence);
private:
double m_formLength, m_formWidth ;
FormOrientation m_formOrientation;
double m_margins[4];
MWAWColor m_backgroundColor;
int m_pageNumber;
std::vector<MWAWHeaderFooter> m_headerFooterList;
int m_pageSpan;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWPageSpan::m_formWidth
double m_formWidth
the form width
Definition: MWAWPageSpan.hxx:235
libmwaw::NumberingType
NumberingType
Definition: libmwaw_internal.hxx:154
MWAWPageSpan::getPageSpan
int getPageSpan() const
Definition: MWAWPageSpan.hxx:154
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:185
MWAWPageSpan::BottomLeft
Definition: MWAWPageSpan.hxx:103
libmwaw::TopBit
Definition: libmwaw_internal.hxx:152
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:211
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
MWAWPageSpan::m_pageNumber
int m_pageNumber
the page number ( or -1)
Definition: MWAWPageSpan.hxx:243
libmwaw_internal.hxx
MWAWPageSpan::setMarginTop
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:181
MWAWPageSpan::getPageNumber
int getPageNumber() const
Definition: MWAWPageSpan.hxx:151
MWAWColor::white
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:179
MWAWPageSpan::BottomRight
Definition: MWAWPageSpan.hxx:103
MWAWPageSpan::getMarginLeft
double getMarginLeft() const
returns the left margin
Definition: MWAWPageSpan.hxx:124
MWAWPageSpan::containsHeaderFooter
bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence)
return true if we have a header footer in this position
Definition: MWAWPageSpan.cxx:348
MWAWPageSpan::PageNumberPosition
PageNumberPosition
a fixed page number position
Definition: MWAWPageSpan.hxx:102
libmwaw::Bottom
Definition: libmwaw_internal.hxx:150
MWAWPageSpan::checkMargins
void checkMargins()
check if the page margins are consistent with the page dimension, if not update them ...
Definition: MWAWPageSpan.cxx:256
MWAWPageSpan::FormOrientation
FormOrientation
the page orientation
Definition: MWAWPageSpan.hxx:100
libmwaw::Top
Definition: libmwaw_internal.hxx:150
MWAWPageSpan::sendHeaderFooters
void sendHeaderFooters(MWAWContentListener *listener) const
send the page's headers/footers if some exists
Definition: MWAWPageSpan.cxx:268
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:177
libmwaw::Right
Definition: libmwaw_internal.hxx:150
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:161
MWAWSubDocumentPtr
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:344
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:189
MWAWPageSpan::backgroundColor
MWAWColor backgroundColor() const
returns the background color
Definition: MWAWPageSpan.hxx:148
libmwaw::Left
Definition: libmwaw_internal.hxx:150
MWAWPageSpan::getPageLength
double getPageLength() const
returns the page length (form width without margin )
Definition: MWAWPageSpan.hxx:140
MWAWPageSpan::getMarginRight
double getMarginRight() const
returns the right margin
Definition: MWAWPageSpan.hxx:128
MWAWPageSpan::getFormOrientation
FormOrientation getFormOrientation() const
returns the page orientation
Definition: MWAWPageSpan.hxx:120
MWAWPageSpan::getFormWidth
double getFormWidth() const
returns the page width
Definition: MWAWPageSpan.hxx:116
MWAWPageSpan::TopCenter
Definition: MWAWPageSpan.hxx:102
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:165
MWAWPageSpan::operator==
bool operator==(shared_ptr< MWAWPageSpan > const &pageSpan) const
operator==
Definition: MWAWPageSpan.cxx:301
MWAWPageSpan::MWAWPageSpan
MWAWPageSpan()
constructor
Definition: MWAWPageSpan.cxx:202
MWAWPageSpan::PORTRAIT
Definition: MWAWPageSpan.hxx:100
MWAWPageSpan::TopLeft
Definition: MWAWPageSpan.hxx:102
MWAWPageSpan::getHeaderFooterPosition
int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence)
return the header footer positions in m_headerFooterList
Definition: MWAWPageSpan.cxx:355
libmwaw::BottomBit
Definition: libmwaw_internal.hxx:152
MWAWHeaderFooterPtr
shared_ptr< MWAWHeaderFooter > MWAWHeaderFooterPtr
Definition: MWAWPageSpan.hxx:92
MWAWPageSpan::getFormLength
double getFormLength() const
returns the page length
Definition: MWAWPageSpan.hxx:112
MWAWPageSpan::LANDSCAPE
Definition: MWAWPageSpan.hxx:100
MWAWPageSpan::operator!=
bool operator!=(shared_ptr< MWAWPageSpan > const &pageSpan) const
operator!=
Definition: MWAWPageSpan.hxx:217
MWAWPageSpan::setFormOrientation
void setFormOrientation(const FormOrientation formOrientation)
set the form orientation
Definition: MWAWPageSpan.hxx:169
MWAWPageSpan::getPageProperty
void getPageProperty(WPXPropertyList &pList) const
add the page properties in pList
Definition: MWAWPageSpan.cxx:282
MWAWPageSpan::getMarginTop
double getMarginTop() const
returns the top margin
Definition: MWAWPageSpan.hxx:132
libmwaw::RightBit
Definition: libmwaw_internal.hxx:152
MWAWPageSpan::~MWAWPageSpan
virtual ~MWAWPageSpan()
destructor
Definition: MWAWPageSpan.cxx:212
MWAWPageSpan::setHeaderFooter
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition: MWAWPageSpan.cxx:216
MWAWPageSpan::None
Definition: MWAWPageSpan.hxx:102
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:173
MWAWPageSpan::m_formLength
double m_formLength
the form length
Definition: MWAWPageSpan.hxx:235
MWAWPageSpan::m_headerFooterList
std::vector< MWAWHeaderFooter > m_headerFooterList
the list of header
Definition: MWAWPageSpan.hxx:245
MWAWPageSpan::m_margins
double m_margins[4]
the margins: libmwaw::Left, ...
Definition: MWAWPageSpan.hxx:239
MWAWPageSpan::m_backgroundColor
MWAWColor m_backgroundColor
the page background color: default white
Definition: MWAWPageSpan.hxx:241
MWAWPageSpan::TopRight
Definition: MWAWPageSpan.hxx:102
MWAWPageSpan::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWPageSpan.hxx:144
MWAWPageSpan::setPageNumber
void setPageNumber(const int pageNumber)
set the page number
Definition: MWAWPageSpan.hxx:207
MWAWPageSpan::m_formOrientation
FormOrientation m_formOrientation
the form orientation
Definition: MWAWPageSpan.hxx:237
MWAWPageSpan::m_pageSpan
int m_pageSpan
the number of page
Definition: MWAWPageSpan.hxx:247
MWAWPageSpan::removeHeaderFooter
void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurence occurence)
remove a header footer
Definition: MWAWPageSpan.cxx:341
MWAWContentListener
Definition: MWAWContentListener.hxx:52
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:161
libmwaw::LeftBit
Definition: libmwaw_internal.hxx:152
MWAWPageSpan::getMarginBottom
double getMarginBottom() const
returns the bottom margin
Definition: MWAWPageSpan.hxx:136
MWAWPageSpan::BottomCenter
Definition: MWAWPageSpan.hxx:103
MWAWPageSpan::setBackgroundColor
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition: MWAWPageSpan.hxx:203