00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef VSDSTYLESCOLLECTOR_H
00032 #define VSDSTYLESCOLLECTOR_H
00033
00034 #include <map>
00035 #include <vector>
00036 #include <list>
00037 #include "VSDCollector.h"
00038 #include "VSDParser.h"
00039 #include "libvisio_utils.h"
00040 #include "VSDStyles.h"
00041
00042 namespace libvisio
00043 {
00044
00045 class VSDStylesCollector : public VSDCollector
00046 {
00047 public:
00048 VSDStylesCollector(
00049 std::vector<std::map<unsigned, XForm> > &groupXFormsSequence,
00050 std::vector<std::map<unsigned, unsigned> > &groupMembershipsSequence,
00051 std::vector<std::list<unsigned> > &documentPageShapeOrders
00052 );
00053 virtual ~VSDStylesCollector() {}
00054
00055 void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc);
00056 void collectForeignData(unsigned level, const WPXBinaryData &binaryData);
00057 void collectOLEList(unsigned id, unsigned level)
00058 {
00059 collectUnhandledChunk(id, level);
00060 }
00061 void collectOLEData(unsigned id, unsigned level, const WPXBinaryData &oleData);
00062 void collectEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop);
00063 void collectLine(unsigned level, const boost::optional<double> &strokeWidth, const boost::optional<Colour> &c, const boost::optional<unsigned char> &linePattern,
00064 const boost::optional<unsigned char> &startMarker, const boost::optional<unsigned char> &endMarker,
00065 const boost::optional<unsigned char> &lineCap);
00066 void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
00067 const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
00068 const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
00069 const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY);
00070 void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
00071 const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
00072 const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
00073 const boost::optional<Colour> &shfgc);
00074 void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow);
00075 void collectMoveTo(unsigned id, unsigned level, double x, double y);
00076 void collectLineTo(unsigned id, unsigned level, double x, double y);
00077 void collectArcTo(unsigned id, unsigned level, double x2, double y2, double bow);
00078 void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree,
00079 const std::vector<std::pair<double, double> > &ctrlPnts, const std::vector<double> &kntVec, const std::vector<double> &weights);
00080 void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID);
00081 void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, const NURBSData &data);
00082 void collectPolylineTo(unsigned id, unsigned level, double x, double y, unsigned char xType, unsigned char yType, const std::vector<std::pair<double, double> > &points);
00083 void collectPolylineTo(unsigned id, unsigned level, double x, double y, unsigned dataID);
00084 void collectPolylineTo(unsigned id, unsigned level, double x, double y, const PolylineData &data);
00085 void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, unsigned degree, double lastKnot,
00086 std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights);
00087 void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points);
00088 void collectXFormData(unsigned level, const XForm &xform);
00089 void collectTxtXForm(unsigned level, const XForm &txtxform);
00090 void collectShapesOrder(unsigned id, unsigned level, const std::vector<unsigned> &shapeIds);
00091 void collectForeignDataType(unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height);
00092 void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale);
00093 void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage, const VSDName &pageName);
00094 void collectShape(unsigned id, unsigned level, unsigned parent, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle);
00095 void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree);
00096 void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot);
00097 void collectSplineEnd();
00098 void collectInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2);
00099 void collectRelCubBezTo(unsigned id, unsigned level, double x, double y, double a, double b, double c, double d);
00100 void collectRelEllipticalArcTo(unsigned id, unsigned level, double x, double y, double a, double b, double c, double d);
00101 void collectRelLineTo(unsigned id, unsigned level, double x, double y);
00102 void collectRelMoveTo(unsigned id, unsigned level, double x, double y);
00103 void collectRelQuadBezTo(unsigned id, unsigned level, double x, double y, double a, double b);
00104 void collectUnhandledChunk(unsigned id, unsigned level);
00105
00106 void collectText(unsigned level, const ::WPXBinaryData &textStream, TextFormat format);
00107 void collectCharIX(unsigned id, unsigned level, unsigned charCount, const boost::optional<VSDName> &font,
00108 const boost::optional<Colour> &fontColour, const boost::optional<double> &fontSize, const boost::optional<bool> &bold,
00109 const boost::optional<bool> &italic, const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline,
00110 const boost::optional<bool> &strikeout, const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps,
00111 const boost::optional<bool> &initcaps, const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript,
00112 const boost::optional<bool> &subscript);
00113 void collectDefaultCharStyle(unsigned charCount, const boost::optional<VSDName> &font, const boost::optional<Colour> &fontColour,
00114 const boost::optional<double> &fontSize, const boost::optional<bool> &bold, const boost::optional<bool> &italic,
00115 const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline, const boost::optional<bool> &strikeout,
00116 const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps, const boost::optional<bool> &initcaps,
00117 const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript, const boost::optional<bool> &subscript);
00118 void collectParaIX(unsigned id, unsigned level, unsigned charCount, const boost::optional<double> &indFirst,
00119 const boost::optional<double> &indLeft, const boost::optional<double> &indRight, const boost::optional<double> &spLine,
00120 const boost::optional<double> &spBefore, const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align,
00121 const boost::optional<unsigned> &flags);
00122 void collectDefaultParaStyle(unsigned charCount, const boost::optional<double> &indFirst, const boost::optional<double> &indLeft,
00123 const boost::optional<double> &indRight, const boost::optional<double> &spLine, const boost::optional<double> &spBefore,
00124 const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align, const boost::optional<unsigned> &flags);
00125 void collectTextBlock(unsigned level, const boost::optional<double> &leftMargin, const boost::optional<double> &rightMargin,
00126 const boost::optional<double> &topMargin, const boost::optional<double> &bottomMargin,
00127 const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
00128 const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
00129 const boost::optional<unsigned char> &textDirection);
00130 void collectNameList(unsigned id, unsigned level)
00131 {
00132 collectUnhandledChunk(id, level);
00133 }
00134 void collectName(unsigned id, unsigned level, const ::WPXBinaryData &name, TextFormat format);
00135 void collectPageSheet(unsigned id, unsigned level);
00136 void collectMisc(unsigned level, const VSDMisc &misc);
00137
00138
00139 void collectStyleSheet(unsigned id, unsigned level,unsigned parentLineStyle, unsigned parentFillStyle, unsigned parentTextStyle);
00140 void collectLineStyle(unsigned level, const boost::optional<double> &strokeWidth, const boost::optional<Colour> &c, const boost::optional<unsigned char> &linePattern,
00141 const boost::optional<unsigned char> &startMarker, const boost::optional<unsigned char> &endMarker,
00142 const boost::optional<unsigned char> &lineCap);
00143 void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
00144 const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
00145 const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
00146 const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY);
00147 void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
00148 const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
00149 const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
00150 const boost::optional<Colour> &shfgc);
00151 void collectCharIXStyle(unsigned id, unsigned level, unsigned charCount, const boost::optional<VSDName> &font,
00152 const boost::optional<Colour> &fontColour, const boost::optional<double> &fontSize, const boost::optional<bool> &bold,
00153 const boost::optional<bool> &italic, const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline,
00154 const boost::optional<bool> &strikeout, const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps,
00155 const boost::optional<bool> &initcaps, const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript,
00156 const boost::optional<bool> &subscript);
00157 void collectParaIXStyle(unsigned id, unsigned level, unsigned charCount, const boost::optional<double> &indFirst,
00158 const boost::optional<double> &indLeft, const boost::optional<double> &indRight, const boost::optional<double> &spLine,
00159 const boost::optional<double> &spBefore, const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align,
00160 const boost::optional<unsigned> &flags);
00161 void collectTextBlockStyle(unsigned level, const boost::optional<double> &leftMargin, const boost::optional<double> &rightMargin,
00162 const boost::optional<double> &topMargin, const boost::optional<double> &bottomMargin,
00163 const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
00164 const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
00165 const boost::optional<unsigned char> &textDirection);
00166
00167
00168 void collectFieldList(unsigned id, unsigned level);
00169 void collectTextField(unsigned id, unsigned level, int nameId, int formatStringId);
00170 void collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId);
00171
00172
00173 void startPage(unsigned pageID);
00174 void endPage();
00175 void endPages() {}
00176
00177 const VSDStyles &getStyleSheets() const
00178 {
00179 return m_styles;
00180 }
00181
00182
00183 private:
00184 VSDStylesCollector(const VSDStylesCollector &);
00185 VSDStylesCollector &operator=(const VSDStylesCollector &);
00186
00187 void _handleLevelChange(unsigned level);
00188 void _flushShapeList();
00189
00190 unsigned m_currentLevel;
00191 bool m_isShapeStarted;
00192
00193 double m_shadowOffsetX;
00194 double m_shadowOffsetY;
00195
00196 unsigned m_currentShapeId;
00197 std::map<unsigned, XForm> m_groupXForms;
00198 std::map<unsigned, unsigned> m_groupMemberships;
00199 std::vector<std::map<unsigned, XForm> > &m_groupXFormsSequence;
00200 std::vector<std::map<unsigned, unsigned> > &m_groupMembershipsSequence;
00201 std::list<unsigned> m_pageShapeOrder;
00202 std::vector<std::list<unsigned> > &m_documentPageShapeOrders;
00203 std::map<unsigned, std::list<unsigned> > m_groupShapeOrder;
00204 std::list<unsigned> m_shapeList;
00205
00206 unsigned m_currentStyleSheet;
00207 VSDStyles m_styles;
00208
00209 unsigned m_currentShapeLevel;
00210 };
00211
00212 }
00213
00214 #endif
00215