Debian Codegraph @

src/lib/WKS4.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 WKS4_H
23 #define WKS4_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 "WKSParser.h"
34
35 namespace WKS4ParserInternal
36 {
37 class SubDocument;
38 struct State;
39 }
40
41 class WKS4Chart;
42 class WKS4Spreadsheet;
43
44 /**
45 * This class parses Microsoft Works spreadsheet or a database file
46 *
47 */
48 class WKS4Parser final : public WKSParser
49 {
50 friend class WKS4ParserInternal::SubDocument;
51 friend class WKS4Chart;
52 friend class WKS4Spreadsheet;
53 public:
54 //! constructor
55 WKS4Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
56 libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN,
57 char const *password=nullptr);
58 //! destructor
59 ~WKS4Parser() override;
60 //! called by WPSDocument to parse the file
61 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
62 //! checks if the document header is correct (or not)
63 bool checkHeader(WPSHeader *header, bool strict=false);
64
65 //! try to read a basic C string, knowing the maximum size
66 bool readCString(librevenge::RVNGString &string, long maxSize);
67
68 protected:
69 //! return true if the pos is in the file, update the file size if need
70 bool checkFilePosition(long pos);
71 //! return the file version
72 int version() const;
73 //! return the file creator
74 libwps::WPSCreator creator() const;
75 /** returns the default font type, ie. the encoding given by the constructor if given
76 or the encoding deduiced from the version.
77 */
78 libwps_tools_win::Font::Type getDefaultFontType() const;
79 //! returns the creator
80 libwps::WPSCreator getCreator() const;
81
82 //
83 // interface with WKS4Spreadsheet
84 //
85
86 //! returns the color corresponding to an id
87 bool getColor(int id, WPSColor &color) const;
88 //! returns the font corresponding to an id
89 bool getFont(int id, WPSFont &font, libwps_tools_win::Font::Type &type) const;
90 //! returns the name of the id's spreadsheet
91 librevenge::RVNGString getSheetName(int id) const;
92
93 /** creates the main listener */
94 std::shared_ptr<WKSContentListener> createListener(librevenge::RVNGSpreadsheetInterface *interface);
95 //! send the header/footer
96 void sendHeaderFooter(bool header);
97
98 //
99 // low level
100 //
101
102 /// check for the existence of a format stream, if it exists, parse it
103 bool parseFormatStream();
104 /// reset the main input
105 void resetMainInput(RVNGInputStreamPtr newInput);
106
107 /** finds the different zones (spreadsheet, chart, print, ...) */
108 bool readZones();
109 //! reads a zone
110 bool readZone();
111 //! reads a Quattro Pro zone
112 bool readZoneQuattro();
113
114 //////////////////////// generic ////////////////////////////////////
115
116 //! reads a mswork font
117 bool readFont();
118
119 //! reads a printer data ?
120 bool readPrnt();
121
122 //! reads another printer data. Seem simillar to ZZPrnt
123 bool readPrn2();
124
125 //! reads the header/footer
126 bool readHeaderFooter(bool header);
127
128 //! read a list of field name + ...
129 bool readFieldName();
130
131 //////////////////////// decode a lotus stream //////////////////////////////
132
133 //! try to decode a stream, if successful, replace the stream'input by the new one
134 static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, long endPos, std::vector<uint8_t> const &key);
135
136 //////////////////////// unknown zone //////////////////////////////
137
138 //! reads windows record 0:7|0:9
139 bool readWindowRecord();
140 /** reads some unknown spreadsheet zones 0:18|0:19|0:20|0:27|0:2a
141
142 \note this zones seems to consist of a list of flags potentially
143 followed by other data*/
144 bool readUnknown1();
145
146 std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/
147 //! the internal state
148 std::shared_ptr<WKS4ParserInternal::State> m_state;
149 //! the chart manager
150 std::shared_ptr<WKS4Chart> m_chartParser;
151 //! the spreadsheet manager
152 std::shared_ptr<WKS4Spreadsheet> m_spreadsheetParser;
153 };
154
155 #endif /* WPS4_H */
156 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */