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
51class MWAWCell;
52class MWAWCellContent;
53class MWAWChart;
56class MWAWTable;
57
59{
60struct DocumentState;
61struct State;
62}
63
66{
67public:
69 MWAWSpreadsheetListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGSpreadsheetInterface *documentInterface);
73 MWAWSpreadsheetListener(MWAWParserState &parserState, MWAWBox2f const &box, librevenge::RVNGSpreadsheetInterface *documentInterface);
76
78 Type getType() const
79 {
80 return Spreadsheet;
81 }
82
84 void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata);
86 void setDocumentLanguage(std::string const &locale);
87
89 void startDocument();
91 void endDocument(bool sendDelayedSubDoc=true);
93 bool isDocumentStarted() const;
94
96 void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
98 bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
102 void closeFrame();
104 bool openGroup(MWAWPosition const &pos);
106 void closeGroup();
107
109 bool canWriteText() const;
110
111 // ------ page --------
113 bool isPageSpanOpened() const;
117 MWAWPageSpan const &getPageSpan();
118
119 // ------ header/footer --------
121 bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
123 bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras);
125 bool isHeaderFooterOpened() const;
126
127 // ------- sheet -----------------
132 void openSheet(std::vector<float> const &colWidth, librevenge::RVNGUnit unit,
133 std::vector<int> const &repeatColWidthNumber=std::vector<int>(), std::string const &name="");
135 void closeSheet();
137 void openSheetRow(float h, librevenge::RVNGUnit unit, int numRepeated=1);
139 void closeSheetRow();
141 void openSheetCell(MWAWCell const &cell, MWAWCellContent const &content, int numRepeated=1);
143 void closeSheetCell();
144
145 // ------- chart -----------------
147 void insertChart(MWAWPosition const &pos, MWAWChart &chart,
149
150 // ------ text data -----------
151
153 void insertChar(uint8_t character);
156 void insertCharacter(unsigned char c);
162 int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
165 void insertUnicode(uint32_t character);
167 void insertUnicodeString(librevenge::RVNGString const &str);
168
170 void insertTab();
172 void insertEOL(bool softBreak=false);
173
174 // ------ text format -----------
176 void setFont(MWAWFont const &font);
178 MWAWFont const &getFont() const;
179
180 // ------ paragraph format -----------
182 bool isParagraphOpened() const;
184 void setParagraph(MWAWParagraph const &paragraph);
186 MWAWParagraph const &getParagraph() const;
187
188 // ------- fields ----------------
190 void insertField(MWAWField const &field);
191
192 // ------- link ----------------
194 void openLink(MWAWLink const &link);
196 void closeLink();
197
198 // ------- subdocument -----------------
200 void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
201
203 void insertComment(MWAWSubDocumentPtr &subDocument);
204
206 void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
209 void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape,
210 MWAWGraphicStyle const &style);
212 void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
214
215 // ------- table -----------------
217 void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
219 void openTable(MWAWTable const &table);
221 void closeTable();
223 void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false);
225 void closeTableRow();
227 void openTableCell(MWAWCell const &cell);
229 void closeTableCell();
231 void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1));
232
233 // ------- section ---------------
236 {
237 return false;
238 }
240 bool isSectionOpened() const
241 {
242 return false;
243 }
245 MWAWSection const &getSection() const;
247 bool openSection(MWAWSection const &section);
249 bool closeSection();
251 void insertBreak(BreakType breakType);
252
253protected:
255 void _openPageSpan(bool sendHeaderFooters=true);
257 void _closePageSpan();
258
259 void _startSubDocument();
260 void _endSubDocument();
261
262 void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos);
263
264 void _openParagraph();
265 void _closeParagraph();
266 void _resetParagraphState(const bool isListElement=false);
267
269 void _openListElement();
271 void _closeListElement();
273 void _changeList();
278 int _getListId() const;
279
280 void _openSpan();
281 void _closeSpan();
282
283 void _flushText();
284 void _flushDeferredTabs();
285
289 shared_ptr<MWAWSpreadsheetListenerInternal::State> _pushParsingState();
291 void _popParsingState();
292
293protected:
295 shared_ptr<MWAWSpreadsheetListenerInternal::DocumentState> m_ds;
297 shared_ptr<MWAWSpreadsheetListenerInternal::State> m_ps;
299 std::vector<shared_ptr<MWAWSpreadsheetListenerInternal::State> > m_psStack;
303 librevenge::RVNGSpreadsheetInterface *m_documentInterface;
304
305private:
310};
311
312#endif
313// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
small class use to define a sheet cell content
Definition: MWAWCell.hxx:356
a structure used to define a cell and its format
Definition: MWAWCell.hxx:53
a class used to store a chart associated to a spreadsheet ....
Definition: MWAWChart.hxx:58
Class to store font.
Definition: MWAWFont.hxx:44
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:46
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:268
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:50
Type
the listener type
Definition: MWAWListener.hxx:56
@ Spreadsheet
Definition: MWAWListener.hxx:56
BreakType
the different break type
Definition: MWAWListener.hxx:58
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:96
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
a class to define the parser state
Definition: MWAWParser.hxx:50
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
a class which stores section properties
Definition: MWAWSection.hxx:46
This class contents the main functions needed to create a spreadsheet processing Document.
Definition: MWAWSpreadsheetListener.hxx:66
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWSpreadsheetListener.cxx:619
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWSpreadsheetListener.hxx:240
void closeTableCell()
close a cell
Definition: MWAWSpreadsheetListener.cxx:1934
void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style)
adds a shape picture in given position
Definition: MWAWSpreadsheetListener.cxx:1025
MWAWSpreadsheetListener(const MWAWSpreadsheetListener &)
copy constructor (unimplemented)
shared_ptr< MWAWSpreadsheetListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWSpreadsheetListener.hxx:297
bool canWriteText() const
returns true if we can add text data
Definition: MWAWSpreadsheetListener.cxx:237
Type getType() const
returns the listener type
Definition: MWAWSpreadsheetListener.hxx:78
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWSpreadsheetListener.cxx:402
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWSpreadsheetListener.cxx:338
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWSpreadsheetListener.cxx:1479
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWSpreadsheetListener.cxx:653
void _openListElement()
open a list level
Definition: MWAWSpreadsheetListener.cxx:724
void openSheet(std::vector< float > const &colWidth, librevenge::RVNGUnit unit, std::vector< int > const &repeatColWidthNumber=std::vector< int >(), std::string const &name="")
opens a sheet
Definition: MWAWSpreadsheetListener.cxx:1574
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWSpreadsheetListener.cxx:257
MWAWParserState & m_parserState
the parser state
Definition: MWAWSpreadsheetListener.hxx:301
bool openGroup(MWAWPosition const &pos)
open a group (not implemented)
Definition: MWAWSpreadsheetListener.cxx:1138
bool insertFooter(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a footer
Definition: MWAWSpreadsheetListener.cxx:637
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWSpreadsheetListener.cxx:776
void _closeListElement()
close a list level
Definition: MWAWSpreadsheetListener.cxx:746
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWSpreadsheetListener.cxx:920
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWSpreadsheetListener.cxx:407
shared_ptr< MWAWSpreadsheetListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWSpreadsheetListener.cxx:1954
bool insertHeader(MWAWSubDocumentPtr subDocument, librevenge::RVNGPropertyList const &extras)
insert a header
Definition: MWAWSpreadsheetListener.cxx:624
bool isDocumentStarted() const
returns true if a document is opened
Definition: MWAWSpreadsheetListener.cxx:497
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWSpreadsheetListener.cxx:419
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWSpreadsheetListener.cxx:377
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition: MWAWSpreadsheetListener.cxx:561
void setDocumentLanguage(std::string const &locale)
sets the documents language
Definition: MWAWSpreadsheetListener.cxx:491
void openSheetCell(MWAWCell const &cell, MWAWCellContent const &content, int numRepeated=1)
open a cell
Definition: MWAWSpreadsheetListener.cxx:1656
void _closeSpan()
Definition: MWAWSpreadsheetListener.cxx:855
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWSpreadsheetListener.cxx:412
void endDocument(bool sendDelayedSubDoc=true)
ends the document
Definition: MWAWSpreadsheetListener.cxx:515
void openLink(MWAWLink const &link)
open a link
Definition: MWAWSpreadsheetListener.cxx:450
std::vector< shared_ptr< MWAWSpreadsheetListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWSpreadsheetListener.hxx:299
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: MWAWSpreadsheetListener.cxx:1625
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWSpreadsheetListener.cxx:311
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWSpreadsheetListener.cxx:1917
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWSpreadsheetListener.cxx:973
void _openParagraph()
Definition: MWAWSpreadsheetListener.cxx:674
void closeSheetRow()
closes this row
Definition: MWAWSpreadsheetListener.cxx:1646
void closeLink()
close a link
Definition: MWAWSpreadsheetListener.cxx:470
void startDocument()
starts the document
Definition: MWAWSpreadsheetListener.cxx:502
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWSpreadsheetListener.cxx:1544
void _closePageSpan()
does close a page (low level)
Definition: MWAWSpreadsheetListener.cxx:607
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWSpreadsheetListener.cxx:386
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1))
add empty cell
Definition: MWAWSpreadsheetListener.cxx:1898
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWSpreadsheetListener.cxx:427
void openTable(MWAWTable const &table)
open a table
Definition: MWAWSpreadsheetListener.cxx:1829
shared_ptr< MWAWSpreadsheetListenerInternal::DocumentState > m_ds
the main parse state
Definition: MWAWSpreadsheetListener.hxx:295
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
tries to open a frame
Definition: MWAWSpreadsheetListener.cxx:1152
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle())
adds a textbox in given position
Definition: MWAWSpreadsheetListener.cxx:1006
void _flushText()
Definition: MWAWSpreadsheetListener.cxx:889
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:1110
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWSpreadsheetListener.cxx:659
void _closeParagraph()
Definition: MWAWSpreadsheetListener.cxx:693
void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata)
sets the documents metadata
Definition: MWAWSpreadsheetListener.cxx:484
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWSpreadsheetListener.cxx:242
void closeTable()
closes this table
Definition: MWAWSpreadsheetListener.cxx:1853
void _popParsingState()
resets the previous parsing state
Definition: MWAWSpreadsheetListener.cxx:1965
void closeTableRow()
closes this row
Definition: MWAWSpreadsheetListener.cxx:1888
void _startSubDocument()
Definition: MWAWSpreadsheetListener.cxx:1552
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWSpreadsheetListener.cxx:548
void insertUnicodeString(librevenge::RVNGString const &str)
adds a unicode string
Definition: MWAWSpreadsheetListener.cxx:326
void insertChart(MWAWPosition const &pos, MWAWChart &chart, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a chart in given position
Definition: MWAWSpreadsheetListener.cxx:1804
MWAWSpreadsheetListener & operator=(const MWAWSpreadsheetListener &)
operator= (unimplemented)
bool closeSection()
close a section
Definition: MWAWSpreadsheetListener.cxx:665
void insertTab()
adds a tab
Definition: MWAWSpreadsheetListener.cxx:361
bool canOpenSectionAddBreak() const
returns true if we can add open a section, add page break, ...
Definition: MWAWSpreadsheetListener.hxx:235
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level.
Definition: MWAWSpreadsheetListener.cxx:759
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWSpreadsheetListener.cxx:553
void insertTable(MWAWPosition const &pos, MWAWTable &table, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
adds a table in given position
Definition: MWAWSpreadsheetListener.cxx:1774
void closeSheetCell()
close a cell
Definition: MWAWSpreadsheetListener.cxx:1760
MWAWSpreadsheetListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGSpreadsheetInterface *documentInterface)
constructor
Definition: MWAWSpreadsheetListener.cxx:212
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:1867
librevenge::RVNGSpreadsheetInterface * m_documentInterface
the document interface
Definition: MWAWSpreadsheetListener.hxx:303
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWSpreadsheetListener.cxx:714
void _openSpan()
Definition: MWAWSpreadsheetListener.cxx:834
void closeGroup()
close a group (not implemented)
Definition: MWAWSpreadsheetListener.cxx:1148
void closeSheet()
closes this sheet
Definition: MWAWSpreadsheetListener.cxx:1612
void closeFrame()
tries to close a frame
Definition: MWAWSpreadsheetListener.cxx:1224
void _flushDeferredTabs()
Definition: MWAWSpreadsheetListener.cxx:869
void _endSubDocument()
Definition: MWAWSpreadsheetListener.cxx:1558
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos)
Definition: MWAWSpreadsheetListener.cxx:1235
virtual ~MWAWSpreadsheetListener()
destructor
Definition: MWAWSpreadsheetListener.cxx:230
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:52
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:781
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:517
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:503
Internal and low level namespace to define the states of MWAWSpreadsheetListener.
Definition: MWAWSpreadsheetListener.cxx:72
SubDocumentType
Definition: libmwaw_internal.hxx:178
small class use to define a embedded object
Definition: libmwaw_internal.hxx:425
a field
Definition: libmwaw_internal.hxx:369
a note
Definition: libmwaw_internal.hxx:406

Generated on Wed Jan 19 2022 22:23:16 for libmwaw by doxygen 1.9.3