GreatWksParser.hxx Source File documentation

GreatWksParser.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 #ifndef GREAT_WKS_PARSER
35 # define GREAT_WKS_PARSER
36
37 #include <string>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWDebug.hxx"
43
44 #include "MWAWParser.hxx"
45
46 namespace GreatWksParserInternal
47 {
48 struct State;
49 class SubDocument;
50 }
51
52 class GreatWksDocument;
53
56 class GreatWksParser final : public MWAWTextParser
57 {
58 friend class GreatWksParserInternal::SubDocument;
59 public:
61 GreatWksParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
63 ~GreatWksParser() final;
64
66 bool checkHeader(MWAWHeader *header, bool strict=false) final;
67
68 // the main parse function
69 void parse(librevenge::RVNGTextInterface *documentInterface) final;
70
71 protected:
73 void init();
74
76 void createDocument(librevenge::RVNGTextInterface *documentInterface);
77
79 void newPage(int number);
80
81 // interface with the text parser
82
84 MWAWSection getMainSection() const;
86 bool sendHF(int id);
87
88 protected:
90 bool createZones();
91
92 //
93 // low level
94 //
95
97 bool readDocInfo();
98
99 //
100 // data
101 //
102
104 std::shared_ptr<GreatWksParserInternal::State> m_state;
105
107 std::shared_ptr<GreatWksDocument> m_document;
108 };
109 #endif
110 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWTextListenerPtr
std::shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:567
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:299
GreatWksParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: GreatWksParser.cxx:500
GreatWksParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: GreatWksParser.cxx:271
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
GreatWksParserInternal::State::getSection
MWAWSection getSection() const
returns a section
Definition: GreatWksParser.cxx:86
MWAWHeaderFooter::HEADER
@ HEADER
Definition: MWAWPageSpan.hxx:48
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
MWAWHeaderFooter::EVEN
@ EVEN
Definition: MWAWPageSpan.hxx:50
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
GreatWksParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: GreatWksParser.cxx:145
MWAWSection::m_columnSeparator
MWAWBorder m_columnSeparator
the vertical separator between columns
Definition: MWAWSection.hxx:112
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
GreatWksDocument::GetMainSection
MWAWSection(MWAWParser::* GetMainSection)() const
callback used to return the main section
Definition: GreatWksDocument.hxx:171
GreatWksParser::readDocInfo
bool readDocInfo()
read the DocInfo block ( many unknown data )
Definition: GreatWksParser.cxx:374
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:208
GreatWksParser
the main class to read a GreatWorks text file
Definition: GreatWksParser.hxx:57
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
GreatWksParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: GreatWksParser.cxx:116
MWAWPrinter.hxx
GreatWksParserInternal
Internal: the structures of a GreatWksParser.
Definition: GreatWksParser.cxx:59
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:193
MWAWHeaderFooter::m_subDocument
MWAWSubDocumentPtr m_subDocument
the document data
Definition: MWAWPageSpan.hxx:92
MWAWParser::getTextListener
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition: MWAWParser.hxx:145
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
GreatWksParserInternal::State::m_columnsWidth
std::vector< double > m_columnsWidth
the columns dimension
Definition: GreatWksParser.cxx:111
MWAWSubDocument
abstract class used to store a subdocument (with a comparison function)
Definition: MWAWSubDocument.hxx:42
GreatWksDocument::NewPage
void(MWAWParser::* NewPage)(int page)
callback used to send a page break
Definition: GreatWksDocument.hxx:173
GreatWksParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: GreatWksParser.cxx:238
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
MWAWHeaderFooter
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:45
GreatWksParserInternal::State::m_hfFlags
bool m_hfFlags[4]
flags to define header/footer (titlePage, l/rPage, header, footer)
Definition: GreatWksParser.cxx:113
GreatWksParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: GreatWksParser.cxx:132
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
MWAWSubDocument.hxx
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
GreatWksParser::~GreatWksParser
~GreatWksParser() final
destructor
Definition: GreatWksParser.cxx:187
MWAWSubDocument::m_input
std::shared_ptr< MWAWInputStream > m_input
the input
Definition: MWAWSubDocument.hxx:77
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
GreatWksParserInternal::State
Internal: the state of a GreatWksParser.
Definition: GreatWksParser.cxx:63
MWAWParser::setTextListener
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:158
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:227
MWAWParagraph.hxx
MWAWRSRCParser.hxx
MWAWPosition.hxx
MWAWDocument::MWAW_K_TEXT
@ MWAW_K_TEXT
word processing file
Definition: MWAWDocument.hxx:82
GreatWksGraph.hxx
GreatWksParserInternal::State::m_headerHeight
int m_headerHeight
the header height if known
Definition: GreatWksParser.cxx:118
GreatWksParser.hxx
MWAWBorder
a border
Definition: libmwaw_internal.hxx:333
MWAWSection::m_columns
std::vector< Column > m_columns
the different column
Definition: MWAWSection.hxx:108
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
libmwaw::DOC_HEADER_FOOTER
@ DOC_HEADER_FOOTER
Definition: libmwaw_internal.hxx:188
GreatWksParser::GreatWksParser
GreatWksParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: GreatWksParser.cxx:179
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
GreatWksParserInternal::SubDocument::SubDocument
SubDocument(GreatWksParser &pars, MWAWInputStreamPtr const &input, int zoneId)
Definition: GreatWksParser.cxx:127
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
MWAWHeaderFooter::ODD
@ ODD
Definition: MWAWPageSpan.hxx:50
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:46
libmwaw::ParseException
Definition: libmwaw_internal.hxx:144
MWAWDebug.hxx
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
GreatWksParser::init
void init()
inits all internal variables
Definition: GreatWksParser.cxx:191
GreatWksParserInternal::State::m_hasColSep
bool m_hasColSep
true if columns have columns separator
Definition: GreatWksParser.cxx:115
GreatWksParser::m_state
std::shared_ptr< GreatWksParserInternal::State > m_state
the state
Definition: GreatWksParser.hxx:104
GreatWksDocument.hxx
GreatWksParserInternal::State::State
State()
constructor
Definition: GreatWksParser.cxx:65
GreatWksParserInternal::State::m_footerHeight
int m_footerHeight
the footer height if known
Definition: GreatWksParser.cxx:119
MWAWPageSpan::setMarginTop
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:203
GreatWksParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: GreatWksParser.cxx:116
MWAWHeaderFooter::FOOTER
@ FOOTER
Definition: MWAWPageSpan.hxx:48
GreatWksParser::m_document
std::shared_ptr< GreatWksDocument > m_document
the main document
Definition: GreatWksParser.hxx:107
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
GreatWksParser::newPage
void newPage(int number)
adds a new page
Definition: GreatWksParser.cxx:222
MWAWHeaderFooter::ALL
@ ALL
Definition: MWAWPageSpan.hxx:50
GreatWksParser::getMainSection
MWAWSection getMainSection() const
return the main section
Definition: GreatWksParser.cxx:209
GreatWksParserInternal::SubDocument
Internal: the subdocument of a GreatWksParser.
Definition: GreatWksParser.cxx:125
GreatWksDocument
the main class to read/store generic data of a GreatWorks document
Definition: GreatWksDocument.hxx:61
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
MWAWTextListener.hxx
Defines MWAWTextListener: the libmwaw word processor listener.
GreatWksParser::createZones
bool createZones()
finds the different objects zones
Definition: GreatWksParser.cxx:334
GreatWksParserInternal::State::numHeaderFooters
int numHeaderFooters() const
returns the number of expected header/footer zones
Definition: GreatWksParser.cxx:76
libmwaw::Right
@ Right
Definition: libmwaw_internal.hxx:176
GreatWksParserInternal::SubDocument::m_id
int m_id
the subdocument id
Definition: GreatWksParser.cxx:142
MWAWSubDocument::m_parser
MWAWParser * m_parser
the main zone parser
Definition: MWAWSubDocument.hxx:75
MWAWSection.hxx
GreatWksText.hxx
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:198
MWAWPageSpan::setHeaderFooter
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition: MWAWPageSpan.cxx:227
libmwaw::Left
@ Left
Definition: libmwaw_internal.hxx:176
GreatWksParserInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: GreatWksParser.cxx:166
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
librevenge
Definition: MWAWDocument.hxx:57
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:213
GreatWksParser::sendHF
bool sendHF(int id)
try to send the i^th header/footer
Definition: GreatWksParser.cxx:214
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
MWAWParser.hxx
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:99
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:163