WKS4.h Source File documentation

WKS4.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 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
48 class WKS4Parser final : public WKSParser
49 {
50 friend class WKS4ParserInternal::SubDocument;
51 friend class WKS4Chart;
52 friend class WKS4Spreadsheet;
53 public:
55 WKS4Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
56 libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN,
57 char const *password=nullptr);
59 ~WKS4Parser() override;
61 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
63 bool checkHeader(WPSHeader *header, bool strict=false);
64
66 bool readCString(librevenge::RVNGString &string, long maxSize);
67
68 protected:
70 bool checkFilePosition(long pos);
72 int version() const;
74 libwps::WPSCreator creator() const;
78 libwps_tools_win::Font::Type getDefaultFontType() const;
80 bool hasLICSCharacters() const;
82 libwps::WPSCreator getCreator() const;
83
84 //
85 // interface with WKS4Spreadsheet
86 //
87
89 bool getColor(int id, WPSColor &color) const;
91 bool getFont(int id, WPSFont &font, libwps_tools_win::Font::Type &type) const;
93 librevenge::RVNGString getSheetName(int id) const;
94
96 std::shared_ptr<WKSContentListener> createListener(librevenge::RVNGSpreadsheetInterface *interface);
98 void sendHeaderFooter(bool header);
99
100 //
101 // low level
102 //
103
105 bool parseFormatStream();
107 void resetMainInput(RVNGInputStreamPtr newInput);
108
110 bool readZones();
112 bool readZone();
114 bool readZoneQuattro();
115
117
119 bool readFont();
120
122 bool readPrnt();
123
125 bool readPrn2();
126
128 bool readHeaderFooter(bool header);
129
131 bool readFieldName();
132
134
136 static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, long endPos, std::vector<uint8_t> const &key);
137
139
141 bool readWindowRecord();
146 bool readUnknown1();
147
148 std::shared_ptr<WKSContentListener> m_listener;
149 std::shared_ptr<WKS4ParserInternal::State> m_state;
152 std::shared_ptr<WKS4Chart> m_chartParser;
154 std::shared_ptr<WKS4Spreadsheet> m_spreadsheetParser;
155 };
156
157 #endif /* WPS4_H */
158 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WKS4ParserInternal
Internal: namespace to define internal class of WKS4Parser.
Definition: WKS4.cpp:52
WKS4Parser::checkFilePosition
bool checkFilePosition(long pos)
return true if the pos is in the file, update the file size if need
Definition: WKS4.cpp:265
WKS4Parser::readPrn2
bool readPrn2()
reads another printer data. Seem simillar to ZZPrnt
Definition: WKS4.cpp:1604
WKS4Parser::m_chartParser
std::shared_ptr< WKS4Chart > m_chartParser
the chart manager
Definition: WKS4.h:152
WKS4ParserInternal::SubDocument
Internal: the subdocument of a WPS4Parser.
Definition: WKS4.cpp:66
WKS4Parser::readCString
bool readCString(librevenge::RVNGString &string, long maxSize)
try to read a basic C string, knowing the maximum size
Definition: WKS4.cpp:1386
WKS4Parser::createListener
std::shared_ptr< WKSContentListener > createListener(librevenge::RVNGSpreadsheetInterface *interface)
creates the main listener
Definition: WKS4.cpp:386
libwps_tools_win.h
WKS4Parser::getSheetName
librevenge::RVNGString getSheetName(int id) const
returns the name of the id&#39;s spreadsheet
Definition: WKS4.cpp:316
WKS4Parser::getCreator
libwps::WPSCreator getCreator() const
returns the creator
Definition: WKS4.cpp:283
WPSFont
define the font properties
Definition: WPSFont.h:36
WKS4Parser::parse
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final
called by WPSDocument to parse the file
Definition: WKS4.cpp:322
WKS4Parser::readZoneQuattro
bool readZoneQuattro()
reads a Quattro Pro zone
Definition: WKS4.cpp:1360
WKS4Parser::m_state
std::shared_ptr< WKS4ParserInternal::State > m_state
the listener (if set)
Definition: WKS4.h:150
libwps_tools_win::Font::Type
Type
enum Type
Definition: libwps_tools_win.h:46
WKS4Parser
This class parses Microsoft Works spreadsheet or a database file.
Definition: WKS4.h:48
WKS4Parser::readHeaderFooter
bool readHeaderFooter(bool header)
reads the header/footer
Definition: WKS4.cpp:1505
WKS4Parser::version
int version() const
return the file version
Definition: WKS4.cpp:247
WKS4Parser::WKS4Parser
WKS4Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header, libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN, char const *password=nullptr)
constructor
Definition: WKS4.cpp:233
WKS4Parser::getColor
bool getColor(int id, WPSColor &color) const
returns the color corresponding to an id
Definition: WKS4.cpp:291
WKS4Parser::creator
libwps::WPSCreator creator() const
return the file creator
Definition: WKS4.cpp:252
WKS4Parser::readFont
bool readFont()
reads a mswork font
Definition: WKS4.cpp:1412
WKS4Parser::readFieldName
bool readFieldName()
read a list of field name + ...
Definition: WKS4.cpp:1649
WKS4Parser::m_listener
std::shared_ptr< WKSContentListener > m_listener
Definition: WKS4.h:148
libwps_internal.h
WKS4Parser::checkHeader
bool checkHeader(WPSHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: WKS4.cpp:411
WKS4Parser::parseFormatStream
bool parseFormatStream()
check for the existence of a format stream, if it exists, parse it
Definition: WKS4.cpp:536
WKS4Parser::sendHeaderFooter
void sendHeaderFooter(bool header)
send the header/footer
Definition: WKS4.cpp:1493
WPSHeader
Definition: WPSHeader.h:31
libwps_tools_win::Font::UNKNOWN
Definition: libwps_tools_win.h:61
WKS4Parser::m_spreadsheetParser
std::shared_ptr< WKS4Spreadsheet > m_spreadsheetParser
the spreadsheet manager
Definition: WKS4.h:154
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
libwps::WPSCreator
WPSCreator
Definition: WPSDocument.h:48
WKS4Chart
This class parses Microsoft Works chart file.
Definition: WKS4Chart.h:49
WKS4Parser::readPrnt
bool readPrnt()
reads a printer data ?
Definition: WKS4.cpp:1553
libwps.h
WKS4Parser::resetMainInput
void resetMainInput(RVNGInputStreamPtr newInput)
reset the main input
Definition: WKS4.cpp:257
WPSColor
the class to store a color
Definition: libwps_internal.h:280
WKS4Parser::decodeStream
static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, long endPos, std::vector< uint8_t > const &key)
try to decode a stream, if successful, replace the stream&#39;input by the new one
Definition: WKS4.cpp:1838
WKS4Parser::readZones
bool readZones()
finds the different zones (spreadsheet, chart, print, ...)
Definition: WKS4.cpp:552
WKS4Parser::readUnknown1
bool readUnknown1()
reads some unknown spreadsheet zones 0:18|0:19|0:20|0:27|0:2a
Definition: WKS4.cpp:1766
WKS4Parser::readWindowRecord
bool readWindowRecord()
reads windows record 0:7|0:9
Definition: WKS4.cpp:1717
WKS4Parser::getDefaultFontType
libwps_tools_win::Font::Type getDefaultFontType() const
returns the default font type, ie.
Definition: WKS4.cpp:278
WKS4Parser::readZone
bool readZone()
reads a zone
Definition: WKS4.cpp:608
WKS4Spreadsheet
This class parses Microsoft Works spreadsheet file.
Definition: WKS4Spreadsheet.h:48
WKS4Parser::getFont
bool getFont(int id, WPSFont &font, libwps_tools_win::Font::Type &type) const
returns the font corresponding to an id
Definition: WKS4.cpp:296
WPSHeaderPtr
std::shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition: libwps_internal.h:109
WKSParser
Definition: WKSParser.h:33
WKS4Parser::hasLICSCharacters
bool hasLICSCharacters() const
returns the true if the file has LICS characters
Definition: WKS4.cpp:309
WKSParser.h
WKS4Parser::~WKS4Parser
~WKS4Parser() override
destructor
Definition: WKS4.cpp:243