Quattro9.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 QUATTRO_9_H
23#define QUATTRO_9_H
24
25#include <map>
26#include <vector>
27
28#include <librevenge-stream/librevenge-stream.h>
29#include "libwps/libwps.h"
30
31#include "libwps_internal.h"
32#include "libwps_tools_win.h"
33
34#include "WPSEntry.h"
35#include "WKSParser.h"
36#include "WPSGraphicStyle.h"
37
38 namespace Quattro9ParserInternal
39{
40 class SubDocument;
41 struct State;
42
43 struct TextEntry
44{
46 TextEntry()
47 : m_entry()
48 , m_fontsList()
49 , m_posFontIdMap()
50 , m_flag(0)
51 , m_extra()
52 {
53 }
54
55 bool empty() const
56 {
57 return !m_entry.valid();
58 }
59
60 librevenge::RVNGString getString(std::shared_ptr<WPSStream> const &stream, libwps_tools_win::Font::Type type=libwps_tools_win::Font::WIN3_WEUROPE) const;
62 void send(std::shared_ptr<WPSStream> const &stream, WPSFont const &font, libwps_tools_win::Font::Type type, WKSContentListenerPtr &listener);
64 std::string getDebugString(std::shared_ptr<WPSStream> const &stream) const;
66 WPSEntry m_entry;
68 std::vector<WPSFont> m_fontsList;
70 std::map<int, int> m_posFontIdMap;
72 int m_flag;
74 std::string m_extra;
75};
76}
77
78 class Quattro9Graph;
79 class Quattro9Spreadsheet;
80
81 namespace QuattroFormulaInternal
82{
83 class CellReference;
84}
85
90 class Quattro9Parser final : public WKSParser
91{
92 friend class Quattro9ParserInternal::SubDocument;
93 friend class Quattro9Graph;
94 friend class Quattro9Spreadsheet;
95
96 public:
98 Quattro9Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
99 libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN,
100 char const *password=nullptr);
102 ~Quattro9Parser() final;
104 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
106 bool checkHeader(WPSHeader *header, bool strict=false);
107
108protected:
110 int version() const;
114 libwps_tools_win::Font::Type getDefaultFontType() const;
116 bool getExternalFileName(int fId, librevenge::RVNGString &fName) const;
118 bool getField(int fId, librevenge::RVNGString &text,
119 QuattroFormulaInternal::CellReference &ref,
120 librevenge::RVNGString const &fileName) const;
121
122 //
123 // interface with Quattro9Spreadsheet
124 //
125
127 bool getFont(int id, WPSFont &font) const;
129 Vec2f getCellPosition(int sheetId, Vec2i const &cell) const;
130
131 //
132 // interface with Quattro9Graph
133 //
134
136 bool getColor(int id, WPSColor &color) const;
138 bool getPattern(int id, WPSGraphicStyle::Pattern &pattern) const;
140 bool sendPageGraphics(int sheetId) const;
141
142 //
143 //
144 //
145
147 std::shared_ptr<WKSContentListener> createListener(librevenge::RVNGSpreadsheetInterface *interface);
148
150 void sendHeaderFooter(bool header);
151
152 //
153 // low level
154 //
155
157 bool checkHeader(std::shared_ptr<WPSStream> stream, bool strict);
159 bool readZones();
161 bool readZone(std::shared_ptr<WPSStream> &stream);
162
164
166 bool readPString(std::shared_ptr<WPSStream> const &stream, long endPos, Quattro9ParserInternal::TextEntry &entry);
168 bool readFontNames(std::shared_ptr<WPSStream> const &stream);
170 bool readFontStyles(std::shared_ptr<WPSStream> const &stream);
172 static bool readFilePositions(std::shared_ptr<WPSStream> const &stream, long (&filePos)[2]);
174 bool readDocumentFields(std::shared_ptr<WPSStream> const &stream);
176 bool readDocumentStrings(std::shared_ptr<WPSStream> const &stream);
177
179 bool readTextStyles(std::shared_ptr<WPSStream> const &stream, long endPos, Quattro9ParserInternal::TextEntry &entry);
181 bool readTextFontStyles(std::shared_ptr<WPSStream> const &stream, int dataSz, WPSFont &font);
182
184 void addDocumentStrings();
185
187
188
190
192 bool parseOLEStream(RVNGInputStreamPtr input, std::string const &avoid="");
194 static bool readOleLinkInfo(std::shared_ptr<WPSStream> stream);
196 static bool readOleBOlePart(std::shared_ptr<WPSStream> stream);
197
199
201 static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, std::vector<uint8_t> const &key);
202
203 std::shared_ptr<WKSContentListener> m_listener;
205 std::shared_ptr<Quattro9ParserInternal::State> m_state;
207 std::shared_ptr<Quattro9Graph> m_graphParser;
209 std::shared_ptr<Quattro9Spreadsheet> m_spreadsheetParser;
210};
211
212#endif /* WPS4_H */
213/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WKSParser.h
WPSEntry.h
WPSGraphicStyle.h
Quattro9Graph
This class parses Quattro9Pro graph file.
Definition Quattro9Graph.h:53
Quattro9ParserInternal::SubDocument
Internal: the subdocument of a WPS4Parser.
Definition Quattro9.cpp:61
Quattro9Parser::getColor
bool getColor(int id, WPSColor &color) const
returns the color corresponding to an id
Definition Quattro9.cpp:491
Quattro9Parser::version
int version() const
return the file version
Definition Quattro9.cpp:417
Quattro9Parser::getFont
bool getFont(int id, WPSFont &font) const
returns the font corresponding to an id
Definition Quattro9.cpp:509
Quattro9Parser::readDocumentFields
bool readDocumentFields(std::shared_ptr< WPSStream > const &stream)
read a zone 406 which contains a list of fields
Definition Quattro9.cpp:1521
Quattro9Parser::readDocumentStrings
bool readDocumentStrings(std::shared_ptr< WPSStream > const &stream)
read a zone 407 which contains a list of stream
Definition Quattro9.cpp:1627
Quattro9Parser::m_spreadsheetParser
std::shared_ptr< Quattro9Spreadsheet > m_spreadsheetParser
the spreadsheet manager
Definition Quattro9.h:209
Quattro9Parser::Quattro9Spreadsheet
friend class Quattro9Spreadsheet
Definition Quattro9.h:94
Quattro9Parser::getPattern
bool getPattern(int id, WPSGraphicStyle::Pattern &pattern) const
returns the pattern corresponding to a pattern id between 0 and 24
Definition Quattro9.cpp:496
Quattro9Parser::Quattro9Parser
Quattro9Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header, libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN, char const *password=nullptr)
constructor
Definition Quattro9.cpp:404
Quattro9Parser::getCellPosition
Vec2f getCellPosition(int sheetId, Vec2i const &cell) const
returns the beginning position of a cell
Definition Quattro9.cpp:520
Quattro9Parser::parse
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final
called by WPSDocument to parse the file
Definition Quattro9.cpp:535
Quattro9Parser::readFontStyles
bool readFontStyles(std::shared_ptr< WPSStream > const &stream)
read a font style zone: zone 7
Definition Quattro9.cpp:1336
Quattro9Parser::readOleBOlePart
static bool readOleBOlePart(std::shared_ptr< WPSStream > stream)
try to read the BOlePart sub stream: a zone which contains 5 long
Definition Quattro9.cpp:1784
Quattro9Parser::m_state
std::shared_ptr< Quattro9ParserInternal::State > m_state
the listener (if set)
Definition Quattro9.h:205
Quattro9Parser::sendHeaderFooter
void sendHeaderFooter(bool header)
send the header/footer
Definition Quattro9.cpp:1740
Quattro9Parser::m_graphParser
std::shared_ptr< Quattro9Graph > m_graphParser
the graph manager
Definition Quattro9.h:207
Quattro9Parser::getDefaultFontType
libwps_tools_win::Font::Type getDefaultFontType() const
returns the default font type, ie.
Definition Quattro9.cpp:422
Quattro9Parser::readTextFontStyles
bool readTextFontStyles(std::shared_ptr< WPSStream > const &stream, int dataSz, WPSFont &font)
read a font style in a text entry zone
Definition Quattro9.cpp:1458
Quattro9Parser::~Quattro9Parser
~Quattro9Parser() final
destructor
Definition Quattro9.cpp:413
Quattro9Parser::Quattro9Graph
friend class Quattro9Graph
Definition Quattro9.h:93
Quattro9Parser::createListener
std::shared_ptr< WKSContentListener > createListener(librevenge::RVNGSpreadsheetInterface *interface)
creates the main listener
Definition Quattro9.cpp:581
Quattro9Parser::checkHeader
bool checkHeader(WPSHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition Quattro9.cpp:599
Quattro9Parser::readFontNames
bool readFontNames(std::shared_ptr< WPSStream > const &stream)
read a font name zone: zone 6
Definition Quattro9.cpp:1293
Quattro9Parser::readFilePositions
static bool readFilePositions(std::shared_ptr< WPSStream > const &stream, long(&filePos)[2])
read a zone which contains two files position (prev and next): zone 2,402,602,a02
Definition Quattro9.cpp:1689
Quattro9Parser::decodeStream
static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, std::vector< uint8_t > const &key)
try to decode a stream, if successful, replace the stream'input by the new one
Definition Quattro9.cpp:1808
Quattro9Parser::readTextStyles
bool readTextStyles(std::shared_ptr< WPSStream > const &stream, long endPos, Quattro9ParserInternal::TextEntry &entry)
read a text entry style zone
Definition Quattro9.cpp:1406
Quattro9Parser::m_listener
std::shared_ptr< WKSContentListener > m_listener
Definition Quattro9.h:203
Quattro9Parser::readZone
bool readZone(std::shared_ptr< WPSStream > &stream)
try to read a zone
Definition Quattro9.cpp:725
Quattro9Parser::readOleLinkInfo
static bool readOleLinkInfo(std::shared_ptr< WPSStream > stream)
try to read the link info sub stream
Definition Quattro9.cpp:1754
Quattro9Parser::getField
bool getField(int fId, librevenge::RVNGString &text, QuattroFormulaInternal::CellReference &ref, librevenge::RVNGString const &fileName) const
returns the text and cell of a field instruction
Definition Quattro9.cpp:444
Quattro9Parser::readPString
bool readPString(std::shared_ptr< WPSStream > const &stream, long endPos, Quattro9ParserInternal::TextEntry &entry)
try to read a string: length[2bytes], unknow[bytes] followed by the string
Definition Quattro9.cpp:1258
Quattro9Parser::getExternalFileName
bool getExternalFileName(int fId, librevenge::RVNGString &fName) const
returns the name of the fId file
Definition Quattro9.cpp:427
Quattro9Parser::parseOLEStream
bool parseOLEStream(RVNGInputStreamPtr input, std::string const &avoid="")
try to parse the OLE stream(except the main stream)
Definition Quattro9.cpp:675
Quattro9Parser::sendPageGraphics
bool sendPageGraphics(int sheetId) const
send the page graphic corresponding to a sheet
Definition Quattro9.cpp:501
Quattro9Parser::readZones
bool readZones()
finds the different zones in the main OLE stream (spreadsheet, chart, print, ...)
Definition Quattro9.cpp:648
Quattro9Parser::addDocumentStrings
void addDocumentStrings()
add the document strings to the spreadsheetParser
Definition Quattro9.cpp:525
Quattro9Spreadsheet
This class parses Quattro9 Pro spreadsheet file.
Definition Quattro9Spreadsheet.h:57
WKSContentListener
Definition WKSContentListener.h:54
WKSParser::WKSParser
WKSParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header)
Definition WKSParser.cpp:30
WPSEntry
basic class to store an entry in a file This contained :
Definition WPSEntry.h:39
WPSFont
define the font properties
Definition WPSFont.h:37
WPSGraphicStyle
a structure used to define a picture style
Definition WPSGraphicStyle.h:38
WPSHeader
Definition WPSHeader.h:32
libwps_tools_win::Font::Type
Type
enum Type
Definition libwps_tools_win.h:46
libwps_tools_win::Font::UNKNOWN
@ UNKNOWN
Definition libwps_tools_win.h:63
libwps_tools_win::Font::WIN3_WEUROPE
@ WIN3_WEUROPE
Definition libwps_tools_win.h:52
libwps.h
libwps_internal.h
WPSHeaderPtr
std::shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition libwps_internal.h:109
WKSContentListenerPtr
std::shared_ptr< WKSContentListener > WKSContentListenerPtr
shared pointer to WKSContentListener
Definition libwps_internal.h:114
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition libwps_internal.h:702
Vec2f
Vec2< float > Vec2f
Vec2 of float.
Definition libwps_internal.h:704
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition libwps_internal.h:87
libwps_tools_win.h
Quattro9ParserInternal
Internal: namespace to define internal class of Quattro9Parser.
Definition Quattro9.cpp:58
QuattroFormulaInternal
namespace to regroup data used to read QuattroPro .wb1-3, .qpw formula
Definition Quattro.h:46
libwps_tools_win
some Windows© classes and tools
Definition libwps_tools_win.cpp:32
Quattro9ParserInternal::State
the state of Quattro9Parser
Definition Quattro9.cpp:125
Quattro9ParserInternal::TextEntry::m_flag
int m_flag
the flag
Definition Quattro9.h:72
Quattro9ParserInternal::TextEntry::getString
librevenge::RVNGString getString(std::shared_ptr< WPSStream > const &stream, libwps_tools_win::Font::Type type=libwps_tools_win::Font::WIN3_WEUROPE) const
returns the string
Definition Quattro9.cpp:280
Quattro9ParserInternal::TextEntry::m_posFontIdMap
std::map< int, int > m_posFontIdMap
the position to font map(complex text)
Definition Quattro9.h:70
Quattro9ParserInternal::TextEntry::send
void send(std::shared_ptr< WPSStream > const &stream, WPSFont const &font, libwps_tools_win::Font::Type type, WKSContentListenerPtr &listener)
sends the text to the main listener
Definition Quattro9.cpp:322
Quattro9ParserInternal::TextEntry::TextEntry
TextEntry()
constructor
Definition Quattro9.h:46
Quattro9ParserInternal::TextEntry::empty
bool empty() const
returns true if the string is empty
Definition Quattro9.h:55
Quattro9ParserInternal::TextEntry::m_extra
std::string m_extra
extra data
Definition Quattro9.h:74
Quattro9ParserInternal::TextEntry::m_fontsList
std::vector< WPSFont > m_fontsList
the list of fonts
Definition Quattro9.h:68
Quattro9ParserInternal::TextEntry::getDebugString
std::string getDebugString(std::shared_ptr< WPSStream > const &stream) const
internal: returns a debug string
Definition Quattro9.cpp:313
Quattro9ParserInternal::TextEntry::m_entry
WPSEntry m_entry
the text entry
Definition Quattro9.h:66
WPSColor
the class to store a color
Definition libwps_internal.h:281
WPSStream
small structure use to store a stream and it debug file
Definition WPSStream.h:30