CDRCollector.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 __CDRCOLLECTOR_H__
00031 #define __CDRCOLLECTOR_H__
00032 
00033 #include <map>
00034 #include <vector>
00035 #include <stack>
00036 #include <libwpg/libwpg.h>
00037 #include <libwpd-stream/libwpd-stream.h>
00038 #include <lcms2.h>
00039 #include "CDRTypes.h"
00040 #include "CDRPath.h"
00041 #include "CDROutputElementList.h"
00042 #include "libcdr_utils.h"
00043 
00044 namespace
00045 {
00046 #include "CDRColorProfiles.h"
00047 }
00048 
00049 namespace libcdr
00050 {
00051 
00052 class CDRParserState
00053 {
00054 public:
00055   CDRParserState();
00056   ~CDRParserState();
00057   std::map<unsigned, CDRFillStyle> m_fillStyles;
00058   std::map<unsigned, CDRLineStyle> m_lineStyles;
00059   std::map<unsigned, WPXBinaryData> m_bmps;
00060   std::map<unsigned, CDRPattern> m_patterns;
00061   std::map<unsigned, WPXBinaryData> m_vects;
00062   std::vector<CDRPage> m_pages;
00063   std::map<unsigned, CDRColor> m_documentPalette;
00064   std::map<unsigned, WPXString> m_fonts;
00065   std::map<unsigned, CDRText> m_texts;
00066 
00067   unsigned _getRGBColor(const CDRColor &color);
00068   unsigned getBMPColor(const CDRColor &color);
00069   WPXString getRGBColorString(const CDRColor &color);
00070   cmsHTRANSFORM m_colorTransformCMYK2RGB;
00071   cmsHTRANSFORM m_colorTransformLab2RGB;
00072   cmsHTRANSFORM m_colorTransformRGB2RGB;
00073 
00074   void setColorTransform(const std::vector<unsigned char> &profile);
00075   void setColorTransform(WPXInputStream *input);
00076 
00077 private:
00078   CDRParserState(const CDRParserState &);
00079   CDRParserState &operator=(const CDRParserState &);
00080 };
00081 
00082 class CDRCollector
00083 {
00084 public:
00085   CDRCollector() {}
00086   virtual ~CDRCollector() {}
00087 
00088   // collector functions
00089   virtual void collectPage(unsigned level) = 0;
00090   virtual void collectObject(unsigned level) = 0;
00091   virtual void collectGroup(unsigned level) = 0;
00092   virtual void collectVect(unsigned level) = 0;
00093   virtual void collectOtherList() = 0;
00094   virtual void collectCubicBezier(double x1, double y1, double x2, double y2, double x, double y) = 0;
00095   virtual void collectQuadraticBezier(double x1, double y1, double x, double y) = 0;
00096   virtual void collectMoveTo(double x, double y) = 0;
00097   virtual void collectLineTo(double x, double y) = 0;
00098   virtual void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y) = 0;
00099   virtual void collectClosePath() = 0;
00100   virtual void collectLevel(unsigned level) = 0;
00101   virtual void collectTransform(double v0, double v1, double x, double v3, double v4, double y, bool considerGroupTransform) = 0;
00102   virtual void collectFildId(unsigned id) = 0;
00103   virtual void collectOutlId(unsigned id) = 0;
00104   virtual void collectFild(unsigned id, unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill) = 0;
00105   virtual void collectOutl(unsigned id, unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
00106                            double stretch, double angle, const CDRColor &color, const std::vector<unsigned short> &dashArray,
00107                            unsigned startMarkerId, unsigned endMarkerId) = 0;
00108   virtual void collectRotate(double angle, double cx, double cy) = 0;
00109   virtual void collectFlags(unsigned flags, bool considerFlags) = 0;
00110   virtual void collectPageSize(double width, double height, double offsetX, double offsetY) = 0;
00111   virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy) = 0;
00112   virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2) = 0;
00113   virtual void collectBmp(unsigned imageId, unsigned colorModel, unsigned width, unsigned height, unsigned bpp, const std::vector<unsigned> &palette, const std::vector<unsigned char> &bitmap) = 0;
00114   virtual void collectBmp(unsigned imageId, const std::vector<unsigned char> &bitmap) = 0;
00115   virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector<unsigned char> &pattern) = 0;
00116   virtual void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector) = 0;
00117   virtual void collectFillTransform(double v0, double v1, double x, double v3, double v4, double y) = 0;
00118   virtual void collectFillOpacity(double opacity) = 0;
00119   virtual void collectPolygon() = 0;
00120   virtual void collectSpline() = 0;
00121   virtual void collectColorProfile(const std::vector<unsigned char> &profile) = 0;
00122   virtual void collectBBox(double x0, double y0, double x1, double y1) = 0;
00123   virtual void collectSpnd(unsigned spnd) = 0;
00124   virtual void collectVectorPattern(unsigned id, const WPXBinaryData &data) = 0;
00125   virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color) = 0;
00126   virtual void collectFont(unsigned fontId, unsigned short fontEncoding, const WPXString &font) = 0;
00127   virtual void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data,
00128                            const std::vector<uint64_t> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides) = 0;
00129   virtual void collectArtisticText() = 0;
00130   virtual void collectParagraphText() = 0;
00131   virtual void collectStlt(const std::map<unsigned, CDRCharacterStyle> &charStyles) = 0;
00132 };
00133 
00134 } // namespace libcdr
00135 
00136 #endif /* __CDRCOLLECTOR_H__ */
00137 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */