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 setDocumentMetaData(librevenge::RVNGPropertyList const &metadata);
76 void setDocumentLanguage(std::string const &locale);
78 void startDocument();
80 void endDocument(bool delayed=true);
81
82 // ------ general information --------
84 bool canWriteText() const;
86 bool isDocumentStarted() const;
87
89 void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
91 void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
92 {
93 handleSubDocument(MWAWVec2f(0,0), subDocument, subDocumentType);
94 }
96 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
98 bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
100 void closeFrame();
102 bool openGroup(MWAWPosition const &pos);
104 void closeGroup();
106 bool openLayer(librevenge::RVNGString const &name);
108 void closeLayer();
109
110 // ------ page --------
112 bool openMasterPage(MWAWPageSpan &masterPage);
114 void closeMasterPage()
115 {
116 _closePageSpan(true);
117 }
119 bool isPageSpanOpened() const;
123 MWAWPageSpan const &getPageSpan();
124
125 // ------ header/footer --------
127 bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
129 bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
131 bool isHeaderFooterOpened() const;
132
133 // ------ text data -----------
135 void insertChar(uint8_t character);
138 void insertCharacter(unsigned char c);
144 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
147 void insertUnicode(uint32_t character);
149 void insertUnicodeString(librevenge::RVNGString const &str);
150
152 void insertTab();
154 void insertEOL(bool softBreak=false);
155
156 // ------ text format -----------
158 void setFont(MWAWFont const &font);
160 MWAWFont const &getFont() const;
161
162 // ------ paragraph format -----------
164 bool isParagraphOpened() const;
166 void setParagraph(MWAWParagraph const &paragraph);
168 MWAWParagraph const &getParagraph() const;
169
170 // ------- fields ----------------
172 void insertField(MWAWField const &field);
173
174 // ------- link ----------------
176 void openLink(MWAWLink const &link);
178 void closeLink();
179
180 // ------- subdocument -----------------
182 void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
183 MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
185 void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style);
187 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style);
189 void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr subDocument);
191 void insertSlideNote(MWAWPosition const &pos, 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<MWAWPresentationListenerInternal::State> _pushParsingState();
286 void _popParsingState();
287
288 protected:
290 shared_ptr<MWAWPresentationListenerInternal::GraphicState> m_ds;
292 shared_ptr<MWAWPresentationListenerInternal::State> m_ps;
294 std::vector<shared_ptr<MWAWPresentationListenerInternal::State> > m_psStack;
296 MWAWParserState &m_parserState;
298 librevenge::RVNGPresentationInterface *m_documentInterface;
299
300 private:
301 MWAWPresentationListener(const MWAWPresentationListener &);
302 MWAWPresentationListener &operator=(const MWAWPresentationListener &);
303 };
304
305 #endif
306 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWPresentationListener::closeSection
bool closeSection()
close a section
Definition: MWAWPresentationListener.hxx:239
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
MWAWLink
a link
Definition: libmwaw_internal.hxx:406
MWAWPresentationListener::m_parserState
MWAWParserState & m_parserState
the parser state
Definition: MWAWPresentationListener.hxx:296
MWAWPresentationListener::canOpenSectionAddBreak
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWPresentationListener.hxx:225
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:192
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:795
MWAWPresentationListener::m_ps
shared_ptr< MWAWPresentationListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWPresentationListener.hxx:292
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
MWAWSubDocumentPtr
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:531
MWAWPresentationListener::m_documentInterface
librevenge::RVNGPresentationInterface * m_documentInterface
the document interface
Definition: MWAWPresentationListener.hxx:298
MWAWPresentationListener::m_ds
shared_ptr< MWAWPresentationListenerInternal::GraphicState > m_ds
the actual global state
Definition: MWAWPresentationListener.hxx:290
HanMacWrdKTextInternal::getSection
Section getSection(const State &state, const long id)
Definition: HanMacWrdKText.cxx:249
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MWAWBox2< float >
MWAWParserState
a class to define the parser state
Definition: MWAWParser.hxx:49
MWAWPresentationListener::m_psStack
std::vector< shared_ptr< MWAWPresentationListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWPresentationListener.hxx:294
MWAWListener::BreakType
BreakType
the different break type
Definition: MWAWListener.hxx:58
MWAWPresentationListenerInternal
Internal and low level namespace to define the states of MWAWPresentationListener.
Definition: MWAWPresentationListener.cxx:62
MWAWPresentationListener::getType
Type getType() const
returns the listener type
Definition: MWAWPresentationListener.hxx:68
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:799
MWAWPresentationListener::handleSubDocument
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWPresentationListener.hxx:91
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:439
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:517
MWAWListener.hxx
MWAWPresentationListener::closeMasterPage
void closeMasterPage()
close a master page
Definition: MWAWPresentationListener.hxx:114
MWAWGraphicShape
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:81
MWAWField
a field
Definition: libmwaw_internal.hxx:383
MWAWNote
a note
Definition: libmwaw_internal.hxx:420
MWAWPresentationListener::isSectionOpened
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWPresentationListener.hxx:230
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
MWAWGraphicStyle.hxx
MWAWVec2< float >
MWAWGraphicStyle::emptyStyle
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:268