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:

Generated on Sat Apr 26 2014 04:35:18 for libmwaw by doxygen 1.8.3.1