MWAWTextListener.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 
40 #ifndef MWAW_TEXT_LISTENER_H
41 #define MWAW_TEXT_LISTENER_H
42 
43 #include <vector>
44 
45 #include <librevenge/librevenge.h>
46 
47 #include "libmwaw_internal.hxx"
48 #include "MWAWGraphicStyle.hxx"
49 
50 #include "MWAWListener.hxx"
51 
52 class MWAWCell;
53 class MWAWGraphicStyle;
54 class MWAWGraphicShape;
55 class MWAWTable;
56 
58 {
59 struct DocumentState;
60 struct State;
61 }
62 
65 {
66 public:
68  MWAWTextListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
70  virtual ~MWAWTextListener();
71 
73  Type getType() const
74  {
75  return Text;
76  }
77 
79  void setDocumentLanguage(std::string locale);
80 
82  void startDocument();
84  void endDocument(bool sendDelayedSubDoc=true);
86  bool isDocumentStarted() const;
87 
89  void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
91  bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
93  bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
95  void closeFrame();
97  bool openGroup(MWAWPosition const &pos);
99  void closeGroup();
100 
102  bool canWriteText() const
103  {
105  }
106 
107  // ------ page --------
109  bool isPageSpanOpened() const;
113  MWAWPageSpan const &getPageSpan();
114 
115  // ------ header/footer --------
117  bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
119  bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
121  bool isHeaderFooterOpened() const;
122 
123  // ------ text data -----------
124 
126  void insertChar(uint8_t character);
129  void insertCharacter(unsigned char c);
135  int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
138  void insertUnicode(uint32_t character);
140  void insertUnicodeString(librevenge::RVNGString const &str);
141 
143  void insertTab();
145  void insertEOL(bool softBreak=false);
146 
147  // ------ text format -----------
149  void setFont(MWAWFont const &font);
151  MWAWFont const &getFont() const;
152 
153  // ------ paragraph format -----------
155  bool isParagraphOpened() const;
157  void setParagraph(MWAWParagraph const &paragraph);
159  MWAWParagraph const &getParagraph() const;
160 
161  // ------- fields ----------------
163  void insertField(MWAWField const &field);
164 
165  // ------- link ----------------
167  void openLink(MWAWLink const &link);
169  void closeLink();
170 
171  // ------- subdocument -----------------
173  void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
174 
176  void insertComment(MWAWSubDocumentPtr &subDocument);
177 
179  void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
182  void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape,
183  MWAWGraphicStyle const &style);
185  void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
186  MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle());
187 
188  // ------- table -----------------
190  void openTable(MWAWTable const &table);
192  void closeTable();
194  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
196  void closeTableRow();
198  void openTableCell(MWAWCell const &cell);
200  void closeTableCell();
202  void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
203 
204  // ------- section ---------------
206  bool canOpenSectionAddBreak() const;
208  bool isSectionOpened() const;
210  MWAWSection const &getSection() const;
212  bool openSection(MWAWSection const &section);
214  bool closeSection();
216  void insertBreak(BreakType breakType);
217 
218 protected:
220  void _openSection();
222  void _closeSection();
224  void _openPageSpan(bool sendHeaderFooters=true);
226  void _closePageSpan();
227 
228  void _startSubDocument();
229  void _endSubDocument();
230 
231  void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos);
232 
233  void _openParagraph();
234  void _closeParagraph();
235  void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
236  void _resetParagraphState(const bool isListElement=false);
237 
239  void _openListElement();
241  void _closeListElement();
243  void _changeList();
248  int _getListId() const;
249 
251  void _openSpan();
253  void _closeSpan();
254 
256  void _flushText();
258  void _flushDeferredTabs();
259 
260  void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
261 
265  shared_ptr<MWAWTextListenerInternal::State> _pushParsingState();
267  void _popParsingState();
268 
269 protected:
271  shared_ptr<MWAWTextListenerInternal::DocumentState> m_ds;
273  shared_ptr<MWAWTextListenerInternal::State> m_ps;
275  std::vector<shared_ptr<MWAWTextListenerInternal::State> > m_psStack;
279  librevenge::RVNGTextInterface *m_documentInterface;
280 
281 private:
285  MWAWTextListener &operator=(const MWAWTextListener &);
286 };
287 
288 #endif
289 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWParserState & m_parserState
the parser state
Definition: MWAWTextListener.hxx:277
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWTextListener.cxx:520
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:64
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
SubDocumentType
Definition: libmwaw_internal.hxx:172
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:767
bool canWriteText() const
returns true if we can add text data
Definition: MWAWTextListener.hxx:102
Type
the listener type
Definition: MWAWListener.hxx:56
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:503
Class to store font.
Definition: MWAWFont.hxx:43
a class to define the parser state
Definition: MWAWParser.hxx:49
BreakType
the different break type
Definition: MWAWListener.hxx:58
shared_ptr< MWAWTextListenerInternal::DocumentState > m_ds
the main parse state
Definition: MWAWTextListener.hxx:271
Internal and low level namespace to define the states of MWAWTextListener.
Definition: MWAWTextListener.cxx:70
small class use to define a embedded object
Definition: libmwaw_internal.hxx:412
a class which stores section properties
Definition: MWAWSection.hxx:45
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:489
Type getType() const
returns the listener type
Definition: MWAWTextListener.hxx:73
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
class to store the paragraph properties
Definition: MWAWParagraph.hxx:81
a field
Definition: libmwaw_internal.hxx:360
shared_ptr< MWAWTextListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWTextListener.hxx:273
a note
Definition: libmwaw_internal.hxx:393
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
librevenge::RVNGTextInterface * m_documentInterface
the document interface
Definition: MWAWTextListener.hxx:279
std::vector< shared_ptr< MWAWTextListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWTextListener.hxx:275
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:269

Generated on Wed May 18 2016 13:08:47 for libmwaw by doxygen 1.8.11