WPSContentListener.h Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
36 class WPSList;
37 class WPSPageSpan;
38 struct WPSParagraph;
39 struct WPSTabStop;
40
41 struct WPSContentParsingState;
42 struct WPSDocumentParsingState;
43
44 class WPSContentListener : public WPSListener
45 {
46 public:
47 WPSContentListener(std::vector<WPSPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
48 virtual ~WPSContentListener();
49
50 void setDocumentLanguage(int lcid);
51
52 void startDocument();
53 void endDocument();
54 void handleSubDocument(WPSSubDocumentPtr &subDocument, libwps::SubDocumentType subDocumentType);
55 bool isHeaderFooterOpened() const;
56
57 // ------ text data -----------
58
60 void insertCharacter(uint8_t character);
64 void insertUnicode(uint32_t character);
66 void insertUnicodeString(librevenge::RVNGString const &str);
67
68 void insertTab();
69 void insertEOL(bool softBreak=false);
70 void insertBreak(const uint8_t breakType);
71
72 // ------ text format -----------
74 void setFont(const WPSFont &font);
76 WPSFont const &getFont() const;
77
78 // ------ paragraph format -----------
80 bool isParagraphOpened() const;
82 void setParagraph(const WPSParagraph &para);
84 WPSParagraph const &getParagraph() const;
85
86 // ------ list format -----------
88 void setCurrentList(shared_ptr<WPSList> list);
90 shared_ptr<WPSList> getCurrentList() const;
91
92 // ------- fields ----------------
94 void insertField(FieldType type);
96 void insertDateTimeField(char const *format);
97
98 // ------- subdocument -----------------
100 enum NoteType { FOOTNOTE, ENDNOTE };
102 void insertNote(const NoteType noteType, WPSSubDocumentPtr &subDocument);
104 void insertLabelNote(const NoteType noteType, librevenge::RVNGString const &label, WPSSubDocumentPtr &subDocument);
106 void insertComment(WPSSubDocumentPtr &subDocument);
107
109 void insertPicture(WPSPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
110 std::string type="image/pict",
111 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
113 void insertTextBox(WPSPosition const &pos, WPSSubDocumentPtr subDocument,
114 librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
115
116
117 // ------- table -----------------
119 void openTable(std::vector<float> const &colWidth, librevenge::RVNGUnit unit);
121 void closeTable();
123 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
125 void closeTableRow();
129 void openTableCell(WPSCell const &cell, librevenge::RVNGPropertyList const &extras=librevenge::RVNGPropertyList());
131 void closeTableCell();
133 void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
134
135 // ------- section ---------------
137 bool isSectionOpened() const;
139 int getSectionNumColumns() const;
141 bool openSection(std::vector<int> colsWidth=std::vector<int>(), librevenge::RVNGUnit unit=librevenge::RVNG_INCH);
143 bool closeSection();
144
145 protected:
146 void _openSection();
147 void _closeSection();
148
149 void _openPageSpan();
150 void _closePageSpan();
151 void _updatePageSpanDependent(bool set);
152
153 void _startSubDocument();
154 void _endSubDocument();
155
156 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, WPSPosition const &pos);
157 bool _openFrame(WPSPosition const &pos, librevenge::RVNGPropertyList extras=librevenge::RVNGPropertyList());
158 void _closeFrame();
159
160 void _openParagraph();
161 void _closeParagraph();
162 void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
163 void _resetParagraphState(const bool isListElement=false);
164
165 void _openListElement();
166 void _closeListElement();
167 void _changeList();
168
169 void _openSpan();
170 void _closeSpan();
171
172 void _flushText();
173 void _flushDeferredTabs();
174
175 void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
176
180 shared_ptr<WPSContentParsingState> _pushParsingState();
182 void _popParsingState();
183
184 protected:
185 shared_ptr<WPSDocumentParsingState> m_ds; // main parse state
186 shared_ptr<WPSContentParsingState> m_ps; // parse state
187 std::vector<shared_ptr<WPSContentParsingState> > m_psStack;
188 librevenge::RVNGTextInterface *m_documentInterface;
189
190 private:
191 WPSContentListener(const WPSContentListener &);
192 WPSContentListener &operator=(const WPSContentListener &);
193 };
194
195 #endif
196 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSContentListener::insertPicture
void insertPicture(WPSPosition const &pos, const librevenge::RVNGBinaryData &binaryData, std::string type="image/pict", librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList())
adds a picture in given position
Definition: WPSContentListener.cpp:1153
WPSContentListener::_closeParagraph
void _closeParagraph()
Definition: WPSContentListener.cpp:760
WPSContentListener::startDocument
void startDocument()
Definition: WPSContentListener.cpp:555
WPSContentListener::insertEOL
void insertEOL(bool softBreak=false)
Definition: WPSContentListener.cpp:234
WPSContentListener::_updatePageSpanDependent
void _updatePageSpanDependent(bool set)
Definition: WPSContentListener.cpp:667
WPSContentListener::operator=
WPSContentListener & operator=(const WPSContentListener &)
WPSParagraph
class to store the paragraph properties
Definition: WPSParagraph.h:54
WPSContentListener::_insertBreakIfNecessary
void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList)
Definition: WPSContentListener.cpp:313
WPSContentListener::_flushText
void _flushText()
Definition: WPSContentListener.cpp:1010
WPSContentListener::_closeListElement
void _closeListElement()
Definition: WPSContentListener.cpp:856
WPSDocumentParsingState
the document state
Definition: WPSContentListener.cpp:46
WPSSubDocumentPtr
shared_ptr< WPSSubDocument > WPSSubDocumentPtr
shared pointer to WPSSubDocument
Definition: libwps_internal.h:105
WPSContentListener::setDocumentLanguage
void setDocumentLanguage(int lcid)
Definition: WPSContentListener.cpp:547
WPSContentListener::insertLabelNote
void insertLabelNote(const NoteType noteType, librevenge::RVNGString const &label, WPSSubDocumentPtr &subDocument)
adds a label note
Definition: WPSContentListener.cpp:1055
WPSContentListener::_flushDeferredTabs
void _flushDeferredTabs()
Definition: WPSContentListener.cpp:987
WPSContentListener::m_ps
shared_ptr< WPSContentParsingState > m_ps
Definition: WPSContentListener.h:186
WPSFont
define the font properties
Definition: WPSFont.h:36
WPSContentListener::_popParsingState
void _popParsingState()
resets the previous parsing state
Definition: WPSContentListener.cpp:1719
WPSContentParsingState
the content state
Definition: WPSContentListener.cpp:81
WPSContentListener::closeTable
void closeTable()
closes this table
Definition: WPSContentListener.cpp:1588
WPSListener
virtual class for content listener
Definition: WPSListener.h:36
WPSContentListener::_changeList
void _changeList()
Definition: WPSContentListener.cpp:873
WPSContentListener::_appendParagraphProperties
void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false)
Definition: WPSContentListener.cpp:802
WPSContentListener::openTable
void openTable(std::vector< float > const &colWidth, librevenge::RVNGUnit unit)
open a table
Definition: WPSContentListener.cpp:1551
WPSContentListener::_openPageSpan
void _openPageSpan()
Definition: WPSContentListener.cpp:600
WPSContentListener::insertBreak
void insertBreak(const uint8_t breakType)
Definition: WPSContentListener.cpp:267
WPSContentListener::insertDateTimeField
void insertDateTimeField(char const *format)
insert a date/time field with given format (see strftime)
Definition: WPSContentListener.cpp:448
WPSContentListener
Definition: WPSContentListener.h:44
WPSContentListener::endDocument
void endDocument()
Definition: WPSContentListener.cpp:571
WPSContentListener::ENDNOTE
Definition: WPSContentListener.h:100
WPSCell
a structure used to defined the cell position, and a format
Definition: WPSCell.h:251
WPSContentListener::m_documentInterface
librevenge::RVNGTextInterface * m_documentInterface
Definition: WPSContentListener.h:188
WPSContentListener::_startSubDocument
void _startSubDocument()
Definition: WPSContentListener.cpp:1531
WPSContentListener::insertTextBox
void insertTextBox(WPSPosition const &pos, WPSSubDocumentPtr subDocument, librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList())
adds a textbox in given position
Definition: WPSContentListener.cpp:1140
WPSContentListener::getCurrentList
shared_ptr< WPSList > getCurrentList() const
returns the current list
Definition: WPSContentListener.cpp:398
WPSContentListener::closeTableRow
void closeTableRow()
closes this row
Definition: WPSContentListener.cpp:1626
WPSContentListener::NoteType
NoteType
defines the footnote type
Definition: WPSContentListener.h:100
WPSContentListener::setParagraph
void setParagraph(const WPSParagraph &para)
sets the actual paragraph
Definition: WPSContentListener.cpp:365
WPSContentListener::_closePageSpan
void _closePageSpan()
Definition: WPSContentListener.cpp:655
WPSContentListener::_endSubDocument
void _endSubDocument()
Definition: WPSContentListener.cpp:1537
libwps_internal.h
WPSContentListener::insertField
void insertField(FieldType type)
adds a field type
Definition: WPSContentListener.cpp:407
WPSContentListener::insertComment
void insertComment(WPSSubDocumentPtr &subDocument)
adds comment
Definition: WPSContentListener.cpp:1113
WPSContentListener::_pushParsingState
shared_ptr< WPSContentParsingState > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: WPSContentListener.cpp:1699
libwps::SubDocumentType
SubDocumentType
Definition: libwps_internal.h:402
WPSList
a small structure used to store the informations about a list
Definition: WPSList.h:36
WPSContentListener::_openListElement
void _openListElement()
Definition: WPSContentListener.cpp:831
WPSContentListener::openTableRow
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false)
open a row with given height.
Definition: WPSContentListener.cpp:1603
WPSContentListener::isHeaderFooterOpened
bool isHeaderFooterOpened() const
Definition: WPSContentListener.cpp:1526
WPSContentListener::getSectionNumColumns
int getSectionNumColumns() const
returns the actual number of columns ( or 1 if no section is opened )
Definition: WPSContentListener.cpp:473
WPSContentListener::m_ds
shared_ptr< WPSDocumentParsingState > m_ds
Definition: WPSContentListener.h:185
WPSContentListener::_openParagraph
void _openParagraph()
Definition: WPSContentListener.cpp:731
WPSContentListener::setFont
void setFont(const WPSFont &font)
set the actual font
Definition: WPSContentListener.cpp:333
WPSContentListener::insertTab
void insertTab()
Definition: WPSContentListener.cpp:255
WPSContentListener::_handleFrameParameters
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, WPSPosition const &pos)
Definition: WPSContentListener.cpp:1224
WPSListener::FieldType
FieldType
Defines some basic type for field.
Definition: WPSListener.h:126
WPSContentListener::_openFrame
bool _openFrame(WPSPosition const &pos, librevenge::RVNGPropertyList extras=librevenge::RVNGPropertyList())
Definition: WPSContentListener.cpp:1169
WPSContentListener::insertCharacter
void insertCharacter(uint8_t character)
adds a basic character, ..
Definition: WPSContentListener.cpp:206
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition: libwps_internal.h:627
WPSContentListener::_openSpan
void _openSpan()
Definition: WPSContentListener.cpp:949
WPSContentListener::openSection
bool openSection(std::vector< int > colsWidth=std::vector< int >(), librevenge::RVNGUnit unit=librevenge::RVNG_INCH)
open a section if possible
Definition: WPSContentListener.cpp:478
WPSContentListener::WPSContentListener
WPSContentListener(std::vector< WPSPageSpan > const &pageList, librevenge::RVNGTextInterface *documentInterface)
Definition: WPSContentListener.cpp:192
WPSContentListener::isParagraphOpened
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: WPSContentListener.cpp:355
WPSContentListener::setCurrentList
void setCurrentList(shared_ptr< WPSList > list)
function to set the actual list
Definition: WPSContentListener.cpp:392
WPSContentListener::closeSection
bool closeSection()
close a section
Definition: WPSContentListener.cpp:526
WPSContentListener::handleSubDocument
void handleSubDocument(WPSSubDocumentPtr &subDocument, libwps::SubDocumentType subDocumentType)
Definition: WPSContentListener.cpp:1440
WPSContentListener::_resetParagraphState
void _resetParagraphState(const bool isListElement=false)
Definition: WPSContentListener.cpp:783
WPSListener.h
WPSTabStop
Definition: WPSParagraph.h:37
WPSPageSpan
Definition: WPSPageSpan.h:38
WPSContentListener::closeTableCell
void closeTableCell()
close a cell
Definition: WPSContentListener.cpp:1678
WPSContentListener::isSectionOpened
bool isSectionOpened() const
returns true if a section is opened
Definition: WPSContentListener.cpp:468
WPSContentListener::_closeFrame
void _closeFrame()
Definition: WPSContentListener.cpp:1212
WPSContentListener::_openSection
void _openSection()
Definition: WPSContentListener.cpp:674
WPSContentListener::insertNote
void insertNote(const NoteType noteType, WPSSubDocumentPtr &subDocument)
adds note
Definition: WPSContentListener.cpp:1044
WPSContentListener::insertUnicode
void insertUnicode(uint32_t character)
adds an unicode character
Definition: WPSContentListener.cpp:218
Vec2< int >
WPSPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: WPSPosition.h:39
WPSContentListener::FOOTNOTE
Definition: WPSContentListener.h:100
WPSContentListener::~WPSContentListener
virtual ~WPSContentListener()
Definition: WPSContentListener.cpp:199
WPSContentListener::_closeSection
void _closeSection()
Definition: WPSContentListener.cpp:712
WPSContentListener::_closeSpan
void _closeSpan()
Definition: WPSContentListener.cpp:974
WPSContentListener::insertUnicodeString
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: WPSContentListener.cpp:227
WPSContentListener::addEmptyTableCell
void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1, 1))
add empty cell
Definition: WPSContentListener.cpp:1637
WPSContentListener::openTableCell
void openTableCell(WPSCell const &cell, librevenge::RVNGPropertyList const &extras=librevenge::RVNGPropertyList())
low level function to define a cell.
Definition: WPSContentListener.cpp:1658
WPSContentListener::getFont
WPSFont const & getFont() const
returns the actual font
Definition: WPSContentListener.cpp:347
WPSContentListener::m_psStack
std::vector< shared_ptr< WPSContentParsingState > > m_psStack
Definition: WPSContentListener.h:187
WPSContentListener::getParagraph
WPSParagraph const & getParagraph() const
returns the actual paragraph
Definition: WPSContentListener.cpp:360