Quattro9Spreadsheet.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 QUATTRO9_SPREADSHEET_H
23#define QUATTRO9_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 Quattro9SpreadsheetInternal
39{
40 struct CellData;
41 class SpreadSheet;
42 struct State;
43}
44
45 namespace Quattro9ParserInternal
46{
47 struct TextEntry;
48}
49
50 class Quattro9Parser;
51
56 class Quattro9Spreadsheet
57{
58 public:
59 friend class Quattro9Parser;
60
62 explicit Quattro9Spreadsheet(Quattro9Parser &parser);
64 ~Quattro9Spreadsheet();
66 void setListener(WKSContentListenerPtr &listen)
67 {
68 m_listener = listen;
69 }
70
71 void cleanState();
73 void updateState();
74
75 protected:
77 int version() const;
79 QuattroFormulaManager::CellReferenceFunction getReadCellReferenceFunction();
80
82 int getNumSpreadsheets() const;
84 librevenge::RVNGString getSheetName(int id) const;
86 void sendSpreadsheet(int sheetId);
88 Vec2f getPosition(int sheetId, Vec2i const &cell) const;
90 void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1);
92 void addUserFormat(int id, librevenge::RVNGString const &name);
94 void addDocumentStrings(std::shared_ptr<WPSStream> const &stream,
95 std::vector<Quattro9ParserInternal::TextEntry> const &entries);
96
97 //
98 // low level
99 //
100
102 void sendCellContent(Quattro9SpreadsheetInternal::CellData const *cell, Vec2i pos, int sheetId, int numRepeated);
103
105 bool readCellStyles(std::shared_ptr<WPSStream> const &stream);
107 bool readDocumentFormulas(std::shared_ptr<WPSStream> const &stream);
109 bool readBeginSheet(std::shared_ptr<WPSStream> const &stream, int &sheetId);
111 bool readEndSheet(std::shared_ptr<WPSStream> const &stream);
113 static bool readPageBreak(std::shared_ptr<WPSStream> const &stream);
115 bool readMergedCells(std::shared_ptr<WPSStream> const &stream);
117 bool readColRowDefault(std::shared_ptr<WPSStream> const &stream);
119 bool readColRowDimension(std::shared_ptr<WPSStream> const &stream);
121 bool readColRowDimensions(std::shared_ptr<WPSStream> const &stream);
123 bool readBeginColumn(std::shared_ptr<WPSStream> const &stream);
125 bool readEndColumn(std::shared_ptr<WPSStream> const &stream);
127 bool readCellList(std::shared_ptr<WPSStream> const &stream);
129 bool readCellResult(std::shared_ptr<WPSStream> const &stream);
130
131 /* reads a cell */
132 static bool readCell(std::shared_ptr<WPSStream> const &stream, Vec2i actPos, WKSContentListener::FormulaInstruction &instr, int sheetId, librevenge::RVNGString const &fName);
134 bool readCellReference(std::shared_ptr<WPSStream> const &stream, long endPos,
135 QuattroFormulaInternal::CellReference &ref,
136 Vec2i const &pos=Vec2i(0,0), int sheetId=0) const;
138
139 private:
140 Quattro9Spreadsheet(Quattro9Spreadsheet const &orig) = delete;
141 Quattro9Spreadsheet &operator=(Quattro9Spreadsheet const &orig) = delete;
142 std::shared_ptr<WKSContentListener> m_listener;
144 Quattro9Parser &m_mainParser;
146 std::shared_ptr<Quattro9SpreadsheetInternal::State> m_state;
147};
148
149#endif /* WPS4_H */
150/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
QuattroFormula.h
WKSContentListener.h
WPSDebug.h
Quattro9Parser
This class parses Quattro Pro WP spreadsheet: .qpw.
Definition Quattro9.h:91
Quattro9Spreadsheet::sendCellContent
void sendCellContent(Quattro9SpreadsheetInternal::CellData const *cell, Vec2i pos, int sheetId, int numRepeated)
send the cell data
Definition Quattro9Spreadsheet.cpp:2044
Quattro9Spreadsheet::getPosition
Vec2f getPosition(int sheetId, Vec2i const &cell) const
returns the beginning position of a cell
Definition Quattro9Spreadsheet.cpp:835
Quattro9Spreadsheet::readEndColumn
bool readEndColumn(std::shared_ptr< WPSStream > const &stream)
read the end column zone: zone a02
Definition Quattro9Spreadsheet.cpp:1580
Quattro9Spreadsheet::readColRowDimension
bool readColRowDimension(std::shared_ptr< WPSStream > const &stream)
read a col/row dimension: zone 633, 634
Definition Quattro9Spreadsheet.cpp:1391
Quattro9Spreadsheet::readMergedCells
bool readMergedCells(std::shared_ptr< WPSStream > const &stream)
read the merged cell: zone 61d
Definition Quattro9Spreadsheet.cpp:1468
Quattro9Spreadsheet::readCellStyles
bool readCellStyles(std::shared_ptr< WPSStream > const &stream)
reads a cell attribute: zone a
Definition Quattro9Spreadsheet.cpp:891
Quattro9Spreadsheet::readCell
static bool readCell(std::shared_ptr< WPSStream > const &stream, Vec2i actPos, WKSContentListener::FormulaInstruction &instr, int sheetId, librevenge::RVNGString const &fName)
Definition Quattro9Spreadsheet.cpp:1879
Quattro9Spreadsheet::updateState
void updateState()
update the state (need to be called before sending data)
Definition Quattro9Spreadsheet.cpp:805
Quattro9Spreadsheet::readPageBreak
static bool readPageBreak(std::shared_ptr< WPSStream > const &stream)
read the page break zone: zone 617
Definition Quattro9Spreadsheet.cpp:1507
Quattro9Spreadsheet::getNumSpreadsheets
int getNumSpreadsheets() const
returns the number of spreadsheet
Definition Quattro9Spreadsheet.cpp:826
Quattro9Spreadsheet::m_state
std::shared_ptr< Quattro9SpreadsheetInternal::State > m_state
the internal state
Definition Quattro9Spreadsheet.h:146
Quattro9Spreadsheet::readDocumentFormulas
bool readDocumentFormulas(std::shared_ptr< WPSStream > const &stream)
reads the document formulas: zone 408
Definition Quattro9Spreadsheet.cpp:1189
Quattro9Spreadsheet::readBeginColumn
bool readBeginColumn(std::shared_ptr< WPSStream > const &stream)
read the begin column zone: zone a01
Definition Quattro9Spreadsheet.cpp:1541
Quattro9Spreadsheet::sendSpreadsheet
void sendSpreadsheet(int sheetId)
send the sheetId'th spreadsheet
Definition Quattro9Spreadsheet.cpp:2010
Quattro9Spreadsheet::setListener
void setListener(WKSContentListenerPtr &listen)
sets the listener
Definition Quattro9Spreadsheet.h:66
Quattro9Spreadsheet::readEndSheet
bool readEndSheet(std::shared_ptr< WPSStream > const &stream)
read the end sheet zone: zone 602
Definition Quattro9Spreadsheet.cpp:1338
Quattro9Spreadsheet::getSheetName
librevenge::RVNGString getSheetName(int id) const
returns the name of the id's spreadsheet
Definition Quattro9Spreadsheet.cpp:846
Quattro9Spreadsheet::~Quattro9Spreadsheet
~Quattro9Spreadsheet()
destructor
Definition Quattro9Spreadsheet.cpp:796
Quattro9Spreadsheet::readCellList
bool readCellList(std::shared_ptr< WPSStream > const &stream)
reads a cell list zone: zone c01
Definition Quattro9Spreadsheet.cpp:1595
Quattro9Spreadsheet::m_listener
std::shared_ptr< WKSContentListener > m_listener
Definition Quattro9Spreadsheet.h:142
Quattro9Spreadsheet::Quattro9Parser
friend class Quattro9Parser
Definition Quattro9Spreadsheet.h:59
Quattro9Spreadsheet::addDLLIdName
void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1)
add a dll's correspondance between an id and a name
Definition Quattro9Spreadsheet.cpp:851
Quattro9Spreadsheet::readBeginSheet
bool readBeginSheet(std::shared_ptr< WPSStream > const &stream, int &sheetId)
read the begin sheet zone: zone 601
Definition Quattro9Spreadsheet.cpp:1258
Quattro9Spreadsheet::readColRowDefault
bool readColRowDefault(std::shared_ptr< WPSStream > const &stream)
read a col/row default dimension: zone 631, 632
Definition Quattro9Spreadsheet.cpp:1355
Quattro9Spreadsheet::Quattro9Spreadsheet
Quattro9Spreadsheet(Quattro9Parser &parser)
constructor
Definition Quattro9Spreadsheet.cpp:788
Quattro9Spreadsheet::readColRowDimensions
bool readColRowDimensions(std::shared_ptr< WPSStream > const &stream)
read a col/row dimensions: zone 635, 636
Definition Quattro9Spreadsheet.cpp:1429
Quattro9Spreadsheet::Quattro9Spreadsheet
Quattro9Spreadsheet(Quattro9Spreadsheet const &orig)=delete
Quattro9Spreadsheet::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 Quattro9Spreadsheet.cpp:1918
Quattro9Spreadsheet::addDocumentStrings
void addDocumentStrings(std::shared_ptr< WPSStream > const &stream, std::vector< Quattro9ParserInternal::TextEntry > const &entries)
set the document strings list
Definition Quattro9Spreadsheet.cpp:871
Quattro9Spreadsheet::operator=
Quattro9Spreadsheet & operator=(Quattro9Spreadsheet const &orig)=delete
Quattro9Spreadsheet::addUserFormat
void addUserFormat(int id, librevenge::RVNGString const &name)
add a user format's correspondance between an id and a name
Definition Quattro9Spreadsheet.cpp:856
Quattro9Spreadsheet::readCellResult
bool readCellResult(std::shared_ptr< WPSStream > const &stream)
reads a cell result zone: zone c02
Definition Quattro9Spreadsheet.cpp:1829
Quattro9Spreadsheet::version
int version() const
return the file version
Definition Quattro9Spreadsheet.cpp:809
Quattro9Spreadsheet::cleanState
void cleanState()
clean internal state
Definition Quattro9Spreadsheet.cpp:800
Quattro9Spreadsheet::getReadCellReferenceFunction
QuattroFormulaManager::CellReferenceFunction getReadCellReferenceFunction()
returns the function to read a cell's reference
Definition Quattro9Spreadsheet.cpp:816
Quattro9Spreadsheet::m_mainParser
Quattro9Parser & m_mainParser
the listener (if set)
Definition Quattro9Spreadsheet.h:144
QuattroFormulaInternal::CellReference
small class use to store Quattro Pro cell reference (.wb1-3 and qpw)
Definition QuattroFormula.h:43
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
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
Quattro9ParserInternal
Internal: namespace to define internal class of Quattro9Parser.
Definition Quattro9.cpp:58
Quattro9SpreadsheetInternal
Definition Quattro9Spreadsheet.cpp:51
Quattro9ParserInternal::TextEntry
Definition Quattro9.h:44
Quattro9SpreadsheetInternal::CellData
a class used to store the cell(s) content of a Quattro Spreadsheet
Definition Quattro9Spreadsheet.cpp:234
Quattro9SpreadsheetInternal::State
the state of Quattro9Spreadsheet
Definition Quattro9Spreadsheet.cpp:738
WKSContentListener::FormulaInstruction
small class use to define a formula instruction
Definition WKSContentListener.h:58