VSDXCollector.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 VSDXCOLLECTOR_H
00032 #define VSDXCOLLECTOR_H
00033 
00034 #include <vector>
00035 #include "VSDXParser.h"
00036 
00037 namespace libvisio
00038 {
00039 
00040 class VSDXCollector
00041 {
00042 public:
00043   VSDXCollector() {};
00044   virtual ~VSDXCollector() {}
00045 
00046   virtual void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) = 0;
00047   virtual void collectForeignData(unsigned id, unsigned level, const WPXBinaryData &binaryData) = 0;
00048   virtual void collectOLEList(unsigned id, unsigned level) = 0;
00049   virtual void collectOLEData(unsigned id, unsigned level, const WPXBinaryData &oleData) = 0;
00050   virtual void collectEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop) = 0;
00051   virtual void collectLine(unsigned id, unsigned level, double strokeWidth, Colour c, unsigned linePattern, unsigned char startMarker, unsigned char endMarker, unsigned lineCap) = 0;
00052   virtual void collectFillAndShadow(unsigned id, unsigned level, unsigned colourIndexFG, unsigned colourIndexBG,
00053                                     unsigned fillPattern, unsigned fillFGTransparency, unsigned fillBGTransparency, unsigned shadowPattern, Colour shfgc,
00054                                     double shadowOffsetX, double shadowOffsetY) = 0;
00055   virtual void collectFillAndShadow(unsigned id, unsigned level, unsigned colourIndexFG, unsigned colourIndexBG, unsigned fillPattern,
00056                                     unsigned fillFGTransparency, unsigned fillBGTransparency, unsigned shadowPattern, Colour shfgc) = 0;
00057   virtual void collectGeometry(unsigned id, unsigned level, unsigned char geomFlags) = 0;
00058   virtual void collectMoveTo(unsigned id, unsigned level, double x, double y) = 0;
00059   virtual void collectLineTo(unsigned id, unsigned level, double x, double y) = 0;
00060   virtual void collectArcTo(unsigned id, unsigned level, double x2, double y2, double bow) = 0;
00061   virtual void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree,
00062                               std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) = 0;
00063   virtual void collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) = 0;
00064   virtual void collectPolylineTo(unsigned id , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > &points) = 0;
00065   virtual void collectPolylineTo(unsigned id , unsigned level, double x, double y, unsigned dataID) = 0;
00066   virtual void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, unsigned degree, double lastKnot,
00067                                 std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) = 0;
00068   virtual void collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points) = 0;
00069   virtual void collectXFormData(unsigned id, unsigned level, const XForm &xform) = 0;
00070   virtual void collectTxtXForm(unsigned id, unsigned level, const XForm &txtxform) = 0;
00071   virtual void collectShapeId(unsigned id, unsigned level, unsigned shapeId) = 0;
00072   virtual void collectForeignDataType(unsigned id, unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height) = 0;
00073   virtual void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale) = 0;
00074   virtual void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, unsigned currentPageID) = 0;
00075   virtual void collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle) = 0;
00076   virtual void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) = 0;
00077   virtual void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot) = 0;
00078   virtual void collectSplineEnd() = 0;
00079   virtual void collectInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2) = 0;
00080 
00081   virtual void collectUnhandledChunk(unsigned id, unsigned level) = 0;
00082 
00083   virtual void collectColours(const std::vector<Colour> &colours) = 0;
00084   virtual void collectFont(unsigned short fontID, const ::WPXBinaryData &textStream, TextFormat format) = 0;
00085   virtual void collectText(unsigned id, unsigned level, const ::WPXBinaryData &textStream, TextFormat format) = 0;
00086   virtual void collectVSDXCharStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, unsigned langId,
00087                                     double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout,
00088                                     bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, WPXString fontFace) = 0;
00089   virtual void collectVSDXParaStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight,
00090                                     double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags) = 0;
00091   virtual void collectTextBlock(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin,
00092                                 unsigned char verticalAlign, unsigned char bgClrId, const Colour &bgColour, double defaultTabStop,
00093                                 unsigned char textDirection) = 0;
00094   virtual void collectNameList(unsigned id, unsigned level) = 0;
00095   virtual void collectName(unsigned id, unsigned level,  const ::WPXBinaryData &name, TextFormat format) = 0;
00096 
00097   // Style collectors
00098   virtual void collectStyleSheet(unsigned id, unsigned level, unsigned parentLineStyle, unsigned parentFillStyle, unsigned parentTextStyle) = 0;
00099   virtual void collectLineStyle(unsigned id, unsigned level, double strokeWidth, Colour c, unsigned char linePattern, unsigned char startMarker, unsigned char endMarker, unsigned char lineCap) = 0;
00100   virtual void collectFillStyle(unsigned id, unsigned level, unsigned char colourIndexFG, unsigned char colourIndexBG, unsigned char fillPattern,
00101                                 unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc,
00102                                 double shadowOffsetX, double shadowOffsetY) = 0;
00103   virtual void collectFillStyle(unsigned id, unsigned level, unsigned char colourIndexFG, unsigned char colourIndexBG, unsigned char fillPattern,
00104                                 unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc) = 0;
00105   virtual void collectCharIXStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, unsigned langId,
00106                                   double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout,
00107                                   bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, WPXString fontFace) = 0;
00108   virtual void collectParaIXStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight,
00109                                   double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags) = 0;
00110   virtual void collectTextBlockStyle(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin,
00111                                      unsigned char verticalAlign, unsigned char bgClrId, const Colour &bgColour, double defaultTabStop,
00112                                      unsigned char textDirection) = 0;
00113 
00114   // Field list
00115   virtual void collectFieldList(unsigned id, unsigned level) = 0;
00116   virtual void collectTextField(unsigned id, unsigned level, int nameId, int formatStringId) = 0;
00117   virtual void collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) = 0;
00118 
00119   // Temporary hack
00120   virtual void startPage() = 0;
00121   virtual void endPage() = 0;
00122   virtual void endPages(const std::vector<unsigned> &pageOrder) = 0;
00123 
00124 protected:
00125   const ::WPXString getColourString(const Colour &c) const
00126   {
00127     ::WPXString sColour;
00128     sColour.sprintf("#%.2x%.2x%.2x", c.r, c.g, c.b);
00129     return sColour;
00130   }
00131 
00132 private:
00133   VSDXCollector(const VSDXCollector &);
00134   VSDXCollector &operator=(const VSDXCollector &);
00135 };
00136 
00137 } // namespace libvisio
00138 
00139 #endif /* VSDXCOLLECTOR_H */
00140 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */