- 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
19 #include <glm/glm.hpp>
20
21 #include "libetonyek_utils.h"
22 #include "IWORKPath_fwd.h"
23 #include "IWORKShape.h"
24 #include "IWORKStyle.h"
25 #include "IWORKStyleStack.h"
26 #include "IWORKStylesheet.h"
27 #include "IWORKTransformation.h"
28 #include "IWORKTypes.h"
29 #include "IWORKOutputManager.h"
30
31 namespace libetonyek
32 {
33
34 class IWORKDocumentInterface;
35 class IWORKPropertyMap;
36 class IWORKTable;
37 class IWORKText;
38 struct IWORKSize;
39
40 class IWORKCollector
41 {
42 private:
43 struct Level
44 {
45 IWORKGeometryPtr_t m_geometry;
46 IWORKStylePtr_t m_graphicStyle;
47 glm::dmat3 m_trafo;
48
49 Level();
50 };
51
52 public:
53 explicit IWORKCollector(IWORKDocumentInterface *document);
54 ~IWORKCollector();
55
56 // collector functions
57
58 void collectStyle(const IWORKStylePtr_t &style);
59
60 void setGraphicStyle(const IWORKStylePtr_t &style);
61
62 void collectGeometry(const IWORKGeometryPtr_t &geometry);
63
64 void collectBezier(const IWORKPathPtr_t &path);
65 void collectImage(const IWORKImagePtr_t &image);
66 void collectLine(const IWORKLinePtr_t &line);
67 void collectShape();
68
69 void collectBezierPath();
70 void collectPolygonPath(const IWORKSize &size, unsigned edges);
71 void collectRoundedRectanglePath(const IWORKSize &size, double radius);
72 void collectArrowPath(const IWORKSize &size, double headWidth, double stemRelYPos, bool doubleSided);
73 void collectStarPath(const IWORKSize &size, unsigned points, double innerRadius);
74 void collectConnectionPath(const IWORKSize &size, double middleX, double middleY);
75 void collectCalloutPath(const IWORKSize &size, double radius, double tailSize, double tailX, double tailY, bool quoteBubble);
76
77 void collectMedia(const IWORKMediaContentPtr_t &content);
78
79 void collectStylesheet(const IWORKStylesheetPtr_t &stylesheet);
80
81 void collectMetadata(const IWORKMetadata &metadata);
82
83 void collectHeader(const std::string &name);
84 void collectFooter(const std::string &name);
85
86 void collectTable(const boost::shared_ptr<IWORKTable> &table);
87 void collectText(const boost::shared_ptr<IWORKText> &text);
88
89 void startDocument();
90 void endDocument();
91
92 void startGroup();
93 void endGroup();
94
95 boost::shared_ptr<IWORKTable> createTable(const IWORKTableNameMapPtr_t &tableNameMap) const;
96 boost::shared_ptr<IWORKText> createText(bool discardEmptyContent = false) const;
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 protected:
110 void fillMetadata(librevenge::RVNGPropertyList &props);
111
112 private:
113 void pushStyle(const IWORKStylePtr_t &style);
114 void resolveStyle(IWORKStyle &style);
115
116 void collectHeaderFooter(const std::string &name, IWORKHeaderFooterMap_t &map);
117
118 void drawMedia(const IWORKMediaPtr_t &media);
119 void drawShape(const IWORKShapePtr_t &shape);
120
121 virtual void drawTable() = 0;
122 virtual void drawMedia(double x, double y, double w, double h, const std::string &mimetype, const librevenge::RVNGBinaryData &data) = 0;
123 virtual void fillShapeProperties(librevenge::RVNGPropertyList &props) = 0;
124 virtual void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox) = 0;
125
126 protected:
127 IWORKDocumentInterface *m_document;
128
129 std::stack<Level> m_levelStack;
130 IWORKStyleStack m_styleStack;
131 std::stack<IWORKStylesheetPtr_t> m_stylesheetStack;
132 IWORKOutputManager m_outputManager;
133
134 std::deque<IWORKStylePtr_t> m_newStyles;
135
136 boost::shared_ptr<IWORKTable> m_currentTable;
137 boost::shared_ptr<IWORKText> m_currentText;
138
139 IWORKHeaderFooterMap_t m_headers;
140 IWORKHeaderFooterMap_t m_footers;
141
142 private:
143 IWORKPathPtr_t m_currentPath;
144 IWORKDataPtr_t m_currentData;
145 IWORKMediaContentPtr_t m_currentUnfiltered;
146 IWORKMediaContentPtr_t m_currentFiltered;
147 IWORKMediaContentPtr_t m_currentLeveled;
148 IWORKMediaContentPtr_t m_currentContent;
149
150 IWORKMetadata m_metadata;
151
152 int m_groupLevel;
153 };
154
155 } // namespace libetonyek
156
157 #endif // IWORKCOLLECTOR_H_INCLUDED
158
159 /* 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:463
libetonyek
Definition: IWORKBezierElement.cpp:18
IWORKTransformation.h
libetonyek::IWORKCollector::m_stylesheetStack
std::stack< IWORKStylesheetPtr_t > m_stylesheetStack
Definition: IWORKCollector.h:131
libetonyek::IWORKCollector::m_currentFiltered
IWORKMediaContentPtr_t m_currentFiltered
Definition: IWORKCollector.h:146
libetonyek::IWORKToken::path
Definition: IWORKToken.h:183
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:278
libetonyek::IWORKToken::stylesheet
Definition: IWORKToken.h:224
libetonyek::IWORKStyle
Represents a hierarchical style.
Definition: IWORKStyle.h:28
libetonyek::IWORKCollector::collectGeometry
void collectGeometry(const IWORKGeometryPtr_t &geometry)
Definition: IWORKCollector.cpp:317
libetonyek::IWORKCollector::m_currentLeveled
IWORKMediaContentPtr_t m_currentLeveled
Definition: IWORKCollector.h:147
libetonyek::IWORKToken::media
Definition: IWORKToken.h:161
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:154
libetonyek::IWORKCollector::Level::m_graphicStyle
IWORKStylePtr_t m_graphicStyle
Definition: IWORKCollector.h:46
libetonyek::IWORKToken::content
Definition: IWORKToken.h:77
libetonyek::IWORKStyleStack
Representation of a dynamic inheritance of styles.
Definition: IWORKStyleStack.h:34
libetonyek::IWORKCollector::m_currentContent
IWORKMediaContentPtr_t m_currentContent
Definition: IWORKCollector.h:148
libetonyek::IWORKCollector::popStylesheet
void popStylesheet()
Definition: IWORKCollector.cpp:541
libetonyek::IWORKToken::shape
Definition: IWORKToken.h:206
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:137
libetonyek::IWORKCollector::collectBezier
void collectBezier(const IWORKPathPtr_t &path)
Definition: IWORKCollector.cpp:325
libetonyek::IWORKCollector::startGroup
void startGroup()
Definition: IWORKCollector.cpp:485
libetonyek::IWORKCollector::collectStarPath
void collectStarPath(const IWORKSize &size, unsigned points, double innerRadius)
Definition: IWORKCollector.cpp:401
libetonyek::IWORKCollector::m_currentText
boost::shared_ptr< IWORKText > m_currentText
Definition: IWORKCollector.h:137
libetonyek::IWORKToken::h
Definition: IWORKToken.h:271
libetonyek::IWORKCollector::drawMedia
void drawMedia(const IWORKMediaPtr_t &media)
Definition: IWORKCollector.cpp:586
libetonyek::IWORKCollector::collectStyle
void collectStyle(const IWORKStylePtr_t &style)
Definition: IWORKCollector.cpp:302
libetonyek::IWORKCollector::Level
Definition: IWORKCollector.h:43
libetonyek::IWORKGeometryPtr_t
boost::shared_ptr< IWORKGeometry > IWORKGeometryPtr_t
Definition: IWORKTypes_fwd.h:40
libetonyek::IWORKSize
Definition: IWORKTypes.h:36
libetonyek::IWORKCollector::resolveStyle
void resolveStyle(IWORKStyle &style)
Definition: IWORKCollector.cpp:548
libetonyek::IWORKImagePtr_t
boost::shared_ptr< IWORKImage > IWORKImagePtr_t
Definition: IWORKTypes_fwd.h:58
libetonyek::IWORKToken::text
Definition: IWORKToken.h:236
libetonyek::IWORKCollector::popStyle
void popStyle()
Definition: IWORKCollector.cpp:531
libetonyek::IWORKCollector::collectFooter
void collectFooter(const std::string &name)
Definition: IWORKCollector.cpp:450
libetonyek::IWORKCollector::collectHeaderFooter
void collectHeaderFooter(const std::string &name, IWORKHeaderFooterMap_t &map)
Definition: IWORKCollector.cpp:554
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:308
libetonyek::IWORKCollector::collectMetadata
void collectMetadata(const IWORKMetadata &metadata)
Definition: IWORKCollector.cpp:440
libetonyek::IWORKCollector::m_headers
IWORKHeaderFooterMap_t m_headers
Definition: IWORKCollector.h:139
libetonyek::IWORKCollector::~IWORKCollector
~IWORKCollector()
Definition: IWORKCollector.cpp:292
libetonyek::IWORKCollector::createTable
boost::shared_ptr< IWORKTable > createTable(const IWORKTableNameMapPtr_t &tableNameMap) const
Definition: IWORKCollector.cpp:497
libetonyek::IWORKCollector::collectImage
void collectImage(const IWORKImagePtr_t &image)
Definition: IWORKCollector.cpp:330
libetonyek::IWORKToken::style
Definition: IWORKToken.h:221
IWORKStyle.h
libetonyek::IWORKCollector::Level::m_geometry
IWORKGeometryPtr_t m_geometry
Definition: IWORKCollector.h:45
libetonyek::IWORKCollector::startDocument
void startDocument()
Definition: IWORKCollector.cpp:469
libetonyek::IWORKCollector::endDocument
void endDocument()
Definition: IWORKCollector.cpp:474
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:143
libetonyek::IWORKCollector
Definition: IWORKCollector.h:40
libetonyek::IWORKCollector::collectHeader
void collectHeader(const std::string &name)
Definition: IWORKCollector.cpp:445
libetonyek::IWORKCollector::collectConnectionPath
void collectConnectionPath(const IWORKSize &size, double middleX, double middleY)
Definition: IWORKCollector.cpp:406
libetonyek::IWORKCollector::m_levelStack
std::stack< Level > m_levelStack
Definition: IWORKCollector.h:129
name
const char * name
Definition: IWORKToken.cpp:43
libetonyek::IWORKCollector::m_currentTable
boost::shared_ptr< IWORKTable > m_currentTable
Definition: IWORKCollector.h:136
libetonyek::IWORKCollector::collectStylesheet
void collectStylesheet(const IWORKStylesheetPtr_t &stylesheet)
Definition: IWORKCollector.cpp:434
libetonyek::IWORKDataPtr_t
boost::shared_ptr< IWORKData > IWORKDataPtr_t
Definition: IWORKTypes_fwd.h:48
libetonyek::IWORKToken::size
Definition: IWORKToken.h:207
libetonyek::IWORKCollector::collectBezierPath
void collectBezierPath()
Definition: IWORKCollector.cpp:378
libetonyek::IWORKCollector::m_newStyles
std::deque< IWORKStylePtr_t > m_newStyles
Definition: IWORKCollector.h:134
libetonyek::IWORKCollector::m_document
IWORKDocumentInterface * m_document
Definition: IWORKCollector.h:127
libetonyek::IWORKCollector::collectMedia
void collectMedia(const IWORKMediaContentPtr_t &content)
Definition: IWORKCollector.cpp:419
libetonyek::IWORKCollector::Level::Level
Level()
Definition: IWORKCollector.cpp:271
libetonyek::IWORKCollector::fillShapeProperties
virtual void fillShapeProperties(librevenge::RVNGPropertyList &props)=0
IWORKPath_fwd.h
libetonyek::IWORKCollector::getOutputManager
IWORKOutputManager & getOutputManager()
Definition: IWORKCollector.cpp:581
libetonyek::IWORKToken::w
Definition: IWORKToken.h:304
libetonyek::IWORKCollector::drawShape
void drawShape(const IWORKShapePtr_t &shape)
Definition: IWORKCollector.cpp:622
IWORKStylesheet.h
libetonyek::IWORKCollector::m_currentUnfiltered
IWORKMediaContentPtr_t m_currentUnfiltered
Definition: IWORKCollector.h:145
libetonyek::IWORKToken::geometry
Definition: IWORKToken.h:123
IWORKShape.h
libetonyek::IWORKCollector::startLevel
void startLevel()
Definition: IWORKCollector.cpp:507
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:47
libetonyek::IWORKCollector::collectArrowPath
void collectArrowPath(const IWORKSize &size, double headWidth, double stemRelYPos, bool doubleSided)
Definition: IWORKCollector.cpp:393
libetonyek::IWORKCollector::endLevel
void endLevel()
Definition: IWORKCollector.cpp:518
IWORKStyleStack.h
libetonyek::KEY1Token::radius
Definition: KEY1Token.h:156
libetonyek::IWORKHeaderFooterMap_t
boost::unordered_map< std::string, IWORKOutputElements > IWORKHeaderFooterMap_t
Definition: IWORKTypes.h:32
libetonyek::IWORKToken::data
Definition: IWORKToken.h:81
libetonyek::IWORKCollector::endGroup
void endGroup()
Definition: IWORKCollector.cpp:490
libetonyek::IWORKMediaPtr_t
boost::shared_ptr< IWORKMedia > IWORKMediaPtr_t
Definition: IWORKTypes_fwd.h:63
libetonyek::IWORKCollector::m_outputManager
IWORKOutputManager m_outputManager
Definition: IWORKCollector.h:132
libetonyek::NUM1Token::document
Definition: NUM1Token.h:34
libetonyek::IWORKCollector::m_footers
IWORKHeaderFooterMap_t m_footers
Definition: IWORKCollector.h:140
libetonyek::IWORKToken::string
Definition: IWORKToken.h:219
libetonyek::IWORKCollector::collectCalloutPath
void collectCalloutPath(const IWORKSize &size, double radius, double tailSize, double tailX, double tailY, bool quoteBubble)
Definition: IWORKCollector.cpp:411
libetonyek::IWORKCollector::m_metadata
IWORKMetadata m_metadata
Definition: IWORKCollector.h:150
libetonyek::IWORKCollector::fillMetadata
void fillMetadata(librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:569
libetonyek::IWORKCollector::collectLine
void collectLine(const IWORKLinePtr_t &line)
Definition: IWORKCollector.cpp:340
libetonyek::IWORKCollector::collectShape
void collectShape()
Definition: IWORKCollector.cpp:350
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:130
libetonyek::IWORKCollector::pushStyle
void pushStyle()
Definition: IWORKCollector.cpp:526
libetonyek::IWORKCollector::m_groupLevel
int m_groupLevel
Definition: IWORKCollector.h:152
libetonyek::IWORKCollector::createText
boost::shared_ptr< IWORKText > createText(bool discardEmptyContent=false) const
Definition: IWORKCollector.cpp:502
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:383
libetonyek::IWORKCollector::collectTable
void collectTable(const boost::shared_ptr< IWORKTable > &table)
Definition: IWORKCollector.cpp:455
libetonyek::IWORKCollector::pushStylesheet
void pushStylesheet(const IWORKStylesheetPtr_t &stylesheet)
Definition: IWORKCollector.cpp:536
libetonyek_utils.h
libetonyek::IWORKToken::metadata
Definition: IWORKToken.h:163
libetonyek::IWORKToken::tailSize
Definition: IWORKToken.h:298
libetonyek::IWORKCollector::collectRoundedRectanglePath
void collectRoundedRectanglePath(const IWORKSize &size, double radius)
Definition: IWORKCollector.cpp:388
libetonyek::IWORKMetadata
Definition: IWORKTypes.h:252
libetonyek::IWORKCollector::m_currentData
IWORKDataPtr_t m_currentData
Definition: IWORKCollector.h:144