PAGCollector.h Source File documentation

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 typedef std::map<unsigned, IWORKOutputID_t> PageGroupsMap_t;
26
27 public:
28 explicit PAGCollector(IWORKDocumentInterface *document);
29
30 // collector functions
31
32 void collectPublicationInfo(const PAGPublicationInfo &pubInfo);
33
34 void collectTextBody();
35
36 void collectAttachment(const IWORKOutputID_t &id, bool block);
37 void collectAttachmentPosition(const IWORKPosition &position);
38
39 void collectAnnotation(const std::string &name);
40
41 void openPageGroup(const boost::optional<int> &page);
42 void closePageGroup();
43
44 // helper functions
45 void setPageDimensions(const IWORKPrintInfo &dimensions);
46
47 void openSection(const std::string &style); // probably better to look for the style in the calling function
48 void openSection(const IWORKStylePtr_t &style);
49 void closeSection();
50
51 void sendAnnotation(const std::string &name);
52
53 PAGFootnoteKind getFootnoteKind() const;
54
55 private:
56 void drawShape(const IWORKShapePtr_t &shape) override;
57 void drawTable() override;
58 void drawMedia(double x, double y, const librevenge::RVNGPropertyList &data) override;
59 void fillShapeProperties(librevenge::RVNGPropertyList &props) override;
60 bool createFrameStylesForTextBox() const override
61 {
62 return true;
63 }
64 void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox, const librevenge::RVNGPropertyList &style) override;
65
66 void flushPageSpan(bool writeEmpty = true);
67 void writePageGroupsObjects();
68
69 private:
70 boost::optional<IWORKPrintInfo> m_pageDimensions;
71 IWORKStylePtr_t m_currentSectionStyle;
72 bool m_firstPageSpan;
73
74 PAGPublicationInfo m_pubInfo;
75
76 PageGroupsMap_t m_pageGroups;
77 int m_page;
78
79 // FIXME: This is a clumsy workaround.
80 boost::optional<IWORKPosition> m_attachmentPosition;
81 PAGAnnotationMap_t m_annotations;
82 };
83
84 } // namespace libetonyek
85
86 #endif // PAGCOLLECTOR_H_INCLUDED
87
88 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::IWORKCollector::m_headers
IWORKHeaderFooterMap_t m_headers
Definition: IWORKCollector.h:173
libetonyek::IWORKCollector::getOutputManager
IWORKOutputManager & getOutputManager()
Definition: IWORKCollector.cpp:1034
libetonyek::PAGPublicationInfo
Definition: PAGTypes.h:28
libetonyek::IWORKShapePtr_t
std::shared_ptr< IWORKShape > IWORKShapePtr_t
Definition: IWORKShape.h:38
libetonyek::IWORKDocumentInterface
Definition: IWORKDocumentInterface.h:18
libetonyek::PAGCollector::collectAnnotation
void collectAnnotation(const std::string &name)
Definition: PAGCollector.cpp:106
libetonyek::IWORKOutputManager::pop
void pop()
Pop a output element from the stack.
Definition: IWORKOutputManager.cpp:33
libetonyek
Definition: IWORKBezierElement.cpp:20
libetonyek::IWORKToken::shape
@ shape
Definition: IWORKToken.h:394
m_page
optional< int > m_page
Definition: PAG1Parser.cpp:642
libetonyek::PAGCollector::m_currentSectionStyle
IWORKStylePtr_t m_currentSectionStyle
Definition: PAGCollector.h:71
IWORKProperties.h
libetonyek::IWORKCollector::m_outputManager
IWORKOutputManager m_outputManager
Definition: IWORKCollector.h:166
libetonyek::IWORKOutputManager::getCurrent
IWORKOutputElements & getCurrent()
Get the current output element.
Definition: IWORKOutputManager.cpp:57
libetonyek::PAGCollector::collectAttachment
void collectAttachment(const IWORKOutputID_t &id, bool block)
m_y
boost::optional< unsigned > m_y
Definition: IWORKFormulaElement.cpp:111
libetonyek::IWORKOutputManager::save
IWORKOutputID_t save()
Save the current output element.
Definition: IWORKOutputManager.cpp:39
libetonyek::PAGCollector::m_firstPageSpan
bool m_firstPageSpan
Definition: PAGCollector.h:72
libetonyek::PAGCollector
Definition: PAGCollector.h:23
libetonyek::PAGCollector::collectTextBody
void collectTextBody()
Definition: PAGCollector.cpp:133
libetonyek::PAGAnnotationMap_t
std::unordered_map< std::string, IWORKOutputElements > PAGAnnotationMap_t
Definition: PAGTypes.h:26
libetonyek::PAGCollector::drawShape
void drawShape(const IWORKShapePtr_t &shape) override
Definition: PAGCollector.cpp:272
ETONYEK_DEBUG_MSG
#define ETONYEK_DEBUG_MSG(M)
Definition: libetonyek_utils.h:54
libetonyek::IWORKDocumentInterface::openFooter
virtual void openFooter(const librevenge::RVNGPropertyList &propList)=0
libetonyek::IWORKDocumentInterface::openHeader
virtual void openHeader(const librevenge::RVNGPropertyList &propList)=0
PAGTypes.h
libetonyek::IWORKHeaderFooterMap_t
std::unordered_map< std::string, IWORKOutputElements > IWORKHeaderFooterMap_t
Definition: IWORKTypes.h:40
libetonyek::IWORKCollector::m_footers
IWORKHeaderFooterMap_t m_footers
Definition: IWORKCollector.h:174
libetonyek::IWORKTextPtr_t
std::shared_ptr< IWORKText > IWORKTextPtr_t
Definition: IWORKText_fwd.h:18
IWORKTable.h
libetonyek::PAGCollector::drawTextBox
void drawTextBox(const IWORKTextPtr_t &text, const glm::dmat3 &trafo, const IWORKGeometryPtr_t &boundingBox, const librevenge::RVNGPropertyList &style) override
Definition: PAGCollector.cpp:356
libetonyek::PAGCollector::collectAttachmentPosition
void collectAttachmentPosition(const IWORKPosition &position)
Definition: PAGCollector.cpp:140
libetonyek::IWORKOutputElements::addOpenComment
void addOpenComment(const librevenge::RVNGPropertyList &propList)
Definition: IWORKOutputElements.cpp:1043
libetonyek::IWORKOutputElements::clear
void clear()
Definition: IWORKOutputElements.cpp:883
libetonyek::IWORKToken::path
@ path
Definition: IWORKToken.h:358
libetonyek::PAGCollector::m_pageGroups
PageGroupsMap_t m_pageGroups
Definition: PAGCollector.h:76
libetonyek::PAGCollector::m_annotations
PAGAnnotationMap_t m_annotations
Definition: PAGCollector.h:81
libetonyek::IWORKCollector::m_stylesheetStack
std::stack< IWORKStylesheetPtr_t > m_stylesheetStack
Definition: IWORKCollector.h:165
libetonyek::PAGCollector::m_page
int m_page
Definition: PAGCollector.h:77
libetonyek::IWORKCollector::fillMetadata
void fillMetadata(librevenge::RVNGPropertyList &props)
Definition: IWORKCollector.cpp:769
libetonyek::PAGCollector::setPageDimensions
void setPageDimensions(const IWORKPrintInfo &dimensions)
Definition: PAGCollector.cpp:145
libetonyek::IWORKDocumentInterface::setDocumentMetaData
virtual void setDocumentMetaData(const librevenge::RVNGPropertyList &propList)=0
libetonyek::IWORKToken::h
@ h
Definition: IWORKToken.h:550
libetonyek::IWORKOutputElements::addSetStyle
void addSetStyle(const librevenge::RVNGPropertyList &propList)
Definition: IWORKOutputElements.cpp:1133
libetonyek::IWORKOutputElements::addCloseFrame
void addCloseFrame()
Definition: IWORKOutputElements.cpp:913
libetonyek::pt2in
double pt2in(const double d)
Convert a length from points to inches.
Definition: libetonyek_utils.cpp:225
libetonyek::IWORKCollector::m_currentTable
std::shared_ptr< IWORKTable > m_currentTable
Definition: IWORKCollector.h:170
libetonyek::IWORKOutputManager::push
void push()
Push a new output element onto the stack.
Definition: IWORKOutputManager.cpp:28
libetonyek::IWORKOutputManager::get
IWORKOutputElements & get(IWORKOutputID_t id)
Get output element with ID id.
Definition: IWORKOutputManager.cpp:46
libetonyek::PAGCollector::m_pageDimensions
boost::optional< IWORKPrintInfo > m_pageDimensions
Definition: PAGCollector.h:70
libetonyek::IWORKOutputElements::write
void write(IWORKDocumentInterface *iface) const
Definition: IWORKOutputElements.cpp:876
libetonyek::IWORKOutputElements::addInsertBinaryObject
void addInsertBinaryObject(const librevenge::RVNGPropertyList &propList)
Definition: IWORKOutputElements.cpp:1008
libetonyek::IWORKToken::position
@ position
Definition: IWORKToken.h:368
libetonyek::PAGCollector::openPageGroup
void openPageGroup(const boost::optional< int > &page)
Definition: PAGCollector.cpp:199
libetonyek::PAGCollector::fillShapeProperties
void fillShapeProperties(librevenge::RVNGPropertyList &props) override
Definition: PAGCollector.cpp:348
IWORKPath.h
libetonyek::PAGPublicationInfo::m_footnoteKind
PAGFootnoteKind m_footnoteKind
Definition: PAGTypes.h:34
libetonyek::PAGFootnoteKind
PAGFootnoteKind
Definition: PAGEnum.h:16
libetonyek::IWORKDocumentInterface::closeFooter
virtual void closeFooter()=0
libetonyek::PAGCollector::writePageGroupsObjects
void writePageGroupsObjects()
Definition: PAGCollector.cpp:460
libetonyek::IWORKCollector::m_inAttachment
bool m_inAttachment
Definition: IWORKCollector.h:180
libetonyek::IWORKToken::metadata
@ metadata
Definition: IWORKToken.h:323
libetonyek::PAGCollector::collectPublicationInfo
void collectPublicationInfo(const PAGPublicationInfo &pubInfo)
Definition: PAGCollector.cpp:128
libetonyek::PAGCollector::PAGCollector
PAGCollector(IWORKDocumentInterface *document)
Definition: PAGCollector.cpp:93
libetonyek::IWORKOutputElements::addStartTextObject
void addStartTextObject(const librevenge::RVNGPropertyList &propList)
Definition: IWORKOutputElements.cpp:1148
libetonyek::IWORKOutputElements::empty
bool empty() const
Definition: IWORKOutputElements.cpp:888
libetonyek::IWORKToken::string
@ string
Definition: IWORKToken.h:411
IWORKDocumentInterface.h
libetonyek::IWORKDocumentInterface::closeHeader
virtual void closeHeader()=0
libetonyek::PAGCollector::m_pubInfo
PAGPublicationInfo m_pubInfo
Definition: PAGCollector.h:74
libetonyek::NUM1Token::document
@ document
Definition: NUM1Token.h:34
IWORKText.h
libetonyek::IWORKToken::pos
@ pos
Definition: IWORKToken.h:592
libetonyek_utils.h
libetonyek::IWORKToken::w
@ w
Definition: IWORKToken.h:630
libetonyek::IWORKToken::style
@ style
Definition: IWORKToken.h:414
y
double y
Definition: IWORKShape.cpp:46
libetonyek::IWORKCollector
Definition: IWORKCollector.h:41
libetonyek::PAGCollector::createFrameStylesForTextBox
bool createFrameStylesForTextBox() const override
Definition: PAGCollector.h:60
libetonyek::IWORKDocumentInterface::openPageSpan
virtual void openPageSpan(const librevenge::RVNGPropertyList &propList)=0
libetonyek::PAGCollector::m_attachmentPosition
boost::optional< IWORKPosition > m_attachmentPosition
Definition: PAGCollector.h:80
libetonyek::IWORKOutputElements::addCloseComment
void addCloseComment()
Definition: IWORKOutputElements.cpp:893
m_pubInfo
PAGPublicationInfo m_pubInfo
Definition: PAG1Parser.cpp:444
libetonyek::PAGCollector::openSection
void openSection(const std::string &style)
Definition: PAGCollector.cpp:150
libetonyek::IWORKCollector::fillWrapProps
static void fillWrapProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props, const boost::optional< int > &order)
Definition: IWORKCollector.cpp:984
IWORKCollector.h
x
double x
Definition: IWORKShape.cpp:45
libetonyek::PAGCollector::drawMedia
void drawMedia(double x, double y, const librevenge::RVNGPropertyList &data) override
Definition: PAGCollector.cpp:311
IWORKOutputElements.h
libetonyek::IWORKToken::first
@ first
Definition: IWORKToken.h:524
libetonyek::IWORKGeometryPtr_t
std::shared_ptr< IWORKGeometry > IWORKGeometryPtr_t
Definition: IWORKTypes_fwd.h:41
libetonyek::IWORKStylePtr_t
std::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
libetonyek::PAGCollector::PageGroupsMap_t
std::map< unsigned, IWORKOutputID_t > PageGroupsMap_t
Definition: PAGCollector.h:25
libetonyek::IWORKPosition
Definition: IWORKTypes.h:52
libetonyek::PAGCollector::sendAnnotation
void sendAnnotation(const std::string &name)
Definition: PAGCollector.cpp:180
PAGProperties.h
libetonyek::IWORKPrintInfo
Definition: IWORKTypes.h:407
libetonyek::IWORKOutputElements::addOpenFrame
void addOpenFrame(const librevenge::RVNGPropertyList &propList)
Definition: IWORKOutputElements.cpp:1068
libetonyek::PAGCollector::closePageGroup
void closePageGroup()
Definition: PAGCollector.cpp:208
libetonyek::KEY2Token::page
@ page
Definition: KEY2Token.h:69
libetonyek::IWORKOutputID_t
unsigned IWORKOutputID_t
Definition: IWORKTypes_fwd.h:28
libetonyek::get
const ValueT & get(const detail::IWAFieldImpl< TagV, ValueT, Reader > &field)
Definition: IWAField.h:190
libetonyek::IWORKCollector::fillGraphicProps
static void fillGraphicProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props, bool isSurface=true, bool isFrame=false)
Definition: IWORKCollector.cpp:781
libetonyek::PAGCollector::flushPageSpan
void flushPageSpan(bool writeEmpty=true)
Definition: PAGCollector.cpp:390
libetonyek::IWORKCollector::m_inAttachments
bool m_inAttachments
Definition: IWORKCollector.h:181
libetonyek::IWORKToken::geometry
@ geometry
Definition: IWORKToken.h:232
libetonyek::IWORKDocumentInterface::closePageSpan
virtual void closePageSpan()=0
libetonyek::IWORKCollector::m_levelStack
std::stack< Level > m_levelStack
Definition: IWORKCollector.h:163
libetonyek::IWORKToken::name
@ name
Definition: IWORKToken.h:578
libetonyek::IWORKToken::data
@ data
Definition: IWORKToken.h:174
libetonyek::IWORKCollector::m_currentText
std::shared_ptr< IWORKText > m_currentText
Definition: IWORKCollector.h:171
libetonyek::PAGCollector::getFootnoteKind
PAGFootnoteKind getFootnoteKind() const
Definition: PAGCollector.cpp:466
libetonyek::IWORKCollector::drawShape
virtual void drawShape(const IWORKShapePtr_t &shape)
Definition: IWORKCollector.cpp:1197
m_x
boost::optional< unsigned > m_x
Definition: IWORKFormulaElement.cpp:111
libetonyek::IWORKOutputElements::addEndTextObject
void addEndTextObject()
Definition: IWORKOutputElements.cpp:1003
libetonyek::PAGCollector::closeSection
void closeSection()
Definition: PAGCollector.cpp:175
PAGCollector.h
libetonyek::PAGCollector::drawTable
void drawTable() override
Definition: PAGCollector.cpp:220
libetonyek::IWORKCollector::m_document
IWORKDocumentInterface * m_document
Definition: IWORKCollector.h:160
libetonyek::IWORKOutputElements
Definition: IWORKOutputElements.h:32
libetonyek::IWORKToken::text
@ text
Definition: IWORKToken.h:465