STOFFGraphicListener.hxx Source File documentation

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
41 #include "libstaroffice_internal.hxx"
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
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(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
97 void closeFrame() final;
99 bool openGroup(STOFFPosition const &pos) final;
101 void closeGroup() final;
103 bool openLayer(librevenge::RVNGString const &name);
105 void closeLayer();
106
107 // ------ page --------
109 bool openMasterPage(STOFFPageSpan &masterPage);
111 void closeMasterPage()
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(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos) final;
196 void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
198 void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
199 STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
203 void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument) final;
207 void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="") final;
208
209 // ------- table -----------------
210
212 void openTable(STOFFTable const &table) final;
214 void openTable(STOFFPosition const &pos, STOFFTable const &table);
216 void closeTable() final;
218 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final;
220 void closeTableRow() final;
222 void openTableCell(STOFFCell const &cell) final;
224 void closeTableCell() final;
226 void addCoveredTableCell(STOFFVec2i const &pos) final;
228 void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1)) final;
229
230 // ------- section ---------------
231
233 bool canOpenSectionAddBreak() const final
234 {
235 return false;
236 }
238 bool isSectionOpened() const final
239 {
240 return false;
241 }
243 STOFFSection const &getSection() const final;
245 bool openSection(STOFFSection const &section) final;
247 bool closeSection() final
248 {
249 return false;
250 }
252 void insertBreak(BreakType breakType) final;
253
254 protected:
256 void _openPageSpan(bool sendHeaderFooters=true);
258 void _closePageSpan(bool masterPage=false);
259
260 void _startSubDocument();
261 void _endSubDocument();
262
266 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos, STOFFGraphicStyle const &style);
267
268 void _openParagraph();
269 void _closeParagraph();
270 void _resetParagraphState(const bool isListElement=false);
271
273 void _openListElement();
275 void _closeListElement();
277 void _changeList();
282 int _getListId() const;
283
284 void _openSpan();
285 void _closeSpan();
286
287 void _flushText();
288
292 std::shared_ptr<STOFFGraphicListenerInternal::State> _pushParsingState();
294 void _popParsingState();
295
296 protected:
298 std::shared_ptr<STOFFGraphicListenerInternal::GraphicState> m_ds;
300 std::shared_ptr<STOFFGraphicListenerInternal::State> m_ps;
302 std::vector<std::shared_ptr<STOFFGraphicListenerInternal::State> > m_psStack;
304 librevenge::RVNGDrawingInterface *m_drawingInterface;
306 librevenge::RVNGPresentationInterface *m_presentationInterface;
307
308 private:
309 STOFFGraphicListener(const STOFFGraphicListener &);
310 STOFFGraphicListener &operator=(const STOFFGraphicListener &);
311 };
312
313 #endif
314 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFGraphicListener::m_ds
std::shared_ptr< STOFFGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: STOFFGraphicListener.hxx:298
STOFFCell
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
STOFFVec2< int >
STOFFListener::Type
Type
the listener type
Definition: STOFFListener.hxx:57
STOFFGraphicListener::m_presentationInterface
librevenge::RVNGPresentationInterface * m_presentationInterface
the presentation interface
Definition: STOFFGraphicListener.hxx:306
STOFFGraphicListener::isSectionOpened
bool isSectionOpened() const final
returns true if a section is opened
Definition: STOFFGraphicListener.hxx:238
STOFFLink
a link
Definition: libstaroffice_internal.hxx:375
STOFFGraphicListener::closeMasterPage
void closeMasterPage()
close a master page
Definition: STOFFGraphicListener.hxx:111
STOFFTable
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
STOFFGraphicListener::getType
Type getType() const final
returns the listener type
Definition: STOFFGraphicListener.hxx:70
STOFFNote
a note
Definition: libstaroffice_internal.hxx:389
STOFFGraphicListener::m_psStack
std::vector< std::shared_ptr< STOFFGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: STOFFGraphicListener.hxx:302
STOFFParagraph
class to store the paragraph properties
Definition: STOFFParagraph.hxx:47
STOFFSubDocumentPtr
std::shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:494
STOFFGraphicListener::m_drawingInterface
librevenge::RVNGDrawingInterface * m_drawingInterface
the drawing interface
Definition: STOFFGraphicListener.hxx:304
STOFFGraphicListener::closeSection
bool closeSection() final
close a section
Definition: STOFFGraphicListener.hxx:247
libstoff::SubDocumentType
SubDocumentType
Definition: libstaroffice_internal.hxx:185
STOFFSection
a class which stores section properties
Definition: STOFFSection.hxx:45
STOFFGraphicListener
This class contains the code needed to create Graphic document.
Definition: STOFFGraphicListener.hxx:59
STOFFGraphicListener::m_ps
std::shared_ptr< STOFFGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: STOFFGraphicListener.hxx:300
STOFFField
a field
Definition: libstaroffice_internal.hxx:363
STOFFGraphicShape
a structure used to define a picture shape
Definition: STOFFGraphicShape.hxx:45
STOFFEmbeddedObject
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:408
STOFFGraphicStyle.hxx
libstaroffice_internal.hxx
STOFFGraphicListener::canOpenSectionAddBreak
bool canOpenSectionAddBreak() const final
returns true if we can add open a section, add page break, ...
Definition: STOFFGraphicListener.hxx:233
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:762
STOFFFont
Class to store font.
Definition: STOFFFont.hxx:43
STOFFGraphicListenerInternal
Internal and low level namespace to define the states of STOFFGraphicListener.
Definition: STOFFGraphicListener.cxx:63
STOFFPageSpan
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:75
STOFFListener::BreakType
BreakType
the different break type
Definition: STOFFListener.hxx:59
STOFFListManagerPtr
std::shared_ptr< STOFFListManager > STOFFListManagerPtr
a smart pointer of STOFFListManager
Definition: libstaroffice_internal.hxx:488
STOFFListener.hxx
STOFFListener
This class contains a virtual interface to all listener.
Definition: STOFFListener.hxx:50
STOFFGraphicStyle
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:44
STOFFPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47