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 
61 {
62 public:
64  MWAWGraphicListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGDrawingInterface *documentInterface);
68  MWAWGraphicListener(MWAWParserState &parserState, Box2f const &box, librevenge::RVNGDrawingInterface *documentInterface);
70  virtual ~MWAWGraphicListener();
71 
73  Type getType() const
74  {
75  return Graphic;
76  }
77 
79  void setDocumentLanguage(std::string locale);
81  void startDocument();
83  void endDocument(bool delayed=true);
84 
85  // ------ general information --------
87  bool canWriteText() const;
89  bool isDocumentStarted() const;
90 
92  void handleSubDocument(Vec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
95  {
96  handleSubDocument(Vec2f(0,0), subDocument, subDocumentType);
97  }
99  bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
101  bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
103  void closeFrame();
104 
105  // ------ page --------
107  bool isPageSpanOpened() const;
111  MWAWPageSpan const &getPageSpan();
112 
113  // ------ header/footer --------
115  bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
117  bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
119  bool isHeaderFooterOpened() const;
120 
121  // ------ text data -----------
123  void insertChar(uint8_t character);
126  void insertCharacter(unsigned char c);
132  int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
135  void insertUnicode(uint32_t character);
137  void insertUnicodeString(librevenge::RVNGString const &str);
138 
140  void insertTab();
142  void insertEOL(bool softBreak=false);
143 
144  // ------ text format -----------
146  void setFont(MWAWFont const &font);
148  MWAWFont const &getFont() const;
149 
150  // ------ paragraph format -----------
152  bool isParagraphOpened() const;
154  void setParagraph(MWAWParagraph const &paragraph);
156  MWAWParagraph const &getParagraph() const;
157 
158  // ------- fields ----------------
160  void insertField(MWAWField const &field);
161 
162  // ------- link ----------------
164  void openLink(MWAWLink const &link);
166  void closeLink();
167 
168  // ------- subdocument -----------------
170  void insertPicture(MWAWPosition const &pos, const librevenge::RVNGBinaryData &binaryData,
171  std::string type="image/pict", MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
173  void insertPicture(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style);
175  void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style);
177  void insertGroup(Box2f const &bdbox, MWAWSubDocumentPtr subDocument);
181  void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
185  void insertComment(MWAWSubDocumentPtr &subDocument);
186 
187  // ------- table -----------------
188 
190  void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
192  void openTable(MWAWTable const &table);
194  void openTable(MWAWPosition const &pos, MWAWTable const &table, MWAWGraphicStyle const &style);
196  void closeTable();
198  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
200  void closeTableRow();
202  void openTableCell(MWAWCell const &cell);
204  void closeTableCell();
206  void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
207 
208  // ------- section ---------------
209 
212  {
213  return false;
214  }
216  bool isSectionOpened() const
217  {
218  return false;
219  }
221  MWAWSection const &getSection() const;
223  bool openSection(MWAWSection const &section);
226  {
227  return false;
228  }
230  void insertBreak(BreakType breakType);
231 
232 protected:
234  void _openPageSpan(bool sendHeaderFooters=true);
236  void _closePageSpan();
237 
238  void _startSubDocument();
239  void _endSubDocument();
240 
244  void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style);
245 
246  void _openParagraph();
247  void _closeParagraph();
248  void _resetParagraphState(const bool isListElement=false);
249 
251  void _openListElement();
253  void _closeListElement();
255  void _changeList();
260  int _getListId() const;
261 
262  void _openSpan();
263  void _closeSpan();
264 
265  void _flushText();
266 
270  shared_ptr<MWAWGraphicListenerInternal::State> _pushParsingState();
272  void _popParsingState();
273 
274 protected:
276  shared_ptr<MWAWGraphicListenerInternal::GraphicState> m_ds;
278  shared_ptr<MWAWGraphicListenerInternal::State> m_ps;
280  std::vector<shared_ptr<MWAWGraphicListenerInternal::State> > m_psStack;
284  librevenge::RVNGDrawingInterface *m_documentInterface;
285 
286 private:
289 };
290 
291 #endif
292 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWGraphicListener.cxx:192
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWGraphicListener.cxx:945
void _openParagraph()
Definition: MWAWGraphicListener.cxx:596
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style)
adds a textbox in given position
Definition: MWAWGraphicListener.cxx:1033
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:1249
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWGraphicListener.cxx:1214
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
void _flushText()
Definition: MWAWGraphicListener.cxx:807
void openTable(MWAWTable const &table)
open a table (using the last parameters of openFrame for the position )
Definition: MWAWGraphicListener.cxx:1110
Vec2< float > Vec2f
Vec2 of float.
Definition: libmwaw_internal.hxx:660
void endDocument(bool delayed=true)
ends the actual document
Definition: MWAWGraphicListener.cxx:466
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWGraphicListener.cxx:898
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWGraphicListener.hxx:211
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWGraphicListener.cxx:1502
Definition: MWAWListener.hxx:56
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWGraphicListener.cxx:639
void insertTab()
adds a tab
Definition: MWAWGraphicListener.cxx:302
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
This class contains the minimal code needed to write a Graphic sub document.
Definition: MWAWGraphicListener.hxx:60
SubDocumentType
Definition: libmwaw_internal.hxx:162
void startDocument()
starts a new document
Definition: MWAWGraphicListener.cxx:455
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
librevenge::RVNGDrawingInterface * m_documentInterface
the document interface
Definition: MWAWGraphicListener.hxx:284
void _closePageSpan()
does close a page (low level)
Definition: MWAWGraphicListener.cxx:568
void closeLink()
close a link
Definition: MWAWGraphicListener.cxx:442
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWGraphicListener.cxx:927
void _openListElement()
open a list level
Definition: MWAWGraphicListener.cxx:648
Type
the listener type
Definition: MWAWListener.hxx:56
bool closeSection()
close a section
Definition: MWAWGraphicListener.hxx:225
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos, MWAWGraphicStyle const &style)
adds in propList the frame parameters.
Definition: MWAWGraphicListener.cxx:1280
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWGraphicListener.hxx:216
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
void _endSubDocument()
Definition: MWAWGraphicListener.cxx:1516
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWGraphicListener.hxx:94
shared_ptr< MWAWGraphicListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWGraphicListener.cxx:1534
Vec2< int > Vec2i
Vec2 of int.
Definition: libmwaw_internal.hxx:656
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:392
MWAWGraphicListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGDrawingInterface *documentInterface)
constructor
Definition: MWAWGraphicListener.cxx:167
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWGraphicListener.cxx:316
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWGraphicListener.cxx:904
void closeTableCell()
close a cell
Definition: MWAWGraphicListener.cxx:1231
Type getType() const
returns the listener type
Definition: MWAWGraphicListener.hxx:73
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: MWAWGraphicListener.cxx:273
Class to store font.
Definition: MWAWFont.hxx:44
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWGraphicListener.cxx:687
void insertGroup(Box2f const &bdbox, MWAWSubDocumentPtr subDocument)
adds a group: ie.
Definition: MWAWGraphicListener.cxx:1069
MWAWGraphicListener & operator=(const MWAWGraphicListener &)
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWGraphicListener.cxx:260
a class to define the parser state
Definition: MWAWParser.hxx:49
BreakType
the different break type
Definition: MWAWListener.hxx:58
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWGraphicListener.cxx:283
void closeFrame()
close a frame
Definition: MWAWGraphicListener.cxx:1271
shared_ptr< MWAWGraphicListenerInternal::GraphicState > m_ds
the actual global state
Definition: MWAWGraphicListener.hxx:276
std::vector< shared_ptr< MWAWGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWGraphicListener.hxx:280
void _closeListElement()
close a list level
Definition: MWAWGraphicListener.cxx:674
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: MWAWGraphicListener.cxx:486
void _popParsingState()
resets the previous parsing state
Definition: MWAWGraphicListener.cxx:1542
void insertPicture(MWAWPosition const &pos, const librevenge::RVNGBinaryData &binaryData, std::string type="image/pict", MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a picture in given position
Definition: MWAWGraphicListener.cxx:1009
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWGraphicListener.cxx:357
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWGraphicListener.cxx:206
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:380
bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a footer
Definition: MWAWGraphicListener.cxx:864
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWGraphicListener.cxx:505
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
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:1164
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWGraphicListener.cxx:838
virtual ~MWAWGraphicListener()
destructor
Definition: MWAWGraphicListener.cxx:185
MWAWParserState & m_parserState
the parser state
Definition: MWAWGraphicListener.hxx:282
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a table in given position
Definition: MWAWGraphicListener.cxx:1084
a field
Definition: libmwaw_internal.hxx:303
void closeTableRow()
closes this row
Definition: MWAWGraphicListener.cxx:1185
void closeTable()
closes this table
Definition: MWAWGraphicListener.cxx:1150
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWGraphicListener.cxx:346
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWGraphicListener.cxx:517
void _openSpan()
Definition: MWAWGraphicListener.cxx:761
a note
Definition: libmwaw_internal.hxx:336
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:49
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWGraphicListener.cxx:492
void openLink(MWAWLink const &link)
open a link
Definition: MWAWGraphicListener.cxx:422
void _closeParagraph()
Definition: MWAWGraphicListener.cxx:617
void _startSubDocument()
Definition: MWAWGraphicListener.cxx:1510
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWGraphicListener.cxx:704
bool canWriteText() const
returns true if a text zone is opened
Definition: MWAWGraphicListener.cxx:497
void handleSubDocument(Vec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument and modify the origin
Definition: MWAWGraphicListener.cxx:1446
void _closeSpan()
Definition: MWAWGraphicListener.cxx:788
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWGraphicListener.cxx:891
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWGraphicListener.cxx:510
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWGraphicListener.cxx:336
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWGraphicListener.cxx:341
bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a header
Definition: MWAWGraphicListener.cxx:843
shared_ptr< MWAWGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWGraphicListener.hxx:278
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:203
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWGraphicListener.cxx:365
void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1, 1))
add empty cell
Definition: MWAWGraphicListener.cxx:1195

Generated on Fri Aug 8 2014 00:08:58 for libmwaw by doxygen 1.8.7