MWAWParagraph.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 MWAW_PARAGRAPH
# define MWAW_PARAGRAPH
#include <assert.h>
#include <iostream>
#include <vector>
#include <libwpd/libwpd.h>
#include "libmwaw_internal.hxx"
#include "MWAWList.hxx"
class WPXPropertyList;
class WPXPropertyListVector;
struct MWAWTabStop {
enum Alignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
MWAWTabStop(double position = 0.0, Alignment alignment = LEFT, uint16_t leaderCharacter='\0', uint16_t decimalCharacter = '.') :
m_position(position), m_alignment(alignment), m_leaderCharacter(leaderCharacter), m_decimalCharacter(decimalCharacter) {
}
void addTo(WPXPropertyListVector &propList, double decalX=0.0) const;
bool operator==(MWAWTabStop const &tabs) const {
return !operator!=(tabs);
}
bool operator!=(MWAWTabStop const &tabs) const {
return m_position < tabs.m_position || m_position > tabs.m_position ||
m_alignment != tabs.m_alignment ||
m_leaderCharacter != tabs.m_leaderCharacter ||
m_decimalCharacter != tabs.m_decimalCharacter;
}
friend std::ostream &operator<<(std::ostream &o, MWAWTabStop const &ft);
double m_position;
Alignment m_alignment;
uint16_t m_leaderCharacter;
uint16_t m_decimalCharacter;
};
class MWAWParagraph
{
public:
enum { NoBreakBit = 0x1, NoBreakWithNextBit=0x2 };
enum Justification { JustificationLeft, JustificationFull, JustificationCenter,
JustificationRight, JustificationFullAllLines
};
enum LineSpacingType { Fixed, AtLeast};
MWAWParagraph();
virtual ~MWAWParagraph();
bool operator==(MWAWParagraph const &p) const {
return !operator!=(p);
}
bool operator!=(MWAWParagraph const &p) const;
double getMarginsWidth() const;
bool hasBorders() const;
bool hasDifferentBorders() const;
void resizeBorders(size_t newSize) {
MWAWBorder empty;
empty.m_style=MWAWBorder::None;
m_borders.resize(newSize, empty);
}
void setInterline(double value, WPXUnit unit, LineSpacingType type=Fixed) {
m_spacings[0]=value;
m_spacingsInterlineUnit=unit;
m_spacingsInterlineType=type;
}
void addTo(WPXPropertyList &propList, bool inTable) const;
void addTabsTo(WPXPropertyListVector &propList, double decalX=0.0) const;
void insert(MWAWParagraph const &para);
friend std::ostream &operator<<(std::ostream &o, MWAWParagraph const &ft);
Variable<double> m_margins[3]; // 0: first line left, 1: left, 2: right
Variable<WPXUnit> m_marginsUnit;
Variable<double> m_spacings[3]; // 0: interline, 1: before, 2: after
Variable<WPXUnit> m_spacingsInterlineUnit;
Variable<LineSpacingType> m_spacingsInterlineType;
Variable<std::vector<MWAWTabStop> > m_tabs;
Variable<bool> m_tabsRelativeToLeftMargin;
Variable<Justification> m_justify;
Variable<int> m_breakStatus; // BITS: 1: unbreakable, 2: dont break after
Variable<int> m_listLevelIndex;
Variable<int> m_listId;
Variable<int> m_listStartValue;
Variable<MWAWListLevel> m_listLevel;
Variable<MWAWColor> m_backgroundColor;
std::vector<Variable<MWAWBorder> > m_borders;
std::string m_extra;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWParagraph::MWAWParagraph
MWAWParagraph()
constructor
Definition: MWAWParagraph.cxx:125
MWAWParagraph::AtLeast
Definition: MWAWParagraph.hxx:93
MWAWParagraph::JustificationCenter
Definition: MWAWParagraph.hxx:89
MWAWParagraph::m_tabs
Variable< std::vector< MWAWTabStop > > m_tabs
the tabulations
Definition: MWAWParagraph.hxx:152
MWAWParagraph::JustificationFull
Definition: MWAWParagraph.hxx:89
MWAWTabStop::RIGHT
Definition: MWAWParagraph.hxx:52
libmwaw_internal.hxx
MWAWTabStop::m_position
double m_position
the tab position
Definition: MWAWParagraph.hxx:73
MWAWTabStop::m_alignment
Alignment m_alignment
the alignement ( left, center, ...)
Definition: MWAWParagraph.hxx:75
MWAWTabStop::m_decimalCharacter
uint16_t m_decimalCharacter
the decimal char
Definition: MWAWParagraph.hxx:79
MWAWParagraph::m_margins
Variable< double > m_margins[3]
the margins
Definition: MWAWParagraph.hxx:138
MWAWParagraph::JustificationRight
Definition: MWAWParagraph.hxx:90
MWAWParagraph::insert
void insert(MWAWParagraph const &para)
insert the set values of para in the actual paragraph
Definition: MWAWParagraph.cxx:177
MWAWList.hxx
MWAWTabStop::operator==
bool operator==(MWAWTabStop const &tabs) const
operator==
Definition: MWAWParagraph.hxx:60
MWAWParagraph::operator!=
bool operator!=(MWAWParagraph const &p) const
operator!=
Definition: MWAWParagraph.cxx:142
MWAWParagraph::NoBreakBit
Definition: MWAWParagraph.hxx:87
MWAWParagraph::m_borders
std::vector< Variable< MWAWBorder > > m_borders
list of border ( order MWAWBorder::Pos)
Definition: MWAWParagraph.hxx:174
MWAWTabStop::CENTER
Definition: MWAWParagraph.hxx:52
MWAWTabStop::MWAWTabStop
MWAWTabStop(double position=0.0, Alignment alignment=LEFT, uint16_t leaderCharacter='\0', uint16_t decimalCharacter= '.')
constructor
Definition: MWAWParagraph.hxx:54
MWAWTabStop::m_leaderCharacter
uint16_t m_leaderCharacter
the leader char
Definition: MWAWParagraph.hxx:77
MWAWBorder
a border
Definition: libmwaw_internal.hxx:232
MWAWParagraph::Fixed
Definition: MWAWParagraph.hxx:93
MWAWParagraph::m_breakStatus
Variable< int > m_breakStatus
a list of bits: 0x1 (unbreakable), 0x2 (do not break after)
Definition: MWAWParagraph.hxx:159
MWAWTabStop::addTo
void addTo(WPXPropertyListVector &propList, double decalX=0.0) const
add a tab to the propList
Definition: MWAWParagraph.cxx:46
MWAWTabStop::Alignment
Alignment
the tab alignement
Definition: MWAWParagraph.hxx:52
MWAWParagraph::m_spacingsInterlineUnit
Variable< WPXUnit > m_spacingsInterlineUnit
the interline unit PERCENT or INCH, ...
Definition: MWAWParagraph.hxx:148
MWAWParagraph::m_tabsRelativeToLeftMargin
Variable< bool > m_tabsRelativeToLeftMargin
true if the tabs are relative to left margin, false if there are relative to the page margin (default...
Definition: MWAWParagraph.hxx:154
MWAWTabStop::DECIMAL
Definition: MWAWParagraph.hxx:52
MWAWParagraph::m_justify
Variable< Justification > m_justify
the justification
Definition: MWAWParagraph.hxx:157
MWAWParagraph::addTo
void addTo(WPXPropertyList &propList, bool inTable) const
add to the propList
Definition: MWAWParagraph.cxx:232
MWAWTabStop::operator!=
bool operator!=(MWAWTabStop const &tabs) const
operator!=
Definition: MWAWParagraph.hxx:64
MWAWTabStop::BAR
Definition: MWAWParagraph.hxx:52
MWAWParagraph::m_spacings
Variable< double > m_spacings[3]
the line spacing
Definition: MWAWParagraph.hxx:146
MWAWParagraph::addTabsTo
void addTabsTo(WPXPropertyListVector &propList, double decalX=0.0) const
add tabs to the propList
Definition: MWAWParagraph.cxx:331
MWAWBorder::None
Definition: libmwaw_internal.hxx:234
MWAWParagraph::resizeBorders
void resizeBorders(size_t newSize)
a function used to resize the borders list ( adding empty borders if needed )
Definition: MWAWParagraph.hxx:112
MWAWParagraph::m_listLevelIndex
Variable< int > m_listLevelIndex
the actual level index
Definition: MWAWParagraph.hxx:162
MWAWTabStop
class to store a tab use by MWAWParagraph
Definition: MWAWParagraph.hxx:50
MWAWParagraph::m_extra
std::string m_extra
a string to store some errors
Definition: MWAWParagraph.hxx:177
MWAWParagraph::m_marginsUnit
Variable< WPXUnit > m_marginsUnit
the margins INCH, ...
Definition: MWAWParagraph.hxx:140
MWAWParagraph::JustificationFullAllLines
Definition: MWAWParagraph.hxx:90
MWAWParagraph::LineSpacingType
LineSpacingType
the line spacing type: fixed or at least
Definition: MWAWParagraph.hxx:93
MWAWBorder::m_style
Style m_style
the border style
Definition: libmwaw_internal.hxx:265
MWAWTabStop::LEFT
Definition: MWAWParagraph.hxx:52
MWAWParagraph::hasBorders
bool hasBorders() const
check if the paragraph has some borders
Definition: MWAWParagraph.cxx:202
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:83
MWAWParagraph::m_spacingsInterlineType
Variable< LineSpacingType > m_spacingsInterlineType
the interline type: fixed, atLeast, ...
Definition: MWAWParagraph.hxx:150
MWAWParagraph::m_backgroundColor
Variable< MWAWColor > m_backgroundColor
the background color
Definition: MWAWParagraph.hxx:171
MWAWParagraph::m_listStartValue
Variable< int > m_listStartValue
the list start value (if set )
Definition: MWAWParagraph.hxx:166
MWAWTabStop::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWTabStop const &ft)
operator <<
Definition: MWAWParagraph.cxx:91
MWAWParagraph::getMarginsWidth
double getMarginsWidth() const
return the paragraph margin width (in inches)
Definition: MWAWParagraph.cxx:226
MWAWParagraph::operator==
bool operator==(MWAWParagraph const &p) const
operator==
Definition: MWAWParagraph.hxx:100
MWAWParagraph::operator<<
friend std::ostream & operator<<(std::ostream &o, MWAWParagraph const &ft)
operator <<
Definition: MWAWParagraph.cxx:342
MWAWParagraph::m_listLevel
Variable< MWAWListLevel > m_listLevel
the actual level
Definition: MWAWParagraph.hxx:168
MWAWParagraph::Justification
Justification
an enum used to defined the paragraph justification: left, center, right, full ...
Definition: MWAWParagraph.hxx:89
Variable< double >
MWAWParagraph::~MWAWParagraph
virtual ~MWAWParagraph()
destructor
Definition: MWAWParagraph.cxx:138
MWAWParagraph::NoBreakWithNextBit
Definition: MWAWParagraph.hxx:87
MWAWParagraph::JustificationLeft
Definition: MWAWParagraph.hxx:89
MWAWParagraph::hasDifferentBorders
bool hasDifferentBorders() const
check if the paragraph has different borders
Definition: MWAWParagraph.cxx:213
MWAWParagraph::m_listId
Variable< int > m_listId
the list id (if know )
Definition: MWAWParagraph.hxx:164
MWAWParagraph::setInterline
void setInterline(double value, WPXUnit unit, LineSpacingType type=Fixed)
set the interline
Definition: MWAWParagraph.hxx:118