- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
52 class MWAWCell;
53 class MWAWGraphicStyle;
54 class MWAWGraphicShape;
55 class MWAWTable;
56
57 namespace MWAWTextListenerInternal
58 {
59 struct DocumentState;
60 struct State;
61 }
62
64 class MWAWTextListener : public MWAWListener
65 {
66 public:
68 MWAWTextListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
70 virtual ~MWAWTextListener();
71
73 Type getType() const
74 {
75 return Text;
76 }
77
79 void setDocumentLanguage(std::string locale);
80
82 void startDocument();
84 void endDocument(bool sendDelayedSubDoc=true);
86 bool isDocumentStarted() const;
87
89 void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
91 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
93 bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
95 void closeFrame();
96
98 bool canWriteText() const
99 {
100 return MWAWTextListener::isDocumentStarted();
101 }
102
103 // ------ page --------
105 bool isPageSpanOpened() const;
109 MWAWPageSpan const &getPageSpan();
110
111 // ------ header/footer --------
113 bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
115 bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
117 bool isHeaderFooterOpened() const;
118
119 // ------ text data -----------
120
122 void insertChar(uint8_t character);
125 void insertCharacter(unsigned char c);
131 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
134 void insertUnicode(uint32_t character);
136 void insertUnicodeString(librevenge::RVNGString const &str);
137
139 void insertTab();
141 void insertEOL(bool softBreak=false);
142
143 // ------ text format -----------
145 void setFont(MWAWFont const &font);
147 MWAWFont const &getFont() const;
148
149 // ------ paragraph format -----------
151 bool isParagraphOpened() const;
153 void setParagraph(MWAWParagraph const &paragraph);
155 MWAWParagraph const &getParagraph() const;
156
157 // ------- fields ----------------
159 void insertField(MWAWField const &field);
160
161 // ------- link ----------------
163 void openLink(MWAWLink const &link);
165 void closeLink();
166
167 // ------- subdocument -----------------
169 void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
170
172 void insertComment(MWAWSubDocumentPtr &subDocument);
173
175 void insertPicture(MWAWPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
176 std::string type="image/pict", MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
178 void insertPicture(MWAWPosition const &pos, MWAWGraphicShape const &shape,
179 MWAWGraphicStyle const &style);
181 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
182 MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle());
183
184 // ------- table -----------------
186 void openTable(MWAWTable const &table);
188 void closeTable();
190 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
192 void closeTableRow();
194 void openTableCell(MWAWCell const &cell);
196 void closeTableCell();
198 void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
199
200 // ------- section ---------------
202 bool canOpenSectionAddBreak() const;
204 bool isSectionOpened() const;
206 MWAWSection const &getSection() const;
208 bool openSection(MWAWSection const &section);
210 bool closeSection();
212 void insertBreak(BreakType breakType);
213
214 protected:
216 void _openSection();
218 void _closeSection();
220 void _openPageSpan(bool sendHeaderFooters=true);
222 void _closePageSpan();
223
224 void _startSubDocument();
225 void _endSubDocument();
226
227 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos);
228
229 void _openParagraph();
230 void _closeParagraph();
231 void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
232 void _resetParagraphState(const bool isListElement=false);
233
235 void _openListElement();
237 void _closeListElement();
239 void _changeList();
244 int _getListId() const;
245
247 void _openSpan();
249 void _closeSpan();
250
252 void _flushText();
254 void _flushDeferredTabs();
255
256 void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
257
261 shared_ptr<MWAWTextListenerInternal::State> _pushParsingState();
263 void _popParsingState();
264
265 protected:
267 shared_ptr<MWAWTextListenerInternal::DocumentState> m_ds;
269 shared_ptr<MWAWTextListenerInternal::State> m_ps;
271 std::vector<shared_ptr<MWAWTextListenerInternal::State> > m_psStack;
273 MWAWParserState &m_parserState;
275 librevenge::RVNGTextInterface *m_documentInterface;
276
277 private:
279 MWAWTextListener(const MWAWTextListener &);
281 MWAWTextListener &operator=(const MWAWTextListener &);
282 };
283
284 #endif
285 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWTextListener::closeTableCell
void closeTableCell()
close a cell
Definition: MWAWTextListener.cxx:1759
MWAWTextListener::_handleFrameParameters
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos)
Definition: MWAWTextListener.cxx:1329
MWAWTextListener::getFont
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWTextListener.cxx:397
MWAWTextListener::insertComment
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWTextListener.cxx:1098
MWAWTextListener::MWAWTextListener
MWAWTextListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGTextInterface *documentInterface)
constructor
Definition: MWAWTextListener.cxx:200
MWAWTextListener::getSection
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWTextListener.cxx:678
MWAWTextListener::_openSection
void _openSection()
does open a section (low level)
Definition: MWAWTextListener.cxx:720
MWAWTextListener::openFrame
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
tries to open a frame
Definition: MWAWTextListener.cxx:1260
MWAWTextListener::m_parserState
MWAWParserState & m_parserState
the parser state
Definition: MWAWTextListener.hxx:273
MWAWTextListener::_popParsingState
void _popParsingState()
resets the previous parsing state
Definition: MWAWTextListener.cxx:1790
MWAWTextListener::isDocumentStarted
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWTextListener.cxx:517
MWAWTextListener::closeTableRow
void closeTableRow()
closes this row
Definition: MWAWTextListener.cxx:1713
MWAWTextListener::insertTab
void insertTab()
adds a tab
Definition: MWAWTextListener.cxx:305
MWAWTextListener::_insertBreakIfNecessary
void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList)
Definition: MWAWTextListener.cxx:360
MWAWTextListener::startDocument
void startDocument()
starts the document
Definition: MWAWTextListener.cxx:522
MWAWTextListener::insertChar
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWTextListener.cxx:213
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
libmwaw_internal.hxx
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:64
MWAWLink
a link
Definition: libmwaw_internal.hxx:380
MWAWTextListener::isSubDocumentOpened
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWTextListener.cxx:1627
MWAWTextListener::getParagraph
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWTextListener.cxx:414
MWAWTextListener::isHeaderFooterOpened
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWTextListener.cxx:639
MWAWTextListener::_closeParagraph
void _closeParagraph()
Definition: MWAWTextListener.cxx:789
MWAWTextListener::isParagraphOpened
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWTextListener.cxx:402
MWAWTextListener::insertNote
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWTextListener.cxx:1041
MWAWTextListener::_closeListElement
void _closeListElement()
close a list level
Definition: MWAWTextListener.cxx:864
MWAWTextListener::insertPicture
void insertPicture(MWAWPosition const &pos, const librevenge::RVNGBinaryData &binaryData, std::string type="image/pict", MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a picture in given position
Definition: MWAWTextListener.cxx:1234
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:173
MWAWTextListener::closeSection
bool closeSection()
close a section
Definition: MWAWTextListener.cxx:705
MWAWTextListener::openTableRow
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false)
open a row with given height ( if h < 0.0, set min-row-height = -h )
Definition: MWAWTextListener.cxx:1692
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
MWAWTextListener::operator=
MWAWTextListener & operator=(const MWAWTextListener &)
operator= (unimplemented)
MWAWTextListener::openTableCell
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWTextListener.cxx:1742
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:717
MWAWTextListener::insertFooter
bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a footer
Definition: MWAWTextListener.cxx:657
MWAWTextListener::_resetParagraphState
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWTextListener.cxx:813
MWAWTextListener::canWriteText
bool canWriteText() const
returns true if we can add text data
Definition: MWAWTextListener.hxx:98
MWAWTextListener::_closeSpan
void _closeSpan()
low level: the function which closes the last opened span property
Definition: MWAWTextListener.cxx:977
MWAWTextListener::isSectionOpened
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWTextListener.cxx:673
MWAWListener::Type
Type
the listener type
Definition: MWAWListener.hxx:56
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
MWAWTextListener::_changeList
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWTextListener.cxx:897
MWAWSubDocumentPtr
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:453
MWAWTextListener::getPageSpan
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWTextListener.cxx:571
MWAWTextListener::closeTable
void closeTable()
closes this table
Definition: MWAWTextListener.cxx:1678
MWAWTextListener::insertCharacter
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWTextListener.cxx:224
MWAWTextListener::_openSpan
void _openSpan()
low level: the function which opens a new span property
Definition: MWAWTextListener.cxx:953
MWAWTextListener::insertHeader
bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a header
Definition: MWAWTextListener.cxx:644
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
MWAWTextListener::_openParagraph
void _openParagraph()
Definition: MWAWTextListener.cxx:763
MWAWParserState
a class to define the parser state
Definition: MWAWParser.hxx:49
MWAWListener::BreakType
BreakType
the different break type
Definition: MWAWListener.hxx:58
MWAWTextListener::m_ds
shared_ptr< MWAWTextListenerInternal::DocumentState > m_ds
the main parse state
Definition: MWAWTextListener.hxx:267
MWAWTextListener::_flushDeferredTabs
void _flushDeferredTabs()
low level: flush the deferred tabs
Definition: MWAWTextListener.cxx:991
MWAWTextListener::closeLink
void closeLink()
close a link
Definition: MWAWTextListener.cxx:497
MWAWTextListener::insertTextBox
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle())
adds a textbox in given position
Definition: MWAWTextListener.cxx:1123
MWAWTextListener::~MWAWTextListener
virtual ~MWAWTextListener()
destructor
Definition: MWAWTextListener.cxx:206
MWAWTextListener::closeFrame
void closeFrame()
tries to close the last open frame
Definition: MWAWTextListener.cxx:1318
MWAWTextListener::canOpenSectionAddBreak
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWTextListener.cxx:683
MWAWTextListener::_startSubDocument
void _startSubDocument()
Definition: MWAWTextListener.cxx:1635
MWAWTextListener::_getListId
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWTextListener.cxx:880
MWAWTextListener::insertEOL
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWTextListener.cxx:287
MWAWTextListenerInternal
Internal and low level namespace to define the states of MWAWTextListener.
Definition: MWAWTextListener.cxx:70
MWAWTextListener::_closePageSpan
void _closePageSpan()
does close a page (low level)
Definition: MWAWTextListener.cxx:624
MWAWTextListener::endDocument
void endDocument(bool sendDelayedSubDoc=true)
ends the document
Definition: MWAWTextListener.cxx:535
MWAWTextListener::_endSubDocument
void _endSubDocument()
Definition: MWAWTextListener.cxx:1641
MWAWTextListener::setDocumentLanguage
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: MWAWTextListener.cxx:511
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWListener::Text
Definition: MWAWListener.hxx:56
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:439
MWAWTextListener::getType
Type getType() const
returns the listener type
Definition: MWAWTextListener.hxx:73
MWAWTextListener::_pushParsingState
shared_ptr< MWAWTextListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWTextListener.cxx:1779
MWAWTextListener::insertField
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWTextListener.cxx:422
MWAWTextListener::setParagraph
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWTextListener.cxx:407
MWAWListener.hxx
MWAWTextListener::_openListElement
void _openListElement()
open a list level
Definition: MWAWTextListener.cxx:834
MWAWTextListener::setFont
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWTextListener.cxx:381
MWAWGraphicShape
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
MWAWTextListener::addEmptyTableCell
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1))
add empty cell
Definition: MWAWTextListener.cxx:1723
MWAWTextListener::openTable
void openTable(MWAWTable const &table)
open a table
Definition: MWAWTextListener.cxx:1655
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
MWAWTextListener::openLink
void openLink(MWAWLink const &link)
open a link
Definition: MWAWTextListener.cxx:481
MWAWTextListener::insertUnicodeString
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: MWAWTextListener.cxx:280
MWAWField
a field
Definition: libmwaw_internal.hxx:361
MWAWTextListener::m_ps
shared_ptr< MWAWTextListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWTextListener.hxx:269
MWAWNote
a note
Definition: libmwaw_internal.hxx:394
MWAWTextListener::openSection
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWTextListener.cxx:688
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWListener
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:49
MWAWTextListener::insertBreak
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWTextListener.cxx:316
MWAWTextListener::m_documentInterface
librevenge::RVNGTextInterface * m_documentInterface
the document interface
Definition: MWAWTextListener.hxx:275
MWAWTextListener::m_psStack
std::vector< shared_ptr< MWAWTextListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWTextListener.hxx:271
MWAWTextListener::_flushText
void _flushText()
low level: flush the deferred text
Definition: MWAWTextListener.cxx:1010
MWAWTextListener::isPageSpanOpened
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWTextListener.cxx:566
MWAWTextListener::_openPageSpan
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWTextListener.cxx:579
MWAWGraphicStyle.hxx
MWAWVec2< int >
MWAWTextListener::_appendParagraphProperties
void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false)
Definition: MWAWTextListener.cxx:821
MWAWGraphicStyle::emptyStyle
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:204
MWAWTextListener::_closeSection
void _closeSection()
does close a section (low level)
Definition: MWAWTextListener.cxx:743
MWAWTextListener::insertUnicode
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWTextListener.cxx:270
MWAWTextListener::handleSubDocument
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWTextListener.cxx:1549