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 collectPath(const CDRPath &path) = 0;
92  virtual void collectLevel(unsigned level) = 0;
93  virtual void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform) = 0;
94  virtual void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill) = 0;
95  virtual void collectLineStyle(unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
96  double stretch, double angle, const CDRColor &color, const std::vector<unsigned> &dashArray,
97  const CDRPath &startMarker, const CDRPath &endMarker) = 0;
98  virtual void collectRotate(double angle, double cx, double cy) = 0;
99  virtual void collectFlags(unsigned flags, bool considerFlags) = 0;
100  virtual void collectPageSize(double width, double height, double offsetX, double offsetY) = 0;
101  virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy) = 0;
102  virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2) = 0;
103  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;
104  virtual void collectBmp(unsigned imageId, const std::vector<unsigned char> &bitmap) = 0;
105  virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector<unsigned char> &pattern) = 0;
106  virtual void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector) = 0;
107  virtual void collectFillTransform(const CDRTransforms &fillTrafos) = 0;
108  virtual void collectFillOpacity(double opacity) = 0;
109  virtual void collectPolygon() = 0;
110  virtual void collectSpline() = 0;
111  virtual void collectColorProfile(const std::vector<unsigned char> &profile) = 0;
112  virtual void collectBBox(double x0, double y0, double x1, double y1) = 0;
113  virtual void collectSpnd(unsigned spnd) = 0;
114  virtual void collectVectorPattern(unsigned id, const WPXBinaryData &data) = 0;
115  virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color) = 0;
116  virtual void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data,
117  const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides) = 0;
118  virtual void collectArtisticText(double x, double y) = 0;
119  virtual void collectParagraphText(double x, double y, double width, double height) = 0;
120  virtual void collectStld(unsigned id, const CDRCharacterStyle &charStyle) = 0;
121 };
122 
123 } // namespace libcdr
124 
125 #endif /* __CDRCOLLECTOR_H__ */
126 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
virtual void collectBBox(double x0, double y0, double x1, double y1)=0
virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2)=0
virtual void collectColorProfile(const std::vector< unsigned char > &profile)=0
virtual void collectText(unsigned textId, unsigned styleId, const std::vector< unsigned char > &data, const std::vector< unsigned char > &charDescriptions, const std::map< unsigned, CDRCharacterStyle > &styleOverrides)=0
virtual void collectPageSize(double width, double height, double offsetX, double offsetY)=0
virtual void collectPath(const CDRPath &path)=0
std::map< unsigned, WPXBinaryData > m_bmps
Definition: CDRCollector.h:57
virtual void collectObject(unsigned level)=0
virtual void collectPage(unsigned level)=0
cmsHTRANSFORM m_colorTransformRGB2RGB
Definition: CDRCollector.h:69
virtual void collectGroup(unsigned level)=0
Definition: CDRPath.h:54
unsigned getBMPColor(const CDRColor &color)
Definition: CDRCollector.cpp:105
unsigned _getRGBColor(const CDRColor &color)
Definition: CDRCollector.cpp:138
virtual void collectFillOpacity(double opacity)=0
virtual void collectFillTransform(const CDRTransforms &fillTrafos)=0
cmsHTRANSFORM m_colorTransformLab2RGB
Definition: CDRCollector.h:68
Definition: CDRTypes.h:103
cmsHTRANSFORM m_colorTransformCMYK2RGB
Definition: CDRCollector.h:67
virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color)=0
Definition: CDRTypes.h:155
virtual ~CDRCollector()
Definition: CDRCollector.h:83
virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy)=0
virtual void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill)=0
virtual void collectRotate(double angle, double cx, double cy)=0
virtual void collectOtherList()=0
WPXString getRGBColorString(const CDRColor &color)
Definition: CDRCollector.cpp:583
std::map< unsigned, CDRColor > m_documentPalette
Definition: CDRCollector.h:61
virtual void collectArtisticText(double x, double y)=0
void setColorTransform(const std::vector< unsigned char > &profile)
Definition: CDRCollector.cpp:60
virtual void collectPpdt(const std::vector< std::pair< double, double > > &points, const std::vector< unsigned > &knotVector)=0
CDRCollector()
Definition: CDRCollector.h:82
virtual void collectVectorPattern(unsigned id, const WPXBinaryData &data)=0
CDRParserState & operator=(const CDRParserState &)
virtual void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform)=0
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
virtual void collectSpline()=0
virtual void collectSpnd(unsigned spnd)=0
std::vector< CDRPage > m_pages
Definition: CDRCollector.h:60
virtual void collectParagraphText(double x, double y, double width, double height)=0
virtual void collectFlags(unsigned flags, bool considerFlags)=0
virtual void collectLevel(unsigned level)=0
virtual void collectVect(unsigned level)=0
~CDRParserState()
Definition: CDRCollector.cpp:50
virtual void collectStld(unsigned id, const CDRCharacterStyle &charStyle)=0
virtual void collectLineStyle(unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth, double stretch, double angle, const CDRColor &color, const std::vector< unsigned > &dashArray, const CDRPath &startMarker, const CDRPath &endMarker)=0
std::map< unsigned, WPXBinaryData > m_vects
Definition: CDRCollector.h:59
CDRParserState()
Definition: CDRCollector.cpp:35
virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector< unsigned char > &pattern)=0
Definition: CDRCollector.h:52
std::map< unsigned, CDRPattern > m_patterns
Definition: CDRCollector.h:58
Definition: CDRTypes.h:71
virtual void collectPolygon()=0
Definition: CDRTypes.h:89
Definition: CDRTransforms.h:66
Definition: CDRCollector.h:79
std::map< unsigned, std::vector< CDRTextLine > > m_texts
Definition: CDRCollector.h:62

Generated for libcdr by doxygen 1.8.6