MWAWContentListener.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_CONTENT_LISTENER_H
35 #define MWAW_CONTENT_LISTENER_H
36 
37 #include <vector>
38 
39 #include <libwpd/libwpd.h>
40 
41 #include "libmwaw_internal.hxx"
42 
43 class WPXBinaryData;
44 class WPXDocumentInterface;
45 class WPXString;
46 class WPXPropertyListVector;
47 
48 class MWAWCell;
49 
50 namespace MWAWContentListenerInternal
51 {
52 struct DocumentState;
53 struct State;
54 }
55 
57 {
58 public:
60 
62  MWAWContentListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, WPXDocumentInterface *documentInterface);
64  virtual ~MWAWContentListener();
65 
67  void setDocumentLanguage(std::string locale);
68 
70  void startDocument();
72  void endDocument(bool sendDelayedSubDoc=true);
73 
75  void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
77  bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
78 
79  // ------ page --------
81  bool isPageSpanOpened() const;
85  MWAWPageSpan const &getPageSpan();
86 
87  // ------ header/footer --------
89  bool insertHeader(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras);
91  bool insertFooter(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras);
93  bool isHeaderFooterOpened() const;
94 
95  // ------ text data -----------
96 
98  void insertChar(uint8_t character);
101  void insertCharacter(unsigned char c);
107  int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
110  void insertUnicode(uint32_t character);
112  void insertUnicodeString(WPXString const &str);
113 
115  void insertTab();
117  void insertEOL(bool softBreak=false);
119  void insertBreak(BreakType breakType);
120 
121  // ------ text format -----------
123  void setFont(MWAWFont const &font);
125  MWAWFont const &getFont() const;
126 
127  // ------ paragraph format -----------
129  bool isParagraphOpened() const;
131  void setParagraph(MWAWParagraph const &paragraph);
133  MWAWParagraph const &getParagraph() const;
134 
135  // ------- fields ----------------
137  void insertField(MWAWField const&field);
138 
139  // ------- subdocument -----------------
141  void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
142 
144  void insertComment(MWAWSubDocumentPtr &subDocument);
145 
147  void insertPicture(MWAWPosition const &pos, const WPXBinaryData &binaryData,
148  std::string type="image/pict",
149  WPXPropertyList frameExtras=WPXPropertyList());
151  void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
152  WPXPropertyList frameExtras=WPXPropertyList(),
153  WPXPropertyList textboxExtras=WPXPropertyList());
154 
155  // ------- table -----------------
157  void openTable(std::vector<float> const &colWidth, WPXUnit unit,
158  WPXPropertyList tableExtras=WPXPropertyList());
160  void closeTable();
162  void openTableRow(float h, WPXUnit unit, bool headerRow=false);
164  void closeTableRow();
168  void openTableCell(MWAWCell const &cell, WPXPropertyList const &extras);
170  void closeTableCell();
172  void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
173 
174  // ------- section ---------------
176  bool isSectionOpened() const;
178  MWAWSection const &getSection() const;
180  bool openSection(MWAWSection const &section);
182  bool closeSection();
183 
184 protected:
185  void _openSection();
186  void _closeSection();
187 
188  void _openPageSpan(bool sendHeaderFooters=true);
189  void _closePageSpan();
190 
191  void _startSubDocument();
192  void _endSubDocument();
193 
194  void _handleFrameParameters( WPXPropertyList &propList, MWAWPosition const &pos);
195  bool openFrame(MWAWPosition const &pos, WPXPropertyList extras=WPXPropertyList());
196  void closeFrame();
197 
198 
199  void _openParagraph();
200  void _closeParagraph();
201  void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
202  void _resetParagraphState(const bool isListElement=false);
203 
205  void _openListElement();
207  void _closeListElement();
209  void _changeList();
214  int _getListId() const;
215 
216  void _openSpan();
217  void _closeSpan();
218 
219  void _flushText();
220  void _flushDeferredTabs();
221 
222  void _insertBreakIfNecessary(WPXPropertyList &propList);
223 
227  shared_ptr<MWAWContentListenerInternal::State> _pushParsingState();
229  void _popParsingState();
230 
231 protected:
233  shared_ptr<MWAWContentListenerInternal::DocumentState> m_ds;
235  shared_ptr<MWAWContentListenerInternal::State> m_ps;
237  std::vector<shared_ptr<MWAWContentListenerInternal::State> > m_psStack;
241  WPXDocumentInterface *m_documentInterface;
242 
243 private:
246 };
247 
248 #endif
249 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Wed Jul 10 2013 18:02:03 for libmwaw by doxygen 1.8.4