VSDCollector.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libvisio
00003  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License or as specified alternatively below. You may obtain a copy of
00008  * the License at http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * Major Contributor(s):
00016  * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch>
00017  * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com>
00018  *
00019  *
00020  * All Rights Reserved.
00021  *
00022  * For minor contributions see the git repository.
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
00026  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00027  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
00028  * instead of those above.
00029  */
00030 
00031 #ifndef VSDCOLLECTOR_H
00032 #define VSDCOLLECTOR_H
00033 
00034 #include <vector>
00035 #include <boost/optional.hpp>
00036 #include "VSDParser.h"
00037 
00038 namespace libvisio
00039 {
00040 
00041 class VSDCollector
00042 {
00043 public:
00044   VSDCollector() {};
00045   virtual ~VSDCollector() {}
00046 
00047   virtual void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) = 0;
00048   virtual void collectForeignData(unsigned level, const WPXBinaryData &binaryData) = 0;
00049   virtual void collectOLEList(unsigned id, unsigned level) = 0;
00050   virtual void collectOLEData(unsigned id, unsigned level, const WPXBinaryData &oleData) = 0;
00051   virtual void collectEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop) = 0;
00052   virtual void collectLine(unsigned level, const boost::optional<double> &strokeWidth, const boost::optional<Colour> &c, const boost::optional<unsigned char> &linePattern,
00053                            const boost::optional<unsigned char> &startMarker, const boost::optional<unsigned char> &endMarker,
00054                            const boost::optional<unsigned char> &lineCap) = 0;
00055   virtual void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
00056                                     const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
00057                                     const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
00058                                     const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY) = 0;
00059   virtual void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
00060                                     const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
00061                                     const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
00062                                     const boost::optional<Colour> &shfgc) = 0;
00063   virtual void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow) = 0;
00064   virtual void collectMoveTo(unsigned id, unsigned level, double x, double y) = 0;
00065   virtual void collectLineTo(unsigned id, unsigned level, double x, double y) = 0;
00066   virtual void collectArcTo(unsigned id, unsigned level, double x2, double y2, double bow) = 0;
00067   virtual void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree,
00068                               const std::vector<std::pair<double, double> > &ctrlPnts, const std::vector<double> &kntVec, const std::vector<double> &weights) = 0;
00069   virtual void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) = 0;
00070   virtual void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, const NURBSData &data) = 0;
00071   virtual void collectPolylineTo(unsigned id, unsigned level, double x, double y, unsigned char xType, unsigned char yType, const std::vector<std::pair<double, double> > &points) = 0;
00072   virtual void collectPolylineTo(unsigned id, unsigned level, double x, double y, unsigned dataID) = 0;
00073   virtual void collectPolylineTo(unsigned id, unsigned level, double x, double y, const PolylineData &data) = 0;
00074   virtual void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, unsigned degree, double lastKnot,
00075                                 std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) = 0;
00076   virtual void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points) = 0;
00077   virtual void collectXFormData(unsigned level, const XForm &xform) = 0;
00078   virtual void collectTxtXForm(unsigned level, const XForm &txtxform) = 0;
00079   virtual void collectShapesOrder(unsigned id, unsigned level, const std::vector<unsigned> &shapeIds) = 0;
00080   virtual void collectForeignDataType(unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height) = 0;
00081   virtual void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale) = 0;
00082   virtual void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage, const VSDName &pageName) = 0;
00083   virtual void collectShape(unsigned id, unsigned level, unsigned parent, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle) = 0;
00084   virtual void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) = 0;
00085   virtual void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot) = 0;
00086   virtual void collectSplineEnd() = 0;
00087   virtual void collectInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2) = 0;
00088   virtual void collectRelCubBezTo(unsigned id, unsigned level, double x, double y, double a, double b, double c, double d) = 0;
00089   virtual void collectRelEllipticalArcTo(unsigned id, unsigned level, double x, double y, double a, double b, double c, double d) = 0;
00090   virtual void collectRelLineTo(unsigned id, unsigned level, double x, double y) = 0;
00091   virtual void collectRelMoveTo(unsigned id, unsigned level, double x, double y) = 0;
00092   virtual void collectRelQuadBezTo(unsigned id, unsigned level, double x, double y, double a, double b) = 0;
00093 
00094   virtual void collectUnhandledChunk(unsigned id, unsigned level) = 0;
00095 
00096   virtual void collectText(unsigned level, const ::WPXBinaryData &textStream, TextFormat format) = 0;
00097   virtual void collectCharIX(unsigned id, unsigned level, unsigned charCount, const boost::optional<VSDName> &font,
00098                              const boost::optional<Colour> &fontColour, const boost::optional<double> &fontSize, const boost::optional<bool> &bold,
00099                              const boost::optional<bool> &italic, const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline,
00100                              const boost::optional<bool> &strikeout, const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps,
00101                              const boost::optional<bool> &initcaps, const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript,
00102                              const boost::optional<bool> &subscript) = 0;
00103   virtual void collectDefaultCharStyle(unsigned charCount, const boost::optional<VSDName> &font, const boost::optional<Colour> &fontColour,
00104                                        const boost::optional<double> &fontSize, const boost::optional<bool> &bold, const boost::optional<bool> &italic,
00105                                        const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline, const boost::optional<bool> &strikeout,
00106                                        const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps, const boost::optional<bool> &initcaps,
00107                                        const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript, const boost::optional<bool> &subscript) = 0;
00108   virtual void collectParaIX(unsigned id, unsigned level, unsigned charCount, const boost::optional<double> &indFirst,
00109                              const boost::optional<double> &indLeft, const boost::optional<double> &indRight, const boost::optional<double> &spLine,
00110                              const boost::optional<double> &spBefore, const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align,
00111                              const boost::optional<unsigned> &flags) = 0;
00112   virtual void collectDefaultParaStyle(unsigned charCount, const boost::optional<double> &indFirst, const boost::optional<double> &indLeft,
00113                                        const boost::optional<double> &indRight, const boost::optional<double> &spLine, const boost::optional<double> &spBefore,
00114                                        const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align, const boost::optional<unsigned> &flags) = 0;
00115   virtual void collectTextBlock(unsigned level, const boost::optional<double> &leftMargin, const boost::optional<double> &rightMargin,
00116                                 const boost::optional<double> &topMargin, const boost::optional<double> &bottomMargin,
00117                                 const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
00118                                 const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
00119                                 const boost::optional<unsigned char> &textDirection) = 0;
00120   virtual void collectNameList(unsigned id, unsigned level) = 0;
00121   virtual void collectName(unsigned id, unsigned level,  const ::WPXBinaryData &name, TextFormat format) = 0;
00122   virtual void collectPageSheet(unsigned id, unsigned level) = 0;
00123   virtual void collectMisc(unsigned level, const VSDMisc &misc) = 0;
00124 
00125   // Style collectors
00126   virtual void collectStyleSheet(unsigned id, unsigned level,unsigned parentLineStyle, unsigned parentFillStyle, unsigned parentTextStyle) = 0;
00127   virtual void collectLineStyle(unsigned level, const boost::optional<double> &strokeWidth, const boost::optional<Colour> &c, const boost::optional<unsigned char> &linePattern,
00128                                 const boost::optional<unsigned char> &startMarker, const boost::optional<unsigned char> &endMarker,
00129                                 const boost::optional<unsigned char> &lineCap) = 0;
00130   virtual void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
00131                                 const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
00132                                 const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
00133                                 const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY) = 0;
00134   virtual void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
00135                                 const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
00136                                 const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
00137                                 const boost::optional<Colour> &shfgc) = 0;
00138   virtual void collectCharIXStyle(unsigned id, unsigned level, unsigned charCount, const boost::optional<VSDName> &font,
00139                                   const boost::optional<Colour> &fontColour, const boost::optional<double> &fontSize, const boost::optional<bool> &bold,
00140                                   const boost::optional<bool> &italic, const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline,
00141                                   const boost::optional<bool> &strikeout, const boost::optional<bool> &doublestrikeout, const boost::optional<bool> &allcaps,
00142                                   const boost::optional<bool> &initcaps, const boost::optional<bool> &smallcaps, const boost::optional<bool> &superscript,
00143                                   const boost::optional<bool> &subscript) = 0;
00144   virtual void collectParaIXStyle(unsigned id, unsigned level, unsigned charCount, const boost::optional<double> &indFirst,
00145                                   const boost::optional<double> &indLeft, const boost::optional<double> &indRight, const boost::optional<double> &spLine,
00146                                   const boost::optional<double> &spBefore, const boost::optional<double> &spAfter, const boost::optional<unsigned char> &align,
00147                                   const boost::optional<unsigned> &flags) = 0;
00148   virtual void collectTextBlockStyle(unsigned level, const boost::optional<double> &leftMargin, const boost::optional<double> &rightMargin,
00149                                      const boost::optional<double> &topMargin, const boost::optional<double> &bottomMargin,
00150                                      const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
00151                                      const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
00152                                      const boost::optional<unsigned char> &textDirection) = 0;
00153   // Field list
00154   virtual void collectFieldList(unsigned id, unsigned level) = 0;
00155   virtual void collectTextField(unsigned id, unsigned level, int nameId, int formatStringId) = 0;
00156   virtual void collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) = 0;
00157 
00158   // Temporary hack
00159   virtual void startPage(unsigned pageId) = 0;
00160   virtual void endPage() = 0;
00161   virtual void endPages() = 0;
00162 
00163 private:
00164   VSDCollector(const VSDCollector &);
00165   VSDCollector &operator=(const VSDCollector &);
00166 };
00167 
00168 } // namespace libvisio
00169 
00170 #endif /* VSDCOLLECTOR_H */
00171 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */