CWParser.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 to Claris Works text document
*
*/
#ifndef CW_MWAW_PARSER
# define CW_MWAW_PARSER
#include <set>
#include <string>
#include <vector>
#include <libwpd/libwpd.h>
#include "MWAWEntry.hxx"
#include "MWAWPosition.hxx"
#include "MWAWParser.hxx"
#include "CWStruct.hxx"
namespace CWParserInternal
{
struct State;
class SubDocument;
}
class CWDatabase;
class CWGraph;
class CWPresentation;
class CWSpreadsheet;
class CWStyleManager;
class CWTable;
class CWText;
class CWParser : public MWAWParser
{
friend class CWParserInternal::SubDocument;
friend class CWDatabase;
friend class CWGraph;
friend class CWPresentation;
friend class CWSpreadsheet;
friend class CWStyleManager;
friend class CWTable;
friend class CWText;
public:
CWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
virtual ~CWParser();
bool checkHeader(MWAWHeader *header, bool strict=false);
// the main parse function
void parse(WPXDocumentInterface *documentInterface);
protected:
void init();
void createDocument(WPXDocumentInterface *documentInterface);
bool createZones();
CWStruct::DSET::Type getZoneType(int zId) const;
bool exploreZonesGraph();
bool exploreZonesGraphRec(int zId, std::set<int> &notDoneList);
void typeMainZones();
int typeMainZonesRec(int zId, CWStruct::DSET::Type type, int maxHeight);
bool readZone();
bool readPrintInfo();
bool readStructZone(char const *zoneName, bool hasEntete);
bool readStructIntZone(char const *zoneName, bool hasEntete, int fSz, std::vector<int> &res);
double getTextHeight() const;
Vec2f getPageLeftTop() const;
void newPage(int number);
//
// interface with the text parser
//
bool sendZone(int zoneId, MWAWPosition pos=MWAWPosition());
void sendZoneInFrame(int zoneId, MWAWPosition pos,
WPXPropertyList extras = WPXPropertyList(),
WPXPropertyList frameExtras = WPXPropertyList());
void forceParsed(int zoneId);
void sendFootnote(int zoneId);
MWAWSection getMainSection() const;
//
// interface with the graph parser
//
bool getColor(int colId, MWAWColor &col) const;
float getPatternPercent(int id) const;
void getHeaderFooterId(int &headerId, int &footerId) const;
//
// low level
//
bool readDocHeader();
bool readEndTable();
shared_ptr<CWStruct::DSET> readDSET(bool &complete);
// THE NAMED ENTRY
/* read the document summary */
bool readDSUM(MWAWEntry const &entry, bool inHeader);
/* read the temporary file name ? */
bool readTNAM(MWAWEntry const &entry);
/* SNAP (in v6) : size[4]/size[2] picture... */
bool readSNAP(MWAWEntry const &entry);
/* sequence of plist of printer : in v6
*/
bool readCPRT(MWAWEntry const &entry);
void checkOrdering(std::vector<int16_t> &vec16, std::vector<int32_t> &vec32) const;
protected:
//
// data
//
shared_ptr<CWParserInternal::State> m_state;
bool m_pageSpanSet;
shared_ptr<CWDatabase> m_databaseParser;
shared_ptr<CWGraph> m_graphParser;
shared_ptr<CWPresentation> m_presentationParser;
shared_ptr<CWSpreadsheet> m_spreadsheetParser;
shared_ptr<CWStyleManager> m_styleManager;
shared_ptr<CWTable> m_tableParser;
shared_ptr<CWText> m_textParser;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
CWParser::readStructIntZone
bool readStructIntZone(char const *zoneName, bool hasEntete, int fSz, std::vector< int > &res)
try to read a int structured zone where fSz to the int size: 1(int8), 2(int16), 4(int32) ...
Definition: CWParser.cxx:1299
MWAWHeader
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
CWParser::getHeaderFooterId
void getHeaderFooterId(int &headerId, int &footerId) const
returns the header/footer id
Definition: CWParser.cxx:229
CWParser::readDSUM
bool readDSUM(MWAWEntry const &entry, bool inHeader)
Definition: CWParser.cxx:1427
CWStyleManager
a structure to store the style list and the lookup zone
Definition: CWStyleManager.hxx:60
MWAWParser.hxx
CWParser::getZoneType
CWStruct::DSET::Type getZoneType(int zId) const
try to return the type of a zone
Definition: CWParser.cxx:220
CWParser::readDSET
shared_ptr< CWStruct::DSET > readDSET(bool &complete)
reads the zone DSET
Definition: CWParser.cxx:1100
CWParser::readPrintInfo
bool readPrintInfo()
read the print info zone
Definition: CWParser.cxx:1957
MWAWEntry.hxx
CWParser::CWParser
CWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: CWParser.cxx:164
CWParser::sendZone
bool sendZone(int zoneId, MWAWPosition pos=MWAWPosition())
send a zone
Definition: CWParser.cxx:285
CWParserInternal::SubDocument
Internal: the subdocument of a CWParser.
Definition: CWParser.cxx:100
CWParser::createZones
bool createZones()
finds the different objects zones
Definition: CWParser.cxx:485
CWParser::getPatternPercent
float getPatternPercent(int id) const
return the pattern percent which corresponds to an id (or -1)
Definition: CWParser.cxx:215
CWSpreadsheet
the main class to read the text part of Claris Works file
Definition: CWSpreadsheet.hxx:70
CWParser::checkOrdering
void checkOrdering(std::vector< int16_t > &vec16, std::vector< int32_t > &vec32) const
small fonction used to check unusual endian ordering of a list of int16_t, int32_t ...
Definition: CWParser.cxx:235
CWParser::readCPRT
bool readCPRT(MWAWEntry const &entry)
Definition: CWParser.cxx:1520
CWText
the main class to read the text part of Claris Works file
Definition: CWText.hxx:75
CWParser::typeMainZones
void typeMainZones()
try to type the main zones
Definition: CWParser.cxx:576
CWTable
the main class to read the text part of Claris Works file
Definition: CWTable.hxx:69
CWParser::m_graphParser
shared_ptr< CWGraph > m_graphParser
the graph parser
Definition: CWParser.hxx:221
CWParser::m_databaseParser
shared_ptr< CWDatabase > m_databaseParser
the database parser
Definition: CWParser.hxx:218
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:161
CWParser::readEndTable
bool readEndTable()
reads the end table ( appears in v3.0 : file version ? )
Definition: CWParser.cxx:788
CWGraph
the main class to read the graphic part of Claris Works file
Definition: CWGraph.hxx:72
CWStruct::DSET::Type
Type
the document type
Definition: CWStruct.hxx:59
CWParser::parse
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: CWParser.cxx:391
CWDatabase
the main class to read the text part of Claris Works file
Definition: CWDatabase.hxx:70
CWParser::newPage
void newPage(int number)
adds a new page
Definition: CWParser.cxx:269
CWParser::exploreZonesGraph
bool exploreZonesGraph()
try to find the zone dags structure...
Definition: CWParser.cxx:660
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:340
CWParser::getMainSection
MWAWSection getMainSection() const
returns the columns information
Definition: CWParser.cxx:327
CWStruct.hxx
CWParser::getPageLeftTop
Vec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: CWParser.cxx:204
CWParser::readStructZone
bool readStructZone(char const *zoneName, bool hasEntete)
try to read a structured zone
Definition: CWParser.cxx:1233
CWPresentation
the main class to read the text part of Claris Works file
Definition: CWPresentation.hxx:67
CWParser::sendFootnote
void sendFootnote(int zoneId)
creates a document to send a footnote
Definition: CWParser.cxx:359
CWParser::m_presentationParser
shared_ptr< CWPresentation > m_presentationParser
the spreadsheet parser
Definition: CWParser.hxx:224
CWParser::typeMainZonesRec
int typeMainZonesRec(int zId, CWStruct::DSET::Type type, int maxHeight)
try to type the main zones recursif, returns the father id
Definition: CWParser.cxx:632
CWParser::m_tableParser
shared_ptr< CWTable > m_tableParser
the table parser
Definition: CWParser.hxx:233
CWParser::m_spreadsheetParser
shared_ptr< CWSpreadsheet > m_spreadsheetParser
the spreadsheet parser
Definition: CWParser.hxx:227
CWParser::init
void init()
inits all internal variables
Definition: CWParser.cxx:176
CWParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: CWParser.cxx:995
CWParser
the main class to read a Claris Works file
Definition: CWParser.hxx:73
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
CWParser::readTNAM
bool readTNAM(MWAWEntry const &entry)
Definition: CWParser.cxx:1476
CWParser::~CWParser
virtual ~CWParser()
destructor
Definition: CWParser.cxx:172
CWParser::m_state
shared_ptr< CWParserInternal::State > m_state
the state
Definition: CWParser.hxx:212
CWParser::exploreZonesGraphRec
bool exploreZonesGraphRec(int zId, std::set< int > &notDoneList)
try to find the zone tree graph ( DSF) function
Definition: CWParser.cxx:748
CWParser::m_styleManager
shared_ptr< CWStyleManager > m_styleManager
the style manager
Definition: CWParser.hxx:230
CWParser::sendZoneInFrame
void sendZoneInFrame(int zoneId, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList(), WPXPropertyList frameExtras=WPXPropertyList())
send a zone in a frame
Definition: CWParser.cxx:367
CWParser::readSNAP
bool readSNAP(MWAWEntry const &entry)
Definition: CWParser.cxx:1372
CWParser::createDocument
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: CWParser.cxx:426
CWParser::readZone
bool readZone()
read a zone
Definition: CWParser.cxx:885
MWAWPosition.hxx
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:87
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
Vec2< float >
CWParser::getColor
bool getColor(int colId, MWAWColor &col) const
returns the color corresponding to colId (if possible)
Definition: CWParser.cxx:210
CWParser::m_pageSpanSet
bool m_pageSpanSet
a flag to know if pageSpan is filled
Definition: CWParser.hxx:215
CWParser::getTextHeight
double getTextHeight() const
returns the page height, ie. paper size less margin (in inches) less header/footer size ...
Definition: CWParser.cxx:199
CWParser::readDocHeader
bool readDocHeader()
reads the document header
Definition: CWParser.cxx:1572
CWParser::m_textParser
shared_ptr< CWText > m_textParser
the text parser
Definition: CWParser.hxx:236
CWParser::forceParsed
void forceParsed(int zoneId)
indicate that a zone is already parsed
Definition: CWParser.cxx:380