Lotus.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 LOTUS_H
23#define LOTUS_H
24
25#include <vector>
26
27#include <librevenge-stream/librevenge-stream.h>
28#include "libwps_internal.h"
29#include "libwps_tools_win.h"
30#include "WPSDebug.h"
31
32#include "WKSParser.h"
33
34namespace LotusParserInternal
35{
36class SubDocument;
37struct State;
38}
39
40class LotusGraph;
41class LotusChart;
44class WPSGraphicStyle;
45class WPSOLE1Parser;
46
47/* .wk3: a spreadsheet is composed in two files
48 + a wk3 file which contains the spreadsheet data
49 + a fm3 file which contains the different formatings
50
51 .wk4: the file contains three parts:
52 + the wk3 previous file
53 + the fm3 file
54 + an unknown part, which may code the file structure,
55
56 Normally the wk3 and the fm3 are a sequence of small zones,
57 but picture seems to be appeared at random position inside the
58 fm3 part (and even inside some structure fm3 structures...)
59
60 search for .ole and OLE1
61
62 .123: the file contains at least two parts:
63 + the 123 storing the spreadsheet's data and format
64 + the last part containing the file's structure
65 + some optional part containing chart, picture, ...
66 */
67
72class LotusParser final : public WKSParser
73{
75 friend class LotusChart;
76 friend class LotusGraph;
77 friend class LotusSpreadsheet;
78 friend class LotusStyleManager;
79public:
82 char const *password=nullptr);
84 ~LotusParser() final;
86 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
88 bool checkHeader(WPSHeader *header, bool strict=false);
89
91 struct Link
92 {
95 {
96 }
97
100 std::string m_linkName;
101 };
102protected:
104 int version() const;
105
106 //
107 // interface
108 //
109
111 bool getFont(int id, WPSFont &font) const;
113 Link const *getLink(std::string const &lId) const;
114
116 librevenge::RVNGString getStringForLMBCS(std::string const &text) const;
118 std::vector<uint32_t> getUnicodeVectorForLMBCS(std::string const &text) const;
120 std::string getDebugStringForLMBCS(std::string const &text) const;
121
123 void sendText(RVNGInputStreamPtr &input, WPSEntry const &entry) const;
124
125 //
126 // interface with LotusChart
127 //
128
130 bool sendChart(int cId, WPSPosition const &pos, WPSGraphicStyle const &style);
131
132 //
133 // interface with LotusGraph
134 //
135
137 bool hasGraphics(int sheetId) const;
139 void sendGraphics(int sheetId);
140
141 //
142 // interface with LotusSpreadsheet
143 //
144
146 bool getLeftTopPosition(Vec2i const &cell, int spreadsheet, Vec2f &pos) const;
148 librevenge::RVNGString getSheetName(int id) const;
149
150 //
151 // interface with WPSOLE1Parser
152 //
153
155 bool updateEmbeddedObject(int id, WPSEmbeddedObject &object) const;
156
158 bool createZones();
160 bool createListener(librevenge::RVNGSpreadsheetInterface *interface);
161
162 //
163 // low level
164 //
165
167 bool parseFormatStream();
168
170 bool checkHeader(std::shared_ptr<WPSStream> stream, bool mainStream, bool strict);
172 bool readZones(std::shared_ptr<WPSStream> stream);
174 bool readExtFormats(std::shared_ptr<WPSStream> stream);
176 bool readZone(std::shared_ptr<WPSStream> &stream);
178 bool readZone1(std::shared_ptr<WPSStream> stream);
180 bool readSheetZone(std::shared_ptr<WPSStream> stream);
182 bool readZone4(std::shared_ptr<WPSStream> stream);
184 bool readChartZone(std::shared_ptr<WPSStream> stream);
186 bool readRefZone(std::shared_ptr<WPSStream> stream);
188 static bool readZone7(std::shared_ptr<WPSStream> stream);
190 bool readZone8(std::shared_ptr<WPSStream> stream);
192 static bool readVersionZone(std::shared_ptr<WPSStream> stream);
194 static bool readZoneV3(std::shared_ptr<WPSStream> stream);
196
198 bool readSheetSize(std::shared_ptr<WPSStream> stream, long endPos, int &row, int &col, int &sheet);
200 bool readMacFontName(std::shared_ptr<WPSStream> stream, long endPos);
202 bool readFMTStyleName(std::shared_ptr<WPSStream> stream);
204 bool readLinkZone(std::shared_ptr<WPSStream> stream);
206 bool readDocumentInfoMac(std::shared_ptr<WPSStream> stream, long endPos);
208
210 static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, long endPos, std::vector<uint8_t> const &key);
212 static std::vector<uint8_t> retrievePasswordKeys(std::vector<uint8_t> const &fileKeys);
213
214 std::shared_ptr<WKSContentListener> m_listener;
216 std::shared_ptr<LotusParserInternal::State> m_state;
218 std::shared_ptr<LotusStyleManager> m_styleManager;
220 std::shared_ptr<LotusChart> m_chartParser;
222 std::shared_ptr<LotusGraph> m_graphParser;
224 std::shared_ptr<LotusSpreadsheet> m_spreadsheetParser;
226 std::shared_ptr<WPSOLE1Parser> m_ole1Parser;
227};
228
229#endif /* LOTUS_H */
230/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
This class parses Microsoft Works chart file.
Definition LotusChart.h:54
This class parses Microsoft Works graph file.
Definition LotusGraph.h:56
friend class LotusChart
Definition Lotus.h:75
friend class LotusSpreadsheet
Definition Lotus.h:77
bool readZones(std::shared_ptr< WPSStream > stream)
finds the different zones (spreadsheet, chart, print, ...)
Definition Lotus.cpp:544
bool readSheetSize(std::shared_ptr< WPSStream > stream, long endPos, int &row, int &col, int &sheet)
reads a basic sheet size : mainly for debugging
Definition Lotus.cpp:2992
std::shared_ptr< LotusStyleManager > m_styleManager
the style manager
Definition Lotus.h:218
bool updateEmbeddedObject(int id, WPSEmbeddedObject &object) const
try to retrieve the content of a graphic, knowing it local id
Definition Lotus.cpp:292
bool readZone(std::shared_ptr< WPSStream > &stream)
reads a zone
Definition Lotus.cpp:616
bool readLinkZone(std::shared_ptr< WPSStream > stream)
reads a link
Definition Lotus.cpp:3161
std::shared_ptr< LotusGraph > m_graphParser
the graph manager
Definition Lotus.h:222
bool readChartZone(std::shared_ptr< WPSStream > stream)
reads a zone of type 5: 123 files
Definition Lotus.cpp:2500
~LotusParser() final
destructor
Definition Lotus.cpp:237
std::shared_ptr< LotusSpreadsheet > m_spreadsheetParser
the spreadsheet manager
Definition Lotus.h:224
bool getLeftTopPosition(Vec2i const &cell, int spreadsheet, Vec2f &pos) const
returns the left top position of a cell
Definition Lotus.cpp:277
bool readMacFontName(std::shared_ptr< WPSStream > stream, long endPos)
reads a mac font name
Definition Lotus.cpp:3009
bool readZone8(std::shared_ptr< WPSStream > stream)
reads a zone of type 8: 123 files
Definition Lotus.cpp:2812
std::vector< uint32_t > getUnicodeVectorForLMBCS(std::string const &text) const
returns the unicode list corresponding to a LMBCS sequence
Definition Lotus.cpp:3534
std::string getDebugStringForLMBCS(std::string const &text) const
small debug function used to print text with format sequence
Definition Lotus.cpp:3712
void sendGraphics(int sheetId)
send the graphics corresponding to a sheetId
Definition Lotus.cpp:272
std::shared_ptr< WPSOLE1Parser > m_ole1Parser
the ole1 parser
Definition Lotus.h:226
LotusParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header, char const *password=nullptr)
constructor
Definition Lotus.cpp:220
static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, long endPos, std::vector< uint8_t > const &key)
try to decode a stream, if successful, replace the stream'input by the new one
Definition Lotus.cpp:3790
static std::vector< uint8_t > retrievePasswordKeys(std::vector< uint8_t > const &fileKeys)
try to guess a password knowing its file keys. Returns the keys if it founds a valid password
Definition Lotus.cpp:3852
bool checkHeader(WPSHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition Lotus.cpp:391
librevenge::RVNGString getStringForLMBCS(std::string const &text) const
returns the string corresponding to a LMBCS sequence
Definition Lotus.cpp:3508
bool readSheetZone(std::shared_ptr< WPSStream > stream)
reads a zone of type 2: 123 files
Definition Lotus.cpp:2017
bool parseFormatStream()
check for the existence of a format stream, if it exists, parse it
Definition Lotus.cpp:520
static bool readZoneV3(std::shared_ptr< WPSStream > stream)
parse a wk123 zone
Definition Lotus.cpp:1809
static bool readVersionZone(std::shared_ptr< WPSStream > stream)
reads a zone of type a: 123 files
Definition Lotus.cpp:2954
bool readZone1(std::shared_ptr< WPSStream > stream)
reads a zone of type 1: 123 files
Definition Lotus.cpp:1833
bool createZones()
try to parse the different zones
Definition Lotus.cpp:478
bool sendChart(int cId, WPSPosition const &pos, WPSGraphicStyle const &style)
try to send a chart
Definition Lotus.cpp:287
std::shared_ptr< LotusParserInternal::State > m_state
the listener (if set)
Definition Lotus.h:216
Link const * getLink(std::string const &lId) const
returns a link corresponding to an id or nullptr
Definition Lotus.cpp:261
librevenge::RVNGString getSheetName(int id) const
returns the name of the id's spreadsheet
Definition Lotus.cpp:282
friend class LotusParserInternal::SubDocument
Definition Lotus.h:74
static bool readZone7(std::shared_ptr< WPSStream > stream)
reads a zone of type 7: 123 files
Definition Lotus.cpp:2686
std::shared_ptr< LotusChart > m_chartParser
the chart manager
Definition Lotus.h:220
bool readRefZone(std::shared_ptr< WPSStream > stream)
reads a zone of type 6: 123 files
Definition Lotus.cpp:2600
bool readDocumentInfoMac(std::shared_ptr< WPSStream > stream, long endPos)
reads a mac document info zone: zone 1b, then 2af8
Definition Lotus.cpp:3264
bool readExtFormats(std::shared_ptr< WPSStream > stream)
parse the extended formats zones 1B
Definition Lotus.cpp:1376
friend class LotusGraph
Definition Lotus.h:76
bool readZone4(std::shared_ptr< WPSStream > stream)
reads a zone of type 4: 123 files
Definition Lotus.cpp:2316
int version() const
return the file version
Definition Lotus.cpp:241
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final
called by WPSDocument to parse the file
Definition Lotus.cpp:307
bool readFMTStyleName(std::shared_ptr< WPSStream > stream)
reads a format style name: b6
Definition Lotus.cpp:3114
std::shared_ptr< WKSContentListener > m_listener
Definition Lotus.h:214
bool createListener(librevenge::RVNGSpreadsheetInterface *interface)
creates the main listener
Definition Lotus.cpp:372
bool hasGraphics(int sheetId) const
return true if the sheet sheetId has some graphic
Definition Lotus.cpp:267
bool getFont(int id, WPSFont &font) const
returns the font corresponding to an id
Definition Lotus.cpp:249
void sendText(RVNGInputStreamPtr &input, WPSEntry const &entry) const
try to send a LBMCS text
Definition Lotus.cpp:3336
friend class LotusStyleManager
Definition Lotus.h:78
This class parses Microsoft Works spreadsheet file.
Definition LotusSpreadsheet.h:53
This class parses the Lotus style.
Definition LotusStyleManager.h:51
WKSParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header)
Definition WKSParser.cpp:30
basic class to store an entry in a file This contained :
Definition WPSEntry.h:39
define the font properties
Definition WPSFont.h:37
a structure used to define a picture style
Definition WPSGraphicStyle.h:38
Definition WPSHeader.h:32
a class used to parse a container which is used by Lotus123 (and also by RagTime).
Definition WPSOLE1Parser.h:50
Class to define the position of an object (textbox, picture, ..) in the document.
Definition WPSPosition.h:40
std::shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition libwps_internal.h:109
Vec2< int > Vec2i
Vec2 of int.
Definition libwps_internal.h:702
Vec2< float > Vec2f
Vec2 of float.
Definition libwps_internal.h:704
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition libwps_internal.h:87
WPSVec3< int > WPSVec3i
WPSVec3 of int.
Definition libwps_internal.h:1067
Internal: namespace to define internal class of LotusParser.
Definition Lotus.cpp:62
the state of LotusParser
Definition Lotus.cpp:65
small class use to define a embedded object
Definition libwps_internal.h:1077

Generated on for libwps by doxygen 1.17.0