MWAWSpreadsheetListener.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_SPREADSHEET_LISTENER_H
41 #define MWAW_SPREADSHEET_LISTENER_H
42 
43 #include <vector>
44 
45 #include <librevenge/librevenge.h>
46 
47 #include "libmwaw_internal.hxx"
48 
49 #include "MWAWListener.hxx"
50 
51 class MWAWCell;
52 class MWAWCellContent;
53 class MWAWChart;
54 class MWAWGraphicStyle;
55 class MWAWGraphicShape;
56 class MWAWTable;
57 
59 {
60 struct DocumentState;
61 struct State;
62 }
63 
66 {
67 public:
69  MWAWSpreadsheetListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGSpreadsheetInterface *documentInterface);
73  MWAWSpreadsheetListener(MWAWParserState &parserState, MWAWBox2f const &box, librevenge::RVNGSpreadsheetInterface *documentInterface);
75  virtual ~MWAWSpreadsheetListener();
76 
78  Type getType() const
79  {
80  return Spreadsheet;
81  }
82 
84  void setDocumentLanguage(std::string locale);
85 
87  void startDocument();
89  void endDocument(bool sendDelayedSubDoc=true);
91  bool isDocumentStarted() const;
92 
94  void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
96  bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
100  void closeFrame();
102  bool openGroup(MWAWPosition const &pos);
104  void closeGroup();
105 
107  bool canWriteText() const;
108 
109  // ------ page --------
111  bool isPageSpanOpened() const;
115  MWAWPageSpan const &getPageSpan();
116 
117  // ------ header/footer --------
119  bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
121  bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
123  bool isHeaderFooterOpened() const;
124 
125  // ------- sheet -----------------
127  void openSheet(std::vector<float> const &colWidth, librevenge::RVNGUnit unit, std::string const &name="");
129  void closeSheet();
131  void openSheetRow(float h, librevenge::RVNGUnit unit);
133  void closeSheetRow();
135  void openSheetCell(MWAWCell const &cell, MWAWCellContent const &content);
137  void closeSheetCell();
138 
139  // ------- chart -----------------
141  void insertChart(MWAWPosition const &pos, MWAWChart &chart,
143 
144  // ------ text data -----------
145 
147  void insertChar(uint8_t character);
150  void insertCharacter(unsigned char c);
156  int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
159  void insertUnicode(uint32_t character);
161  void insertUnicodeString(librevenge::RVNGString const &str);
162 
164  void insertTab();
166  void insertEOL(bool softBreak=false);
167 
168  // ------ text format -----------
170  void setFont(MWAWFont const &font);
172  MWAWFont const &getFont() const;
173 
174  // ------ paragraph format -----------
176  bool isParagraphOpened() const;
178  void setParagraph(MWAWParagraph const &paragraph);
180  MWAWParagraph const &getParagraph() const;
181 
182  // ------- fields ----------------
184  void insertField(MWAWField const &field);
185 
186  // ------- link ----------------
188  void openLink(MWAWLink const &link);
190  void closeLink();
191 
192  // ------- subdocument -----------------
194  void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
195 
197  void insertComment(MWAWSubDocumentPtr &subDocument);
198 
200  void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
203  void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape,
204  MWAWGraphicStyle const &style);
206  void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
207  MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle());
208 
209  // ------- table -----------------
211  void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
213  void openTable(MWAWTable const &table);
215  void closeTable();
217  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
219  void closeTableRow();
221  void openTableCell(MWAWCell const &cell);
223  void closeTableCell();
225  void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
226 
227  // ------- section ---------------
230  {
231  return false;
232  }
234  bool isSectionOpened() const
235  {
236  return false;
237  }
239  MWAWSection const &getSection() const;
241  bool openSection(MWAWSection const &section);
243  bool closeSection();
245  void insertBreak(BreakType breakType);
246 
247 protected:
249  void _openPageSpan(bool sendHeaderFooters=true);
251  void _closePageSpan();
252 
253  void _startSubDocument();
254  void _endSubDocument();
255 
256  void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos);
257 
258  void _openParagraph();
259  void _closeParagraph();
260  void _resetParagraphState(const bool isListElement=false);
261 
263  void _openListElement();
265  void _closeListElement();
267  void _changeList();
272  int _getListId() const;
273 
274  void _openSpan();
275  void _closeSpan();
276 
277  void _flushText();
278  void _flushDeferredTabs();
279 
283  shared_ptr<MWAWSpreadsheetListenerInternal::State> _pushParsingState();
285  void _popParsingState();
286 
287 protected:
289  shared_ptr<MWAWSpreadsheetListenerInternal::DocumentState> m_ds;
291  shared_ptr<MWAWSpreadsheetListenerInternal::State> m_ps;
293  std::vector<shared_ptr<MWAWSpreadsheetListenerInternal::State> > m_psStack;
297  librevenge::RVNGSpreadsheetInterface *m_documentInterface;
298 
299 private:
304 };
305 
306 #endif
307 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWSpreadsheetListener.cxx:748
void _openListElement()
open a list level
Definition: MWAWSpreadsheetListener.cxx:758
void closeFrame()
tries to close a frame
Definition: MWAWSpreadsheetListener.cxx:1233
void _flushText()
Definition: MWAWSpreadsheetListener.cxx:919
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWSpreadsheetListener.cxx:594
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWSpreadsheetListener.cxx:376
void _startSubDocument()
Definition: MWAWSpreadsheetListener.cxx:1539
void closeSheetRow()
closes this row
Definition: MWAWSpreadsheetListener.cxx:1624
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWSpreadsheetListener.hxx:234
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWSpreadsheetListener.cxx:337
void _popParsingState()
resets the previous parsing state
Definition: MWAWSpreadsheetListener.cxx:1939
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
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: MWAWSpreadsheetListener.cxx:1841
void openLink(MWAWLink const &link)
open a link
Definition: MWAWSpreadsheetListener.cxx:490
void _closeSpan()
Definition: MWAWSpreadsheetListener.cxx:885
librevenge::RVNGSpreadsheetInterface * m_documentInterface
the document interface
Definition: MWAWSpreadsheetListener.hxx:297
void insertTab()
adds a tab
Definition: MWAWSpreadsheetListener.cxx:360
void closeLink()
close a link
Definition: MWAWSpreadsheetListener.cxx:510
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWSpreadsheetListener.hxx:229
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWSpreadsheetListener.cxx:256
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWSpreadsheetListener.cxx:406
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
void closeSheet()
closes this sheet
Definition: MWAWSpreadsheetListener.cxx:1592
bool openGroup(MWAWPosition const &pos)
open a group (not implemented)
Definition: MWAWSpreadsheetListener.cxx:1163
Type
the listener type
Definition: MWAWListener.hxx:56
shared_ptr< MWAWSpreadsheetListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWSpreadsheetListener.hxx:291
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
shared_ptr< MWAWSpreadsheetListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWSpreadsheetListener.cxx:1928
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWSpreadsheetListener.cxx:426
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:503
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWSpreadsheetListener.cxx:401
small class use to define a sheet cell content
Definition: MWAWCell.hxx:356
void openSheetRow(float h, librevenge::RVNGUnit unit)
open a row with given height ( if h < 0.0, set min-row-height = -h )
Definition: MWAWSpreadsheetListener.cxx:1605
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos)
Definition: MWAWSpreadsheetListener.cxx:1244
Class to store font.
Definition: MWAWFont.hxx:43
a class to define the parser state
Definition: MWAWParser.hxx:49
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: MWAWSpreadsheetListener.cxx:325
BreakType
the different break type
Definition: MWAWListener.hxx:58
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWSpreadsheetListener.cxx:530
void endDocument(bool sendDelayedSubDoc=true)
ends the document
Definition: MWAWSpreadsheetListener.cxx:548
void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a picture with potential various representationin given position
Definition: MWAWSpreadsheetListener.cxx:1135
This class contents the main functions needed to create a spreadsheet processing Document.
Definition: MWAWSpreadsheetListener.hxx:65
void closeTableRow()
closes this row
Definition: MWAWSpreadsheetListener.cxx:1862
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWSpreadsheetListener.cxx:310
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWSpreadsheetListener.cxx:385
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWSpreadsheetListener.cxx:586
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWSpreadsheetListener.cxx:1003
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1))
add empty cell
Definition: MWAWSpreadsheetListener.cxx:1872
void _openParagraph()
Definition: MWAWSpreadsheetListener.cxx:708
void startDocument()
starts the document
Definition: MWAWSpreadsheetListener.cxx:535
void insertChart(MWAWPosition const &pos, MWAWChart &chart, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a chart in given position
Definition: MWAWSpreadsheetListener.cxx:1778
void closeTable()
closes this table
Definition: MWAWSpreadsheetListener.cxx:1827
void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a table in given position
Definition: MWAWSpreadsheetListener.cxx:1748
void _closeParagraph()
Definition: MWAWSpreadsheetListener.cxx:727
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWSpreadsheetListener.cxx:810
small class use to define a embedded object
Definition: libmwaw_internal.hxx:412
void _openSpan()
Definition: MWAWSpreadsheetListener.cxx:864
MWAWSpreadsheetListener & operator=(const MWAWSpreadsheetListener &)
operator= (unimplemented)
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWSpreadsheetListener.cxx:693
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
tries to open a frame
Definition: MWAWSpreadsheetListener.cxx:1173
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWSpreadsheetListener.cxx:793
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWSpreadsheetListener.cxx:950
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle())
adds a textbox in given position
Definition: MWAWSpreadsheetListener.cxx:1036
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWSpreadsheetListener.cxx:411
a class which stores section properties
Definition: MWAWSection.hxx:45
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:489
void closeTableCell()
close a cell
Definition: MWAWSpreadsheetListener.cxx:1908
Definition: MWAWListener.hxx:56
std::vector< shared_ptr< MWAWSpreadsheetListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWSpreadsheetListener.hxx:293
void openTable(MWAWTable const &table)
open a table
Definition: MWAWSpreadsheetListener.cxx:1803
void closeSheetCell()
close a cell
Definition: MWAWSpreadsheetListener.cxx:1734
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
virtual ~MWAWSpreadsheetListener()
destructor
Definition: MWAWSpreadsheetListener.cxx:229
shared_ptr< MWAWSpreadsheetListenerInternal::DocumentState > m_ds
the main parse state
Definition: MWAWSpreadsheetListener.hxx:289
bool canWriteText() const
returns true if we can add text data
Definition: MWAWSpreadsheetListener.cxx:236
class to store the paragraph properties
Definition: MWAWParagraph.hxx:81
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWSpreadsheetListener.cxx:418
a field
Definition: libmwaw_internal.hxx:360
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWSpreadsheetListener.cxx:1531
bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a header
Definition: MWAWSpreadsheetListener.cxx:657
Internal and low level namespace to define the states of MWAWSpreadsheetListener. ...
Definition: MWAWSpreadsheetListener.cxx:71
MWAWSpreadsheetListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGSpreadsheetInterface *documentInterface)
constructor
Definition: MWAWSpreadsheetListener.cxx:211
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWSpreadsheetListener.cxx:1468
void openSheetCell(MWAWCell const &cell, MWAWCellContent const &content)
open a cell
Definition: MWAWSpreadsheetListener.cxx:1634
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
void _flushDeferredTabs()
Definition: MWAWSpreadsheetListener.cxx:899
void _endSubDocument()
Definition: MWAWSpreadsheetListener.cxx:1545
void _closeListElement()
close a list level
Definition: MWAWSpreadsheetListener.cxx:780
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: MWAWSpreadsheetListener.cxx:524
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWSpreadsheetListener.cxx:241
MWAWParserState & m_parserState
the parser state
Definition: MWAWSpreadsheetListener.hxx:295
void _closePageSpan()
does close a page (low level)
Definition: MWAWSpreadsheetListener.cxx:640
bool closeSection()
close a section
Definition: MWAWSpreadsheetListener.cxx:699
void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style)
adds a shape picture in given position
Definition: MWAWSpreadsheetListener.cxx:1055
a class used to store a chart associated to a spreadsheet ....
Definition: MWAWChart.hxx:57
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWSpreadsheetListener.cxx:581
Type getType() const
returns the listener type
Definition: MWAWSpreadsheetListener.hxx:78
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWSpreadsheetListener.cxx:686
void openSheet(std::vector< float > const &colWidth, librevenge::RVNGUnit unit, std::string const &name="")
open a sheet
Definition: MWAWSpreadsheetListener.cxx:1561
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWSpreadsheetListener.cxx:652
bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a footer
Definition: MWAWSpreadsheetListener.cxx:670
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWSpreadsheetListener.cxx:1891
void closeGroup()
close a group (not implemented)
Definition: MWAWSpreadsheetListener.cxx:1169
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:269

Generated on Fri Aug 28 2015 11:04:35 for libmwaw by doxygen 1.8.9.1