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 MWAWCell;
44 class MWAWTable;
45 
46 namespace MWAWContentListenerInternal
47 {
48 struct DocumentState;
49 struct State;
50 }
51 
53 {
54 public:
56 
58  MWAWContentListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, WPXDocumentInterface *documentInterface);
60  virtual ~MWAWContentListener();
61 
63  void setDocumentLanguage(std::string locale);
64 
66  void startDocument();
68  void endDocument(bool sendDelayedSubDoc=true);
69 
71  void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
73  bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
74 
75  // ------ page --------
77  bool isPageSpanOpened() const;
81  MWAWPageSpan const &getPageSpan();
82 
83  // ------ header/footer --------
85  bool insertHeader(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras);
87  bool insertFooter(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras);
89  bool isHeaderFooterOpened() const;
90 
91  // ------ text data -----------
92 
94  void insertChar(uint8_t character);
97  void insertCharacter(unsigned char c);
103  int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
106  void insertUnicode(uint32_t character);
108  void insertUnicodeString(WPXString const &str);
109 
111  void insertTab();
113  void insertEOL(bool softBreak=false);
115  void insertBreak(BreakType breakType);
116 
117  // ------ text format -----------
119  void setFont(MWAWFont const &font);
121  MWAWFont const &getFont() const;
122 
123  // ------ paragraph format -----------
125  bool isParagraphOpened() const;
127  void setParagraph(MWAWParagraph const &paragraph);
129  MWAWParagraph const &getParagraph() const;
130 
131  // ------- fields ----------------
133  void insertField(MWAWField const&field);
134 
135  // ------- subdocument -----------------
137  void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
138 
140  void insertComment(MWAWSubDocumentPtr &subDocument);
141 
143  void insertPicture(MWAWPosition const &pos, const WPXBinaryData &binaryData,
144  std::string type="image/pict",
145  WPXPropertyList frameExtras=WPXPropertyList());
147  void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
148  WPXPropertyList frameExtras=WPXPropertyList(),
149  WPXPropertyList textboxExtras=WPXPropertyList());
150 
151  // ------- table -----------------
153  void openTable(MWAWTable const &table);
155  void closeTable();
157  void openTableRow(float h, WPXUnit unit, bool headerRow=false);
159  void closeTableRow();
161  void openTableCell(MWAWCell const &cell);
163  void closeTableCell();
165  void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
166 
167  // ------- section ---------------
169  bool isSectionOpened() const;
171  MWAWSection const &getSection() const;
173  bool openSection(MWAWSection const &section);
175  bool closeSection();
176 
177 protected:
178  void _openSection();
179  void _closeSection();
180 
181  void _openPageSpan(bool sendHeaderFooters=true);
182  void _closePageSpan();
183 
184  void _startSubDocument();
185  void _endSubDocument();
186 
187  void _handleFrameParameters( WPXPropertyList &propList, MWAWPosition const &pos);
188  bool openFrame(MWAWPosition const &pos, WPXPropertyList extras=WPXPropertyList());
189  void closeFrame();
190 
191 
192  void _openParagraph();
193  void _closeParagraph();
194  void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
195  void _resetParagraphState(const bool isListElement=false);
196 
198  void _openListElement();
200  void _closeListElement();
202  void _changeList();
207  int _getListId() const;
208 
209  void _openSpan();
210  void _closeSpan();
211 
212  void _flushText();
213  void _flushDeferredTabs();
214 
215  void _insertBreakIfNecessary(WPXPropertyList &propList);
216 
220  shared_ptr<MWAWContentListenerInternal::State> _pushParsingState();
222  void _popParsingState();
223 
224 protected:
226  shared_ptr<MWAWContentListenerInternal::DocumentState> m_ds;
228  shared_ptr<MWAWContentListenerInternal::State> m_ps;
230  std::vector<shared_ptr<MWAWContentListenerInternal::State> > m_psStack;
234  WPXDocumentInterface *m_documentInterface;
235 
236 private:
239 };
240 
241 #endif
242 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void _openParagraph()
Definition: MWAWContentListener.cxx:698
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWContentListener.cxx:582
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWContentListener.cxx:381
void closeTable()
closes this table
Definition: MWAWContentListener.cxx:1481
void _closeListElement()
close a list level
Definition: MWAWContentListener.cxx:801
shared_ptr< MWAWContentListenerInternal::DocumentState > m_ds
the main parse state
Definition: MWAWContentListener.hxx:226
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWContentListener.cxx:210
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWContentListener.cxx:393
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWContentListener.cxx:516
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWContentListener.cxx:401
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWContentListener.cxx:616
bool closeSection()
close a section
Definition: MWAWContentListener.cxx:642
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWContentListener.cxx:626
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWContentListener.cxx:1359
bool insertHeader(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras)
insert a header
Definition: MWAWContentListener.cxx:587
void _openSection()
Definition: MWAWContentListener.cxx:657
void openTableRow(float h, WPXUnit unit, bool headerRow=false)
open a row with given height ( if h &lt; 0.0, set min-row-height = -h )
Definition: MWAWContentListener.cxx:1495
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWContentListener.cxx:252
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWContentListener.cxx:269
void _flushText()
Definition: MWAWContentListener.cxx:944
SubDocumentType
Definition: libmwaw_internal.hxx:157
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWContentListener.cxx:1029
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:53
void _insertBreakIfNecessary(WPXPropertyList &propList)
Definition: MWAWContentListener.cxx:341
void startDocument()
starts the document
Definition: MWAWContentListener.cxx:465
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWContentListener.cxx:817
void insertTab()
adds a tab
Definition: MWAWContentListener.cxx:286
virtual ~MWAWContentListener()
destructor
Definition: MWAWContentListener.cxx:191
void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false)
Definition: MWAWContentListener.cxx:756
a structure used to define a cell and its format
Definition: MWAWCell.hxx:50
Vec2< int > Vec2i
Vec2 of int.
Definition: libmwaw_internal.hxx:578
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:344
WPXDocumentInterface * m_documentInterface
the document interface
Definition: MWAWContentListener.hxx:234
void _handleFrameParameters(WPXPropertyList &propList, MWAWPosition const &pos)
Definition: MWAWContentListener.cxx:1159
shared_ptr< MWAWContentListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWContentListener.hxx:228
void closeTableRow()
closes this row
Definition: MWAWContentListener.cxx:1516
void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1, 1))
add empty cell
Definition: MWAWContentListener.cxx:1526
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWContentListener.cxx:511
a class to define the parser state
Definition: MWAWParser.hxx:51
void insertUnicodeString(WPXString const &str)
adds a unicode string
Definition: MWAWContentListener.cxx:262
void endDocument(bool sendDelayedSubDoc=true)
ends the document
Definition: MWAWContentListener.cxx:480
void _openPageSpan(bool sendHeaderFooters=true)
Definition: MWAWContentListener.cxx:524
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWContentListener.cxx:297
bool insertFooter(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras)
insert a footer
Definition: MWAWContentListener.cxx:600
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWContentListener.cxx:748
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWContentListener.cxx:1545
void _closeSection()
Definition: MWAWContentListener.cxx:678
void openTable(MWAWTable const &table)
open a table
Definition: MWAWContentListener.cxx:1456
void _closeParagraph()
Definition: MWAWContentListener.cxx:727
void _openSpan()
Definition: MWAWContentListener.cxx:888
void _closeSpan()
Definition: MWAWContentListener.cxx:912
void _flushDeferredTabs()
Definition: MWAWContentListener.cxx:925
BreakType
Definition: MWAWContentListener.hxx:55
void _openListElement()
open a list level
Definition: MWAWContentListener.cxx:769
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWContentListener.cxx:386
a class which stores section properties
Definition: MWAWSection.hxx:45
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWContentListener.cxx:360
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWContentListener.cxx:834
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, WPXPropertyList frameExtras=WPXPropertyList(), WPXPropertyList textboxExtras=WPXPropertyList())
adds a textbox in given position
Definition: MWAWContentListener.cxx:1054
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWContentListener.cxx:376
class to store the paragraph properties
Definition: MWAWParagraph.hxx:83
void _endSubDocument()
Definition: MWAWContentListener.cxx:1442
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWContentListener.cxx:199
bool openFrame(MWAWPosition const &pos, WPXPropertyList extras=WPXPropertyList())
Definition: MWAWContentListener.cxx:1092
a field
Definition: libmwaw_internal.hxx:281
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWContentListener.cxx:974
void _popParsingState()
resets the previous parsing state
Definition: MWAWContentListener.cxx:1596
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWContentListener.cxx:1428
MWAWParserState & m_parserState
the parser state
Definition: MWAWContentListener.hxx:232
a note
Definition: libmwaw_internal.hxx:299
Definition: MWAWContentListener.hxx:55
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWContentListener & operator=(const MWAWContentListener &)
void _startSubDocument()
Definition: MWAWContentListener.cxx:1436
Definition: MWAWContentListener.hxx:52
void _closePageSpan()
Definition: MWAWContentListener.cxx:567
void closeFrame()
Definition: MWAWContentListener.cxx:1148
shared_ptr< MWAWContentListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWContentListener.cxx:1582
Definition: MWAWContentListener.hxx:55
void insertPicture(MWAWPosition const &pos, const WPXBinaryData &binaryData, std::string type="image/pict", WPXPropertyList frameExtras=WPXPropertyList())
adds a picture in given position
Definition: MWAWContentListener.cxx:1067
std::vector< shared_ptr< MWAWContentListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWContentListener.hxx:230
void closeTableCell()
close a cell
Definition: MWAWContentListener.cxx:1562
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: MWAWContentListener.cxx:459
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWContentListener.cxx:621
Definition: MWAWContentListener.hxx:55
MWAWContentListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, WPXDocumentInterface *documentInterface)
constructor
Definition: MWAWContentListener.cxx:185

Generated on Wed Jun 11 2014 01:30:58 for libmwaw by doxygen 1.8.5