WPS4.h Source File documentation

WPS4.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 WPS4_H
23 #define WPS4_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
31 #include "WPSParser.h"
32
33 class WPSPageSpan;
34
35 namespace WPS4ParserInternal
36 {
37 class SubDocument;
38 struct State;
39 }
40
41 class WPS4Graph;
42 class WPS4Text;
43
48 class WPS4Parser final : public WPSParser
49 {
50 friend class WPS4ParserInternal::SubDocument;
51 friend class WPS4Graph;
52 friend class WPS4Text;
53
54 public:
56 WPS4Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
57 libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN);
59 ~WPS4Parser() final;
61 void parse(librevenge::RVNGTextInterface *documentInterface) final;
63 bool checkHeader(WPSHeader *header, bool strict=false);
64 protected:
66 bool getColor(int id, WPSColor &color) const;
67
69 void setSizeFile(long sz);
71 bool checkFilePosition(long pos);
72
74 void newPage(int number);
76 void setListener(std::shared_ptr<WPSContentListener> const &listener);
77
79 bool createStructures();
81 bool createOLEStructures();
83 std::shared_ptr<WPSContentListener> createListener(librevenge::RVNGTextInterface *interface);
84
85 // interface with text parser
86
88 float pageHeight() const;
90 float pageWidth() const;
92 int numColumns() const;
96 libwps_tools_win::Font::Type getDefaultFontType() const;
98 libwps_tools_win::Font::Type getOEMFontType() const;
99
103 void createDocument(WPSEntry const &entry, libwps::SubDocumentType type);
105 void createNote(WPSEntry const &entry, librevenge::RVNGString const &label);
107 void createTextBox(WPSEntry const &entry, WPSPosition const &pos, librevenge::RVNGPropertyList &extras);
109 void send(WPSEntry const &entry, libwps::SubDocumentType type);
110
111 // interface with graph parser
112
116 int readObject(RVNGInputStreamPtr input, WPSEntry const &entry);
117
121 void sendObject(WPSPosition const &position, int id);
122
123 //
124 // low level
125 //
126
128 bool findZones();
129
133 bool parseEntry(std::string const &name);
134
136 bool readDocDim();
137
139 bool readPrnt(WPSEntry const &entry);
140
145 bool readDocWindowsInfo(WPSEntry const &entry);
146
147 std::shared_ptr<WPSContentListener> m_listener; /* the listener (if set)*/
149 std::shared_ptr<WPS4Graph> m_graphParser;
151 std::shared_ptr<WPS4Text> m_textParser;
153 std::shared_ptr<WPS4ParserInternal::State> m_state;
154 };
155
156 #endif /* WPS4_H */
157 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSTextSubDocument.h
WPS4Parser::createNote
void createNote(WPSEntry const &entry, librevenge::RVNGString const &label)
creates a document for a footnote entry with label and then send the data
Definition: WPS4.cpp:366
WPS4ParserInternal::State
the state of WPS4
Definition: WPS4.cpp:129
WPS4ParserInternal::State::m_numPages
int m_numPages
Definition: WPS4.cpp:156
WPS4ParserInternal::SubDocument::operator==
bool operator==(std::shared_ptr< WPSSubDocument > const &doc) const final
operator==
Definition: WPS4.cpp:57
WPS4ParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: WPS4.cpp:54
WPS4Parser::setSizeFile
void setSizeFile(long sz)
sets the file size ( filled by WPS4Text )
Definition: WPS4.cpp:242
libwps::DebugStream::str
static std::string str()
Definition: WPSDebug.h:200
libwps::DebugFile::open
static bool open(std::string const &)
Definition: WPSDebug.h:215
WPS4ParserInternal::State::m_noFirstPageHeader
bool m_noFirstPageHeader
Definition: WPS4.cpp:153
WPS4Graph.h
WPS4Parser::~WPS4Parser
~WPS4Parser() final
destructor
Definition: WPS4.cpp:174
libwps::DebugFile::addPos
static void addPos(long)
Definition: WPSDebug.h:220
WPS4ParserInternal::SubDocument::MN
@ MN
Definition: WPS4.cpp:49
WPSEntry::end
long end() const
returns the end offset
Definition: WPSEntry.h:78
WPS4Parser::getColor
bool getColor(int id, WPSColor &color) const
color
Definition: WPS4.cpp:206
libwps::Debug::dumpFile
bool dumpFile(librevenge::RVNGBinaryData &, char const *)
Definition: WPSDebug.h:180
WPSEntry::setLength
void setLength(long l)
sets the zone size
Definition: WPSEntry.h:62
libwps_tools_win::Font::Type
Type
enum Type
Definition: libwps_tools_win.h:46
WPS4Parser::createListener
std::shared_ptr< WPSContentListener > createListener(librevenge::RVNGTextInterface *interface)
creates the main listener
Definition: WPS4.cpp:269
WPSParser::setVersion
void setVersion(int vers)
Definition: WPSParser.h:60
WPS4ParserInternal::State::m_OEMFontType
libwps_tools_win::Font::Type m_OEMFontType
the OEM code page
Definition: WPS4.cpp:150
WPS4ParserInternal::SubDocument::Unknown
@ Unknown
Definition: WPS4.cpp:49
WPS4Parser::numColumns
int numColumns() const
returns the number of columns
Definition: WPS4.cpp:189
WPSOLEParser::getObjectsMap
std::map< int, WPSEmbeddedObject > const & getObjectsMap() const
returns the list of data positions which have been read
Definition: WPSOLEParser.cpp:281
WPSPageSpan::LANDSCAPE
@ LANDSCAPE
Definition: WPSPageSpan.h:41
WPSContentListenerPtr
std::shared_ptr< WPSContentListener > WPSContentListenerPtr
shared pointer to WPSContentListener
Definition: libwps_internal.h:107
libwps
Definition: libwps_internal.cpp:39
WPS4Parser::pageHeight
float pageHeight() const
returns the page height, ie. paper size less margin (in inches)
Definition: WPS4.cpp:179
WPS4Parser::newPage
void newPage(int number)
adds a new page
Definition: WPS4.cpp:307
WPSOLEParser::getNotParse
std::vector< std::string > const & getNotParse() const
returns the list of unknown ole
Definition: WPSOLEParser.cpp:276
WPSTextSubDocument::m_parser
WPSParser * m_parser
Definition: WPSTextSubDocument.h:62
WPS4ParserInternal::State::m_eof
long m_eof
the last file position
Definition: WPS4.cpp:146
WPS4Text
The class which parses text zones in a pc MS Works document v1-4.
Definition: WPS4Text.h:65
libwps::DebugFile::reset
static void reset()
Definition: WPSDebug.h:224
WPSOLEParser
a class used to parse some basic oles Tries to read the different ole parts and stores their contents...
Definition: WPSOLEParser.h:86
WPSPageSpan::setMarginRight
void setMarginRight(const double marginRight)
Definition: WPSPageSpan.h:134
WPS4Parser::m_graphParser
std::shared_ptr< WPS4Graph > m_graphParser
the graph parser
Definition: WPS4.h:149
WPSPageSpan::ALL
@ ALL
Definition: WPSPageSpan.h:44
WPSHeader.h
WPS4Parser::pageWidth
float pageWidth() const
returns the page width, ie. paper size less margin (in inches)
Definition: WPS4.cpp:184
WPS4Parser::m_state
std::shared_ptr< WPS4ParserInternal::State > m_state
the internal state
Definition: WPS4.h:153
WPSContentListener
Definition: WPSContentListener.h:45
WPSEntry::valid
bool valid(bool checkId=false) const
returns true if the zone length is positive
Definition: WPSEntry.h:89
WPS4Parser::createOLEStructures
bool createOLEStructures()
tries to parse the different OLE zones ( except the main zone )
Definition: WPS4.cpp:462
WPS4Parser::readDocWindowsInfo
bool readDocWindowsInfo(WPSEntry const &entry)
reads the additional windows info
Definition: WPS4.cpp:978
WPSPageSpan::HEADER
@ HEADER
Definition: WPSPageSpan.h:43
WPSPageSpan::FOOTER
@ FOOTER
Definition: WPSPageSpan.h:43
WPSEntry
basic class to store an entry in a file This contained :
Definition: WPSEntry.h:39
WPSHeader::setMajorVersion
void setMajorVersion(int version)
Definition: WPSHeader.h:94
WPS4ParserInternal::State::m_isDosFile
bool m_isDosFile
flag to know if the file is or not a dos file
Definition: WPS4.cpp:144
WPSParser::getNameEntryMap
NameMultiMap & getNameEntryMap()
Definition: WPSParser.h:70
WPS4Parser::WPS4Parser
WPS4Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header, libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::UNKNOWN)
constructor
Definition: WPS4.cpp:161
WPSParser
Definition: WPSParser.h:36
WPS_PAGE_BREAK
#define WPS_PAGE_BREAK
Definition: libwps_internal.h:519
WPS4Parser::WPS4Graph
friend class WPS4Graph
Definition: WPS4.h:51
WPS4Graph
the main class to read/store picture in a Pc MS Works document v1-4
Definition: WPS4Graph.h:57
WPS4Parser::getDefaultFontType
libwps_tools_win::Font::Type getDefaultFontType() const
returns the default font type, ie.
Definition: WPS4.cpp:194
WPSPageSpan.h
WPSEntry::setId
void setId(int i)
sets the id
Definition: WPSEntry.h:163
WPS4Parser::checkFilePosition
bool checkFilePosition(long pos)
return true if the pos is in the file, update the file size if need
Definition: WPS4.cpp:248
WPSOLEParser::parse
bool parse(RVNGInputStreamPtr fileInput)
tries to parse basic OLE (excepted mainName)
Definition: WPSOLEParser.cpp:318
WPS4Parser::createDocument
void createDocument(WPSEntry const &entry, libwps::SubDocumentType type)
creates a document for a comment entry and then send the data
Definition: WPS4.cpp:353
WPSHeader::setNeedEncoding
void setNeedEncoding(bool needEncoding)
Definition: WPSHeader.h:84
WPSParser::getFileInput
RVNGInputStreamPtr getFileInput()
Definition: WPSParser.cpp:45
libwps::ParseException
Definition: libwps_internal.h:152
WPS_DEBUG_MSG
#define WPS_DEBUG_MSG(M)
Definition: libwps_internal.h:134
libwps::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:76
WPS_FALLTHROUGH
#define WPS_FALLTHROUGH
fall through attributes
Definition: libwps_internal.h:82
WPSEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: WPSEntry.h:57
WPSContentListener.h
WPSOLEParser.h
libwps_tools_win::Font::getTypeName
static librevenge::RVNGString getTypeName(Type type)
return the type name
Definition: libwps_tools_win.cpp:259
WPSHeader
Definition: WPSHeader.h:32
libwps::DOC_COMMENT_ANNOTATION
@ DOC_COMMENT_ANNOTATION
Definition: libwps_internal.h:248
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
WPSPageSpan::setFormWidth
void setFormWidth(const double formWidth)
Definition: WPSPageSpan.h:122
libwps::SubDocumentType
SubDocumentType
Definition: libwps_internal.h:248
WPSPageSpan::PORTRAIT
@ PORTRAIT
Definition: WPSPageSpan.h:41
WPSEntry::setType
void setType(std::string const &tp)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: WPSEntry.h:126
WPS4Parser::checkHeader
bool checkHeader(WPSHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: WPS4.cpp:545
WPS4Parser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
called by WPSDocument to parse the file
Definition: WPS4.cpp:387
WPS4Parser::getOEMFontType
libwps_tools_win::Font::Type getOEMFontType() const
returns the document codepage ( given from the file OEM field )
Definition: WPS4.cpp:201
WPSEntry.h
WPS4ParserInternal::SubDocument::SubDocument
SubDocument(RVNGInputStreamPtr const &input, WPS4Parser &pars, WPSEntry const &entry)
constructor for a text entry
Definition: WPS4.cpp:51
libwps::DebugFile::addNote
static void addNote(char const *)
Definition: WPSDebug.h:221
WPSParser::getInput
RVNGInputStreamPtr & getInput()
Definition: WPSParser.h:47
WPS4ParserInternal::State::m_pageSpan
WPSPageSpan m_pageSpan
the actual document size
Definition: WPS4.cpp:152
libwps::DOC_HEADER_FOOTER
@ DOC_HEADER_FOOTER
Definition: libwps_internal.h:248
WPSEntry::begin
long begin() const
returns the begin offset
Definition: WPSEntry.h:73
WPS4Parser::send
void send(WPSEntry const &entry, libwps::SubDocumentType type)
sends text corresponding to the entry to the listener (via WPS4Text)
Definition: WPS4.cpp:339
WPS4ParserInternal::State::State
State(libwps_tools_win::Font::Type fontType)
Definition: WPS4.cpp:130
WPSEntry::type
std::string const & type() const
returns the type of the entry
Definition: WPSEntry.h:131
libwps::read8
int8_t read8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:59
WPSSubDocumentPtr
std::shared_ptr< WPSSubDocument > WPSSubDocumentPtr
shared pointer to WPSSubDocument
Definition: libwps_internal.h:111
WPSPageSpan::setMarginTop
void setMarginTop(const double marginTop)
Definition: WPSPageSpan.h:138
WPS4ParserInternal::SubDocument::m_entry
WPSEntry m_entry
the entry
Definition: WPS4.cpp:69
WPSEntry::length
long length() const
returns the length of the zone
Definition: WPSEntry.h:83
WPSHeaderPtr
std::shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition: libwps_internal.h:109
WPS4Parser::readDocDim
bool readDocDim()
tries to read the document dimension
Definition: WPS4.cpp:839
WPS4ParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: WPS4.cpp:156
libwps::DebugStream
Definition: WPSDebug.h:192
WPSEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: WPSEntry.h:115
WPSPageSpan::setFormOrientation
void setFormOrientation(const FormOrientation formOrientation)
Definition: WPSPageSpan.h:126
libwps::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:40
WPSParser::version
int version() const
Definition: WPSParser.h:56
WPS4ParserInternal::SubDocument::Type
Type
type of an entry stored in textId
Definition: WPS4.cpp:49
WPS4Parser::createStructures
bool createStructures()
tries to parse the main zone, ...
Definition: WPS4.cpp:445
WPS4ParserInternal
Definition: WPS4.cpp:43
WPS4.h
WPSPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
Definition: WPSPageSpan.h:142
WPS4Parser::WPS4Text
friend class WPS4Text
Definition: WPS4.h:52
libwps_tools_win::Font::getTypeForOEM
static Type getTypeForOEM(int oem)
Definition: libwps_tools_win.cpp:112
libwps_tools_win.h
WPSParser.h
WPSParser::ascii
libwps::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: WPSParser.h:65
WPS4Parser::readObject
int readObject(RVNGInputStreamPtr input, WPSEntry const &entry)
tries to read a picture ( via its WPS4Graph )
Definition: WPS4.cpp:326
WPSPageSpan
Definition: WPSPageSpan.h:39
WPSPageSpan::setHeaderFooter
void setHeaderFooter(const HeaderFooterType type, const HeaderFooterOccurrence occurrence, WPSSubDocumentPtr &subDocument)
Definition: WPSPageSpan.cpp:111
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
WPSEntry::hasType
bool hasType(std::string const &tp) const
returns true if the type entry == type
Definition: WPSEntry.h:136
WPS4Parser
This class parses Works version 2 through 4.
Definition: WPS4.h:49
WPS4ParserInternal::State::m_noFirstPageFooter
bool m_noFirstPageFooter
Definition: WPS4.cpp:154
WPS4ParserInternal::State::m_fontType
libwps_tools_win::Font::Type m_fontType
the user font type
Definition: WPS4.cpp:148
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
WPSTextSubDocument
Basic class used to store a sub document.
Definition: WPSTextSubDocument.h:36
WPS4ParserInternal::SubDocument::parse
void parse(std::shared_ptr< WPSContentListener > &listener, libwps::SubDocumentType subDocumentType) final
the parser function
Definition: WPS4.cpp:72
WPS4ParserInternal::State::m_numColumns
int m_numColumns
the number of columns
Definition: WPS4.cpp:155
WPS4Text.h
WPSPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: WPSPosition.h:40
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
WPS4Parser::findZones
bool findZones()
finds the different zones (text, print, ...) and updates nameMultiMap
Definition: WPS4.cpp:569
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
libwps_internal.h
WPSColor
the class to store a color
Definition: libwps_internal.h:281
WPSEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: WPSEntry.h:120
librevenge
Definition: WPSOLEStream.h:34
WPS4Parser::m_listener
std::shared_ptr< WPSContentListener > m_listener
Definition: WPS4.h:147
WPS4Parser::parseEntry
bool parseEntry(std::string const &name)
parses an entry
Definition: WPS4.cpp:509
libwps_tools_win
some Windows© classes and tools
Definition: libwps_tools_win.cpp:32
WPSPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
Definition: WPSPageSpan.h:130
WPS4ParserInternal::SubDocument
Internal: the subdocument of a WPS4Parser.
Definition: WPS4.cpp:46
WPS4Parser::readPrnt
bool readPrnt(WPSEntry const &entry)
tries to read the printer information
Definition: WPS4.cpp:906
WPSPageSpan::setFormLength
void setFormLength(const double formLength)
Definition: WPSPageSpan.h:118
WPS4Parser::setListener
void setListener(std::shared_ptr< WPSContentListener > const &listener)
set the listener
Definition: WPS4.cpp:262
WPS4Parser::createTextBox
void createTextBox(WPSEntry const &entry, WPSPosition const &pos, librevenge::RVNGPropertyList &extras)
creates a textbox and then send the data
Definition: WPS4.cpp:374
WPS4Parser::sendObject
void sendObject(WPSPosition const &position, int id)
sends an object with given id ( via its WPS4Graph )
Definition: WPS4.cpp:334
WPSContentListener::FOOTNOTE
@ FOOTNOTE
Definition: WPSContentListener.h:99
libwps::DebugFile::setStream
static void setStream(RVNGInputStreamPtr)
Definition: WPSDebug.h:212
WPS4Parser::m_textParser
std::shared_ptr< WPS4Text > m_textParser
the text parser
Definition: WPS4.h:151