MSWParser.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 MSW_MWAW_PARSER
# define MSW_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 MSWParserInternal
{
struct Object;
struct State;
class SubDocument;
}
class MSWText;
class MSWTextStyles;
struct MSWEntry : public MWAWEntry {
MSWEntry() : MWAWEntry(), m_pictType(-1) {
}
int pictType() const {
return m_pictType;
}
void setPictType(int newId) {
m_pictType = newId;
}
friend std::ostream &operator<<(std::ostream &o, MSWEntry const &entry);
int m_pictType;
};
class MSWParser : public MWAWParser
{
friend class MSWText;
friend class MSWTextStyles;
friend class MSWParserInternal::SubDocument;
public:
MSWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
virtual ~MSWParser();
bool checkHeader(MWAWHeader *header, bool strict=false);
void parse(WPXDocumentInterface *documentInterface);
protected:
void init();
void createDocument(WPXDocumentInterface *documentInterface);
bool createZones();
bool readHeaderEndV3();
bool readZoneList();
bool readPrintInfo(MSWEntry &entry);
bool readPrinter(MSWEntry &entry);
bool readDocSum(MSWEntry &entry);
bool readStringsZone(MSWEntry &entry, std::vector<std::string> &list);
bool readObjects();
bool readObjectList(MSWEntry &entry);
bool readObjectFlags(MSWEntry &entry);
bool readObject(MSWParserInternal::Object &obj);
bool readDocumentInfo(MSWEntry &entry);
bool readZone17(MSWEntry &entry);
bool checkPicturePos(long pos, int type);
bool readPicture(MSWEntry &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);
//
// low level
//
MSWEntry readEntry(std::string type, int id=-1);
protected:
//
// data
//
shared_ptr<MSWParserInternal::State> m_state;
std::multimap<std::string, MSWEntry> m_entryMap;
shared_ptr<MSWText> m_textParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MSWParser::send
void send(int id, libmwaw::SubDocumentType type)
try to send a footnote, a field to the textParser
Definition: MSWParser.cxx:379
MSWParser::MSWParser
MSWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: MSWParser.cxx:284
MWAWHeader
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
MSWParser::readZone17
bool readZone17(MSWEntry &entry)
read the zone 17( some bdbox + text position ?)
Definition: MSWParser.cxx:1069
MSWParser::m_textParser
shared_ptr< MSWText > m_textParser
the text parser
Definition: MSWParser.hxx:198
MSWTextStyles
the main class to read/store the text font, paragraph, section stylesread
Definition: MSWTextStyles.hxx:66
MWAWParser.hxx
MWAWPosition::Char
Definition: MWAWPosition.hxx:51
MWAWEntry.hxx
MSWParser::readDocSum
bool readDocSum(MSWEntry &entry)
read the document sumary
Definition: MSWParser.cxx:1193
MSWParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: MSWParser.cxx:679
MSWParser::readObjects
bool readObjects()
read the objects
Definition: MSWParser.cxx:1305
MSWEntry::pictType
int pictType() const
returns the text id
Definition: MSWParser.hxx:70
MSWParser
the main class to read a Microsoft Word file
Definition: MSWParser.hxx:88
MSWEntry
the entry of MSWParser
Definition: MSWParser.hxx:63
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:157
MSWParser::readObjectFlags
bool readObjectFlags(MSWEntry &entry)
read the object flags
Definition: MSWParser.cxx:1428
MSWParser::readPrinter
bool readPrinter(MSWEntry &entry)
read the printer name
Definition: MSWParser.cxx:1146
MSWText
the main class to read the text part of Microsoft Word file
Definition: MSWText.hxx:64
MSWParser::readStringsZone
bool readStringsZone(MSWEntry &entry, std::vector< std::string > &list)
read a zone which consists in a list of string
Definition: MSWParser.cxx:1248
MSWEntry::MSWEntry
MSWEntry()
Definition: MSWParser.hxx:64
MSWEntry::operator<<
friend std::ostream & operator<<(std::ostream &o, MSWEntry const &entry)
operator<<
Definition: MSWParser.cxx:271
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:161
MSWParser::readObjectList
bool readObjectList(MSWEntry &entry)
read the object list
Definition: MSWParser.cxx:1355
MSWParserInternal::Object
Internal: the object of MSWParser.
Definition: MSWParser.cxx:61
MSWParser::sendFieldComment
void sendFieldComment(int id)
try to send a bookmark field id
Definition: MSWParser.cxx:366
MSWParser::readHeaderEndV3
bool readHeaderEndV3()
finish reading the header (v3)
Definition: MSWParser.cxx:819
MSWParser::createDocument
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MSWParser.cxx:437
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:340
MWAWPosition::AnchorTo
AnchorTo
a list of enum used to defined the anchor
Definition: MWAWPosition.hxx:51
MSWParser::createZones
bool createZones()
finds the different zones
Definition: MSWParser.cxx:487
MSWParser::newPage
void newPage(int number)
adds a new page
Definition: MSWParser.cxx:310
MSWParser::readEntry
MSWEntry readEntry(std::string type, int id=-1)
read a file entry
Definition: MSWParser.cxx:958
MSWParser::getColor
bool getColor(int id, MWAWColor &col) const
returns the color corresponding to an id
Definition: MSWParser.cxx:323
MSWParser::m_state
shared_ptr< MSWParserInternal::State > m_state
the state
Definition: MSWParser.hxx:192
MSWParser::readPrintInfo
bool readPrintInfo(MSWEntry &entry)
read the print info zone
Definition: MSWParser.cxx:1832
MSWParser::sendPicture
void sendPicture(long fPos, int cPos, MWAWPosition::AnchorTo anchor=MWAWPosition::Char)
send a picture
Definition: MSWParser.cxx:1771
MSWParser::readPicture
bool readPicture(MSWEntry &entry)
read a picture data
Definition: MSWParser.cxx:1692
MSWParser::readObject
bool readObject(MSWParserInternal::Object &obj)
read an object
Definition: MSWParser.cxx:1485
MSWParser::init
void init()
inits all internal variables
Definition: MSWParser.cxx:294
MSWParser::~MSWParser
virtual ~MSWParser()
destructor
Definition: MSWParser.cxx:290
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
MSWParser::checkPicturePos
bool checkPicturePos(long pos, int type)
check if a position corresponds or not to a picture entry
Definition: MSWParser.cxx:1657
MWAWInputStream.hxx
MWAWDebug.hxx
MSWParser::m_entryMap
std::multimap< std::string, MSWEntry > m_entryMap
the list of entries
Definition: MSWParser.hxx:195
MSWParser::parse
void parse(WPXDocumentInterface *documentInterface)
the main parse function
Definition: MSWParser.cxx:401
MSWParser::sendFootnote
void sendFootnote(int id)
try to send a footnote id
Definition: MSWParser.cxx:357
MSWParser::readDocumentInfo
bool readDocumentInfo(MSWEntry &entry)
read the page dimensions + ?
Definition: MSWParser.cxx:999
MWAWPosition.hxx
MSWParser::readZoneList
bool readZoneList()
read the list of zones
Definition: MSWParser.cxx:549
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:87
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MSWEntry::setPictType
void setPictType(int newId)
sets the picture id
Definition: MSWParser.hxx:74
MSWEntry::m_pictType
int m_pictType
the picture identificator
Definition: MSWParser.hxx:80
MSWParserInternal::SubDocument
Internal: the subdocument of a MSWParser.
Definition: MSWParser.cxx:200