/src/libabw/src/lib/ABWCollector.h
Line | Count | Source |
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 | 545 | : m_mimeType(), m_binaryData() {} |
49 | | ABWData(const ABWData &data) |
50 | 0 | : m_mimeType(data.m_mimeType), m_binaryData(data.m_binaryData) {} |
51 | | ABWData(const librevenge::RVNGString &mimeType, const librevenge::RVNGBinaryData binaryData) |
52 | 2.46k | : m_mimeType(mimeType), m_binaryData(binaryData) {} |
53 | 3.00k | ~ABWData() {} |
54 | 2.46k | 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 | 377k | : m_listLevel(-1), m_minLabelWidth(0.0), m_spaceBefore(0.0), m_parentId(), m_listId(0) {} |
64 | 377k | 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; |
72 | | //! the list id |
73 | | int m_listId; |
74 | | }; |
75 | | |
76 | | struct ABWOrderedListElement : public ABWListElement |
77 | | { |
78 | | ABWOrderedListElement() |
79 | 3.60k | : ABWListElement(), m_numFormat(), m_numPrefix(), m_numSuffix(), m_startValue(-1) {} |
80 | 3.60k | ~ABWOrderedListElement() override {} |
81 | | void writeOut(librevenge::RVNGPropertyList &propList) const override; |
82 | | ABWListType getType() const override |
83 | 3.41k | { |
84 | 3.41k | return ABW_ORDERED; |
85 | 3.41k | } |
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 | 373k | : ABWListElement(), m_bulletChar() {} |
97 | 373k | ~ABWUnorderedListElement() override {} |
98 | | void writeOut(librevenge::RVNGPropertyList &propList) const override; |
99 | | ABWListType getType() const override |
100 | 272k | { |
101 | 272k | return ABW_UNORDERED; |
102 | 272k | } |
103 | | |
104 | | librevenge::RVNGString m_bulletChar; |
105 | | }; |
106 | | |
107 | | class ABWCollector |
108 | | { |
109 | | public: |
110 | 64.7k | ABWCollector() {} |
111 | 64.7k | 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: */ |