QuattroSpreadsheet.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 QUATTRO_SPREADSHEET_H
23 #define QUATTRO_SPREADSHEET_H
24
25 #include <ostream>
26 #include <map>
27 #include <vector>
28
29 #include <librevenge-stream/librevenge-stream.h>
30
31 #include "libwps_internal.h"
32
33 #include "WPSDebug.h"
34 #include "WKSContentListener.h"
35
36 #include "QuattroFormula.h"
37
38 namespace QuattroSpreadsheetInternal
39 {
40 class Cell;
41 class SpreadSheet;
42 struct State;
43 }
44
45 class QuattroParser;
46
51 class QuattroSpreadsheet
52 {
53 public:
54 friend class QuattroParser;
55
57 explicit QuattroSpreadsheet(QuattroParser &parser);
59 ~QuattroSpreadsheet();
61 void setListener(WKSContentListenerPtr &listen)
62 {
63 m_listener = listen;
64 }
66 void cleanState();
68 void updateState();
69
70 protected:
72 int version() const;
74 QuattroFormulaManager::CellReferenceFunction getReadCellReferenceFunction();
75
77 int getNumSpreadsheets() const;
79 librevenge::RVNGString getSheetName(int id) const;
81 void sendSpreadsheet(int sheetId, std::vector<Vec2i> const &listGraphicCells);
83 Vec2f getPosition(int sheetId, Vec2i const &cell) const;
85 void sendCellContent(QuattroSpreadsheetInternal::Cell const &cell, int sheetId);
86
88 void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1);
90 void addUserFormat(int id, librevenge::RVNGString const &name);
91
92 //
93 // low level
94 //
96
98 bool readCell(std::shared_ptr<WPSStream> const &stream);
100 bool readSheetSize(std::shared_ptr<WPSStream> const &stream);
102 bool readColumnRowDefaultSize(std::shared_ptr<WPSStream> const &stream);
104 bool readColumnSize(std::shared_ptr<WPSStream> const &stream);
106 bool readRowSize(std::shared_ptr<WPSStream> const &stream);
108 bool readRowRangeSize(std::shared_ptr<WPSStream> const &stream);
109
111 bool readBeginEndSheet(std::shared_ptr<WPSStream> const &stream, int &sheetId);
113 bool readSheetName(std::shared_ptr<WPSStream> const &stream);
115 bool readCellStyle(std::shared_ptr<WPSStream> const &stream);
116
118 bool readViewInfo(std::shared_ptr<WPSStream> const &stream);
119
120 /* reads a cell */
121 bool readCell(std::shared_ptr<WPSStream> const &stream, Vec2i actPos, WKSContentListener::FormulaInstruction &instr, int sheetId, librevenge::RVNGString const &fName) const;
123 void updateCellWithUserFormat(QuattroSpreadsheetInternal::Cell &cell, librevenge::RVNGString const &format);
125 bool readCellReference(std::shared_ptr<WPSStream> const &stream, long endPos,
126 QuattroFormulaInternal::CellReference &ref,
127 Vec2i const &pos=Vec2i(0,0), int sheetId=0) const;
128
129 private:
130 QuattroSpreadsheet(QuattroSpreadsheet const &orig) = delete;
131 QuattroSpreadsheet &operator=(QuattroSpreadsheet const &orig) = delete;
132 std::shared_ptr<WKSContentListener> m_listener;
133 QuattroParser &m_mainParser;
136 std::shared_ptr<QuattroSpreadsheetInternal::State> m_state;
137 };
138
139 #endif /* WPS4_H */
140 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
QuattroSpreadsheet::readRowRangeSize
bool readRowRangeSize(std::shared_ptr< WPSStream > const &stream)
reads the row size: zone 105,106
Definition: QuattroSpreadsheet.cpp:1230
QuattroSpreadsheet::readColumnRowDefaultSize
bool readColumnRowDefaultSize(std::shared_ptr< WPSStream > const &stream)
reads the sheet column/row default size: zone d2-d5
Definition: QuattroSpreadsheet.cpp:1087
QuattroSpreadsheet::updateCellWithUserFormat
void updateCellWithUserFormat(QuattroSpreadsheetInternal::Cell &cell, librevenge::RVNGString const &format)
try to update the cell&#39;s format using the user format
Definition: QuattroSpreadsheet.cpp:1675
QuattroSpreadsheet::m_state
std::shared_ptr< QuattroSpreadsheetInternal::State > m_state
the internal state
Definition: QuattroSpreadsheet.h:136
QuattroSpreadsheet::getSheetName
librevenge::RVNGString getSheetName(int id) const
returns the name of the id&#39;s spreadsheet
Definition: QuattroSpreadsheet.cpp:586
QuattroSpreadsheet::cleanState
void cleanState()
clean internal state
Definition: QuattroSpreadsheet.cpp:551
QuattroSpreadsheet::readCell
bool readCell(std::shared_ptr< WPSStream > const &stream)
reads a cell content data: zone 0xc-0x10 or 33
Definition: QuattroSpreadsheet.cpp:628
QuattroSpreadsheet::setListener
void setListener(WKSContentListenerPtr &listen)
sets the listener
Definition: QuattroSpreadsheet.h:61
QuattroSpreadsheet::addDLLIdName
void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1)
add a dll&#39;s correspondance between an id and a name
Definition: QuattroSpreadsheet.cpp:602
QuattroFormula.h
QuattroSpreadsheet::~QuattroSpreadsheet
~QuattroSpreadsheet()
destructor
Definition: QuattroSpreadsheet.cpp:547
QuattroSpreadsheet::readColumnSize
bool readColumnSize(std::shared_ptr< WPSStream > const &stream)
reads the column size: zone d8,d9
Definition: QuattroSpreadsheet.cpp:1127
QuattroSpreadsheet::operator=
QuattroSpreadsheet & operator=(QuattroSpreadsheet const &orig)=delete
WKSContentListener.h
QuattroSpreadsheet::readSheetName
bool readSheetName(std::shared_ptr< WPSStream > const &stream)
reads sheet name: zone cc
Definition: QuattroSpreadsheet.cpp:1330
QuattroSpreadsheet::m_mainParser
QuattroParser & m_mainParser
the listener (if set)
Definition: QuattroSpreadsheet.h:134
QuattroFormulaManager::CellReferenceFunction
std::function< bool(std::shared_ptr< WPSStream > const &stream, long endPos, QuattroFormulaInternal::CellReference &ref, Vec2i const &cPos, int cSheet)> CellReferenceFunction
Definition: QuattroFormula.h:81
QuattroSpreadsheet::readBeginEndSheet
bool readBeginEndSheet(std::shared_ptr< WPSStream > const &stream, int &sheetId)
read the begin/end of a sheet zone: zone ca and cb
Definition: QuattroSpreadsheet.cpp:1283
libwps_internal.h
libwps_tools_win::Language::name
std::string name(long id)
returns the name given Windows© id
Definition: libwps_tools_win.cpp:7332
QuattroSpreadsheet::readCellStyle
bool readCellStyle(std::shared_ptr< WPSStream > const &stream)
reads a cell attribute: zone 0xce
Definition: QuattroSpreadsheet.cpp:810
QuattroSpreadsheet::m_listener
std::shared_ptr< WKSContentListener > m_listener
Definition: QuattroSpreadsheet.h:132
QuattroSpreadsheet::sendSpreadsheet
void sendSpreadsheet(int sheetId, std::vector< Vec2i > const &listGraphicCells)
send the sheetId&#39;th spreadsheet
Definition: QuattroSpreadsheet.cpp:1586
QuattroParser
This class parses Quattro Pro spreadsheet: .wb1, ..., .wb3.
Definition: Quattro.h:53
QuattroSpreadsheet
This class parses Quattro Pro spreadsheet file.
Definition: QuattroSpreadsheet.h:51
QuattroSpreadsheet::sendCellContent
void sendCellContent(QuattroSpreadsheetInternal::Cell const &cell, int sheetId)
send the cell data
Definition: QuattroSpreadsheet.cpp:1900
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition: libwps_internal.h:702
QuattroSpreadsheet::getReadCellReferenceFunction
QuattroFormulaManager::CellReferenceFunction getReadCellReferenceFunction()
returns the function to read a cell&#39;s reference
Definition: QuattroSpreadsheet.cpp:567
QuattroSpreadsheet::readSheetSize
bool readSheetSize(std::shared_ptr< WPSStream > const &stream)
reads sheet size: zone 06
Definition: QuattroSpreadsheet.cpp:1046
QuattroSpreadsheet::readCellReference
bool readCellReference(std::shared_ptr< WPSStream > const &stream, long endPos, QuattroFormulaInternal::CellReference &ref, Vec2i const &pos=Vec2i(0, 0), int sheetId=0) const
try to read a cell reference
Definition: QuattroSpreadsheet.cpp:1495
QuattroSpreadsheet::readViewInfo
bool readViewInfo(std::shared_ptr< WPSStream > const &stream)
reads a view info: zone 197/198
Definition: QuattroSpreadsheet.cpp:1371
QuattroSpreadsheet::addUserFormat
void addUserFormat(int id, librevenge::RVNGString const &name)
add a user format&#39;s correspondance between an id and a name
Definition: QuattroSpreadsheet.cpp:607
QuattroSpreadsheet::readRowSize
bool readRowSize(std::shared_ptr< WPSStream > const &stream)
reads the row size: zone d6,d7
Definition: QuattroSpreadsheet.cpp:1181
QuattroSpreadsheetInternal::Cell
a cellule of a Quattro spreadsheet
Definition: QuattroSpreadsheet.cpp:110
WKSContentListenerPtr
std::shared_ptr< WKSContentListener > WKSContentListenerPtr
shared pointer to WKSContentListener
Definition: libwps_internal.h:114
Vec2< float >
QuattroSpreadsheet::QuattroSpreadsheet
QuattroSpreadsheet(QuattroParser &parser)
constructor
Definition: QuattroSpreadsheet.cpp:539
WKSContentListener::FormulaInstruction
small class use to define a formula instruction
Definition: WKSContentListener.h:57
QuattroFormulaInternal::CellReference
small class use to store Quattro Pro cell reference (.wb1-3 and qpw)
Definition: QuattroFormula.h:42
QuattroSpreadsheet::version
int version() const
return the file version
Definition: QuattroSpreadsheet.cpp:560
QuattroSpreadsheet::updateState
void updateState()
update the state (need to be called before sending data)
Definition: QuattroSpreadsheet.cpp:556
WPSDebug.h
QuattroSpreadsheet::getPosition
Vec2f getPosition(int sheetId, Vec2i const &cell) const
returns the beginning position of a cell
Definition: QuattroSpreadsheet.cpp:591
QuattroSpreadsheet::getNumSpreadsheets
int getNumSpreadsheets() const
returns the number of spreadsheet
Definition: QuattroSpreadsheet.cpp:577
QuattroSpreadsheetInternal
Definition: QuattroSpreadsheet.cpp:49