EDocParser.hxx Source File documentation

EDocParser.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 E_DOC_PARSER
35 # define E_DOC_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 EDocParserInternal
48 {
49 struct State;
50 }
51
54 class EDocParser final : public MWAWTextParser
55 {
56 friend class EDText;
57 public:
59 EDocParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
61 ~EDocParser() final;
62
64 bool checkHeader(MWAWHeader *header, bool strict=false) final;
65
66 // the main parse function
67 void parse(librevenge::RVNGTextInterface *documentInterface) final;
68
69 protected:
71 void init();
72
74 void createDocument(librevenge::RVNGTextInterface *documentInterface);
75
77 void newPage(int number);
78
79 protected:
81 bool createZones();
82
84 bool sendContents();
86 bool sendIndex();
87
88 // Intermediate level
89
91 bool sendPicture(int pictId, bool compressed);
92
94 bool readFontsName(MWAWEntry const &entry);
95
97 bool readIndex(MWAWEntry const &entry);
98
100 bool readInfo(MWAWEntry const &entry);
101
103 bool findContents();
104
106 bool decodeZone(MWAWEntry const &entry, librevenge::RVNGBinaryData &dt);
107
109 void flushExtra();
110
112 MWAWInputStreamPtr rsrcInput();
113
115 libmwaw::DebugFile &rsrcAscii();
116
117 //
118 // data
119 //
121 std::shared_ptr<EDocParserInternal::State> m_state;
122 };
123 #endif
124 // 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
EDocParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: EDocParser.cxx:206
MWAWInputStream::get
static std::shared_ptr< MWAWInputStream > get(librevenge::RVNGBinaryData const &data, bool inverted)
returns a new input stream corresponding to a librevenge::RVNGBinaryData
Definition: MWAWInputStream.cxx:102
EDocParserInternal::DeflateStruct::push
bool push(unsigned char c)
push a new character
Definition: EDocParser.cxx:699
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
MWAWTabStop::m_leaderCharacter
uint16_t m_leaderCharacter
the leader char
Definition: MWAWParagraph.hxx:78
EDocParser::~EDocParser
~EDocParser() final
destructor
Definition: EDocParser.cxx:135
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
EDocParser
the main class to read a eDOC file
Definition: EDocParser.hxx:55
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
EDocParser::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: EDocParser.cxx:154
EDocParserInternal::DeflateStruct::DeflateStruct
DeflateStruct(long size, long initSize)
constructor
Definition: EDocParser.cxx:683
EDocParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: EDocParser.cxx:149
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:237
MWAWParagraph::m_tabs
MWAWVariable< std::vector< MWAWTabStop > > m_tabs
the tabulations
Definition: MWAWParagraph.hxx:162
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:121
EDocParserInternal::State::m_idCPICMap
std::map< int, MWAWEntry > m_idCPICMap
a map id -> cPIC zone
Definition: EDocParser.cxx:112
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:190
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
EDocParserInternal::DeflateStruct
very low structure to help uncompress data
Definition: EDocParser.cxx:681
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:164
MWAWFontConverter.hxx
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
EDocParser::EDocParser
EDocParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: EDocParser.cxx:128
MWAWPrinter.hxx
EDocParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: EDocParser.cxx:178
EDocParserInternal::Index
Internal: an index of a EDocParser.
Definition: EDocParser.cxx:63
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:85
MWAWPictData::get
static MWAWPictData * get(MWAWInputStreamPtr const &input, int size)
checks if the data pointed by input is known
Definition: MWAWPictData.hxx:108
EDocParserInternal::DeflateStruct::sendDuplicated
bool sendDuplicated(int num, int depl)
send a duplicated part of the data
Definition: EDocParser.cxx:748
MWAWDocument::MWAW_T_EDOC
@ MWAW_T_EDOC
eDOC (v2)
Definition: MWAWDocument.hxx:108
EDocParserInternal::State::State
State()
constructor
Definition: EDocParser.cxx:95
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:126
MWAWParser::getTextListener
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition: MWAWParser.hxx:145
EDocParserInternal::State
Internal: the state of a EDocParser.
Definition: EDocParser.cxx:93
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
MWAWParagraph::m_margins
MWAWVariable< double > m_margins[3]
the margins
Definition: MWAWParagraph.hxx:148
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
MWAWTabStop
class to store a tab use by MWAWParagraph
Definition: MWAWParagraph.hxx:46
EDocParserInternal::Index::m_text
std::string m_text
the text
Definition: EDocParser.cxx:84
MWAWSubDocument.hxx
EDocParserInternal::State::m_indexList
std::vector< Index > m_indexList
the index list
Definition: EDocParser.cxx:116
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:178
MWAWParser::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWParser.hxx:185
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
EDocParserInternal::DeflateStruct::m_data
std::vector< unsigned char > m_data
the resulting data
Definition: EDocParser.cxx:733
EDocParserInternal::State::m_maxPictId
int m_maxPictId
the maximum of picture to read
Definition: EDocParser.cxx:110
MWAWParser::setTextListener
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:158
MWAWParagraph.hxx
libmwaw::DebugFile::skipZone
void skipZone(long beginPos, long endPos)
skips the file zone defined by beginPos-endPos
Definition: MWAWDebug.hxx:113
MWAWRSRCParser.hxx
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:193
libmwaw_internal.hxx
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:183
MWAWPosition.hxx
EDocParser::findContents
bool findContents()
try to find the content zone
Definition: EDocParser.cxx:293
EDocParser::readInfo
bool readInfo(MWAWEntry const &entry)
parse the Info zone
Definition: EDocParser.cxx:597
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
EDocParserInternal::Index::m_extra
std::string m_extra
extra data
Definition: EDocParser.cxx:88
EDocParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: EDocParser.cxx:117
EDocParserInternal::State::m_compressed
bool m_compressed
a flag to know if the data are compressed or not
Definition: EDocParser.cxx:108
EDocParserInternal::DeflateStruct::DeflateStruct
DeflateStruct(DeflateStruct const &orig)=delete
EDocParserInternal::DeflateStruct::m_toWrite
long m_toWrite
the number of data that we need to write
Definition: EDocParser.cxx:731
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:93
MWAWPictData.hxx
EDocParserInternal::State::m_idPICTMap
std::map< int, MWAWEntry > m_idPICTMap
a map id -> PICT zone
Definition: EDocParser.cxx:114
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
EDocParser::decodeZone
bool decodeZone(MWAWEntry const &entry, librevenge::RVNGBinaryData &dt)
try to decode a compress zone
Definition: EDocParser.cxx:799
MWAWPict::MWAW_R_BAD
@ MWAW_R_BAD
Definition: MWAWPict.hxx:73
EDocParser::flushExtra
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: EDocParser.cxx:390
MWAWTabStop::m_alignment
Alignment m_alignment
the alignment ( left, center, ...)
Definition: MWAWParagraph.hxx:76
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
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:83
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
EDocParserInternal
Internal: the structures of a EDocParser.
Definition: EDocParser.cxx:60
EDocParserInternal::DeflateStruct::m_circQueue
std::vector< unsigned char > m_circQueue
a circular queue
Definition: EDocParser.cxx:736
MWAWTabStop::m_position
double m_position
the tab position
Definition: MWAWParagraph.hxx:74
EDocParserInternal::DeflateStruct::m_circQueuePos
size_t m_circQueuePos
the position in the circular queue
Definition: EDocParser.cxx:738
MWAWPosition::Char
@ Char
Definition: MWAWPosition.hxx:51
EDocParser::createZones
bool createZones()
finds the different objects zones
Definition: EDocParser.cxx:239
EDocParser::EDText
friend class EDText
Definition: EDocParser.hxx:56
EDocParserInternal::State::m_headerHeight
int m_headerHeight
the header height if known
Definition: EDocParser.cxx:119
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
MWAWPictData::check
static ReadResult check(MWAWInputStreamPtr const &input, int size, MWAWBox2f &box)
checks if the data pointed by input is known
Definition: MWAWPictData.hxx:100
EDocParser::m_state
std::shared_ptr< EDocParserInternal::State > m_state
the state
Definition: EDocParser.hxx:121
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
EDocParserInternal::DeflateStruct::getBinaryData
bool getBinaryData(librevenge::RVNGBinaryData &dt) const
return the content of the block in dt
Definition: EDocParser.cxx:721
EDocParser::init
void init()
inits all internal variables
Definition: EDocParser.cxx:139
EDocParserInternal::DeflateStruct::operator=
DeflateStruct & operator=(DeflateStruct const &orig)=delete
MWAWParagraph::m_marginsUnit
MWAWVariable< librevenge::RVNGUnit > m_marginsUnit
the margins INCH, ...
Definition: MWAWParagraph.hxx:150
EDocParserInternal::Index::m_levelId
int m_levelId
the font id
Definition: EDocParser.cxx:82
EDocParserInternal::DeflateStruct::m_numDelayed
int m_numDelayed
the number of character delayed
Definition: EDocParser.cxx:740
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
EDocParser::sendPicture
bool sendPicture(int pictId, bool compressed)
try to send a picture
Definition: EDocParser.cxx:344
EDocParser::sendIndex
bool sendIndex()
try to send the index
Definition: EDocParser.cxx:468
MWAWTextListener.hxx
Defines MWAWTextListener: the libmwaw word processor listener.
EDocParser::newPage
void newPage(int number)
adds a new page
Definition: EDocParser.cxx:162
EDocParser.hxx
EDocParser::sendContents
bool sendContents()
try to send the contents
Definition: EDocParser.cxx:329
EDocParserInternal::DeflateStruct::treatDelayed
bool treatDelayed(unsigned char c)
check if there is delayed char, if so treat them
Definition: EDocParser.cxx:761
EDocParserInternal::DeflateStruct::m_delayedChar
unsigned char m_delayedChar
the delayed character
Definition: EDocParser.cxx:742
EDocParserInternal::Index::operator<<
friend std::ostream & operator<<(std::ostream &o, Index const &index)
operator<<
Definition: EDocParser.cxx:73
EDocParserInternal::State::m_footerHeight
int m_footerHeight
the footer height if known
Definition: EDocParser.cxx:120
EDocParserInternal::DeflateStruct::isEnd
bool isEnd() const
true if we have build of the data
Definition: EDocParser.cxx:694
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:99
MWAWBox2::size
MWAWVec2< T > size() const
the box size
Definition: libmwaw_internal.hxx:1067
EDocParserInternal::Index::m_page
int m_page
the page number
Definition: EDocParser.cxx:86
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
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:51
MWAWInputStream.hxx
MWAWHeader::reset
void reset(MWAWDocument::Type type, int vers, Kind kind=MWAWDocument::MWAW_K_TEXT)
resets the data
Definition: MWAWHeader.hxx:84
MWAWFont.hxx
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
MWAWTabStop::RIGHT
@ RIGHT
Definition: MWAWParagraph.hxx:48
MWAWBox2< float >
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
EDocParser::readIndex
bool readIndex(MWAWEntry const &entry)
parse the index zone
Definition: EDocParser.cxx:512
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
MWAWParser.hxx
EDocParserInternal::Index::Index
Index()
constructor
Definition: EDocParser.cxx:65
EDocParser::readFontsName
bool readFontsName(MWAWEntry const &entry)
parse the fonts name eDcF
Definition: EDocParser.cxx:414
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:99
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:163
EDocParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: EDocParser.cxx:117
EDocParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: EDocParser.cxx:970
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:325