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