ABWCollector.h Source File documentation

ABWCollector.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 libabw 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 __ABWCOLLECTOR_H__
11 #define __ABWCOLLECTOR_H__
12
13 #include <string>
14 #include <map>
15 #include <librevenge/librevenge.h>
16
17 namespace libabw
18 {
19 class ABWOutputElements;
20
21 enum ABWUnit
22 {
23 ABW_NONE,
24 ABW_CM,
25 ABW_IN,
26 ABW_MM,
27 ABW_PI,
28 ABW_PT,
29 ABW_PX,
30 ABW_PERCENT
31 };
32
33 enum ABWListType
34 {
35 ABW_ORDERED,
36 ABW_UNORDERED
37 };
38
39 typedef std::map<std::string, std::string> ABWPropertyMap;
40
41 bool findInt(const std::string &str, int &res);
42 bool findDouble(const std::string &str, double &res, ABWUnit &unit);
43 void parsePropString(const std::string &str, ABWPropertyMap &props);
44
45 struct ABWData
46 {
47 ABWData()
48 : m_mimeType(), m_binaryData() {}
49 ABWData(const ABWData &data)
50 : m_mimeType(data.m_mimeType), m_binaryData(data.m_binaryData) {}
51 ABWData(const librevenge::RVNGString &mimeType, const librevenge::RVNGBinaryData binaryData)
52 : m_mimeType(mimeType), m_binaryData(binaryData) {}
53 ~ABWData() {}
54
55 librevenge::RVNGString m_mimeType;
56 librevenge::RVNGBinaryData m_binaryData;
57 };
58
59 struct ABWListElement
60 {
61 ABWListElement()
62 : m_listLevel(-1), m_minLabelWidth(0.0), m_spaceBefore(0.0), m_parentId(), m_listId(0) {}
63 virtual ~ABWListElement() {}
64 virtual void writeOut(librevenge::RVNGPropertyList &propList) const;
65 virtual ABWListType getType() const = 0;
66
67 int m_listLevel;
68 double m_minLabelWidth;
69 double m_spaceBefore;
70 int m_parentId;
72 int m_listId;
73 };
74
75 struct ABWOrderedListElement : public ABWListElement
76 {
77 ABWOrderedListElement()
78 : ABWListElement(), m_numFormat(), m_numPrefix(), m_numSuffix(), m_startValue(-1) {}
79 ~ABWOrderedListElement() override {}
80 void writeOut(librevenge::RVNGPropertyList &propList) const override;
81 ABWListType getType() const override
82 {
83 return ABW_ORDERED;
84 }
85
86 librevenge::RVNGString m_numFormat;
87 librevenge::RVNGString m_numPrefix;
88 librevenge::RVNGString m_numSuffix;
89 int m_startValue;
90 };
91
92 struct ABWUnorderedListElement : public ABWListElement
93 {
94 ABWUnorderedListElement()
95 : ABWListElement(), m_bulletChar() {}
96 ~ABWUnorderedListElement() override {}
97 void writeOut(librevenge::RVNGPropertyList &propList) const override;
98 ABWListType getType() const override
99 {
100 return ABW_UNORDERED;
101 }
102
103 librevenge::RVNGString m_bulletChar;
104 };
105
106 class ABWCollector
107 {
108 public:
109 ABWCollector() {}
110 virtual ~ABWCollector() {}
111
112 // collector functions
113
114 virtual void collectTextStyle(const char *name, const char *basedon, const char *followedby, const char *props) = 0;
115 virtual void collectDocumentProperties(const char *props) = 0;
116 virtual void collectParagraphProperties(const char *level, const char *listid, const char *parentid,
117 const char *style, const char *props) = 0;
118 virtual void collectSectionProperties(const char *footer, const char *footerLeft, const char *footerFirst,
119 const char *footerLast, const char *header, const char *headerLeft,
120 const char *headerFirst, const char *headerLast, const char *props) = 0;
121 virtual void collectCharacterProperties(const char *style, const char *props) = 0;
122 virtual void collectPageSize(const char *width, const char *height, const char *units, const char *pageScale) = 0;
123 virtual void closeParagraphOrListElement() = 0;
124 virtual void closeSpan() = 0;
125 virtual void openLink(const char *href) = 0;
126 virtual void closeLink() = 0;
127 virtual void openFoot(const char *id) = 0;
128 virtual void closeFoot() = 0;
129 virtual void openEndnote(const char *id) = 0;
130 virtual void closeEndnote() = 0;
131 virtual void openField(const char *type, const char *id)= 0;
132 virtual void closeField()= 0;
133 virtual void endSection() = 0;
134 virtual void startDocument() = 0;
135 virtual void endDocument() = 0;
136 virtual void insertLineBreak() = 0;
137 virtual void insertColumnBreak() = 0;
138 virtual void insertPageBreak() = 0;
139 virtual void insertText(const char *text) = 0;
140 virtual void insertImage(const char *dataid, const char *props) = 0;
141 virtual void collectList(const char *id, const char *listDecimal, const char *listDelim,
142 const char *parentid, const char *startValue, const char *type) = 0;
143
144 virtual void collectData(const char *name, const char *mimeType, const librevenge::RVNGBinaryData &data) = 0;
145 virtual void collectHeaderFooter(const char *id, const char *type) = 0;
146
147 virtual void openTable(const char *props) = 0;
148 virtual void closeTable() = 0;
149 virtual void openCell(const char *props) = 0;
150 virtual void closeCell() = 0;
151
152 virtual void openFrame(const char *props, const char *imageId, const char *title, const char *alt) = 0;
153 virtual void closeFrame(ABWOutputElements *(&elements), bool &pageFrame) = 0;
154 virtual void addFrameElements(ABWOutputElements &elements, bool pageFrame) = 0;
155
156 virtual void addMetadataEntry(const char *name, const char *value) = 0;
157 };
158
159 } // namespace libabw
160
161 #endif /* __ABWCOLLECTOR_H__ */
162 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libabw::ABWListElement::m_spaceBefore
double m_spaceBefore
Definition: ABWCollector.h:69
libabw::ABWCollector::ABWCollector
ABWCollector()
Definition: ABWCollector.h:109
libabw::ABWOrderedListElement::getType
ABWListType getType() const override
Definition: ABWCollector.h:81
libabw::ABW_PX
Definition: ABWCollector.h:29
libabw::ABWData::m_binaryData
librevenge::RVNGBinaryData m_binaryData
Definition: ABWCollector.h:56
libabw::ABWUnorderedListElement
Definition: ABWCollector.h:92
libabw::ABWCollector::closeTable
virtual void closeTable()=0
libabw::ABWUnorderedListElement::ABWUnorderedListElement
ABWUnorderedListElement()
Definition: ABWCollector.h:94
libabw::ABWCollector::~ABWCollector
virtual ~ABWCollector()
Definition: ABWCollector.h:110
libabw::ABWCollector::endDocument
virtual void endDocument()=0
libabw::ABW_CM
Definition: ABWCollector.h:24
libabw::ABWCollector::insertText
virtual void insertText(const char *text)=0
libabw::ABWCollector::collectData
virtual void collectData(const char *name, const char *mimeType, const librevenge::RVNGBinaryData &data)=0
libabw::ABWListElement::m_parentId
int m_parentId
Definition: ABWCollector.h:70
libabw::ABWCollector::collectTextStyle
virtual void collectTextStyle(const char *name, const char *basedon, const char *followedby, const char *props)=0
libabw::ABWCollector::closeParagraphOrListElement
virtual void closeParagraphOrListElement()=0
libabw::parsePropString
void parsePropString(const std::string &str, ABWPropertyMap &props)
Definition: ABWCollector.cpp:27
libabw::ABWCollector::addFrameElements
virtual void addFrameElements(ABWOutputElements &elements, bool pageFrame)=0
libabw
Definition: AbiDocument.cpp:16
libabw::ABWListElement::~ABWListElement
virtual ~ABWListElement()
Definition: ABWCollector.h:63
libabw::ABWCollector::closeSpan
virtual void closeSpan()=0
libabw::ABWCollector::collectCharacterProperties
virtual void collectCharacterProperties(const char *style, const char *props)=0
libabw::ABWData::ABWData
ABWData(const librevenge::RVNGString &mimeType, const librevenge::RVNGBinaryData binaryData)
Definition: ABWCollector.h:51
libabw::ABWCollector::closeField
virtual void closeField()=0
libabw::ABWOutputElements
Definition: ABWOutputElements.h:24
libabw::ABWOrderedListElement::ABWOrderedListElement
ABWOrderedListElement()
Definition: ABWCollector.h:77
libabw::ABWListElement
Definition: ABWCollector.h:59
libabw::ABWCollector::insertLineBreak
virtual void insertLineBreak()=0
libabw::ABWOrderedListElement::m_numSuffix
librevenge::RVNGString m_numSuffix
Definition: ABWCollector.h:88
libabw::ABWCollector::openField
virtual void openField(const char *type, const char *id)=0
libabw::ABW_ORDERED
Definition: ABWCollector.h:35
libabw::ABWListElement::m_listLevel
int m_listLevel
Definition: ABWCollector.h:67
libabw::ABWCollector::insertColumnBreak
virtual void insertColumnBreak()=0
libabw::ABWOrderedListElement::m_startValue
int m_startValue
Definition: ABWCollector.h:89
libabw::ABWCollector::collectList
virtual void collectList(const char *id, const char *listDecimal, const char *listDelim, const char *parentid, const char *startValue, const char *type)=0
libabw::ABWCollector::openTable
virtual void openTable(const char *props)=0
libabw::ABWListElement::writeOut
virtual void writeOut(librevenge::RVNGPropertyList &propList) const
Definition: ABWCollector.cpp:83
libabw::ABWUnorderedListElement::m_bulletChar
librevenge::RVNGString m_bulletChar
Definition: ABWCollector.h:103
libabw::ABWListElement::getType
virtual ABWListType getType() const =0
libabw::ABWUnorderedListElement::writeOut
void writeOut(librevenge::RVNGPropertyList &propList) const override
Definition: ABWCollector.cpp:103
libabw::ABW_PI
Definition: ABWCollector.h:27
libabw::ABWListElement::ABWListElement
ABWListElement()
Definition: ABWCollector.h:61
libabw::ABWCollector::collectDocumentProperties
virtual void collectDocumentProperties(const char *props)=0
libabw::ABWCollector::closeFrame
virtual void closeFrame(ABWOutputElements *(&elements), bool &pageFrame)=0
libabw::ABWListType
ABWListType
Definition: ABWCollector.h:33
libabw::ABWOrderedListElement::m_numPrefix
librevenge::RVNGString m_numPrefix
Definition: ABWCollector.h:87
libabw::ABWData::ABWData
ABWData()
Definition: ABWCollector.h:47
libabw::ABWCollector::openFrame
virtual void openFrame(const char *props, const char *imageId, const char *title, const char *alt)=0
libabw::ABWCollector::closeLink
virtual void closeLink()=0
libabw::ABWCollector
Definition: ABWCollector.h:106
libabw::ABWListElement::m_minLabelWidth
double m_minLabelWidth
Definition: ABWCollector.h:68
libabw::ABWCollector::startDocument
virtual void startDocument()=0
libabw::ABWOrderedListElement
Definition: ABWCollector.h:75
libabw::findInt
bool findInt(const std::string &str, int &res)
Definition: ABWCollector.cpp:16
libabw::ABWCollector::openEndnote
virtual void openEndnote(const char *id)=0
libabw::ABWData::ABWData
ABWData(const ABWData &data)
Definition: ABWCollector.h:49
libabw::ABW_MM
Definition: ABWCollector.h:26
libabw::ABWCollector::closeEndnote
virtual void closeEndnote()=0
libabw::ABWData::m_mimeType
librevenge::RVNGString m_mimeType
Definition: ABWCollector.h:55
libabw::ABW_PT
Definition: ABWCollector.h:28
libabw::ABWCollector::addMetadataEntry
virtual void addMetadataEntry(const char *name, const char *value)=0
libabw::ABWCollector::openLink
virtual void openLink(const char *href)=0
libabw::ABWData::~ABWData
~ABWData()
Definition: ABWCollector.h:53
libabw::ABWData
Definition: ABWCollector.h:45
libabw::ABWCollector::closeCell
virtual void closeCell()=0
libabw::ABWCollector::collectPageSize
virtual void collectPageSize(const char *width, const char *height, const char *units, const char *pageScale)=0
libabw::ABWUnorderedListElement::getType
ABWListType getType() const override
Definition: ABWCollector.h:98
libabw::ABWCollector::closeFoot
virtual void closeFoot()=0
libabw::ABWCollector::openFoot
virtual void openFoot(const char *id)=0
libabw::ABWOrderedListElement::m_numFormat
librevenge::RVNGString m_numFormat
Definition: ABWCollector.h:86
libabw::ABWPropertyMap
std::map< std::string, std::string > ABWPropertyMap
Definition: ABWCollector.h:39
libabw::ABWCollector::collectHeaderFooter
virtual void collectHeaderFooter(const char *id, const char *type)=0
libabw::ABWCollector::insertPageBreak
virtual void insertPageBreak()=0
libabw::ABW_PERCENT
Definition: ABWCollector.h:30
libabw::ABW_IN
Definition: ABWCollector.h:25
libabw::ABWCollector::endSection
virtual void endSection()=0
libabw::ABWCollector::openCell
virtual void openCell(const char *props)=0
libabw::ABWListElement::m_listId
int m_listId
the list id
Definition: ABWCollector.h:72
libabw::ABW_UNORDERED
Definition: ABWCollector.h:36
libabw::ABWCollector::collectSectionProperties
virtual void collectSectionProperties(const char *footer, const char *footerLeft, const char *footerFirst, const char *footerLast, const char *header, const char *headerLeft, const char *headerFirst, const char *headerLast, const char *props)=0
libabw::ABWOrderedListElement::writeOut
void writeOut(librevenge::RVNGPropertyList &propList) const override
Definition: ABWCollector.cpp:91
libabw::ABWOrderedListElement::~ABWOrderedListElement
~ABWOrderedListElement() override
Definition: ABWCollector.h:79
libabw::findDouble
bool findDouble(const std::string &str, double &res, ABWUnit &unit)
Definition: ABWCollector.cpp:45
libabw::ABWCollector::collectParagraphProperties
virtual void collectParagraphProperties(const char *level, const char *listid, const char *parentid, const char *style, const char *props)=0
libabw::ABWUnorderedListElement::~ABWUnorderedListElement
~ABWUnorderedListElement() override
Definition: ABWCollector.h:96
libabw::ABW_NONE
Definition: ABWCollector.h:23
libabw::ABWUnit
ABWUnit
Definition: ABWCollector.h:21
libabw::ABWCollector::insertImage
virtual void insertImage(const char *dataid, const char *props)=0