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 
60 {
61 public:
63  STOFFGraphicListener(STOFFParserState &parserState, 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();
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(STOFFGraphicStyle const &style);
170  bool isGraphicStyleDefined(librevenge::RVNGString const &name) const;
171 
172  // ------- fields ----------------
174  void insertField(STOFFField const &field);
175 
176  // ------- link ----------------
178  void openLink(STOFFLink const &link);
180  void closeLink();
181 
182  // ------- subdocument -----------------
184  void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style);
186  void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle());
188  void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
189  STOFFGraphicStyle const &style=STOFFGraphicStyle());
193  void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument);
197  void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="");
198 
199  // ------- table -----------------
200 
202  void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle());
204  void openTable(STOFFTable const &table);
206  void openTable(STOFFPosition const &pos, STOFFTable const &table);
208  void closeTable();
210  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
212  void closeTableRow();
214  void openTableCell(STOFFCell const &cell);
216  void closeTableCell();
218  void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1));
219 
220  // ------- section ---------------
221 
224  {
225  return false;
226  }
228  bool isSectionOpened() const
229  {
230  return false;
231  }
233  STOFFSection const &getSection() const;
235  bool openSection(STOFFSection const &section);
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, STOFFPosition const &pos, STOFFGraphicStyle 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<STOFFGraphicListenerInternal::State> _pushParsingState();
284  void _popParsingState();
285 
286 protected:
288  shared_ptr<STOFFGraphicListenerInternal::GraphicState> m_ds;
290  shared_ptr<STOFFGraphicListenerInternal::State> m_ps;
292  std::vector<shared_ptr<STOFFGraphicListenerInternal::State> > m_psStack;
296  librevenge::RVNGDrawingInterface *m_documentInterface;
297 
298 private:
300  STOFFGraphicListener &operator=(const STOFFGraphicListener &);
301 };
302 
303 #endif
304 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFParserState & m_parserState
the parser state
Definition: STOFFGraphicListener.hxx:294
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
bool isSectionOpened() const
returns true if a section is opened
Definition: STOFFGraphicListener.hxx:228
Type
the listener type
Definition: STOFFListener.hxx:56
std::vector< shared_ptr< STOFFGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: STOFFGraphicListener.hxx:292
void closeMasterPage()
close a master page
Definition: STOFFGraphicListener.hxx:109
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
a class to define the parser state
Definition: STOFFParser.hxx:49
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: STOFFGraphicListener.hxx:223
a note
Definition: libstaroffice_internal.hxx:390
class to store the paragraph properties
Definition: STOFFParagraph.hxx:47
bool closeSection()
close a section
Definition: STOFFGraphicListener.hxx:237
librevenge::RVNGDrawingInterface * m_documentInterface
the document interface
Definition: STOFFGraphicListener.hxx:296
SubDocumentType
Definition: libstaroffice_internal.hxx:175
shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:492
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:409
shared_ptr< STOFFGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: STOFFGraphicListener.hxx:290
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:754
Class to store font.
Definition: STOFFFont.hxx:43
shared_ptr< STOFFGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: STOFFGraphicListener.hxx:288
Type getType() const
returns the listener type
Definition: STOFFGraphicListener.hxx:68
Internal and low level namespace to define the states of STOFFGraphicListener.
Definition: STOFFGraphicListener.cxx:63
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:74
BreakType
the different break type
Definition: STOFFListener.hxx:58
This class contains a virtual interface to all listener.
Definition: STOFFListener.hxx:49
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:44
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47

Generated on Thu Mar 10 2016 10:00:11 for libstaroffice by doxygen 1.8.11