- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MWAWGraphicListener.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
34 #ifndef MWAW_GRAPHIC_LISTENER_H
35 #define MWAW_GRAPHIC_LISTENER_H
36
37 #include <vector>
38
39 #include <librevenge/librevenge.h>
40
41 #include "libmwaw_internal.hxx"
42
43 #include "MWAWGraphicStyle.hxx"
44
45 #include "MWAWListener.hxx"
46
47 class MWAWGraphicShape;
48
49 namespace MWAWGraphicListenerInternal
50 {
51 struct GraphicState;
52 struct State;
53 }
54
59 class MWAWGraphicListener : public MWAWListener
60 {
61 public:
63 MWAWGraphicListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGDrawingInterface *documentInterface);
67 MWAWGraphicListener(MWAWParserState &parserState, MWAWBox2f const &box, librevenge::RVNGDrawingInterface *documentInterface);
69 virtual ~MWAWGraphicListener();
70
72 Type getType() const
73 {
74 return Graphic;
75 }
76
78 void setDocumentLanguage(std::string locale);
80 void startDocument();
82 void endDocument(bool delayed=true);
83
84 // ------ general information --------
86 bool canWriteText() const;
88 bool isDocumentStarted() const;
89
91 void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
93 void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
94 {
95 handleSubDocument(MWAWVec2f(0,0), subDocument, subDocumentType);
96 }
98 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
100 bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
102 void closeFrame();
104 bool openGroup(MWAWPosition const &pos);
106 void closeGroup();
108 bool openLayer(librevenge::RVNGString const &name);
110 void closeLayer();
111
112 // ------ page --------
114 bool openMasterPage(MWAWPageSpan &masterPage);
116 void closeMasterPage()
117 {
118 _closePageSpan(true);
119 }
121 bool isPageSpanOpened() const;
125 MWAWPageSpan const &getPageSpan();
126
127 // ------ header/footer --------
129 bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
131 bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
133 bool isHeaderFooterOpened() const;
134
135 // ------ text data -----------
137 void insertChar(uint8_t character);
140 void insertCharacter(unsigned char c);
146 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
149 void insertUnicode(uint32_t character);
151 void insertUnicodeString(librevenge::RVNGString const &str);
152
154 void insertTab();
156 void insertEOL(bool softBreak=false);
157
158 // ------ text format -----------
160 void setFont(MWAWFont const &font);
162 MWAWFont const &getFont() const;
163
164 // ------ paragraph format -----------
166 bool isParagraphOpened() const;
168 void setParagraph(MWAWParagraph const &paragraph);
170 MWAWParagraph const &getParagraph() const;
171
172 // ------- fields ----------------
174 void insertField(MWAWField const &field);
175
176 // ------- link ----------------
178 void openLink(MWAWLink const &link);
180 void closeLink();
181
182 // ------- subdocument -----------------
184 void insertPicture(MWAWPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
185 std::string type="image/pict", MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
187 void insertPicture(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style);
189 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style);
191 void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr subDocument);
195 void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
199 void insertComment(MWAWSubDocumentPtr &subDocument);
200
201 // ------- table -----------------
202
204 void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
206 void openTable(MWAWTable const &table);
208 void openTable(MWAWPosition const &pos, MWAWTable const &table, MWAWGraphicStyle const &style);
210 void closeTable();
212 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
214 void closeTableRow();
216 void openTableCell(MWAWCell const &cell);
218 void closeTableCell();
220 void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
221
222 // ------- section ---------------
223
225 bool canOpenSectionAddBreak() const
226 {
227 return false;
228 }
230 bool isSectionOpened() const
231 {
232 return false;
233 }
235 MWAWSection const &getSection() const;
237 bool openSection(MWAWSection const &section);
239 bool closeSection()
240 {
241 return false;
242 }
244 void insertBreak(BreakType breakType);
245
246 protected:
248 void _openPageSpan(bool sendHeaderFooters=true);
250 void _closePageSpan(bool masterPage=false);
251
252 void _startSubDocument();
253 void _endSubDocument();
254
258 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style);
259
260 void _openParagraph();
261 void _closeParagraph();
262 void _resetParagraphState(const bool isListElement=false);
263
265 void _openListElement();
267 void _closeListElement();
269 void _changeList();
274 int _getListId() const;
275
276 void _openSpan();
277 void _closeSpan();
278
279 void _flushText();
280
284 shared_ptr<MWAWGraphicListenerInternal::State> _pushParsingState();
286 void _popParsingState();
287
288 protected:
290 shared_ptr<MWAWGraphicListenerInternal::GraphicState> m_ds;
292 shared_ptr<MWAWGraphicListenerInternal::State> m_ps;
294 std::vector<shared_ptr<MWAWGraphicListenerInternal::State> > m_psStack;
296 MWAWParserState &m_parserState;
298 librevenge::RVNGDrawingInterface *m_documentInterface;
299
300 private:
301 MWAWGraphicListener(const MWAWGraphicListener &);
302 MWAWGraphicListener &operator=(const MWAWGraphicListener &);
303 };
304
305 #endif
306 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWGraphicListener::closeGroup
void closeGroup()
close a group
Definition: MWAWGraphicListener.cxx:1364
MWAWGraphicListener::insertChar
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWGraphicListener.cxx:202
MWAWGraphicListener::insertNote
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWGraphicListener.cxx:993
MWAWGraphicListener::_openParagraph
void _openParagraph()
Definition: MWAWGraphicListener.cxx:640
MWAWGraphicListener::insertTextBox
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style)
adds a textbox in given position
Definition: MWAWGraphicListener.cxx:1093
MWAWGraphicListener::openFrame
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
store the position and the style (which will be needed further to insert a textbox or a table with op...
Definition: MWAWGraphicListener.cxx:1308
MWAWGraphicListener::openLayer
bool openLayer(librevenge::RVNGString const &name)
open a layer
Definition: MWAWGraphicListener.cxx:1375
MWAWGraphicListener::openTableCell
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWGraphicListener.cxx:1273
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
libmwaw_internal.hxx
MWAWGraphicListener::_flushText
void _flushText()
Definition: MWAWGraphicListener.cxx:851
MWAWGraphicListener::openTable
void openTable(MWAWTable const &table)
open a table (using the last parameters of openFrame for the position )
Definition: MWAWGraphicListener.cxx:1169
MWAWGraphicListener::endDocument
void endDocument(bool delayed=true)
ends the actual document
Definition: MWAWGraphicListener.cxx:476
MWAWLink
a link
Definition: libmwaw_internal.hxx:380
MWAWGraphicListener::openSection
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWGraphicListener.cxx:942
MWAWGraphicListener::canOpenSectionAddBreak
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWGraphicListener.hxx:225
MWAWGraphicListener::isSubDocumentOpened
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWGraphicListener.cxx:1633
MWAWListener::Graphic
Definition: MWAWListener.hxx:56
MWAWGraphicListenerInternal
Internal and low level namespace to define the states of MWAWGraphicListener.
Definition: MWAWGraphicListener.cxx:62
MWAWGraphicListener::openMasterPage
bool openMasterPage(MWAWPageSpan &masterPage)
opens a master page
Definition: MWAWGraphicListener.cxx:527
MWAWGraphicListener::_resetParagraphState
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWGraphicListener.cxx:683
MWAWGraphicListener::insertTab
void insertTab()
adds a tab
Definition: MWAWGraphicListener.cxx:312
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
MWAWGraphicListener
This class contains the code needed to create Graphic document.
Definition: MWAWGraphicListener.hxx:59
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:173
MWAWGraphicListener::startDocument
void startDocument()
starts a new document
Definition: MWAWGraphicListener.cxx:465
MWAWGraphicListener::insertGroup
void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr subDocument)
adds a group: ie.
Definition: MWAWGraphicListener.cxx:1129
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
MWAWGraphicListener::m_documentInterface
librevenge::RVNGDrawingInterface * m_documentInterface
the document interface
Definition: MWAWGraphicListener.hxx:298
MWAWGraphicListener::closeLink
void closeLink()
close a link
Definition: MWAWGraphicListener.cxx:452
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:717
MWAWGraphicListener::insertComment
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWGraphicListener.cxx:975
MWAWGraphicListener::_openListElement
void _openListElement()
open a list level
Definition: MWAWGraphicListener.cxx:692
MWAWListener::Type
Type
the listener type
Definition: MWAWListener.hxx:56
MWAWGraphicListener::closeSection
bool closeSection()
close a section
Definition: MWAWGraphicListener.hxx:239
MWAWGraphicListener::_handleFrameParameters
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style)
adds in propList the frame parameters.
Definition: MWAWGraphicListener.cxx:1413
MWAWGraphicListener::isSectionOpened
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWGraphicListener.hxx:230
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
MWAWGraphicListener::_endSubDocument
void _endSubDocument()
Definition: MWAWGraphicListener.cxx:1647
MWAWGraphicListener::handleSubDocument
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWGraphicListener.hxx:93
MWAWGraphicListener::_pushParsingState
shared_ptr< MWAWGraphicListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWGraphicListener.cxx:1665
MWAWSubDocumentPtr
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:453
MWAWGraphicListener::MWAWGraphicListener
MWAWGraphicListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGDrawingInterface *documentInterface)
constructor
Definition: MWAWGraphicListener.cxx:177
MWAWGraphicListener::setFont
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWGraphicListener.cxx:326
MWAWGraphicListener::insertBreak
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWGraphicListener.cxx:948
MWAWGraphicListener::closeTableCell
void closeTableCell()
close a cell
Definition: MWAWGraphicListener.cxx:1290
MWAWGraphicListener::closeLayer
void closeLayer()
close a layer
Definition: MWAWGraphicListener.cxx:1402
MWAWGraphicListener::getType
Type getType() const
returns the listener type
Definition: MWAWGraphicListener.hxx:72
MWAWGraphicListener::insertUnicodeString
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: MWAWGraphicListener.cxx:283
MWAWGraphicListener::openGroup
bool openGroup(MWAWPosition const &pos)
open a group
Definition: MWAWGraphicListener.cxx:1339
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
MWAWGraphicListener::_getListId
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWGraphicListener.cxx:731
MWAWBox2< float >
MWAWGraphicListener::operator=
MWAWGraphicListener & operator=(const MWAWGraphicListener &)
MWAWGraphicListener::insertUnicode
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWGraphicListener.cxx:270
MWAWParserState
a class to define the parser state
Definition: MWAWParser.hxx:49
MWAWListener::BreakType
BreakType
the different break type
Definition: MWAWListener.hxx:58
MWAWGraphicListener::insertEOL
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWGraphicListener.cxx:293
MWAWGraphicListener::addEmptyTableCell
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1))
add empty cell
Definition: MWAWGraphicListener.cxx:1254
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:721
MWAWGraphicListener::_closePageSpan
void _closePageSpan(bool masterPage=false)
does close a page (low level)
Definition: MWAWGraphicListener.cxx:601
MWAWGraphicListener::closeMasterPage
void closeMasterPage()
close a master page
Definition: MWAWGraphicListener.hxx:116
MWAWGraphicListener::closeFrame
void closeFrame()
close a frame
Definition: MWAWGraphicListener.cxx:1330
MWAWGraphicListener::m_ds
shared_ptr< MWAWGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: MWAWGraphicListener.hxx:290
MWAWGraphicListener::m_psStack
std::vector< shared_ptr< MWAWGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWGraphicListener.hxx:294
MWAWGraphicListener::_closeListElement
void _closeListElement()
close a list level
Definition: MWAWGraphicListener.cxx:718
MWAWGraphicListener::setDocumentLanguage
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: MWAWGraphicListener.cxx:496
MWAWGraphicListener::_popParsingState
void _popParsingState()
resets the previous parsing state
Definition: MWAWGraphicListener.cxx:1673
MWAWGraphicListener::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: MWAWGraphicListener.cxx:1057
MWAWGraphicListener::handleSubDocument
void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument and modify the origin
Definition: MWAWGraphicListener.cxx:1578
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWGraphicListener::getParagraph
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWGraphicListener.cxx:367
MWAWGraphicListener::insertCharacter
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWGraphicListener.cxx:216
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:439
MWAWListener.hxx
MWAWGraphicListener::insertFooter
bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a footer
Definition: MWAWGraphicListener.cxx:908
MWAWGraphicListener::isPageSpanOpened
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWGraphicListener.cxx:515
MWAWGraphicShape
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
MWAWGraphicListener::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: MWAWGraphicListener.cxx:1223
MWAWGraphicListener::isHeaderFooterOpened
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWGraphicListener.cxx:882
MWAWGraphicListener::~MWAWGraphicListener
virtual ~MWAWGraphicListener()
destructor
Definition: MWAWGraphicListener.cxx:195
MWAWGraphicListener::m_parserState
MWAWParserState & m_parserState
the parser state
Definition: MWAWGraphicListener.hxx:296
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
MWAWGraphicListener::insertTable
void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a table in given position
Definition: MWAWGraphicListener.cxx:1144
MWAWField
a field
Definition: libmwaw_internal.hxx:361
MWAWGraphicListener::closeTableRow
void closeTableRow()
closes this row
Definition: MWAWGraphicListener.cxx:1244
MWAWGraphicListener::closeTable
void closeTable()
closes this table
Definition: MWAWGraphicListener.cxx:1209
MWAWGraphicListener::setParagraph
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWGraphicListener.cxx:356
MWAWGraphicListener::_openPageSpan
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWGraphicListener.cxx:550
MWAWGraphicListener::_openSpan
void _openSpan()
Definition: MWAWGraphicListener.cxx:805
MWAWNote
a note
Definition: libmwaw_internal.hxx:394
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
MWAWGraphicListener::isDocumentStarted
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWGraphicListener.cxx:502
MWAWGraphicListener::openLink
void openLink(MWAWLink const &link)
open a link
Definition: MWAWGraphicListener.cxx:432
MWAWGraphicListener::_closeParagraph
void _closeParagraph()
Definition: MWAWGraphicListener.cxx:661
MWAWGraphicListener::_startSubDocument
void _startSubDocument()
Definition: MWAWGraphicListener.cxx:1641
MWAWGraphicListener::_changeList
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWGraphicListener.cxx:748
MWAWGraphicListener::canWriteText
bool canWriteText() const
returns true if a text zone is opened
Definition: MWAWGraphicListener.cxx:507
MWAWGraphicListener::_closeSpan
void _closeSpan()
Definition: MWAWGraphicListener.cxx:832
MWAWGraphicListener::getSection
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWGraphicListener.cxx:935
MWAWGraphicListener::getPageSpan
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWGraphicListener.cxx:520
MWAWGraphicListener::getFont
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWGraphicListener.cxx:346
MWAWGraphicStyle.hxx
MWAWVec2< float >
MWAWGraphicListener::isParagraphOpened
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWGraphicListener.cxx:351
MWAWGraphicListener::insertHeader
bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a header
Definition: MWAWGraphicListener.cxx:887
MWAWGraphicListener::m_ps
shared_ptr< MWAWGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWGraphicListener.hxx:292
MWAWGraphicStyle::emptyStyle
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:204
MWAWGraphicListener::insertField
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWGraphicListener.cxx:375