Debian Codegraph @

src/lib/QuattroDos.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_DOS_H
23 #define QUATTRO_DOS_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 QuattroDosParserInternal
36 {
37 class SubDocument;
38 struct State;
39 }
40
41 class QuattroDosChart;
42 class QuattroDosSpreadsheet;
43
44 /**
45 * This class parses Quattro Pro spreadsheet: .wq1 and wq2
46 *
47 */
48 class QuattroDosParser final : public WKSParser
49 {
50 friend class QuattroDosParserInternal::SubDocument;
51 friend class QuattroDosChart;
52 friend class QuattroDosSpreadsheet;
53 public:
54 //! constructor
55 QuattroDosParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
56 libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN);
57 //! destructor
58 ~QuattroDosParser() final;
59 //! called by WPSDocument to parse the file
60 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
61 //! checks if the document header is correct (or not)
62 bool checkHeader(WPSHeader *header, bool strict=false);
63
64 protected:
65 //! return true if the pos is in the file, update the file size if need
66 bool checkFilePosition(long pos);
67 //! return the file version
68 int version() const;
69 /** returns the default font type, ie. the encoding given by the constructor if given
70 or the encoding deduiced from the version.
71 */
72 libwps_tools_win::Font::Type getDefaultFontType() const;
73 //! returns the name of the fId file
74 librevenge::RVNGString getFileName(int fId) const;
75
76 //
77 // interface with QuattroDosSpreadsheet
78 //
79
80 //! returns the color corresponding to an id
81 bool getColor(int id, WPSColor &color) const;
82 //! returns the font corresponding to an id
83 bool getFont(int id, WPSFont &font, libwps_tools_win::Font::Type &type) const;
84 //! returns the name of the id's spreadsheet
85 librevenge::RVNGString getSheetName(int id) const;
86
87 //
88 // interface with QuattroDosChart
89 //
90
91 //! try to send the chart corresponding to sheetId and a position
92 bool sendChart(int sheetId, Vec2i const &cell, Vec2f const &chartSize);
93
94 /** creates the main listener */
95 std::shared_ptr<WKSContentListener> createListener(librevenge::RVNGSpreadsheetInterface *interface);
96 //! send the header/footer
97 void sendHeaderFooter(bool header);
98
99 //
100 // low level
101 //
102
103 /** finds the different zones (spreadsheet, chart, print, ...) */
104 bool readZones();
105 //! reads a zone
106 bool readZone();
107
108 //////////////////////// generic ////////////////////////////////////
109
110 //! reads the user fonts
111 bool readUserFonts();
112 //! try to read a font
113 bool readFont(WPSFont &font, libwps_tools_win::Font::Type &type);
114 //! reads the header/footer
115 bool readHeaderFooter(bool header);
116
117 //! read a list of field name + ...
118 bool readFieldName();
119 //! read a file name
120 bool readFileName();
121
122 //! try to read a basic pascal string, knowing the maximum size(excluding string size)
123 bool readPString(librevenge::RVNGString &string, long maxSize);
124 //////////////////////// unknown zone //////////////////////////////
125
126 //! reads windows record 0:7|0:9
127 bool readWindowRecord();
128 /** reads some unknown spreadsheet zones 0:18|0:19|0:20|0:27|0:2a
129
130 \note this zones seems to consist of a list of flags potentially
131 followed by other data*/
132 bool readUnknown1();
133
134 std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/
135 //! the internal state
136 std::shared_ptr<QuattroDosParserInternal::State> m_state;
137 //! the spreadsheet manager
138 std::shared_ptr<QuattroDosSpreadsheet> m_spreadsheetParser;
139 //! the chart manager
140 std::shared_ptr<QuattroDosChart> m_chartParser;
141 };
142
143 #endif /* WPS4_H */
144 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */