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;
98  bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
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 -----------------
130  void openSheet(std::vector<float> const &colWidth, librevenge::RVNGUnit unit,
131  std::vector<int> const &repeatColWidthNumber=std::vector<int>(), std::string const &name="");
133  void closeSheet();
135  void openSheetRow(float h, librevenge::RVNGUnit unit, int numRepeated=1);
137  void closeSheetRow();
139  void openSheetCell(MWAWCell const &cell, MWAWCellContent const &content, int numRepeated=1);
141  void closeSheetCell();
142 
143  // ------- chart -----------------
145  void insertChart(MWAWPosition const &pos, MWAWChart &chart,
147 
148  // ------ text data -----------
149 
151  void insertChar(uint8_t character);
154  void insertCharacter(unsigned char c);
160  int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
163  void insertUnicode(uint32_t character);
165  void insertUnicodeString(librevenge::RVNGString const &str);
166 
168  void insertTab();
170  void insertEOL(bool softBreak=false);
171 
172  // ------ text format -----------
174  void setFont(MWAWFont const &font);
176  MWAWFont const &getFont() const;
177 
178  // ------ paragraph format -----------
180  bool isParagraphOpened() const;
182  void setParagraph(MWAWParagraph const &paragraph);
184  MWAWParagraph const &getParagraph() const;
185 
186  // ------- fields ----------------
188  void insertField(MWAWField const &field);
189 
190  // ------- link ----------------
192  void openLink(MWAWLink const &link);
194  void closeLink();
195 
196  // ------- subdocument -----------------
198  void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
199 
201  void insertComment(MWAWSubDocumentPtr &subDocument);
202 
204  void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
207  void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape,
208  MWAWGraphicStyle const &style);
210  void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
211  MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle());
212 
213  // ------- table -----------------
215  void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
217  void openTable(MWAWTable const &table);
219  void closeTable();
221  void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
223  void closeTableRow();
225  void openTableCell(MWAWCell const &cell);
227  void closeTableCell();
229  void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
230 
231  // ------- section ---------------
234  {
235  return false;
236  }
238  bool isSectionOpened() const
239  {
240  return false;
241  }
243  MWAWSection const &getSection() const;
245  bool openSection(MWAWSection const &section);
247  bool closeSection();
249  void insertBreak(BreakType breakType);
250 
251 protected:
253  void _openPageSpan(bool sendHeaderFooters=true);
255  void _closePageSpan();
256 
257  void _startSubDocument();
258  void _endSubDocument();
259 
260  void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos);
261 
262  void _openParagraph();
263  void _closeParagraph();
264  void _resetParagraphState(const bool isListElement=false);
265 
267  void _openListElement();
269  void _closeListElement();
271  void _changeList();
276  int _getListId() const;
277 
278  void _openSpan();
279  void _closeSpan();
280 
281  void _flushText();
282  void _flushDeferredTabs();
283 
287  shared_ptr<MWAWSpreadsheetListenerInternal::State> _pushParsingState();
289  void _popParsingState();
290 
291 protected:
293  shared_ptr<MWAWSpreadsheetListenerInternal::DocumentState> m_ds;
295  shared_ptr<MWAWSpreadsheetListenerInternal::State> m_ps;
297  std::vector<shared_ptr<MWAWSpreadsheetListenerInternal::State> > m_psStack;
301  librevenge::RVNGSpreadsheetInterface *m_documentInterface;
302 
303 private:
308 };
309 
310 #endif
311 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWSpreadsheetListener.hxx:238
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
librevenge::RVNGSpreadsheetInterface * m_documentInterface
the document interface
Definition: MWAWSpreadsheetListener.hxx:301
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWSpreadsheetListener.hxx:233
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:774
Type
the listener type
Definition: MWAWListener.hxx:56
shared_ptr< MWAWSpreadsheetListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWSpreadsheetListener.hxx:295
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:510
small class use to define a sheet cell content
Definition: MWAWCell.hxx:357
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
This class contents the main functions needed to create a spreadsheet processing Document.
Definition: MWAWSpreadsheetListener.hxx:65
small class use to define a embedded object
Definition: libmwaw_internal.hxx:419
a class which stores section properties
Definition: MWAWSection.hxx:45
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:496
std::vector< shared_ptr< MWAWSpreadsheetListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWSpreadsheetListener.hxx:297
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
shared_ptr< MWAWSpreadsheetListenerInternal::DocumentState > m_ds
the main parse state
Definition: MWAWSpreadsheetListener.hxx:293
class to store the paragraph properties
Definition: MWAWParagraph.hxx:81
a field
Definition: libmwaw_internal.hxx:363
Internal and low level namespace to define the states of MWAWSpreadsheetListener. ...
Definition: MWAWSpreadsheetListener.cxx:71
a note
Definition: libmwaw_internal.hxx:400
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
MWAWParserState & m_parserState
the parser state
Definition: MWAWSpreadsheetListener.hxx:299
a class used to store a chart associated to a spreadsheet ....
Definition: MWAWChart.hxx:57
Type getType() const
returns the listener type
Definition: MWAWSpreadsheetListener.hxx:78
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:269

Generated on Wed Jun 28 2017 09:26:20 for libmwaw by doxygen 1.8.11