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 <memory>
15 #include <stack>
16 #include <string>
17 
18 #include <boost/optional.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 
42 {
43 private:
44  struct Level
45  {
48  glm::dmat3 m_trafo;
49  glm::dmat3 m_previousTrafo;
50 
51  Level();
52  };
53 
54 public:
56  virtual ~IWORKCollector();
57 
58  void setRecorder(const std::shared_ptr<IWORKRecorder> &recorder);
59 
60  // collector functions
61 
62  void collectStyle(const IWORKStylePtr_t &style);
63 
65 
67  void setAccumulateTransformTo(bool accumulate);
68 
69  void collectBezier(const IWORKPathPtr_t &path);
70  void collectLine(const IWORKLinePtr_t &line);
71  void collectShape(const boost::optional<int> &order=boost::none, const boost::optional<unsigned> &resizeFlags=boost::none, bool locked=false);
72 
73  void collectBezierPath();
74  void collectPolygonPath(const IWORKSize &size, unsigned edges);
75  void collectRoundedRectanglePath(const IWORKSize &size, double radius);
76  void collectArrowPath(const IWORKSize &size, double headWidth, double stemRelYPos, bool doubleSided);
77  void collectStarPath(const IWORKSize &size, unsigned points, double innerRadius);
79  void collectCalloutPath(const IWORKSize &size, double radius, double tailSize, double tailX, double tailY, bool quoteBubble);
80 
82  const boost::optional<int> &order=boost::none, bool locked=false);
83  void collectMedia(const IWORKMediaContentPtr_t &content, const IWORKGeometryPtr_t &cropGeometry=IWORKGeometryPtr_t(), const boost::optional<int> &order=boost::none);
84 
86 
88 
89  void collectHeader(const std::string &name);
90  void collectFooter(const std::string &name);
91 
92  void collectTable(const std::shared_ptr<IWORKTable> &table);
93  void collectText(const std::shared_ptr<IWORKText> &text);
94  virtual void collectStickyNote();
95 
96  void startDocument(const librevenge::RVNGPropertyList &props);
97  void endDocument();
98 
99  void startAttachment();
100  void endAttachment();
101 
102  void startAttachments();
103  void endAttachments();
104 
105  void startGroup();
106  void endGroup();
107 
108  // really add a group in the final file
109  void openGroup();
110  void closeGroup();
111  bool getOpenGroupLevel() const
112  {
113  return m_groupOpenLevel;
114  };
115 
116  void startLevel();
117  void endLevel();
118 
119  void pushStyle();
120  void popStyle();
121 
123  void popStylesheet();
125  {
126  if (m_stylesheetStack.empty())
127  return IWORKStylesheetPtr_t();
128  return m_stylesheetStack.top();
129  }
130 
132 
133 public:
134  virtual std::shared_ptr<IWORKTable> createTable(const IWORKTableNameMapPtr_t &tableNameMap, const IWORKLanguageManager &langManager) const;
135  virtual std::shared_ptr<IWORKText> createText(const IWORKLanguageManager &langManager, bool discardEmptyContent = false, bool allowListInsertion=true) const;
136 
137 protected:
138  void fillMetadata(librevenge::RVNGPropertyList &props);
139 
140  static void fillGraphicProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props,
141  bool isSurface=true, bool isFrame=false);
142  static void fillLayoutProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props);
143  static void fillTextAutoSizeProps(const boost::optional<unsigned> &resizeFlags, const IWORKGeometryPtr_t &boundingBox, librevenge::RVNGPropertyList &props);
144  static void fillWrapProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props,
145  const boost::optional<int> &order);
146  static void writeFill(const IWORKFill &fill, librevenge::RVNGPropertyList &props);
147  void drawShape(const IWORKShapePtr_t &shape);
148 
149 private:
150  void pushStyle(const IWORKStylePtr_t &style);
151 
153 
154  void drawLine(const IWORKLinePtr_t &line);
155  void drawMedia(const IWORKMediaPtr_t &media);
156  virtual void drawTable() = 0;
157  virtual void drawMedia(double x, double y, const librevenge::RVNGPropertyList &data) = 0;
158  virtual void fillShapeProperties(librevenge::RVNGPropertyList &props) = 0;
159  virtual bool createFrameStylesForTextBox() const = 0;
160  virtual void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox, const librevenge::RVNGPropertyList &style) = 0;
161 
162 protected:
165 
167  std::shared_ptr<IWORKRecorder> m_recorder;
168 
169  std::stack<Level> m_levelStack;
171  std::stack<IWORKStylesheetPtr_t> m_stylesheetStack;
173 
174  std::deque<IWORKStylePtr_t> m_newStyles;
175 
176  std::shared_ptr<IWORKTable> m_currentTable;
177  std::shared_ptr<IWORKText> m_currentText;
178 
181 
182  std::stack<IWORKPathPtr_t> m_pathStack;
184 
185  std::stack<bool> m_attachmentStack;
188 
189 private:
195 
197 
201 };
202 
203 } // namespace libetonyek
204 
205 #endif // IWORKCOLLECTOR_H_INCLUDED
206 
207 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
std::shared_ptr< IWORKGeometry > IWORKGeometryPtr_t
Definition: IWORKTypes_fwd.h:41
std::stack< IWORKStylesheetPtr_t > m_stylesheetStack
Definition: IWORKCollector.h:171
IWORKMediaContentPtr_t m_currentFiltered
Definition: IWORKCollector.h:192
Definition: IWORKToken.h:365
void collectTable(const std::shared_ptr< IWORKTable > &table)
Definition: IWORKCollector.cpp:491
IWORKCollector(IWORKDocumentInterface *document)
Definition: IWORKCollector.cpp:191
Definition: IWORKToken.h:424
void collectGeometry(const IWORKGeometryPtr_t &geometry)
Definition: IWORKCollector.cpp:267
IWORKMediaContentPtr_t m_currentLeveled
Definition: IWORKCollector.h:193
Definition: IWORKToken.h:326
double y
Definition: IWORKShape.cpp:47
A manager for output elements.
Definition: IWORKOutputManager.h:29
void collectConnectionPath(const IWORKConnectionPath &path)
Definition: IWORKCollector.cpp:419
Definition: IWORKToken.h:303
IWORKStylePtr_t m_graphicStyle
Definition: IWORKCollector.h:47
Definition: IWORKToken.h:167
Representation of a dynamic inheritance of styles.
Definition: IWORKStyleStack.h:34
IWORKMediaContentPtr_t m_currentContent
Definition: IWORKCollector.h:194
void popStylesheet()
Definition: IWORKCollector.cpp:705
Definition: IWORKToken.h:401
void startAttachments()
Definition: IWORKCollector.cpp:672
std::shared_ptr< IWORKMedia > IWORKMediaPtr_t
Definition: IWORKTypes_fwd.h:64
bool m_inAttachment
Definition: IWORKCollector.h:186
std::shared_ptr< IWORKRecorder > m_recorder
Definition: IWORKCollector.h:167
std::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
static void fillWrapProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props, const boost::optional< int > &order)
Definition: IWORKCollector.cpp:966
Definition: PAG1Token.h:43
Definition: IWORKToken.h:264
void setAccumulateTransformTo(bool accumulate)
Definition: IWORKCollector.cpp:262
void collectShape(const boost::optional< int > &order=boost::none, const boost::optional< unsigned > &resizeFlags=boost::none, bool locked=false)
Definition: IWORKCollector.cpp:337
void collectBezier(const IWORKPathPtr_t &path)
Definition: IWORKCollector.cpp:285
void startGroup()
Definition: IWORKCollector.cpp:539
void collectStarPath(const IWORKSize &size, unsigned points, double innerRadius)
Definition: IWORKCollector.cpp:410
bool m_inAttachments
Definition: IWORKCollector.h:187
static void fillGraphicProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props, bool isSurface=true, bool isFrame=false)
Definition: IWORKCollector.cpp:744
void drawMedia(const IWORKMediaPtr_t &media)
Definition: IWORKCollector.cpp:1100
void collectStyle(const IWORKStylePtr_t &style)
Definition: IWORKCollector.cpp:235
Definition: IWORKCollector.h:44
Definition: IWORKTypes.h:44
Definition: IWORKToken.h:472
void popStyle()
Definition: IWORKCollector.cpp:689
void collectFooter(const std::string &name)
Definition: IWORKCollector.cpp:486
void collectHeaderFooter(const std::string &name, IWORKHeaderFooterMap_t &map)
Definition: IWORKCollector.cpp:718
Definition: IWORKDocumentInterface.h:18
double x
Definition: IWORKShape.cpp:46
virtual void drawTable()=0
static void fillLayoutProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:910
Definition: KEY1Token.h:198
void endAttachment()
Definition: IWORKCollector.cpp:649
Definition: IWORKToken.h:674
void setGraphicStyle(const IWORKStylePtr_t &style)
Definition: IWORKCollector.cpp:247
void collectMetadata(const IWORKMetadata &metadata)
Definition: IWORKCollector.cpp:476
int m_groupOpenLevel
Definition: IWORKCollector.h:200
virtual void collectStickyNote()
Definition: IWORKCollector.cpp:517
IWORKHeaderFooterMap_t m_headers
Definition: IWORKCollector.h:179
std::shared_ptr< IWORKData > IWORKDataPtr_t
Definition: IWORKTypes_fwd.h:49
void collectText(const std::shared_ptr< IWORKText > &text)
Definition: IWORKCollector.cpp:505
virtual ~IWORKCollector()
Definition: IWORKCollector.cpp:220
std::unordered_map< std::string, IWORKOutputElements > IWORKHeaderFooterMap_t
Definition: IWORKTypes.h:40
Definition: IWORKToken.h:421
IWORKGeometryPtr_t m_geometry
Definition: IWORKCollector.h:46
virtual bool createFrameStylesForTextBox() const =0
void endDocument()
Definition: IWORKCollector.cpp:527
bool m_accumulateTransform
Definition: IWORKCollector.h:198
IWORKPathPtr_t m_currentPath
Definition: IWORKCollector.h:183
Definition: IWORKCollector.h:41
void collectHeader(const std::string &name)
Definition: IWORKCollector.cpp:481
bool getOpenGroupLevel() const
Definition: IWORKCollector.h:111
void setRecorder(const std::shared_ptr< IWORKRecorder > &recorder)
Definition: IWORKCollector.cpp:230
std::stack< Level > m_levelStack
Definition: IWORKCollector.h:169
const char * name
Definition: IWORKToken.cpp:43
void closeGroup()
Definition: IWORKCollector.cpp:576
void openGroup()
Definition: IWORKCollector.cpp:563
void collectStylesheet(const IWORKStylesheetPtr_t &stylesheet)
Definition: IWORKCollector.cpp:464
std::shared_ptr< IWORKText > IWORKTextPtr_t
Definition: IWORKText_fwd.h:20
Definition: IWORKToken.h:402
std::stack< IWORKPathPtr_t > m_pathStack
Definition: IWORKCollector.h:182
void collectBezierPath()
Definition: IWORKCollector.cpp:374
std::deque< IWORKStylePtr_t > m_newStyles
Definition: IWORKCollector.h:174
IWORKDocumentInterface * m_document
Definition: IWORKCollector.h:166
static void writeFill(const IWORKFill &fill, librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:1234
IWORKCollector & operator=(const IWORKCollector &)
virtual std::shared_ptr< IWORKTable > createTable(const IWORKTableNameMapPtr_t &tableNameMap, const IWORKLanguageManager &langManager) const
Definition: IWORKCollector.cpp:588
Level()
Definition: IWORKCollector.cpp:183
virtual void fillShapeProperties(librevenge::RVNGPropertyList &props)=0
IWORKOutputManager & getOutputManager()
Definition: IWORKCollector.cpp:1016
std::shared_ptr< IWORKText > m_currentText
Definition: IWORKCollector.h:177
void drawShape(const IWORKShapePtr_t &shape)
Definition: IWORKCollector.cpp:1180
Definition: IWORKPath.h:87
IWORKMediaContentPtr_t m_currentUnfiltered
Definition: IWORKCollector.h:191
Definition: IWORKToken.h:236
void startLevel()
Definition: IWORKCollector.cpp:598
Definition: IWORKToken.h:577
void collectImage(const IWORKMediaContentPtr_t &image, const IWORKGeometryPtr_t &cropGeometry=IWORKGeometryPtr_t(), const boost::optional< int > &order=boost::none, bool locked=false)
Definition: IWORKCollector.cpp:296
glm::dmat3 m_trafo
Definition: IWORKCollector.h:48
std::shared_ptr< IWORKTableNameMap_t > IWORKTableNameMapPtr_t
Definition: IWORKTypes_fwd.h:34
void collectArrowPath(const IWORKSize &size, double headWidth, double stemRelYPos, bool doubleSided)
Definition: IWORKCollector.cpp:397
std::shared_ptr< IWORKLine > IWORKLinePtr_t
Definition: IWORKTypes_fwd.h:45
void endLevel()
Definition: IWORKCollector.cpp:619
Definition: KEY1Token.h:185
virtual std::shared_ptr< IWORKText > createText(const IWORKLanguageManager &langManager, bool discardEmptyContent=false, bool allowListInsertion=true) const
Definition: IWORKCollector.cpp:593
Definition: IWORKToken.h:178
void endGroup()
Definition: IWORKCollector.cpp:550
Definition: IWORKLanguageManager.h:23
IWORKOutputManager m_outputManager
Definition: IWORKCollector.h:172
Definition: NUM1Token.h:34
IWORKHeaderFooterMap_t m_footers
Definition: IWORKCollector.h:180
Definition: IWORKToken.h:418
void collectCalloutPath(const IWORKSize &size, double radius, double tailSize, double tailX, double tailY, bool quoteBubble)
Definition: IWORKCollector.cpp:428
IWORKMetadata m_metadata
Definition: IWORKCollector.h:196
void drawLine(const IWORKLinePtr_t &line)
Definition: IWORKCollector.cpp:1021
void fillMetadata(librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:732
void collectLine(const IWORKLinePtr_t &line)
Definition: IWORKCollector.cpp:319
std::shared_ptr< IWORKPath > IWORKPathPtr_t
Definition: IWORKPath_fwd.h:20
void endAttachments()
Definition: IWORKCollector.cpp:678
static void fillTextAutoSizeProps(const boost::optional< unsigned > &resizeFlags, const IWORKGeometryPtr_t &boundingBox, librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:946
IWORKStyleStack m_styleStack
Definition: IWORKCollector.h:170
std::shared_ptr< IWORKShape > IWORKShapePtr_t
Definition: IWORKShape.h:39
void pushStyle()
Definition: IWORKCollector.cpp:684
boost::variant< IWORKColor, IWORKGradient, IWORKMediaContent > IWORKFill
Definition: IWORKTypes.h:309
int m_groupLevel
Definition: IWORKCollector.h:199
void collectPolygonPath(const IWORKSize &size, unsigned edges)
Definition: IWORKCollector.cpp:379
IWORKStylesheetPtr_t getStylesheet() const
Definition: IWORKCollector.h:124
virtual void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox, const librevenge::RVNGPropertyList &style)=0
void pushStylesheet(const IWORKStylesheetPtr_t &stylesheet)
Definition: IWORKCollector.cpp:694
Definition: IWORKToken.h:328
glm::dmat3 m_previousTrafo
Definition: IWORKCollector.h:49
std::shared_ptr< IWORKTable > m_currentTable
Definition: IWORKCollector.h:176
Definition: IWORKToken.h:624
void collectRoundedRectanglePath(const IWORKSize &size, double radius)
Definition: IWORKCollector.cpp:388
std::shared_ptr< IWORKMediaContent > IWORKMediaContentPtr_t
Definition: IWORKTypes_fwd.h:54
void startDocument(const librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:522
Definition: IWORKTypes.h:328
Definition: IWORKToken.h:204
void startAttachment()
Definition: IWORKCollector.cpp:633
IWORKDataPtr_t m_currentData
Definition: IWORKCollector.h:190
std::stack< bool > m_attachmentStack
Definition: IWORKCollector.h:185
void collectMedia(const IWORKMediaContentPtr_t &content, const IWORKGeometryPtr_t &cropGeometry=IWORKGeometryPtr_t(), const boost::optional< int > &order=boost::none)
Definition: IWORKCollector.cpp:441
std::shared_ptr< IWORKStylesheet > IWORKStylesheetPtr_t
Definition: IWORKStylesheet.h:19

Generated for libetonyek by doxygen 1.8.6