MsWrdParser.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
/*
* parser for Microsoft Word ( version 3.0-5.1 )
*/
#ifndef MS_WRD_MWAW_PARSER
# define MS_WRD_MWAW_PARSER
#include <list>
#include <map>
#include <string>
#include <vector>
#include "MWAWDebug.hxx"
#include "MWAWEntry.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWPosition.hxx"
#include "MWAWParser.hxx"
namespace MsWrdParserInternal
{
struct Object;
struct State;
class SubDocument;
}
class MsWrdText;
class MsWrdTextStyles;
struct MsWrdEntry final : public MWAWEntry {
MsWrdEntry()
: MWAWEntry()
, m_pictType(-1)
{
}
MsWrdEntry(MsWrdEntry const &)=default;
~MsWrdEntry() final;
int pictType() const
{
return m_pictType;
}
void setPictType(int newId)
{
m_pictType = newId;
}
friend std::ostream &operator<<(std::ostream &o, MsWrdEntry const &entry);
int m_pictType;
};
class MsWrdParser final : public MWAWTextParser
{
friend class MsWrdText;
friend class MsWrdTextStyles;
friend class MsWrdParserInternal::SubDocument;
public:
MsWrdParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
~MsWrdParser() final;
bool checkHeader(MWAWHeader *header, bool strict=false) final;
void parse(librevenge::RVNGTextInterface *documentInterface) final;
protected:
void init();
void createDocument(librevenge::RVNGTextInterface *documentInterface);
bool createZones();
bool readHeaderEndV3();
bool readZoneList();
bool readPrintInfo(MsWrdEntry &entry);
bool readPrinter(MsWrdEntry &entry);
bool readDocSum(MsWrdEntry &entry);
bool readStringsZone(MsWrdEntry &entry, std::vector<std::string> &list);
bool readObjects();
bool readObjectList(MsWrdEntry &entry);
bool readObjectFlags(MsWrdEntry &entry);
bool readObject(MsWrdParserInternal::Object &obj);
bool readDocumentInfo(MsWrdEntry &entry);
bool readZone17(MsWrdEntry &entry);
bool checkPicturePos(long pos, int type);
bool readPicture(MsWrdEntry &entry);
void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char);
bool getColor(int id, MWAWColor &col) const;
void newPage(int number);
/*
* interface with subdocument
*/
void sendFootnote(int id);
void sendFieldComment(int id);
void send(int id, libmwaw::SubDocumentType type);
void send(MWAWEntry const &entry);
void sendSimpleTextZone(MWAWListenerPtr &listener, MWAWEntry const &entry);
//
// low level
//
MsWrdEntry readEntry(std::string type, int id=-1);
protected:
//
// data
//
std::shared_ptr<MsWrdParserInternal::State> m_state;
std::multimap<std::string, MsWrdEntry> m_entryMap;
std::shared_ptr<MsWrdText> m_textParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWEntry.hxx
MWAWInputStream.hxx
MWAWParser.hxx
MWAWPosition.hxx
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MWAWEntry::MWAWEntry
MWAWEntry()
constructor
Definition MWAWEntry.hxx:50
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition MWAWHeader.hxx:57
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition MWAWPosition.hxx:48
MWAWTextParser::MWAWTextParser
MWAWTextParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:307
MsWrdParserInternal::SubDocument
Internal: the subdocument of a MsWrdParser.
Definition MsWrdParser.cxx:231
MsWrdParser::readZone17
bool readZone17(MsWrdEntry &entry)
read the zone 17( some bdbox + text position ?)
Definition MsWrdParser.cxx:1151
MsWrdParser::sendSimpleTextZone
void sendSimpleTextZone(MWAWListenerPtr &listener, MWAWEntry const &entry)
try to send a simple text zone(ie. a comment)
Definition MsWrdParser.cxx:414
MsWrdParser::readPrintInfo
bool readPrintInfo(MsWrdEntry &entry)
read the print info zone
Definition MsWrdParser.cxx:1939
MsWrdParser::send
void send(int id, libmwaw::SubDocumentType type)
try to send a footnote, a field to the textParser
Definition MsWrdParser.cxx:465
MsWrdParser::init
void init()
inits all internal variables
Definition MsWrdParser.cxx:351
MsWrdParser::sendFootnote
void sendFootnote(int id)
try to send a footnote id
Definition MsWrdParser.cxx:443
MsWrdParser::sendPicture
void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char)
send a picture
Definition MsWrdParser.cxx:1871
MsWrdParser::readObject
bool readObject(MsWrdParserInternal::Object &obj)
read an object
Definition MsWrdParser.cxx:1584
MsWrdParser::readDocSum
bool readDocSum(MsWrdEntry &entry)
read the document sumary
Definition MsWrdParser.cxx:1275
MsWrdParser::readPicture
bool readPicture(MsWrdEntry &entry)
read a picture data
Definition MsWrdParser.cxx:1795
MsWrdParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition MsWrdParser.cxx:757
MsWrdParser::readObjects
bool readObjects()
read the objects
Definition MsWrdParser.cxx:1403
MsWrdParser::readZoneList
bool readZoneList()
read the list of zones
Definition MsWrdParser.cxx:627
MsWrdParser::m_state
std::shared_ptr< MsWrdParserInternal::State > m_state
the state
Definition MsWrdParser.hxx:203
MsWrdParser::readObjectFlags
bool readObjectFlags(MsWrdEntry &entry)
read the object flags
Definition MsWrdParser.cxx:1527
MsWrdParser::readHeaderEndV3
bool readHeaderEndV3()
finish reading the header (v3)
Definition MsWrdParser.cxx:898
MsWrdParser::getColor
bool getColor(int id, MWAWColor &col) const
returns the color corresponding to an id
Definition MsWrdParser.cxx:380
MsWrdParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition MsWrdParser.cxx:514
MsWrdParser::MsWrdText
friend class MsWrdText
Definition MsWrdParser.hxx:99
MsWrdParser::readDocumentInfo
bool readDocumentInfo(MsWrdEntry &entry)
read the page dimensions + ?
Definition MsWrdParser.cxx:1080
MsWrdParser::newPage
void newPage(int number)
adds a new page
Definition MsWrdParser.cxx:367
MsWrdParser::~MsWrdParser
~MsWrdParser() final
destructor
Definition MsWrdParser.cxx:347
MsWrdParser::m_textParser
std::shared_ptr< MsWrdText > m_textParser
the text parser
Definition MsWrdParser.hxx:209
MsWrdParser::MsWrdTextStyles
friend class MsWrdTextStyles
Definition MsWrdParser.hxx:100
MsWrdParser::readPrinter
bool readPrinter(MsWrdEntry &entry)
read the printer name
Definition MsWrdParser.cxx:1228
MsWrdParser::MsWrdParser
MsWrdParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition MsWrdParser.cxx:338
MsWrdParser::readEntry
MsWrdEntry readEntry(std::string type, int id=-1)
read a file entry
Definition MsWrdParser.cxx:1039
MsWrdParser::m_entryMap
std::multimap< std::string, MsWrdEntry > m_entryMap
the list of entries
Definition MsWrdParser.hxx:206
MsWrdParser::readObjectList
bool readObjectList(MsWrdEntry &entry)
read the object list
Definition MsWrdParser.cxx:1454
MsWrdParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
the main parse function
Definition MsWrdParser.cxx:479
MsWrdParser::checkPicturePos
bool checkPicturePos(long pos, int type)
check if a position corresponds or not to a picture entry
Definition MsWrdParser.cxx:1760
MsWrdParser::createZones
bool createZones()
finds the different zones
Definition MsWrdParser.cxx:566
MsWrdParser::sendFieldComment
void sendFieldComment(int id)
try to send a bookmark field id
Definition MsWrdParser.cxx:452
MsWrdParser::readStringsZone
bool readStringsZone(MsWrdEntry &entry, std::vector< std::string > &list)
read a zone which consists in a list of string
Definition MsWrdParser.cxx:1346
MsWrdTextStyles
the main class to read/store the text font, paragraph, section stylesread
Definition MsWrdTextStyles.hxx:68
MsWrdText
the main class to read the text part of Microsoft Word file
Definition MsWrdText.hxx:65
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition libmwaw_internal.hxx:561
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition libmwaw_internal.hxx:553
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
MsWrdParserInternal
Internal: the structures of a MsWrdParser.
Definition MsWrdParser.cxx:59
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition libmwaw_internal.cxx:51
librevenge
Definition MWAWDocument.hxx:57
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192
MsWrdEntry
the entry of MsWrdParser
Definition MsWrdParser.hxx:63
MsWrdEntry::m_pictType
int m_pictType
the picture identificator
Definition MsWrdParser.hxx:89
MsWrdEntry::~MsWrdEntry
~MsWrdEntry() final
destructor
Definition MsWrdParser.cxx:321
MsWrdEntry::pictType
int pictType() const
returns the text id
Definition MsWrdParser.hxx:77
MsWrdEntry::MsWrdEntry
MsWrdEntry()
constructor
Definition MsWrdParser.hxx:65
MsWrdEntry::MsWrdEntry
MsWrdEntry(MsWrdEntry const &)=default
MsWrdEntry::operator<<
friend std::ostream & operator<<(std::ostream &o, MsWrdEntry const &entry)
operator<<
Definition MsWrdParser.cxx:325
MsWrdEntry::setPictType
void setPictType(int newId)
sets the picture id
Definition MsWrdParser.hxx:82
MsWrdParserInternal::Object
Internal: the object of MsWrdParser.
Definition MsWrdParser.cxx:62
MsWrdParserInternal::State
Internal: the state of a MsWrdParser.
Definition MsWrdParser.cxx:188