1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libvisio project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include "VSDStylesCollector.h"
11 
12 #include <vector>
13 #include <map>
14 
VSDStylesCollector(std::vector<std::map<unsigned,XForm>> & groupXFormsSequence,std::vector<std::map<unsigned,unsigned>> & groupMembershipsSequence,std::vector<std::list<unsigned>> & documentPageShapeOrders)15 libvisio::VSDStylesCollector::VSDStylesCollector(
16   std::vector<std::map<unsigned, XForm> > &groupXFormsSequence,
17   std::vector<std::map<unsigned, unsigned> > &groupMembershipsSequence,
18   std::vector<std::list<unsigned> > &documentPageShapeOrders
19 ) :
20   m_currentLevel(0), m_isShapeStarted(false),
21   m_shadowOffsetX(0.0), m_shadowOffsetY(0.0),
22   m_currentShapeId(0), m_groupXForms(), m_groupMemberships(),
23   m_groupXFormsSequence(groupXFormsSequence),
24   m_groupMembershipsSequence(groupMembershipsSequence),
25   m_pageShapeOrder(), m_documentPageShapeOrders(documentPageShapeOrders),
26   m_groupShapeOrder(), m_shapeList(), m_currentStyleSheet(0), m_styles(),
27   m_currentShapeLevel(0)
28 {
29   m_groupXFormsSequence.clear();
30   m_groupMembershipsSequence.clear();
31   m_documentPageShapeOrders.clear();
32 }
33 
collectEllipticalArcTo(unsigned,unsigned level,double,double,double,double,double,double)34 void libvisio::VSDStylesCollector::collectEllipticalArcTo(unsigned /* id */, unsigned level, double /* x3 */, double /* y3 */,
35                                                           double /* x2 */, double /* y2 */, double /* angle */, double /* ecc */)
36 {
37   _handleLevelChange(level);
38 }
39 
collectForeignData(unsigned level,const librevenge::RVNGBinaryData &)40 void libvisio::VSDStylesCollector::collectForeignData(unsigned level, const librevenge::RVNGBinaryData & /* binaryData */)
41 {
42   _handleLevelChange(level);
43 }
44 
collectOLEData(unsigned,unsigned level,const librevenge::RVNGBinaryData &)45 void libvisio::VSDStylesCollector::collectOLEData(unsigned /* id */, unsigned level, const librevenge::RVNGBinaryData & /* oleData */)
46 {
47   _handleLevelChange(level);
48 }
49 
collectEllipse(unsigned,unsigned level,double,double,double,double,double,double)50 void libvisio::VSDStylesCollector::collectEllipse(unsigned /* id */, unsigned level, double /* cx */, double /* cy */,
51                                                   double /* xleft */, double /* yleft */, double /* xtop */, double /* ytop */)
52 {
53   _handleLevelChange(level);
54 }
55 
collectLine(unsigned level,const boost::optional<double> &,const boost::optional<Colour> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<double> &,const boost::optional<long> &,const boost::optional<long> &)56 void libvisio::VSDStylesCollector::collectLine(unsigned level, const boost::optional<double> & /* strokeWidth */,
57                                                const boost::optional<Colour> & /* c */, const boost::optional<unsigned char> & /* linePattern */,
58                                                const boost::optional<unsigned char> & /* startMarker */, const boost::optional<unsigned char> & /* endMarker */,
59                                                const boost::optional<unsigned char> & /* lineCap */, const boost::optional<double> & /* rounding */,
60                                                const boost::optional<long> & /* qsLineColour */, const boost::optional<long> & /* qsLineMatrix */)
61 {
62   _handleLevelChange(level);
63 }
64 
collectFillAndShadow(unsigned level,const boost::optional<Colour> &,const boost::optional<Colour> &,const boost::optional<unsigned char> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<Colour> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<long> &,const boost::optional<long> &,const boost::optional<long> &)65 void libvisio::VSDStylesCollector::collectFillAndShadow(unsigned level, const boost::optional<Colour> & /* colourFG */, const boost::optional<Colour> & /* colourBG */,
66                                                         const boost::optional<unsigned char> & /* fillPattern */, const boost::optional<double> & /* fillFGTransparency */,
67                                                         const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */,
68                                                         const boost::optional<Colour> & /* shfgc */, const boost::optional<double> & /* shadowOffsetX */,
69                                                         const boost::optional<double> & /* shadowOffsetY */, const boost::optional<long> & /* qsFillColour */,
70                                                         const boost::optional<long> & /* qsShadowColour */, const boost::optional<long> & /* qsFillMatrix */)
71 {
72   _handleLevelChange(level);
73 }
74 
collectFillAndShadow(unsigned level,const boost::optional<Colour> &,const boost::optional<Colour> &,const boost::optional<unsigned char> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<Colour> &)75 void libvisio::VSDStylesCollector::collectFillAndShadow(unsigned level, const boost::optional<Colour> & /* colourFG */, const boost::optional<Colour> & /* colourBG */,
76                                                         const boost::optional<unsigned char> & /* fillPattern */, const boost::optional<double> & /* fillFGTransparency */,
77                                                         const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */,
78                                                         const boost::optional<Colour> & /* shfgc */)
79 {
80   _handleLevelChange(level);
81 }
82 
collectGeometry(unsigned,unsigned level,bool,bool,bool)83 void libvisio::VSDStylesCollector::collectGeometry(unsigned /* id */, unsigned level, bool /* noFill */, bool /* noLine */, bool /* noShow */)
84 {
85   _handleLevelChange(level);
86 }
87 
collectMoveTo(unsigned,unsigned level,double,double)88 void libvisio::VSDStylesCollector::collectMoveTo(unsigned /* id */, unsigned level, double /* x */, double /* y */)
89 {
90   _handleLevelChange(level);
91 }
92 
collectLineTo(unsigned,unsigned level,double,double)93 void libvisio::VSDStylesCollector::collectLineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */)
94 {
95   _handleLevelChange(level);
96 }
97 
collectArcTo(unsigned,unsigned level,double,double,double)98 void libvisio::VSDStylesCollector::collectArcTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, double /* bow */)
99 {
100   _handleLevelChange(level);
101 }
102 
collectNURBSTo(unsigned,unsigned level,double,double,unsigned char,unsigned char,unsigned,const std::vector<std::pair<double,double>> &,const std::vector<double> &,const std::vector<double> &)103 void libvisio::VSDStylesCollector::collectNURBSTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */,
104                                                   unsigned char /* xType */, unsigned char /* yType */, unsigned /* degree */, const std::vector<std::pair<double, double> > & /* ctrlPts */,
105                                                   const std::vector<double> & /* kntVec */, const std::vector<double> & /* weights */)
106 {
107   _handleLevelChange(level);
108 }
109 
collectNURBSTo(unsigned,unsigned level,double,double,double,double,double,double,unsigned)110 void libvisio::VSDStylesCollector::collectNURBSTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, double /* knot */,
111                                                   double /* knotPrev */, double /* weight */, double /* weightPrev */, unsigned /* dataID */)
112 {
113   _handleLevelChange(level);
114 }
115 
collectNURBSTo(unsigned,unsigned level,double,double,double,double,double,double,const NURBSData &)116 void libvisio::VSDStylesCollector::collectNURBSTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, double /* knot */,
117                                                   double /* knotPrev */, double /* weight */, double /* weightPrev */, const NURBSData & /* data */)
118 {
119   _handleLevelChange(level);
120 }
121 
collectPolylineTo(unsigned,unsigned level,double,double,unsigned char,unsigned char,const std::vector<std::pair<double,double>> &)122 void libvisio::VSDStylesCollector::collectPolylineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */,
123                                                      unsigned char /* xType */, unsigned char /* yType */,
124                                                      const std::vector<std::pair<double, double> > & /* points */)
125 {
126   _handleLevelChange(level);
127 }
128 
collectPolylineTo(unsigned,unsigned level,double,double,unsigned)129 void libvisio::VSDStylesCollector::collectPolylineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, unsigned /* dataID */)
130 {
131   _handleLevelChange(level);
132 }
133 
collectPolylineTo(unsigned,unsigned level,double,double,const PolylineData &)134 void libvisio::VSDStylesCollector::collectPolylineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, const PolylineData & /* data */)
135 {
136   _handleLevelChange(level);
137 }
138 
collectSplineStart(unsigned,unsigned level,double,double,double,double,double,unsigned)139 void libvisio::VSDStylesCollector::collectSplineStart(unsigned /* id */, unsigned level, double /* x */, double /* y */,
140                                                       double /* secondKnot */, double /* firstKnot */, double /* lastKnot */, unsigned /* degree */)
141 {
142   _handleLevelChange(level);
143 }
144 
collectSplineKnot(unsigned,unsigned level,double,double,double)145 void libvisio::VSDStylesCollector::collectSplineKnot(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* knot */)
146 {
147   _handleLevelChange(level);
148 }
149 
collectSplineEnd()150 void libvisio::VSDStylesCollector::collectSplineEnd()
151 {
152 }
153 
collectInfiniteLine(unsigned,unsigned level,double,double,double,double)154 void libvisio::VSDStylesCollector::collectInfiniteLine(unsigned /* id */, unsigned level, double /* x1 */, double /* y1 */, double /* x2 */, double /* y2 */)
155 {
156   _handleLevelChange(level);
157 }
158 
collectRelCubBezTo(unsigned,unsigned level,double,double,double,double,double,double)159 void libvisio::VSDStylesCollector::collectRelCubBezTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* a */, double /* b */, double /* c */, double /* d */)
160 {
161   _handleLevelChange(level);
162 }
163 
collectRelEllipticalArcTo(unsigned,unsigned level,double,double,double,double,double,double)164 void libvisio::VSDStylesCollector::collectRelEllipticalArcTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* a */, double /* b */, double /* c */, double /* d */)
165 {
166   _handleLevelChange(level);
167 }
168 
collectRelLineTo(unsigned,unsigned level,double,double)169 void libvisio::VSDStylesCollector::collectRelLineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */)
170 {
171   _handleLevelChange(level);
172 }
173 
collectRelMoveTo(unsigned,unsigned level,double,double)174 void libvisio::VSDStylesCollector::collectRelMoveTo(unsigned /* id */, unsigned level, double /* x */, double /* y */)
175 {
176   _handleLevelChange(level);
177 }
178 
collectRelQuadBezTo(unsigned,unsigned level,double,double,double,double)179 void libvisio::VSDStylesCollector::collectRelQuadBezTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* a */, double /* b */)
180 {
181   _handleLevelChange(level);
182 }
183 
collectShapeData(unsigned,unsigned level,unsigned char,unsigned char,unsigned,double,std::vector<std::pair<double,double>>,std::vector<double>,std::vector<double>)184 void libvisio::VSDStylesCollector::collectShapeData(unsigned /* id */, unsigned level, unsigned char /* xType */, unsigned char /* yType */,
185                                                     unsigned /* degree */, double /*lastKnot*/, std::vector<std::pair<double, double> > /* controlPoints */,
186                                                     std::vector<double> /* knotVector */, std::vector<double> /* weights */)
187 {
188   _handleLevelChange(level);
189 }
190 
collectShapeData(unsigned,unsigned level,unsigned char,unsigned char,std::vector<std::pair<double,double>>)191 void libvisio::VSDStylesCollector::collectShapeData(unsigned /* id */, unsigned level, unsigned char /* xType */, unsigned char /* yType */,
192                                                     std::vector<std::pair<double, double> > /* points */)
193 {
194   _handleLevelChange(level);
195 }
196 
collectXFormData(unsigned level,const XForm & xform)197 void libvisio::VSDStylesCollector::collectXFormData(unsigned level, const XForm &xform)
198 {
199   _handleLevelChange(level);
200   if (m_isShapeStarted)
201     m_groupXForms[m_currentShapeId] = xform;
202 }
203 
collectTxtXForm(unsigned level,const XForm &)204 void libvisio::VSDStylesCollector::collectTxtXForm(unsigned level, const XForm & /* txtxform */)
205 {
206   _handleLevelChange(level);
207 }
208 
collectShapesOrder(unsigned,unsigned level,const std::vector<unsigned> & shapeIds)209 void libvisio::VSDStylesCollector::collectShapesOrder(unsigned /* id */, unsigned level, const std::vector<unsigned> &shapeIds)
210 {
211   _handleLevelChange(level);
212   m_shapeList.clear();
213   for (unsigned int shapeId : shapeIds)
214     m_shapeList.push_back(shapeId);
215   _flushShapeList();
216 }
217 
collectForeignDataType(unsigned level,unsigned,unsigned,double,double,double,double)218 void libvisio::VSDStylesCollector::collectForeignDataType(unsigned level, unsigned /* foreignType */, unsigned /* foreignFormat */,
219                                                           double /* offsetX */, double /* offsetY */, double /* width */, double /* height */)
220 {
221   _handleLevelChange(level);
222 }
223 
collectPageProps(unsigned,unsigned level,double,double,double,double,double)224 void libvisio::VSDStylesCollector::collectPageProps(unsigned /* id */, unsigned level, double /* pageWidth */, double /* pageHeight */,
225                                                     double /* shadowOffsetX */, double /* shadowOffsetY */, double /* scale */)
226 {
227   _handleLevelChange(level);
228 }
229 
collectPage(unsigned,unsigned level,unsigned,bool,const VSDName &)230 void libvisio::VSDStylesCollector::collectPage(unsigned /* id */, unsigned level, unsigned /* backgroundPageID */, bool /* isBackgroundPage */, const VSDName & /* pageName */)
231 {
232   _handleLevelChange(level);
233 }
234 
collectShape(unsigned id,unsigned level,unsigned parent,unsigned,unsigned,unsigned,unsigned,unsigned)235 void libvisio::VSDStylesCollector::collectShape(unsigned id, unsigned level, unsigned parent, unsigned /*masterPage*/, unsigned /*masterShape*/,
236                                                 unsigned /* lineStyle */, unsigned /* fillStyle */, unsigned /* textStyle */)
237 {
238   _handleLevelChange(level);
239   m_currentShapeLevel = level;
240   m_currentShapeId = id;
241   m_isShapeStarted = true;
242   if (parent && parent != MINUS_ONE)
243     m_groupMemberships[m_currentShapeId] = parent;
244 }
245 
collectMisc(unsigned level,const VSDMisc &)246 void libvisio::VSDStylesCollector::collectMisc(unsigned level, const VSDMisc & /* misc */)
247 {
248   _handleLevelChange(level);
249 }
250 
collectLayerMem(unsigned level,const VSDName &)251 void libvisio::VSDStylesCollector::collectLayerMem(unsigned level, const VSDName & /* layerMem */)
252 {
253   _handleLevelChange(level);
254 }
255 
collectLayer(unsigned,unsigned level,const VSDLayer &)256 void libvisio::VSDStylesCollector::collectLayer(unsigned /* id */, unsigned level, const VSDLayer & /* layer */)
257 {
258   _handleLevelChange(level);
259 }
260 
collectUnhandledChunk(unsigned,unsigned level)261 void libvisio::VSDStylesCollector::collectUnhandledChunk(unsigned /* id */, unsigned level)
262 {
263   _handleLevelChange(level);
264 }
265 
collectText(unsigned level,const librevenge::RVNGBinaryData &,TextFormat)266 void libvisio::VSDStylesCollector::collectText(unsigned level, const librevenge::RVNGBinaryData & /*textStream*/, TextFormat /*format*/)
267 {
268   _handleLevelChange(level);
269 }
270 
collectParaIX(unsigned,unsigned level,unsigned,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<VSDName> &,const boost::optional<VSDName> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned> &)271 void libvisio::VSDStylesCollector::collectParaIX(unsigned /* id */, unsigned level, unsigned /* charCount */,
272                                                  const boost::optional<double> & /* indFirst */, const boost::optional<double> & /* indLeft */,
273                                                  const boost::optional<double> & /* indRight */, const boost::optional<double> & /* spLine */,
274                                                  const boost::optional<double> & /* spBefore */, const boost::optional<double> & /* spAfter */,
275                                                  const boost::optional<unsigned char> & /* align */, const boost::optional<unsigned char> & /* bullet */,
276                                                  const boost::optional<VSDName> & /* bulletStr */, const boost::optional<VSDName> & /* bulletFont */,
277                                                  const boost::optional<double> & /* bulletFontSize */, const boost::optional<double> & /* textPosAfterBullet */,
278                                                  const boost::optional<unsigned> & /* flags */)
279 {
280   _handleLevelChange(level);
281 }
282 
collectDefaultParaStyle(unsigned,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<VSDName> &,const boost::optional<VSDName> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned> &)283 void libvisio::VSDStylesCollector::collectDefaultParaStyle(unsigned /* charCount */, const boost::optional<double> & /* indFirst */,
284                                                            const boost::optional<double> & /* indLeft */, const boost::optional<double> & /* indRight */,
285                                                            const boost::optional<double> & /* spLine */, const boost::optional<double> & /* spBefore */,
286                                                            const boost::optional<double> & /* spAfter */, const boost::optional<unsigned char> & /* align */,
287                                                            const boost::optional<unsigned char> & /* bullet */, const boost::optional<VSDName> & /* bulletStr */,
288                                                            const boost::optional<VSDName> & /* bulletFont */, const boost::optional<double> & /* bulletFontSize */,
289                                                            const boost::optional<double> & /* textPosAfterBullet */, const boost::optional<unsigned> & /* flags */)
290 {
291 }
292 
collectCharIX(unsigned,unsigned level,unsigned,const boost::optional<VSDName> &,const boost::optional<Colour> &,const boost::optional<double> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<double> &)293 void libvisio::VSDStylesCollector::collectCharIX(unsigned /* id */, unsigned level, unsigned /* charCount */,
294                                                  const boost::optional<VSDName> & /* font */, const boost::optional<Colour> & /* fontColour */, const boost::optional<double> & /* fontSize */,
295                                                  const boost::optional<bool> & /* bold */, const boost::optional<bool> & /* italic */, const boost::optional<bool> & /* underline */,
296                                                  const boost::optional<bool> & /* doubleunderline */, const boost::optional<bool> & /* strikeout */, const boost::optional<bool> & /* doublestrikeout */,
297                                                  const boost::optional<bool> & /* allcaps */, const boost::optional<bool> & /* initcaps */, const boost::optional<bool> & /* smallcaps */,
298                                                  const boost::optional<bool> & /* superscript */, const boost::optional<bool> & /* subscript */, const boost::optional<double> & /* scaleWidth */)
299 {
300   _handleLevelChange(level);
301 }
302 
collectTabsDataList(unsigned level,const std::map<unsigned,VSDTabSet> &)303 void libvisio::VSDStylesCollector::collectTabsDataList(unsigned level, const std::map<unsigned, VSDTabSet> & /* tabSets */)
304 {
305   _handleLevelChange(level);
306 }
307 
collectDefaultCharStyle(unsigned,const boost::optional<VSDName> &,const boost::optional<Colour> &,const boost::optional<double> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<double> &)308 void libvisio::VSDStylesCollector::collectDefaultCharStyle(unsigned /* charCount */,
309                                                            const boost::optional<VSDName> & /* font */, const boost::optional<Colour> & /* fontColour */, const boost::optional<double> & /* fontSize */,
310                                                            const boost::optional<bool> & /* bold */, const boost::optional<bool> & /* italic */, const boost::optional<bool> & /* underline */,
311                                                            const boost::optional<bool> & /* doubleunderline */, const boost::optional<bool> & /* strikeout */, const boost::optional<bool> & /* doublestrikeout */,
312                                                            const boost::optional<bool> & /* allcaps */, const boost::optional<bool> & /* initcaps */, const boost::optional<bool> & /* smallcaps */,
313                                                            const boost::optional<bool> & /* superscript */, const boost::optional<bool> & /* subscript */, const boost::optional<double> & /* scaleWidth */)
314 {
315 }
316 
collectTextBlock(unsigned level,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<bool> &,const boost::optional<Colour> &,const boost::optional<double> &,const boost::optional<unsigned char> &)317 void libvisio::VSDStylesCollector::collectTextBlock(unsigned level, const boost::optional<double> & /* leftMargin */,
318                                                     const boost::optional<double> & /* rightMargin */, const boost::optional<double> & /* topMargin */, const boost::optional<double> & /* bottomMargin */,
319                                                     const boost::optional<unsigned char> & /* verticalAlign */, const boost::optional<bool> & /* isBgFilled */, const boost::optional<Colour> & /* bgColour */,
320                                                     const boost::optional<double> & /* defaultTabStop */, const boost::optional<unsigned char> & /* textDirection */)
321 {
322   _handleLevelChange(level);
323 }
324 
collectName(unsigned,unsigned level,const librevenge::RVNGBinaryData &,TextFormat)325 void libvisio::VSDStylesCollector::collectName(unsigned /*id*/, unsigned level, const librevenge::RVNGBinaryData & /*name*/, TextFormat /*format*/)
326 {
327   _handleLevelChange(level);
328 }
329 
collectPageSheet(unsigned,unsigned level)330 void libvisio::VSDStylesCollector::collectPageSheet(unsigned /* id */, unsigned level)
331 {
332   _handleLevelChange(level);
333   m_currentShapeLevel = level;
334 }
335 
collectStyleSheet(unsigned,unsigned level,unsigned,unsigned,unsigned)336 void libvisio::VSDStylesCollector::collectStyleSheet(unsigned /* id */, unsigned level, unsigned /* parentLineStyle */, unsigned /* parentFillStyle */, unsigned /* parentTextStyle */)
337 {
338   _handleLevelChange(level);
339 }
340 
collectLineStyle(unsigned level,const boost::optional<double> &,const boost::optional<Colour> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<double> &,const boost::optional<long> &,const boost::optional<long> &)341 void libvisio::VSDStylesCollector::collectLineStyle(unsigned level, const boost::optional<double> & /* strokeWidth */, const boost::optional<Colour> & /* c */,
342                                                     const boost::optional<unsigned char> & /* linePattern */, const boost::optional<unsigned char> & /* startMarker */,
343                                                     const boost::optional<unsigned char> & /* endMarker */, const boost::optional<unsigned char> & /* lineCap */,
344                                                     const boost::optional<double> & /* rounding */, const boost::optional<long> & /* qsLineColour */,
345                                                     const boost::optional<long> & /* qsLineMatrix */)
346 {
347   _handleLevelChange(level);
348 }
349 
collectFillStyle(unsigned level,const boost::optional<Colour> &,const boost::optional<Colour> &,const boost::optional<unsigned char> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<Colour> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<long> &,const boost::optional<long> &,const boost::optional<long> &)350 void libvisio::VSDStylesCollector::collectFillStyle(unsigned level, const boost::optional<Colour> & /* colourFG */, const boost::optional<Colour> & /* colourBG */,
351                                                     const boost::optional<unsigned char> & /* fillPattern */, const boost::optional<double> & /* fillFGTransparency */,
352                                                     const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */,
353                                                     const boost::optional<Colour> & /* shfgc */, const boost::optional<double> & /* shadowOffsetX */,
354                                                     const boost::optional<double> & /* shadowOffsetY */, const boost::optional<long> & /* qsFillColour */,
355                                                     const boost::optional<long> & /* qsShadowColour */, const boost::optional<long> & /* qsFillMatrix */)
356 {
357   _handleLevelChange(level);
358 }
359 
collectFillStyle(unsigned level,const boost::optional<Colour> &,const boost::optional<Colour> &,const boost::optional<unsigned char> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<Colour> &)360 void libvisio::VSDStylesCollector::collectFillStyle(unsigned level, const boost::optional<Colour> & /* colourFG */, const boost::optional<Colour> & /* colourBG */,
361                                                     const boost::optional<unsigned char> & /* fillPattern */, const boost::optional<double> & /* fillFGTransparency */,
362                                                     const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */,
363                                                     const boost::optional<Colour> & /* shfgc */)
364 {
365   _handleLevelChange(level);
366 }
367 
collectCharIXStyle(unsigned,unsigned level,unsigned,const boost::optional<VSDName> &,const boost::optional<Colour> &,const boost::optional<double> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<bool> &,const boost::optional<double> &)368 void libvisio::VSDStylesCollector::collectCharIXStyle(unsigned /* id */, unsigned level, unsigned /* charCount */, const boost::optional<VSDName> & /* font */,
369                                                       const boost::optional<Colour> & /* fontColour */, const boost::optional<double> & /* fontSize */,
370                                                       const boost::optional<bool> & /* bold */, const boost::optional<bool> & /* italic */,
371                                                       const boost::optional<bool> & /* underline */, const boost::optional<bool> & /* doubleunderline */,
372                                                       const boost::optional<bool> & /* strikeout */, const boost::optional<bool> & /* doublestrikeout */,
373                                                       const boost::optional<bool> & /* allcaps */, const boost::optional<bool> & /* initcaps */,
374                                                       const boost::optional<bool> & /* smallcaps */, const boost::optional<bool> & /* superscript */,
375                                                       const boost::optional<bool> & /* subscript */, const boost::optional<double> & /* scaleWidth */)
376 {
377   _handleLevelChange(level);
378 }
379 
collectParaIXStyle(unsigned,unsigned level,unsigned,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<unsigned char> &,const boost::optional<VSDName> &,const boost::optional<VSDName> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned> &)380 void libvisio::VSDStylesCollector::collectParaIXStyle(unsigned /* id */, unsigned level, unsigned /* charCount */, const boost::optional<double> & /* indFirst */,
381                                                       const boost::optional<double> & /* indLeft */, const boost::optional<double> & /* indRight */,
382                                                       const boost::optional<double> & /* spLine */, const boost::optional<double> & /* spBefore */,
383                                                       const boost::optional<double> & /* spAfter */, const boost::optional<unsigned char> & /* align */,
384                                                       const boost::optional<unsigned char> & /* bullet */, const boost::optional<VSDName> & /* bulletStr */,
385                                                       const boost::optional<VSDName> & /* bulletFont */, const boost::optional<double> & /* bulletFontSize */,
386                                                       const boost::optional<double> & /* textPosAfterBullet */, const boost::optional<unsigned> & /* flags */)
387 {
388   _handleLevelChange(level);
389 }
390 
391 
collectTextBlockStyle(unsigned level,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<double> &,const boost::optional<unsigned char> &,const boost::optional<bool> &,const boost::optional<Colour> &,const boost::optional<double> &,const boost::optional<unsigned char> &)392 void libvisio::VSDStylesCollector::collectTextBlockStyle(unsigned level, const boost::optional<double> & /* leftMargin */, const boost::optional<double> & /* rightMargin */,
393                                                          const boost::optional<double> & /* topMargin */, const boost::optional<double> & /* bottomMargin */,
394                                                          const boost::optional<unsigned char> & /* verticalAlign */, const boost::optional<bool> & /* isBgFilled */,
395                                                          const boost::optional<Colour> & /* bgColour */, const boost::optional<double> & /* defaultTabStop */,
396                                                          const boost::optional<unsigned char> & /* textDirection */)
397 {
398   _handleLevelChange(level);
399 }
400 
collectFieldList(unsigned,unsigned level)401 void libvisio::VSDStylesCollector::collectFieldList(unsigned /* id */, unsigned level)
402 {
403   _handleLevelChange(level);
404 }
405 
collectTextField(unsigned,unsigned level,int,int)406 void libvisio::VSDStylesCollector::collectTextField(unsigned /* id */, unsigned level, int /* nameId */, int /* formatStringId */)
407 {
408   _handleLevelChange(level);
409 }
410 
collectNumericField(unsigned,unsigned level,unsigned short,unsigned short,double,int)411 void libvisio::VSDStylesCollector::collectNumericField(unsigned /* id */, unsigned level, unsigned short /* format */,  unsigned short /* cellType */, double /* number */, int /* formatStringId */)
412 {
413   _handleLevelChange(level);
414 }
415 
startPage(unsigned)416 void libvisio::VSDStylesCollector::startPage(unsigned /* pageId */)
417 {
418   m_groupXForms.clear();
419   m_groupMemberships.clear();
420   m_pageShapeOrder.clear();
421   m_groupShapeOrder.clear();
422 }
423 
endPage()424 void libvisio::VSDStylesCollector::endPage()
425 {
426   _handleLevelChange(0);
427   m_groupXFormsSequence.push_back(m_groupXForms);
428   m_groupMembershipsSequence.push_back(m_groupMemberships);
429 
430   bool changed = true;
431   while (!m_groupShapeOrder.empty() && changed)
432   {
433     changed = false;
434     for (auto j = m_pageShapeOrder.begin(); j != m_pageShapeOrder.end();)
435     {
436       auto iter = m_groupShapeOrder.find(*j++);
437       if (m_groupShapeOrder.end() != iter)
438       {
439         m_pageShapeOrder.splice(j, iter->second, iter->second.begin(), iter->second.end());
440         m_groupShapeOrder.erase(iter);
441         changed = true;
442       }
443     }
444   }
445   m_documentPageShapeOrders.push_back(m_pageShapeOrder);
446 }
447 
_handleLevelChange(unsigned level)448 void libvisio::VSDStylesCollector::_handleLevelChange(unsigned level)
449 {
450   if (m_currentLevel == level)
451     return;
452   if (level <= m_currentShapeLevel)
453     m_isShapeStarted = false;
454 
455   m_currentLevel = level;
456 }
457 
_flushShapeList()458 void libvisio::VSDStylesCollector::_flushShapeList()
459 {
460   if (m_shapeList.empty())
461     return;
462 
463   if (m_isShapeStarted)
464     m_groupShapeOrder[m_currentShapeId] = m_shapeList;
465   else
466     m_pageShapeOrder = m_shapeList;
467 
468   m_shapeList.clear();
469 }
470 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
471