VSDStylesCollector.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 VSDSTYLESCOLLECTOR_H
32 #define VSDSTYLESCOLLECTOR_H
33 
34 #include <map>
35 #include <vector>
36 #include <list>
37 #include "VSDCollector.h"
38 #include "VSDParser.h"
39 #include "libvisio_utils.h"
40 #include "VSDStyles.h"
41 
42 namespace libvisio
43 {
44 
46 {
47 public:
49  std::vector<std::map<unsigned, XForm> > &groupXFormsSequence,
50  std::vector<std::map<unsigned, unsigned> > &groupMembershipsSequence,
51  std::vector<std::list<unsigned> > &documentPageShapeOrders
52  );
53  virtual ~VSDStylesCollector() {}
54 
55  void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc);
56  void collectForeignData(unsigned level, const WPXBinaryData &binaryData);
57  void collectOLEList(unsigned id, unsigned level)
58  {
59  collectUnhandledChunk(id, level);
60  }
61  void collectOLEData(unsigned id, unsigned level, const WPXBinaryData &oleData);
62  void collectEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop);
63  void collectLine(unsigned level, const boost::optional<double> &strokeWidth, const boost::optional<Colour> &c, const boost::optional<unsigned char> &linePattern,
64  const boost::optional<unsigned char> &startMarker, const boost::optional<unsigned char> &endMarker,
65  const boost::optional<unsigned char> &lineCap);
66  void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
67  const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
68  const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
69  const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY);
70  void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
71  const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
72  const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
73  const boost::optional<Colour> &shfgc);
74  void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow);
75  void collectMoveTo(unsigned id, unsigned level, double x, double y);
76  void collectLineTo(unsigned id, unsigned level, double x, double y);
77  void collectArcTo(unsigned id, unsigned level, double x2, double y2, double bow);
78  void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType,
79  unsigned degree, std::vector<std::pair<double, double> > controlPoints,
80  std::vector<double> knotVector, std::vector<double> weights);
81  void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID);
82  void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, const NURBSData &data);
83  void collectPolylineTo(unsigned id, unsigned level, double x, double y, unsigned char xType, unsigned char yType, const std::vector<std::pair<double, double> > &points);
84  void collectPolylineTo(unsigned id, unsigned level, double x, double y, unsigned dataID);
85  void collectPolylineTo(unsigned id, unsigned level, double x, double y, const PolylineData &data);
86  void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, unsigned degree, double lastKnot,
87  std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights);
88  void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points);
89  void collectXFormData(unsigned level, const XForm &xform);
90  void collectTxtXForm(unsigned level, const XForm &txtxform);
91  void collectShapesOrder(unsigned id, unsigned level, const std::vector<unsigned> &shapeIds);
92  void collectForeignDataType(unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height);
93  void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale);
94  void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage, const VSDName &pageName);
95  void collectShape(unsigned id, unsigned level, unsigned parent, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle);
96  void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree);
97  void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot);
98  void collectSplineEnd();
99  void collectInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2);
100  void collectRelCubBezTo(unsigned id, unsigned level, double x, double y, double a, double b, double c, double d);
101  void collectRelEllipticalArcTo(unsigned id, unsigned level, double x, double y, double a, double b, double c, double d);
102  void collectRelLineTo(unsigned id, unsigned level, double x, double y);
103  void collectRelMoveTo(unsigned id, unsigned level, double x, double y);
104  void collectRelQuadBezTo(unsigned id, unsigned level, double x, double y, double a, double b);
105  void collectUnhandledChunk(unsigned id, unsigned level);
106 
107  void collectText(unsigned level, const ::WPXBinaryData &textStream, TextFormat format);
108  void collectCharIX(unsigned id, unsigned level, unsigned charCount, const boost::optional<VSDName> &font,
109  const boost::optional<Colour> &fontColour, const boost::optional<double> &fontSize, const boost::optional<bool> &bold,
110  const boost::optional<bool> &italic, const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline,
111  const boost::optional<bool> &strikeout, const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps,
112  const boost::optional<bool> &initcaps, const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript,
113  const boost::optional<bool> &subscript);
114  void collectDefaultCharStyle(unsigned charCount, const boost::optional<VSDName> &font, const boost::optional<Colour> &fontColour,
115  const boost::optional<double> &fontSize, const boost::optional<bool> &bold, const boost::optional<bool> &italic,
116  const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline, const boost::optional<bool> &strikeout,
117  const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps, const boost::optional<bool> &initcaps,
118  const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript, const boost::optional<bool> &subscript);
119  void collectParaIX(unsigned id, unsigned level, unsigned charCount, const boost::optional<double> &indFirst,
120  const boost::optional<double> &indLeft, const boost::optional<double> &indRight, const boost::optional<double> &spLine,
121  const boost::optional<double> &spBefore, const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align,
122  const boost::optional<unsigned> &flags);
123  void collectDefaultParaStyle(unsigned charCount, const boost::optional<double> &indFirst, const boost::optional<double> &indLeft,
124  const boost::optional<double> &indRight, const boost::optional<double> &spLine, const boost::optional<double> &spBefore,
125  const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align, const boost::optional<unsigned> &flags);
126  void collectTextBlock(unsigned level, const boost::optional<double> &leftMargin, const boost::optional<double> &rightMargin,
127  const boost::optional<double> &topMargin, const boost::optional<double> &bottomMargin,
128  const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
129  const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
130  const boost::optional<unsigned char> &textDirection);
131  void collectNameList(unsigned id, unsigned level)
132  {
133  collectUnhandledChunk(id, level);
134  }
135  void collectName(unsigned id, unsigned level, const ::WPXBinaryData &name, TextFormat format);
136  void collectPageSheet(unsigned id, unsigned level);
137  void collectMisc(unsigned level, const VSDMisc &misc);
138 
139  // Style collectors
140  void collectStyleSheet(unsigned id, unsigned level,unsigned parentLineStyle, unsigned parentFillStyle, unsigned parentTextStyle);
141  void collectLineStyle(unsigned level, const boost::optional<double> &strokeWidth, const boost::optional<Colour> &c, const boost::optional<unsigned char> &linePattern,
142  const boost::optional<unsigned char> &startMarker, const boost::optional<unsigned char> &endMarker,
143  const boost::optional<unsigned char> &lineCap);
144  void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
145  const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
146  const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
147  const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY);
148  void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
149  const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
150  const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
151  const boost::optional<Colour> &shfgc);
152  void collectCharIXStyle(unsigned id, unsigned level, unsigned charCount, const boost::optional<VSDName> &font,
153  const boost::optional<Colour> &fontColour, const boost::optional<double> &fontSize, const boost::optional<bool> &bold,
154  const boost::optional<bool> &italic, const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline,
155  const boost::optional<bool> &strikeout, const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps,
156  const boost::optional<bool> &initcaps, const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript,
157  const boost::optional<bool> &subscript);
158  void collectParaIXStyle(unsigned id, unsigned level, unsigned charCount, const boost::optional<double> &indFirst,
159  const boost::optional<double> &indLeft, const boost::optional<double> &indRight, const boost::optional<double> &spLine,
160  const boost::optional<double> &spBefore, const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align,
161  const boost::optional<unsigned> &flags);
162  void collectTextBlockStyle(unsigned level, const boost::optional<double> &leftMargin, const boost::optional<double> &rightMargin,
163  const boost::optional<double> &topMargin, const boost::optional<double> &bottomMargin,
164  const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
165  const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
166  const boost::optional<unsigned char> &textDirection);
167 
168  // Field list
169  void collectFieldList(unsigned id, unsigned level);
170  void collectTextField(unsigned id, unsigned level, int nameId, int formatStringId);
171  void collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId);
172 
173  // Temporary hack
174  void startPage(unsigned pageID);
175  void endPage();
176  void endPages() {}
177 
178  const VSDStyles &getStyleSheets() const
179  {
180  return m_styles;
181  }
182 
183 
184 private:
187 
188  void _handleLevelChange(unsigned level);
189  void _flushShapeList();
190 
191  unsigned m_currentLevel;
193 
196 
198  std::map<unsigned, XForm> m_groupXForms;
199  std::map<unsigned, unsigned> m_groupMemberships;
200  std::vector<std::map<unsigned, XForm> > &m_groupXFormsSequence;
201  std::vector<std::map<unsigned, unsigned> > &m_groupMembershipsSequence;
202  std::list<unsigned> m_pageShapeOrder;
203  std::vector<std::list<unsigned> > &m_documentPageShapeOrders;
204  std::map<unsigned, std::list<unsigned> > m_groupShapeOrder;
205  std::list<unsigned> m_shapeList;
206 
209 
211 };
212 
213 }
214 
215 #endif /* VSDSTYLESCOLLECTOR_H */
216 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.1.2