MWAWPresentationListener.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MWAWPresentationListener.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_PRESENTATION_LISTENER_H
35 #define MWAW_PRESENTATION_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 MWAWPresentationListenerInternal
50 {
51 struct GraphicState;
52 struct State;
53 }
54
59 class MWAWPresentationListener : public MWAWListener
60 {
61 public:
63 MWAWPresentationListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGPresentationInterface *documentInterface);
65 virtual ~MWAWPresentationListener();
66
68 Type getType() const
69 {
70 return Presentation;
71 }
72
74 void setDocumentLanguage(std::string locale);
76 void startDocument();
78 void endDocument(bool delayed=true);
79
80 // ------ general information --------
82 bool canWriteText() const;
84 bool isDocumentStarted() const;
85
87 void handleSubDocument(Vec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
89 void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
90 {
91 handleSubDocument(Vec2f(0,0), subDocument, subDocumentType);
92 }
94 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
96 bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
98 void closeFrame();
100 bool openGroup(MWAWPosition const &pos);
102 void closeGroup();
104 bool openLayer(librevenge::RVNGString const &name);
106 void closeLayer();
107
108 // ------ page --------
110 bool openMasterPage(MWAWPageSpan &masterPage);
112 void closeMasterPage()
113 {
114 _closePageSpan(true);
115 }
117 bool isPageSpanOpened() const;
121 MWAWPageSpan const &getPageSpan();
122
123 // ------ header/footer --------
125 bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
127 bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
129 bool isHeaderFooterOpened() const;
130
131 // ------ text data -----------
133 void insertChar(uint8_t character);
136 void insertCharacter(unsigned char c);
142 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
145 void insertUnicode(uint32_t character);
147 void insertUnicodeString(librevenge::RVNGString const &str);
148
150 void insertTab();
152 void insertEOL(bool softBreak=false);
153
154 // ------ text format -----------
156 void setFont(MWAWFont const &font);
158 MWAWFont const &getFont() const;
159
160 // ------ paragraph format -----------
162 bool isParagraphOpened() const;
164 void setParagraph(MWAWParagraph const &paragraph);
166 MWAWParagraph const &getParagraph() const;
167
168 // ------- fields ----------------
170 void insertField(MWAWField const &field);
171
172 // ------- link ----------------
174 void openLink(MWAWLink const &link);
176 void closeLink();
177
178 // ------- subdocument -----------------
180 void insertPicture(MWAWPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
181 std::string type="image/pict", MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
183 void insertPicture(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style);
185 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style);
187 void insertGroup(Box2f const &bdbox, MWAWSubDocumentPtr subDocument);
189 void insertSlideNote(MWAWPosition const &pos, MWAWSubDocumentPtr &subDocument);
193 void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
197 void insertComment(MWAWSubDocumentPtr &subDocument);
198
199 // ------- table -----------------
200
202 void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
204 void openTable(MWAWTable const &table);
206 void openTable(MWAWPosition const &pos, MWAWTable const &table, MWAWGraphicStyle const &style);
208 void closeTable();
210 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
212 void closeTableRow();
214 void openTableCell(MWAWCell const &cell);
216 void closeTableCell();
218 void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
219
220 // ------- section ---------------
221
223 bool canOpenSectionAddBreak() const
224 {
225 return false;
226 }
228 bool isSectionOpened() const
229 {
230 return false;
231 }
233 MWAWSection const &getSection() const;
235 bool openSection(MWAWSection const &section);
237 bool closeSection()
238 {
239 return false;
240 }
242 void insertBreak(BreakType breakType);
243
244 protected:
246 void _openPageSpan(bool sendHeaderFooters=true);
248 void _closePageSpan(bool masterPage=false);
249
250 void _startSubDocument();
251 void _endSubDocument();
252
256 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style);
257
258 void _openParagraph();
259 void _closeParagraph();
260 void _resetParagraphState(const bool isListElement=false);
261
263 void _openListElement();
265 void _closeListElement();
267 void _changeList();
272 int _getListId() const;
273
274 void _openSpan();
275 void _closeSpan();
276
277 void _flushText();
278
282 shared_ptr<MWAWPresentationListenerInternal::State> _pushParsingState();
284 void _popParsingState();
285
286 protected:
288 shared_ptr<MWAWPresentationListenerInternal::GraphicState> m_ds;
290 shared_ptr<MWAWPresentationListenerInternal::State> m_ps;
292 std::vector<shared_ptr<MWAWPresentationListenerInternal::State> > m_psStack;
294 MWAWParserState &m_parserState;
296 librevenge::RVNGPresentationInterface *m_documentInterface;
297
298 private:
299 MWAWPresentationListener(const MWAWPresentationListener &);
300 MWAWPresentationListener &operator=(const MWAWPresentationListener &);
301 };
302
303 #endif
304 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWPresentationListener::endDocument
void endDocument(bool delayed=true)
ends the actual document
Definition: MWAWPresentationListener.cxx:464
MWAWPresentationListener::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: MWAWPresentationListener.cxx:1235
MWAWPresentationListener::handleSubDocument
void handleSubDocument(Vec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument and modify the origin
Definition: MWAWPresentationListener.cxx:1590
MWAWPresentationListener::closeFrame
void closeFrame()
close a frame
Definition: MWAWPresentationListener.cxx:1342
MWAWPresentationListener::closeSection
bool closeSection()
close a section
Definition: MWAWPresentationListener.hxx:237
MWAWPresentationListener::isParagraphOpened
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWPresentationListener.cxx:339
MWAWPresentationListener::canOpenSectionAddBreak
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWPresentationListener.hxx:223
MWAWPresentationListener::insertFooter
bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a footer
Definition: MWAWPresentationListener.cxx:896
MWAWPresentationListener::_popParsingState
void _popParsingState()
resets the previous parsing state
Definition: MWAWPresentationListener.cxx:1686
MWAWPresentationListener::setDocumentLanguage
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: MWAWPresentationListener.cxx:484
MWAWPresentationListener
This class contains code needed to write a presention document.
Definition: MWAWPresentationListener.hxx:59
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
libmwaw_internal.hxx
Vec2f
Vec2< float > Vec2f
Vec2 of float.
Definition: libmwaw_internal.hxx:711
MWAWPresentationListener::_openListElement
void _openListElement()
open a list level
Definition: MWAWPresentationListener.cxx:680
MWAWLink
a link
Definition: libmwaw_internal.hxx:370
Box2< float >
MWAWPresentationListener::m_parserState
MWAWParserState & m_parserState
the parser state
Definition: MWAWPresentationListener.hxx:294
MWAWPresentationListener::isSubDocumentOpened
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWPresentationListener.cxx:1645
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:163
MWAWPresentationListener::_openParagraph
void _openParagraph()
Definition: MWAWPresentationListener.cxx:628
MWAWPresentationListener::insertHeader
bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a header
Definition: MWAWPresentationListener.cxx:875
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
MWAWPresentationListener::isHeaderFooterOpened
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWPresentationListener.cxx:870
MWAWPresentationListener::closeGroup
void closeGroup()
close a group
Definition: MWAWPresentationListener.cxx:1376
MWAWPresentationListener::m_ps
shared_ptr< MWAWPresentationListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWPresentationListener.hxx:290
MWAWPresentationListener::isDocumentStarted
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWPresentationListener.cxx:490
MWAWPresentationListener::getFont
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWPresentationListener.cxx:334
MWAWPresentationListener::~MWAWPresentationListener
virtual ~MWAWPresentationListener()
destructor
Definition: MWAWPresentationListener.cxx:183
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
MWAWPresentationListener::insertTab
void insertTab()
adds a tab
Definition: MWAWPresentationListener.cxx:300
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition: libmwaw_internal.hxx:707
MWAWPresentationListener::_endSubDocument
void _endSubDocument()
Definition: MWAWPresentationListener.cxx:1659
MWAWSubDocumentPtr
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:443
MWAWPresentationListener::_pushParsingState
shared_ptr< MWAWPresentationListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWPresentationListener.cxx:1677
MWAWPresentationListener::openTableCell
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWPresentationListener.cxx:1285
MWAWPresentationListener::m_documentInterface
librevenge::RVNGPresentationInterface * m_documentInterface
the document interface
Definition: MWAWPresentationListener.hxx:296
MWAWPresentationListener::m_ds
shared_ptr< MWAWPresentationListenerInternal::GraphicState > m_ds
the actual global state
Definition: MWAWPresentationListener.hxx:288
MWAWPresentationListener::closeTableCell
void closeTableCell()
close a cell
Definition: MWAWPresentationListener.cxx:1302
MWAWPresentationListener::getPageSpan
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWPresentationListener.cxx:508
MWAWPresentationListener::openLayer
bool openLayer(librevenge::RVNGString const &name)
open a layer
Definition: MWAWPresentationListener.cxx:1387
MWAWPresentationListener::setParagraph
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWPresentationListener.cxx:344
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
MWAWPresentationListener::getType
Type getType() const
returns the listener type
Definition: MWAWPresentationListener.hxx:68
MWAWPresentationListener::_closeSpan
void _closeSpan()
Definition: MWAWPresentationListener.cxx:820
MWAWParserState
a class to define the parser state
Definition: MWAWParser.hxx:49
MWAWPresentationListener::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: MWAWPresentationListener.cxx:1320
MWAWPresentationListener::m_psStack
std::vector< shared_ptr< MWAWPresentationListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWPresentationListener.hxx:292
MWAWListener::BreakType
BreakType
the different break type
Definition: MWAWListener.hxx:58
MWAWPresentationListener::insertEOL
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWPresentationListener.cxx:281
MWAWPresentationListener::operator=
MWAWPresentationListener & operator=(const MWAWPresentationListener &)
MWAWPresentationListener::_getListId
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWPresentationListener.cxx:719
MWAWPresentationListener::openSection
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWPresentationListener.cxx:930
MWAWPresentationListenerInternal
Internal and low level namespace to define the states of MWAWPresentationListener.
Definition: MWAWPresentationListener.cxx:62
MWAWPresentationListener::insertUnicode
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWPresentationListener.cxx:258
MWAWPresentationListener::_openPageSpan
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWPresentationListener.cxx:538
MWAWPresentationListener::_flushText
void _flushText()
Definition: MWAWPresentationListener.cxx:839
MWAWPresentationListener::handleSubDocument
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWPresentationListener.hxx:89
MWAWPresentationListener::openLink
void openLink(MWAWLink const &link)
open a link
Definition: MWAWPresentationListener.cxx:420
MWAWPresentationListener::openGroup
bool openGroup(MWAWPosition const &pos)
open a group
Definition: MWAWPresentationListener.cxx:1351
MWAWPresentationListener::_closeListElement
void _closeListElement()
close a list level
Definition: MWAWPresentationListener.cxx:706
MWAWPresentationListener::insertTable
void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a table in given position
Definition: MWAWPresentationListener.cxx:1156
MWAWPresentationListener::_handleFrameParameters
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style)
adds in propList the frame parameters.
Definition: MWAWPresentationListener.cxx:1425
MWAWPresentationListener::insertComment
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWPresentationListener.cxx:963
MWAWPresentationListener::setFont
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWPresentationListener.cxx:314
MWAWPresentationListener::insertBreak
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWPresentationListener.cxx:936
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:429
MWAWPresentationListener::insertTextBox
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style)
adds a textbox in given position
Definition: MWAWPresentationListener.cxx:1081
MWAWPresentationListener::startDocument
void startDocument()
starts a new document
Definition: MWAWPresentationListener.cxx:453
MWAWListener.hxx
MWAWPresentationListener::closeMasterPage
void closeMasterPage()
close a master page
Definition: MWAWPresentationListener.hxx:112
MWAWListener::Presentation
Definition: MWAWListener.hxx:56
MWAWPresentationListener::closeLayer
void closeLayer()
close a layer
Definition: MWAWPresentationListener.cxx:1414
MWAWGraphicShape
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
MWAWPresentationListener::openMasterPage
bool openMasterPage(MWAWPageSpan &masterPage)
opens a master page
Definition: MWAWPresentationListener.cxx:515
MWAWPresentationListener::canWriteText
bool canWriteText() const
returns true if a text zone is opened
Definition: MWAWPresentationListener.cxx:495
MWAWPresentationListener::isSectionOpened
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWPresentationListener.hxx:228
MWAWPresentationListener::addEmptyTableCell
void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1, 1))
add empty cell
Definition: MWAWPresentationListener.cxx:1266
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
MWAWPresentationListener::closeLink
void closeLink()
close a link
Definition: MWAWPresentationListener.cxx:440
MWAWPresentationListener::_changeList
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWPresentationListener.cxx:736
MWAWPresentationListener::insertNote
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWPresentationListener.cxx:981
MWAWPresentationListener::openTable
void openTable(MWAWTable const &table)
open a table (using the last parameters of openFrame for the position )
Definition: MWAWPresentationListener.cxx:1181
MWAWField
a field
Definition: libmwaw_internal.hxx:351
MWAWPresentationListener::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: MWAWPresentationListener.cxx:1045
MWAWPresentationListener::insertUnicodeString
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: MWAWPresentationListener.cxx:271
MWAWPresentationListener::closeTable
void closeTable()
closes this table
Definition: MWAWPresentationListener.cxx:1221
MWAWPresentationListener::_openSpan
void _openSpan()
Definition: MWAWPresentationListener.cxx:793
MWAWNote
a note
Definition: libmwaw_internal.hxx:384
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
MWAWPresentationListener::insertCharacter
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWPresentationListener.cxx:204
Vec2< float >
MWAWPresentationListener::_closePageSpan
void _closePageSpan(bool masterPage=false)
does close a page (low level)
Definition: MWAWPresentationListener.cxx:589
MWAWPresentationListener::insertChar
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWPresentationListener.cxx:190
MWAWPresentationListener::_resetParagraphState
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWPresentationListener.cxx:671
MWAWPresentationListener::closeTableRow
void closeTableRow()
closes this row
Definition: MWAWPresentationListener.cxx:1256
MWAWPresentationListener::getSection
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWPresentationListener.cxx:923
MWAWPresentationListener::getParagraph
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWPresentationListener.cxx:355
MWAWPresentationListener::insertGroup
void insertGroup(Box2f const &bdbox, MWAWSubDocumentPtr subDocument)
adds a group: ie.
Definition: MWAWPresentationListener.cxx:1141
MWAWPresentationListener::isPageSpanOpened
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWPresentationListener.cxx:503
MWAWPresentationListener::insertField
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWPresentationListener.cxx:363
MWAWPresentationListener::_closeParagraph
void _closeParagraph()
Definition: MWAWPresentationListener.cxx:649
MWAWPresentationListener::MWAWPresentationListener
MWAWPresentationListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGPresentationInterface *documentInterface)
constructor
Definition: MWAWPresentationListener.cxx:177
MWAWGraphicStyle.hxx
MWAWPresentationListener::_startSubDocument
void _startSubDocument()
Definition: MWAWPresentationListener.cxx:1653
MWAWGraphicStyle::emptyStyle
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:204
MWAWPresentationListener::insertSlideNote
void insertSlideNote(MWAWPosition const &pos, MWAWSubDocumentPtr &subDocument)
insert a slide note
Definition: MWAWPresentationListener.cxx:1117