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 <libwpd/libwpd.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:
66  virtual ~MWAWGraphicListener();
67 
69  void startGraphic(Box2f const &bdbox);
71  bool endGraphic(WPXBinaryData &data, std::string &mimeType);
73  bool isDocumentStarted() const;
74 
76  void handleSubDocument(Vec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
78  bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
79 
80  // ------ general information --------
82  bool canWriteText() const;
84  Box2f const &getGraphicBdBox();
85 
86  // ------ text data -----------
88  void insertChar(uint8_t character);
91  void insertCharacter(unsigned char c);
97  int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
100  void insertUnicode(uint32_t character);
102  void insertUnicodeString(WPXString const &str);
103 
105  void insertTab();
107  void insertEOL(bool softBreak=false);
108 
109  // ------ text format -----------
111  void setFont(MWAWFont const &font);
113  MWAWFont const &getFont() const;
114 
115  // ------ paragraph format -----------
117  bool isParagraphOpened() const;
119  void setParagraph(MWAWParagraph const &paragraph);
121  MWAWParagraph const &getParagraph() const;
122 
123  // ------- fields ----------------
125  void insertField(MWAWField const &field);
126 
127  // ------- subdocument -----------------
129  void insertPicture(Box2f const &bdbox, MWAWGraphicStyle const &style,
130  const WPXBinaryData &binaryData, std::string type="image/pict");
132  void insertPicture(Box2f const &bdbox, MWAWGraphicShape const &shape,
133  MWAWGraphicStyle const &style);
135  void insertTextBox(Box2f const &bdbox, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style);
137  void insertGroup(Box2f const &bdbox, MWAWSubDocumentPtr subDocument);
138  // ------- section ---------------
140  bool canOpenSectionAddBreak() const {
141  return false;
142  }
144  bool isSectionOpened() const {
145  return false;
146  }
148  MWAWSection const &getSection() const;
150  bool openSection(MWAWSection const &section);
152  bool closeSection() {
153  return false;
154  }
156  void insertBreak(BreakType breakType);
157 
158 protected:
159  void _startSubDocument();
160  void _endSubDocument();
161 
162  void _handleFrameParameters(WPXPropertyList &propList, Box2f const &pos, MWAWGraphicStyle const &style);
163  bool openFrame();
164  void closeFrame();
165 
166 
167  void _openParagraph();
168  void _closeParagraph();
169  void _resetParagraphState(const bool isListElement=false);
170 
172  void _openListElement();
174  void _closeListElement();
176  void _changeList();
181  int _getListId() const;
182 
183  void _openSpan();
184  void _closeSpan();
185 
186  void _flushText();
187 
191  shared_ptr<MWAWGraphicListenerInternal::State> _pushParsingState();
193  void _popParsingState();
194 
195 protected:
197  shared_ptr<MWAWGraphicListenerInternal::GraphicState> m_gs;
199  shared_ptr<MWAWGraphicListenerInternal::State> m_ps;
201  std::vector<shared_ptr<MWAWGraphicListenerInternal::State> > m_psStack;
204 
205 private:
208 };
209 
210 #endif
211 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWGraphicListener.cxx:142
void _openParagraph()
Definition: MWAWGraphicListener.cxx:443
bool endGraphic(WPXBinaryData &data, std::string &mimeType)
ends the actual graphic and fill the final WPXBinaryData, ...
Definition: MWAWGraphicListener.cxx:396
void _flushText()
Definition: MWAWGraphicListener.cxx:657
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWGraphicListener.cxx:694
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWGraphicListener.hxx:140
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWGraphicListener.cxx:909
bool openFrame()
Definition: MWAWGraphicListener.cxx:791
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWGraphicListener.cxx:485
void insertTab()
adds a tab
Definition: MWAWGraphicListener.cxx:247
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 insertPicture(Box2f const &bdbox, MWAWGraphicStyle const &style, const WPXBinaryData &binaryData, std::string type="image/pict")
adds a picture in given position
Definition: MWAWGraphicListener.cxx:724
void _openListElement()
open a list level
Definition: MWAWGraphicListener.cxx:494
bool closeSection()
close a section
Definition: MWAWGraphicListener.hxx:152
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWGraphicListener.hxx:144
void _endSubDocument()
Definition: MWAWGraphicListener.cxx:923
shared_ptr< MWAWGraphicListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWGraphicListener.cxx:937
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:358
void insertTextBox(Box2f const &bdbox, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &style)
adds a textbox in given position
Definition: MWAWGraphicListener.cxx:751
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWGraphicListener.cxx:261
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWGraphicListener.cxx:700
MWAWGraphicListener(MWAWParserState &parserState)
constructor
Definition: MWAWGraphicListener.cxx:130
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWGraphicListener.cxx:533
void insertGroup(Box2f const &bdbox, MWAWSubDocumentPtr subDocument)
adds a group: ie.
Definition: MWAWGraphicListener.cxx:779
MWAWGraphicListener & operator=(const MWAWGraphicListener &)
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWGraphicListener.cxx:206
a class to define the parser state
Definition: MWAWParser.hxx:51
BreakType
the different break type
Definition: MWAWListener.hxx:52
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWGraphicListener.cxx:229
void closeFrame()
Definition: MWAWGraphicListener.cxx:805
std::vector< shared_ptr< MWAWGraphicListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWGraphicListener.hxx:201
void _closeListElement()
close a list level
Definition: MWAWGraphicListener.cxx:520
void _handleFrameParameters(WPXPropertyList &propList, Box2f const &pos, MWAWGraphicStyle const &style)
Definition: MWAWGraphicListener.cxx:816
void _popParsingState()
resets the previous parsing state
Definition: MWAWGraphicListener.cxx:945
shared_ptr< MWAWGraphicListenerInternal::GraphicState > m_gs
the actual global state
Definition: MWAWGraphicListener.hxx:197
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWGraphicListener.cxx:302
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWGraphicListener.cxx:156
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:348
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:46
virtual ~MWAWGraphicListener()
destructor
Definition: MWAWGraphicListener.cxx:135
MWAWParserState & m_parserState
the parser state
Definition: MWAWGraphicListener.hxx:203
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
a field
Definition: libmwaw_internal.hxx:286
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWGraphicListener.cxx:291
void _openSpan()
Definition: MWAWGraphicListener.cxx:615
void insertUnicodeString(WPXString const &str)
adds a unicode string
Definition: MWAWGraphicListener.cxx:219
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:46
void startGraphic(Box2f const &bdbox)
starts a new graphic
Definition: MWAWGraphicListener.cxx:375
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWGraphicListener.cxx:425
void _closeParagraph()
Definition: MWAWGraphicListener.cxx:464
void _startSubDocument()
Definition: MWAWGraphicListener.cxx:917
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWGraphicListener.cxx:550
bool canWriteText() const
returns true if a text zone is opened
Definition: MWAWGraphicListener.cxx:430
void handleSubDocument(Vec2f const &orig, MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWGraphicListener.cxx:864
void _closeSpan()
Definition: MWAWGraphicListener.cxx:640
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWGraphicListener.cxx:687
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWGraphicListener.cxx:281
Box2f const & getGraphicBdBox()
returns the graphic bdbox.
Definition: MWAWGraphicListener.cxx:435
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWGraphicListener.cxx:286
shared_ptr< MWAWGraphicListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWGraphicListener.hxx:199
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWGraphicListener.cxx:310

Generated on Tue Mar 10 2015 17:32:09 for libmwaw by doxygen 1.8.5