STOFFGraphicListener.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 /* libstoff
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 STOFF_GRAPHIC_LISTENER_H
35 #define STOFF_GRAPHIC_LISTENER_H
36 
37 #include <vector>
38 
39 #include <librevenge/librevenge.h>
40 
42 
43 #include "STOFFGraphicStyle.hxx"
44 
45 #include "STOFFListener.hxx"
46 
47 class STOFFGraphicShape;
48 
50 {
51 struct GraphicState;
52 struct State;
53 }
54 
59 class STOFFGraphicListener final : public STOFFListener
60 {
61 public:
63  STOFFGraphicListener(STOFFListManagerPtr listManager, std::vector<STOFFPageSpan> const &pageList, librevenge::RVNGDrawingInterface *drawingInterface);
65  STOFFGraphicListener(STOFFListManagerPtr listManager, std::vector<STOFFPageSpan> const &pageList, librevenge::RVNGPresentationInterface *presentationInterface);
67  ~STOFFGraphicListener() final;
68 
70  Type getType() const final
71  {
72  return Graphic;
73  }
74 
76  void setDocumentLanguage(std::string locale) final;
78  void setDocumentMetaData(const librevenge::RVNGPropertyList &list) final;
80  void startDocument() final;
82  void endDocument(bool sendDelayedSubDoc=true) final;
83 
84  // ------ general information --------
86  bool canWriteText() const final;
88  bool isDocumentStarted() const final;
89 
91  void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType) final;
93  bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const final;
95  bool openFrame(STOFFFrameStyle const &frame, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
97  void closeFrame() final;
99  bool openGroup(STOFFFrameStyle const &frame) final;
101  void closeGroup() final;
103  bool openLayer(librevenge::RVNGString const &name);
105  void closeLayer();
106 
107  // ------ page --------
109  bool openMasterPage(STOFFPageSpan &masterPage);
112  {
113  _closePageSpan(true);
114  }
116  bool isPageSpanOpened() const final;
120  STOFFPageSpan const &getPageSpan() final;
121 
122  // ------ header/footer --------
124  bool openHeader(librevenge::RVNGPropertyList const &extras) final;
126  bool openFooter(librevenge::RVNGPropertyList const &extras) final;
128  bool closeHeader() final;
130  bool closeFooter() final;
132  bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) final;
134  bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) final;
136  bool isHeaderFooterOpened() const final;
137 
138  // ------ text data -----------
140  void insertChar(uint8_t character) final;
145  void insertUnicode(uint32_t character) final;
147  void insertUnicodeString(librevenge::RVNGString const &str) final;
148 
150  void insertTab() final;
152  void insertEOL(bool softBreak=false) final;
153 
154  // ------ text format -----------
156  void setFont(STOFFFont const &font) final;
158  STOFFFont const &getFont() const final;
159 
160  // ------ paragraph format -----------
162  bool isParagraphOpened() const final;
164  void setParagraph(STOFFParagraph const &paragraph) final;
166  STOFFParagraph const &getParagraph() const final;
167 
168  // ------ style definition -----------
170  void defineStyle(STOFFFont const &style) final;
172  bool isFontStyleDefined(librevenge::RVNGString const &name) const final;
174  void defineStyle(STOFFGraphicStyle const &style) final;
176  bool isGraphicStyleDefined(librevenge::RVNGString const &name) const final;
178  void defineStyle(STOFFParagraph const &style) final;
180  bool isParagraphStyleDefined(librevenge::RVNGString const &name) const final;
181 
182  // ------- fields ----------------
184  void insertField(STOFFField const &field) final;
185 
186  // ------- link ----------------
188  void openLink(STOFFLink const &link) final;
190  void closeLink() final;
191 
192  // ------- subdocument -----------------
194  void insertShape(STOFFFrameStyle const &frame, STOFFGraphicShape const &shape, STOFFGraphicStyle const &style) final;
196  void insertTextBox(STOFFFrameStyle const &frame, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
198  void insertPicture(STOFFFrameStyle const &frame, STOFFEmbeddedObject const &picture,
199  STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
201  void insertEquation(STOFFFrameStyle const &frame, librevenge::RVNGString const &equation,
202  STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
206  void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument) final;
210  void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="") final;
211 
212  // ------- table -----------------
213 
215  void openTable(STOFFTable const &table) final;
217  void openTable(STOFFFrameStyle const &frame, STOFFTable const &table);
219  void closeTable() final;
221  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final;
223  void closeTableRow() final;
225  void openTableCell(STOFFCell const &cell) final;
227  void closeTableCell() final;
229  void addCoveredTableCell(STOFFVec2i const &pos) final;
231  void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1)) final;
232 
233  // ------- section ---------------
234 
236  bool canOpenSectionAddBreak() const final
237  {
238  return false;
239  }
241  bool isSectionOpened() const final
242  {
243  return false;
244  }
246  STOFFSection const &getSection() const final;
248  bool openSection(STOFFSection const &section) final;
250  bool closeSection() final
251  {
252  return false;
253  }
255  void insertBreak(BreakType breakType) final;
256 
257 protected:
259  void _openPageSpan(bool sendHeaderFooters=true);
261  void _closePageSpan(bool masterPage=false);
262 
263  void _startSubDocument();
264  void _endSubDocument();
265 
269  void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFFrameStyle const &frame, STOFFGraphicStyle const &style);
270 
271  void _openParagraph();
272  void _closeParagraph();
273  void _resetParagraphState(const bool isListElement=false);
274 
276  void _openListElement();
278  void _closeListElement();
280  void _changeList();
285  int _getListId() const;
286 
287  void _openSpan();
288  void _closeSpan();
289 
290  void _flushText();
291 
295  std::shared_ptr<STOFFGraphicListenerInternal::State> _pushParsingState();
297  void _popParsingState();
298 
299 protected:
301  std::shared_ptr<STOFFGraphicListenerInternal::GraphicState> m_ds;
303  std::shared_ptr<STOFFGraphicListenerInternal::State> m_ps;
305  std::vector<std::shared_ptr<STOFFGraphicListenerInternal::State> > m_psStack;
307  librevenge::RVNGDrawingInterface *m_drawingInterface;
309  librevenge::RVNGPresentationInterface *m_presentationInterface;
310 
311 private:
314 };
315 
316 #endif
317 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void setDocumentMetaData(const librevenge::RVNGPropertyList &list) final
sets the document meta data
Definition: STOFFGraphicListener.cxx:518
std::shared_ptr< STOFFGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: STOFFGraphicListener.hxx:301
bool isPageSpanOpened() const final
returns true if a page is opened
Definition: STOFFGraphicListener.cxx:538
void _flushText()
Definition: STOFFGraphicListener.cxx:916
bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) final
insert a header
Definition: STOFFGraphicListener.cxx:990
bool isHeaderFooterOpened() const final
returns true if the header/footer is open
Definition: STOFFGraphicListener.cxx:956
void insertUnicode(uint32_t character) final
insert a character using the font converter to find the utf8 character
Definition: STOFFGraphicListener.cxx:305
void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument) final
insert a note
Definition: STOFFGraphicListener.cxx:1129
void insertTab() final
adds a tab
Definition: STOFFGraphicListener.cxx:353
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: STOFFGraphicListener.cxx:574
void setDocumentLanguage(std::string locale) final
sets the documents language
Definition: STOFFGraphicListener.cxx:512
Definition: STOFFDocument.hxx:42
void _closeSpan()
Definition: STOFFGraphicListener.cxx:894
bool isParagraphStyleDefined(librevenge::RVNGString const &name) const final
check if a paragraph style with a display name is already defined
Definition: STOFFGraphicListener.cxx:283
void _closePageSpan(bool masterPage=false)
does close a page (low level)
Definition: STOFFGraphicListener.cxx:625
void _openSpan()
Definition: STOFFGraphicListener.cxx:863
void startDocument() final
starts a new document
Definition: STOFFGraphicListener.cxx:472
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
void closeLink() final
close a link
Definition: STOFFGraphicListener.cxx:455
void setFont(STOFFFont const &font) final
sets the font
Definition: STOFFGraphicListener.cxx:370
void insertPicture(STOFFFrameStyle const &frame, STOFFEmbeddedObject const &picture, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final
adds a picture with potential various representationin given position
Definition: STOFFGraphicListener.cxx:1150
void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1, 1)) final
add empty cell
Definition: STOFFGraphicListener.cxx:1451
void insertField(STOFFField const &field) final
adds a field type
Definition: STOFFGraphicListener.cxx:414
void endDocument(bool sendDelayedSubDoc=true) final
ends the actual document
Definition: STOFFGraphicListener.cxx:489
Class to store a frame style.
Definition: STOFFFrameStyle.hxx:45
Type
the listener type
Definition: STOFFListener.hxx:57
librevenge::RVNGPresentationInterface * m_presentationInterface
the presentation interface
Definition: STOFFGraphicListener.hxx:309
bool closeHeader() final
close a header
Definition: STOFFGraphicListener.cxx:1000
void _changeList()
update the list so that it corresponds to the actual level
Definition: STOFFGraphicListener.cxx:790
bool openGroup(STOFFFrameStyle const &frame) final
open a group
Definition: STOFFGraphicListener.cxx:1548
bool isSectionOpened() const final
returns true if a section is opened
Definition: STOFFGraphicListener.hxx:241
void insertShape(STOFFFrameStyle const &frame, STOFFGraphicShape const &shape, STOFFGraphicStyle const &style) final
adds a shape picture in given position
Definition: STOFFGraphicListener.cxx:1212
std::shared_ptr< STOFFGraphicListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: STOFFGraphicListener.cxx:1732
void openLink(STOFFLink const &link) final
open a link
Definition: STOFFGraphicListener.cxx:430
void closeMasterPage()
close a master page
Definition: STOFFGraphicListener.hxx:111
void _closeParagraph()
Definition: STOFFGraphicListener.cxx:695
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
void closeGroup() final
close a group
Definition: STOFFGraphicListener.cxx:1575
void closeTableRow() final
closes this row
Definition: STOFFGraphicListener.cxx:1419
bool isDocumentStarted() const final
returns true if a document is opened
Definition: STOFFGraphicListener.cxx:525
Definition: STOFFListener.hxx:57
Type getType() const final
returns the listener type
Definition: STOFFGraphicListener.hxx:70
void _closeListElement()
close a list level
Definition: STOFFGraphicListener.cxx:758
void _openListElement()
open a list level
Definition: STOFFGraphicListener.cxx:729
void closeLayer()
close a layer
Definition: STOFFGraphicListener.cxx:1619
a note
Definition: libstaroffice_internal.hxx:389
void insertChar(uint8_t character) final
adds a basic character, ..
Definition: STOFFGraphicListener.cxx:291
bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) final
insert a footer
Definition: STOFFGraphicListener.cxx:1044
std::vector< std::shared_ptr< STOFFGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: STOFFGraphicListener.hxx:305
void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType) final
function called to add a subdocument and modify the origin
Definition: STOFFGraphicListener.cxx:1646
class to store the paragraph properties
Definition: STOFFParagraph.hxx:47
void _popParsingState()
resets the previous parsing state
Definition: STOFFGraphicListener.cxx:1740
void _endSubDocument()
Definition: STOFFGraphicListener.cxx:1714
bool isFontStyleDefined(librevenge::RVNGString const &name) const final
check if a font style with a display name is already defined
Definition: STOFFGraphicListener.cxx:273
void _resetParagraphState(const bool isListElement=false)
Definition: STOFFGraphicListener.cxx:720
~STOFFGraphicListener() final
destructor
Definition: STOFFGraphicListener.cxx:234
void closeFrame() final
close a frame
Definition: STOFFGraphicListener.cxx:1539
void defineStyle(STOFFFont const &style) final
defines a font styles
Definition: STOFFGraphicListener.cxx:238
std::shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:495
STOFFSection const & getSection() const final
returns the actual section
Definition: STOFFGraphicListener.cxx:1072
librevenge::RVNGDrawingInterface * m_drawingInterface
the drawing interface
Definition: STOFFGraphicListener.hxx:307
void addCoveredTableCell(STOFFVec2i const &pos) final
add covered cell
Definition: STOFFGraphicListener.cxx:1432
bool openMasterPage(STOFFPageSpan &masterPage)
opens a master page
Definition: STOFFGraphicListener.cxx:550
bool openFrame(STOFFFrameStyle const &frame, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final
store the position and the style (which will be needed further to insert a textbox or a table with op...
Definition: STOFFGraphicListener.cxx:1517
bool closeSection() final
close a section
Definition: STOFFGraphicListener.hxx:250
SubDocumentType
Definition: libstaroffice_internal.hxx:185
a class which stores section properties
Definition: STOFFSection.hxx:45
This class contains the code needed to create Graphic document.
Definition: STOFFGraphicListener.hxx:59
std::shared_ptr< STOFFGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: STOFFGraphicListener.hxx:303
a field
Definition: libstaroffice_internal.hxx:363
void setParagraph(STOFFParagraph const &paragraph) final
sets the paragraph
Definition: STOFFGraphicListener.cxx:391
bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const final
returns try if a subdocument is open
Definition: STOFFGraphicListener.cxx:1700
a structure used to define a picture shape
Definition: STOFFGraphicShape.hxx:45
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libstaroffice_internal.cxx:50
void insertUnicodeString(librevenge::RVNGString const &str) final
adds a unicode string
Definition: STOFFGraphicListener.cxx:324
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:408
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: STOFFGraphicListener.cxx:1395
bool openSection(STOFFSection const &section) final
open a section if possible
Definition: STOFFGraphicListener.cxx:1078
void insertEquation(STOFFFrameStyle const &frame, librevenge::RVNGString const &equation, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final
adds a equation given a position
Definition: STOFFGraphicListener.cxx:1178
void insertTextBox(STOFFFrameStyle const &frame, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final
adds a textbox in given position
Definition: STOFFGraphicListener.cxx:1298
void openTableCell(STOFFCell const &cell) final
open a cell
Definition: STOFFGraphicListener.cxx:1476
void openTable(STOFFTable const &table) final
open a table (using the last parameters of openFrame for the position )
Definition: STOFFGraphicListener.cxx:1331
bool canOpenSectionAddBreak() const final
returns true if we can add open a section, add page break, ...
Definition: STOFFGraphicListener.hxx:236
void _openParagraph()
Definition: STOFFGraphicListener.cxx:672
bool openLayer(librevenge::RVNGString const &name)
open a layer
Definition: STOFFGraphicListener.cxx:1589
STOFFGraphicListener(STOFFListManagerPtr listManager, std::vector< STOFFPageSpan > const &pageList, librevenge::RVNGDrawingInterface *drawingInterface)
constructor with a drawing interface
Definition: STOFFGraphicListener.cxx:214
void insertEOL(bool softBreak=false) final
adds an end of line ( by default an hard one)
Definition: STOFFGraphicListener.cxx:334
Class to store font.
Definition: STOFFFont.hxx:43
STOFFPageSpan const & getPageSpan() final
returns the current page span
Definition: STOFFGraphicListener.cxx:543
void closeTableCell() final
close a cell
Definition: STOFFGraphicListener.cxx:1496
bool canWriteText() const final
returns true if a text zone is opened
Definition: STOFFGraphicListener.cxx:530
bool openHeader(librevenge::RVNGPropertyList const &extras) final
open a header (interaction with STOFFPageSpan which fills the parameters for openHeader) ...
Definition: STOFFGraphicListener.cxx:961
Internal and low level namespace to define the states of STOFFGraphicListener.
Definition: STOFFGraphicListener.cxx:63
bool isParagraphOpened() const final
returns true if a paragraph or a list is opened
Definition: STOFFGraphicListener.cxx:386
bool openFooter(librevenge::RVNGPropertyList const &extras) final
open a footer (interaction with STOFFPageSpan which fills the parameters for openFooter) ...
Definition: STOFFGraphicListener.cxx:1015
STOFFParagraph const & getParagraph() const final
returns the actual paragraph
Definition: STOFFGraphicListener.cxx:406
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:75
void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="") final
adds comment
Definition: STOFFGraphicListener.cxx:1111
BreakType
the different break type
Definition: STOFFListener.hxx:59
bool closeFooter() final
close a footer
Definition: STOFFGraphicListener.cxx:1054
STOFFFont const & getFont() const final
returns the actual font
Definition: STOFFGraphicListener.cxx:381
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFFrameStyle const &frame, STOFFGraphicStyle const &style)
adds in propList the frame parameters.
Definition: STOFFGraphicListener.cxx:1633
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: STOFFGraphicListener.cxx:774
void closeTable() final
closes this table
Definition: STOFFGraphicListener.cxx:1378
std::shared_ptr< STOFFListManager > STOFFListManagerPtr
a smart pointer of STOFFListManager
Definition: libstaroffice_internal.hxx:489
void _startSubDocument()
Definition: STOFFGraphicListener.cxx:1708
STOFFGraphicListener & operator=(const STOFFGraphicListener &)
This class contains a virtual interface to all listener.
Definition: STOFFListener.hxx:50
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:44
void insertBreak(BreakType breakType) final
inserts a break type: ColumBreak, PageBreak, ..
Definition: STOFFGraphicListener.cxx:1084
bool isGraphicStyleDefined(librevenge::RVNGString const &name) const final
check if a graphic style with a display name is already defined
Definition: STOFFGraphicListener.cxx:278

Generated on Sat May 29 2021 22:54:03 for libstaroffice by doxygen 1.8.14