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
48
50{
51struct GraphicState;
52struct State;
53}
54
60{
61public:
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 virtual ~STOFFGraphicListener();
68
70 Type getType() const
71 {
72 return Graphic;
73 }
74
76 void setDocumentLanguage(std::string locale);
78 void setDocumentMetaData(const librevenge::RVNGPropertyList &list);
80 void startDocument();
82 void endDocument(bool sendDelayedSubDoc=true);
83
84 // ------ general information --------
86 bool canWriteText() const;
88 bool isDocumentStarted() const;
89
91 void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType);
93 bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const;
95 bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle());
97 void closeFrame();
99 bool openGroup(STOFFPosition const &pos);
101 void closeGroup();
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;
120 STOFFPageSpan const &getPageSpan();
121
122 // ------ header/footer --------
124 bool openHeader(librevenge::RVNGPropertyList const &extras);
126 bool openFooter(librevenge::RVNGPropertyList const &extras);
128 bool closeHeader();
130 bool closeFooter();
132 bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
134 bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
136 bool isHeaderFooterOpened() const;
137
138 // ------ text data -----------
140 void insertChar(uint8_t character);
145 void insertUnicode(uint32_t character);
147 void insertUnicodeString(librevenge::RVNGString const &str);
148
150 void insertTab();
152 void insertEOL(bool softBreak=false);
153
154 // ------ text format -----------
156 void setFont(STOFFFont const &font);
158 STOFFFont const &getFont() const;
159
160 // ------ paragraph format -----------
162 bool isParagraphOpened() const;
164 void setParagraph(STOFFParagraph const &paragraph);
166 STOFFParagraph const &getParagraph() const;
167
168 // ------ style definition -----------
170 void defineStyle(STOFFFont const &style);
172 bool isFontStyleDefined(librevenge::RVNGString const &name) const;
174 void defineStyle(STOFFGraphicStyle const &style);
176 bool isGraphicStyleDefined(librevenge::RVNGString const &name) const;
178 void defineStyle(STOFFParagraph const &style);
180 bool isParagraphStyleDefined(librevenge::RVNGString const &name) const;
181
182 // ------- fields ----------------
184 void insertField(STOFFField const &field);
185
186 // ------- link ----------------
188 void openLink(STOFFLink const &link);
190 void closeLink();
191
192 // ------- subdocument -----------------
194 void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos);
196 void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle());
198 void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
199 STOFFGraphicStyle const &style=STOFFGraphicStyle());
203 void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument);
207 void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="");
208
209 // ------- table -----------------
210
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 addCoveredTableCell(STOFFVec2i const &pos);
228 void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1));
229
230 // ------- section ---------------
231
234 {
235 return false;
236 }
238 bool isSectionOpened() const
239 {
240 return false;
241 }
243 STOFFSection const &getSection() const;
245 bool openSection(STOFFSection const &section);
248 {
249 return false;
250 }
252 void insertBreak(BreakType breakType);
253
254protected:
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 shared_ptr<STOFFGraphicListenerInternal::State> _pushParsingState();
294 void _popParsingState();
295
296protected:
298 shared_ptr<STOFFGraphicListenerInternal::GraphicState> m_ds;
300 shared_ptr<STOFFGraphicListenerInternal::State> m_ps;
302 std::vector<shared_ptr<STOFFGraphicListenerInternal::State> > m_psStack;
304 librevenge::RVNGDrawingInterface *m_drawingInterface;
306 librevenge::RVNGPresentationInterface *m_presentationInterface;
307
308private:
311};
312
313#endif
314// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
a structure used to define a cell and its format
Definition: STOFFCell.hxx:54
Class to store font.
Definition: STOFFFont.hxx:44
This class contains the code needed to create Graphic document.
Definition: STOFFGraphicListener.hxx:60
void addCoveredTableCell(STOFFVec2i const &pos)
add covered cell
Definition: STOFFGraphicListener.cxx:1358
void insertChar(uint8_t character)
adds a basic character, ..
Definition: STOFFGraphicListener.cxx:255
void _changeList()
update the list so that it corresponds to the actual level
Definition: STOFFGraphicListener.cxx:753
STOFFGraphicListener(const STOFFGraphicListener &)
std::vector< shared_ptr< STOFFGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: STOFFGraphicListener.hxx:302
void insertField(STOFFField const &field)
adds a field type
Definition: STOFFGraphicListener.cxx:378
bool openSection(STOFFSection const &section)
open a section if possible
Definition: STOFFGraphicListener.cxx:1039
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level.
Definition: STOFFGraphicListener.cxx:736
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: STOFFGraphicListener.cxx:288
STOFFParagraph const & getParagraph() const
returns the actual paragraph
Definition: STOFFGraphicListener.cxx:370
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: STOFFGraphicListener.hxx:233
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: STOFFGraphicListener.cxx:1045
bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: STOFFGraphicListener.cxx:1623
bool closeSection()
close a section
Definition: STOFFGraphicListener.hxx:247
bool isParagraphStyleDefined(librevenge::RVNGString const &name) const
check if a paragraph style with a display name is already defined
Definition: STOFFGraphicListener.cxx:247
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: STOFFGraphicListener.cxx:919
librevenge::RVNGDrawingInterface * m_drawingInterface
the drawing interface
Definition: STOFFGraphicListener.hxx:304
bool isDocumentStarted() const
returns true if a document is opened
Definition: STOFFGraphicListener.cxx:487
librevenge::RVNGPresentationInterface * m_presentationInterface
the presentation interface
Definition: STOFFGraphicListener.hxx:306
void closeLink()
close a link
Definition: STOFFGraphicListener.cxx:418
bool openHeader(librevenge::RVNGPropertyList const &extras)
open a header (interaction with STOFFPageSpan which fills the parameters for openHeader)
Definition: STOFFGraphicListener.cxx:924
void _closePageSpan(bool masterPage=false)
does close a page (low level)
Definition: STOFFGraphicListener.cxx:587
void closeTableRow()
closes this row
Definition: STOFFGraphicListener.cxx:1345
void insertTab()
adds a tab
Definition: STOFFGraphicListener.cxx:317
void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="")
adds comment
Definition: STOFFGraphicListener.cxx:1072
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false)
open a row with given height ( if h < 0.0, set min-row-height = -h )
Definition: STOFFGraphicListener.cxx:1321
void _closeParagraph()
Definition: STOFFGraphicListener.cxx:657
void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos)
adds a shape picture in given position
Definition: STOFFGraphicListener.cxx:1139
void closeFrame()
close a frame
Definition: STOFFGraphicListener.cxx:1465
void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a textbox in given position
Definition: STOFFGraphicListener.cxx:1225
bool closeHeader()
close a header
Definition: STOFFGraphicListener.cxx:962
void closeTableCell()
close a cell
Definition: STOFFGraphicListener.cxx:1422
void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a picture with potential various representationin given position
Definition: STOFFGraphicListener.cxx:1111
STOFFPageSpan const & getPageSpan()
returns the current page span
Definition: STOFFGraphicListener.cxx:505
bool closeFooter()
close a footer
Definition: STOFFGraphicListener.cxx:1015
void _endSubDocument()
Definition: STOFFGraphicListener.cxx:1637
virtual ~STOFFGraphicListener()
destructor
Definition: STOFFGraphicListener.cxx:198
bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)
insert a footer
Definition: STOFFGraphicListener.cxx:1005
Type getType() const
returns the listener type
Definition: STOFFGraphicListener.hxx:70
void _closeSpan()
Definition: STOFFGraphicListener.cxx:857
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: STOFFGraphicListener.cxx:350
void _startSubDocument()
Definition: STOFFGraphicListener.cxx:1631
void closeMasterPage()
close a master page
Definition: STOFFGraphicListener.hxx:111
bool isGraphicStyleDefined(librevenge::RVNGString const &name) const
check if a graphic style with a display name is already defined
Definition: STOFFGraphicListener.cxx:242
STOFFSection const & getSection() const
returns the actual section
Definition: STOFFGraphicListener.cxx:1033
bool isFontStyleDefined(librevenge::RVNGString const &name) const
check if a font style with a display name is already defined
Definition: STOFFGraphicListener.cxx:237
bool openMasterPage(STOFFPageSpan &masterPage)
opens a master page
Definition: STOFFGraphicListener.cxx:512
void _closeListElement()
close a list level
Definition: STOFFGraphicListener.cxx:720
void openTableCell(STOFFCell const &cell)
open a cell
Definition: STOFFGraphicListener.cxx:1402
void openTable(STOFFTable const &table)
open a table (using the last parameters of openFrame for the position )
Definition: STOFFGraphicListener.cxx:1258
STOFFFont const & getFont() const
returns the actual font
Definition: STOFFGraphicListener.cxx:345
void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument)
insert a note
Definition: STOFFGraphicListener.cxx:1090
void _popParsingState()
resets the previous parsing state
Definition: STOFFGraphicListener.cxx:1663
void _openListElement()
open a list level
Definition: STOFFGraphicListener.cxx:691
shared_ptr< STOFFGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: STOFFGraphicListener.hxx:300
void _flushText()
Definition: STOFFGraphicListener.cxx:879
shared_ptr< STOFFGraphicListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: STOFFGraphicListener.cxx:1655
void closeTable()
closes this table
Definition: STOFFGraphicListener.cxx:1304
void _openSpan()
Definition: STOFFGraphicListener.cxx:826
void closeGroup()
close a group
Definition: STOFFGraphicListener.cxx:1501
void setParagraph(STOFFParagraph const &paragraph)
sets the paragraph
Definition: STOFFGraphicListener.cxx:355
void startDocument()
starts a new document
Definition: STOFFGraphicListener.cxx:434
bool openGroup(STOFFPosition const &pos)
open a group
Definition: STOFFGraphicListener.cxx:1474
void setDocumentMetaData(const librevenge::RVNGPropertyList &list)
sets the document meta data
Definition: STOFFGraphicListener.cxx:480
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: STOFFGraphicListener.cxx:536
STOFFGraphicListener & operator=(const STOFFGraphicListener &)
void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1, 1))
add empty cell
Definition: STOFFGraphicListener.cxx:1377
bool isSectionOpened() const
returns true if a section is opened
Definition: STOFFGraphicListener.hxx:238
void openLink(STOFFLink const &link)
open a link
Definition: STOFFGraphicListener.cxx:394
void insertUnicode(uint32_t character)
insert a character using the font converter to find the utf8 character
Definition: STOFFGraphicListener.cxx:269
void _resetParagraphState(const bool isListElement=false)
Definition: STOFFGraphicListener.cxx:682
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: STOFFGraphicListener.cxx:298
void _openParagraph()
Definition: STOFFGraphicListener.cxx:634
bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)
insert a header
Definition: STOFFGraphicListener.cxx:952
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: STOFFGraphicListener.cxx:474
bool openFooter(librevenge::RVNGPropertyList const &extras)
open a footer (interaction with STOFFPageSpan which fills the parameters for openFooter)
Definition: STOFFGraphicListener.cxx:977
bool canWriteText() const
returns true if a text zone is opened
Definition: STOFFGraphicListener.cxx:492
void closeLayer()
close a layer
Definition: STOFFGraphicListener.cxx:1545
void setFont(STOFFFont const &font)
sets the font
Definition: STOFFGraphicListener.cxx:334
shared_ptr< STOFFGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: STOFFGraphicListener.hxx:298
bool isPageSpanOpened() const
returns true if a page is opened
Definition: STOFFGraphicListener.cxx:500
void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType)
function called to add a subdocument and modify the origin
Definition: STOFFGraphicListener.cxx:1570
bool openLayer(librevenge::RVNGString const &name)
open a layer
Definition: STOFFGraphicListener.cxx:1515
void endDocument(bool sendDelayedSubDoc=true)
ends the actual document
Definition: STOFFGraphicListener.cxx:451
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:1443
void defineStyle(STOFFFont const &style)
defines a font styles
Definition: STOFFGraphicListener.cxx:202
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos, STOFFGraphicStyle const &style)
adds in propList the frame parameters.
Definition: STOFFGraphicListener.cxx:1559
a structure used to define a picture shape
Definition: STOFFGraphicShape.hxx:46
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:45
This class contains a virtual interface to all listener.
Definition: STOFFListener.hxx:51
Type
the listener type
Definition: STOFFListener.hxx:57
@ Graphic
Definition: STOFFListener.hxx:57
BreakType
the different break type
Definition: STOFFListener.hxx:59
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:76
class to store the paragraph properties
Definition: STOFFParagraph.hxx:48
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: STOFFPosition.hxx:48
a class which stores section properties
Definition: STOFFSection.hxx:46
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:52
shared_ptr< STOFFListManager > STOFFListManagerPtr
a smart pointer of STOFFListManager
Definition: libstaroffice_internal.hxx:478
shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:484
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:748
Internal and low level namespace to define the states of STOFFGraphicListener.
Definition: STOFFGraphicListener.cxx:64
SubDocumentType
Definition: libstaroffice_internal.hxx:175
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:398
a field
Definition: libstaroffice_internal.hxx:353
a note
Definition: libstaroffice_internal.hxx:379

Generated on Fri Sep 30 2022 11:47:05 for libstaroffice by doxygen 1.9.5