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 MWAWHeaderFooter
{
public:
enum Type { HEADER, FOOTER, UNDEF };
enum Occurrence { ODD, EVEN, ALL, NEVER };
enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight };
explicit MWAWHeaderFooter(Type const type=UNDEF, Occurrence const occurrence=NEVER);
MWAWHeaderFooter(MWAWHeaderFooter const &)=default;
MWAWHeaderFooter &operator=(MWAWHeaderFooter const &)=default;
MWAWHeaderFooter &operator=(MWAWHeaderFooter &&)=default;
~MWAWHeaderFooter();
bool isDefined() const
{
return m_type != UNDEF;
}
void send(MWAWListener *listener) const;
bool operator==(MWAWHeaderFooter const &headerFooter) const;
bool operator!=(MWAWHeaderFooter const &headerFooter) const
{
return !operator==(headerFooter);
}
void insertPageNumberParagraph(MWAWListener *listener) const;
public:
Type m_type;
Occurrence m_occurrence;
double m_height;
PageNumberPosition m_pageNumberPosition;
libmwaw::NumberingType m_pageNumberType;
MWAWFont m_pageNumberFont;
MWAWSubDocumentPtr m_subDocument;
};
typedef std::shared_ptr<MWAWHeaderFooter> MWAWHeaderFooterPtr;
class MWAWPageSpan
{
public:
enum FormOrientation { PORTRAIT, LANDSCAPE };
enum PageNumberPosition { None = 0, TopLeft, TopCenter, TopRight,
BottomLeft, BottomCenter, BottomRight
};
public:
MWAWPageSpan();
MWAWPageSpan(MWAWPageSpan const &)=default;
MWAWPageSpan &operator=(MWAWPageSpan const &)=default;
MWAWPageSpan &operator=(MWAWPageSpan &&)=default;
~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 setPageName(librevenge::RVNGString const &name)
{
m_name=name;
}
bool hasPageName() const
{
return !m_name.empty();
}
librevenge::RVNGString const &getPageName() const
{
return m_name;
}
void setMasterPageName(librevenge::RVNGString const &name)
{
m_masterName=name;
}
bool hasMasterPageName() const
{
return !m_masterName.empty();
}
librevenge::RVNGString const &getMasterPageName() const
{
return m_masterName;
}
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==(std::shared_ptr<MWAWPageSpan> const &pageSpan) const;
bool operator!=(std::shared_ptr<MWAWPageSpan> const &pageSpan) const
{
return !operator==(pageSpan);
}
// interface with MWAWListener
void getPageProperty(librevenge::RVNGPropertyList &pList, bool isPresentation=false) const;
void sendHeaderFooters(MWAWListener *listener) const;
void sendHeaderFooters(MWAWListener *listener, MWAWHeaderFooter::Occurrence occurrence) const;
protected:
int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence);
void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence);
bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence);
private:
double m_formLength, m_formWidth ;
double m_margins[4];
librevenge::RVNGString m_name;
librevenge::RVNGString m_masterName;
FormOrientation m_formOrientation;
MWAWColor m_backgroundColor;
std::vector<MWAWHeaderFooter> m_headerFooterList;
int m_pageNumber;
int m_pageSpan;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWFont.hxx
MWAWHeaderFooterPtr
std::shared_ptr< MWAWHeaderFooter > MWAWHeaderFooterPtr
Definition MWAWPageSpan.hxx:95
MWAWFont
Class to store font.
Definition MWAWFont.hxx:44
MWAWListener
This class contains a virtual interface to all listener.
Definition MWAWListener.hxx:50
MWAWPageSpan::backgroundColor
MWAWColor backgroundColor() const
returns the background color
Definition MWAWPageSpan.hxx:162
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition MWAWPageSpan.hxx:268
MWAWPageSpan::setMarginTop
void setMarginTop(const double marginTop)
set the page top margin
Definition MWAWPageSpan.hxx:203
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition MWAWPageSpan.hxx:208
MWAWPageSpan::containsHeaderFooter
bool containsHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
return true if we have a header footer in this position
Definition MWAWPageSpan.cxx:387
MWAWPageSpan::hasMasterPageName
bool hasMasterPageName() const
return true if the masterPage has a name
Definition MWAWPageSpan.hxx:248
MWAWPageSpan::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition MWAWPageSpan.hxx:157
MWAWPageSpan::getPageProperty
void getPageProperty(librevenge::RVNGPropertyList &pList, bool isPresentation=false) const
add the page properties in pList
Definition MWAWPageSpan.cxx:310
MWAWPageSpan::operator=
MWAWPageSpan & operator=(MWAWPageSpan const &)=default
MWAWPageSpan::operator==
bool operator==(std::shared_ptr< MWAWPageSpan > const &pageSpan) const
operator==
Definition MWAWPageSpan.cxx:339
MWAWPageSpan::FormOrientation
FormOrientation
the page orientation
Definition MWAWPageSpan.hxx:102
MWAWPageSpan::LANDSCAPE
@ LANDSCAPE
Definition MWAWPageSpan.hxx:102
MWAWPageSpan::PORTRAIT
@ PORTRAIT
Definition MWAWPageSpan.hxx:102
MWAWPageSpan::hasPageName
bool hasPageName() const
return true if the page has a name
Definition MWAWPageSpan.hxx:233
MWAWPageSpan::MWAWPageSpan
MWAWPageSpan(MWAWPageSpan const &)=default
MWAWPageSpan::m_margins
double m_margins[4]
the margins: libmwaw::Left, ...
Definition MWAWPageSpan.hxx:298
MWAWPageSpan::PageNumberPosition
PageNumberPosition
a fixed page number position
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::TopCenter
@ TopCenter
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::BottomRight
@ BottomRight
Definition MWAWPageSpan.hxx:105
MWAWPageSpan::BottomLeft
@ BottomLeft
Definition MWAWPageSpan.hxx:105
MWAWPageSpan::BottomCenter
@ BottomCenter
Definition MWAWPageSpan.hxx:105
MWAWPageSpan::TopRight
@ TopRight
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::None
@ None
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::TopLeft
@ TopLeft
Definition MWAWPageSpan.hxx:104
MWAWPageSpan::getPageNumber
int getPageNumber() const
Definition MWAWPageSpan.hxx:166
MWAWPageSpan::m_pageNumber
int m_pageNumber
the page number ( or -1)
Definition MWAWPageSpan.hxx:310
MWAWPageSpan::getPageLength
double getPageLength() const
returns the page length (form width without margin )
Definition MWAWPageSpan.hxx:152
MWAWPageSpan::getMasterPageName
librevenge::RVNGString const & getMasterPageName() const
return the page master name
Definition MWAWPageSpan.hxx:253
MWAWPageSpan::getFormWidth
double getFormWidth() const
returns the page width
Definition MWAWPageSpan.hxx:122
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition MWAWPageSpan.hxx:183
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition MWAWPageSpan.hxx:198
MWAWPageSpan::getMarginTop
double getMarginTop() const
returns the top margin
Definition MWAWPageSpan.hxx:142
MWAWPageSpan::setBackgroundColor
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition MWAWPageSpan.hxx:258
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition MWAWPageSpan.hxx:193
MWAWPageSpan::MWAWPageSpan
MWAWPageSpan()
constructor
Definition MWAWPageSpan.cxx:209
MWAWPageSpan::m_pageSpan
int m_pageSpan
the number of page
Definition MWAWPageSpan.hxx:312
MWAWPageSpan::m_formWidth
double m_formWidth
the form width
Definition MWAWPageSpan.hxx:296
MWAWPageSpan::m_formLength
double m_formLength
the form length
Definition MWAWPageSpan.hxx:296
MWAWPageSpan::setMasterPageName
void setMasterPageName(librevenge::RVNGString const &name)
set the page master name
Definition MWAWPageSpan.hxx:243
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition MWAWPageSpan.hxx:178
MWAWPageSpan::m_masterName
librevenge::RVNGString m_masterName
the page master name
Definition MWAWPageSpan.hxx:302
MWAWPageSpan::getMarginLeft
double getMarginLeft() const
returns the left margin
Definition MWAWPageSpan.hxx:132
MWAWPageSpan::removeHeaderFooter
void removeHeaderFooter(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
remove a header footer
Definition MWAWPageSpan.cxx:380
MWAWPageSpan::m_backgroundColor
MWAWColor m_backgroundColor
the page background color: default white
Definition MWAWPageSpan.hxx:306
MWAWPageSpan::sendHeaderFooters
void sendHeaderFooters(MWAWListener *listener) const
send the page's headers/footers if some exists
Definition MWAWPageSpan.cxx:283
MWAWPageSpan::getFormLength
double getFormLength() const
returns the page length
Definition MWAWPageSpan.hxx:117
MWAWPageSpan::m_name
librevenge::RVNGString m_name
the page name
Definition MWAWPageSpan.hxx:300
MWAWPageSpan::getHeaderFooterPosition
int getHeaderFooterPosition(MWAWHeaderFooter::Type type, MWAWHeaderFooter::Occurrence occurrence)
return the header footer positions in m_headerFooterList
Definition MWAWPageSpan.cxx:394
MWAWPageSpan::checkMargins
void checkMargins()
check if the page margins are consistent with the page dimension, if not update them
Definition MWAWPageSpan.cxx:271
MWAWPageSpan::m_formOrientation
FormOrientation m_formOrientation
the form orientation
Definition MWAWPageSpan.hxx:304
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition MWAWPageSpan.hxx:213
MWAWPageSpan::getFormOrientation
FormOrientation getFormOrientation() const
returns the page orientation
Definition MWAWPageSpan.hxx:127
MWAWPageSpan::m_headerFooterList
std::vector< MWAWHeaderFooter > m_headerFooterList
the list of header
Definition MWAWPageSpan.hxx:308
MWAWPageSpan::operator!=
bool operator!=(std::shared_ptr< MWAWPageSpan > const &pageSpan) const
operator!=
Definition MWAWPageSpan.hxx:275
MWAWPageSpan::~MWAWPageSpan
~MWAWPageSpan()
destructor
Definition MWAWPageSpan.cxx:223
MWAWPageSpan::operator=
MWAWPageSpan & operator=(MWAWPageSpan &&)=default
MWAWPageSpan::getPageSpan
int getPageSpan() const
Definition MWAWPageSpan.hxx:170
MWAWPageSpan::getMarginBottom
double getMarginBottom() const
returns the bottom margin
Definition MWAWPageSpan.hxx:147
MWAWPageSpan::setPageName
void setPageName(librevenge::RVNGString const &name)
set the page name
Definition MWAWPageSpan.hxx:228
MWAWPageSpan::setHeaderFooter
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition MWAWPageSpan.cxx:227
MWAWPageSpan::getPageName
librevenge::RVNGString const & getPageName() const
return the page name
Definition MWAWPageSpan.hxx:238
MWAWPageSpan::setFormOrientation
void setFormOrientation(const FormOrientation formOrientation)
set the form orientation
Definition MWAWPageSpan.hxx:188
MWAWPageSpan::getMarginRight
double getMarginRight() const
returns the right margin
Definition MWAWPageSpan.hxx:137
MWAWPageSpan::setPageNumber
void setPageNumber(const int pageNumber)
set the page number
Definition MWAWPageSpan.hxx:263
libmwaw_internal.hxx
MWAWSubDocumentPtr
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition libmwaw_internal.hxx:565
libmwaw::LeftBit
@ LeftBit
Definition libmwaw_internal.hxx:178
libmwaw::BottomBit
@ BottomBit
Definition libmwaw_internal.hxx:178
libmwaw::TopBit
@ TopBit
Definition libmwaw_internal.hxx:178
libmwaw::RightBit
@ RightBit
Definition libmwaw_internal.hxx:178
libmwaw::NumberingType
NumberingType
Definition libmwaw_internal.hxx:180
libmwaw::Top
@ Top
Definition libmwaw_internal.hxx:176
libmwaw::Bottom
@ Bottom
Definition libmwaw_internal.hxx:176
libmwaw::Left
@ Left
Definition libmwaw_internal.hxx:176
libmwaw::Right
@ Right
Definition libmwaw_internal.hxx:176
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192
MWAWColor::white
static MWAWColor white()
return the white color
Definition libmwaw_internal.hxx:250