RagTime5StyleManager.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

RagTime5StyleManager.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 #ifndef RAG_TIME_5_STYLE_MANAGER
35 # define RAG_TIME_5_STYLE_MANAGER
36
37 #include <map>
38 #include <ostream>
39 #include <sstream>
40 #include <set>
41 #include <string>
42 #include <vector>
43
44 #include "libmwaw_internal.hxx"
45 #include "MWAWDebug.hxx"
46 #include "MWAWEntry.hxx"
47 #include "MWAWGraphicStyle.hxx"
48
49 #include "RagTime5ClusterManager.hxx"
50 #include "RagTime5StructManager.hxx"
51
52 namespace RagTime5StyleManagerInternal
53 {
54 struct State;
55 }
56
57 class RagTime5Parser;
58
60 class RagTime5StyleManager
61 {
62 friend class RagTime5Parser;
63 public:
65 RagTime5StyleManager(RagTime5Parser &parser);
67 ~RagTime5StyleManager();
68
69 struct GraphicStyle;
70 struct TextStyle;
71
73 bool readGraphicColors(RagTime5ClusterManager::Cluster &cluster);
75 bool readGraphicStyles(RagTime5ClusterManager::Cluster &cluster);
77 bool readTextStyles(RagTime5ClusterManager::Cluster &cluster);
78
80 bool updateBorderStyle(int graphicId, MWAWGraphicStyle &borderStyle, bool isLine);
82 bool updateSurfaceStyle(int graphicId, MWAWGraphicStyle &surfaceStyle);
84 bool getLineColor(int graphicId, MWAWColor &color);
85
87 bool update(int textId, MWAWFont &font, MWAWParagraph &para);
88
89 protected:
91 void updateTextStyles(size_t id, RagTime5StyleManager::TextStyle const &style,
92 std::vector<RagTime5StyleManager::TextStyle> const &listReadStyles,
93 std::multimap<size_t, size_t> const &idToChildIpMap,
94 std::set<size_t> &seens);
96 void updateGraphicStyles(size_t id, RagTime5StyleManager::GraphicStyle const &style,
97 std::vector<RagTime5StyleManager::GraphicStyle> const &listReadStyles,
98 std::multimap<size_t, size_t> const &idToChildIpMap,
99 std::set<size_t> &seens);
100
101 public:
103 struct GraphicStyle {
105 GraphicStyle() : m_parentId(-1000), m_width(-1), m_dash(), m_pattern(), m_gradient(-1), m_gradientRotation(-1000), m_gradientCenter(MWAWVec2f(0.5f,0.5f)),
106 m_position(-1), m_cap(1), m_mitter(-1), m_limitPercent(-1), m_hidden(false), m_extra("")
107 {
108 m_colors[0]=MWAWVariable<MWAWColor>(MWAWColor::black());
109 m_colors[1]=MWAWVariable<MWAWColor>(MWAWColor::white());
110 m_colorsAlpha[0]=m_colorsAlpha[1]=-1;
111 }
113 virtual ~GraphicStyle()
114 {
115 }
117 bool isDefault() const
118 {
119 return m_parentId<=-1000 && m_width<0 && !m_dash.isSet() && !m_pattern &&
120 m_gradient<0 && m_gradientRotation<=-1000 && !m_gradientCenter.isSet() &&
121 m_position<0 && m_cap<0 && m_mitter<0 &&
122 !m_colors[0].isSet() && !m_colors[1].isSet() && m_colorsAlpha[0]<0 && m_colorsAlpha[1]<0 &&
123 m_limitPercent<0 && !m_hidden.isSet() && m_extra.empty();
124 }
126 friend std::ostream &operator<<(std::ostream &o, GraphicStyle const &style);
128 void insert(GraphicStyle const &childStyle);
130 bool read(MWAWInputStreamPtr &input, RagTime5StructManager::Field const &field, std::vector<MWAWColor> const &colorList);
132 int m_parentId;
134 float m_width;
136 MWAWVariable<MWAWColor> m_colors[2];
138 float m_colorsAlpha[2];
140 MWAWVariable<std::vector<long> > m_dash;
142 shared_ptr<MWAWGraphicStyle::Pattern> m_pattern;
144 int m_gradient;
146 float m_gradientRotation;
148 MWAWVariable<MWAWVec2f> m_gradientCenter;
150 int m_position;
152 int m_cap;
154 int m_mitter;
156 float m_limitPercent;
158 MWAWVariable<bool> m_hidden;
160 std::string m_extra;
161 };
163 struct TextStyle {
165 TextStyle() : m_linkIdList(),
166 m_dateStyleId(-1), m_graphStyleId(-1), m_graphLineStyleId(-1), m_keepWithNext(false), m_justify(-1), m_breakMethod(-1), m_tabList(),
167 m_fontName(""), m_fontId(-1), m_fontSize(-1), m_scriptPosition(0), m_fontScaling(-1), m_underline(-1), m_caps(-1), m_language(-1), m_widthStreching(-1),
168 m_numColumns(-1), m_columnGap(-1), m_extra("")
169 {
170 m_parentId[0]=m_parentId[1]=-1;
171 m_fontFlags[0]=m_fontFlags[1]=0;
172 for (int i=0; i<3; ++i) {
173 m_margins[i]=-1;
174 m_spacings[i]=-1;
175 m_spacingUnits[i]=-1;
176 }
177 for (int i=0; i<4; ++i) m_letterSpacings[i]=0;
178 }
180 virtual ~TextStyle()
181 {
182 }
184 bool isDefault() const
185 {
186 if (m_parentId[0]>=0 || m_parentId[1]>=0 || !m_linkIdList.empty() ||
187 m_dateStyleId>=0 || m_graphStyleId>=0 || m_graphLineStyleId>=0 ||
188 m_keepWithNext.isSet() || m_justify>=0 || m_breakMethod>=0 || !m_tabList.empty() ||
189 !m_fontName.empty() || m_fontId>=0 || m_fontSize>=0 || m_fontFlags[0] || m_fontFlags[1] || m_scriptPosition.isSet() ||
190 m_fontScaling>=0 || m_underline>=0 || m_caps>=0 || m_language>=0 || m_widthStreching>=0 ||
191 m_numColumns>=0 || m_columnGap>=0 || !m_extra.empty())
192 return false;
193 for (int i=0; i<3; ++i) {
194 if (m_margins[i]>=0 || m_spacings[i]>=0 || m_spacingUnits[i]>=0)
195 return false;
196 }
197 for (int i=0; i<4; ++i) {
198 if (m_letterSpacings[i]>0 || m_letterSpacings[i]<0)
199 return false;
200 }
201 return true;
202 }
204 static std::string getLanguageLocale(int id);
205
207 friend std::ostream &operator<<(std::ostream &o, TextStyle const &style);
209 void insert(TextStyle const &childStyle);
211 bool read(RagTime5StructManager::Field const &field);
213 int m_parentId[2];
215 std::vector<int> m_linkIdList;
217 int m_dateStyleId;
219 int m_graphStyleId;
221 int m_graphLineStyleId;
222
223 // paragraph
224
226 MWAWVariable<bool> m_keepWithNext;
228 int m_justify;
230 double m_spacings[3];
232 int m_spacingUnits[3];
234 int m_breakMethod;
236 double m_margins[3];
238 std::vector<RagTime5StructManager::TabStop> m_tabList;
239
240 // character
241
243 librevenge::RVNGString m_fontName;
245 int m_fontId;
247 float m_fontSize;
249 uint32_t m_fontFlags[2];
251 MWAWVariable<float> m_scriptPosition;
253 float m_fontScaling;
255 int m_underline;
257 int m_caps;
259 int m_language;
261 double m_letterSpacings[4];
263 double m_widthStreching;
264
265 // column
266
268 int m_numColumns;
270 double m_columnGap;
271
273 std::string m_extra;
274 };
275
276 protected:
277 //
278 // data
279 //
280
282 RagTime5Parser &m_mainParser;
284 MWAWParserStatePtr m_parserState;
285
287 shared_ptr<RagTime5StyleManagerInternal::State> m_state;
288
289 private:
290 RagTime5StyleManager(RagTime5StyleManager const &orig);
291 RagTime5StyleManager operator=(RagTime5StyleManager const &orig);
292 };
293
294 #endif
295 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
RagTime5StyleManager::GraphicStyle::m_hidden
MWAWVariable< bool > m_hidden
flag to know if we need to print the shape
Definition: RagTime5StyleManager.hxx:158
RagTime5StyleManager::readGraphicColors
bool readGraphicColors(RagTime5ClusterManager::Cluster &cluster)
try to read a graphic color zone
Definition: RagTime5StyleManager.cxx:281
RagTime5StyleManager::TextStyle::m_fontId
int m_fontId
the font id
Definition: RagTime5StyleManager.hxx:245
RagTime5StyleManager::TextStyle::m_caps
int m_caps
caps : none, all caps, lower caps, inital caps + other lowers
Definition: RagTime5StyleManager.hxx:257
RagTime5StyleManager::GraphicStyle::isDefault
bool isDefault() const
returns true if the line style is default
Definition: RagTime5StyleManager.hxx:117
RagTime5StyleManager::TextStyle::read
bool read(RagTime5StructManager::Field const &field)
try to read a text style
Definition: RagTime5StyleManager.cxx:1272
RagTime5StyleManager::GraphicStyle::m_colors
MWAWVariable< MWAWColor > m_colors[2]
the first and second color
Definition: RagTime5StyleManager.hxx:136
RagTime5StyleManager::update
bool update(int textId, MWAWFont &font, MWAWParagraph &para)
update the font and the paragraph properties using a text style
Definition: RagTime5StyleManager.cxx:645
RagTime5StyleManager::GraphicStyle::m_gradient
int m_gradient
the gradient 0: none, normal, radial
Definition: RagTime5StyleManager.hxx:144
RagTime5StyleManager::GraphicStyle::m_extra
std::string m_extra
extra data
Definition: RagTime5StyleManager.hxx:160
RagTime5StyleManager::GraphicStyle::m_dash
MWAWVariable< std::vector< long > > m_dash
the line dash/...
Definition: RagTime5StyleManager.hxx:140
MWAWEntry.hxx
libmwaw_internal.hxx
MWAWColor::white
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:225
RagTime5StyleManager::GraphicStyle::insert
void insert(GraphicStyle const &childStyle)
update the current style
Definition: RagTime5StyleManager.cxx:1090
RagTime5StyleManager::updateSurfaceStyle
bool updateSurfaceStyle(int graphicId, MWAWGraphicStyle &surfaceStyle)
update a graphic style
Definition: RagTime5StyleManager.cxx:469
RagTime5StyleManager::TextStyle::insert
void insert(TextStyle const &childStyle)
update the current style
Definition: RagTime5StyleManager.cxx:1823
RagTime5StyleManager::GraphicStyle::~GraphicStyle
virtual ~GraphicStyle()
destructor
Definition: RagTime5StyleManager.hxx:113
RagTime5StyleManager::updateTextStyles
void updateTextStyles(size_t id, RagTime5StyleManager::TextStyle const &style, std::vector< RagTime5StyleManager::TextStyle > const &listReadStyles, std::multimap< size_t, size_t > const &idToChildIpMap, std::set< size_t > &seens)
recursive function use to update the style list
Definition: RagTime5StyleManager.cxx:620
RagTime5StyleManager::GraphicStyle::m_gradientCenter
MWAWVariable< MWAWVec2f > m_gradientCenter
the rotation center(checkme)
Definition: RagTime5StyleManager.hxx:148
RagTime5StyleManager::TextStyle::m_graphLineStyleId
int m_graphLineStyleId
the graphic line style id
Definition: RagTime5StyleManager.hxx:221
RagTime5StyleManager::updateGraphicStyles
void updateGraphicStyles(size_t id, RagTime5StyleManager::GraphicStyle const &style, std::vector< RagTime5StyleManager::GraphicStyle > const &listReadStyles, std::multimap< size_t, size_t > const &idToChildIpMap, std::set< size_t > &seens)
recursive function use to update the style list
Definition: RagTime5StyleManager.cxx:396
RagTime5StyleManager::GraphicStyle::read
bool read(MWAWInputStreamPtr &input, RagTime5StructManager::Field const &field, std::vector< MWAWColor > const &colorList)
try to read a graphic style
Definition: RagTime5StyleManager.cxx:794
MWAWColor::black
static MWAWColor black()
return the back color
Definition: libmwaw_internal.hxx:220
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
RagTime5StyleManager::TextStyle::getLanguageLocale
static std::string getLanguageLocale(int id)
returns the language locale name corresponding to an id ( if known)
Definition: RagTime5StyleManager.cxx:1219
RagTime5StyleManager::TextStyle::m_numColumns
int m_numColumns
the number of columns
Definition: RagTime5StyleManager.hxx:268
RagTime5StyleManager::TextStyle::m_fontName
librevenge::RVNGString m_fontName
the font name
Definition: RagTime5StyleManager.hxx:243
RagTime5StructManager.hxx
RagTime5StyleManager
basic class used to read/store RagTime 5/6 styles
Definition: RagTime5StyleManager.hxx:60
RagTime5StyleManager::TextStyle::m_breakMethod
int m_breakMethod
the break method 0: asIs, next container, next page, next even page, next odd page ...
Definition: RagTime5StyleManager.hxx:234
RagTime5StyleManager::updateBorderStyle
bool updateBorderStyle(int graphicId, MWAWGraphicStyle &borderStyle, bool isLine)
update a graphic style(border)
Definition: RagTime5StyleManager.cxx:433
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:176
RagTime5StyleManager::operator=
RagTime5StyleManager operator=(RagTime5StyleManager const &orig)
RagTime5StyleManager::TextStyle::m_dateStyleId
int m_dateStyleId
the date style id
Definition: RagTime5StyleManager.hxx:217
RagTime5StyleManager::readTextStyles
bool readTextStyles(RagTime5ClusterManager::Cluster &cluster)
try to read a main text styles
Definition: RagTime5StyleManager.cxx:505
RagTime5StyleManager::TextStyle::m_language
int m_language
the language
Definition: RagTime5StyleManager.hxx:259
RagTime5StyleManager::TextStyle::m_graphStyleId
int m_graphStyleId
the graphic style id
Definition: RagTime5StyleManager.hxx:219
RagTime5StyleManager::TextStyle::m_fontFlags
uint32_t m_fontFlags[2]
the font flags (add and remove )
Definition: RagTime5StyleManager.hxx:249
RagTime5StyleManager::~RagTime5StyleManager
~RagTime5StyleManager()
destructor
Definition: RagTime5StyleManager.cxx:274
RagTime5StyleManager::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: RagTime5StyleManager.hxx:284
RagTime5StyleManager::TextStyle::m_keepWithNext
MWAWVariable< bool > m_keepWithNext
the keep with next flag
Definition: RagTime5StyleManager.hxx:226
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
RagTime5StyleManager::GraphicStyle::m_width
float m_width
the line width (in point)
Definition: RagTime5StyleManager.hxx:134
RagTime5StyleManager::GraphicStyle::operator<<
friend std::ostream & operator<<(std::ostream &o, GraphicStyle const &style)
operator<<
Definition: RagTime5StyleManager.cxx:1116
RagTime5StyleManager::GraphicStyle::m_cap
int m_cap
the line caps ( normal=1, round, square)
Definition: RagTime5StyleManager.hxx:152
RagTime5StyleManager::TextStyle::m_widthStreching
double m_widthStreching
the width streching
Definition: RagTime5StyleManager.hxx:263
RagTime5StyleManager::TextStyle::m_letterSpacings
double m_letterSpacings[4]
the spacings in percent ( normal, minimum, maximum)
Definition: RagTime5StyleManager.hxx:261
RagTime5StyleManager::RagTime5StyleManager
RagTime5StyleManager(RagTime5Parser &parser)
constructor
Definition: RagTime5StyleManager.cxx:269
RagTime5StyleManager::TextStyle::m_extra
std::string m_extra
extra data
Definition: RagTime5StyleManager.hxx:273
RagTime5StyleManager::TextStyle::m_justify
int m_justify
justify 0: left, 1:center, 2:right, 3:full, 4:full all
Definition: RagTime5StyleManager.hxx:228
RagTime5StyleManager::GraphicStyle::m_limitPercent
float m_limitPercent
the line limit
Definition: RagTime5StyleManager.hxx:156
RagTime5StyleManager::TextStyle::operator<<
friend std::ostream & operator<<(std::ostream &o, TextStyle const &style)
operator<<
Definition: RagTime5StyleManager.cxx:1867
RagTime5Parser
the main class to read a RagTime v5 file
Definition: RagTime5Parser.hxx:72
RagTime5StructManager::Field
a field of RagTime 5/6 structures
Definition: RagTime5StructManager.hxx:218
RagTime5StyleManager::TextStyle::m_columnGap
double m_columnGap
the gap between columns
Definition: RagTime5StyleManager.hxx:270
RagTime5StyleManager::TextStyle::m_tabList
std::vector< RagTime5StructManager::TabStop > m_tabList
the tabulations
Definition: RagTime5StyleManager.hxx:238
RagTime5StyleManager::TextStyle::m_spacings
double m_spacings[3]
the interline/before/after value
Definition: RagTime5StyleManager.hxx:230
RagTime5StyleManager::readGraphicStyles
bool readGraphicStyles(RagTime5ClusterManager::Cluster &cluster)
try to read a main graphic styles
Definition: RagTime5StyleManager.cxx:290
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:489
RagTime5StyleManager::TextStyle::m_scriptPosition
MWAWVariable< float > m_scriptPosition
the font script position ( in percent)
Definition: RagTime5StyleManager.hxx:251
RagTime5StyleManager::TextStyle::TextStyle
TextStyle()
constructor
Definition: RagTime5StyleManager.hxx:165
MWAWDebug.hxx
RagTime5StyleManager::GraphicStyle::m_pattern
shared_ptr< MWAWGraphicStyle::Pattern > m_pattern
the line pattern
Definition: RagTime5StyleManager.hxx:142
RagTime5StyleManager::GraphicStyle::m_mitter
int m_mitter
the line mitter ( triangle=1, round, out)
Definition: RagTime5StyleManager.hxx:154
RagTime5StyleManager::TextStyle::m_fontScaling
float m_fontScaling
the font script position ( in percent)
Definition: RagTime5StyleManager.hxx:253
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:81
RagTime5StyleManager::GraphicStyle::GraphicStyle
GraphicStyle()
constructor
Definition: RagTime5StyleManager.hxx:105
RagTime5StyleManager::m_mainParser
RagTime5Parser & m_mainParser
the parser
Definition: RagTime5StyleManager.hxx:282
RagTime5StyleManager::GraphicStyle::m_colorsAlpha
float m_colorsAlpha[2]
alpha of the first and second color
Definition: RagTime5StyleManager.hxx:138
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:495
RagTime5StyleManager::GraphicStyle
the graphic style of a RagTime v5-v6 document
Definition: RagTime5StyleManager.hxx:103
RagTime5StyleManager::GraphicStyle::m_parentId
int m_parentId
the parent id
Definition: RagTime5StyleManager.hxx:132
RagTime5StyleManager::TextStyle::m_spacingUnits
int m_spacingUnits[3]
the interline/before/after unit 0: line, 1:point
Definition: RagTime5StyleManager.hxx:232
RagTime5StyleManager::TextStyle::m_margins
double m_margins[3]
the spacings in point ( left, right, first)
Definition: RagTime5StyleManager.hxx:236
RagTime5StyleManager::TextStyle::~TextStyle
virtual ~TextStyle()
destructor
Definition: RagTime5StyleManager.hxx:180
RagTime5StyleManager::TextStyle
the text style of a RagTime v5-v6 document
Definition: RagTime5StyleManager.hxx:163
RagTime5StyleManager::TextStyle::isDefault
bool isDefault() const
returns true if the line style is default
Definition: RagTime5StyleManager.hxx:184
RagTime5StyleManager::getLineColor
bool getLineColor(int graphicId, MWAWColor &color)
returns the line color corresponding to a graphic style
Definition: RagTime5StyleManager.cxx:419
RagTime5ClusterManager.hxx
MWAWVariable::isSet
bool isSet() const
return true if the variable is set
Definition: libmwaw_internal.hxx:572
MWAWVariable< MWAWColor >
RagTime5StyleManagerInternal
Internal: the structures of a RagTime5Style.
Definition: RagTime5StyleManager.cxx:50
RagTime5StyleManager::m_state
shared_ptr< RagTime5StyleManagerInternal::State > m_state
the state
Definition: RagTime5StyleManager.hxx:287
RagTime5StyleManager::TextStyle::m_fontSize
float m_fontSize
the font size
Definition: RagTime5StyleManager.hxx:247
MWAWGraphicStyle.hxx
RagTime5StyleManager::TextStyle::m_linkIdList
std::vector< int > m_linkIdList
the link id list
Definition: RagTime5StyleManager.hxx:215
RagTime5StyleManager::TextStyle::m_underline
int m_underline
underline : none, single, double
Definition: RagTime5StyleManager.hxx:255
MWAWVec2< float >
RagTime5StyleManager::TextStyle::m_parentId
int m_parentId[2]
the parent id ( main and style ?)
Definition: RagTime5StyleManager.hxx:213
RagTime5StyleManager::GraphicStyle::m_gradientRotation
float m_gradientRotation
the gradient rotation(checkme)
Definition: RagTime5StyleManager.hxx:146
RagTime5StyleManager::GraphicStyle::m_position
int m_position
the line position inside=1/normal/outside/round
Definition: RagTime5StyleManager.hxx:150
RagTime5ClusterManager::Cluster
the cluster data
Definition: RagTime5ClusterManager.hxx:214