MoreParser.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 MORE_PARSER
35 # define MORE_PARSER
36 
37 #include <string>
38 #include <vector>
39 
40 #include <librevenge/librevenge.h>
41 
42 #include "MWAWDebug.hxx"
43 #include "MWAWInputStream.hxx"
44 
45 #include "MWAWParser.hxx"
46 
47 namespace MoreParserInternal
48 {
49 class SubDocument;
50 struct State;
51 }
52 
53 class MoreText;
54 
57 namespace MoreStruct
58 {
59 struct Pattern {
62  {
63  for (int i=0; i<8; i++) m_pattern[i]=0;
64  }
66  friend std::ostream &operator<<(std::ostream &o, Pattern const &pat);
68  unsigned char m_pattern[8];
73 };
74 }
75 
78 class MoreParser : public MWAWTextParser
79 {
81  friend class MoreText;
82 public:
84  MoreParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
86  virtual ~MoreParser();
87 
89  bool checkHeader(MWAWHeader *header, bool strict=false);
90 
91  // the main parse function
92  void parse(librevenge::RVNGTextInterface *documentInterface);
93 
94 protected:
96  void init();
97 
99  void createDocument(librevenge::RVNGTextInterface *documentInterface);
100 
102  MWAWVec2f getPageLeftTop() const;
104  void newPage(int number);
106  bool getColor(int id, MWAWColor &col) const;
107 
108  // interface with the text parser
109 
110 protected:
112  bool createZones();
113 
115  bool readZonesList();
116 
118  bool readPrintInfo(MWAWEntry const &entry);
119 
121  bool readDocumentInfo(MWAWEntry const &entry);
122 
124  bool readSlideList(MWAWEntry const &entry);
125 
127  bool readSlide(MWAWEntry const &entry);
128 
130  bool readGraphic(MWAWEntry const &entry);
131 
133  bool readUnknown9(MWAWEntry const &entry);
134 
136  bool readColors(long endPos);
137 
139  bool readPattern(long endPos, MoreStruct::Pattern &pattern);
140 
142  bool readBackside(long endPos, std::string &extra);
143 
145  bool readFreePos(MWAWEntry const &entry);
146 
148  bool readUnkn9Sub(long endPos);
149 
150  //
151  // low level
152  //
153 
155  bool checkAndStore(MWAWEntry const &entry);
156 
158  bool checkAndFindSize(MWAWEntry &entry);
159 
162 
165 
166  //
167  // data
168  //
169 
171  shared_ptr<MoreParserInternal::State> m_state;
172 
174  shared_ptr<MoreText> m_textParser;
175 };
176 #endif
177 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
MoreStruct::Pattern::operator<<
friend std::ostream & operator<<(std::ostream &o, Pattern const &pat)
operator<<
Definition: MoreParser.cxx:1295
MoreParser::readSlideList
bool readSlideList(MWAWEntry const &entry)
read the list of slide definitions
Definition: MoreParser.cxx:781
MoreStruct::Pattern::Pattern
Pattern()
constructor
Definition: MoreParser.hxx:61
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:296
MoreParser::readUnknown9
bool readUnknown9(MWAWEntry const &entry)
read a unknown zone ( block 9 )
Definition: MoreParser.cxx:981
MoreParserInternal::State::m_typeEntryMap
std::multimap< std::string, MWAWEntry > m_typeEntryMap
a map type -> entry
Definition: MoreParser.cxx:71
MoreParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface)
virtual function used to parse the input
Definition: MoreParser.cxx:250
MWAWTextListenerPtr
shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:519
MoreStruct::operator<<
std::ostream & operator<<(std::ostream &o, Pattern const &pat)
Definition: MoreParser.cxx:1295
MoreText
the main class to read the text part of More Text file
Definition: MoreText.hxx:65
MWAWDocument::MWAW_T_MORE
@ MWAW_T_MORE
More (v2-3): retrieve the organization part but not the slide/tree parts.
Definition: MWAWDocument.hxx:129
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:262
MoreParser::~MoreParser
virtual ~MoreParser()
destructor
Definition: MoreParser.cxx:152
MoreParser::readBackside
bool readBackside(long endPos, std::string &extra)
read a backside ( some sub zone of block 9)
Definition: MoreParser.cxx:1110
MWAWHeaderFooter::HEADER
@ HEADER
Definition: MWAWPageSpan.hxx:48
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:127
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:785
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
MoreStruct::Pattern::m_backColor
MWAWColor m_backColor
the back color
Definition: MoreParser.hxx:72
MoreParser::m_textParser
shared_ptr< MoreText > m_textParser
the text parser
Definition: MoreParser.hxx:174
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:110
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
MoreStruct::Pattern::m_pattern
unsigned char m_pattern[8]
the pattern
Definition: MoreParser.hxx:68
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
MoreParser
the main class to read a More file
Definition: MoreParser.hxx:79
MoreParserInternal::State::setDefaultColorList
void setDefaultColorList(int version)
set the default color map
Definition: MoreParser.cxx:82
MoreParserInternal::State::m_footerHeight
int m_footerHeight
the footer height if known
Definition: MoreParser.cxx:79
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:202
MoreParser::readPrintInfo
bool readPrintInfo(MWAWEntry const &entry)
read a PrintInfo zone ( first block )
Definition: MoreParser.cxx:462
MWAWFontConverter.hxx
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:182
MoreParserInternal::SubDocument::SubDocument
SubDocument(MoreParser &pars, MWAWInputStreamPtr input)
Definition: MoreParser.cxx:104
MoreParser::readDocumentInfo
bool readDocumentInfo(MWAWEntry const &entry)
read a docinfo zone ( second block )
Definition: MoreParser.cxx:515
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:126
MoreParser::m_state
shared_ptr< MoreParserInternal::State > m_state
the state
Definition: MoreParser.hxx:171
MoreParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type)
the parser function
Definition: MoreParser.cxx:131
MWAWPrinter.hxx
MoreParserInternal::SubDocument
Internal: the subdocument of a MoreParser.
Definition: MoreParser.cxx:102
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:187
MWAWColor::str
std::string str() const
print the color in the form #rrggbb
Definition: libmwaw_internal.cxx:231
MWAWHeaderFooter::m_subDocument
MWAWSubDocumentPtr m_subDocument
the document data
Definition: MWAWPageSpan.hxx:89
libmwaw::PrinterInfo
the AppleŠ printer information : TPrint
Definition: MWAWPrinter.hxx:82
MoreStruct::Pattern
Definition: MoreParser.hxx:59
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:115
MWAWParser::getTextListener
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition: MWAWParser.hxx:145
MoreParser::readSlide
bool readSlide(MWAWEntry const &entry)
read a slide definitions
Definition: MoreParser.cxx:842
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
MWAWSubDocument
abstract class used to store a subdocument (with a comparison function)
Definition: MWAWSubDocument.hxx:42
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
MoreParser::newPage
void newPage(int number)
adds a new page
Definition: MoreParser.cxx:221
MWAWHeaderFooter
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:45
MoreParser::createZones
bool createZones()
finds the different objects zones
Definition: MoreParser.cxx:323
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
MoreStruct::Pattern::m_frontColor
MWAWColor m_frontColor
the front color
Definition: MoreParser.hxx:70
MoreParser::getColor
bool getColor(int id, MWAWColor &col) const
return the color which corresponds to an id (if possible)
Definition: MoreParser.cxx:234
MoreParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: MoreParser.cxx:76
MWAWSubDocument.hxx
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:172
MoreParser::readFreePos
bool readFreePos(MWAWEntry const &entry)
read the list of free file position
Definition: MoreParser.cxx:633
MoreParserInternal::State::State
State()
constructor
Definition: MoreParser.cxx:64
MoreParser::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: MoreParser.cxx:174
MoreParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: MoreParser.cxx:727
MWAWPictData::check
static ReadResult check(MWAWInputStreamPtr input, int size, MWAWBox2f &box)
checks if the data pointed by input is known
Definition: MWAWPictData.hxx:100
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:178
MWAWPageSpan::setBackgroundColor
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition: MWAWPageSpan.hxx:252
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:85
MoreStruct
a namespace used to define basic structures in a More file
Definition: MoreParser.cxx:1294
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:121
MWAWParser::setTextListener
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:146
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:227
MWAWParagraph.hxx
libmwaw::DebugFile::skipZone
void skipZone(long beginPos, long endPos)
skips the file zone defined by beginPos-endPos
Definition: MWAWDebug.hxx:105
MWAWRSRCParser.hxx
MWAWVec2::y
T y() const
second element
Definition: libmwaw_internal.hxx:620
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:190
libmwaw::Debug::dumpFile
bool dumpFile(librevenge::RVNGBinaryData &data, char const *fileName)
a debug function to store in a datafile in the current directory WARNING: this function erase the fil...
Definition: MWAWDebug.cxx:197
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:177
MWAWPosition.hxx
MWAWParser::getFormLength
double getFormLength() const
returns the form length
Definition: MWAWParser.hxx:170
MoreParser::readPattern
bool readPattern(long endPos, MoreStruct::Pattern &pattern)
read a pattern ( some sub zone of block 9)
Definition: MoreParser.cxx:1160
MWAWVec2::x
T x() const
first element
Definition: libmwaw_internal.hxx:615
MoreParser::checkAndFindSize
bool checkAndFindSize(MWAWEntry &entry)
check if the entry is valid defined by the begin pos points to a zone: dataSz data
Definition: MoreParser.cxx:202
MoreText.hxx
MoreParser.hxx
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:56
MWAWColor::isBlack
bool isBlack() const
return true if the color is black
Definition: libmwaw_internal.hxx:265
MWAWParser::setVersion
void setVersion(int vers)
sets the document's version
Definition: MWAWParser.hxx:206
MoreParser::init
void init()
inits all internal variables
Definition: MoreParser.cxx:156
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:82
MWAWPictData.hxx
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
MWAWPict::MWAW_R_BAD
@ MWAW_R_BAD
Definition: MWAWPict.hxx:73
MWAWVec2< float >
libmwaw::ParseException
Definition: libmwaw_internal.hxx:142
MWAWDebug.hxx
MoreParser::readColors
bool readColors(long endPos)
read a color zone ( beginning of block 9 )
Definition: MoreParser.cxx:1068
MoreParserInternal::State::m_backgroundColor
MWAWColor m_backgroundColor
the organization back page color
Definition: MoreParser.cxx:73
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:72
MWAWParser::getFormWidth
double getFormWidth() const
returns the form width
Definition: MWAWParser.hxx:175
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:61
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
MoreParserInternal::State::m_headerHeight
int m_headerHeight
the header height if known
Definition: MoreParser.cxx:78
MoreParserInternal
Internal: the structures of a MoreParser.
Definition: MoreParser.cxx:59
MWAWPageSpan::setMarginTop
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:197
libmwaw::PrinterInfo::read
bool read(MWAWInputStreamPtr input)
reads the struture in a file
Definition: MWAWPrinter.cxx:218
MWAWHeaderFooter::FOOTER
@ FOOTER
Definition: MWAWPageSpan.hxx:48
MoreParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: MoreParser.cxx:76
MoreParser::MoreText
friend class MoreText
Definition: MoreParser.hxx:81
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWHeader.hxx
MoreParser::readZonesList
bool readZonesList()
read the list of zones ( v2-3) : first 0x80 bytes
Definition: MoreParser.cxx:394
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:503
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:77
MoreParserInternal::SubDocument::operator!=
virtual bool operator!=(MWAWSubDocument const &doc) const
operator!=
Definition: MoreParser.cxx:111
MWAWHeaderFooter::ALL
@ ALL
Definition: MWAWPageSpan.hxx:50
MoreParserInternal::SubDocument::operator==
virtual bool operator==(MWAWSubDocument const &doc) const
operator!==
Definition: MoreParser.cxx:120
MoreParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MoreParser.cxx:279
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
MWAWTextListener.hxx
MoreParserInternal::State
Internal: the state of a MoreParser.
Definition: MoreParser.cxx:62
MoreParser::checkAndStore
bool checkAndStore(MWAWEntry const &entry)
check if the entry is valid, if so store it in the list of entry
Definition: MoreParser.cxx:188
MoreParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: MoreParser.cxx:169
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MoreParser::MoreParser
MoreParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: MoreParser.cxx:146
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr ip)
resets the input
Definition: MWAWDebug.hxx:73
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:192
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:88
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:513
MWAWPageSpan::setHeaderFooter
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition: MWAWPageSpan.cxx:223
MoreParserInternal::SubDocument::~SubDocument
virtual ~SubDocument()
destructor
Definition: MoreParser.cxx:108
MoreParser::readGraphic
bool readGraphic(MWAWEntry const &entry)
read a graphic ( in a slide )
Definition: MoreParser.cxx:927
libmwaw::DebugFile
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
MWAWInputStream.hxx
MWAWColor::isWhite
bool isWhite() const
return true if the color is white
Definition: libmwaw_internal.hxx:270
MWAWHeader::reset
void reset(MWAWDocument::Type type, int vers, Kind kind=MWAWDocument::MWAW_K_TEXT)
resets the data
Definition: MWAWHeader.hxx:82
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:207
MWAWSubDocumentPtr
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:517
MWAWBox2< float >
MoreParserInternal::State::m_colorList
std::vector< MWAWColor > m_colorList
a list colorId -> color
Definition: MoreParser.cxx:75
MoreParser::getPageLeftTop
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: MoreParser.cxx:182
MoreParser::readUnkn9Sub
bool readUnkn9Sub(long endPos)
read the last subzone find in a block 9 ( unknown meaning)
Definition: MoreParser.cxx:1189
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:781
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
MWAWListenerPtr
shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:505
MWAWParser.hxx
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:96
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:151

Generated on Wed Jun 17 2020 06:30:11 for libmwaw by doxygen 1.8.18