PAGCollector.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 PAGCOLLECTOR_H_INCLUDED
11 #define PAGCOLLECTOR_H_INCLUDED
12
13 #include <map>
14
15 #include "IWORKCollector.h"
16 #include "PAGTypes.h"
17
18 namespace libetonyek
19 {
20
21 class IWORKDocumentInterface;
22
23 class PAGCollector : public IWORKCollector
24 {
25 struct Section
26 {
27 Section();
28
29 void clear();
30
31 IWORKStylePtr_t m_style;
32 boost::optional<double> m_width;
33 boost::optional<double> m_height;
34 boost::optional<double> m_horizontalMargin;
35 boost::optional<double> m_verticalMargin;
36 };
37
38 typedef std::map<unsigned, IWORKOutputID_t> PageGroupsMap_t;
39
40 public:
41 explicit PAGCollector(IWORKDocumentInterface *document);
42
43 // collector functions
44
45 void collectPublicationInfo(const PAGPublicationInfo &pubInfo);
46
47 void collectTextBody();
48
49 void collectAttachment(const IWORKOutputID_t &id, bool block);
50 void collectAttachmentPosition(const IWORKPosition &position);
51
52 void openPageGroup(const boost::optional<int> &page);
53 void closePageGroup();
54
55 // helper functions
56
57 void openSection(const std::string &style, double width, double height, double horizontalMargin, double verticalMargin);
58 void closeSection();
59
60 void openAttachments();
61 void closeAttachments();
62
63 PAGFootnoteKind getFootnoteKind() const;
64
65 private:
66 void drawTable() override;
67 void drawMedia(double x, double y, double w, double h, const std::string &mimetype, const librevenge::RVNGBinaryData &data) override;
68 void fillShapeProperties(librevenge::RVNGPropertyList &props) override;
69 void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox) override;
70
71 void flushPageSpan(bool writeEmpty = true);
72 void writePageGroupsObjects();
73
74 private:
75 Section m_currentSection;
76 bool m_firstPageSpan;
77
78 PAGPublicationInfo m_pubInfo;
79
80 PageGroupsMap_t m_pageGroups;
81 int m_page;
82
83 // FIXME: This is a clumsy workaround.
84 boost::optional<IWORKPosition> m_attachmentPosition;
85 bool m_inAttachments;
86 };
87
88 } // namespace libetonyek
89
90 #endif // PAGCOLLECTOR_H_INCLUDED
91
92 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::IWORKGeometryPtr_t
std::shared_ptr< IWORKGeometry > IWORKGeometryPtr_t
Definition: IWORKTypes_fwd.h:39
libetonyek
Definition: IWORKBezierElement.cpp:18
libetonyek::PAGCollector::m_page
int m_page
Definition: PAGCollector.h:81
libetonyek::PAGCollector::closePageGroup
void closePageGroup()
Definition: PAGCollector.cpp:187
libetonyek::PAGCollector::fillShapeProperties
void fillShapeProperties(librevenge::RVNGPropertyList &props) override
Definition: PAGCollector.cpp:255
libetonyek::PAGCollector
Definition: PAGCollector.h:23
y
double y
Definition: IWORKShape.cpp:43
libetonyek::PAGCollector::Section::m_verticalMargin
boost::optional< double > m_verticalMargin
Definition: PAGCollector.h:35
libetonyek::PAGCollector::flushPageSpan
void flushPageSpan(bool writeEmpty=true)
Definition: PAGCollector.cpp:300
libetonyek::PAGCollector::drawMedia
void drawMedia(double x, double y, double w, double h, const std::string &mimetype, const librevenge::RVNGBinaryData &data) override
Definition: PAGCollector.cpp:219
libetonyek::IWORKToken::position
Definition: IWORKToken.h:236
libetonyek::PAGCollector::openPageGroup
void openPageGroup(const boost::optional< int > &page)
Definition: PAGCollector.cpp:178
libetonyek::PAGCollector::m_firstPageSpan
bool m_firstPageSpan
Definition: PAGCollector.h:76
libetonyek::PAGPublicationInfo
Definition: PAGTypes.h:26
libetonyek::IWORKOutputID_t
unsigned IWORKOutputID_t
Definition: IWORKTypes_fwd.h:26
libetonyek::KEY2Token::page
Definition: KEY2Token.h:44
libetonyek::IWORKToken::width
Definition: IWORKToken.h:374
libetonyek::IWORKStylePtr_t
std::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
libetonyek::PAGFootnoteKind
PAGFootnoteKind
Definition: PAGEnum.h:16
libetonyek::PAGCollector::collectAttachment
void collectAttachment(const IWORKOutputID_t &id, bool block)
libetonyek::IWORKToken::h
Definition: IWORKToken.h:328
libetonyek::PAGCollector::m_inAttachments
bool m_inAttachments
Definition: PAGCollector.h:85
libetonyek::PAGCollector::collectTextBody
void collectTextBody()
Definition: PAGCollector.cpp:124
libetonyek::PAGCollector::PageGroupsMap_t
std::map< unsigned, IWORKOutputID_t > PageGroupsMap_t
Definition: PAGCollector.h:38
libetonyek::PAGCollector::Section::m_width
boost::optional< double > m_width
Definition: PAGCollector.h:32
libetonyek::PAGCollector::drawTextBox
void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox) override
Definition: PAGCollector.cpp:261
libetonyek::IWORKToken::text
Definition: IWORKToken.h:284
libetonyek::IWORKDocumentInterface
Definition: IWORKDocumentInterface.h:18
x
double x
Definition: IWORKShape.cpp:42
libetonyek::PAGCollector::closeSection
void closeSection()
Definition: PAGCollector.cpp:161
libetonyek::PAGCollector::drawTable
void drawTable() override
Definition: PAGCollector.cpp:199
libetonyek::PAGCollector::collectAttachmentPosition
void collectAttachmentPosition(const IWORKPosition &position)
Definition: PAGCollector.cpp:131
libetonyek::PAGCollector::m_attachmentPosition
boost::optional< IWORKPosition > m_attachmentPosition
Definition: PAGCollector.h:84
PAGTypes.h
libetonyek::PAGCollector::collectPublicationInfo
void collectPublicationInfo(const PAGPublicationInfo &pubInfo)
Definition: PAGCollector.cpp:119
libetonyek::PAGCollector::Section::m_height
boost::optional< double > m_height
Definition: PAGCollector.h:33
libetonyek::IWORKToken::style
Definition: IWORKToken.h:268
libetonyek::PAGCollector::m_currentSection
Section m_currentSection
Definition: PAGCollector.h:75
libetonyek::PAGCollector::Section::clear
void clear()
Definition: PAGCollector.cpp:99
libetonyek::PAGCollector::m_pubInfo
PAGPublicationInfo m_pubInfo
Definition: PAGCollector.h:78
libetonyek::IWORKCollector
Definition: IWORKCollector.h:41
libetonyek::IWORKTextPtr_t
std::shared_ptr< IWORKText > IWORKTextPtr_t
Definition: IWORKText_fwd.h:18
libetonyek::IWORKToken::height
Definition: IWORKToken.h:329
libetonyek::PAGCollector::m_pageGroups
PageGroupsMap_t m_pageGroups
Definition: PAGCollector.h:80
libetonyek::IWORKToken::w
Definition: IWORKToken.h:373
libetonyek::PAGCollector::Section::Section
Section()
Definition: PAGCollector.cpp:90
libetonyek::IWORKPosition
Definition: IWORKTypes.h:46
libetonyek::PAGCollector::closeAttachments
void closeAttachments()
Definition: PAGCollector.cpp:172
libetonyek::PAGCollector::writePageGroupsObjects
void writePageGroupsObjects()
Definition: PAGCollector.cpp:353
libetonyek::IWORKToken::data
Definition: IWORKToken.h:101
libetonyek::NUM1Token::document
Definition: NUM1Token.h:34
libetonyek::IWORKToken::string
Definition: IWORKToken.h:266
libetonyek::PAGCollector::openAttachments
void openAttachments()
Definition: PAGCollector.cpp:166
libetonyek::PAGCollector::Section::m_style
IWORKStylePtr_t m_style
Definition: PAGCollector.h:31
libetonyek::PAGCollector::PAGCollector
PAGCollector(IWORKDocumentInterface *document)
Definition: PAGCollector.cpp:108
libetonyek::PAGCollector::openSection
void openSection(const std::string &style, double width, double height, double horizontalMargin, double verticalMargin)
Definition: PAGCollector.cpp:136
libetonyek::PAGCollector::Section
Definition: PAGCollector.h:25
IWORKCollector.h
libetonyek::PAGCollector::Section::m_horizontalMargin
boost::optional< double > m_horizontalMargin
Definition: PAGCollector.h:34
libetonyek::PAGCollector::getFootnoteKind
PAGFootnoteKind getFootnoteKind() const
Definition: PAGCollector.cpp:359