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 
50 {
51 struct GraphicState;
52 struct State;
53 }
54 
60 {
61 public:
63  MWAWPresentationListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGPresentationInterface *documentInterface);
66 
68  Type getType() const final
69  {
70  return Presentation;
71  }
72 
74  void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata) final;
76  void setDocumentLanguage(std::string const &locale) final;
78  void startDocument() final;
80  void endDocument(bool delayed=true) final;
81 
82  // ------ general information --------
84  bool canWriteText() const final;
86  bool isDocumentStarted() const final;
87 
89  void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType);
91  void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType) final
92  {
93  handleSubDocument(MWAWVec2f(0,0), subDocument, subDocumentType);
94  }
96  bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const final;
98  bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final;
100  void closeFrame() final;
102  bool openGroup(MWAWPosition const &pos) final;
104  void closeGroup() final;
106  bool openLayer(librevenge::RVNGString const &name);
108  void closeLayer();
109 
110  // ------ page --------
112  bool openMasterPage(MWAWPageSpan &masterPage);
115  {
116  _closePageSpan(true);
117  }
119  bool isPageSpanOpened() const final;
123  MWAWPageSpan const &getPageSpan() final;
124 
125  // ------ header/footer --------
127  bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final;
129  bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final;
131  bool isHeaderFooterOpened() const final;
132 
133  // ------ text data -----------
135  void insertChar(uint8_t character) final;
138  void insertCharacter(unsigned char c) final;
144  int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1) final;
147  void insertUnicode(uint32_t character) final;
149  void insertUnicodeString(librevenge::RVNGString const &str) final;
150 
152  void insertTab() final;
154  void insertEOL(bool softBreak=false) final;
155 
156  // ------ text format -----------
158  void setFont(MWAWFont const &font) final;
160  MWAWFont const &getFont() const final;
161 
162  // ------ paragraph format -----------
164  bool isParagraphOpened() const final;
166  void setParagraph(MWAWParagraph const &paragraph) final;
168  MWAWParagraph const &getParagraph() const final;
169 
170  // ------- fields ----------------
172  void insertField(MWAWField const &field) final;
173 
174  // ------- link ----------------
176  void openLink(MWAWLink const &link) final;
178  void closeLink() final;
179 
180  // ------- subdocument -----------------
182  void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
183  MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final;
185  void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style) final;
187  void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument, MWAWGraphicStyle const &style) final;
189  void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr const &subDocument);
191  void insertSlideNote(MWAWPosition const &pos, MWAWSubDocumentPtr &subDocument);
195  void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument) final;
199  void insertComment(MWAWSubDocumentPtr &subDocument) final;
200 
201  // ------- table -----------------
202 
204  void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
206  void openTable(MWAWTable const &table) final;
208  void openTable(MWAWPosition const &pos, MWAWTable const &table, MWAWGraphicStyle const &style);
210  void closeTable() final;
212  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final;
214  void closeTableRow() final;
216  void openTableCell(MWAWCell const &cell) final;
218  void closeTableCell() final;
220  void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1)) final;
221 
222  // ------- section ---------------
223 
225  bool canOpenSectionAddBreak() const final
226  {
227  return false;
228  }
230  bool isSectionOpened() const final
231  {
232  return false;
233  }
235  MWAWSection const &getSection() const final;
237  bool openSection(MWAWSection const &section) final;
239  bool closeSection() final
240  {
241  return false;
242  }
244  void insertBreak(BreakType breakType) final;
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  std::shared_ptr<MWAWPresentationListenerInternal::State> _pushParsingState();
286  void _popParsingState();
287 
288 protected:
290  std::shared_ptr<MWAWPresentationListenerInternal::GraphicState> m_ds;
292  std::shared_ptr<MWAWPresentationListenerInternal::State> m_ps;
294  std::vector<std::shared_ptr<MWAWPresentationListenerInternal::State> > m_psStack;
298  librevenge::RVNGPresentationInterface *m_documentInterface;
299 
300 private:
303 };
304 
305 #endif
306 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
std::shared_ptr< MWAWPresentationListenerInternal::GraphicState > m_ds
the actual global state
Definition: MWAWPresentationListener.hxx:290
void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata) final
sets the documents metadata
Definition: MWAWPresentationListener.cxx:483
void _popParsingState()
resets the previous parsing state
Definition: MWAWPresentationListener.cxx:1707
This class contains code needed to write a presention document.
Definition: MWAWPresentationListener.hxx:59
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:98
Definition: MWAWDocument.hxx:56
void endDocument(bool delayed=true) final
ends the actual document
Definition: MWAWPresentationListener.cxx:463
void _openListElement()
open a list level
Definition: MWAWPresentationListener.cxx:686
void setFont(MWAWFont const &font) final
sets the font
Definition: MWAWPresentationListener.cxx:348
MWAWParserState & m_parserState
the parser state
Definition: MWAWPresentationListener.hxx:296
bool closeSection() final
close a section
Definition: MWAWPresentationListener.hxx:239
MWAWSection const & getSection() const final
returns the actual section
Definition: MWAWPresentationListener.cxx:934
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const final
returns try if a subdocument is open
Definition: MWAWPresentationListener.cxx:1666
void insertUnicodeString(librevenge::RVNGString const &str) final
adds a unicode string
Definition: MWAWPresentationListener.cxx:305
void insertEOL(bool softBreak=false) final
adds an end of line ( by default an hard one)
Definition: MWAWPresentationListener.cxx:315
void insertChar(uint8_t character) final
adds a basic character, ..
Definition: MWAWPresentationListener.cxx:224
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
void closeTable() final
closes this table
Definition: MWAWPresentationListener.cxx:1233
SubDocumentType
Definition: libmwaw_internal.hxx:188
MWAWPresentationListener & operator=(const MWAWPresentationListener &)=delete
void _openParagraph()
Definition: MWAWPresentationListener.cxx:634
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
std::vector< std::shared_ptr< MWAWPresentationListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWPresentationListener.hxx:294
bool openSection(MWAWSection const &section) final
open a section if possible
Definition: MWAWPresentationListener.cxx:940
void insertBreak(BreakType breakType) final
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWPresentationListener.cxx:946
void setParagraph(MWAWParagraph const &paragraph) final
sets the paragraph
Definition: MWAWPresentationListener.cxx:378
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:50
void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final
adds a picture with potential various representationin given position
Definition: MWAWPresentationListener.cxx:1058
Type
the listener type
Definition: MWAWListener.hxx:56
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
bool isSectionOpened() const final
returns true if a section is opened
Definition: MWAWPresentationListener.hxx:230
void _endSubDocument()
Definition: MWAWPresentationListener.cxx:1680
bool isParagraphOpened() const final
returns true if a paragraph or a list is opened
Definition: MWAWPresentationListener.cxx:373
bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final
insert a footer
Definition: MWAWPresentationListener.cxx:907
librevenge::RVNGPresentationInterface * m_documentInterface
the document interface
Definition: MWAWPresentationListener.hxx:298
void insertTab() final
adds a tab
Definition: MWAWPresentationListener.cxx:334
bool isPageSpanOpened() const final
returns true if a page is opened
Definition: MWAWPresentationListener.cxx:509
void openTable(MWAWTable const &table) final
open a table (using the last parameters of openFrame for the position )
Definition: MWAWPresentationListener.cxx:1193
bool canOpenSectionAddBreak() const final
returns true if we can add open a section, add page break, ...
Definition: MWAWPresentationListener.hxx:225
bool openLayer(librevenge::RVNGString const &name)
open a layer
Definition: MWAWPresentationListener.cxx:1399
Class to store font.
Definition: MWAWFont.hxx:43
bool isHeaderFooterOpened() const final
returns true if the header/footer is open
Definition: MWAWPresentationListener.cxx:881
void _closeSpan()
Definition: MWAWPresentationListener.cxx:831
a class to define the parser state
Definition: MWAWParser.hxx:49
BreakType
the different break type
Definition: MWAWListener.hxx:58
Internal and low level namespace to define the states of MWAWPresentationListener.
Definition: MWAWPresentationListener.cxx:62
void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument and modify the origin
Definition: MWAWPresentationListener.cxx:1610
void insertField(MWAWField const &field) final
adds a field type
Definition: MWAWPresentationListener.cxx:397
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWPresentationListener.cxx:544
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
void closeGroup() final
close a group
Definition: MWAWPresentationListener.cxx:1388
void closeFrame() final
close a frame
Definition: MWAWPresentationListener.cxx:1354
void _flushText()
Definition: MWAWPresentationListener.cxx:850
void insertUnicode(uint32_t character) final
adds an unicode character.
Definition: MWAWPresentationListener.cxx:292
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument) final
insert a note
Definition: MWAWPresentationListener.cxx:993
~MWAWPresentationListener() final
destructor
Definition: MWAWPresentationListener.cxx:217
void insertComment(MWAWSubDocumentPtr &subDocument) final
adds comment
Definition: MWAWPresentationListener.cxx:975
void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr const &subDocument)
adds a group: ie.
Definition: MWAWPresentationListener.cxx:1153
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1)) final
add empty cell
Definition: MWAWPresentationListener.cxx:1278
void _closeListElement()
close a list level
Definition: MWAWPresentationListener.cxx:712
void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a table in given position
Definition: MWAWPresentationListener.cxx:1168
void setDocumentLanguage(std::string const &locale) final
sets the documents language
Definition: MWAWPresentationListener.cxx:490
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style)
adds in propList the frame parameters.
Definition: MWAWPresentationListener.cxx:1437
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: MWAWPresentationListener.cxx:1247
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWPresentationListener.cxx:725
a class which stores section properties
Definition: MWAWSection.hxx:45
Type getType() const final
returns the listener type
Definition: MWAWPresentationListener.hxx:68
MWAWFont const & getFont() const final
returns the actual font
Definition: MWAWPresentationListener.cxx:368
void closeTableRow() final
closes this row
Definition: MWAWPresentationListener.cxx:1268
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
void closeMasterPage()
close a master page
Definition: MWAWPresentationListener.hxx:114
Definition: MWAWListener.hxx:56
void closeLayer()
close a layer
Definition: MWAWPresentationListener.cxx:1426
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
bool openMasterPage(MWAWPageSpan &masterPage)
opens a master page
Definition: MWAWPresentationListener.cxx:521
class to store the paragraph properties
Definition: MWAWParagraph.hxx:84
void openLink(MWAWLink const &link) final
open a link
Definition: MWAWPresentationListener.cxx:418
void openTableCell(MWAWCell const &cell) final
open a cell
Definition: MWAWPresentationListener.cxx:1297
void startDocument() final
starts a new document
Definition: MWAWPresentationListener.cxx:452
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWPresentationListener.cxx:741
void closeLink() final
close a link
Definition: MWAWPresentationListener.cxx:438
a field
Definition: libmwaw_internal.hxx:399
void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style) final
adds a shape picture in given position
Definition: MWAWPresentationListener.cxx:1016
bool isDocumentStarted() const final
returns true if a document is opened
Definition: MWAWPresentationListener.cxx:496
bool canWriteText() const final
returns true if a text zone is opened
Definition: MWAWPresentationListener.cxx:501
void _openSpan()
Definition: MWAWPresentationListener.cxx:802
a note
Definition: libmwaw_internal.hxx:445
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
std::shared_ptr< MWAWPresentationListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWPresentationListener.hxx:292
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final
store the position and the style (which will be needed further to insert a textbox or a table with op...
Definition: MWAWPresentationListener.cxx:1332
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:49
bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final
insert a header
Definition: MWAWPresentationListener.cxx:886
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:565
std::shared_ptr< MWAWPresentationListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWPresentationListener.cxx:1698
void _closePageSpan(bool masterPage=false)
does close a page (low level)
Definition: MWAWPresentationListener.cxx:595
void closeTableCell() final
close a cell
Definition: MWAWPresentationListener.cxx:1314
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWPresentationListener.cxx:677
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument, MWAWGraphicStyle const &style) final
adds a textbox in given position
Definition: MWAWPresentationListener.cxx:1093
void insertCharacter(unsigned char c) final
insert a character using the font converter to find the utf8 character
Definition: MWAWPresentationListener.cxx:238
MWAWPageSpan const & getPageSpan() final
returns the current page span
Definition: MWAWPresentationListener.cxx:514
void _closeParagraph()
Definition: MWAWPresentationListener.cxx:655
MWAWPresentationListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGPresentationInterface *documentInterface)
constructor
Definition: MWAWPresentationListener.cxx:207
MWAWParagraph const & getParagraph() const final
returns the actual paragraph
Definition: MWAWPresentationListener.cxx:389
void _startSubDocument()
Definition: MWAWPresentationListener.cxx:1674
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:477
void insertSlideNote(MWAWPosition const &pos, MWAWSubDocumentPtr &subDocument)
insert a slide note
Definition: MWAWPresentationListener.cxx:1129
bool openGroup(MWAWPosition const &pos) final
open a group
Definition: MWAWPresentationListener.cxx:1363

Generated for libmwaw by doxygen 1.8.14