STOFFTextListener.hxx Source File documentation

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
41 #include "libstaroffice_internal.hxx"
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
59 class STOFFTextListener final : public STOFFListener
60 {
61 public:
63 STOFFTextListener(STOFFListManagerPtr listManager, std::vector<STOFFPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
65 ~STOFFTextListener() final;
66
68 Type getType() const final
69 {
70 return Text;
71 }
72
74 void setDocumentLanguage(std::string locale) final;
76 void setDocumentMetaData(const librevenge::RVNGPropertyList &list) final;
78 void startDocument() final;
80 void endDocument(bool sendDelayedSubDoc=true) final;
81
82 // ------ general information --------
84 bool canWriteText() const final
85 {
86 return STOFFTextListener::isDocumentStarted();
87 }
88
90 bool isDocumentStarted() const final;
91
93 void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType) final;
95 bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const final;
97 bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
99 void closeFrame() final;
101 bool openGroup(STOFFPosition const &pos) final;
103 void closeGroup() final;
105 bool openLayer(librevenge::RVNGString const &name);
107 void closeLayer();
108
109 // ------ page --------
111 bool openMasterPage(STOFFPageSpan &/*masterPage*/);
113 void closeMasterPage()
114 {
115 }
117 bool isPageSpanOpened() const final;
121 STOFFPageSpan const &getPageSpan() final;
122
123 // ------ header/footer --------
125 bool openHeader(librevenge::RVNGPropertyList const &extras) final;
127 bool openFooter(librevenge::RVNGPropertyList const &extras) final;
129 bool closeHeader() final;
131 bool closeFooter() final;
133 bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) final;
135 bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) final;
137 bool isHeaderFooterOpened() const final;
138
139 // ------ text data -----------
141 void insertChar(uint8_t character) final;
146 void insertUnicode(uint32_t character) final;
148 void insertUnicodeString(librevenge::RVNGString const &str) final;
149
151 void insertTab() final;
153 void insertEOL(bool softBreak=false) final;
154
155 // ------ text format -----------
157 void setFont(STOFFFont const &font) final;
159 STOFFFont const &getFont() const final;
160
161 // ------ paragraph format -----------
163 bool isParagraphOpened() const final;
165 void setParagraph(STOFFParagraph const &paragraph) final;
167 STOFFParagraph const &getParagraph() const final;
168
169 // ------ style definition -----------
171 void defineStyle(STOFFFont const &style) final;
173 bool isFontStyleDefined(librevenge::RVNGString const &name) const final;
175 void defineStyle(STOFFGraphicStyle const &style) final;
177 bool isGraphicStyleDefined(librevenge::RVNGString const &name) const final;
179 void defineStyle(STOFFParagraph const &style) final;
181 bool isParagraphStyleDefined(librevenge::RVNGString const &name) const final;
182
183 // ------- fields ----------------
185 void insertField(STOFFField const &field) final;
186
187 // ------- link ----------------
189 void openLink(STOFFLink const &link) final;
191 void closeLink() final;
192
193 // ------- subdocument -----------------
195 void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style, STOFFPosition const &pos) final;
197 void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
199 void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
200 STOFFGraphicStyle const &style=STOFFGraphicStyle()) final;
202 void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument) final;
204 void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="") final;
205
206 // ------- table -----------------
207
209 void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle());
211 void openTable(STOFFTable const &table) final;
213 void openTable(STOFFPosition const &pos, STOFFTable const &table);
215 void closeTable() final;
217 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final;
219 void closeTableRow() final;
221 void openTableCell(STOFFCell const &cell) final;
223 void closeTableCell() final;
225 void addCoveredTableCell(STOFFVec2i const &pos) final;
227 void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1)) final;
228
229 // ------- section ---------------
230
232 bool canOpenSectionAddBreak() const final;
234 bool isSectionOpened() const final;
236 STOFFSection const &getSection() const final;
238 bool openSection(STOFFSection const &section) final;
240 bool closeSection() final;
242 void insertBreak(BreakType breakType) final;
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 std::shared_ptr<STOFFTextListenerInternal::State> _pushParsingState();
296 void _popParsingState();
297
298 protected:
300 std::shared_ptr<STOFFTextListenerInternal::TextState> m_ds;
302 std::shared_ptr<STOFFTextListenerInternal::State> m_ps;
304 std::vector<std::shared_ptr<STOFFTextListenerInternal::State> > m_psStack;
306 librevenge::RVNGTextInterface *m_documentInterface;
307
308 private:
309 STOFFTextListener(const STOFFTextListener &);
310 STOFFTextListener &operator=(const STOFFTextListener &);
311 };
312
313 #endif
314 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFTextListener::m_ds
std::shared_ptr< STOFFTextListenerInternal::TextState > m_ds
the actual global state
Definition: STOFFTextListener.hxx:300
STOFFTextListener::canWriteText
bool canWriteText() const final
returns true if a text zone is opened
Definition: STOFFTextListener.hxx:84
STOFFCell
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
STOFFVec2< int >
STOFFListener::Type
Type
the listener type
Definition: STOFFListener.hxx:57
STOFFLink
a link
Definition: libstaroffice_internal.hxx:375
STOFFTextListener::m_psStack
std::vector< std::shared_ptr< STOFFTextListenerInternal::State > > m_psStack
stack of local state
Definition: STOFFTextListener.hxx:304
STOFFTable
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
STOFFNote
a note
Definition: libstaroffice_internal.hxx:389
STOFFTextListener::getType
Type getType() const final
returns the listener type
Definition: STOFFTextListener.hxx:68
STOFFParagraph
class to store the paragraph properties
Definition: STOFFParagraph.hxx:47
STOFFSubDocumentPtr
std::shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:494
STOFFTextListener::m_documentInterface
librevenge::RVNGTextInterface * m_documentInterface
the document interface
Definition: STOFFTextListener.hxx:306
libstoff::SubDocumentType
SubDocumentType
Definition: libstaroffice_internal.hxx:185
STOFFSection
a class which stores section properties
Definition: STOFFSection.hxx:45
STOFFTextListener::isDocumentStarted
bool isDocumentStarted() const final
returns true if a document is opened
Definition: STOFFTextListener.cxx:511
STOFFField
a field
Definition: libstaroffice_internal.hxx:363
STOFFGraphicShape
a structure used to define a picture shape
Definition: STOFFGraphicShape.hxx:45
STOFFEmbeddedObject
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:408
STOFFGraphicStyle.hxx
libstaroffice_internal.hxx
STOFFTextListener
This class contains the code needed to create Text document.
Definition: STOFFTextListener.hxx:59
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:762
STOFFTextListener::closeMasterPage
void closeMasterPage()
close a master page
Definition: STOFFTextListener.hxx:113
STOFFFont
Class to store font.
Definition: STOFFFont.hxx:43
STOFFTextListener::m_ps
std::shared_ptr< STOFFTextListenerInternal::State > m_ps
the actual local parse state
Definition: STOFFTextListener.hxx:302
STOFFPageSpan
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:75
STOFFListener::BreakType
BreakType
the different break type
Definition: STOFFListener.hxx:59
STOFFTextListenerInternal
Internal and low level namespace to define the states of STOFFTextListener.
Definition: STOFFTextListener.cxx:68
STOFFListManagerPtr
std::shared_ptr< STOFFListManager > STOFFListManagerPtr
a smart pointer of STOFFListManager
Definition: libstaroffice_internal.hxx:488
STOFFListener.hxx
STOFFListener
This class contains a virtual interface to all listener.
Definition: STOFFListener.hxx:50
STOFFGraphicStyle
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:44
STOFFPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47