WPSContentListener.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
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 * Major Contributor(s):
10 * Copyright (C) 2006, 2007 Andrew Ziem
11 * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
12 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
13 * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
14 *
15 * For minor contributions see the git repository.
16 *
17 * Alternatively, the contents of this file may be used under the terms
18 * of the GNU Lesser General Public License Version 2.1 or later
19 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
20 * applicable instead of those above.
21 *
22 * For further information visit http://libwps.sourceforge.net
23 */
24
25#ifndef WPSCONTENTLISTENER_H
26#define WPSCONTENTLISTENER_H
27
28#include <vector>
29
30#include <librevenge/librevenge.h>
31
32#include "libwps_internal.h"
33
34#include "WPSListener.h"
35
36class WPSGraphicShape;
37class WPSGraphicStyle;
38class WPSList;
39class WPSPageSpan;
40struct WPSParagraph;
41struct WPSTabStop;
42
45
46class WPSContentListener final : public WPSListener
47{
48public:
49 WPSContentListener(std::vector<WPSPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
50 ~WPSContentListener() final;
51
52 void setDocumentLanguage(int lcid) final;
53 void setMetaData(const librevenge::RVNGPropertyList &list);
54
55 void startDocument();
56 void endDocument();
57 void handleSubDocument(WPSSubDocumentPtr &subDocument, libwps::SubDocumentType subDocumentType);
58 bool isHeaderFooterOpened() const;
59
60 // ------ text data -----------
61
63 void insertCharacter(uint8_t character) final;
67 void insertUnicode(uint32_t character) final;
69 void insertUnicodeString(librevenge::RVNGString const &str) final;
70
71 void insertTab() final;
72 void insertEOL(bool softBreak=false) final;
73 void insertBreak(const uint8_t breakType) final;
74
75 // ------ text format -----------
77 void setFont(const WPSFont &font) final;
79 WPSFont const &getFont() const final;
80
81 // ------ paragraph format -----------
83 bool isParagraphOpened() const final;
85 void setParagraph(const WPSParagraph &para) final;
87 WPSParagraph const &getParagraph() const final;
88
89 // ------ list format -----------
91 void setCurrentList(std::shared_ptr<WPSList> list);
93 std::shared_ptr<WPSList> getCurrentList() const;
94
95 // ------- fields ----------------
97 void insertField(WPSField const &field) final;
98
99 // ------- subdocument -----------------
103 void insertNote(const NoteType noteType, WPSSubDocumentPtr &subDocument);
105 void insertLabelNote(const NoteType noteType, librevenge::RVNGString const &label, WPSSubDocumentPtr &subDocument);
107 void insertComment(WPSSubDocumentPtr &subDocument);
108
110 void insertPicture(WPSPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
111 std::string const &type="image/pict",
112 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
114 void insertPicture(WPSPosition const &pos, WPSGraphicShape const &shape, WPSGraphicStyle const &style);
116 void insertObject(WPSPosition const &pos, const WPSEmbeddedObject &obj,
117 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
118
120 void insertTextBox(WPSPosition const &pos, WPSSubDocumentPtr subDocument,
121 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
123 bool openGroup(WPSPosition const &pos) final;
125 void closeGroup() final;
126
127 // ------- table -----------------
129 void openTable(std::vector<float> const &colWidth, librevenge::RVNGUnit unit);
131 void closeTable();
133 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
135 void closeTableRow();
139 void openTableCell(WPSCell const &cell, librevenge::RVNGPropertyList const &extras=librevenge::RVNGPropertyList());
141 void closeTableCell();
143 void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
144
145 // ------- section ---------------
147 bool isSectionOpened() const;
149 int getSectionNumColumns() const;
151 bool openSection(std::vector<int> colsWidth=std::vector<int>(), librevenge::RVNGUnit unit=librevenge::RVNG_INCH);
153 bool closeSection();
154
155protected:
156 void _openSection();
157 void _closeSection();
158
159 void _openPageSpan();
160 void _closePageSpan();
161 void _updatePageSpanDependent(bool set);
162
163 void _startSubDocument();
164 void _endSubDocument();
165
166 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, WPSPosition const &pos);
167 bool _openFrame(WPSPosition const &pos, librevenge::RVNGPropertyList extras=librevenge::RVNGPropertyList());
168 void _closeFrame();
169
170 void _openParagraph();
171 void _closeParagraph();
172 void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
173 void _resetParagraphState(const bool isListElement=false);
174
175 void _openListElement();
176 void _closeListElement();
177 void _changeList();
178
179 void _openSpan();
180 void _closeSpan();
181
182 void _flushText();
183 void _flushDeferredTabs();
184
185 void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
186
190 std::shared_ptr<WPSContentParsingState> _pushParsingState();
192 void _popParsingState();
193
194protected:
195 std::shared_ptr<WPSDocumentParsingState> m_ds; // main parse state
196 std::shared_ptr<WPSContentParsingState> m_ps; // parse state
197 std::vector<std::shared_ptr<WPSContentParsingState> > m_psStack;
198 librevenge::RVNGTextInterface *m_documentInterface;
199
200private:
203};
204
205#endif
206/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
a structure used to defined the cell position, and a format
Definition WPSCell.h:291
void _startSubDocument()
Definition WPSContentListener.cpp:1676
WPSContentListener(std::vector< WPSPageSpan > const &pageList, librevenge::RVNGTextInterface *documentInterface)
Definition WPSContentListener.cpp:213
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false)
open a row with given height.
Definition WPSContentListener.cpp:1747
void _flushText()
Definition WPSContentListener.cpp:1003
void insertUnicodeString(librevenge::RVNGString const &str) final
adds a unicode string
Definition WPSContentListener.cpp:250
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, WPSPosition const &pos)
Definition WPSContentListener.cpp:1353
void _closeSection()
Definition WPSContentListener.cpp:705
void insertBreak(const uint8_t breakType) final
Definition WPSContentListener.cpp:290
void _openPageSpan()
Definition WPSContentListener.cpp:593
void insertUnicode(uint32_t character) final
adds an unicode character
Definition WPSContentListener.cpp:241
std::shared_ptr< WPSDocumentParsingState > m_ds
Definition WPSContentListener.h:195
void setFont(const WPSFont &font) final
set the actual font
Definition WPSContentListener.cpp:356
bool isParagraphOpened() const final
returns true if a paragraph or a list is opened
Definition WPSContentListener.cpp:378
void insertEOL(bool softBreak=false) final
Definition WPSContentListener.cpp:257
void _flushDeferredTabs()
Definition WPSContentListener.cpp:980
void _closePageSpan()
Definition WPSContentListener.cpp:649
void _openParagraph()
Definition WPSContentListener.cpp:724
void insertField(WPSField const &field) final
adds a field
Definition WPSContentListener.cpp:429
void _openSection()
Definition WPSContentListener.cpp:668
void handleSubDocument(WPSSubDocumentPtr &subDocument, libwps::SubDocumentType subDocumentType)
Definition WPSContentListener.cpp:1583
void startDocument()
Definition WPSContentListener.cpp:548
std::shared_ptr< WPSContentParsingState > m_ps
Definition WPSContentListener.h:196
void _openSpan()
Definition WPSContentListener.cpp:942
std::shared_ptr< WPSList > getCurrentList() const
returns the current list
Definition WPSContentListener.cpp:421
void insertTextBox(WPSPosition const &pos, WPSSubDocumentPtr subDocument, librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList())
adds a textbox in given position
Definition WPSContentListener.cpp:1133
void closeTableRow()
closes this row
Definition WPSContentListener.cpp:1770
void _updatePageSpanDependent(bool set)
Definition WPSContentListener.cpp:661
bool isHeaderFooterOpened() const
Definition WPSContentListener.cpp:1671
void _openListElement()
Definition WPSContentListener.cpp:824
void openTable(std::vector< float > const &colWidth, librevenge::RVNGUnit unit)
open a table
Definition WPSContentListener.cpp:1696
void openTableCell(WPSCell const &cell, librevenge::RVNGPropertyList const &extras=librevenge::RVNGPropertyList())
low level function to define a cell.
Definition WPSContentListener.cpp:1802
void closeTableCell()
close a cell
Definition WPSContentListener.cpp:1822
std::vector< std::shared_ptr< WPSContentParsingState > > m_psStack
Definition WPSContentListener.h:197
void _closeListElement()
Definition WPSContentListener.cpp:849
void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1, 1))
add empty cell
Definition WPSContentListener.cpp:1781
void insertPicture(WPSPosition const &pos, const librevenge::RVNGBinaryData &binaryData, std::string const &type="image/pict", librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList())
adds a picture in given position
Definition WPSContentListener.cpp:1189
void setParagraph(const WPSParagraph &para) final
sets the actual paragraph
Definition WPSContentListener.cpp:388
NoteType
defines the footnote type
Definition WPSContentListener.h:101
@ ENDNOTE
Definition WPSContentListener.h:101
@ FOOTNOTE
Definition WPSContentListener.h:101
void _closeSpan()
Definition WPSContentListener.cpp:967
bool isSectionOpened() const
returns true if a section is opened
Definition WPSContentListener.cpp:451
bool _openFrame(WPSPosition const &pos, librevenge::RVNGPropertyList extras=librevenge::RVNGPropertyList())
Definition WPSContentListener.cpp:1284
void _closeParagraph()
Definition WPSContentListener.cpp:753
bool closeSection()
close a section
Definition WPSContentListener.cpp:509
void setDocumentLanguage(int lcid) final
Definition WPSContentListener.cpp:530
~WPSContentListener() final
Definition WPSContentListener.cpp:222
bool openSection(std::vector< int > colsWidth=std::vector< int >(), librevenge::RVNGUnit unit=librevenge::RVNG_INCH)
open a section if possible
Definition WPSContentListener.cpp:461
void _closeFrame()
Definition WPSContentListener.cpp:1341
int getSectionNumColumns() const
returns the actual number of columns ( or 1 if no section is opened )
Definition WPSContentListener.cpp:456
void _resetParagraphState(const bool isListElement=false)
Definition WPSContentListener.cpp:776
WPSParagraph const & getParagraph() const final
returns the actual paragraph
Definition WPSContentListener.cpp:383
void setMetaData(const librevenge::RVNGPropertyList &list)
Definition WPSContentListener.cpp:538
librevenge::RVNGTextInterface * m_documentInterface
Definition WPSContentListener.h:198
void closeTable()
closes this table
Definition WPSContentListener.cpp:1732
void insertTab() final
adds an unicode character to a string ( with correct encoding ).
Definition WPSContentListener.cpp:278
void insertLabelNote(const NoteType noteType, librevenge::RVNGString const &label, WPSSubDocumentPtr &subDocument)
adds a label note
Definition WPSContentListener.cpp:1048
void _changeList()
Definition WPSContentListener.cpp:866
void _popParsingState()
resets the previous parsing state
Definition WPSContentListener.cpp:1863
WPSFont const & getFont() const final
returns the actual font
Definition WPSContentListener.cpp:370
void _endSubDocument()
Definition WPSContentListener.cpp:1682
void setCurrentList(std::shared_ptr< WPSList > list)
function to set the actual list
Definition WPSContentListener.cpp:415
void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false)
Definition WPSContentListener.cpp:795
void endDocument()
Definition WPSContentListener.cpp:564
bool openGroup(WPSPosition const &pos) final
open a group
Definition WPSContentListener.cpp:1218
void insertObject(WPSPosition const &pos, const WPSEmbeddedObject &obj, librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList())
adds an object with replacement picture in given position
Definition WPSContentListener.cpp:1202
void insertCharacter(uint8_t character) final
adds a basic character, ..
Definition WPSContentListener.cpp:229
void insertComment(WPSSubDocumentPtr &subDocument)
adds comment
Definition WPSContentListener.cpp:1106
void insertNote(const NoteType noteType, WPSSubDocumentPtr &subDocument)
adds note
Definition WPSContentListener.cpp:1037
std::shared_ptr< WPSContentParsingState > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition WPSContentListener.cpp:1843
void closeGroup() final
close a group
Definition WPSContentListener.cpp:1272
void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList)
Definition WPSContentListener.cpp:336
define the font properties
Definition WPSFont.h:37
a structure used to define a picture shape
Definition WPSGraphicShape.h:35
a structure used to define a picture style
Definition WPSGraphicStyle.h:38
a small structure used to store the informations about a list
Definition WPSList.h:37
WPSListener()
Definition WPSListener.h:39
Definition WPSPageSpan.h:39
Class to define the position of an object (textbox, picture, ..) in the document.
Definition WPSPosition.h:40
std::shared_ptr< WPSSubDocument > WPSSubDocumentPtr
shared pointer to WPSSubDocument
Definition libwps_internal.h:111
Vec2< int > Vec2i
Vec2 of int.
Definition libwps_internal.h:702
SubDocumentType
Definition libwps_internal.h:248
the content state
Definition WPSContentListener.cpp:88
the document state
Definition WPSContentListener.cpp:49
small class use to define a embedded object
Definition libwps_internal.h:1077
a field
Definition libwps_internal.h:463
class to store the paragraph properties
Definition WPSParagraph.h:58
Definition WPSParagraph.h:38

Generated on for libwps by doxygen 1.17.0