Debian Codegraph @

src/lib/Multiplan.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 MULTIPLAN_H
23 #define MULTIPLAN_H
24
25 #include <vector>
26
27 #include <librevenge-stream/librevenge-stream.h>
28 #include "libwps/libwps.h"
29
30 #include "libwps_internal.h"
31 #include "libwps_tools_win.h"
32
33 #include "WKSContentListener.h"
34
35 #include "WKSParser.h"
36
37 namespace libwps
38 {
39
40 namespace MultiplanParserInternal
41 {
42 struct State;
43 }
44
45 /**
46 * This class parses Microsoft Multiplan DOS spreadsheet v1
47 *
48 */
49 class MultiplanParser final : public WKSParser
50 {
51 public:
52 //! constructor
53 MultiplanParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
54 libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN,
55 char const *password=nullptr);
56 //! destructor
57 ~MultiplanParser() override;
58 //! called by WPSDocument to parse the file
59 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
60 //! checks if the document header is correct (or not)
61 bool checkHeader(WPSHeader *header, bool strict=false);
62
63 protected:
64 //! return true if the pos is in the file, update the file size if need
65 bool checkFilePosition(long pos);
66 //! return the file version
67 int version() const;
68 /** returns the default font type, ie. the encoding given by the constructor if given
69 or the encoding deduiced from the version.
70 */
71 libwps_tools_win::Font::Type getDefaultFontType() const;
72
73 /** creates the main listener */
74 static std::shared_ptr<WKSContentListener> createListener(librevenge::RVNGSpreadsheetInterface *interface);
75 //! try to send the main spreadsheet
76 bool sendSpreadsheet();
77 //! try to send a cell
78 bool sendCell(Vec2i const &cellPos, int pos);
79
80 //
81 // low level
82 //
83
84 /** finds the different zones (spreadsheet, chart, print, ...) */
85 bool readZones();
86 //! read the columns width
87 bool readColumnsWidth();
88 //! read the spreadsheet zone list
89 bool readZonesList();
90 //! read the spreadsheet zone list v2
91 bool readZonesListV2();
92 //! read the cell data position
93 bool readCellDataPosition(WPSEntry const &entry);
94 //! read a link
95 bool readLink(int pos, WKSContentListener::FormulaInstruction &instruction);
96 //! read a link filename
97 bool readFilename(int pos, librevenge::RVNGString &filename);
98 //! read a shared data
99 bool readSharedData(int pos, int cellType, Vec2i const &cellPos, WKSContentListener::CellContent &content);
100 //! reads a name and returns the cell's instruction
101 bool readName(int pos, WKSContentListener::FormulaInstruction &instruction);
102 //! try to read the function names: v2
103 bool readFunctionNamesList();
104
105 //////////////////////// encryption ////////////////////////////////////
106
107 //! check if the password corresponds to a ket
108 bool checkPassword(char const *password) const;
109 //! try to decode a stream, if successful, replace the stream'input by the new one
110 RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input);
111 //! try to guess a password supposing that the Zone0 content is default
112 bool retrievePasswordKeys();
113
114 //////////////////////// unknown zone //////////////////////////////
115
116 //! read an unknown zone
117 bool readZoneB();
118
119
120 protected:
121 //! try to read a double value
122 bool readDouble(double &value);
123 //! try to read a formula
124 bool readFormula(Vec2i const &cellPos, std::vector<WKSContentListener::FormulaInstruction> &formula, long endPos, std::string &extra);
125 //! try to read a formula V2
126 bool readFormulaV2(Vec2i const &cellPos, std::vector<WKSContentListener::FormulaInstruction> &formula, long endPos, std::string &extra);
127
128 std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/
129 //! the internal state
130 std::shared_ptr<MultiplanParserInternal::State> m_state;
131 };
132
133 }
134
135 #endif /* MULTIPLAN_H */
136 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */