LotusSpreadsheet.h Source File documentation

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
35namespace LotusSpreadsheetInternal
36{
37class Cell;
38class Spreadsheet;
39struct Style;
40struct State;
41struct Table123Styles;
42class SubDocument;
43}
44
45class LotusParser;
46class LotusStyleManager;
47
52 class LotusSpreadsheet
53{
54public:
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 }
71
72 void setLastSpreadsheetId(int id);
73
74 // interface which LotusParser
75
77 bool getLeftTopPosition(Vec2i const &cell, int spreadsheet, Vec2f &pos);
78protected:
80 int version() const;
82 bool hasSomeSpreadsheetData() const;
83
85 void sendSpreadsheet(int sheetId);
87 librevenge::RVNGString getSheetName(int id) const;
88
92 void sendRowContent(LotusSpreadsheetInternal::Spreadsheet const &sheet, int row, LotusSpreadsheetInternal::Table123Styles const *table123Styles);
94 void sendCellContent(LotusSpreadsheetInternal::Cell const &cell,
95 LotusSpreadsheetInternal::Style const &style, int numRepeated=1);
97 void sendText(RVNGInputStreamPtr &input, long endPos, LotusSpreadsheetInternal::Style const &style) const;
99 void sendTextNote(RVNGInputStreamPtr &input, WPSEntry const &entry) const;
100
102
103 //
104 // low level
105 //
107
109 bool readSheetName(std::shared_ptr<WPSStream> stream);
111 bool readSheetName1B(std::shared_ptr<WPSStream> stream, long endPos);
112
114 bool readCellsFormat801(std::shared_ptr<WPSStream> stream, WPSVec3i const &minC, WPSVec3i const &maxC, int typeZone);
116 bool readColumnDefinition(std::shared_ptr<WPSStream> stream);
118 bool readColumnSizes(std::shared_ptr<WPSStream> stream);
120 bool readRowFormats(std::shared_ptr<WPSStream> stream);
122 bool readRowFormat(std::shared_ptr<WPSStream> stream, LotusSpreadsheetInternal::Style &style, int &numCell, long endPos);
124 bool readRowSizes(std::shared_ptr<WPSStream> stream, long endPos);
125
127 bool readCell(std::shared_ptr<WPSStream> stream);
129 bool readCellName(std::shared_ptr<WPSStream> stream);
130
131 // in fmt
132
134 bool readSheetHeader(std::shared_ptr<WPSStream> stream);
136 bool readExtraRowFormats(std::shared_ptr<WPSStream> stream);
137
138 // in zone 0x1b
139
141 static bool readNote(std::shared_ptr<WPSStream> stream, long endPos);
142
143 // data in formula
144
145 /* reads a cell */
146 bool readCell(WPSStream &stream, int sId, bool isList, WKSContentListener::FormulaInstruction &instr);
147 /* reads a formula */
148 bool readFormula(WPSStream &stream, long endPos, int sId, bool newFormula,
149 std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error);
150 /* try to parse a variable data */
151 static bool parseVariable(std::string const &variable, WKSContentListener::FormulaInstruction &instr);
153 static std::string getDebugStringForText(std::string const &text);
154private:
155 LotusSpreadsheet(LotusSpreadsheet const &orig) = delete;
156 LotusSpreadsheet &operator=(LotusSpreadsheet const &orig) = delete;
157 std::shared_ptr<WKSContentListener> m_listener;
159 LotusParser &m_mainParser;
161 std::shared_ptr<LotusStyleManager> m_styleManager;
163 std::shared_ptr<LotusSpreadsheetInternal::State> m_state;
164};
165
166#endif /* LOTUS_SPREAD_SHEET_H */
167/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WKSContentListener.h
WPSDebug.h
LotusParser
This class parses a wk3,wk4,123 Lotus spreadsheet.
Definition Lotus.h:73
LotusSpreadsheetInternal::Cell
a cellule of a Lotus spreadsheet
Definition LotusSpreadsheet.cpp:220
LotusSpreadsheetInternal::Spreadsheet
the spreadsheet of a LotusSpreadsheet
Definition LotusSpreadsheet.cpp:295
LotusSpreadsheetInternal::SubDocument
Internal: the subdocument of a LotusSpreadsheet.
Definition LotusSpreadsheet.cpp:754
LotusSpreadsheet::readExtraRowFormats
bool readExtraRowFormats(std::shared_ptr< WPSStream > stream)
try to read an extra row format: 0xc5
Definition LotusSpreadsheet.cpp:1923
LotusSpreadsheet::readSheetName
bool readSheetName(std::shared_ptr< WPSStream > stream)
reads a sheet name: zone 0x23
Definition LotusSpreadsheet.cpp:1821
LotusSpreadsheet::readColumnDefinition
bool readColumnDefinition(std::shared_ptr< WPSStream > stream)
reads the columns definitions
Definition LotusSpreadsheet.cpp:937
LotusSpreadsheet::LotusSpreadsheet
LotusSpreadsheet(LotusParser &parser)
constructor
Definition LotusSpreadsheet.cpp:800
LotusSpreadsheet::hasSomeSpreadsheetData
bool hasSomeSpreadsheetData() const
returns true if some spreadsheet are defined
Definition LotusSpreadsheet.cpp:921
LotusSpreadsheet::readRowSizes
bool readRowSizes(std::shared_ptr< WPSStream > stream, long endPos)
reads the row size ( in pt*32 )
Definition LotusSpreadsheet.cpp:1759
LotusSpreadsheet::readCellsFormat801
bool readCellsFormat801(std::shared_ptr< WPSStream > stream, WPSVec3i const &minC, WPSVec3i const &maxC, int typeZone)
reads a cell zone formats: zone 801, lotus 123
Definition LotusSpreadsheet.cpp:1406
LotusSpreadsheet::sendText
void sendText(RVNGInputStreamPtr &input, long endPos, LotusSpreadsheetInternal::Style const &style) const
try to send a formated text
Definition LotusSpreadsheet.cpp:3340
LotusSpreadsheet::setLastSpreadsheetId
void setLastSpreadsheetId(int id)
set the last spreadsheet number ( default 0)
Definition LotusSpreadsheet.cpp:904
LotusSpreadsheet::parseVariable
static bool parseVariable(std::string const &variable, WKSContentListener::FormulaInstruction &instr)
Definition LotusSpreadsheet.cpp:2784
LotusSpreadsheet::getSheetName
librevenge::RVNGString getSheetName(int id) const
returns the name of the id's spreadsheet
Definition LotusSpreadsheet.cpp:831
LotusSpreadsheet::readColumnSizes
bool readColumnSizes(std::shared_ptr< WPSStream > stream)
reads the column sizes ( in char )
Definition LotusSpreadsheet.cpp:1019
LotusSpreadsheet::sendTextNote
void sendTextNote(RVNGInputStreamPtr &input, WPSEntry const &entry) const
try to send a note
Definition LotusSpreadsheet.cpp:3442
LotusSpreadsheet::m_listener
std::shared_ptr< WKSContentListener > m_listener
Definition LotusSpreadsheet.h:157
LotusSpreadsheet::readNote
static bool readNote(std::shared_ptr< WPSStream > stream, long endPos)
try to read a note: subZone id 9065
Definition LotusSpreadsheet.cpp:3299
LotusSpreadsheet::getDebugStringForText
static std::string getDebugStringForText(std::string const &text)
small debug function used to print text with format sequence
Definition LotusSpreadsheet.cpp:3485
LotusSpreadsheet::LotusSpreadsheet
LotusSpreadsheet(LotusSpreadsheet const &orig)=delete
LotusSpreadsheet::m_styleManager
std::shared_ptr< LotusStyleManager > m_styleManager
the style manager
Definition LotusSpreadsheet.h:161
LotusSpreadsheet::sendSpreadsheet
void sendSpreadsheet(int sheetId)
send the data
Definition LotusSpreadsheet.cpp:2408
LotusSpreadsheet::LotusParser
friend class LotusParser
Definition LotusSpreadsheet.h:55
LotusSpreadsheet::readCellName
bool readCellName(std::shared_ptr< WPSStream > stream)
reads a cell or list of cell name
Definition LotusSpreadsheet.cpp:2034
LotusSpreadsheet::operator=
LotusSpreadsheet & operator=(LotusSpreadsheet const &orig)=delete
LotusSpreadsheet::setListener
void setListener(WKSContentListenerPtr &listen)
sets the listener
Definition LotusSpreadsheet.h:67
LotusSpreadsheet::cleanState
void cleanState()
clean internal state
Definition LotusSpreadsheet.cpp:812
LotusSpreadsheet::updateState
void updateState()
update internal state (must be called one time before sending data)
Definition LotusSpreadsheet.cpp:836
LotusSpreadsheet::sendRowContent
void sendRowContent(LotusSpreadsheetInternal::Spreadsheet const &sheet, int row, LotusSpreadsheetInternal::Table123Styles const *table123Styles)
send the cell data in a row
Definition LotusSpreadsheet.cpp:2504
LotusSpreadsheet::~LotusSpreadsheet
~LotusSpreadsheet()
destructor
Definition LotusSpreadsheet.cpp:808
LotusSpreadsheet::m_mainParser
LotusParser & m_mainParser
the listener (if set)
Definition LotusSpreadsheet.h:159
LotusSpreadsheet::readSheetName1B
bool readSheetName1B(std::shared_ptr< WPSStream > stream, long endPos)
reads a sheet name: zone 0x1b 36b0
Definition LotusSpreadsheet.cpp:3259
LotusSpreadsheet::readRowFormat
bool readRowFormat(std::shared_ptr< WPSStream > stream, LotusSpreadsheetInternal::Style &style, int &numCell, long endPos)
reads a cell's row format
Definition LotusSpreadsheet.cpp:1200
LotusSpreadsheet::version
int version() const
return the file version
Definition LotusSpreadsheet.cpp:914
LotusSpreadsheet::readSheetHeader
bool readSheetHeader(std::shared_ptr< WPSStream > stream)
try to read a sheet header: 0xc3
Definition LotusSpreadsheet.cpp:1879
LotusSpreadsheet::m_state
std::shared_ptr< LotusSpreadsheetInternal::State > m_state
the internal state
Definition LotusSpreadsheet.h:163
LotusSpreadsheet::sendCellContent
void sendCellContent(LotusSpreadsheetInternal::Cell const &cell, LotusSpreadsheetInternal::Style const &style, int numRepeated=1)
send the cell data
Definition LotusSpreadsheet.cpp:2735
LotusSpreadsheet::readCell
bool readCell(std::shared_ptr< WPSStream > stream)
reads a cell
Definition LotusSpreadsheet.cpp:2109
LotusSpreadsheet::getLeftTopPosition
bool getLeftTopPosition(Vec2i const &cell, int spreadsheet, Vec2f &pos)
returns the left top position of a cell
Definition LotusSpreadsheet.cpp:817
LotusSpreadsheet::readFormula
bool readFormula(WPSStream &stream, long endPos, int sId, bool newFormula, std::vector< WKSContentListener::FormulaInstruction > &formula, std::string &error)
Definition LotusSpreadsheet.cpp:2922
LotusSpreadsheet::readRowFormats
bool readRowFormats(std::shared_ptr< WPSStream > stream)
reads the row formats
Definition LotusSpreadsheet.cpp:1073
LotusStyleManager
This class parses the Lotus style.
Definition LotusStyleManager.h:51
WPSEntry
basic class to store an entry in a file This contained :
Definition WPSEntry.h:39
libwps_internal.h
WKSContentListenerPtr
std::shared_ptr< WKSContentListener > WKSContentListenerPtr
shared pointer to WKSContentListener
Definition libwps_internal.h:114
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition libwps_internal.h:702
Vec2f
Vec2< float > Vec2f
Vec2 of float.
Definition libwps_internal.h:704
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition libwps_internal.h:87
WPSVec3i
WPSVec3< int > WPSVec3i
WPSVec3 of int.
Definition libwps_internal.h:1067
LotusSpreadsheetInternal
Definition LotusSpreadsheet.cpp:55
LotusSpreadsheetInternal::State
the state of LotusSpreadsheet
Definition LotusSpreadsheet.cpp:654
LotusSpreadsheetInternal::Style
a class used to store a style of a cell in LotusSpreadsheet
Definition LotusSpreadsheet.cpp:60
LotusSpreadsheetInternal::Table123Styles
a class used to store the styles of a table in LotusSpreadsheet in a lotus 123 files
Definition LotusSpreadsheet.cpp:570
WKSContentListener::FormulaInstruction
small class use to define a formula instruction
Definition WKSContentListener.h:58
WPSStream
small structure use to store a stream and it debug file
Definition WPSStream.h:30