MWAWGraphicListener.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/* libmwaw
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 MWAW_GRAPHIC_LISTENER_H
35#define MWAW_GRAPHIC_LISTENER_H
36
37#include <vector>
38
39#include <librevenge/librevenge.h>
40
41#include "libmwaw_internal.hxx"
42
43#include "MWAWGraphicStyle.hxx"
44
45#include "MWAWListener.hxx"
46
48
50{
51struct GraphicState;
52struct State;
53}
54
60{
61public:
63 MWAWGraphicListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGDrawingInterface *documentInterface);
67 MWAWGraphicListener(MWAWParserState &parserState, MWAWBox2f const &box, librevenge::RVNGDrawingInterface *documentInterface);
69 virtual ~MWAWGraphicListener();
70
72 Type getType() const
73 {
74 return Graphic;
75 }
76
78 void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata);
80 void setDocumentLanguage(std::string const &locale);
82 void startDocument();
84 void endDocument(bool delayed=true);
85
86 // ------ general information --------
88 bool canWriteText() const;
90 bool isDocumentStarted() const;
91
93 void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
96 {
97 handleSubDocument(MWAWVec2f(0,0), subDocument, subDocumentType);
98 }
100 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
104 void closeFrame();
106 bool openGroup(MWAWPosition const &pos);
108 void closeGroup();
110 bool openLayer(librevenge::RVNGString const &name);
112 void closeLayer();
113
114 // ------ page --------
116 bool openMasterPage(MWAWPageSpan &masterPage);
119 {
120 _closePageSpan(true);
121 }
123 bool isPageSpanOpened() const;
127 MWAWPageSpan const &getPageSpan();
128
129 // ------ header/footer --------
131 bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
133 bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
135 bool isHeaderFooterOpened() const;
136
137 // ------ text data -----------
139 void insertChar(uint8_t character);
142 void insertCharacter(unsigned char c);
148 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
151 void insertUnicode(uint32_t character);
153 void insertUnicodeString(librevenge::RVNGString const &str);
154
156 void insertTab();
158 void insertEOL(bool softBreak=false);
159
160 // ------ text format -----------
162 void setFont(MWAWFont const &font);
164 MWAWFont const &getFont() const;
165
166 // ------ paragraph format -----------
168 bool isParagraphOpened() const;
170 void setParagraph(MWAWParagraph const &paragraph);
172 MWAWParagraph const &getParagraph() const;
173
174 // ------- fields ----------------
176 void insertField(MWAWField const &field);
177
178 // ------- link ----------------
180 void openLink(MWAWLink const &link);
182 void closeLink();
183
184 // ------- subdocument -----------------
186 void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
189 void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style);
191 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style);
193 void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr subDocument);
197 void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
201 void insertComment(MWAWSubDocumentPtr &subDocument);
202
203 // ------- table -----------------
204
206 void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
208 void openTable(MWAWTable const &table);
210 void openTable(MWAWPosition const &pos, MWAWTable const &table, MWAWGraphicStyle const &style);
212 void closeTable();
214 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
216 void closeTableRow();
218 void openTableCell(MWAWCell const &cell);
220 void closeTableCell();
222 void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
223
224 // ------- section ---------------
225
228 {
229 return false;
230 }
232 bool isSectionOpened() const
233 {
234 return false;
235 }
237 MWAWSection const &getSection() const;
239 bool openSection(MWAWSection const &section);
242 {
243 return false;
244 }
246 void insertBreak(BreakType breakType);
247
248protected:
250 void _openPageSpan(bool sendHeaderFooters=true);
252 void _closePageSpan(bool masterPage=false);
253
254 void _startSubDocument();
255 void _endSubDocument();
256
260 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style);
261
262 void _openParagraph();
263 void _closeParagraph();
264 void _resetParagraphState(const bool isListElement=false);
265
267 void _openListElement();
269 void _closeListElement();
271 void _changeList();
276 int _getListId() const;
277
278 void _openSpan();
279 void _closeSpan();
280
281 void _flushText();
282
286 shared_ptr<MWAWGraphicListenerInternal::State> _pushParsingState();
288 void _popParsingState();
289
290protected:
292 shared_ptr<MWAWGraphicListenerInternal::GraphicState> m_ds;
294 shared_ptr<MWAWGraphicListenerInternal::State> m_ps;
296 std::vector<shared_ptr<MWAWGraphicListenerInternal::State> > m_psStack;
300 librevenge::RVNGDrawingInterface *m_documentInterface;
301
302private:
305};
306
307#endif
308// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
a structure used to define a cell and its format
Definition: MWAWCell.hxx:53
Class to store font.
Definition: MWAWFont.hxx:44
This class contains the code needed to create Graphic document.
Definition: MWAWGraphicListener.hxx:60
void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument and modify the origin
Definition: MWAWGraphicListener.cxx:1567
void closeTableCell()
close a cell
Definition: MWAWGraphicListener.cxx:1271
void setDocumentLanguage(std::string const &locale)
sets the documents language
Definition: MWAWGraphicListener.cxx:470
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWGraphicListener.cxx:860
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWGraphicListener.cxx:913
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWGraphicListener.cxx:349
MWAWGraphicListener(const MWAWGraphicListener &)
bool closeSection()
close a section
Definition: MWAWGraphicListener.hxx:241
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style)
adds in propList the frame parameters.
Definition: MWAWGraphicListener.cxx:1394
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: MWAWGraphicListener.cxx:1204
MWAWGraphicListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGDrawingInterface *documentInterface)
constructor
Definition: MWAWGraphicListener.cxx:180
void _startSubDocument()
Definition: MWAWGraphicListener.cxx:1630
void closeLayer()
close a layer
Definition: MWAWGraphicListener.cxx:1383
void _openSpan()
Definition: MWAWGraphicListener.cxx:783
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWGraphicListener.cxx:273
void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style)
adds a shape picture in given position
Definition: MWAWGraphicListener.cxx:995
void _openListElement()
open a list level
Definition: MWAWGraphicListener.cxx:666
void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata)
sets the documents metadata
Definition: MWAWGraphicListener.cxx:463
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWGraphicListener.hxx:227
void openTable(MWAWTable const &table)
open a table (using the last parameters of openFrame for the position )
Definition: MWAWGraphicListener.cxx:1150
void _endSubDocument()
Definition: MWAWGraphicListener.cxx:1636
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1))
add empty cell
Definition: MWAWGraphicListener.cxx:1235
void closeTableRow()
closes this row
Definition: MWAWGraphicListener.cxx:1225
void startDocument()
starts a new document
Definition: MWAWGraphicListener.cxx:432
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style)
adds a textbox in given position
Definition: MWAWGraphicListener.cxx:1074
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWGraphicListener.cxx:972
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
store the position and the style (which will be needed further to insert a textbox or a table with op...
Definition: MWAWGraphicListener.cxx:1289
void closeMasterPage()
close a master page
Definition: MWAWGraphicListener.hxx:118
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWGraphicListener.hxx:232
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWGraphicListener.cxx:205
void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr subDocument)
adds a group: ie.
Definition: MWAWGraphicListener.cxx:1110
bool openLayer(librevenge::RVNGString const &name)
open a layer
Definition: MWAWGraphicListener.cxx:1356
MWAWParserState & m_parserState
the parser state
Definition: MWAWGraphicListener.hxx:298
void openLink(MWAWLink const &link)
open a link
Definition: MWAWGraphicListener.cxx:399
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWGraphicListener.cxx:370
bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a header
Definition: MWAWGraphicListener.cxx:865
void closeTable()
closes this table
Definition: MWAWGraphicListener.cxx:1190
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWGraphicListener.cxx:219
shared_ptr< MWAWGraphicListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWGraphicListener.cxx:1654
Type getType() const
returns the listener type
Definition: MWAWGraphicListener.hxx:72
void _closePageSpan(bool masterPage=false)
does close a page (low level)
Definition: MWAWGraphicListener.cxx:575
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWGraphicListener.hxx:95
void _closeListElement()
close a list level
Definition: MWAWGraphicListener.cxx:692
librevenge::RVNGDrawingInterface * m_documentInterface
the document interface
Definition: MWAWGraphicListener.hxx:300
void closeLink()
close a link
Definition: MWAWGraphicListener.cxx:419
void endDocument(bool delayed=true)
ends the actual document
Definition: MWAWGraphicListener.cxx:443
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWGraphicListener.cxx:524
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWGraphicListener.cxx:954
void closeFrame()
close a frame
Definition: MWAWGraphicListener.cxx:1311
bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a footer
Definition: MWAWGraphicListener.cxx:886
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWGraphicListener.cxx:354
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWGraphicListener.cxx:657
bool openGroup(MWAWPosition const &pos)
open a group
Definition: MWAWGraphicListener.cxx:1320
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level.
Definition: MWAWGraphicListener.cxx:705
MWAWGraphicListener & operator=(const MWAWGraphicListener &)
void _flushText()
Definition: MWAWGraphicListener.cxx:829
void insertTab()
adds a tab
Definition: MWAWGraphicListener.cxx:315
shared_ptr< MWAWGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWGraphicListener.hxx:294
void _popParsingState()
resets the previous parsing state
Definition: MWAWGraphicListener.cxx:1662
void _closeParagraph()
Definition: MWAWGraphicListener.cxx:635
virtual ~MWAWGraphicListener()
destructor
Definition: MWAWGraphicListener.cxx:198
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWGraphicListener.cxx:919
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWGraphicListener.cxx:722
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWGraphicListener.cxx:329
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWGraphicListener.cxx:476
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWGraphicListener.cxx:359
void _closeSpan()
Definition: MWAWGraphicListener.cxx:810
std::vector< shared_ptr< MWAWGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWGraphicListener.hxx:296
void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a picture with potential various representationin given position
Definition: MWAWGraphicListener.cxx:1039
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWGraphicListener.cxx:1622
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWGraphicListener.cxx:489
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWGraphicListener.cxx:378
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWGraphicListener.cxx:296
void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a table in given position
Definition: MWAWGraphicListener.cxx:1125
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWGraphicListener.cxx:1254
bool canWriteText() const
returns true if a text zone is opened
Definition: MWAWGraphicListener.cxx:481
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWGraphicListener.cxx:494
void closeGroup()
close a group
Definition: MWAWGraphicListener.cxx:1345
void _openParagraph()
Definition: MWAWGraphicListener.cxx:614
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: MWAWGraphicListener.cxx:286
shared_ptr< MWAWGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: MWAWGraphicListener.hxx:292
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWGraphicListener.cxx:925
bool openMasterPage(MWAWPageSpan &masterPage)
opens a master page
Definition: MWAWGraphicListener.cxx:501
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:46
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:268
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:50
Type
the listener type
Definition: MWAWListener.hxx:56
@ Graphic
Definition: MWAWListener.hxx:56
BreakType
the different break type
Definition: MWAWListener.hxx:58
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:96
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
a class to define the parser state
Definition: MWAWParser.hxx:50
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
a class which stores section properties
Definition: MWAWSection.hxx:46
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:52
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:781
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:517
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:503
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:785
Internal and low level namespace to define the states of MWAWGraphicListener.
Definition: MWAWGraphicListener.cxx:63
SubDocumentType
Definition: libmwaw_internal.hxx:178
small class use to define a embedded object
Definition: libmwaw_internal.hxx:425
a field
Definition: libmwaw_internal.hxx:369
a note
Definition: libmwaw_internal.hxx:406

Generated on Wed Jan 19 2022 22:23:16 for libmwaw by doxygen 1.9.3