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 
51 
52 class MWAWCell;
53 
55 {
56 struct State;
57 }
58 
59 class RagTime5Document;
60 
63 {
64  friend class RagTime5Document;
65 public:
70 
71  struct GraphicStyle;
72  struct TextStyle;
73 
82 
84  bool updateSurfaceStyle(int graphicId, MWAWGraphicStyle &surfaceStyle) const;
86  bool updateFrameStyle(int graphicId, MWAWGraphicStyle &surfaceStyle) const;
88  bool updateBorderStyle(int graphicId, MWAWGraphicStyle &borderStyle, bool isLine) const;
90  bool getLineColor(int graphicId, MWAWColor &color) const;
92  bool updateTextStyles(int textId, MWAWFont &font, MWAWParagraph &para, MWAWSection &section, double totalWidth=0) const;
94  bool getCellBorder(int graphicId, MWAWBorder &border) const;
96  bool getCellBackgroundColor(int graphicId, MWAWColor &color) const;
98  bool updateCellFormat(int formatId, MWAWCell &cell) const;
99 
100 protected:
102  void updateTextStyles(size_t id, RagTime5StyleManager::TextStyle const &style,
103  std::vector<RagTime5StyleManager::TextStyle> const &listReadStyles,
104  std::multimap<size_t, size_t> const &idToChildIpMap,
105  std::set<size_t> &seens);
107  void updateGraphicStyles(size_t id, RagTime5StyleManager::GraphicStyle const &style,
108  std::vector<RagTime5StyleManager::GraphicStyle> const &listReadStyles,
109  std::multimap<size_t, size_t> const &idToChildIpMap,
110  std::set<size_t> &seens);
111 
112 public:
114  struct GraphicStyle {
117  : m_parentId(-1000)
118  , m_width(-1)
119  , m_dash()
120  , m_pattern()
121  , m_gradient(-1)
122  , m_gradientRotation(-1000)
123  , m_gradientCenter(MWAWVec2f(0.5f,0.5f))
124  , m_position(-1)
125  , m_cap(1)
126  , m_mitter(-1)
127  , m_limitPercent(-1)
128  , m_hidden(false)
129  , m_extra("")
130  {
133  for (auto &alpha : m_colorsAlpha) alpha=-1;
134  }
136  virtual ~GraphicStyle();
138  bool isDefault() const
139  {
140  return m_parentId<=-1000 && m_width<0 && !m_dash.isSet() && !m_pattern &&
141  m_gradient<0 && m_gradientRotation<=-1000 && !m_gradientCenter.isSet() &&
142  m_position<0 && m_cap<0 && m_mitter<0 &&
143  !m_colors[0].isSet() && !m_colors[1].isSet() && m_colorsAlpha[0]<0 && m_colorsAlpha[1]<0 &&
144  m_limitPercent<0 && !m_hidden.isSet() && m_extra.empty();
145  }
147  bool updateColor(bool first, int colorId, std::vector<MWAWColor> const &colorList);
149  friend std::ostream &operator<<(std::ostream &o, GraphicStyle const &style);
151  void insert(GraphicStyle const &childStyle);
153  bool read(MWAWInputStreamPtr &input, RagTime5StructManager::Field const &field, std::vector<MWAWColor> const &colorList);
157  float m_width;
161  float m_colorsAlpha[2];
165  std::shared_ptr<MWAWGraphicStyle::Pattern> m_pattern;
175  int m_cap;
177  int m_mitter;
183  std::string m_extra;
184 
185  GraphicStyle(GraphicStyle const &)=default; // removeme
186  GraphicStyle(GraphicStyle &&)=default;
187  GraphicStyle &operator=(GraphicStyle const &)=default; // removeme
188  GraphicStyle &operator=(GraphicStyle &&)=default;
189  };
191  struct TextStyle {
194  : m_linkIdList()
195  , m_dateStyleId(-1)
196  , m_graphStyleId(-1)
197  , m_graphLineStyleId(-1)
198  , m_keepWithNext(false)
199  , m_justify(-1)
200  , m_breakMethod(-1)
201  , m_tabList()
202  , m_fontName("")
203  , m_fontId(-1)
204  , m_fontSize(-1)
205  , m_scriptPosition(0)
206  , m_fontScaling(-1)
207  , m_underline(-1)
208  , m_caps(-1)
209  , m_language(-1)
210  , m_widthStreching(-1)
211  , m_numColumns(-1)
212  , m_columnGap(-1)
213  , m_extra("")
214  {
215  for (auto &parentId : m_parentId) parentId=-1;
216  for (auto &fontFlag : m_fontFlags) fontFlag=0;
217  for (auto &margin : m_margins) margin=-1;
218  for (auto &spacing : m_spacings) spacing=-1;
219  for (auto &spacingUnit : m_spacingUnits) spacingUnit=-1;
220  for (auto &letterSpacing : m_letterSpacings) letterSpacing=0;
221  }
223  virtual ~TextStyle();
225  bool isDefault() const
226  {
227  if (m_parentId[0]>=0 || m_parentId[1]>=0 || !m_linkIdList.empty() ||
229  m_keepWithNext.isSet() || m_justify>=0 || m_breakMethod>=0 || !m_tabList.empty() ||
230  !m_fontName.empty() || m_fontId>=0 || m_fontSize>=0 || m_fontFlags[0] || m_fontFlags[1] || m_scriptPosition.isSet() ||
231  m_fontScaling>=0 || m_underline>=0 || m_caps>=0 || m_language>=0 || m_widthStreching>=0 ||
232  m_numColumns>=0 || m_columnGap>=0 || !m_extra.empty())
233  return false;
234  for (int i=0; i<3; ++i) {
235  if (m_margins[i]>=0 || m_spacings[i]>=0 || m_spacingUnits[i]>=0)
236  return false;
237  }
238  for (auto spacing : m_letterSpacings) {
239  if (spacing>0 || spacing<0)
240  return false;
241  }
242  return true;
243  }
245  static std::string getLanguageLocale(int id);
246 
248  friend std::ostream &operator<<(std::ostream &o, TextStyle const &style);
250  void insert(TextStyle const &childStyle);
252  bool read(RagTime5StructManager::Field const &field);
254  int m_parentId[2];
256  std::vector<int> m_linkIdList;
263 
264  // paragraph
265 
271  double m_spacings[3];
277  double m_margins[3];
279  std::vector<RagTime5StructManager::TabStop> m_tabList;
280 
281  // character
282 
284  librevenge::RVNGString m_fontName;
286  int m_fontId;
288  float m_fontSize;
290  uint32_t m_fontFlags[2];
298  int m_caps;
302  double m_letterSpacings[4];
305 
306  // column
307 
311  double m_columnGap;
312 
314  std::string m_extra;
315 
316  TextStyle(TextStyle const &)=default; // removeme
317  TextStyle(TextStyle &&)=default;
318  TextStyle &operator=(TextStyle const &)=default; // removeme
319  TextStyle &operator=(TextStyle &&)=default;
320  };
321 
322 public:
324  static std::string printType(unsigned long fileType)
325  {
326  return RagTime5StructManager::printType(fileType);
327  }
328 
329 protected:
330  //
331  // data
332  //
333 
338 
340  std::shared_ptr<RagTime5StyleManagerInternal::State> m_state;
341 
342 private:
343  RagTime5StyleManager(RagTime5StyleManager const &orig) = delete;
345 };
346 
347 #endif
348 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWVariable< bool > m_hidden
flag to know if we need to print the shape
Definition: RagTime5StyleManager.hxx:181
static std::string printType(unsigned long fileType)
debug: print a file type
Definition: RagTime5StructManager.cxx:94
bool readGraphicColors(RagTime5ClusterManager::Cluster &cluster)
try to read a graphic color zone
Definition: RagTime5StyleManager.cxx:320
int m_fontId
the font id
Definition: RagTime5StyleManager.hxx:286
int m_caps
caps : none, all caps, lower caps, inital caps + other lowers
Definition: RagTime5StyleManager.hxx:298
bool isDefault() const
returns true if the line style is default
Definition: RagTime5StyleManager.hxx:138
bool updateFrameStyle(int graphicId, MWAWGraphicStyle &surfaceStyle) const
updates a graphic style (used for textbox)
Definition: RagTime5StyleManager.cxx:579
bool read(RagTime5StructManager::Field const &field)
try to read a text style
Definition: RagTime5StyleManager.cxx:1748
MWAWVariable< MWAWColor > m_colors[2]
the first and second color
Definition: RagTime5StyleManager.hxx:159
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:557
RagTime5StyleManager operator=(RagTime5StyleManager const &orig)=delete
bool readFormats(RagTime5ClusterManager::Cluster &cluster)
try to read the list of format
Definition: RagTime5StyleManager.cxx:919
int m_gradient
the gradient 0: none, normal, radial
Definition: RagTime5StyleManager.hxx:167
std::string m_extra
extra data
Definition: RagTime5StyleManager.hxx:183
MWAWVariable< std::vector< long > > m_dash
the line dash/...
Definition: RagTime5StyleManager.hxx:163
bool updateTextStyles(int textId, MWAWFont &font, MWAWParagraph &para, MWAWSection &section, double totalWidth=0) const
update the font and the paragraph properties using a text style
Definition: RagTime5StyleManager.cxx:775
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:250
void insert(GraphicStyle const &childStyle)
update the current style
Definition: RagTime5StyleManager.cxx:1564
void insert(TextStyle const &childStyle)
update the current style
Definition: RagTime5StyleManager.cxx:2269
MWAWVariable< MWAWVec2f > m_gradientCenter
the rotation center(checkme)
Definition: RagTime5StyleManager.hxx:171
bool updateSurfaceStyle(int graphicId, MWAWGraphicStyle &surfaceStyle) const
updates a graphic style
Definition: RagTime5StyleManager.cxx:599
int m_graphLineStyleId
the graphic line style id
Definition: RagTime5StyleManager.hxx:262
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:434
bool read(MWAWInputStreamPtr &input, RagTime5StructManager::Field const &field, std::vector< MWAWColor > const &colorList)
try to read a graphic style
Definition: RagTime5StyleManager.cxx:1273
RagTime5StyleManager(RagTime5Document &doc)
constructor
Definition: RagTime5StyleManager.cxx:306
static MWAWColor black()
return the back color
Definition: libmwaw_internal.hxx:245
bool getCellBackgroundColor(int graphicId, MWAWColor &color) const
returns the cell background
Definition: RagTime5StyleManager.cxx:517
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
static std::string getLanguageLocale(int id)
returns the language locale name corresponding to an id ( if known)
Definition: RagTime5StyleManager.cxx:1695
int m_numColumns
the number of columns
Definition: RagTime5StyleManager.hxx:309
librevenge::RVNGString m_fontName
the font name
Definition: RagTime5StyleManager.hxx:284
RagTime5Document & m_document
the parser
Definition: RagTime5StyleManager.hxx:335
bool updateCellFormat(int formatId, MWAWCell &cell) const
updates the cell format
Definition: RagTime5StyleManager.cxx:1245
basic class used to read/store RagTime 5/6 styles
Definition: RagTime5StyleManager.hxx:62
bool updateBorderStyle(int graphicId, MWAWGraphicStyle &borderStyle, bool isLine) const
updates a graphic style(border)
Definition: RagTime5StyleManager.cxx:543
int m_breakMethod
the break method 0: asIs, next container, next page, next even page, next odd page ...
Definition: RagTime5StyleManager.hxx:275
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
the class to store a color
Definition: libmwaw_internal.hxx:192
int m_dateStyleId
the date style id
Definition: RagTime5StyleManager.hxx:258
bool readTextStyles(RagTime5ClusterManager::Cluster &cluster)
try to read a main text styles
Definition: RagTime5StyleManager.cxx:636
int m_language
the language
Definition: RagTime5StyleManager.hxx:300
int m_graphStyleId
the graphic style id
Definition: RagTime5StyleManager.hxx:260
uint32_t m_fontFlags[2]
the font flags (add and remove )
Definition: RagTime5StyleManager.hxx:290
~RagTime5StyleManager()
destructor
Definition: RagTime5StyleManager.cxx:313
bool getLineColor(int graphicId, MWAWColor &color) const
returns the line color corresponding to a graphic style
Definition: RagTime5StyleManager.cxx:457
bool updateColor(bool first, int colorId, std::vector< MWAWColor > const &colorList)
update the first/second color using the color list
Definition: RagTime5StyleManager.cxx:1552
MWAWParserStatePtr m_parserState
the parser state
Definition: RagTime5StyleManager.hxx:337
MWAWVariable< bool > m_keepWithNext
the keep with next flag
Definition: RagTime5StyleManager.hxx:267
Class to store font.
Definition: MWAWFont.hxx:43
a border
Definition: libmwaw_internal.hxx:333
float m_width
the line width (in point)
Definition: RagTime5StyleManager.hxx:157
friend std::ostream & operator<<(std::ostream &o, GraphicStyle const &style)
operator<<
Definition: RagTime5StyleManager.cxx:1590
int m_cap
the line caps ( normal=1, round, square)
Definition: RagTime5StyleManager.hxx:175
double m_widthStreching
the width streching
Definition: RagTime5StyleManager.hxx:304
double m_letterSpacings[4]
the spacings in percent ( normal, minimum, maximum)
Definition: RagTime5StyleManager.hxx:302
std::string m_extra
extra data
Definition: RagTime5StyleManager.hxx:314
int m_justify
justify 0: left, 1:center, 2:right, 3:full, 4:full all
Definition: RagTime5StyleManager.hxx:269
std::shared_ptr< RagTime5StyleManagerInternal::State > m_state
the state
Definition: RagTime5StyleManager.hxx:340
float m_limitPercent
the line limit
Definition: RagTime5StyleManager.hxx:179
friend std::ostream & operator<<(std::ostream &o, TextStyle const &style)
operator<<
Definition: RagTime5StyleManager.cxx:2313
TextStyle & operator=(TextStyle const &)=default
a field of RagTime 5/6 structures
Definition: RagTime5StructManager.hxx:242
double m_columnGap
the gap between columns
Definition: RagTime5StyleManager.hxx:311
std::vector< RagTime5StructManager::TabStop > m_tabList
the tabulations
Definition: RagTime5StyleManager.hxx:279
double m_spacings[3]
the interline/before/after value
Definition: RagTime5StyleManager.hxx:271
a class which stores section properties
Definition: MWAWSection.hxx:45
bool readGraphicStyles(RagTime5ClusterManager::Cluster &cluster)
try to read a main graphic styles
Definition: RagTime5StyleManager.cxx:329
MWAWVariable< float > m_scriptPosition
the font script position ( in percent)
Definition: RagTime5StyleManager.hxx:292
TextStyle()
constructor
Definition: RagTime5StyleManager.hxx:193
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
int m_mitter
the line mitter ( triangle=1, round, out)
Definition: RagTime5StyleManager.hxx:177
static std::string printType(unsigned long fileType)
debug: print a file type
Definition: RagTime5StyleManager.hxx:324
GraphicStyle & operator=(GraphicStyle const &)=default
float m_fontScaling
the font script position ( in percent)
Definition: RagTime5StyleManager.hxx:294
class to store the paragraph properties
Definition: MWAWParagraph.hxx:84
GraphicStyle()
constructor
Definition: RagTime5StyleManager.hxx:116
the main class to read a RagTime v5 file
Definition: RagTime5Document.hxx:76
virtual ~GraphicStyle()
destructor
Definition: RagTime5StyleManager.cxx:1269
float m_colorsAlpha[2]
alpha of the first and second color
Definition: RagTime5StyleManager.hxx:161
bool getCellBorder(int graphicId, MWAWBorder &border) const
returns a cell border
Definition: RagTime5StyleManager.cxx:471
the graphic style of a RagTime v5-v6 document
Definition: RagTime5StyleManager.hxx:114
int m_parentId
the parent id
Definition: RagTime5StyleManager.hxx:155
std::shared_ptr< MWAWGraphicStyle::Pattern > m_pattern
the line pattern
Definition: RagTime5StyleManager.hxx:165
int m_spacingUnits[3]
the interline/before/after unit 0: line, 1:point
Definition: RagTime5StyleManager.hxx:273
virtual ~TextStyle()
destructor
Definition: RagTime5StyleManager.cxx:1691
double m_margins[3]
the spacings in point ( left, right, first)
Definition: RagTime5StyleManager.hxx:277
the text style of a RagTime v5-v6 document
Definition: RagTime5StyleManager.hxx:191
bool isDefault() const
returns true if the line style is default
Definition: RagTime5StyleManager.hxx:225
bool isSet() const
return true if the variable is set
Definition: libmwaw_internal.hxx:635
Internal: the structures of a RagTime5Style.
Definition: RagTime5StyleManager.cxx:52
float m_fontSize
the font size
Definition: RagTime5StyleManager.hxx:288
std::vector< int > m_linkIdList
the link id list
Definition: RagTime5StyleManager.hxx:256
int m_underline
underline : none, single, double
Definition: RagTime5StyleManager.hxx:296
small class which defines a vector with 2 elements
Definition: libmwaw_internal.hxx:655
int m_parentId[2]
the parent id ( main and style ?)
Definition: RagTime5StyleManager.hxx:254
float m_gradientRotation
the gradient rotation(checkme)
Definition: RagTime5StyleManager.hxx:169
int m_position
the line position inside=1/normal/outside/round
Definition: RagTime5StyleManager.hxx:173
the cluster data
Definition: RagTime5ClusterManager.hxx:261

Generated on Thu May 30 2024 13:09:12 for libmwaw by doxygen 1.8.10