CDRCollector.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/*
3 * This file is part of the libcdr project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef __CDRCOLLECTOR_H__
11#define __CDRCOLLECTOR_H__
12
13#include <map>
14#include <utility>
15#include <vector>
16
17#include <librevenge/librevenge.h>
18#include <librevenge-stream/librevenge-stream.h>
19
20#include <lcms2.h>
21
22#include "CDRTypes.h"
23
24 namespace libcdr
25{
26
27 class CDRPath;
28 class CDRTransforms;
29
30 class CDRParserState
31{
32 public:
33 CDRParserState();
34 ~CDRParserState();
35 std::map<unsigned, librevenge::RVNGBinaryData> m_bmps;
36 std::map<unsigned, CDRPattern> m_patterns;
37 std::map<unsigned, librevenge::RVNGBinaryData> m_vects;
38 std::vector<CDRPage> m_pages;
39 std::map<unsigned, CDRColor> m_documentPalette;
40 std::map<unsigned, std::vector<CDRTextLine> > m_texts;
41 std::map<unsigned, CDRStyle> m_styles;
42 std::map<unsigned, CDRFillStyle> m_fillStyles;
43 std::map<unsigned, CDRLineStyle> m_lineStyles;
44
45 unsigned _getRGBColor(const CDRColor &color);
46 unsigned getBMPColor(const CDRColor &color);
47 librevenge::RVNGString getRGBColorString(const CDRColor &color);
48 cmsHTRANSFORM m_colorTransformCMYK2RGB;
49 cmsHTRANSFORM m_colorTransformLab2RGB;
50 cmsHTRANSFORM m_colorTransformRGB2RGB;
51
52 void setColorTransform(const std::vector<unsigned char> &profile);
53 void setColorTransform(librevenge::RVNGInputStream *input);
54 void getRecursedStyle(CDRStyle &style, unsigned styleId);
55
56 private:
57 CDRParserState(const CDRParserState &);
58 CDRParserState &operator=(const CDRParserState &);
59};
60
61 class CDRCollector
62{
63 public:
64 CDRCollector() {}
65 virtual ~CDRCollector() {}
66
67 // collector functions
68 virtual void collectPage(unsigned level) = 0;
69 virtual void collectObject(unsigned level) = 0;
70 virtual void collectGroup(unsigned level) = 0;
71 virtual void collectVect(unsigned level) = 0;
72 virtual void collectOtherList() = 0;
73 virtual void collectPath(const CDRPath &path) = 0;
74 virtual void collectLevel(unsigned level) = 0;
75 virtual void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform) = 0;
76 virtual void collectFillStyle(unsigned id, const CDRFillStyle &fillStyle) = 0;
77 virtual void collectFillStyleId(unsigned id) = 0;
78 virtual void collectLineStyle(unsigned id, const CDRLineStyle &lineStyle) = 0;
79 virtual void collectLineStyleId(unsigned id) = 0;
80 virtual void collectRotate(double angle, double cx, double cy) = 0;
81 virtual void collectFlags(unsigned flags, bool considerFlags) = 0;
82 virtual void collectPageSize(double width, double height, double offsetX, double offsetY) = 0;
83 virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy) = 0;
84 virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2) = 0;
85 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;
86 virtual void collectBmp(unsigned imageId, const std::vector<unsigned char> &bitmap) = 0;
87 virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector<unsigned char> &pattern) = 0;
88 virtual void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector) = 0;
89 virtual void collectFillTransform(const CDRTransforms &fillTrafos) = 0;
90 virtual void collectFillOpacity(double opacity) = 0;
91 virtual void collectPolygon() = 0;
92 virtual void collectSpline() = 0;
93 virtual void collectColorProfile(const std::vector<unsigned char> &profile) = 0;
94 virtual void collectBBox(double x0, double y0, double x1, double y1) = 0;
95 virtual void collectSpnd(unsigned spnd) = 0;
96 virtual void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data) = 0;
97 virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color) = 0;
98 virtual void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data,
99 const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRStyle> &styleOverrides) = 0;
100 virtual void collectArtisticText(double x, double y) = 0;
101 virtual void collectParagraphText(double x, double y, double width, double height) = 0;
102 virtual void collectStld(unsigned id, const CDRStyle &style) = 0;
103 virtual void collectStyleId(unsigned id) = 0;
104};
105
106} // namespace libcdr
107
108#endif /* __CDRCOLLECTOR_H__ */
109/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
CDRTypes.h
libcdr::CDRCollector
Definition: CDRCollector.h:62
libcdr::CDRCollector::collectOtherList
virtual void collectOtherList()=0
libcdr::CDRCollector::collectFlags
virtual void collectFlags(unsigned flags, bool considerFlags)=0
libcdr::CDRCollector::collectSpnd
virtual void collectSpnd(unsigned spnd)=0
libcdr::CDRCollector::collectRotate
virtual void collectRotate(double angle, double cx, double cy)=0
libcdr::CDRCollector::collectLevel
virtual void collectLevel(unsigned level)=0
libcdr::CDRCollector::collectLineStyleId
virtual void collectLineStyleId(unsigned id)=0
libcdr::CDRCollector::collectText
virtual void collectText(unsigned textId, unsigned styleId, const std::vector< unsigned char > &data, const std::vector< unsigned char > &charDescriptions, const std::map< unsigned, CDRStyle > &styleOverrides)=0
libcdr::CDRCollector::collectSpline
virtual void collectSpline()=0
libcdr::CDRCollector::collectPolygon
virtual void collectPolygon()=0
libcdr::CDRCollector::collectBBox
virtual void collectBBox(double x0, double y0, double x1, double y1)=0
libcdr::CDRCollector::collectBitmap
virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2)=0
libcdr::CDRCollector::collectStld
virtual void collectStld(unsigned id, const CDRStyle &style)=0
libcdr::CDRCollector::collectPpdt
virtual void collectPpdt(const std::vector< std::pair< double, double > > &points, const std::vector< unsigned > &knotVector)=0
libcdr::CDRCollector::collectTransform
virtual void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform)=0
libcdr::CDRCollector::collectPageSize
virtual void collectPageSize(double width, double height, double offsetX, double offsetY)=0
libcdr::CDRCollector::CDRCollector
CDRCollector()
Definition: CDRCollector.h:64
libcdr::CDRCollector::collectPaletteEntry
virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color)=0
libcdr::CDRCollector::collectParagraphText
virtual void collectParagraphText(double x, double y, double width, double height)=0
libcdr::CDRCollector::collectFillStyleId
virtual void collectFillStyleId(unsigned id)=0
libcdr::CDRCollector::collectStyleId
virtual void collectStyleId(unsigned id)=0
libcdr::CDRCollector::collectBmp
virtual void collectBmp(unsigned imageId, const std::vector< unsigned char > &bitmap)=0
libcdr::CDRCollector::collectObject
virtual void collectObject(unsigned level)=0
libcdr::CDRCollector::~CDRCollector
virtual ~CDRCollector()
Definition: CDRCollector.h:65
libcdr::CDRCollector::collectBmp
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
libcdr::CDRCollector::collectVect
virtual void collectVect(unsigned level)=0
libcdr::CDRCollector::collectPage
virtual void collectPage(unsigned level)=0
libcdr::CDRCollector::collectFillOpacity
virtual void collectFillOpacity(double opacity)=0
libcdr::CDRCollector::collectBmpf
virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector< unsigned char > &pattern)=0
libcdr::CDRCollector::collectPath
virtual void collectPath(const CDRPath &path)=0
libcdr::CDRCollector::collectVectorPattern
virtual void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data)=0
libcdr::CDRCollector::collectArtisticText
virtual void collectArtisticText(double x, double y)=0
libcdr::CDRCollector::collectLineStyle
virtual void collectLineStyle(unsigned id, const CDRLineStyle &lineStyle)=0
libcdr::CDRCollector::collectPolygonTransform
virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy)=0
libcdr::CDRCollector::collectFillTransform
virtual void collectFillTransform(const CDRTransforms &fillTrafos)=0
libcdr::CDRCollector::collectColorProfile
virtual void collectColorProfile(const std::vector< unsigned char > &profile)=0
libcdr::CDRCollector::collectFillStyle
virtual void collectFillStyle(unsigned id, const CDRFillStyle &fillStyle)=0
libcdr::CDRCollector::collectGroup
virtual void collectGroup(unsigned level)=0
libcdr::CDRParserState
Definition: CDRCollector.h:31
libcdr::CDRParserState::m_pages
std::vector< CDRPage > m_pages
Definition: CDRCollector.h:38
libcdr::CDRParserState::operator=
CDRParserState & operator=(const CDRParserState &)
libcdr::CDRParserState::m_bmps
std::map< unsigned, librevenge::RVNGBinaryData > m_bmps
Definition: CDRCollector.h:35
libcdr::CDRParserState::m_patterns
std::map< unsigned, CDRPattern > m_patterns
Definition: CDRCollector.h:36
libcdr::CDRParserState::m_vects
std::map< unsigned, librevenge::RVNGBinaryData > m_vects
Definition: CDRCollector.h:37
libcdr::CDRParserState::CDRParserState
CDRParserState(const CDRParserState &)
libcdr::CDRParserState::~CDRParserState
~CDRParserState()
Definition: CDRCollector.cpp:35
libcdr::CDRParserState::m_colorTransformLab2RGB
cmsHTRANSFORM m_colorTransformLab2RGB
Definition: CDRCollector.h:49
libcdr::CDRParserState::m_documentPalette
std::map< unsigned, CDRColor > m_documentPalette
Definition: CDRCollector.h:39
libcdr::CDRParserState::m_lineStyles
std::map< unsigned, CDRLineStyle > m_lineStyles
Definition: CDRCollector.h:43
libcdr::CDRParserState::m_fillStyles
std::map< unsigned, CDRFillStyle > m_fillStyles
Definition: CDRCollector.h:42
libcdr::CDRParserState::m_colorTransformRGB2RGB
cmsHTRANSFORM m_colorTransformRGB2RGB
Definition: CDRCollector.h:50
libcdr::CDRParserState::m_colorTransformCMYK2RGB
cmsHTRANSFORM m_colorTransformCMYK2RGB
Definition: CDRCollector.h:48
libcdr::CDRParserState::setColorTransform
void setColorTransform(const std::vector< unsigned char > &profile)
Definition: CDRCollector.cpp:45
libcdr::CDRParserState::getRecursedStyle
void getRecursedStyle(CDRStyle &style, unsigned styleId)
Definition: CDRCollector.cpp:591
libcdr::CDRParserState::CDRParserState
CDRParserState()
Definition: CDRCollector.cpp:19
libcdr::CDRParserState::m_styles
std::map< unsigned, CDRStyle > m_styles
Definition: CDRCollector.h:41
libcdr::CDRParserState::getBMPColor
unsigned getBMPColor(const CDRColor &color)
Definition: CDRCollector.cpp:90
libcdr::CDRParserState::getRGBColorString
librevenge::RVNGString getRGBColorString(const CDRColor &color)
Definition: CDRCollector.cpp:584
libcdr::CDRParserState::_getRGBColor
unsigned _getRGBColor(const CDRColor &color)
Definition: CDRCollector.cpp:123
libcdr::CDRParserState::m_texts
std::map< unsigned, std::vector< CDRTextLine > > m_texts
Definition: CDRCollector.h:40
libcdr::CDRPath
Definition: CDRPath.h:37
libcdr::CDRTransforms
Definition: CDRTransforms.h:51
libcdr
Definition: CDRDocument.h:17
libcdr::CDRColor
Definition: CDRTypes.h:54
libcdr::CDRFillStyle
Definition: CDRTypes.h:106
libcdr::CDRLineStyle
Definition: CDRTypes.h:118
libcdr::CDRStyle
Definition: CDRTypes.h:142