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 
53 {
54 struct State;
55 }
56 
57 class RagTime5Parser;
58 
61 {
62  friend class RagTime5Parser;
63 public:
65  explicit RagTime5StyleManager(RagTime5Parser &parser);
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);
79  bool readFormats(RagTime5ClusterManager::Cluster &cluster);
80 
82  bool updateSurfaceStyle(int graphicId, MWAWGraphicStyle &surfaceStyle) const;
84  bool updateBorderStyle(int graphicId, MWAWGraphicStyle &borderStyle, bool isLine) const;
86  bool getLineColor(int graphicId, MWAWColor &color) const;
88  bool updateTextStyles(int textId, MWAWFont &font, MWAWParagraph &para) const;
90  bool getCellBorder(int graphicId, MWAWBorder &border) const;
92  bool getCellBackgroundColor(int graphicId, MWAWColor &color) const;
94  bool updateCellFormat(int formatId, MWAWCell &cell) const;
95 
96 protected:
98  void updateTextStyles(size_t id, RagTime5StyleManager::TextStyle const &style,
99  std::vector<RagTime5StyleManager::TextStyle> const &listReadStyles,
100  std::multimap<size_t, size_t> const &idToChildIpMap,
101  std::set<size_t> &seens);
103  void updateGraphicStyles(size_t id, RagTime5StyleManager::GraphicStyle const &style,
104  std::vector<RagTime5StyleManager::GraphicStyle> const &listReadStyles,
105  std::multimap<size_t, size_t> const &idToChildIpMap,
106  std::set<size_t> &seens);
107 
108 public:
110  struct GraphicStyle {
112  GraphicStyle() : m_parentId(-1000), m_width(-1), m_dash(), m_pattern(), m_gradient(-1), m_gradientRotation(-1000), m_gradientCenter(MWAWVec2f(0.5f,0.5f)),
113  m_position(-1), m_cap(1), m_mitter(-1), m_limitPercent(-1), m_hidden(false), m_extra("")
114  {
117  m_colorsAlpha[0]=m_colorsAlpha[1]=-1;
118  }
120  virtual ~GraphicStyle();
122  bool isDefault() const
123  {
124  return m_parentId<=-1000 && m_width<0 && !m_dash.isSet() && !m_pattern &&
125  m_gradient<0 && m_gradientRotation<=-1000 && !m_gradientCenter.isSet() &&
126  m_position<0 && m_cap<0 && m_mitter<0 &&
127  !m_colors[0].isSet() && !m_colors[1].isSet() && m_colorsAlpha[0]<0 && m_colorsAlpha[1]<0 &&
128  m_limitPercent<0 && !m_hidden.isSet() && m_extra.empty();
129  }
131  friend std::ostream &operator<<(std::ostream &o, GraphicStyle const &style);
133  void insert(GraphicStyle const &childStyle);
135  bool read(MWAWInputStreamPtr &input, RagTime5StructManager::Field const &field, std::vector<MWAWColor> const &colorList);
139  float m_width;
143  float m_colorsAlpha[2];
147  shared_ptr<MWAWGraphicStyle::Pattern> m_pattern;
157  int m_cap;
159  int m_mitter;
165  std::string m_extra;
166  };
168  struct TextStyle {
170  TextStyle() : m_linkIdList(),
171  m_dateStyleId(-1), m_graphStyleId(-1), m_graphLineStyleId(-1), m_keepWithNext(false), m_justify(-1), m_breakMethod(-1), m_tabList(),
172  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),
173  m_numColumns(-1), m_columnGap(-1), m_extra("")
174  {
175  m_parentId[0]=m_parentId[1]=-1;
176  m_fontFlags[0]=m_fontFlags[1]=0;
177  for (int i=0; i<3; ++i) {
178  m_margins[i]=-1;
179  m_spacings[i]=-1;
180  m_spacingUnits[i]=-1;
181  }
182  for (int i=0; i<4; ++i) m_letterSpacings[i]=0;
183  }
185  virtual ~TextStyle();
187  bool isDefault() const
188  {
189  if (m_parentId[0]>=0 || m_parentId[1]>=0 || !m_linkIdList.empty() ||
190  m_dateStyleId>=0 || m_graphStyleId>=0 || m_graphLineStyleId>=0 ||
191  m_keepWithNext.isSet() || m_justify>=0 || m_breakMethod>=0 || !m_tabList.empty() ||
192  !m_fontName.empty() || m_fontId>=0 || m_fontSize>=0 || m_fontFlags[0] || m_fontFlags[1] || m_scriptPosition.isSet() ||
193  m_fontScaling>=0 || m_underline>=0 || m_caps>=0 || m_language>=0 || m_widthStreching>=0 ||
194  m_numColumns>=0 || m_columnGap>=0 || !m_extra.empty())
195  return false;
196  for (int i=0; i<3; ++i) {
197  if (m_margins[i]>=0 || m_spacings[i]>=0 || m_spacingUnits[i]>=0)
198  return false;
199  }
200  for (int i=0; i<4; ++i) {
201  if (m_letterSpacings[i]>0 || m_letterSpacings[i]<0)
202  return false;
203  }
204  return true;
205  }
207  static std::string getLanguageLocale(int id);
208 
210  friend std::ostream &operator<<(std::ostream &o, TextStyle const &style);
212  void insert(TextStyle const &childStyle);
214  bool read(RagTime5StructManager::Field const &field);
216  int m_parentId[2];
218  std::vector<int> m_linkIdList;
225 
226  // paragraph
227 
233  double m_spacings[3];
235  int m_spacingUnits[3];
239  double m_margins[3];
241  std::vector<RagTime5StructManager::TabStop> m_tabList;
242 
243  // character
244 
246  librevenge::RVNGString m_fontName;
248  int m_fontId;
250  float m_fontSize;
252  uint32_t m_fontFlags[2];
260  int m_caps;
264  double m_letterSpacings[4];
267 
268  // column
269 
273  double m_columnGap;
274 
276  std::string m_extra;
277  };
278 
279 protected:
280  //
281  // data
282  //
283 
288 
290  shared_ptr<RagTime5StyleManagerInternal::State> m_state;
291 
292 private:
294  RagTime5StyleManager operator=(RagTime5StyleManager const &orig);
295 };
296 
297 #endif
298 // 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:163
int m_fontId
the font id
Definition: RagTime5StyleManager.hxx:248
int m_caps
caps : none, all caps, lower caps, inital caps + other lowers
Definition: RagTime5StyleManager.hxx:260
int m_gradient
the gradient 0: none, normal, radial
Definition: RagTime5StyleManager.hxx:149
std::string m_extra
extra data
Definition: RagTime5StyleManager.hxx:165
std::ostream & operator<<(std::ostream &o, Shape const &shape)
Definition: BeagleWksDRParser.cxx:98
MWAWVariable< std::vector< long > > m_dash
the line dash/...
Definition: RagTime5StyleManager.hxx:145
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:245
MWAWVariable< MWAWVec2f > m_gradientCenter
the rotation center(checkme)
Definition: RagTime5StyleManager.hxx:153
int m_graphLineStyleId
the graphic line style id
Definition: RagTime5StyleManager.hxx:224
static MWAWColor black()
return the back color
Definition: libmwaw_internal.hxx:240
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
int m_numColumns
the number of columns
Definition: RagTime5StyleManager.hxx:271
librevenge::RVNGString m_fontName
the font name
Definition: RagTime5StyleManager.hxx:246
basic class used to read/store RagTime 5/6 styles
Definition: RagTime5StyleManager.hxx:60
int m_breakMethod
the break method 0: asIs, next container, next page, next even page, next odd page ...
Definition: RagTime5StyleManager.hxx:237
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
the class to store a color
Definition: libmwaw_internal.hxx:196
int m_dateStyleId
the date style id
Definition: RagTime5StyleManager.hxx:220
int m_language
the language
Definition: RagTime5StyleManager.hxx:262
int m_graphStyleId
the graphic style id
Definition: RagTime5StyleManager.hxx:222
bool isDefault() const
returns true if the line style is default
Definition: RagTime5StyleManager.hxx:187
MWAWParserStatePtr m_parserState
the parser state
Definition: RagTime5StyleManager.hxx:287
MWAWVariable< bool > m_keepWithNext
the keep with next flag
Definition: RagTime5StyleManager.hxx:229
Class to store font.
Definition: MWAWFont.hxx:43
a border
Definition: libmwaw_internal.hxx:328
float m_width
the line width (in point)
Definition: RagTime5StyleManager.hxx:139
int m_cap
the line caps ( normal=1, round, square)
Definition: RagTime5StyleManager.hxx:157
double m_widthStreching
the width streching
Definition: RagTime5StyleManager.hxx:266
std::string m_extra
extra data
Definition: RagTime5StyleManager.hxx:276
int m_justify
justify 0: left, 1:center, 2:right, 3:full, 4:full all
Definition: RagTime5StyleManager.hxx:231
float m_limitPercent
the line limit
Definition: RagTime5StyleManager.hxx:161
the main class to read a RagTime v5 file
Definition: RagTime5Parser.hxx:73
a field of RagTime 5/6 structures
Definition: RagTime5StructManager.hxx:218
double m_columnGap
the gap between columns
Definition: RagTime5StyleManager.hxx:273
friend class RagTime5StyleManager
Definition: RagTime5Parser.hxx:83
std::vector< RagTime5StructManager::TabStop > m_tabList
the tabulations
Definition: RagTime5StyleManager.hxx:241
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:517
MWAWVariable< float > m_scriptPosition
the font script position ( in percent)
Definition: RagTime5StyleManager.hxx:254
TextStyle()
constructor
Definition: RagTime5StyleManager.hxx:170
shared_ptr< MWAWGraphicStyle::Pattern > m_pattern
the line pattern
Definition: RagTime5StyleManager.hxx:147
int m_mitter
the line mitter ( triangle=1, round, out)
Definition: RagTime5StyleManager.hxx:159
float m_fontScaling
the font script position ( in percent)
Definition: RagTime5StyleManager.hxx:256
class to store the paragraph properties
Definition: MWAWParagraph.hxx:81
GraphicStyle()
constructor
Definition: RagTime5StyleManager.hxx:112
RagTime5Parser & m_mainParser
the parser
Definition: RagTime5StyleManager.hxx:285
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:523
bool isDefault() const
returns true if the line style is default
Definition: RagTime5StyleManager.hxx:122
the graphic style of a RagTime v5-v6 document
Definition: RagTime5StyleManager.hxx:110
int m_parentId
the parent id
Definition: RagTime5StyleManager.hxx:137
the text style of a RagTime v5-v6 document
Definition: RagTime5StyleManager.hxx:168
Internal: the structures of a RagTime5Style.
Definition: RagTime5StyleManager.cxx:51
shared_ptr< RagTime5StyleManagerInternal::State > m_state
the state
Definition: RagTime5StyleManager.hxx:290
float m_fontSize
the font size
Definition: RagTime5StyleManager.hxx:250
std::vector< int > m_linkIdList
the link id list
Definition: RagTime5StyleManager.hxx:218
int m_underline
underline : none, single, double
Definition: RagTime5StyleManager.hxx:258
float m_gradientRotation
the gradient rotation(checkme)
Definition: RagTime5StyleManager.hxx:151
int m_position
the line position inside=1/normal/outside/round
Definition: RagTime5StyleManager.hxx:155
the cluster data
Definition: RagTime5ClusterManager.hxx:216

Generated on Sat Jul 29 2017 11:22:56 for libmwaw by doxygen 1.8.13