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 {
51  friend class WKS4Chart;
52  friend class WKS4Spreadsheet;
53 public:
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;
81 
82  //
83  // interface with WKS4Spreadsheet
84  //
85 
87  bool getColor(int id, WPSColor &color) const;
89  bool getFont(int id, WPSFont &font, libwps_tools_win::Font::Type &type) const;
91  librevenge::RVNGString getSheetName(int id) const;
92 
94  std::shared_ptr<WKSContentListener> createListener(librevenge::RVNGSpreadsheetInterface *interface);
96  void sendHeaderFooter(bool header);
97 
98  //
99  // low level
100  //
101 
103  bool parseFormatStream();
105  void resetMainInput(RVNGInputStreamPtr newInput);
106 
108  bool readZones();
110  bool readZone();
112  bool readZoneQuattro();
113 
115 
117  bool readFont();
118 
120  bool readPrnt();
121 
123  bool readPrn2();
124 
126  bool readHeaderFooter(bool header);
127 
129  bool readFieldName();
130 
132 
134  static RVNGInputStreamPtr decodeStream(RVNGInputStreamPtr input, long endPos, std::vector<uint8_t> const &key);
135 
137 
139  bool readWindowRecord();
144  bool readUnknown1();
145 
146  std::shared_ptr<WKSContentListener> m_listener;
147  std::shared_ptr<WKS4ParserInternal::State> m_state;
150  std::shared_ptr<WKS4Chart> m_chartParser;
152  std::shared_ptr<WKS4Spreadsheet> m_spreadsheetParser;
153 };
154 
155 #endif /* WPS4_H */
156 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
libwps_tools_win::Font::LICS
@ LICS
Definition: libwps_tools_win.h:54
WKS4Parser::checkHeader
bool checkHeader(WPSHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: WKS4.cpp:413
WKS4Parser::parseFormatStream
bool parseFormatStream()
check for the existence of a format stream, if it exists, parse it
Definition: WKS4.cpp:538
WKS4ParserInternal::State::getDefaultFontType
libwps_tools_win::Font::Type getDefaultFontType() const
return the default font style
Definition: WKS4.cpp:146
WPSFont::m_extra
std::string m_extra
public field use to add a message when the font is printed
Definition: WPSFont.h:94
WPS_STRIKEOUT_BIT
#define WPS_STRIKEOUT_BIT
Definition: libwps_internal.h:507
WKS4ParserInternal::SubDocument::SubDocument
SubDocument(RVNGInputStreamPtr const &input, WKS4Parser &pars, bool header)
constructor for a text entry
Definition: WKS4.cpp:77
libwps::DebugStream::str
static std::string str()
Definition: WPSDebug.h:200
WKS4ParserInternal::State::m_creator
libwps::WPSCreator m_creator
the application
Definition: WKS4.cpp:172
libwps::DebugFile::open
static bool open(std::string const &)
Definition: WPSDebug.h:215
WKS4Parser::sendHeaderFooter
void sendHeaderFooter(bool header)
send the header/footer
Definition: WKS4.cpp:1491
WPS_BOLD_BIT
#define WPS_BOLD_BIT
Definition: libwps_internal.h:506
WKS4ParserInternal::State::m_password
char const * m_password
the password (if known)
Definition: WKS4.cpp:192
WKS4Parser::m_spreadsheetParser
std::shared_ptr< WKS4Spreadsheet > m_spreadsheetParser
the spreadsheet manager
Definition: WKS4.h:152
libwps::DebugFile::addPos
static void addPos(long)
Definition: WPSDebug.h:220
libwps::encodeLotusPassword
bool encodeLotusPassword(char const *password, uint16_t &key, std::vector< uint8_t > &keys, uint8_t const(&defValues)[16])
returns the checksum and the keys (to encode a lotus file) given a password file
Definition: libwps_internal.cpp:977
libwps_tools_win::Font::Type
Type
enum Type
Definition: libwps_tools_win.h:46
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'input by the new one
Definition: WKS4.cpp:1836
WPSHeader::setKind
void setKind(libwps::WPSKind kind)
Definition: WPSHeader.h:64
WKS4Chart.h
libwps::WPS_SYMPHONY
@ WPS_SYMPHONY
Lotus Symphony files(untested, probably DOS documents)
Definition: WPSDocument.h:52
WKS4Parser::readZones
bool readZones()
finds the different zones (spreadsheet, chart, print, ...)
Definition: WKS4.cpp:554
WKS4Parser::readUnknown1
bool readUnknown1()
reads some unknown spreadsheet zones 0:18|0:19|0:20|0:27|0:2a
Definition: WKS4.cpp:1764
WPSTable.h
WPS_UNDERLINE_BIT
#define WPS_UNDERLINE_BIT
Definition: libwps_internal.h:508
WKSSubDocument.h
libwps
Definition: libwps_internal.cpp:39
WKS4ParserInternal::State::m_footerString
librevenge::RVNGString m_footerString
the footer string
Definition: WKS4.cpp:189
WKS4Parser::readPrnt
bool readPrnt()
reads a printer data ?
Definition: WKS4.cpp:1551
WKS4Parser::resetMainInput
void resetMainInput(RVNGInputStreamPtr newInput)
reset the main input
Definition: WKS4.cpp:266
WKS4Parser::readZone
bool readZone()
reads a zone
Definition: WKS4.cpp:610
WKS4ParserInternal::Font::Font
Font(libwps_tools_win::Font::Type type)
constructor
Definition: WKS4.cpp:58
libwps::DebugFile::reset
static void reset()
Definition: WPSDebug.h:224
WKS4Spreadsheet.h
WKSParser::resetInput
void resetInput(RVNGInputStreamPtr const &newInput)
Definition: WKSParser.h:45
WPSColumnFormat
Definition: WPSTable.h:40
libwps_tools_win::Font::unicodeString
static librevenge::RVNGString unicodeString(const unsigned char *p, unsigned long size, Type type, bool skipUnknown=true)
converts a list of character in unicode
Definition: libwps_tools_win.cpp:7283
WPSPageSpan::ALL
@ ALL
Definition: WPSPageSpan.h:44
WPSHeader.h
WKS4Format::parse
bool parse()
try to parse an input
Definition: WKS4Format.cpp:108
WKS4Parser::readWindowRecord
bool readWindowRecord()
reads windows record 0:7|0:9
Definition: WKS4.cpp:1715
WKS4ParserInternal
Internal: namespace to define internal class of WKS4Parser.
Definition: WKS4.cpp:53
WKS4Parser::getDefaultFontType
libwps_tools_win::Font::Type getDefaultFontType() const
returns the default font type, ie.
Definition: WKS4.cpp:287
WPSFont
define the font properties
Definition: WPSFont.h:37
WPS_ITALICS_BIT
#define WPS_ITALICS_BIT
Definition: libwps_internal.h:502
WKS4ParserInternal::State::operator=
State & operator=(State const &)=delete
WPSPageSpan::HEADER
@ HEADER
Definition: WPSPageSpan.h:43
WPSPageSpan::FOOTER
@ FOOTER
Definition: WPSPageSpan.h:43
WPSHeader::setMajorVersion
void setMajorVersion(int version)
Definition: WPSHeader.h:94
WPSHeader::setCreator
void setCreator(libwps::WPSCreator creator)
Definition: WPSHeader.h:54
WKS4ParserInternal::State::m_headerString
librevenge::RVNGString m_headerString
the header string
Definition: WKS4.cpp:187
libwps::WPS_DATABASE
@ WPS_DATABASE
Definition: WPSDocument.h:60
WKS4ParserInternal::State::m_version
int m_version
the file version
Definition: WKS4.cpp:178
WPSPageSpan.h
WPSStringStream
internal class used to create a RVNGInputStream from a unsigned char's pointer
Definition: WPSStringStream.h:42
WKS4ParserInternal::Font
the font of a WKS4Parser
Definition: WKS4.cpp:56
WKS4ParserInternal::State::m_fontType
libwps_tools_win::Font::Type m_fontType
the user font type
Definition: WKS4.cpp:176
WKS4ParserInternal::State::getDefaultFont
WPSFont getDefaultFont() const
returns a default font (Courier12) with file's version to define the default encoding *‍/
Definition: WKS4.cpp:158
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:305
WKS4.h
WPSHeader::setNeedEncoding
void setNeedEncoding(bool needEncoding)
Definition: WPSHeader.h:84
WKSParser::getInput
RVNGInputStreamPtr & getInput()
Definition: WKSParser.h:41
libwps::ParseException
Definition: libwps_internal.h:152
libwps::PasswordException
Definition: libwps_internal.h:157
libwps::WPSCreator
WPSCreator
Definition: WPSDocument.h:48
WPS_DEBUG_MSG
#define WPS_DEBUG_MSG(M)
Definition: libwps_internal.h:134
WKS4ParserInternal::State::m_isSpreadsheet
bool m_isSpreadsheet
boolean to know if the file is a spreadsheet file or a database file
Definition: WKS4.cpp:174
libwps::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:76
WKS4ParserInternal::State::m_eof
long m_eof
the last file position
Definition: WKS4.cpp:170
WPSFont::m_color
WPSColor m_color
the font color
Definition: WPSFont.h:89
WKSParser.h
WKS4ParserInternal::State
the state of WKS4Parser
Definition: WKS4.cpp:123
WKS4Parser::checkFilePosition
bool checkFilePosition(long pos)
return true if the pos is in the file, update the file size if need
Definition: WKS4.cpp:274
WPSHeader
Definition: WPSHeader.h:32
WPSHeader::setIsEncrypted
void setIsEncrypted(bool isEncrypted)
Definition: WPSHeader.h:74
libwps_tools_win::Font::UNKNOWN
@ UNKNOWN
Definition: libwps_tools_win.h:63
libwps::read32
int32_t read32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:85
libwps::SubDocumentType
SubDocumentType
Definition: libwps_internal.h:248
WPSFont.h
WKS4ParserInternal::SubDocument::m_header
bool m_header
a flag to known if we need to send the header or the footer
Definition: WKS4.cpp:95
WKS4Parser::~WKS4Parser
~WKS4Parser() override
destructor
Definition: WKS4.cpp:252
WPSEntry.h
WPSFont::m_attributes
uint32_t m_attributes
the font attributes defined as a set of bits
Definition: WPSFont.h:85
libwps.h
libwps::DebugFile::addNote
static void addNote(char const *)
Definition: WPSDebug.h:221
WKS4Parser::m_chartParser
std::shared_ptr< WKS4Chart > m_chartParser
the chart manager
Definition: WKS4.h:150
WKS4ParserInternal::State::State
State(libwps_tools_win::Font::Type fontType, char const *password)
constructor
Definition: WKS4.cpp:125
libwps::WPS_SPREADSHEET
@ WPS_SPREADSHEET
Definition: WPSDocument.h:60
WKS4Chart
This class parses Microsoft Works chart file.
Definition: WKS4Chart.h:50
libwps::read8
int8_t read8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:59
WPSFont::m_size
double m_size
font size
Definition: WPSFont.h:83
WKS4Parser::createListener
std::shared_ptr< WKSContentListener > createListener(librevenge::RVNGSpreadsheetInterface *interface)
creates the main listener
Definition: WKS4.cpp:388
WPSSubDocumentPtr
std::shared_ptr< WPSSubDocument > WPSSubDocumentPtr
shared pointer to WPSSubDocument
Definition: libwps_internal.h:111
WKS4Parser::readCString
bool readCString(librevenge::RVNGString &string, long maxSize)
try to read a basic C string, knowing the maximum size
Definition: WKS4.cpp:1388
WPSColumnFormat::m_numRepeat
int m_numRepeat
the number times a column is repeated
Definition: WPSTable.h:92
libwps_tools_win::Font::CP_437
@ CP_437
Definition: libwps_tools_win.h:46
WKS4Parser::readPrn2
bool readPrn2()
reads another printer data. Seem simillar to ZZPrnt
Definition: WKS4.cpp:1602
WPSHeaderPtr
std::shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition: libwps_internal.h:109
WKSSubDocument
Basic class used to store a spreadsheet sub document.
Definition: WKSSubDocument.h:36
libwps::DebugStream
Definition: WPSDebug.h:192
libwps::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:40
WKS4ParserInternal::State::m_isEncrypted
bool m_isEncrypted
true if the file is encrypted
Definition: WKS4.cpp:194
WKS4Format.h
libwps_tools_win.h
WKS4Parser::getSheetName
librevenge::RVNGString getSheetName(int id) const
returns the name of the id's spreadsheet
Definition: WKS4.cpp:318
WPSPageSpan
Definition: WPSPageSpan.h:39
WPSPageSpan::setHeaderFooter
void setHeaderFooter(const HeaderFooterType type, const HeaderFooterOccurrence occurrence, WPSSubDocumentPtr &subDocument)
Definition: WPSPageSpan.cpp:111
WKS4Parser::getCreator
libwps::WPSCreator getCreator() const
returns the creator
Definition: WKS4.cpp:292
WKS4ParserInternal::State::m_hasLICSCharacters
bool m_hasLICSCharacters
flag to know if the character
Definition: WKS4.cpp:180
WKS4ParserInternal::State::m_fontsList
std::vector< Font > m_fontsList
the fonts list
Definition: WKS4.cpp:182
libwps::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:64
libwps_tools_win::Language::name
std::string name(long id)
returns the name given Windows id
Definition: libwps_tools_win.cpp:7332
WKS4Format
This class parses Lotus format file.
Definition: WKS4Format.h:49
WKS4ParserInternal::State::State
State(State const &)=delete
WKS4Parser::parse
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final
called by WPSDocument to parse the file
Definition: WKS4.cpp:324
libwps::WPS_LOTUS
@ WPS_LOTUS
Lotus DOS(wk1), Apple(Lotus 123 v1), Windows(wk3,wk4,123) spreadsheets.
Definition: WPSDocument.h:49
WKS4Parser::readHeaderFooter
bool readHeaderFooter(bool header)
reads the header/footer
Definition: WKS4.cpp:1503
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
WKS4Parser::readZoneQuattro
bool readZoneQuattro()
reads a Quattro Pro zone
Definition: WKS4.cpp:1362
WKS4ParserInternal::Font::m_type
libwps_tools_win::Font::Type m_type
font encoding type
Definition: WKS4.cpp:65
libwps::DebugFile::addDelimiter
static void addDelimiter(long, char)
Definition: WPSDebug.h:222
libwps::readDataToEnd
bool readDataToEnd(RVNGInputStreamPtr &input, librevenge::RVNGBinaryData &data)
try to read the last bytes from input and store them in a librevenge::RVNGBinaryData
Definition: libwps_internal.cpp:346
libwps_tools_win::Font::WIN3_WEUROPE
@ WIN3_WEUROPE
Definition: libwps_tools_win.h:52
WKS4ParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: WKS4.cpp:80
libwps::read16
int16_t read16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:71
libwps_tools_win::Font::DOS_850
@ DOS_850
Definition: libwps_tools_win.h:47
WKSParser::ascii
libwps::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: WKSParser.h:63
libwps_internal.h
WKS4Spreadsheet
This class parses Microsoft Works spreadsheet file.
Definition: WKS4Spreadsheet.h:49
WKSContentListener.h
WPSColor
the class to store a color
Definition: libwps_internal.h:281
WKS4Parser::m_state
std::shared_ptr< WKS4ParserInternal::State > m_state
the listener (if set)
Definition: WKS4.h:148
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:242
WKS4ParserInternal::State::m_isDecoded
bool m_isDecoded
true if the main stream has been decoded
Definition: WKS4.cpp:196
libwps_tools_win::Font::getFontType
static Type getFontType(librevenge::RVNGString &name)
returns the type of the font using the fontName
Definition: libwps_tools_win.cpp:39
WKS4ParserInternal::Font::Font
Font(Font const &)=default
WKSContentListener
Definition: WKSContentListener.h:54
WKS4ParserInternal::SubDocument::operator==
virtual bool operator==(std::shared_ptr< WKSSubDocument > const &doc) const final
operator==
Definition: WKS4.cpp:83
WKS4Parser::creator
libwps::WPSCreator creator() const
return the file creator
Definition: WKS4.cpp:261
WKS4Parser::version
int version() const
return the file version
Definition: WKS4.cpp:256
WKS4Parser
This class parses Microsoft Works spreadsheet or a database file.
Definition: WKS4.h:49
WKSParser::getFileInput
RVNGInputStreamPtr getFileInput()
Definition: WKSParser.cpp:44
libwps_tools_win
some Windows classes and tools
Definition: libwps_tools_win.cpp:32
libwps::WPS_MSWORKS
@ WPS_MSWORKS
Microsoft Works documents (all wps, wks and wdb)
Definition: WPSDocument.h:48
WPSStringStream.h
WKS4Parser::getColor
bool getColor(int id, WPSColor &color) const
returns the color corresponding to an id
Definition: WKS4.cpp:300
WKS4Parser::readFont
bool readFont()
reads a mswork font
Definition: WKS4.cpp:1410
WKS4ParserInternal::State::m_pageSpan
WPSPageSpan m_pageSpan
the actual document size
Definition: WKS4.cpp:184
WKS4ParserInternal::SubDocument
Internal: the subdocument of a WPS4Parser.
Definition: WKS4.cpp:74
WPSFont::m_name
librevenge::RVNGString m_name
font name
Definition: WPSFont.h:81
libwps::DebugFile::setStream
static void setStream(RVNGInputStreamPtr)
Definition: WPSDebug.h:212
WKS4Parser::readFieldName
bool readFieldName()
read a list of field name + ...
Definition: WKS4.cpp:1647
WKS4Parser::m_listener
std::shared_ptr< WKSContentListener > m_listener
Definition: WKS4.h:146
WKSParser
Definition: WKSParser.h:34

Generated on Sun Nov 12 2023 12:30:57 for libwps by doxygen 1.8.20