Debian Codegraph @

src/lib/QuattroSpreadsheet.h

raw symbols SCIP
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 ([email protected])
12 * Copyright (C) 2003 Marc Maurer ([email protected])
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
47 /**
48 * This class parses Quattro Pro spreadsheet file
49 *
50 */
51 class QuattroSpreadsheet
52 {
53 public:
54 friend class QuattroParser;
55
56 //! constructor
57 explicit QuattroSpreadsheet(QuattroParser &parser);
58 //! destructor
59 ~QuattroSpreadsheet();
60 //! sets the listener
61 void setListener(WKSContentListenerPtr &listen)
62 {
63 m_listener = listen;
64 }
65 //! clean internal state
66 void cleanState();
67 //! update the state (need to be called before sending data)
68 void updateState();
69
70 protected:
71 //! return the file version
72 int version() const;
73 //! returns the function to read a cell's reference
74 QuattroFormulaManager::CellReferenceFunction getReadCellReferenceFunction();
75
76 //! returns the number of spreadsheet
77 int getNumSpreadsheets() const;
78 //! returns the name of the id's spreadsheet
79 librevenge::RVNGString getSheetName(int id) const;
80 //! send the sheetId'th spreadsheet
81 void sendSpreadsheet(int sheetId, std::vector<Vec2i> const &listGraphicCells);
82 //! returns the beginning position of a cell
83 Vec2f getPosition(int sheetId, Vec2i const &cell) const;
84 //! send the cell data
85 void sendCellContent(QuattroSpreadsheetInternal::Cell const &cell, int sheetId);
86
87 //! add a dll's correspondance between an id and a name
88 void addDLLIdName(int id, librevenge::RVNGString const &name, bool func1);
89 //! add a user format's correspondance between an id and a name
90 void addUserFormat(int id, librevenge::RVNGString const &name);
91
92 //
93 // low level
94 //
95 //////////////////////// spreadsheet //////////////////////////////
96
97 //! reads a cell content data: zone 0xc-0x10 or 33
98 bool readCell(std::shared_ptr<WPSStream> const &stream);
99 //! reads sheet size: zone 06
100 bool readSheetSize(std::shared_ptr<WPSStream> const &stream);
101 //! reads the sheet column/row default size: zone d2-d5
102 bool readColumnRowDefaultSize(std::shared_ptr<WPSStream> const &stream);
103 //! reads the column size: zone d8,d9
104 bool readColumnSize(std::shared_ptr<WPSStream> const &stream);
105 //! reads the row size: zone d6,d7
106 bool readRowSize(std::shared_ptr<WPSStream> const &stream);
107 //! reads the row size: zone 105,106
108 bool readRowRangeSize(std::shared_ptr<WPSStream> const &stream);
109
110 //! read the begin/end of a sheet zone: zone ca and cb
111 bool readBeginEndSheet(std::shared_ptr<WPSStream> const &stream, int &sheetId);
112 //! reads sheet name: zone cc
113 bool readSheetName(std::shared_ptr<WPSStream> const &stream);
114 //! reads a cell attribute: zone 0xce
115 bool readCellStyle(std::shared_ptr<WPSStream> const &stream);
116
117 //! reads a view info: zone 197/198
118 static bool readViewInfo(std::shared_ptr<WPSStream> const &stream);
119
120 /* reads a cell */
121 static bool readCell(std::shared_ptr<WPSStream> const &stream, Vec2i actPos, WKSContentListener::FormulaInstruction &instr, int sheetId, librevenge::RVNGString const &fName);
122 //! try to update the cell's format using the user format
123 static void updateCellWithUserFormat(QuattroSpreadsheetInternal::Cell &cell, librevenge::RVNGString const &format);
124 //! try to read a cell reference
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; /** the listener (if set)*/
133 //! the main parser
134 QuattroParser &m_mainParser;
135 //! the internal state
136 std::shared_ptr<QuattroSpreadsheetInternal::State> m_state;
137 };
138
139 #endif /* WPS4_H */
140 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */