1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* This file is part of the libsw602 project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW602_PARAGRAPH_H
#define INCLUDED_SW602_PARAGRAPH_H
#include <iostream>
#include <vector>
#include <boost/optional.hpp>
#include <librevenge/librevenge.h>
#include "SW602List.h"
#include "SW602Types.h"
namespace libsw602
{
/** class to store a tab use by SW602Paragraph */
struct SW602TabStop
{
//! the tab alignment
enum Alignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
//! constructor
SW602TabStop(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)
{
}
//! add a tab to the propList
void addTo(librevenge::RVNGPropertyListVector &propList, double decalX=0.0) const;
//! operator==
bool operator==(SW602TabStop const &tabs) const
{
return cmp(tabs)==0;
}
//! operator!=
bool operator!=(SW602TabStop const &tabs) const
{
return cmp(tabs)!=0;
}
//! operator <<
friend std::ostream &operator<<(std::ostream &o, SW602TabStop const &ft);
//! a comparison function
int cmp(SW602TabStop const &tabs) const;
//! the tab position
double m_position;
//! the alignment ( left, center, ...)
Alignment m_alignment;
//! the leader char
uint16_t m_leaderCharacter;
//! the decimal char
uint16_t m_decimalCharacter;
};
//! class to store the paragraph properties
class SW602Paragraph
{
public:
/** some bit use to defined the break status */
enum { NoBreakBit = 0x1, NoBreakWithNextBit=0x2 };
/** an enum used to defined the paragraph justification: left, center, right, full ... */
enum Justification { JustificationLeft, JustificationFull, JustificationCenter,
JustificationRight, JustificationFullAllLines
};
/** the line spacing type: fixed or at least */
enum LineSpacingType { Fixed, AtLeast};
//! constructor
SW602Paragraph();
//! destructor
virtual ~SW602Paragraph();
//! operator==
bool operator==(SW602Paragraph const &p) const
{
return cmp(p)==0;
}
//! operator!=
bool operator!=(SW602Paragraph const &p) const
{
return cmp(p)!=0;
}
//! a comparison function
int cmp(SW602Paragraph const &p) const;
//! return the paragraph margin width (in inches)
double getMarginsWidth() const;
//! check if the paragraph has some borders
bool hasBorders() const;
//! check if the paragraph has different borders
bool hasDifferentBorders() const;
//! a function used to resize the borders list ( adding empty borders if needed )
void resizeBorders(size_t newSize)
{
SW602Border empty;
empty.m_style=SW602Border::None;
m_borders.resize(newSize, boost::optional<SW602Border>(empty));
}
//! set the interline
void setInterline(double value, librevenge::RVNGUnit unit, LineSpacingType type=Fixed)
{
m_spacings[0]=value;
m_spacingsInterlineUnit=unit;
m_spacingsInterlineType=type;
}
//! add to the propList
void addTo(librevenge::RVNGPropertyList &propList, bool inTable) const;
//! insert the set values of para in the actual paragraph
void insert(SW602Paragraph const ¶);
//! operator <<
friend std::ostream &operator<<(std::ostream &o, SW602Paragraph const &ft);
/** the margins
*
* - 0: first line left margin
* - 1: left margin
* - 2: right margin*/
boost::optional<double> m_margins[3]; // 0: first line left, 1: left, 2: right
/** the margins INCH, ... */
boost::optional<librevenge::RVNGUnit> m_marginsUnit;
/** the line spacing
*
* - 0: interline
* - 1: before
* - 2: after */
boost::optional<double> m_spacings[3]; // 0: interline, 1: before, 2: after
/** the interline unit PERCENT or INCH, ... */
boost::optional<librevenge::RVNGUnit> m_spacingsInterlineUnit;
/** the interline type: fixed, atLeast, ... */
boost::optional<LineSpacingType> m_spacingsInterlineType;
//! the tabulations
boost::optional<std::vector<SW602TabStop> > m_tabs;
//! true if the tabs are relative to left margin, false if there are relative to the page margin (default)
boost::optional<bool> m_tabsRelativeToLeftMargin;
/** the justification */
boost::optional<Justification> m_justify;
/** a list of bits: 0x1 (unbreakable), 0x2 (do not break after) */
boost::optional<int> m_breakStatus; // BITS: 1: unbreakable, 2: dont break after
/** the actual level index */
boost::optional<int> m_listLevelIndex;
/** the list id (if know ) */
boost::optional<int> m_listId;
/** the list start value (if set ) */
boost::optional<int> m_listStartValue;
/** the actual level */
boost::optional<SW602ListLevel> m_listLevel;
//! the background color
boost::optional<SW602Color> m_backgroundColor;
//! list of border ( order SW602Border::Pos)
std::vector<boost::optional<SW602Border> > m_borders;
//! the style name
std::string m_styleName;
//! a string to store some errors
std::string m_extra;
};
}
#endif
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|