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
47 class MWAWGraphicShape;
48
49 namespace MWAWGraphicListenerInternal
50 {
51 struct GraphicState;
52 struct State;
53 }
54
59 class MWAWGraphicListener final : public MWAWListener
60 {
61 public:
63 MWAWGraphicListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGDrawingInterface *documentInterface);
67 MWAWGraphicListener(MWAWParserState &parserState, MWAWBox2f const &box, librevenge::RVNGDrawingInterface *documentInterface);
69 ~MWAWGraphicListener() final;
70
72 Type getType() const final
73 {
74 return Graphic;
75 }
76
78 void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata) final;
80 void setDocumentLanguage(std::string const &locale) final;
82 void startDocument() final;
84 void endDocument(bool delayed=true) final;
85
86 // ------ general information --------
88 bool canWriteText() const final;
90 bool isDocumentStarted() const final;
91
93 void handleSubDocument(MWAWVec2f const &orig, MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType);
95 void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType) final
96 {
97 handleSubDocument(MWAWVec2f(0,0), subDocument, subDocumentType);
98 }
100 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const final;
102 bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final;
104 void closeFrame() final;
106 bool openGroup(MWAWPosition const &pos) final;
108 void closeGroup() final;
110 bool openLayer(librevenge::RVNGString const &name);
112 void closeLayer();
113
114 // ------ page --------
116 bool openMasterPage(MWAWPageSpan &masterPage);
118 void closeMasterPage()
119 {
120 _closePageSpan(true);
121 }
123 bool isPageSpanOpened() const final;
127 MWAWPageSpan const &getPageSpan() final;
128
129 // ------ header/footer --------
131 bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final;
133 bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final;
135 bool isHeaderFooterOpened() const final;
136
137 // ------ text data -----------
139 void insertChar(uint8_t character) final;
142 void insertCharacter(unsigned char c) final;
148 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1) final;
151 void insertUnicode(uint32_t character) final;
153 void insertUnicodeString(librevenge::RVNGString const &str) final;
154
156 void insertTab() final;
158 void insertEOL(bool softBreak=false) final;
159
160 // ------ text format -----------
162 void setFont(MWAWFont const &font) final;
164 MWAWFont const &getFont() const final;
165
166 // ------ paragraph format -----------
168 bool isParagraphOpened() const final;
170 void setParagraph(MWAWParagraph const &paragraph) final;
172 MWAWParagraph const &getParagraph() const final;
173
174 // ------- fields ----------------
176 void insertField(MWAWField const &field) final;
177
178 // ------- link ----------------
180 void openLink(MWAWLink const &link) final;
182 void closeLink() final;
183
184 // ------- subdocument -----------------
186 void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
187 MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final;
189 void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style) final;
191 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument, MWAWGraphicStyle const &style) final;
193 void insertGroup(MWAWBox2f const &bdbox, MWAWSubDocumentPtr const &subDocument);
197 void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument) final;
201 void insertComment(MWAWSubDocumentPtr &subDocument) final;
202
203 // ------- table -----------------
204
206 void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
208 void openTable(MWAWTable const &table) final;
210 void openTable(MWAWPosition const &pos, MWAWTable const &table, MWAWGraphicStyle const &style);
212 void closeTable() final;
214 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final;
216 void closeTableRow() final;
218 void openTableCell(MWAWCell const &cell) final;
220 void closeTableCell() final;
222 void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1)) final;
223
224 // ------- section ---------------
225
227 bool canOpenSectionAddBreak() const final
228 {
229 return false;
230 }
232 bool isSectionOpened() const final
233 {
234 return false;
235 }
237 MWAWSection const &getSection() const final;
239 bool openSection(MWAWSection const &section) final;
241 bool closeSection() final
242 {
243 return false;
244 }
246 void insertBreak(BreakType breakType) final;
247
248 protected:
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 std::shared_ptr<MWAWGraphicListenerInternal::State> _pushParsingState();
288 void _popParsingState();
289
290 protected:
292 std::shared_ptr<MWAWGraphicListenerInternal::GraphicState> m_ds;
294 std::shared_ptr<MWAWGraphicListenerInternal::State> m_ps;
296 std::vector<std::shared_ptr<MWAWGraphicListenerInternal::State> > m_psStack;
298 MWAWParserState &m_parserState;
300 librevenge::RVNGDrawingInterface *m_documentInterface;
301
302 private:
303 MWAWGraphicListener(const MWAWGraphicListener &) = delete;
304 MWAWGraphicListener &operator=(const MWAWGraphicListener &) = delete;
305 };
306
307 #endif
308 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWGraphicListener::m_psStack
std::vector< std::shared_ptr< MWAWGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWGraphicListener.hxx:296
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
libmwaw_internal.hxx
MWAWLink
a link
Definition: libmwaw_internal.hxx:430
MWAWGraphicListenerInternal
Internal and low level namespace to define the states of MWAWGraphicListener.
Definition: MWAWGraphicListener.cxx:62
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
MWAWGraphicListener
This class contains the code needed to create Graphic document.
Definition: MWAWGraphicListener.hxx:59
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
MWAWGraphicListener::canOpenSectionAddBreak
bool canOpenSectionAddBreak() const final
returns true if we can add open a section, add page break, ...
Definition: MWAWGraphicListener.hxx:227
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
MWAWGraphicListener::m_documentInterface
librevenge::RVNGDrawingInterface * m_documentInterface
the document interface
Definition: MWAWGraphicListener.hxx:300
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:834
MWAWListener::Type
Type
the listener type
Definition: MWAWListener.hxx:56
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
HanMacWrdKTextInternal::getSection
Section getSection(const State &state, const long id)
Definition: HanMacWrdKText.cxx:268
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MWAWBox2< float >
MWAWGraphicListener::handleSubDocument
void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType) final
function called to add a subdocument
Definition: MWAWGraphicListener.hxx:95
MWAWParserState
a class to define the parser state
Definition: MWAWParser.hxx:49
MWAWListener::BreakType
BreakType
the different break type
Definition: MWAWListener.hxx:58
MWAWGraphicListener::m_ps
std::shared_ptr< MWAWGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWGraphicListener.hxx:294
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:838
MWAWGraphicListener::closeMasterPage
void closeMasterPage()
close a master page
Definition: MWAWGraphicListener.hxx:118
MWAWGraphicListener::closeSection
bool closeSection() final
close a section
Definition: MWAWGraphicListener.hxx:241
MWAWGraphicListener::getType
Type getType() const final
returns the listener type
Definition: MWAWGraphicListener.hxx:72
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWListener.hxx
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:547
MWAWGraphicShape
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
MWAWGraphicListener::isSectionOpened
bool isSectionOpened() const final
returns true if a section is opened
Definition: MWAWGraphicListener.hxx:232
MWAWGraphicListener::m_parserState
MWAWParserState & m_parserState
the parser state
Definition: MWAWGraphicListener.hxx:298
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:84
MWAWField
a field
Definition: libmwaw_internal.hxx:399
MWAWNote
a note
Definition: libmwaw_internal.hxx:445
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWListener
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:49
MWAWSubDocumentPtr
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:561
MWAWGraphicListener::m_ds
std::shared_ptr< MWAWGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: MWAWGraphicListener.hxx:292
MWAWGraphicStyle.hxx
MWAWVec2< float >
MWAWGraphicStyle::emptyStyle
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:304