CDRCollector.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libcdr
3  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License or as specified alternatively below. You may obtain a copy of
8  * the License at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * Major Contributor(s):
16  * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
17  *
18  *
19  * All Rights Reserved.
20  *
21  * For minor contributions see the git repository.
22  *
23  * Alternatively, the contents of this file may be used under the terms of
24  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
25  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
26  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
27  * instead of those above.
28  */
29 
30 #ifndef __CDRCOLLECTOR_H__
31 #define __CDRCOLLECTOR_H__
32 
33 #include <map>
34 #include <vector>
35 #include <stack>
36 #include <libwpg/libwpg.h>
37 #include <libwpd-stream/libwpd-stream.h>
38 #include <lcms2.h>
39 #include "CDRTypes.h"
40 #include "CDRPath.h"
41 #include "CDROutputElementList.h"
42 #include "libcdr_utils.h"
43 
44 namespace
45 {
46 #include "CDRColorProfiles.h"
47 }
48 
49 namespace libcdr
50 {
51 
53 {
54 public:
57  std::map<unsigned, WPXBinaryData> m_bmps;
58  std::map<unsigned, CDRPattern> m_patterns;
59  std::map<unsigned, WPXBinaryData> m_vects;
60  std::vector<CDRPage> m_pages;
61  std::map<unsigned, CDRColor> m_documentPalette;
62  std::map<unsigned, std::vector<CDRTextLine> > m_texts;
63 
64  unsigned _getRGBColor(const CDRColor &color);
65  unsigned getBMPColor(const CDRColor &color);
66  WPXString getRGBColorString(const CDRColor &color);
67  cmsHTRANSFORM m_colorTransformCMYK2RGB;
68  cmsHTRANSFORM m_colorTransformLab2RGB;
69  cmsHTRANSFORM m_colorTransformRGB2RGB;
70 
71  void setColorTransform(const std::vector<unsigned char> &profile);
72  void setColorTransform(WPXInputStream *input);
73 
74 private:
77 };
78 
80 {
81 public:
83  virtual ~CDRCollector() {}
84 
85  // collector functions
86  virtual void collectPage(unsigned level) = 0;
87  virtual void collectObject(unsigned level) = 0;
88  virtual void collectGroup(unsigned level) = 0;
89  virtual void collectVect(unsigned level) = 0;
90  virtual void collectOtherList() = 0;
91  virtual void collectCubicBezier(double x1, double y1, double x2, double y2, double x, double y) = 0;
92  virtual void collectQuadraticBezier(double x1, double y1, double x, double y) = 0;
93  virtual void collectMoveTo(double x, double y) = 0;
94  virtual void collectLineTo(double x, double y) = 0;
95  virtual void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y) = 0;
96  virtual void collectClosePath() = 0;
97  virtual void collectLevel(unsigned level) = 0;
98  virtual void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform) = 0;
99  virtual void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill) = 0;
100  virtual void collectLineStyle(unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
101  double stretch, double angle, const CDRColor &color, const std::vector<unsigned> &dashArray,
102  unsigned startMarkerId, unsigned endMarkerId) = 0;
103  virtual void collectRotate(double angle, double cx, double cy) = 0;
104  virtual void collectFlags(unsigned flags, bool considerFlags) = 0;
105  virtual void collectPageSize(double width, double height, double offsetX, double offsetY) = 0;
106  virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy) = 0;
107  virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2) = 0;
108  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;
109  virtual void collectBmp(unsigned imageId, const std::vector<unsigned char> &bitmap) = 0;
110  virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector<unsigned char> &pattern) = 0;
111  virtual void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector) = 0;
112  virtual void collectFillTransform(const CDRTransforms &fillTrafos) = 0;
113  virtual void collectFillOpacity(double opacity) = 0;
114  virtual void collectPolygon() = 0;
115  virtual void collectSpline() = 0;
116  virtual void collectColorProfile(const std::vector<unsigned char> &profile) = 0;
117  virtual void collectBBox(double x0, double y0, double x1, double y1) = 0;
118  virtual void collectSpnd(unsigned spnd) = 0;
119  virtual void collectVectorPattern(unsigned id, const WPXBinaryData &data) = 0;
120  virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color) = 0;
121  virtual void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data,
122  const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides) = 0;
123  virtual void collectArtisticText(double x, double y) = 0;
124  virtual void collectParagraphText(double x, double y, double width, double height) = 0;
125  virtual void collectStld(unsigned id, const CDRCharacterStyle &charStyle) = 0;
126 };
127 
128 } // namespace libcdr
129 
130 #endif /* __CDRCOLLECTOR_H__ */
131 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libcdr by doxygen 1.8.1.2