STOFFSpreadsheetListener.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 /* libstaroffice
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 STOFF_SPREADSHEET_LISTENER_H
41 #define STOFF_SPREADSHEET_LISTENER_H
42 
43 #include <vector>
44 
45 #include <librevenge/librevenge.h>
46 
48 
49 #include "STOFFListener.hxx"
50 
51 class STOFFCell;
52 class STOFFCellContent;
53 class STOFFChart;
54 class STOFFGraphicStyle;
55 class STOFFTable;
56 
58 {
59 struct DocumentState;
60 struct State;
61 }
62 
65 {
66 public:
68  STOFFSpreadsheetListener(STOFFParserState &parserState, std::vector<STOFFPageSpan> const &pageList, librevenge::RVNGSpreadsheetInterface *documentInterface);
70  virtual ~STOFFSpreadsheetListener();
71 
73  Type getType() const
74  {
75  return Spreadsheet;
76  }
77 
79  void setDocumentLanguage(std::string locale);
81  void setDocumentMetaData(const librevenge::RVNGPropertyList &list);
82 
84  void startDocument();
86  void endDocument(bool sendDelayedSubDoc=true);
88  bool isDocumentStarted() const;
89 
91  void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType);
93  bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const;
95  bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle());
97  void closeFrame();
99  bool openGroup();
101  void closeGroup();
102 
104  bool canWriteText() const;
105 
106  // ------ page --------
108  bool isPageSpanOpened() const;
112  STOFFPageSpan const &getPageSpan();
113 
114  // ------ header/footer --------
116  bool openHeader(librevenge::RVNGPropertyList const &extras);
118  bool openFooter(librevenge::RVNGPropertyList const &extras);
120  bool closeHeader();
122  bool closeFooter();
124  bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
126  bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which);
128  bool isHeaderFooterOpened() const;
129 
130  // ------- sheet -----------------
132  void openSheet(std::vector<float> const &colWidth, librevenge::RVNGUnit unit,
133  std::vector<int> const &repeatColWidthNumber=std::vector<int>(), librevenge::RVNGString const &name="");
135  void closeSheet();
137  void openSheetRow(float h, librevenge::RVNGUnit unit, int numRepeated=1);
139  void closeSheetRow();
141  void openSheetCell(STOFFCell const &cell, STOFFCellContent const &content, int numRepeated=1);
143  void closeSheetCell();
144 
145  // ------- chart -----------------
147  void insertChart(STOFFPosition const &pos, STOFFChart &chart, STOFFGraphicStyle const &style=STOFFGraphicStyle());
148 
149  // ------ text data -----------
150 
152  void insertChar(uint8_t character);
155  void insertUnicode(uint32_t character);
157  void insertUnicodeString(librevenge::RVNGString const &str);
158 
160  void insertTab();
162  void insertEOL(bool softBreak=false);
163 
164  // ------ text format -----------
166  void setFont(STOFFFont const &font);
168  STOFFFont const &getFont() const;
169 
170  // ------ paragraph format -----------
172  bool isParagraphOpened() const;
174  void setParagraph(STOFFParagraph const &paragraph);
176  STOFFParagraph const &getParagraph() const;
177 
178  // ------ style definition -----------
180  void defineStyle(STOFFGraphicStyle const &style);
182  bool isGraphicStyleDefined(librevenge::RVNGString const &name) const;
183 
184  // ------- fields ----------------
186  void insertField(STOFFField const &field);
187 
188  // ------- link ----------------
190  void openLink(STOFFLink const &link);
192  void closeLink();
193 
194  // ------- subdocument -----------------
196  void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument);
198  void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="");
199 
201  void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
202  STOFFGraphicStyle const &style=STOFFGraphicStyle());
204  void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style);
206  void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument,
207  STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle());
208  // ------- table -----------------
210  void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle());
212  void openTable(STOFFTable const &table);
214  void closeTable();
216  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
218  void closeTableRow();
220  void openTableCell(STOFFCell const &cell);
222  void closeTableCell();
224  void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1));
225 
226  // ------- section ---------------
229  {
230  return false;
231  }
233  bool isSectionOpened() const
234  {
235  return false;
236  }
238  STOFFSection const &getSection() const;
240  bool openSection(STOFFSection const &section);
242  bool closeSection();
244  void insertBreak(BreakType breakType);
245 
246 protected:
248  void _openPageSpan(bool sendHeaderFooters=true);
250  void _closePageSpan();
251 
252  void _startSubDocument();
253  void _endSubDocument();
254 
255  void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos);
256 
257  void _openParagraph();
258  void _closeParagraph();
259  void _resetParagraphState(const bool isListElement=false);
260 
262  void _openListElement();
264  void _closeListElement();
266  void _changeList();
271  int _getListId() const;
272 
273  void _openSpan();
274  void _closeSpan();
275 
276  void _flushText();
277  void _flushDeferredTabs();
278 
282  shared_ptr<STOFFSpreadsheetListenerInternal::State> _pushParsingState();
284  void _popParsingState();
285 
286 protected:
288  shared_ptr<STOFFSpreadsheetListenerInternal::DocumentState> m_ds;
290  shared_ptr<STOFFSpreadsheetListenerInternal::State> m_ps;
292  std::vector<shared_ptr<STOFFSpreadsheetListenerInternal::State> > m_psStack;
296  librevenge::RVNGSpreadsheetInterface *m_documentInterface;
297 
298 private:
303 };
304 
305 #endif
306 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
bool openGroup()
open a group (not implemented)
Definition: STOFFSpreadsheetListener.cxx:1091
void _flushDeferredTabs()
Definition: STOFFSpreadsheetListener.cxx:868
shared_ptr< STOFFSpreadsheetListenerInternal::DocumentState > m_ds
the main parse state
Definition: STOFFSpreadsheetListener.hxx:288
bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)
insert a footer
Definition: STOFFSpreadsheetListener.cxx:624
void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="")
adds comment
Definition: STOFFSpreadsheetListener.cxx:962
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: STOFFSpreadsheetListener.cxx:283
void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: STOFFSpreadsheetListener.cxx:1179
virtual ~STOFFSpreadsheetListener()
destructor
Definition: STOFFSpreadsheetListener.cxx:218
bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: STOFFSpreadsheetListener.cxx:1241
void insertTable(STOFFPosition const &pos, STOFFTable &table, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a table in given position
Definition: STOFFSpreadsheetListener.cxx:1471
bool closeSection()
close a section
Definition: STOFFSpreadsheetListener.cxx:669
void closeFrame()
tries to close a frame
Definition: STOFFSpreadsheetListener.cxx:1160
STOFFPageSpan const & getPageSpan()
returns the current page span
Definition: STOFFSpreadsheetListener.cxx:502
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, STOFFPosition const &pos)
Definition: STOFFSpreadsheetListener.cxx:1171
STOFFSpreadsheetListener(STOFFParserState &parserState, std::vector< STOFFPageSpan > const &pageList, librevenge::RVNGSpreadsheetInterface *documentInterface)
constructor
Definition: STOFFSpreadsheetListener.cxx:212
STOFFParagraph const & getParagraph() const
returns the actual paragraph
Definition: STOFFSpreadsheetListener.cxx:368
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: STOFFSpreadsheetListener.hxx:228
void closeSheet()
closes this sheet
Definition: STOFFSpreadsheetListener.cxx:1308
Definition: STOFFListener.hxx:56
void defineStyle(STOFFGraphicStyle const &style)
defines a graphic styles
Definition: STOFFSpreadsheetListener.cxx:222
bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)
insert a header
Definition: STOFFSpreadsheetListener.cxx:583
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle())
tries to open a frame
Definition: STOFFSpreadsheetListener.cxx:1101
void openTableCell(STOFFCell const &cell)
open a cell
Definition: STOFFSpreadsheetListener.cxx:1615
Type
the listener type
Definition: STOFFListener.hxx:56
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false)
open a row with given height ( if h < 0.0, set min-row-height = -h )
Definition: STOFFSpreadsheetListener.cxx:1565
small class use to define a sheet cell content
Definition: STOFFCell.hxx:226
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: STOFFSpreadsheetListener.cxx:319
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: STOFFSpreadsheetListener.cxx:256
STOFFSection const & getSection() const
returns the actual section
Definition: STOFFSpreadsheetListener.cxx:656
bool closeHeader()
close a header
Definition: STOFFSpreadsheetListener.cxx:601
bool isSectionOpened() const
returns true if a section is opened
Definition: STOFFSpreadsheetListener.hxx:233
Internal and low level namespace to define the states of STOFFSpreadsheetListener.
Definition: STOFFSpreadsheetListener.cxx:73
void openSheet(std::vector< float > const &colWidth, librevenge::RVNGUnit unit, std::vector< int > const &repeatColWidthNumber=std::vector< int >(), librevenge::RVNGString const &name="")
open a sheet
Definition: STOFFSpreadsheetListener.cxx:1271
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
a class to define the parser state
Definition: STOFFParser.hxx:49
void _closeListElement()
close a list level
Definition: STOFFSpreadsheetListener.cxx:749
void insertChar(uint8_t character)
adds a basic character, ..
Definition: STOFFSpreadsheetListener.cxx:241
void _changeList()
update the list so that it corresponds to the actual level
Definition: STOFFSpreadsheetListener.cxx:779
void setParagraph(STOFFParagraph const &paragraph)
sets the paragraph
Definition: STOFFSpreadsheetListener.cxx:361
void setDocumentMetaData(const librevenge::RVNGPropertyList &list)
sets the document meta data
Definition: STOFFSpreadsheetListener.cxx:439
void insertTab()
adds a tab
Definition: STOFFSpreadsheetListener.cxx:303
void _closeSpan()
Definition: STOFFSpreadsheetListener.cxx:854
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: STOFFSpreadsheetListener.cxx:762
void endDocument(bool sendDelayedSubDoc=true)
ends the document
Definition: STOFFSpreadsheetListener.cxx:464
void closeSheetCell()
close a cell
Definition: STOFFSpreadsheetListener.cxx:1458
a note
Definition: libstaroffice_internal.hxx:390
bool canWriteText() const
returns true if we can add text data
Definition: STOFFSpreadsheetListener.cxx:236
void openSheetCell(STOFFCell const &cell, STOFFCellContent const &content, int numRepeated=1)
open a cell
Definition: STOFFSpreadsheetListener.cxx:1352
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: STOFFSpreadsheetListener.cxx:271
class to store the paragraph properties
Definition: STOFFParagraph.hxx:47
std::vector< shared_ptr< STOFFSpreadsheetListenerInternal::State > > m_psStack
stack of local state
Definition: STOFFSpreadsheetListener.hxx:292
void insertField(STOFFField const &field)
adds a field type
Definition: STOFFSpreadsheetListener.cxx:376
void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a picture with potential various representationin given position
Definition: STOFFSpreadsheetListener.cxx:1015
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: STOFFSpreadsheetListener.cxx:510
librevenge::RVNGSpreadsheetInterface * m_documentInterface
the document interface
Definition: STOFFSpreadsheetListener.hxx:296
void setFont(STOFFFont const &font)
sets the font
Definition: STOFFSpreadsheetListener.cxx:344
This class contents the main functions needed to create a spreadsheet processing Document.
Definition: STOFFSpreadsheetListener.hxx:64
void _openSpan()
Definition: STOFFSpreadsheetListener.cxx:833
a class used to store a chart associated to a spreadsheet ....
Definition: STOFFChart.hxx:56
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: STOFFSpreadsheetListener.cxx:566
void _openParagraph()
Definition: STOFFSpreadsheetListener.cxx:678
STOFFSpreadsheetListener & operator=(const STOFFSpreadsheetListener &)
operator= (unimplemented)
void _popParsingState()
resets the previous parsing state
Definition: STOFFSpreadsheetListener.cxx:1663
SubDocumentType
Definition: libstaroffice_internal.hxx:175
shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:492
a class which stores section properties
Definition: STOFFSection.hxx:45
void closeGroup()
close a group (not implemented)
Definition: STOFFSpreadsheetListener.cxx:1097
a field
Definition: libstaroffice_internal.hxx:353
void closeSheetRow()
closes this row
Definition: STOFFSpreadsheetListener.cxx:1342
void closeTableCell()
close a cell
Definition: STOFFSpreadsheetListener.cxx:1632
shared_ptr< STOFFSpreadsheetListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: STOFFSpreadsheetListener.cxx:1652
void _openListElement()
open a list level
Definition: STOFFSpreadsheetListener.cxx:727
a structure used to define a picture shape
Definition: STOFFGraphicShape.hxx:45
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:409
void openLink(STOFFLink const &link)
open a link
Definition: STOFFSpreadsheetListener.cxx:399
void _startSubDocument()
Definition: STOFFSpreadsheetListener.cxx:1249
void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle())
adds a textbox in given position
Definition: STOFFSpreadsheetListener.cxx:997
void closeLink()
close a link
Definition: STOFFSpreadsheetListener.cxx:419
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:754
void insertChart(STOFFPosition const &pos, STOFFChart &chart, STOFFGraphicStyle const &style=STOFFGraphicStyle())
adds a chart in given position
Definition: STOFFSpreadsheetListener.cxx:1501
void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style)
adds a shape picture in given position
Definition: STOFFSpreadsheetListener.cxx:1030
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: STOFFSpreadsheetListener.cxx:356
void setDocumentLanguage(std::string locale)
sets the document language
Definition: STOFFSpreadsheetListener.cxx:433
void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1, 1))
add empty cell
Definition: STOFFSpreadsheetListener.cxx:1596
void closeTable()
closes this table
Definition: STOFFSpreadsheetListener.cxx:1551
Class to store font.
Definition: STOFFFont.hxx:43
void startDocument()
starts the document
Definition: STOFFSpreadsheetListener.cxx:451
bool isPageSpanOpened() const
returns true if a page is opened
Definition: STOFFSpreadsheetListener.cxx:497
void openSheetRow(float h, librevenge::RVNGUnit unit, int numRepeated=1)
open a row with given height ( if h < 0.0, set min-row-height = -h )
Definition: STOFFSpreadsheetListener.cxx:1321
shared_ptr< STOFFSpreadsheetListenerInternal::State > m_ps
the actual local parse state
Definition: STOFFSpreadsheetListener.hxx:290
bool openSection(STOFFSection const &section)
open a section if possible
Definition: STOFFSpreadsheetListener.cxx:663
bool isDocumentStarted() const
returns true if a document is opened
Definition: STOFFSpreadsheetListener.cxx:446
bool isGraphicStyleDefined(librevenge::RVNGString const &name) const
check if a graphic style with a display name is already defined
Definition: STOFFSpreadsheetListener.cxx:229
void _closeParagraph()
Definition: STOFFSpreadsheetListener.cxx:696
bool openHeader(librevenge::RVNGPropertyList const &extras)
open a header (interaction with STOFFPageSpan which fills the parameters for openHeader) ...
Definition: STOFFSpreadsheetListener.cxx:571
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:74
BreakType
the different break type
Definition: STOFFListener.hxx:58
STOFFFont const & getFont() const
returns the actual font
Definition: STOFFSpreadsheetListener.cxx:351
void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument)
insert a note
Definition: STOFFSpreadsheetListener.cxx:909
void _flushText()
Definition: STOFFSpreadsheetListener.cxx:878
void _closePageSpan()
does close a page (low level)
Definition: STOFFSpreadsheetListener.cxx:554
void _resetParagraphState(const bool isListElement=false)
Definition: STOFFSpreadsheetListener.cxx:717
bool openFooter(librevenge::RVNGPropertyList const &extras)
open a footer (interaction with STOFFPageSpan which fills the parameters for openFooter) ...
Definition: STOFFSpreadsheetListener.cxx:612
bool closeFooter()
close a footer
Definition: STOFFSpreadsheetListener.cxx:642
This class contains a virtual interface to all listener.
Definition: STOFFListener.hxx:49
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:44
void closeTableRow()
closes this row
Definition: STOFFSpreadsheetListener.cxx:1586
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47
void openTable(STOFFTable const &table)
open a table
Definition: STOFFSpreadsheetListener.cxx:1526
void _endSubDocument()
Definition: STOFFSpreadsheetListener.cxx:1255
Type getType() const
returns the listener type
Definition: STOFFSpreadsheetListener.hxx:73
STOFFParserState & m_parserState
the parser state
Definition: STOFFSpreadsheetListener.hxx:294

Generated on Mon Feb 22 2016 01:18:22 for libstaroffice by doxygen 1.8.10