VSDXStylesCollector.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 VSDXSTYLESCOLLECTOR_H
32 #define VSDXSTYLESCOLLECTOR_H
33 
34 #include <map>
35 #include <vector>
36 #include <list>
37 #include "VSDXCollector.h"
38 #include "VSDXParser.h"
39 #include "libvisio_utils.h"
40 #include "VSDXStyles.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 ~VSDXStylesCollector() {};
54 
55  void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc);
56  void collectForeignData(unsigned id, 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 id, unsigned level, double strokeWidth, Colour c, unsigned linePattern, unsigned char startMarker, unsigned char endMarker, unsigned lineCap);
64  void collectFillAndShadow(unsigned id, unsigned level, unsigned colourIndexFG, unsigned colourIndexBG, unsigned fillPattern,
65  unsigned fillFGTransparency, unsigned fillBGTransparency, unsigned shadowPattern, Colour shfgc,
66  double shadowOffsetX, double shadowOffsetY);
67  void collectFillAndShadow(unsigned id, unsigned level, unsigned colourIndexFG, unsigned colourIndexBG, unsigned fillPattern,
68  unsigned fillFGTransparency, unsigned fillBGTransparency, unsigned shadowPattern, Colour shfgc);
69  void collectGeometry(unsigned id, unsigned level, unsigned char geomFlags);
70  void collectMoveTo(unsigned id, unsigned level, double x, double y);
71  void collectLineTo(unsigned id, unsigned level, double x, double y);
72  void collectArcTo(unsigned id, unsigned level, double x2, double y2, double bow);
73  void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType,
74  unsigned degree, std::vector<std::pair<double, double> > controlPoints,
75  std::vector<double> knotVector, std::vector<double> weights);
76  void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID);
77  void collectPolylineTo(unsigned id , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > &points);
78  void collectPolylineTo(unsigned id , unsigned level, double x, double y, unsigned dataID);
79  void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, unsigned degree, double lastKnot,
80  std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights);
81  void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points);
82  void collectXFormData(unsigned id, unsigned level, const XForm &xform);
83  void collectTxtXForm(unsigned id, unsigned level, const XForm &txtxform);
84  void collectShapeId(unsigned id, unsigned level, unsigned shapeId);
85  void collectForeignDataType(unsigned id, unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height);
86  void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale);
87  void collectPage(unsigned id, unsigned level, unsigned backgroundPageID);
88  void collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle);
89  void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree);
90  void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot);
91  void collectSplineEnd();
92  void collectInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2);
93  void collectUnhandledChunk(unsigned id, unsigned level);
94 
95  void collectColours(const std::vector<Colour> &colours);
96  void collectFont(unsigned short fontID, const ::WPXBinaryData &textStream, TextFormat format);
97 
98  void collectText(unsigned id, unsigned level, const ::WPXBinaryData &textStream, TextFormat format);
99  void collectVSDXCharStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour,
100  double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout,
101  bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace);
102  void collectVSDXParaStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight,
103  double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags);
104  void collectTextBlock(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign,
105  unsigned char bgClrId, const Colour &bgColour, double defaultTabStop, unsigned char textDirection);
106  void collectNameList(unsigned id, unsigned level)
107  {
108  collectUnhandledChunk(id, level);
109  }
110  void collectName(unsigned id, unsigned level, const ::WPXBinaryData &name, TextFormat format);
111 
112  // Style collectors
113  void collectStyleSheet(unsigned id, unsigned level, unsigned parentLineStyle, unsigned parentFillStyle, unsigned parentTextStyle);
114  void collectLineStyle(unsigned id, unsigned level, double strokeWidth, Colour c, unsigned char linePattern, unsigned char startMarker, unsigned char endMarker, unsigned char lineCap);
115  void collectFillStyle(unsigned id, unsigned level, unsigned char colourIndexFG, unsigned char colourIndexBG, unsigned char fillPattern,
116  unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc,
117  double shadowOffsetX, double shadowOffsetY);
118  void collectFillStyle(unsigned id, unsigned level, unsigned char colourIndexFG, unsigned char colourIndexBG, unsigned char fillPattern,
119  unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc);
120  void collectCharIXStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour,
121  double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout,
122  bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace);
123  void collectParaIXStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight,
124  double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags);
125  void collectTextBlockStyle(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign,
126  unsigned char bgClrId, const Colour &bgColour, double defaultTabStop, unsigned char textDirection);
127 
128  // Field list
129  void collectFieldList(unsigned id, unsigned level);
130  void collectTextField(unsigned id, unsigned level, int nameId, int formatStringId);
131  void collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId);
132 
133  // Temporary hack
134  void startPage(unsigned pageID);
135  void endPage();
136  void endPages() {}
137 
139  {
140  return m_styles;
141  }
142 
143 
144 private:
147 
148  void _handleLevelChange(unsigned level);
149  void _flushShapeList();
150 
151  unsigned m_currentLevel;
153 
156 
158  std::map<unsigned, XForm> m_groupXForms;
159  std::map<unsigned, unsigned> m_groupMemberships;
160  std::vector<std::map<unsigned, XForm> > &m_groupXFormsSequence;
161  std::vector<std::map<unsigned, unsigned> > &m_groupMembershipsSequence;
162  std::list<unsigned> m_pageShapeOrder;
163  std::vector<std::list<unsigned> > &m_documentPageShapeOrders;
164  std::map<unsigned, std::list<unsigned> > m_groupShapeOrder;
165  std::list<unsigned> m_shapeList;
166 
174 
180 };
181 
182 }
183 
184 #endif /* VSDXSTYLESCOLLECTOR_H */
185 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.1.1