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  size(12.0/72.0),
93  bold(false),
94  italic(false),
95  underline(false),
96  doubleunderline(false),
97  strikeout(false),
98  doublestrikeout(false),
99  allcaps(false),
100  initcaps(false),
101  smallcaps(false),
102  superscript(false),
103  subscript(false),
104  face() {}
105  VSDXCharStyle(unsigned cc, unsigned short id, Colour c, double s, bool b, bool i, bool u, bool du, bool so, bool dso, bool ac, bool ic, bool sc, bool super, bool sub, VSDXFont f) :
106  charCount(cc),
107  faceID(id),
108  colour(c),
109  size(s),
110  bold(b),
111  italic(i),
112  underline(u),
113  doubleunderline(du),
114  strikeout(so),
115  doublestrikeout(dso),
116  allcaps(ac),
117  initcaps(ic),
118  smallcaps(sc),
119  superscript(super),
120  subscript(sub),
121  face(f) {}
123  unsigned charCount;
124  unsigned short faceID;
126  double size;
127  bool bold;
128  bool italic;
129  bool underline;
131  bool strikeout;
133  bool allcaps;
134  bool initcaps;
135  bool smallcaps;
137  bool subscript;
139 };
140 
142 {
144  charCount(0),
145  indFirst(0.0),
146  indLeft(0.0),
147  indRight(0.0),
148  spLine(-1.2),
149  spBefore(0.0),
150  spAfter(0.0),
151  align(1),
152  flags(0) {}
153  VSDXParaStyle(unsigned cc, double ifst, double il, double ir, double sl, double sb, double sa, unsigned char a, unsigned f) :
154  charCount(cc),
155  indFirst(ifst),
156  indLeft(il),
157  indRight(ir),
158  spLine(sl),
159  spBefore(sb),
160  spAfter(sa),
161  align(a),
162  flags(f) {}
164  unsigned charCount;
165  double indFirst;
166  double indLeft;
167  double indRight;
168  double spLine;
169  double spBefore;
170  double spAfter;
171  unsigned char align;
172  unsigned flags;
173 };
174 
176 {
178  leftMargin(0.0),
179  rightMargin(0.0),
180  topMargin(0.0),
181  bottomMargin(0.0),
182  verticalAlign(0),
184  textBkgndColour(0xff,0xff,0xff,0),
185  defaultTabStop(0.5),
186  textDirection(0) {}
187  VSDXTextBlockStyle(double lm, double rm, double tm, double bm, unsigned char va, unsigned char bgClrId, Colour bgClr, double defTab, unsigned char td) :
188  leftMargin(lm),
189  rightMargin(rm),
190  topMargin(tm),
191  bottomMargin(bm),
192  verticalAlign(va),
193  textBkgndColourId(bgClrId),
194  textBkgndColour(bgClr),
195  defaultTabStop(defTab),
196  textDirection(td) {}
198  double leftMargin;
199  double rightMargin;
200  double topMargin;
201  double bottomMargin;
202  unsigned char verticalAlign;
203  unsigned char textBkgndColourId;
206  unsigned char textDirection;
207 };
208 
210 {
211 public:
212  VSDXStyles();
213  VSDXStyles(const VSDXStyles &styles);
214  ~VSDXStyles();
215  VSDXStyles &operator=(const VSDXStyles &styles);
216  void addLineStyle(unsigned lineStyleIndex, VSDXLineStyle *lineStyle);
217  void addFillStyle(unsigned fillStyleIndex, VSDXFillStyle *fillStyle);
218  void addTextBlockStyle(unsigned textStyleIndex, VSDXTextBlockStyle *textBlockStyle);
219  void addCharStyle(unsigned textStyleIndex, VSDXCharStyle *charStyle);
220  void addParaStyle(unsigned textStyleIndex, VSDXParaStyle *paraStyle);
221 
222  void addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster);
223  void addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster);
224  void addTextStyleMaster(unsigned textStyleIndex, unsigned textStyleMaster);
225 
226  const VSDXLineStyle *getLineStyle(unsigned lineStyleIndex) const;
227  const VSDXFillStyle *getFillStyle(unsigned fillStyleIndex) const;
228  const VSDXTextBlockStyle *getTextBlockStyle(unsigned textStyleIndex) const;
229  const VSDXCharStyle *getCharStyle(unsigned textStyleIndex) const;
230  const VSDXParaStyle *getParaStyle(unsigned textStyleIndex) const;
231 
232 private:
233  std::map<unsigned, VSDXLineStyle *> m_lineStyles;
234  std::map<unsigned, VSDXFillStyle *> m_fillStyles;
235  std::map<unsigned, VSDXTextBlockStyle *> m_textBlockStyles;
236  std::map<unsigned, VSDXCharStyle *> m_charStyles;
237  std::map<unsigned, VSDXParaStyle *> m_paraStyles;
238  std::map<unsigned, unsigned> m_lineStyleMasters;
239  std::map<unsigned, unsigned> m_fillStyleMasters;
240  std::map<unsigned, unsigned> m_textStyleMasters;
241 };
242 
243 
244 } // namespace libvisio
245 
246 #endif // __VSDXSTYLES_H__
247 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.1