CDRContentCollector.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libcdr
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) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
00017  *
00018  *
00019  * All Rights Reserved.
00020  *
00021  * For minor contributions see the git repository.
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
00025  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00026  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
00027  * instead of those above.
00028  */
00029 
00030 #ifndef __CDRCONTENTCOLLECTOR_H__
00031 #define __CDRCONTENTCOLLECTOR_H__
00032 
00033 #include <map>
00034 #include <vector>
00035 #include <stack>
00036 #include <libwpg/libwpg.h>
00037 #include <lcms2.h>
00038 #include "CDRTypes.h"
00039 #include "CDRPath.h"
00040 #include "CDROutputElementList.h"
00041 #include "CDRCollector.h"
00042 
00043 namespace libcdr
00044 {
00045 
00046 class CDRContentCollector : public CDRCollector
00047 {
00048 public:
00049   CDRContentCollector(CDRParserState &ps, ::libwpg::WPGPaintInterface *painter);
00050   virtual ~CDRContentCollector();
00051 
00052   // collector functions
00053   void collectPage(unsigned level);
00054   void collectObject(unsigned level);
00055   void collectGroup(unsigned level);
00056   void collectVect(unsigned level);
00057   void collectOtherList();
00058   void collectCubicBezier(double x1, double y1, double x2, double y2, double x, double y);
00059   void collectQuadraticBezier(double x1, double y1, double x, double y);
00060   void collectMoveTo(double x, double y);
00061   void collectLineTo(double x, double y);
00062   void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y);
00063   void collectClosePath();
00064   void collectLevel(unsigned level);
00065   void collectTransform(double v0, double v1, double x, double v3, double v4, double y, bool considerGroupTransform);
00066   void collectFildId(unsigned id);
00067   void collectOutlId(unsigned id);
00068   void collectFild(unsigned, unsigned short, const CDRColor &, const CDRColor &, const CDRGradient &, const CDRImageFill &) {}
00069   void collectOutl(unsigned, unsigned short, unsigned short, unsigned short, double, double, double, const CDRColor &,
00070                    const std::vector<unsigned short> &, unsigned, unsigned) {}
00071   void collectRotate(double angle, double cx, double cy);
00072   void collectFlags(unsigned flags, bool considerFlags);
00073   void collectPageSize(double, double, double, double) {}
00074   void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy);
00075   void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2);
00076   void collectBmp(unsigned, unsigned, unsigned, unsigned, unsigned, const std::vector<unsigned>&, const std::vector<unsigned char>&) {}
00077   void collectBmp(unsigned, const std::vector<unsigned char>&) {}
00078   void collectBmpf(unsigned, unsigned, unsigned, const std::vector<unsigned char> &) {}
00079   void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector);
00080   void collectFillTransform(double v0, double v1, double x, double v3, double v4, double y);
00081   void collectFillOpacity(double opacity);
00082   void collectPolygon();
00083   void collectSpline();
00084   void collectColorProfile(const std::vector<unsigned char> &) {}
00085   void collectBBox(double x0, double y0, double x1, double y1);
00086   void collectSpnd(unsigned spnd);
00087   void collectVectorPattern(unsigned id, const WPXBinaryData &data);
00088   void collectPaletteEntry(unsigned, unsigned, const CDRColor &) {}
00089   void collectFont(unsigned, unsigned short, const WPXString &) {}
00090   void collectText(unsigned, unsigned, const std::vector<unsigned char>&,
00091                    const std::vector<uint64_t>&, const std::map<unsigned, CDRCharacterStyle>&) {}
00092   void collectArtisticText();
00093   void collectParagraphText();
00094   void collectStlt(const std::map<unsigned, CDRCharacterStyle> &) {}
00095 
00096 private:
00097   CDRContentCollector(const CDRContentCollector &);
00098   CDRContentCollector &operator=(const CDRContentCollector &);
00099 
00100   // helper functions
00101   void _startPage(double width, double height);
00102   void _endPage();
00103   void _flushCurrentPath();
00104 
00105   void _fillProperties(WPXPropertyList &propList, WPXPropertyListVector &vec);
00106   void _lineProperties(WPXPropertyList &propList);
00107   void _generateBitmapFromPattern(WPXBinaryData &bitmap, const CDRPattern &pattern, const CDRColor &fgColor, const CDRColor &bgColor);
00108 
00109   libwpg::WPGPaintInterface *m_painter;
00110 
00111   bool m_isPageProperties;
00112   bool m_isPageStarted;
00113   bool m_ignorePage;
00114 
00115   CDRPage m_page;
00116   unsigned m_pageIndex;
00117   unsigned m_currentFildId, m_currentOutlId;
00118   unsigned m_spnd;
00119   unsigned m_currentObjectLevel, m_currentGroupLevel, m_currentVectLevel, m_currentPageLevel;
00120   CDRImage m_currentImage;
00121   CDRText m_currentText;
00122   double m_currentTextOffsetX;
00123   double m_currentTextOffsetY;
00124   CDRBBox m_currentBBox;
00125 
00126   CDRPath m_currentPath;
00127   CDRTransform m_currentTransform, m_fillTransform;
00128   CDRPolygon *m_polygon;
00129   bool m_isInPolygon;
00130   bool m_isInSpline;
00131   std::stack<CDROutputElementList> *m_outputElements;
00132   std::stack<CDROutputElementList> m_contentOutputElements;
00133   std::stack<CDROutputElementList> m_fillOutputElements;
00134   std::stack<unsigned> m_groupLevels;
00135   std::stack<CDRTransform> m_groupTransforms;
00136   CDRSplineData m_splineData;
00137   double m_fillOpacity;
00138 
00139   CDRParserState &m_ps;
00140 };
00141 
00142 } // namespace libcdr
00143 
00144 #endif /* __CDRCOLLECTOR_H__ */
00145 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */