STOFFTextListener.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 /* libstoff
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 STOFF_TEXT_LISTENER_H
35 #define STOFF_TEXT_LISTENER_H
36 
37 #include <vector>
38 
39 #include <librevenge/librevenge.h>
40 
42 
43 #include "STOFFGraphicStyle.hxx"
44 
45 #include "STOFFListener.hxx"
46 
47 class STOFFTextShape;
48 
49 namespace STOFFTextListenerInternal
50 {
51 struct TextState;
52 struct State;
53 }
54 
60 {
61 public:
63  STOFFTextListener(STOFFListManagerPtr listManager, std::vector<STOFFPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
65  virtual ~STOFFTextListener();
66 
68  Type getType() const
69  {
70  return Text;
71  }
72 
74  void setDocumentLanguage(std::string locale);
76  void setDocumentMetaData(const librevenge::RVNGPropertyList &list);
78  void startDocument();
80  void endDocument(bool sendDelayedSubDoc=true);
81 
82  // ------ general information --------
84  bool canWriteText() const
85  {
87  }
88 
90  bool isDocumentStarted() const;
91 
93  void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType);
95  bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const;
97  bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle());
99  void closeFrame();
101  bool openGroup(STOFFPosition const &pos);
103  void closeGroup();
105  bool openLayer(librevenge::RVNGString const &name);
107  void closeLayer();
108 
109  // ------ page --------
111  bool openMasterPage(STOFFPageSpan &/*masterPage*/);
114  {
115  }
117  bool isPageSpanOpened() const;
121  STOFFPageSpan const &getPageSpan();
122 
123  // ------ header/footer --------
125  bool openHeader(librevenge::RVNGPropertyList const &extras);
127  bool openFooter(librevenge::RVNGPropertyList const &extras);
129  bool closeHeader();
131  bool closeFooter();
133  bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
135  bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
137  bool isHeaderFooterOpened() const;
138 
139  // ------ text data -----------
141  void insertChar(uint8_t character);
146  void insertUnicode(uint32_t character);
148  void insertUnicodeString(librevenge::RVNGString const &str);
149 
151  void insertTab();
153  void insertEOL(bool softBreak=false);
154 
155  // ------ text format -----------
157  void setFont(STOFFFont const &font);
159  STOFFFont const &getFont() const;
160 
161  // ------ paragraph format -----------
163  bool isParagraphOpened() const;
165  void setParagraph(STOFFParagraph const &paragraph);
167  STOFFParagraph const &getParagraph() const;
168 
169  // ------ style definition -----------
171  void defineStyle(STOFFFont const &style);
173  bool isFontStyleDefined(librevenge::RVNGString const &name) const;
175  void defineStyle(STOFFGraphicStyle const &style);
177  bool isGraphicStyleDefined(librevenge::RVNGString const &name) const;
179  void defineStyle(STOFFParagraph const &style);
181  bool isParagraphStyleDefined(librevenge::RVNGString const &name) const;
182 
183  // ------- fields ----------------
185  void insertField(STOFFField const &field);
186 
187  // ------- link ----------------
189  void openLink(STOFFLink const &link);
191  void closeLink();
192 
193  // ------- subdocument -----------------
195  void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos);
197  void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle());
199  void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
200  STOFFGraphicStyle const &style=STOFFGraphicStyle());
202  void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument);
204  void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="");
205 
206  // ------- table -----------------
207 
209  void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle());
211  void openTable(STOFFTable const &table);
213  void openTable(STOFFPosition const &pos, STOFFTable const &table);
215  void closeTable();
217  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
219  void closeTableRow();
221  void openTableCell(STOFFCell const &cell);
223  void closeTableCell();
225  void addCoveredTableCell(STOFFVec2i const &pos);
227  void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1));
228 
229  // ------- section ---------------
230 
232  bool canOpenSectionAddBreak() const;
234  bool isSectionOpened() const;
236  STOFFSection const &getSection() const;
238  bool openSection(STOFFSection const &section);
240  bool closeSection();
242  void insertBreak(BreakType breakType);
243 
244 protected:
246  void _openSection();
248  void _closeSection();
250  void _openPageSpan(bool sendHeaderFooters=true);
252  void _closePageSpan();
253 
254  void _startSubDocument();
255  void _endSubDocument();
256 
260  void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos, STOFFGraphicStyle const &style);
261 
262  void _openParagraph();
263  void _closeParagraph();
264  void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
265  void _resetParagraphState(const bool isListElement=false);
266 
268  void _openListElement();
270  void _closeListElement();
272  void _changeList();
277  int _getListId() const;
278 
280  void _openSpan();
282  void _closeSpan();
283 
285  void _flushText();
287  void _flushDeferredTabs();
288 
289  void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
290 
294  shared_ptr<STOFFTextListenerInternal::State> _pushParsingState();
296  void _popParsingState();
297 
298 protected:
300  shared_ptr<STOFFTextListenerInternal::TextState> m_ds;
302  shared_ptr<STOFFTextListenerInternal::State> m_ps;
304  std::vector<shared_ptr<STOFFTextListenerInternal::State> > m_psStack;
306  librevenge::RVNGTextInterface *m_documentInterface;
307 
308 private:
311 };
312 
313 #endif
314 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFPageSpan const & getPageSpan()
returns the current page span
Definition: STOFFTextListener.cxx:539
void _closePageSpan()
does close a page (low level)
Definition: STOFFTextListener.cxx:595
void _closeSection()
does close a section (low level)
Definition: STOFFTextListener.cxx:752
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: STOFFTextListener.cxx:891
bool openHeader(librevenge::RVNGPropertyList const &extras)
open a header (interaction with STOFFPageSpan which fills the parameters for openHeader) ...
Definition: STOFFTextListener.cxx:615
bool isDocumentStarted() const
returns true if a document is opened
Definition: STOFFTextListener.cxx:485
void setFont(STOFFFont const &font)
sets the font
Definition: STOFFTextListener.cxx:393
void closeFrame()
close a frame
Definition: STOFFTextListener.cxx:1295
void _openSpan()
low level: the function which opens a new span property
Definition: STOFFTextListener.cxx:967
void _closeParagraph()
Definition: STOFFTextListener.cxx:800
void insertChar(uint8_t character)
adds a basic character, ..
Definition: STOFFTextListener.cxx:263
STOFFFont const & getFont() const
returns the actual font
Definition: STOFFTextListener.cxx:401
bool isSectionOpened() const
returns true if a section is opened
Definition: STOFFTextListener.cxx:688
bool isFontStyleDefined(librevenge::RVNGString const &name) const
check if a font style with a display name is already defined
Definition: STOFFTextListener.cxx:245
void closeGroup()
close a group
Definition: STOFFTextListener.cxx:1355
void closeTableCell()
close a cell
Definition: STOFFTextListener.cxx:1608
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
bool isGraphicStyleDefined(librevenge::RVNGString const &name) const
check if a graphic style with a display name is already defined
Definition: STOFFTextListener.cxx:250
bool canWriteText() const
returns true if a text zone is opened
Definition: STOFFTextListener.hxx:84
void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a textbox in given position
Definition: STOFFTextListener.cxx:1128
void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType)
function called to add a subdocument and modify the origin
Definition: STOFFTextListener.cxx:1378
Type
the listener type
Definition: STOFFListener.hxx:57
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: STOFFTextListener.cxx:698
void _changeList()
update the list so that it corresponds to the actual level
Definition: STOFFTextListener.cxx:908
void insertField(STOFFField const &field)
adds a field type
Definition: STOFFTextListener.cxx:430
void defineStyle(STOFFFont const &style)
defines a font styles
Definition: STOFFTextListener.cxx:219
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: STOFFTextListener.cxx:291
void openTable(STOFFTable const &table)
open a table (using the last parameters of openFrame for the position )
Definition: STOFFTextListener.cxx:1487
void insertUnicode(uint32_t character)
insert a character using the font converter to find the utf8 character
Definition: STOFFTextListener.cxx:274
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: STOFFTextListener.cxx:324
bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: STOFFTextListener.cxx:1459
void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a picture with potential various representationin given position
Definition: STOFFTextListener.cxx:1213
void _flushDeferredTabs()
low level: flush the deferred tabs
Definition: STOFFTextListener.cxx:1005
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
bool closeHeader()
close a header
Definition: STOFFTextListener.cxx:639
void _closeSpan()
low level: the function which closes the last opened span property
Definition: STOFFTextListener.cxx:991
void openTableCell(STOFFCell const &cell)
open a cell
Definition: STOFFTextListener.cxx:1591
STOFFTextListener(STOFFListManagerPtr listManager, std::vector< STOFFPageSpan > const &pageList, librevenge::RVNGTextInterface *documentInterface)
constructor
Definition: STOFFTextListener.cxx:209
a note
Definition: libstaroffice_internal.hxx:393
shared_ptr< STOFFTextListenerInternal::State > m_ps
the actual local parse state
Definition: STOFFTextListener.hxx:302
class to store the paragraph properties
Definition: STOFFParagraph.hxx:47
virtual ~STOFFTextListener()
destructor
Definition: STOFFTextListener.cxx:215
bool openMasterPage(STOFFPageSpan &)
opens a master page
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos, STOFFGraphicStyle const &style)
adds in propList the frame parameters.
Definition: STOFFTextListener.cxx:1367
bool openFooter(librevenge::RVNGPropertyList const &extras)
open a footer (interaction with STOFFPageSpan which fills the parameters for openFooter) ...
Definition: STOFFTextListener.cxx:650
Definition: STOFFListener.hxx:57
shared_ptr< STOFFListManager > STOFFListManagerPtr
a smart pointer of STOFFListManager
Definition: libstaroffice_internal.hxx:492
void _popParsingState()
resets the previous parsing state
Definition: STOFFTextListener.cxx:1639
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: STOFFTextListener.cxx:547
void addCoveredTableCell(STOFFVec2i const &pos)
add covered cell
Definition: STOFFTextListener.cxx:1556
void closeTableRow()
closes this row
Definition: STOFFTextListener.cxx:1546
void _flushText()
low level: flush the deferred text
Definition: STOFFTextListener.cxx:1013
void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos)
adds a shape picture in given position
Definition: STOFFTextListener.cxx:1143
librevenge::RVNGTextInterface * m_documentInterface
the document interface
Definition: STOFFTextListener.hxx:306
SubDocumentType
Definition: libstaroffice_internal.hxx:189
bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)
insert a footer
Definition: STOFFTextListener.cxx:662
shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:498
a class which stores section properties
Definition: STOFFSection.hxx:45
STOFFParagraph const & getParagraph() const
returns the actual paragraph
Definition: STOFFTextListener.cxx:422
void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="")
adds comment
Definition: STOFFTextListener.cxx:1101
void closeLayer()
close a layer
a field
Definition: libstaroffice_internal.hxx:367
a structure used to define a picture shape
Definition: STOFFGraphicShape.hxx:45
bool closeFooter()
close a footer
Definition: STOFFTextListener.cxx:674
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:412
void _closeListElement()
close a list level
Definition: STOFFTextListener.cxx:875
STOFFSection const & getSection() const
returns the actual section
Definition: STOFFTextListener.cxx:693
void endDocument(bool sendDelayedSubDoc=true)
ends the actual document
Definition: STOFFTextListener.cxx:503
bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle())
store the position and the style (which will be needed further to insert a textbox or a table with op...
Definition: STOFFTextListener.cxx:1226
void _openSection()
does open a section (low level)
Definition: STOFFTextListener.cxx:734
Type getType() const
returns the listener type
Definition: STOFFTextListener.hxx:68
This class contains the code needed to create Text document.
Definition: STOFFTextListener.hxx:59
void _openListElement()
open a list level
Definition: STOFFTextListener.cxx:845
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:762
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: STOFFTextListener.cxx:610
void startDocument()
starts a new document
Definition: STOFFTextListener.cxx:490
bool openSection(STOFFSection const &section)
open a section if possible
Definition: STOFFTextListener.cxx:703
STOFFTextListener & operator=(const STOFFTextListener &)
void closeMasterPage()
close a master page
Definition: STOFFTextListener.hxx:113
Class to store font.
Definition: STOFFFont.hxx:43
void closeTable()
closes this table
Definition: STOFFTextListener.cxx:1511
shared_ptr< STOFFTextListenerInternal::TextState > m_ds
the actual global state
Definition: STOFFTextListener.hxx:300
void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList)
Definition: STOFFTextListener.cxx:372
void setDocumentMetaData(const librevenge::RVNGPropertyList &list)
sets the document meta data
Definition: STOFFTextListener.cxx:472
void _resetParagraphState(const bool isListElement=false)
Definition: STOFFTextListener.cxx:824
bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)
insert a header
Definition: STOFFTextListener.cxx:627
void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a table in given position
bool isPageSpanOpened() const
returns true if a page is opened
Definition: STOFFTextListener.cxx:534
void insertTab()
adds a tab
Definition: STOFFTextListener.cxx:313
void openLink(STOFFLink const &link)
open a link
Definition: STOFFTextListener.cxx:440
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: STOFFTextListener.cxx:298
std::vector< shared_ptr< STOFFTextListenerInternal::State > > m_psStack
stack of local state
Definition: STOFFTextListener.hxx:304
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:75
bool closeSection()
close a section
Definition: STOFFTextListener.cxx:719
void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument)
insert a note
Definition: STOFFTextListener.cxx:1044
BreakType
the different break type
Definition: STOFFListener.hxx:59
bool openGroup(STOFFPosition const &pos)
open a group
Definition: STOFFTextListener.cxx:1305
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: STOFFTextListener.cxx:406
void _startSubDocument()
Definition: STOFFTextListener.cxx:1467
bool openLayer(librevenge::RVNGString const &name)
open a layer
void _openParagraph()
Definition: STOFFTextListener.cxx:772
bool isParagraphStyleDefined(librevenge::RVNGString const &name) const
check if a paragraph style with a display name is already defined
Definition: STOFFTextListener.cxx:255
void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1, 1))
add empty cell
Definition: STOFFTextListener.cxx:1572
This class contains a virtual interface to all listener.
Definition: STOFFListener.hxx:50
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:44
shared_ptr< STOFFTextListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: STOFFTextListener.cxx:1628
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47
void closeLink()
close a link
Definition: STOFFTextListener.cxx:458
void setParagraph(STOFFParagraph const &paragraph)
sets the paragraph
Definition: STOFFTextListener.cxx:411
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false)
open a row with given height ( if h &lt; 0.0, set min-row-height = -h )
Definition: STOFFTextListener.cxx:1525
void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false)
Definition: STOFFTextListener.cxx:832
void _endSubDocument()
Definition: STOFFTextListener.cxx:1473
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: STOFFTextListener.cxx:479

Generated on Fri Apr 13 2018 00:25:11 for libstaroffice by doxygen 1.8.5