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) {}
50  double width;
52  unsigned char pattern;
53  unsigned char startMarker;
54  unsigned char endMarker;
55  unsigned char cap;
56 };
57 
59 {
62  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)
63  : fgColourId(fgcId), bgColourId(bgcId), pattern(p), fgTransparency(fga), bgTransparency(bga), shadowFgColour(sfgc), shadowPattern(shp), shadowOffsetX(shX), shadowOffsetY(shY) {}
65  unsigned char fgColourId;
66  // Colour fgColour;
67  unsigned char bgColourId;
68  // Colour bgColour;
69  unsigned char pattern;
70 
71  unsigned char fgTransparency;
72  unsigned char bgTransparency;
73 
75  unsigned char shadowPattern;
76  double shadowOffsetX;
77  double shadowOffsetY;
78 };
79 
81 {
83  charCount(0),
84  faceID(0),
85  colour(),
86  size(12.0/72.0),
87  bold(false),
88  italic(false),
89  underline(false),
90  doubleunderline(false),
91  strikeout(false),
92  doublestrikeout(false),
93  allcaps(false),
94  initcaps(false),
95  smallcaps(false),
96  superscript(false),
97  subscript(false),
98  face() {}
99  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) :
100  charCount(cc),
101  faceID(id),
102  colour(c),
103  size(s),
104  bold(b),
105  italic(i),
106  underline(u),
107  doubleunderline(du),
108  strikeout(so),
109  doublestrikeout(dso),
110  allcaps(ac),
111  initcaps(ic),
112  smallcaps(sc),
113  superscript(super),
114  subscript(sub),
115  face(f) {}
117  unsigned charCount;
118  unsigned short faceID;
120  double size;
121  bool bold;
122  bool italic;
123  bool underline;
125  bool strikeout;
127  bool allcaps;
128  bool initcaps;
129  bool smallcaps;
131  bool subscript;
133 };
134 
136 {
138  charCount(0),
139  indFirst(0.0),
140  indLeft(0.0),
141  indRight(0.0),
142  spLine(-1.2),
143  spBefore(0.0),
144  spAfter(0.0),
145  align(1),
146  flags(0) {}
147  VSDXParaStyle(unsigned cc, double ifst, double il, double ir, double sl, double sb, double sa, unsigned char a, unsigned f) :
148  charCount(cc),
149  indFirst(ifst),
150  indLeft(il),
151  indRight(ir),
152  spLine(sl),
153  spBefore(sb),
154  spAfter(sa),
155  align(a),
156  flags(f) {}
158  unsigned charCount;
159  double indFirst;
160  double indLeft;
161  double indRight;
162  double spLine;
163  double spBefore;
164  double spAfter;
165  unsigned char align;
166  unsigned flags;
167 };
168 
170 {
172  leftMargin(0.0),
173  rightMargin(0.0),
174  topMargin(0.0),
175  bottomMargin(0.0),
176  verticalAlign(0),
178  textBkgndColour(0xff,0xff,0xff,0),
179  defaultTabStop(0.5),
180  textDirection(0) {}
181  VSDXTextBlockStyle(double lm, double rm, double tm, double bm, unsigned char va, unsigned char bgClrId, Colour bgClr, double defTab, unsigned char td) :
182  leftMargin(lm),
183  rightMargin(rm),
184  topMargin(tm),
185  bottomMargin(bm),
186  verticalAlign(va),
187  textBkgndColourId(bgClrId),
188  textBkgndColour(bgClr),
189  defaultTabStop(defTab),
190  textDirection(td) {}
192  double leftMargin;
193  double rightMargin;
194  double topMargin;
195  double bottomMargin;
196  unsigned char verticalAlign;
197  unsigned char textBkgndColourId;
200  unsigned char textDirection;
201 };
202 
204 {
205 public:
206  VSDXStyles();
207  VSDXStyles(const VSDXStyles &styles);
208  ~VSDXStyles();
209  VSDXStyles &operator=(const VSDXStyles &styles);
210  void addLineStyle(unsigned lineStyleIndex, VSDXLineStyle *lineStyle);
211  void addFillStyle(unsigned fillStyleIndex, VSDXFillStyle *fillStyle);
212  void addTextBlockStyle(unsigned textStyleIndex, VSDXTextBlockStyle *textBlockStyle);
213  void addCharStyle(unsigned textStyleIndex, VSDXCharStyle *charStyle);
214  void addParaStyle(unsigned textStyleIndex, VSDXParaStyle *paraStyle);
215 
216  void addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster);
217  void addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster);
218  void addTextStyleMaster(unsigned textStyleIndex, unsigned textStyleMaster);
219 
220  const VSDXLineStyle *getLineStyle(unsigned lineStyleIndex) const;
221  const VSDXFillStyle *getFillStyle(unsigned fillStyleIndex) const;
222  const VSDXTextBlockStyle *getTextBlockStyle(unsigned textStyleIndex) const;
223  const VSDXCharStyle *getCharStyle(unsigned textStyleIndex) const;
224  const VSDXParaStyle *getParaStyle(unsigned textStyleIndex) const;
225 
226 private:
227  std::map<unsigned, VSDXLineStyle *> m_lineStyles;
228  std::map<unsigned, VSDXFillStyle *> m_fillStyles;
229  std::map<unsigned, VSDXTextBlockStyle *> m_textBlockStyles;
230  std::map<unsigned, VSDXCharStyle *> m_charStyles;
231  std::map<unsigned, VSDXParaStyle *> m_paraStyles;
232  std::map<unsigned, unsigned> m_lineStyleMasters;
233  std::map<unsigned, unsigned> m_fillStyleMasters;
234  std::map<unsigned, unsigned> m_textStyleMasters;
235 };
236 
237 
238 } // namespace libvisio
239 
240 #endif // __VSDXSTYLES_H__
241 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.1.2