VSDXStyles.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libvisio
3  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License or as specified alternatively below. You may obtain a copy of
8  * the License at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * Major Contributor(s):
16  * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch>
17  * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com>
18  *
19  *
20  * All Rights Reserved.
21  *
22  * For minor contributions see the git repository.
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
26  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
27  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
28  * instead of those above.
29  */
30 
31 #ifndef __VSDXSTYLES_H__
32 #define __VSDXSTYLES_H__
33 
34 #include <map>
35 #include <vector>
36 #include <libwpg/libwpg.h>
37 #include "VSDXTypes.h"
38 
39 namespace libvisio
40 {
41 
43 {
45  : width(0.01), colour(), pattern(0), startMarker(0), endMarker(0), cap(0) {}
46  VSDXLineStyle(double w, Colour col, unsigned char p, unsigned char sm,
47  unsigned char em, unsigned char c)
48  : width(w), colour(col), pattern(p), startMarker(sm), endMarker(em), cap(c) {}
49  VSDXLineStyle(const VSDXLineStyle &lineStyle)
50  : width(lineStyle.width), colour(lineStyle.colour), pattern(lineStyle.pattern), startMarker(lineStyle.startMarker), endMarker(lineStyle.endMarker), cap(lineStyle.cap) {}
52  double width;
54  unsigned char pattern;
55  unsigned char startMarker;
56  unsigned char endMarker;
57  unsigned char cap;
58 };
59 
61 {
64  VSDXFillStyle(unsigned char fgcId, unsigned char bgcId, unsigned char p, unsigned char fga, unsigned char bga, Colour sfgc, unsigned char shp, double shX, double shY)
65  : fgColourId(fgcId), bgColourId(bgcId), pattern(p), fgTransparency(fga), bgTransparency(bga), shadowFgColour(sfgc), shadowPattern(shp), shadowOffsetX(shX), shadowOffsetY(shY) {}
66  VSDXFillStyle(const VSDXFillStyle &fillStyle)
67  : fgColourId(fillStyle.fgColourId), bgColourId(fillStyle.bgColourId), pattern(fillStyle.pattern),
71  unsigned char fgColourId;
72  // Colour fgColour;
73  unsigned char bgColourId;
74  // Colour bgColour;
75  unsigned char pattern;
76 
77  unsigned char fgTransparency;
78  unsigned char bgTransparency;
79 
81  unsigned char shadowPattern;
82  double shadowOffsetX;
83  double shadowOffsetY;
84 };
85 
87 {
89  charCount(0),
90  faceID(0),
91  colour(),
92  langID(0),
93  size(12.0/72.0),
94  bold(false),
95  italic(false),
96  underline(false),
97  doubleunderline(false),
98  strikeout(false),
99  doublestrikeout(false),
100  allcaps(false),
101  initcaps(false),
102  smallcaps(false),
103  superscript(false),
104  subscript(false),
105  face("Arial") {}
106  VSDXCharStyle(unsigned cc, unsigned short id, Colour c, unsigned lang, double s, bool b, bool i, bool u, bool du, bool so, bool dso, bool ac, bool ic, bool sc, bool super, bool sub, WPXString f) :
107  charCount(cc),
108  faceID(id),
109  colour(c),
110  langID(lang),
111  size(s),
112  bold(b),
113  italic(i),
114  underline(u),
115  doubleunderline(du),
116  strikeout(so),
117  doublestrikeout(dso),
118  allcaps(ac),
119  initcaps(ic),
120  smallcaps(sc),
121  superscript(super),
122  subscript(sub),
123  face(f) {}
125  unsigned charCount;
126  unsigned short faceID;
128  unsigned langID;
129  double size;
130  bool bold;
131  bool italic;
132  bool underline;
134  bool strikeout;
136  bool allcaps;
137  bool initcaps;
138  bool smallcaps;
140  bool subscript;
141  WPXString face;
142 };
143 
145 {
147  charCount(0),
148  indFirst(0.0),
149  indLeft(0.0),
150  indRight(0.0),
151  spLine(-1.2),
152  spBefore(0.0),
153  spAfter(0.0),
154  align(1),
155  flags(0) {}
156  VSDXParaStyle(unsigned cc, double ifst, double il, double ir, double sl, double sb, double sa, unsigned char a, unsigned f) :
157  charCount(cc),
158  indFirst(ifst),
159  indLeft(il),
160  indRight(ir),
161  spLine(sl),
162  spBefore(sb),
163  spAfter(sa),
164  align(a),
165  flags(f) {}
167  unsigned charCount;
168  double indFirst;
169  double indLeft;
170  double indRight;
171  double spLine;
172  double spBefore;
173  double spAfter;
174  unsigned char align;
175  unsigned flags;
176 };
177 
179 {
181  leftMargin(0.0),
182  rightMargin(0.0),
183  topMargin(0.0),
184  bottomMargin(0.0),
185  verticalAlign(0),
187  textBkgndColour(0xff,0xff,0xff,0),
188  defaultTabStop(0.5),
189  textDirection(0) {}
190  VSDXTextBlockStyle(double lm, double rm, double tm, double bm, unsigned char va, unsigned char bgClrId, Colour bgClr, double defTab, unsigned char td) :
191  leftMargin(lm),
192  rightMargin(rm),
193  topMargin(tm),
194  bottomMargin(bm),
195  verticalAlign(va),
196  textBkgndColourId(bgClrId),
197  textBkgndColour(bgClr),
198  defaultTabStop(defTab),
199  textDirection(td) {}
201  double leftMargin;
202  double rightMargin;
203  double topMargin;
204  double bottomMargin;
205  unsigned char verticalAlign;
206  unsigned char textBkgndColourId;
209  unsigned char textDirection;
210 };
211 
213 {
214 public:
215  VSDXStyles();
216  VSDXStyles(const VSDXStyles &styles);
217  ~VSDXStyles();
218  VSDXStyles &operator=(const VSDXStyles &styles);
219  void addLineStyle(unsigned lineStyleIndex, VSDXLineStyle *lineStyle);
220  void addFillStyle(unsigned fillStyleIndex, VSDXFillStyle *fillStyle);
221  void addTextBlockStyle(unsigned textStyleIndex, VSDXTextBlockStyle *textBlockStyle);
222  void addCharStyle(unsigned textStyleIndex, VSDXCharStyle *charStyle);
223  void addParaStyle(unsigned textStyleIndex, VSDXParaStyle *paraStyle);
224 
225  void addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster);
226  void addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster);
227  void addTextStyleMaster(unsigned textStyleIndex, unsigned textStyleMaster);
228 
229  const VSDXLineStyle *getLineStyle(unsigned lineStyleIndex) const;
230  const VSDXFillStyle *getFillStyle(unsigned fillStyleIndex) const;
231  const VSDXTextBlockStyle *getTextBlockStyle(unsigned textStyleIndex) const;
232  const VSDXCharStyle *getCharStyle(unsigned textStyleIndex) const;
233  const VSDXParaStyle *getParaStyle(unsigned textStyleIndex) const;
234 
235 private:
236  std::map<unsigned, VSDXLineStyle *> m_lineStyles;
237  std::map<unsigned, VSDXFillStyle *> m_fillStyles;
238  std::map<unsigned, VSDXTextBlockStyle *> m_textBlockStyles;
239  std::map<unsigned, VSDXCharStyle *> m_charStyles;
240  std::map<unsigned, VSDXParaStyle *> m_paraStyles;
241  std::map<unsigned, unsigned> m_lineStyleMasters;
242  std::map<unsigned, unsigned> m_fillStyleMasters;
243  std::map<unsigned, unsigned> m_textStyleMasters;
244 };
245 
246 
247 } // namespace libvisio
248 
249 #endif // __VSDXSTYLES_H__
250 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.1