MWAWTextListener.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3/* libmwaw
4* Version: MPL 2.0 / LGPLv2+
5*
6* The contents of this file are subject to the Mozilla Public License Version
7* 2.0 (the "License"); you may not use this file except in compliance with
8* the License or as specified alternatively below. You may obtain a copy of
9* the License at http://www.mozilla.org/MPL/
10*
11* Software distributed under the License is distributed on an "AS IS" basis,
12* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13* for the specific language governing rights and limitations under the
14* License.
15*
16* Major Contributor(s):
17* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20* Copyright (C) 2006, 2007 Andrew Ziem
21* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22*
23*
24* All Rights Reserved.
25*
26* For minor contributions see the git repository.
27*
28* Alternatively, the contents of this file may be used under the terms of
29* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30* in which case the provisions of the LGPLv2+ are applicable
31* instead of those above.
32*/
33
40#ifndef MWAW_TEXT_LISTENER_H
41#define MWAW_TEXT_LISTENER_H
42
43#include <vector>
44
45#include <librevenge/librevenge.h>
46
47#include "libmwaw_internal.hxx"
48#include "MWAWGraphicStyle.hxx"
49
50#include "MWAWListener.hxx"
51
52class MWAWCell;
55class MWAWTable;
56
58{
59struct DocumentState;
60struct State;
61}
62
64class MWAWTextListener final : public MWAWListener
65{
66public:
68 MWAWTextListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
70 ~MWAWTextListener() final;
71
73 Type getType() const final
74 {
75 return Text;
76 }
77
79 void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata) final;
81 void setDocumentLanguage(std::string const &locale) final;
82
84 void startDocument() final;
86 void endDocument(bool sendDelayedSubDoc=true) final;
88 bool isDocumentStarted() const final;
89
91 void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType) final;
93 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const final;
95 bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final;
97 void closeFrame() final;
99 bool openGroup(MWAWPosition const &pos) final;
101 void closeGroup() final;
102
104 bool canWriteText() const final
105 {
107 }
108
109 // ------ page --------
111 bool isPageSpanOpened() const final;
115 MWAWPageSpan const &getPageSpan() final;
116
117 // ------ header/footer --------
119 bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final;
121 bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final;
123 bool isHeaderFooterOpened() const final;
124
125 // ------ text data -----------
126
128 void insertChar(uint8_t character) final;
131 void insertCharacter(unsigned char c) final;
137 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1) final;
140 void insertUnicode(uint32_t character) final;
142 void insertUnicodeString(librevenge::RVNGString const &str) final;
143
145 void insertTab() final;
147 void insertEOL(bool softBreak=false) final;
148
149 // ------ text format -----------
151 void setFont(MWAWFont const &font) final;
153 MWAWFont const &getFont() const final;
154
155 // ------ paragraph format -----------
157 bool isParagraphOpened() const final;
159 void setParagraph(MWAWParagraph const &paragraph) final;
161 MWAWParagraph const &getParagraph() const final;
162
163 // ------- fields ----------------
165 void insertField(MWAWField const &field) final;
166
167 // ------- link ----------------
169 void openLink(MWAWLink const &link) final;
171 void closeLink() final;
172
173 // ------- subdocument -----------------
175 void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument) final;
176
178 void insertComment(MWAWSubDocumentPtr &subDocument) final;
179
181 void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
182 MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final;
184 void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape,
185 MWAWGraphicStyle const &style) final;
187 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument,
188 MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle()) final;
189
190 // ------- table -----------------
192 void openTable(MWAWTable const &table) final;
194 void closeTable() final;
196 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final;
198 void closeTableRow() final;
200 void openTableCell(MWAWCell const &cell) final;
202 void closeTableCell() final;
204 void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1)) final;
205
206 // ------- section ---------------
208 bool canOpenSectionAddBreak() const final;
210 bool isSectionOpened() const final;
212 MWAWSection const &getSection() const final;
214 bool openSection(MWAWSection const &section) final;
216 bool closeSection() final;
218 void insertBreak(BreakType breakType) final;
219
220protected:
222 void _openSection();
224 void _closeSection();
226 void _openPageSpan(bool sendHeaderFooters=true);
228 void _closePageSpan();
229
230 void _startSubDocument();
231 void _endSubDocument();
232
233 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos);
234
235 void _openParagraph();
236 void _closeParagraph();
237 void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
238 void _resetParagraphState(const bool isListElement=false);
239
241 void _openListElement();
243 void _closeListElement();
245 void _changeList();
250 int _getListId() const;
251
253 void _openSpan();
255 void _closeSpan();
256
258 void _flushText();
260 void _flushDeferredTabs();
261
262 void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
263
267 std::shared_ptr<MWAWTextListenerInternal::State> _pushParsingState();
269 void _popParsingState();
270
271protected:
273 std::shared_ptr<MWAWTextListenerInternal::DocumentState> m_ds;
275 std::shared_ptr<MWAWTextListenerInternal::State> m_ps;
277 std::vector<std::shared_ptr<MWAWTextListenerInternal::State> > m_psStack;
281 librevenge::RVNGTextInterface *m_documentInterface;
282
283private:
287 MWAWTextListener &operator=(const MWAWTextListener &) = delete;
288};
289
290#endif
291// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
a structure used to define a cell and its format
Definition: MWAWCell.hxx:53
Class to store font.
Definition: MWAWFont.hxx:44
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:46
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:50
Type
the listener type
Definition: MWAWListener.hxx:56
@ Text
Definition: MWAWListener.hxx:56
BreakType
the different break type
Definition: MWAWListener.hxx:58
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:99
class to store the paragraph properties
Definition: MWAWParagraph.hxx:85
a class to define the parser state
Definition: MWAWParser.hxx:50
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
a class which stores section properties
Definition: MWAWSection.hxx:46
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:52
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
bool isParagraphOpened() const final
returns true if a paragraph or a list is opened
Definition: MWAWTextListener.cxx:431
bool isPageSpanOpened() const final
returns true if a page is opened
Definition: MWAWTextListener.cxx:561
void closeTableRow() final
closes this row
Definition: MWAWTextListener.cxx:1814
bool canWriteText() const final
returns true if we can add text data
Definition: MWAWTextListener.hxx:104
std::shared_ptr< MWAWTextListenerInternal::DocumentState > m_ds
the main parse state
Definition: MWAWTextListener.hxx:273
std::shared_ptr< MWAWTextListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWTextListener.hxx:275
void insertChar(uint8_t character) final
adds a basic character, ..
Definition: MWAWTextListener.cxx:238
void insertTab() final
adds a tab
Definition: MWAWTextListener.cxx:330
void startDocument() final
starts the document
Definition: MWAWTextListener.cxx:517
std::shared_ptr< MWAWTextListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWTextListener.cxx:1880
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWTextListener.cxx:891
void _openSpan()
low level: the function which opens a new span property
Definition: MWAWTextListener.cxx:950
bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final
insert a header
Definition: MWAWTextListener.cxx:639
void setParagraph(MWAWParagraph const &paragraph) final
sets the paragraph
Definition: MWAWTextListener.cxx:436
std::vector< std::shared_ptr< MWAWTextListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWTextListener.hxx:277
void _openListElement()
open a list level
Definition: MWAWTextListener.cxx:829
void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType) final
function called to add a subdocument
Definition: MWAWTextListener.cxx:1643
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1)) final
add empty cell
Definition: MWAWTextListener.cxx:1824
bool isHeaderFooterOpened() const final
returns true if the header/footer is open
Definition: MWAWTextListener.cxx:634
void _openParagraph()
Definition: MWAWTextListener.cxx:758
void insertField(MWAWField const &field) final
adds a field type
Definition: MWAWTextListener.cxx:451
librevenge::RVNGTextInterface * m_documentInterface
the document interface
Definition: MWAWTextListener.hxx:281
void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style) final
adds a shape picture in given position
Definition: MWAWTextListener.cxx:1136
void insertComment(MWAWSubDocumentPtr &subDocument) final
adds comment
Definition: MWAWTextListener.cxx:1095
void _closeListElement()
close a list level
Definition: MWAWTextListener.cxx:859
void openTable(MWAWTable const &table) final
open a table
Definition: MWAWTextListener.cxx:1756
bool isSectionOpened() const final
returns true if a section is opened
Definition: MWAWTextListener.cxx:668
void openLink(MWAWLink const &link) final
open a link
Definition: MWAWTextListener.cxx:469
void _closeSection()
does close a section (low level)
Definition: MWAWTextListener.cxx:738
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWTextListener.cxx:808
void _popParsingState()
resets the previous parsing state
Definition: MWAWTextListener.cxx:1891
void _closeSpan()
low level: the function which closes the last opened span property
Definition: MWAWTextListener.cxx:974
MWAWPageSpan const & getPageSpan() final
returns the current page span
Definition: MWAWTextListener.cxx:566
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos)
Definition: MWAWTextListener.cxx:1401
void closeLink() final
close a link
Definition: MWAWTextListener.cxx:485
void _closePageSpan()
does close a page (low level)
Definition: MWAWTextListener.cxx:619
MWAWParserState & m_parserState
the parser state
Definition: MWAWTextListener.hxx:279
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument, MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle()) final
adds a textbox in given position
Definition: MWAWTextListener.cxx:1120
void insertUnicodeString(librevenge::RVNGString const &str) final
adds a unicode string
Definition: MWAWTextListener.cxx:305
void openTableCell(MWAWCell const &cell) final
open a cell
Definition: MWAWTextListener.cxx:1843
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const final
returns try if a subdocument is open
Definition: MWAWTextListener.cxx:1728
void closeGroup() final
close a group
Definition: MWAWTextListener.cxx:1389
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final
tries to open a frame
Definition: MWAWTextListener.cxx:1258
MWAWParagraph const & getParagraph() const final
returns the actual paragraph
Definition: MWAWTextListener.cxx:443
void endDocument(bool sendDelayedSubDoc=true) final
ends the document
Definition: MWAWTextListener.cxx:530
void closeTable() final
closes this table
Definition: MWAWTextListener.cxx:1779
void setFont(MWAWFont const &font) final
sets the font
Definition: MWAWTextListener.cxx:410
void insertEOL(bool softBreak=false) final
adds an end of line ( by default an hard one)
Definition: MWAWTextListener.cxx:312
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWTextListener.cxx:574
void _flushText()
low level: flush the deferred text
Definition: MWAWTextListener.cxx:1007
MWAWFont const & getFont() const final
returns the actual font
Definition: MWAWTextListener.cxx:426
void _openSection()
does open a section (low level)
Definition: MWAWTextListener.cxx:715
void _closeParagraph()
Definition: MWAWTextListener.cxx:784
void insertUnicode(uint32_t character) final
adds an unicode character.
Definition: MWAWTextListener.cxx:295
MWAWSection const & getSection() const final
returns the actual section
Definition: MWAWTextListener.cxx:673
void _startSubDocument()
Definition: MWAWTextListener.cxx:1736
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument) final
insert a note
Definition: MWAWTextListener.cxx:1038
void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList)
Definition: MWAWTextListener.cxx:389
bool closeSection() final
close a section
Definition: MWAWTextListener.cxx:700
void insertBreak(BreakType breakType) final
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWTextListener.cxx:341
void _flushDeferredTabs()
low level: flush the deferred tabs
Definition: MWAWTextListener.cxx:988
void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false)
Definition: MWAWTextListener.cxx:816
void closeFrame() final
tries to close the last open frame
Definition: MWAWTextListener.cxx:1328
void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final
adds a picture with potential various representationin given position
Definition: MWAWTextListener.cxx:1234
Type getType() const final
returns the listener type
Definition: MWAWTextListener.hxx:73
bool openGroup(MWAWPosition const &pos) final
open a group
Definition: MWAWTextListener.cxx:1338
bool openSection(MWAWSection const &section) final
open a section if possible
Definition: MWAWTextListener.cxx:683
void closeTableCell() final
close a cell
Definition: MWAWTextListener.cxx:1860
bool isDocumentStarted() const final
returns true if a document is opened
Definition: MWAWTextListener.cxx:512
void insertCharacter(unsigned char c) final
insert a character using the font converter to find the utf8 character
Definition: MWAWTextListener.cxx:249
void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata) final
sets the documents metadata
Definition: MWAWTextListener.cxx:499
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final
open a row with given height ( if h < 0.0, set min-row-height = -h )
Definition: MWAWTextListener.cxx:1793
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level.
Definition: MWAWTextListener.cxx:875
bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final
insert a footer
Definition: MWAWTextListener.cxx:652
void _endSubDocument()
Definition: MWAWTextListener.cxx:1742
void setDocumentLanguage(std::string const &locale) final
sets the documents language
Definition: MWAWTextListener.cxx:506
~MWAWTextListener() final
destructor
Definition: MWAWTextListener.cxx:231
bool canOpenSectionAddBreak() const final
returns true if we can add open a section, add page break, ...
Definition: MWAWTextListener.cxx:678
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:565
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
Internal and low level namespace to define the states of MWAWTextListener.
Definition: MWAWTextListener.cxx:71
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:51
Definition: MWAWDocument.hxx:57
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
a field
Definition: libmwaw_internal.hxx:399
a note
Definition: libmwaw_internal.hxx:445

Generated on Thu Jan 19 2023 00:00:00 for libmwaw by doxygen 1.9.6