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 
49 namespace STOFFGraphicListenerInternal
50 {
51 struct GraphicState;
52 struct State;
53 }
54 
60 {
61 public:
63  STOFFGraphicListener(STOFFListManagerPtr listManager, std::vector<STOFFPageSpan> const &pageList, librevenge::RVNGDrawingInterface *documentInterface);
65  virtual ~STOFFGraphicListener();
66 
68  Type getType() const
69  {
70  return Graphic;
71  }
72 
74  void setDocumentLanguage(std::string locale);
76  void setDocumentMetaData(const librevenge::RVNGPropertyList &list);
78  void startDocument();
80  void endDocument(bool sendDelayedSubDoc=true);
81 
82  // ------ general information --------
84  bool canWriteText() const;
86  bool isDocumentStarted() const;
87 
89  void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType);
91  bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const;
93  bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle());
95  void closeFrame();
97  bool openGroup(STOFFPosition const &pos);
99  void closeGroup();
101  bool openLayer(librevenge::RVNGString const &name);
103  void closeLayer();
104 
105  // ------ page --------
107  bool openMasterPage(STOFFPageSpan &masterPage);
110  {
111  _closePageSpan(true);
112  }
114  bool isPageSpanOpened() const;
118  STOFFPageSpan const &getPageSpan();
119 
120  // ------ header/footer --------
122  bool openHeader(librevenge::RVNGPropertyList const &extras);
124  bool openFooter(librevenge::RVNGPropertyList const &extras);
126  bool closeHeader();
128  bool closeFooter();
130  bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
132  bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
134  bool isHeaderFooterOpened() const;
135 
136  // ------ text data -----------
138  void insertChar(uint8_t character);
143  void insertUnicode(uint32_t character);
145  void insertUnicodeString(librevenge::RVNGString const &str);
146 
148  void insertTab();
150  void insertEOL(bool softBreak=false);
151 
152  // ------ text format -----------
154  void setFont(STOFFFont const &font);
156  STOFFFont const &getFont() const;
157 
158  // ------ paragraph format -----------
160  bool isParagraphOpened() const;
162  void setParagraph(STOFFParagraph const &paragraph);
164  STOFFParagraph const &getParagraph() const;
165 
166  // ------ style definition -----------
168  void defineStyle(STOFFFont const &style);
170  bool isFontStyleDefined(librevenge::RVNGString const &name) const;
172  void defineStyle(STOFFGraphicStyle const &style);
174  bool isGraphicStyleDefined(librevenge::RVNGString const &name) const;
176  void defineStyle(STOFFParagraph const &style);
178  bool isParagraphStyleDefined(librevenge::RVNGString const &name) const;
179 
180  // ------- fields ----------------
182  void insertField(STOFFField const &field);
183 
184  // ------- link ----------------
186  void openLink(STOFFLink const &link);
188  void closeLink();
189 
190  // ------- subdocument -----------------
192  void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos);
194  void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle());
196  void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
197  STOFFGraphicStyle const &style=STOFFGraphicStyle());
201  void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument);
205  void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="");
206 
207  // ------- table -----------------
208 
210  void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle());
212  void openTable(STOFFTable const &table);
214  void openTable(STOFFPosition const &pos, STOFFTable const &table);
216  void closeTable();
218  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
220  void closeTableRow();
222  void openTableCell(STOFFCell const &cell);
224  void closeTableCell();
226  void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1));
227 
228  // ------- section ---------------
229 
232  {
233  return false;
234  }
236  bool isSectionOpened() const
237  {
238  return false;
239  }
241  STOFFSection const &getSection() const;
243  bool openSection(STOFFSection const &section);
246  {
247  return false;
248  }
250  void insertBreak(BreakType breakType);
251 
252 protected:
254  void _openPageSpan(bool sendHeaderFooters=true);
256  void _closePageSpan(bool masterPage=false);
257 
258  void _startSubDocument();
259  void _endSubDocument();
260 
264  void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos, STOFFGraphicStyle const &style);
265 
266  void _openParagraph();
267  void _closeParagraph();
268  void _resetParagraphState(const bool isListElement=false);
269 
271  void _openListElement();
273  void _closeListElement();
275  void _changeList();
280  int _getListId() const;
281 
282  void _openSpan();
283  void _closeSpan();
284 
285  void _flushText();
286 
290  shared_ptr<STOFFGraphicListenerInternal::State> _pushParsingState();
292  void _popParsingState();
293 
294 protected:
296  shared_ptr<STOFFGraphicListenerInternal::GraphicState> m_ds;
298  shared_ptr<STOFFGraphicListenerInternal::State> m_ps;
300  std::vector<shared_ptr<STOFFGraphicListenerInternal::State> > m_psStack;
302  librevenge::RVNGDrawingInterface *m_documentInterface;
303 
304 private:
307 };
308 
309 #endif
310 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void closeFrame()
close a frame
Definition: STOFFGraphicListener.cxx:1287
STOFFSection const & getSection() const
returns the actual section
Definition: STOFFGraphicListener.cxx:917
void _flushText()
Definition: STOFFGraphicListener.cxx:784
shared_ptr< STOFFGraphicListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: STOFFGraphicListener.cxx:1465
bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: STOFFGraphicListener.cxx:1433
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: STOFFGraphicListener.cxx:488
bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)
insert a footer
Definition: STOFFGraphicListener.cxx:892
void _closeSpan()
Definition: STOFFGraphicListener.cxx:765
bool closeFooter()
close a footer
Definition: STOFFGraphicListener.cxx:902
void _closePageSpan(bool masterPage=false)
does close a page (low level)
Definition: STOFFGraphicListener.cxx:535
void _openSpan()
Definition: STOFFGraphicListener.cxx:738
bool openSection(STOFFSection const &section)
open a section if possible
Definition: STOFFGraphicListener.cxx:923
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a table in given position
Definition: STOFFGraphicListener.cxx:1098
bool isDocumentStarted() const
returns true if a document is opened
Definition: STOFFGraphicListener.cxx:442
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: STOFFGraphicListener.cxx:278
void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument)
insert a note
Definition: STOFFGraphicListener.cxx:974
bool isSectionOpened() const
returns true if a section is opened
Definition: STOFFGraphicListener.hxx:236
void endDocument(bool sendDelayedSubDoc=true)
ends the actual document
Definition: STOFFGraphicListener.cxx:409
void setFont(STOFFFont const &font)
sets the font
Definition: STOFFGraphicListener.cxx:308
Type
the listener type
Definition: STOFFListener.hxx:57
void _changeList()
update the list so that it corresponds to the actual level
Definition: STOFFGraphicListener.cxx:681
std::vector< shared_ptr< STOFFGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: STOFFGraphicListener.hxx:300
void insertUnicode(uint32_t character)
insert a character using the font converter to find the utf8 character
Definition: STOFFGraphicListener.cxx:249
bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)
insert a header
Definition: STOFFGraphicListener.cxx:845
STOFFPageSpan const & getPageSpan()
returns the current page span
Definition: STOFFGraphicListener.cxx:460
bool isParagraphStyleDefined(librevenge::RVNGString const &name) const
check if a paragraph style with a display name is already defined
Definition: STOFFGraphicListener.cxx:227
void closeTableCell()
close a cell
Definition: STOFFGraphicListener.cxx:1247
bool openFooter(librevenge::RVNGPropertyList const &extras)
open a footer (interaction with STOFFPageSpan which fills the parameters for openFooter) ...
Definition: STOFFGraphicListener.cxx:867
void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a picture with potential various representationin given position
Definition: STOFFGraphicListener.cxx:995
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: STOFFGraphicListener.cxx:929
void closeMasterPage()
close a master page
Definition: STOFFGraphicListener.hxx:109
bool isFontStyleDefined(librevenge::RVNGString const &name) const
check if a font style with a display name is already defined
Definition: STOFFGraphicListener.cxx:217
void _closeParagraph()
Definition: STOFFGraphicListener.cxx:594
void startDocument()
starts a new document
Definition: STOFFGraphicListener.cxx:398
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
virtual ~STOFFGraphicListener()
destructor
Definition: STOFFGraphicListener.cxx:192
void defineStyle(STOFFFont const &style)
defines a font styles
Definition: STOFFGraphicListener.cxx:196
void openLink(STOFFLink const &link)
open a link
Definition: STOFFGraphicListener.cxx:365
void openTableCell(STOFFCell const &cell)
open a cell
Definition: STOFFGraphicListener.cxx:1230
bool closeHeader()
close a header
Definition: STOFFGraphicListener.cxx:855
Definition: STOFFListener.hxx:57
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: STOFFGraphicListener.hxx:231
void _closeListElement()
close a list level
Definition: STOFFGraphicListener.cxx:651
void _openListElement()
open a list level
Definition: STOFFGraphicListener.cxx:625
void closeLayer()
close a layer
Definition: STOFFGraphicListener.cxx:1358
a note
Definition: libstaroffice_internal.hxx:379
class to store the paragraph properties
Definition: STOFFParagraph.hxx:47
void _popParsingState()
resets the previous parsing state
Definition: STOFFGraphicListener.cxx:1473
void _endSubDocument()
Definition: STOFFGraphicListener.cxx:1447
STOFFFont const & getFont() const
returns the actual font
Definition: STOFFGraphicListener.cxx:319
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false)
open a row with given height ( if h &lt; 0.0, set min-row-height = -h )
Definition: STOFFGraphicListener.cxx:1180
bool closeSection()
close a section
Definition: STOFFGraphicListener.hxx:245
void _resetParagraphState(const bool isListElement=false)
Definition: STOFFGraphicListener.cxx:616
void setParagraph(STOFFParagraph const &paragraph)
sets the paragraph
Definition: STOFFGraphicListener.cxx:329
STOFFGraphicListener(STOFFListManagerPtr listManager, std::vector< STOFFPageSpan > const &pageList, librevenge::RVNGDrawingInterface *documentInterface)
constructor
Definition: STOFFGraphicListener.cxx:186
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: STOFFGraphicListener.cxx:268
librevenge::RVNGDrawingInterface * m_documentInterface
the document interface
Definition: STOFFGraphicListener.hxx:302
shared_ptr< STOFFListManager > STOFFListManagerPtr
a smart pointer of STOFFListManager
Definition: libstaroffice_internal.hxx:478
void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1, 1))
add empty cell
Definition: STOFFGraphicListener.cxx:1211
void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType)
function called to add a subdocument and modify the origin
Definition: STOFFGraphicListener.cxx:1380
bool canWriteText() const
returns true if a text zone is opened
Definition: STOFFGraphicListener.cxx:447
bool openMasterPage(STOFFPageSpan &masterPage)
opens a master page
Definition: STOFFGraphicListener.cxx:467
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: STOFFGraphicListener.cxx:429
bool openHeader(librevenge::RVNGPropertyList const &extras)
open a header (interaction with STOFFPageSpan which fills the parameters for openHeader) ...
Definition: STOFFGraphicListener.cxx:820
void insertTab()
adds a tab
Definition: STOFFGraphicListener.cxx:294
SubDocumentType
Definition: libstaroffice_internal.hxx:175
shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:484
a class which stores section properties
Definition: STOFFSection.hxx:45
This class contains the code needed to create Graphic document.
Definition: STOFFGraphicListener.hxx:59
a field
Definition: libstaroffice_internal.hxx:353
a structure used to define a picture shape
Definition: STOFFGraphicShape.hxx:45
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:398
bool isGraphicStyleDefined(librevenge::RVNGString const &name) const
check if a graphic style with a display name is already defined
Definition: STOFFGraphicListener.cxx:222
bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle())
store the position and the style (which will be needed further to insert a textbox or a table with op...
Definition: STOFFGraphicListener.cxx:1265
shared_ptr< STOFFGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: STOFFGraphicListener.hxx:298
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:748
void _openParagraph()
Definition: STOFFGraphicListener.cxx:574
bool openLayer(librevenge::RVNGString const &name)
open a layer
Definition: STOFFGraphicListener.cxx:1331
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: STOFFGraphicListener.cxx:324
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: STOFFGraphicListener.cxx:664
Class to store font.
Definition: STOFFFont.hxx:43
shared_ptr< STOFFGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: STOFFGraphicListener.hxx:296
void closeLink()
close a link
Definition: STOFFGraphicListener.cxx:385
Type getType() const
returns the listener type
Definition: STOFFGraphicListener.hxx:68
void closeGroup()
close a group
Definition: STOFFGraphicListener.cxx:1320
void insertField(STOFFField const &field)
adds a field type
Definition: STOFFGraphicListener.cxx:352
bool isPageSpanOpened() const
returns true if a page is opened
Definition: STOFFGraphicListener.cxx:455
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: STOFFGraphicListener.cxx:815
void openTable(STOFFTable const &table)
open a table (using the last parameters of openFrame for the position )
Definition: STOFFGraphicListener.cxx:1123
void insertChar(uint8_t character)
adds a basic character, ..
Definition: STOFFGraphicListener.cxx:235
void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a textbox in given position
Definition: STOFFGraphicListener.cxx:1072
void setDocumentMetaData(const librevenge::RVNGPropertyList &list)
sets the document meta data
Definition: STOFFGraphicListener.cxx:435
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:75
void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos)
adds a shape picture in given position
Definition: STOFFGraphicListener.cxx:1017
BreakType
the different break type
Definition: STOFFListener.hxx:59
void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="")
adds comment
Definition: STOFFGraphicListener.cxx:956
void _startSubDocument()
Definition: STOFFGraphicListener.cxx:1441
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos, STOFFGraphicStyle const &style)
adds in propList the frame parameters.
Definition: STOFFGraphicListener.cxx:1369
bool openGroup(STOFFPosition const &pos)
open a group
Definition: STOFFGraphicListener.cxx:1296
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
STOFFParagraph const & getParagraph() const
returns the actual paragraph
Definition: STOFFGraphicListener.cxx:344
void closeTableRow()
closes this row
Definition: STOFFGraphicListener.cxx:1201
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47
void closeTable()
closes this table
Definition: STOFFGraphicListener.cxx:1166

Generated on Wed Feb 22 2017 17:25:04 for libstaroffice by doxygen 1.8.5