LotusSpreadsheet.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2006, 2007 Andrew Ziem
11 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
12 * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
13 *
14 * For minor contributions see the git repository.
15 *
16 * Alternatively, the contents of this file may be used under the terms
17 * of the GNU Lesser General Public License Version 2.1 or later
18 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19 * applicable instead of those above.
20 */
21
22 #ifndef LOTUS_SPREADSHEET_H
23 #define LOTUS_SPREADSHEET_H
24
25 #include <ostream>
26 #include <vector>
27
28 #include <librevenge-stream/librevenge-stream.h>
29
30 #include "libwps_internal.h"
31
32 #include "WPSDebug.h"
33 #include "WKSContentListener.h"
34
35 namespace LotusSpreadsheetInternal
36 {
37 class Cell;
38 class Spreadsheet;
39 struct Style;
40 struct State;
41 struct Table123Styles;
42 class SubDocument;
43 }
44
45 class LotusParser;
46 class LotusStyleManager;
47
52 class LotusSpreadsheet
53 {
54 public:
55 friend class LotusParser;
56 friend class LotusSpreadsheetInternal::SubDocument;
57
59 explicit LotusSpreadsheet(LotusParser &parser);
61 ~LotusSpreadsheet();
63 void cleanState();
65 void updateState();
67 void setListener(WKSContentListenerPtr &listen)
68 {
69 m_listener = listen;
70 }
72 void setLastSpreadsheetId(int id);
73
74 // interface which LotusParser
75
77 bool getLeftTopPosition(Vec2i const &cell, int spreadsheet, Vec2f &pos);
78 protected:
80 int version() const;
82 bool hasSomeSpreadsheetData() const;
83
85 void sendSpreadsheet(int sheetId);
86
90 void sendRowContent(LotusSpreadsheetInternal::Spreadsheet const &sheet, int row, LotusSpreadsheetInternal::Table123Styles const *table123Styles);
92 void sendCellContent(LotusSpreadsheetInternal::Cell const &cell,
93 LotusSpreadsheetInternal::Style const &style, int numRepeated=1);
95 void sendText(RVNGInputStreamPtr &input, long endPos, LotusSpreadsheetInternal::Style const &style) const;
97 void sendTextNote(RVNGInputStreamPtr &input, WPSEntry const &entry) const;
98
100
101 //
102 // low level
103 //
105
107 bool readSheetName(shared_ptr<WPSStream> stream);
109 bool readSheetName1B(shared_ptr<WPSStream> stream, long endPos);
110
112 bool readCellsFormat801(shared_ptr<WPSStream> stream, WPSVec3i const &minC, WPSVec3i const &maxC, int typeZone);
114 bool readColumnDefinition(shared_ptr<WPSStream> stream);
116 bool readColumnSizes(shared_ptr<WPSStream> stream);
118 bool readRowFormats(shared_ptr<WPSStream> stream);
120 bool readRowFormat(shared_ptr<WPSStream> stream, LotusSpreadsheetInternal::Style &style, int &numCell, long endPos);
122 bool readRowSizes(shared_ptr<WPSStream> stream, long endPos);
123
125 bool readCell(shared_ptr<WPSStream> stream);
127 bool readCellName(shared_ptr<WPSStream> stream);
128
129 // in fmt
130
132 bool readSheetHeader(shared_ptr<WPSStream> stream);
134 bool readExtraRowFormats(shared_ptr<WPSStream> stream);
135
136 // in zone 0x1b
137
139 bool readNote(shared_ptr<WPSStream> stream, long endPos);
140
141 // data in formula
142
143 /* reads a cell */
144 bool readCell(WPSStream &stream, int sId, bool isList, WKSContentListener::FormulaInstruction &instr);
145 /* reads a formula */
146 bool readFormula(WPSStream &stream, long endPos, int sId, bool newFormula,
147 std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error);
148
150 static std::string getDebugStringForText(std::string const &text);
151 private:
152 LotusSpreadsheet(LotusSpreadsheet const &orig);
153 LotusSpreadsheet &operator=(LotusSpreadsheet const &orig);
154 shared_ptr<WKSContentListener> m_listener;
155 LotusParser &m_mainParser;
158 shared_ptr<LotusStyleManager> m_styleManager;
160 shared_ptr<LotusSpreadsheetInternal::State> m_state;
161 };
162
163 #endif /* LOTUS_SPREAD_SHEET_H */
164 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
LotusSpreadsheet::m_listener
shared_ptr< WKSContentListener > m_listener
Definition: LotusSpreadsheet.h:154
LotusSpreadsheetInternal::SubDocument
Internal: the subdocument of a LotusSpreadsheet.
Definition: LotusSpreadsheet.cpp:692
LotusSpreadsheetInternal::Cell
a cellule of a Lotus spreadsheet
Definition: LotusSpreadsheet.cpp:194
LotusSpreadsheetInternal::Table123Styles
a class used to store the styles of a table in LotusSpreadsheet in a lotus 123 files ...
Definition: LotusSpreadsheet.cpp:518
WKSContentListener.h
LotusSpreadsheetInternal::Style
a class used to store a style of a cell in LotusSpreadsheet
Definition: LotusSpreadsheet.cpp:55
LotusParser
This class parses a WK2..WK4 Lotus spreadsheet.
Definition: Lotus.h:66
LotusSpreadsheetInternal::SubDocument::operator=
SubDocument & operator=(SubDocument const &)
libwps_internal.h
WKSSubDocument::parser
WKSParser * parser() const
returns the parser
Definition: WKSSubDocument.h:44
WKSContentListenerPtr
shared_ptr< WKSContentListener > WKSContentListenerPtr
shared pointer to WKSContentListener
Definition: libwps_internal.h:115
LotusStyleManager
This class parses the Lotus style.
Definition: LotusStyleManager.h:47
LotusSpreadsheetInternal::Spreadsheet
the spreadsheet of a LotusSpreadsheet
Definition: LotusSpreadsheet.cpp:258
RVNGInputStreamPtr
shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:88
LotusSpreadsheet::setListener
void setListener(WKSContentListenerPtr &listen)
sets the listener
Definition: LotusSpreadsheet.h:67
LotusSpreadsheet
This class parses Microsoft Works spreadsheet file.
Definition: LotusSpreadsheet.h:52
LotusSpreadsheet::m_state
shared_ptr< LotusSpreadsheetInternal::State > m_state
the internal state
Definition: LotusSpreadsheet.h:160
LotusSpreadsheet::m_styleManager
shared_ptr< LotusStyleManager > m_styleManager
the style manager
Definition: LotusSpreadsheet.h:158
WPSEntry
basic class to store an entry in a file This contained :
Definition: WPSEntry.h:38
Vec2< int >
LotusSpreadsheetInternal
Definition: LotusSpreadsheet.cpp:50
WPSStream
small structure use to store a stream and it debug file
Definition: WPSStream.h:29
WKSContentListener::FormulaInstruction
small class use to define a formula instruction
Definition: WKSContentListener.h:56
WPSDebug.h
WPSVec3
small class which defines a vector with 3 elements
Definition: libwps_internal.h:912