DocMkrParser.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 DOC_MKR_PARSER
35 # define DOC_MKR_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 DocMkrParserInternal
48 {
49 struct State;
50 }
51 
52 class DocMkrText;
53 
56 class DocMkrParser final : public MWAWTextParser
57 {
58  friend class DocMkrText;
59 public:
61  DocMkrParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
63  ~DocMkrParser() 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 
80 
82  void newPage(int number);
83 
84 protected:
86  bool createZones();
88  bool readPictInfo(MWAWEntry const &entry);
90  bool readSTwD(MWAWEntry const &entry);
92  bool readXtr2(MWAWEntry const &entry);
93 
94  // Intermediate level
95 
97  bool sendPicture(int zId, int lId, double lineW);
99  void flushExtra();
100 
103 
105  libmwaw::DebugFile &rsrcAscii();
106 
107  //
108  // data
109  //
111  std::shared_ptr<DocMkrParserInternal::State> m_state;
112 
114  std::shared_ptr<DocMkrText> m_textParser;
115 };
116 #endif
117 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
DocMkrParser::readPictInfo
bool readPictInfo(MWAWEntry const &entry)
try to read a pict info zone ? ( resource pInf )
Definition: DocMkrParser.cxx:489
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
DocMkrParserInternal::PictInfo::m_sndId
int m_sndId
the sound id
Definition: DocMkrParser.cxx:79
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
MWAWRSRCParser::Version::m_majorVersion
int m_majorVersion
the major number
Definition: MWAWRSRCParser.hxx:146
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
MWAWRSRCParser::Version
a public structure used to return the version
Definition: MWAWRSRCParser.hxx:133
DocMkrParser::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: DocMkrParser.cxx:240
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
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
DocMkrParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: DocMkrParser.cxx:264
DocMkrParserInternal::State::m_idPictInfoMap
std::map< int, PictInfo > m_idPictInfoMap
a map id->pictInfo
Definition: DocMkrParser.cxx:180
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:237
DocMkrParserInternal::PictInfo::m_action
int m_action
the action
Definition: DocMkrParser.cxx:87
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:121
DocMkrParserInternal::PictInfo::m_align
int m_align
the alignment ( 1:center, ... )
Definition: DocMkrParser.cxx:81
DocMkrParserInternal::PictInfo::m_print
bool m_print
true if the picture is printed
Definition: DocMkrParser.cxx:83
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
DocMkrParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: DocMkrParser.cxx:235
DocMkrParserInternal::State::findPictInfoUnit
void findPictInfoUnit(int nZones)
try to find the picture info unit (fixme: a hack)
Definition: DocMkrParser.cxx:189
DocMkrParserInternal::PictInfo
Internal: store a picture information in DocMkrParser.
Definition: DocMkrParser.cxx:60
DocMkrParserInternal::PictInfo::m_actionString
std::string m_actionString
the action string
Definition: DocMkrParser.cxx:89
DocMkrParserInternal::State
Internal: the state of a DocMkrParser.
Definition: DocMkrParser.cxx:158
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
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:137
MWAWPrinter.hxx
DocMkrParserInternal::PictInfo::m_invert
bool m_invert
true if we must invert the picture
Definition: DocMkrParser.cxx:85
MWAWPictData::get
static MWAWPictData * get(MWAWInputStreamPtr const &input, int size)
checks if the data pointed by input is known
Definition: MWAWPictData.hxx:108
DocMkrParserInternal::State::m_headerHeight
int m_headerHeight
the header height if known
Definition: DocMkrParser.cxx:185
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
MWAWDocument::MWAW_T_DOCMAKER
@ MWAW_T_DOCMAKER
DocMaker (v4)
Definition: MWAWDocument.hxx:107
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
DocMkrParser::~DocMkrParser
~DocMkrParser() final
destructor
Definition: DocMkrParser.cxx:222
MWAWPosition::XCenter
@ XCenter
Definition: MWAWPosition.hxx:55
DocMkrParserInternal::operator<<
std::ostream & operator<<(std::ostream &o, PictInfo const &info)
Definition: DocMkrParser.cxx:98
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
DocMkrParser
the main class to read a DocMake file
Definition: DocMkrParser.hxx:57
MWAWSubDocument.hxx
DocMkrParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: DocMkrParser.cxx:183
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
DocMkrParserInternal::PictInfo::m_extra
std::string m_extra
extra data
Definition: DocMkrParser.cxx:95
MWAWParser::setTextListener
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:158
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
DocMkrParser::m_textParser
std::shared_ptr< DocMkrText > m_textParser
the text parser
Definition: DocMkrParser.hxx:114
MWAWPosition.hxx
DocMkrParserInternal::PictInfo::operator<<
friend std::ostream & operator<<(std::ostream &o, PictInfo const &info)
operator<<
Definition: DocMkrParser.cxx:98
DocMkrParser::init
void init()
inits all internal variables
Definition: DocMkrParser.cxx:226
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
MWAWParser::setVersion
void setVersion(int vers)
sets the document's version
Definition: MWAWParser.hxx:206
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
MWAWPosition::m_wrapping
Wrapping m_wrapping
Wrapping.
Definition: MWAWPosition.hxx:278
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:93
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: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
DocMkrParserInternal::PictInfo::PictInfo
PictInfo()
constructor
Definition: DocMkrParser.cxx:62
DocMkrParserInternal::State::m_footerHeight
int m_footerHeight
the footer height if known
Definition: DocMkrParser.cxx:186
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
DocMkrParser::createZones
bool createZones()
finds the different objects zones
Definition: DocMkrParser.cxx:322
DocMkrParser::flushExtra
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: DocMkrParser.cxx:414
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
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
DocMkrParser::m_state
std::shared_ptr< DocMkrParserInternal::State > m_state
the state
Definition: DocMkrParser.hxx:111
DocMkrParserInternal::State::State
State()
constructor
Definition: DocMkrParser.cxx:160
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
DocMkrParser.hxx
DocMkrParserInternal::State::pictInfoId
int pictInfoId(int zId, int lId) const
return a pictinfo id corresponding to a zone and a local if
Definition: DocMkrParser.cxx:171
MWAWTextListener.hxx
Defines MWAWTextListener: the libmwaw word processor listener.
DocMkrParserInternal::PictInfo::m_next
int m_next[2]
the next chapter/paragraph position for goChapter
Definition: DocMkrParser.cxx:91
DocMkrParser::sendPicture
bool sendPicture(int zId, int lId, double lineW)
try to send a picture knowing zId and local id
Definition: DocMkrParser.cxx:430
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
DocMkrParser::readXtr2
bool readXtr2(MWAWEntry const &entry)
try to read an unknown zone ( resource xtr2 )
Definition: DocMkrParser.cxx:653
DocMkrParser::readSTwD
bool readSTwD(MWAWEntry const &entry)
try to read an unknown zone ( resource sTwD )
Definition: DocMkrParser.cxx:616
MWAWPosition::XRight
@ XRight
Definition: MWAWPosition.hxx:55
MWAWBox2::size
MWAWVec2< T > size() const
the box size
Definition: libmwaw_internal.hxx:1067
DocMkrParser::getPageLeftTop
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
DocMkrParserInternal
Internal: the structures of a DocMkrParser.
Definition: DocMkrParser.cxx:57
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
DocMkrParserInternal::State::m_zonePictInfoUnit
int m_zonePictInfoUnit
the zone unit to retrieve pictInfo
Definition: DocMkrParser.cxx:182
DocMkrText.hxx
MWAWPosition::WRunThrough
@ WRunThrough
Definition: MWAWPosition.hxx:53
DocMkrParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: DocMkrParser.cxx:183
DocMkrText
the main class to read the text part of DocMaker file
Definition: DocMkrText.hxx:60
MWAWPosition::XLeft
@ XLeft
Definition: MWAWPosition.hxx:55
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:51
MWAWPosition::Paragraph
@ Paragraph
Definition: MWAWPosition.hxx:51
MWAWInputStream.hxx
DocMkrParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: DocMkrParser.cxx:689
MWAWHeader::reset
void reset(MWAWDocument::Type type, int vers, Kind kind=MWAWDocument::MWAW_K_TEXT)
resets the data
Definition: MWAWHeader.hxx:84
librevenge
Definition: MWAWDocument.hxx:57
MWAWBox2< float >
DocMkrParserInternal::State::m_idPictEntryMap
std::map< int, MWAWEntry > m_idPictEntryMap
a map id->pictEntry
Definition: DocMkrParser.cxx:178
DocMkrParserInternal::PictInfo::m_appleScript
std::string m_appleScript[3]
the applescript type
Definition: DocMkrParser.cxx:93
DocMkrParser::DocMkrParser
DocMkrParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: DocMkrParser.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
DocMkrParser::DocMkrText
friend class DocMkrText
Definition: DocMkrParser.hxx:58
DocMkrParserInternal::PictInfo::m_id
int m_id
the picture id
Definition: DocMkrParser.cxx:77
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:163
DocMkrParser::newPage
void newPage(int number)
adds a new page
Definition: DocMkrParser.cxx:248
DocMkrParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: DocMkrParser.cxx:294

Generated on Fri Sep 18 2020 18:14:52 for libmwaw by doxygen 1.8.20