IWORKCollector.h Source File documentation

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

IWORKCollector.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 libetonyek 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 IWORKCOLLECTOR_H_INCLUDED
11 #define IWORKCOLLECTOR_H_INCLUDED
12
13 #include <deque>
14 #include <stack>
15 #include <string>
16
17 #include <boost/optional.hpp>
18 #include <boost/shared_ptr.hpp>
19
20 #include "libetonyek_utils.h"
21 #include "IWORKPath_fwd.h"
22 #include "IWORKShape.h"
23 #include "IWORKStyle.h"
24 #include "IWORKStyleStack.h"
25 #include "IWORKStylesheet.h"
26 #include "IWORKTransformation.h"
27 #include "IWORKTypes.h"
28 #include "IWORKOutputManager.h"
29
30 namespace libetonyek
31 {
32
33 class IWORKDocumentInterface;
34 class IWORKLanguageManager;
35 class IWORKPropertyMap;
36 class IWORKRecorder;
37 class IWORKTable;
38 class IWORKText;
39 struct IWORKSize;
40
41 class IWORKCollector
42 {
43 private:
44 struct Level
45 {
46 IWORKGeometryPtr_t m_geometry;
47 IWORKStylePtr_t m_graphicStyle;
48 glm::dmat3 m_trafo;
49
50 Level();
51 };
52
53 public:
54 explicit IWORKCollector(IWORKDocumentInterface *document);
55 ~IWORKCollector();
56
57 void setRecorder(const boost::shared_ptr<IWORKRecorder> &recorder);
58
59 // collector functions
60
61 void collectStyle(const IWORKStylePtr_t &style);
62
63 void setGraphicStyle(const IWORKStylePtr_t &style);
64
65 void collectGeometry(const IWORKGeometryPtr_t &geometry);
66
67 void collectBezier(const IWORKPathPtr_t &path);
68 void collectImage(const IWORKImagePtr_t &image);
69 void collectLine(const IWORKLinePtr_t &line);
70 void collectShape();
71
72 void collectBezierPath();
73 void collectPolygonPath(const IWORKSize &size, unsigned edges);
74 void collectRoundedRectanglePath(const IWORKSize &size, double radius);
75 void collectArrowPath(const IWORKSize &size, double headWidth, double stemRelYPos, bool doubleSided);
76 void collectStarPath(const IWORKSize &size, unsigned points, double innerRadius);
77 void collectConnectionPath(const IWORKSize &size, double middleX, double middleY);
78 void collectCalloutPath(const IWORKSize &size, double radius, double tailSize, double tailX, double tailY, bool quoteBubble);
79
80 void collectMedia(const IWORKMediaContentPtr_t &content);
81
82 void collectStylesheet(const IWORKStylesheetPtr_t &stylesheet);
83
84 void collectMetadata(const IWORKMetadata &metadata);
85
86 void collectHeader(const std::string &name);
87 void collectFooter(const std::string &name);
88
89 void collectTable(const boost::shared_ptr<IWORKTable> &table);
90 void collectText(const boost::shared_ptr<IWORKText> &text);
91
92 void startDocument();
93 void endDocument();
94
95 void startGroup();
96 void endGroup();
97
98 void startLevel();
99 void endLevel();
100
101 void pushStyle();
102 void popStyle();
103
104 void pushStylesheet(const IWORKStylesheetPtr_t &stylesheet);
105 void popStylesheet();
106
107 IWORKOutputManager &getOutputManager();
108
109 public:
110 virtual boost::shared_ptr<IWORKTable> createTable(const IWORKTableNameMapPtr_t &tableNameMap) const;
111 virtual boost::shared_ptr<IWORKText> createText(const IWORKLanguageManager &langManager, bool discardEmptyContent = false) const;
112
113 protected:
114 void fillMetadata(librevenge::RVNGPropertyList &props);
115
116 static void writeFill(const IWORKFill &fill, librevenge::RVNGPropertyList &props);
117
118 private:
119 void pushStyle(const IWORKStylePtr_t &style);
120 void resolveStyle(IWORKStyle &style);
121
122 void collectHeaderFooter(const std::string &name, IWORKHeaderFooterMap_t &map);
123
124 void drawMedia(const IWORKMediaPtr_t &media);
125 void drawShape(const IWORKShapePtr_t &shape);
126
127 virtual void drawTable() = 0;
128 virtual void drawMedia(double x, double y, double w, double h, const std::string &mimetype, const librevenge::RVNGBinaryData &data) = 0;
129 virtual void fillShapeProperties(librevenge::RVNGPropertyList &props) = 0;
130 virtual void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox) = 0;
131
132 protected:
133 IWORKDocumentInterface *m_document;
134 boost::shared_ptr<IWORKRecorder> m_recorder;
135
136 std::stack<Level> m_levelStack;
137 IWORKStyleStack m_styleStack;
138 std::stack<IWORKStylesheetPtr_t> m_stylesheetStack;
139 IWORKOutputManager m_outputManager;
140
141 std::deque<IWORKStylePtr_t> m_newStyles;
142
143 boost::shared_ptr<IWORKTable> m_currentTable;
144 boost::shared_ptr<IWORKText> m_currentText;
145
146 IWORKHeaderFooterMap_t m_headers;
147 IWORKHeaderFooterMap_t m_footers;
148
149 private:
150 IWORKPathPtr_t m_currentPath;
151 IWORKDataPtr_t m_currentData;
152 IWORKMediaContentPtr_t m_currentUnfiltered;
153 IWORKMediaContentPtr_t m_currentFiltered;
154 IWORKMediaContentPtr_t m_currentLeveled;
155 IWORKMediaContentPtr_t m_currentContent;
156
157 IWORKMetadata m_metadata;
158
159 int m_groupLevel;
160 };
161
162 } // namespace libetonyek
163
164 #endif // IWORKCOLLECTOR_H_INCLUDED
165
166 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::IWORKStylesheetPtr_t
boost::shared_ptr< IWORKStylesheet > IWORKStylesheetPtr_t
Definition: IWORKStylesheet.h:19
libetonyek::IWORKCollector::collectText
void collectText(const boost::shared_ptr< IWORKText > &text)
Definition: IWORKCollector.cpp:592
libetonyek
Definition: IWORKBezierElement.cpp:18
IWORKTransformation.h
libetonyek::IWORKCollector::m_stylesheetStack
std::stack< IWORKStylesheetPtr_t > m_stylesheetStack
Definition: IWORKCollector.h:138
libetonyek::IWORKCollector::m_currentFiltered
IWORKMediaContentPtr_t m_currentFiltered
Definition: IWORKCollector.h:153
libetonyek::IWORKToken::path
Definition: IWORKToken.h:216
IWORKOutputManager.h
libetonyek::IWORKMediaContentPtr_t
boost::shared_ptr< IWORKMediaContent > IWORKMediaContentPtr_t
Definition: IWORKTypes_fwd.h:53
libetonyek::IWORKCollector::IWORKCollector
IWORKCollector(IWORKDocumentInterface *document)
Definition: IWORKCollector.cpp:318
libetonyek::IWORKToken::stylesheet
Definition: IWORKToken.h:257
libetonyek::IWORKStyle
Represents a hierarchical style.
Definition: IWORKStyle.h:28
libetonyek::IWORKCollector::collectGeometry
void collectGeometry(const IWORKGeometryPtr_t &geometry)
Definition: IWORKCollector.cpp:375
libetonyek::IWORKCollector::m_currentLeveled
IWORKMediaContentPtr_t m_currentLeveled
Definition: IWORKCollector.h:154
libetonyek::IWORKToken::media
Definition: IWORKToken.h:192
y
double y
Definition: IWORKShape.cpp:43
libetonyek::IWORKOutputManager
A manager for output elements.
Definition: IWORKOutputManager.h:29
libetonyek::IWORKStylePtr_t
boost::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
libetonyek::IWORKShapePtr_t
boost::shared_ptr< IWORKShape > IWORKShapePtr_t
Definition: IWORKShape.h:36
libetonyek::IWORKToken::line
Definition: IWORKToken.h:176
libetonyek::IWORKCollector::Level::m_graphicStyle
IWORKStylePtr_t m_graphicStyle
Definition: IWORKCollector.h:47
libetonyek::IWORKToken::content
Definition: IWORKToken.h:88
libetonyek::IWORKStyleStack
Representation of a dynamic inheritance of styles.
Definition: IWORKStyleStack.h:34
libetonyek::IWORKCollector::m_currentContent
IWORKMediaContentPtr_t m_currentContent
Definition: IWORKCollector.h:155
libetonyek::IWORKCollector::popStylesheet
void popStylesheet()
Definition: IWORKCollector.cpp:706
libetonyek::IWORKCollector::setRecorder
void setRecorder(const boost::shared_ptr< IWORKRecorder > &recorder)
Definition: IWORKCollector.cpp:343
libetonyek::IWORKToken::shape
Definition: IWORKToken.h:239
libetonyek::IWORKCollector::drawTextBox
virtual void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox)=0
libetonyek::IWORKToken::image
Definition: IWORKToken.h:154
libetonyek::IWORKCollector::collectBezier
void collectBezier(const IWORKPathPtr_t &path)
Definition: IWORKCollector.cpp:389
libetonyek::IWORKCollector::startGroup
void startGroup()
Definition: IWORKCollector.cpp:620
libetonyek::IWORKCollector::collectStarPath
void collectStarPath(const IWORKSize &size, unsigned points, double innerRadius)
Definition: IWORKCollector.cpp:499
libetonyek::IWORKCollector::m_currentText
boost::shared_ptr< IWORKText > m_currentText
Definition: IWORKCollector.h:144
libetonyek::IWORKToken::h
Definition: IWORKToken.h:312
libetonyek::IWORKCollector::drawMedia
void drawMedia(const IWORKMediaPtr_t &media)
Definition: IWORKCollector.cpp:757
libetonyek::IWORKCollector::collectStyle
void collectStyle(const IWORKStylePtr_t &style)
Definition: IWORKCollector.cpp:348
libetonyek::IWORKCollector::Level
Definition: IWORKCollector.h:44
libetonyek::IWORKGeometryPtr_t
boost::shared_ptr< IWORKGeometry > IWORKGeometryPtr_t
Definition: IWORKTypes_fwd.h:40
libetonyek::IWORKSize
Definition: IWORKTypes.h:37
libetonyek::IWORKCollector::resolveStyle
void resolveStyle(IWORKStyle &style)
Definition: IWORKCollector.cpp:719
libetonyek::IWORKCollector::createText
virtual boost::shared_ptr< IWORKText > createText(const IWORKLanguageManager &langManager, bool discardEmptyContent=false) const
Definition: IWORKCollector.cpp:649
libetonyek::IWORKImagePtr_t
boost::shared_ptr< IWORKImage > IWORKImagePtr_t
Definition: IWORKTypes_fwd.h:58
libetonyek::IWORKToken::text
Definition: IWORKToken.h:270
libetonyek::IWORKCollector::popStyle
void popStyle()
Definition: IWORKCollector.cpp:690
libetonyek::IWORKCollector::collectFooter
void collectFooter(const std::string &name)
Definition: IWORKCollector.cpp:573
libetonyek::IWORKCollector::collectHeaderFooter
void collectHeaderFooter(const std::string &name, IWORKHeaderFooterMap_t &map)
Definition: IWORKCollector.cpp:725
libetonyek::IWORKDocumentInterface
Definition: IWORKDocumentInterface.h:18
x
double x
Definition: IWORKShape.cpp:42
libetonyek::IWORKCollector::drawTable
virtual void drawTable()=0
libetonyek::IWORKCollector::setGraphicStyle
void setGraphicStyle(const IWORKStylePtr_t &style)
Definition: IWORKCollector.cpp:360
libetonyek::IWORKCollector::collectMetadata
void collectMetadata(const IWORKMetadata &metadata)
Definition: IWORKCollector.cpp:563
libetonyek::IWORKCollector::m_headers
IWORKHeaderFooterMap_t m_headers
Definition: IWORKCollector.h:146
libetonyek::IWORKCollector::~IWORKCollector
~IWORKCollector()
Definition: IWORKCollector.cpp:333
libetonyek::IWORKCollector::createTable
virtual boost::shared_ptr< IWORKTable > createTable(const IWORKTableNameMapPtr_t &tableNameMap) const
Definition: IWORKCollector.cpp:644
libetonyek::IWORKCollector::collectImage
void collectImage(const IWORKImagePtr_t &image)
Definition: IWORKCollector.cpp:397
libetonyek::IWORKToken::style
Definition: IWORKToken.h:254
IWORKStyle.h
libetonyek::IWORKCollector::Level::m_geometry
IWORKGeometryPtr_t m_geometry
Definition: IWORKCollector.h:46
libetonyek::IWORKCollector::startDocument
void startDocument()
Definition: IWORKCollector.cpp:604
libetonyek::IWORKCollector::endDocument
void endDocument()
Definition: IWORKCollector.cpp:609
libetonyek::IWORKPathPtr_t
boost::shared_ptr< IWORKPath > IWORKPathPtr_t
Definition: IWORKPath_fwd.h:20
libetonyek::IWORKCollector::m_currentPath
IWORKPathPtr_t m_currentPath
Definition: IWORKCollector.h:150
libetonyek::IWORKCollector
Definition: IWORKCollector.h:41
libetonyek::IWORKCollector::collectHeader
void collectHeader(const std::string &name)
Definition: IWORKCollector.cpp:568
libetonyek::IWORKCollector::collectConnectionPath
void collectConnectionPath(const IWORKSize &size, double middleX, double middleY)
Definition: IWORKCollector.cpp:508
libetonyek::IWORKCollector::m_levelStack
std::stack< Level > m_levelStack
Definition: IWORKCollector.h:136
name
const char * name
Definition: IWORKToken.cpp:43
libetonyek::IWORKCollector::m_currentTable
boost::shared_ptr< IWORKTable > m_currentTable
Definition: IWORKCollector.h:143
libetonyek::IWORKCollector::collectStylesheet
void collectStylesheet(const IWORKStylesheetPtr_t &stylesheet)
Definition: IWORKCollector.cpp:551
libetonyek::IWORKDataPtr_t
boost::shared_ptr< IWORKData > IWORKDataPtr_t
Definition: IWORKTypes_fwd.h:48
libetonyek::IWORKCollector::m_recorder
boost::shared_ptr< IWORKRecorder > m_recorder
Definition: IWORKCollector.h:134
libetonyek::IWORKToken::size
Definition: IWORKToken.h:240
libetonyek::IWORKCollector::collectBezierPath
void collectBezierPath()
Definition: IWORKCollector.cpp:463
libetonyek::IWORKCollector::m_newStyles
std::deque< IWORKStylePtr_t > m_newStyles
Definition: IWORKCollector.h:141
libetonyek::IWORKCollector::m_document
IWORKDocumentInterface * m_document
Definition: IWORKCollector.h:133
libetonyek::IWORKCollector::writeFill
static void writeFill(const IWORKFill &fill, librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:822
libetonyek::IWORKFill
boost::variant< IWORKColor, IWORKGradient, IWORKFillImage > IWORKFill
Definition: IWORKTypes.h:243
libetonyek::IWORKCollector::collectMedia
void collectMedia(const IWORKMediaContentPtr_t &content)
Definition: IWORKCollector.cpp:530
libetonyek::IWORKCollector::Level::Level
Level()
Definition: IWORKCollector.cpp:311
libetonyek::IWORKCollector::fillShapeProperties
virtual void fillShapeProperties(librevenge::RVNGPropertyList &props)=0
IWORKPath_fwd.h
libetonyek::IWORKCollector::getOutputManager
IWORKOutputManager & getOutputManager()
Definition: IWORKCollector.cpp:752
libetonyek::IWORKToken::w
Definition: IWORKToken.h:354
libetonyek::IWORKCollector::drawShape
void drawShape(const IWORKShapePtr_t &shape)
Definition: IWORKCollector.cpp:793
IWORKStylesheet.h
libetonyek::IWORKCollector::m_currentUnfiltered
IWORKMediaContentPtr_t m_currentUnfiltered
Definition: IWORKCollector.h:152
libetonyek::IWORKToken::geometry
Definition: IWORKToken.h:139
IWORKShape.h
libetonyek::IWORKCollector::startLevel
void startLevel()
Definition: IWORKCollector.cpp:654
libetonyek::IWORKTableNameMapPtr_t
boost::shared_ptr< IWORKTableNameMap_t > IWORKTableNameMapPtr_t
Definition: IWORKTypes_fwd.h:33
libetonyek::IWORKCollector::Level::m_trafo
glm::dmat3 m_trafo
Definition: IWORKCollector.h:48
libetonyek::IWORKCollector::collectArrowPath
void collectArrowPath(const IWORKSize &size, double headWidth, double stemRelYPos, bool doubleSided)
Definition: IWORKCollector.cpp:486
libetonyek::IWORKCollector::endLevel
void endLevel()
Definition: IWORKCollector.cpp:671
IWORKStyleStack.h
libetonyek::KEY1Token::radius
Definition: KEY1Token.h:156
libetonyek::IWORKHeaderFooterMap_t
boost::unordered_map< std::string, IWORKOutputElements > IWORKHeaderFooterMap_t
Definition: IWORKTypes.h:33
libetonyek::IWORKToken::data
Definition: IWORKToken.h:95
libetonyek::IWORKCollector::endGroup
void endGroup()
Definition: IWORKCollector.cpp:631
libetonyek::IWORKMediaPtr_t
boost::shared_ptr< IWORKMedia > IWORKMediaPtr_t
Definition: IWORKTypes_fwd.h:63
libetonyek::IWORKLanguageManager
Definition: IWORKLanguageManager.h:24
libetonyek::IWORKCollector::m_outputManager
IWORKOutputManager m_outputManager
Definition: IWORKCollector.h:139
libetonyek::NUM1Token::document
Definition: NUM1Token.h:34
libetonyek::IWORKCollector::m_footers
IWORKHeaderFooterMap_t m_footers
Definition: IWORKCollector.h:147
libetonyek::IWORKToken::string
Definition: IWORKToken.h:252
libetonyek::IWORKCollector::collectCalloutPath
void collectCalloutPath(const IWORKSize &size, double radius, double tailSize, double tailX, double tailY, bool quoteBubble)
Definition: IWORKCollector.cpp:517
libetonyek::IWORKCollector::m_metadata
IWORKMetadata m_metadata
Definition: IWORKCollector.h:157
libetonyek::IWORKCollector::fillMetadata
void fillMetadata(librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:740
libetonyek::IWORKCollector::collectLine
void collectLine(const IWORKLinePtr_t &line)
Definition: IWORKCollector.cpp:413
libetonyek::IWORKCollector::collectShape
void collectShape()
Definition: IWORKCollector.cpp:429
libetonyek::IWORKLinePtr_t
boost::shared_ptr< IWORKLine > IWORKLinePtr_t
Definition: IWORKTypes_fwd.h:44
IWORKTypes.h
libetonyek::IWORKCollector::m_styleStack
IWORKStyleStack m_styleStack
Definition: IWORKCollector.h:137
libetonyek::IWORKCollector::pushStyle
void pushStyle()
Definition: IWORKCollector.cpp:685
libetonyek::IWORKCollector::m_groupLevel
int m_groupLevel
Definition: IWORKCollector.h:159
libetonyek::IWORKTextPtr_t
boost::shared_ptr< IWORKText > IWORKTextPtr_t
Definition: IWORKText_fwd.h:18
libetonyek::IWORKCollector::collectPolygonPath
void collectPolygonPath(const IWORKSize &size, unsigned edges)
Definition: IWORKCollector.cpp:468
libetonyek::IWORKCollector::collectTable
void collectTable(const boost::shared_ptr< IWORKTable > &table)
Definition: IWORKCollector.cpp:578
libetonyek::IWORKCollector::pushStylesheet
void pushStylesheet(const IWORKStylesheetPtr_t &stylesheet)
Definition: IWORKCollector.cpp:695
libetonyek_utils.h
libetonyek::IWORKToken::metadata
Definition: IWORKToken.h:194
libetonyek::IWORKToken::tailSize
Definition: IWORKToken.h:347
libetonyek::IWORKCollector::collectRoundedRectanglePath
void collectRoundedRectanglePath(const IWORKSize &size, double radius)
Definition: IWORKCollector.cpp:477
libetonyek::IWORKMetadata
Definition: IWORKTypes.h:255
libetonyek::IWORKToken::fill
Definition: IWORKToken.h:108
libetonyek::IWORKCollector::m_currentData
IWORKDataPtr_t m_currentData
Definition: IWORKCollector.h:151