Canvas5Parser.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.
*/
#ifndef CANVAS5_PARSER
# define CANVAS5_PARSER
#include <functional>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include <librevenge/librevenge.h>
#include "MWAWDebug.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWPosition.hxx"
#include "MWAWParser.hxx"
namespace Canvas5ParserInternal
{
struct Layer;
struct Slide;
struct State;
}
class Canvas5Graph;
class Canvas5Image;
class Canvas5StyleManager;
namespace Canvas5Structure
{
struct Stream;
}
class Canvas5Parser final : public MWAWGraphicParser
{
friend class Canvas5Graph;
friend class Canvas5Image;
friend class Canvas5StyleManager;
public:
Canvas5Parser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
~Canvas5Parser() final;
bool checkHeader(MWAWHeader *header, bool strict=false) final;
// the main parse function
void parse(librevenge::RVNGDrawingInterface *documentInterface) final;
protected:
void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
//
// interface
//
bool isWindowsFile() const;
librevenge::RVNGString getTextLink(int textLinkId) const;
protected:
bool createZones();
bool readMainBlock(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readMainBlock9(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readFileRSRCs(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readSI200(Canvas5Structure::Stream &stream);
bool readFileDesc(Canvas5Structure::Stream &stream);
// Intermediate level
//
// first block
//
bool readFileHeader(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readDocumentSettings(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readLayers(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readSlides(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readTextLinks(std::shared_ptr<Canvas5Structure::Stream> stream);
//
// second block
//
//
// third block
//
bool readPrinterRsrc(Canvas5Structure::Stream &stream);
bool readOLnkRsrc(std::shared_ptr<Canvas5Structure::Stream> stream);
bool readObjectDBRsrc(std::shared_ptr<Canvas5Structure::Stream> stream);
//
// Mac RSRC
//
bool readPnot(Canvas5Structure::Stream &stream, MWAWEntry const &entry);
bool readPicture(Canvas5Structure::Stream &stream, MWAWEntry const &entry);
//
// Windows RSRC
//
//
// send data to the listener
//
bool send(Canvas5ParserInternal::Slide const &slide);
bool send(Canvas5ParserInternal::Layer const &layer);
//
// low level
//
bool readString(Canvas5Structure::Stream &stream, librevenge::RVNGString &string, int maxSize, bool canBeCString=false);
bool readDouble(Canvas5Structure::Stream &stream, double &val, bool &isNaN) const;
double readDouble(Canvas5Structure::Stream &stream, int fieldSize) const;
int readInteger(Canvas5Structure::Stream &stream, int fieldSize) const;
struct Item {
Item()
: m_id(-1)
, m_type(unsigned(-1))
, m_length(0)
, m_pos(-1)
, m_decal(0)
{
}
int m_id;
unsigned m_type;
long m_length;
long m_pos;
int m_decal;
};
typedef std::function<void(std::shared_ptr<Canvas5Structure::Stream>, Item const &, std::string const &)> DataFunction;
static void defDataFunction(std::shared_ptr<Canvas5Structure::Stream>, Item const &, std::string const &) {}
static void stringDataFunction(std::shared_ptr<Canvas5Structure::Stream> stream, Item const &item, std::string const &what);
bool readDataHeader(Canvas5Structure::Stream &stream, int expectedSize, int &N);
bool readExtendedHeader(std::shared_ptr<Canvas5Structure::Stream> stream, int expectedValue, std::string const &what, DataFunction const &func);
bool readUsed(Canvas5Structure::Stream &stream, std::string const &what);
bool readDefined(Canvas5Structure::Stream &stream, std::vector<bool> &defined, std::string const &what);
bool readIndexMap(std::shared_ptr<Canvas5Structure::Stream> stream, std::string const &what, DataFunction const &func=&Canvas5Parser::defDataFunction);
// v9 new structures
bool readArray9(std::shared_ptr<Canvas5Structure::Stream> stream, std::string const &what,
DataFunction const &func=&Canvas5Parser::defDataFunction);
bool readItemHeader9(Canvas5Structure::Stream &stream, int &id, int &used);
bool getTAG9(Canvas5Structure::Stream &stream, std::string &tag, int &type);
bool checkTAG9(Canvas5Structure::Stream &stream, std::string const &tag, int type);
static MWAWInputStreamPtr decode(MWAWInputStreamPtr input, int version);
//
// data
//
std::shared_ptr<Canvas5ParserInternal::State> m_state;
std::shared_ptr<Canvas5Graph> m_graphParser;
std::shared_ptr<Canvas5Image> m_imageParser;
std::shared_ptr<Canvas5StyleManager> m_styleManager;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWInputStream.hxx
MWAWParser.hxx
MWAWPosition.hxx
Canvas5Graph
the main class to read the graphic part of Canvas v5-v11 file
Definition Canvas5Graph.hxx:85
Canvas5Image
the main class to read/convert the image or movie inside of Canvas 5-11 files
Definition Canvas5Image.hxx:78
Canvas5Parser::readTextLinks
bool readTextLinks(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the text links
Definition Canvas5Parser.cxx:2288
Canvas5Parser::m_graphParser
std::shared_ptr< Canvas5Graph > m_graphParser
the graph parser
Definition Canvas5Parser.hxx:252
Canvas5Parser::m_imageParser
std::shared_ptr< Canvas5Image > m_imageParser
the image parser
Definition Canvas5Parser.hxx:254
Canvas5Parser::readMainBlock
bool readMainBlock(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the first big block
Definition Canvas5Parser.cxx:458
Canvas5Parser::readFileRSRCs
bool readFileRSRCs(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the third big block: a list of resource?, font, ...
Definition Canvas5Parser.cxx:619
Canvas5Parser::readSI200
bool readSI200(Canvas5Structure::Stream &stream)
try to read the SI200 zone: v6
Definition Canvas5Parser.cxx:1518
Canvas5Parser::readString
bool readString(Canvas5Structure::Stream &stream, librevenge::RVNGString &string, int maxSize, bool canBeCString=false)
try to read a pascal string in the data fork or a Pascal/C string depending on the file type
Definition Canvas5Parser.cxx:2971
Canvas5Parser::readMainBlock9
bool readMainBlock9(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the first big block: v9
Definition Canvas5Parser.cxx:492
Canvas5Parser::Canvas5Graph
friend class Canvas5Graph
Definition Canvas5Parser.hxx:73
Canvas5Parser::readUsed
bool readUsed(Canvas5Structure::Stream &stream, std::string const &what)
try to read the used list
Definition Canvas5Parser.cxx:3301
Canvas5Parser::m_styleManager
std::shared_ptr< Canvas5StyleManager > m_styleManager
the style manager
Definition Canvas5Parser.hxx:256
Canvas5Parser::m_state
std::shared_ptr< Canvas5ParserInternal::State > m_state
the state
Definition Canvas5Parser.hxx:250
Canvas5Parser::readOLnkRsrc
bool readOLnkRsrc(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the OLnk rsrc block: v6
Definition Canvas5Parser.cxx:2176
Canvas5Parser::readArray9
bool readArray9(std::shared_ptr< Canvas5Structure::Stream > stream, std::string const &what, DataFunction const &func=&Canvas5Parser::defDataFunction)
try to read an array: v9
Definition Canvas5Parser.cxx:3358
Canvas5Parser::readObjectDBRsrc
bool readObjectDBRsrc(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the object database: XOBD v6
Definition Canvas5Parser.cxx:2234
Canvas5Parser::readInteger
int readInteger(Canvas5Structure::Stream &stream, int fieldSize) const
try to read a int: either a cast a double: fieldSize=8 or a int32/int16
Definition Canvas5Parser.cxx:2906
Canvas5Parser::stringDataFunction
static void stringDataFunction(std::shared_ptr< Canvas5Structure::Stream > stream, Item const &item, std::string const &what)
the default function to parse a string
Definition Canvas5Parser.cxx:3121
Canvas5Parser::getTextLink
librevenge::RVNGString getTextLink(int textLinkId) const
returns the link corresponding to a text id
Definition Canvas5Parser.cxx:208
Canvas5Parser::readDefined
bool readDefined(Canvas5Structure::Stream &stream, std::vector< bool > &defined, std::string const &what)
try to read the defined list
Definition Canvas5Parser.cxx:3247
Canvas5Parser::createDocument
void createDocument(librevenge::RVNGDrawingInterface *documentInterface)
creates the listener which will be associated to the document
Definition Canvas5Parser.cxx:253
Canvas5Parser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition Canvas5Parser.cxx:2718
Canvas5Parser::~Canvas5Parser
~Canvas5Parser() final
destructor
Definition Canvas5Parser.cxx:198
Canvas5Parser::checkTAG9
bool checkTAG9(Canvas5Structure::Stream &stream, std::string const &tag, int type)
try to check is the following is a tag: v9
Definition Canvas5Parser.cxx:3510
Canvas5Parser::readSlides
bool readSlides(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the list of slides
Definition Canvas5Parser.cxx:2392
Canvas5Parser::readPnot
bool readPnot(Canvas5Structure::Stream &stream, MWAWEntry const &entry)
read the RSRC 0 pnot zone
Definition Canvas5Parser.cxx:2784
Canvas5Parser::send
bool send(Canvas5ParserInternal::Slide const &slide)
try to send a page/slide
Definition Canvas5Parser.cxx:2856
Canvas5Parser::readDocumentSettings
bool readDocumentSettings(std::shared_ptr< Canvas5Structure::Stream > stream)
read the document settings
Definition Canvas5Parser.cxx:1774
Canvas5Parser::isWindowsFile
bool isWindowsFile() const
returns true if the file is a windows file
Definition Canvas5Parser.cxx:202
Canvas5Parser::getTAG9
bool getTAG9(Canvas5Structure::Stream &stream, std::string &tag, int &type)
try to return a tag, type:0 means begin, type:1 means end: v9
Definition Canvas5Parser.cxx:3543
Canvas5Parser::defDataFunction
static void defDataFunction(std::shared_ptr< Canvas5Structure::Stream >, Item const &, std::string const &)
the default function to parse the data of a index map/a extended header
Definition Canvas5Parser.hxx:208
Canvas5Parser::readExtendedHeader
bool readExtendedHeader(std::shared_ptr< Canvas5Structure::Stream > stream, int expectedValue, std::string const &what, DataFunction const &func)
try to read an extended data header, ie.
Definition Canvas5Parser.cxx:3040
Canvas5Parser::readPrinterRsrc
bool readPrinterRsrc(Canvas5Structure::Stream &stream)
try to read a printer rsrc
Definition Canvas5Parser.cxx:2015
Canvas5Parser::readFileHeader
bool readFileHeader(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the file header
Definition Canvas5Parser.cxx:1653
Canvas5Parser::Canvas5Parser
Canvas5Parser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition Canvas5Parser.cxx:179
Canvas5Parser::parse
void parse(librevenge::RVNGDrawingInterface *documentInterface) final
virtual function used to parse the input
Definition Canvas5Parser.cxx:221
Canvas5Parser::readDouble
bool readDouble(Canvas5Structure::Stream &stream, double &val, bool &isNaN) const
try to read a double 8
Definition Canvas5Parser.cxx:2959
Canvas5Parser::Canvas5StyleManager
friend class Canvas5StyleManager
Definition Canvas5Parser.hxx:75
Canvas5Parser::DataFunction
std::function< void(std::shared_ptr< Canvas5Structure::Stream >, Item const &, std::string const &)> DataFunction
a function used to parse the data of a index map/a extended header
Definition Canvas5Parser.hxx:206
Canvas5Parser::readPicture
bool readPicture(Canvas5Structure::Stream &stream, MWAWEntry const &entry)
read the RSRC Pict zone
Definition Canvas5Parser.cxx:2812
Canvas5Parser::readFileDesc
bool readFileDesc(Canvas5Structure::Stream &stream)
try to read the last block: some pathes, ...
Definition Canvas5Parser.cxx:1592
Canvas5Parser::decode
static MWAWInputStreamPtr decode(MWAWInputStreamPtr input, int version)
try to decode the input stream
Definition Canvas5Parser.cxx:3599
Canvas5Parser::readIndexMap
bool readIndexMap(std::shared_ptr< Canvas5Structure::Stream > stream, std::string const &what, DataFunction const &func=&Canvas5Parser::defDataFunction)
try to read a index map
Definition Canvas5Parser.cxx:3140
Canvas5Parser::readDataHeader
bool readDataHeader(Canvas5Structure::Stream &stream, int expectedSize, int &N)
try to read a data header, ie. N fields with a given size
Definition Canvas5Parser.cxx:3019
Canvas5Parser::readLayers
bool readLayers(std::shared_ptr< Canvas5Structure::Stream > stream)
try to read the different layers
Definition Canvas5Parser.cxx:1908
Canvas5Parser::readItemHeader9
bool readItemHeader9(Canvas5Structure::Stream &stream, int &id, int &used)
try to read an array item header: v9
Definition Canvas5Parser.cxx:3485
Canvas5Parser::createZones
bool createZones()
finds the different objects zones
Definition Canvas5Parser.cxx:381
Canvas5Parser::Canvas5Image
friend class Canvas5Image
Definition Canvas5Parser.hxx:74
Canvas5StyleManager
the main class to read the style part of Canvas 5 file
Definition Canvas5StyleManager.hxx:86
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MWAWGraphicParser::MWAWGraphicParser
MWAWGraphicParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:259
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition MWAWHeader.hxx:57
MWAWParser::version
int version() const
returns the works version
Definition MWAWParser.hxx:108
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition libmwaw_internal.hxx:561
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
Canvas5ParserInternal
Internal: the structures of a Canvas5Parser.
Definition Canvas5Parser.cxx:71
Canvas5Structure
a namespace used to define basic function or structure to read a Canvas v5-v11 file
Definition Canvas5BMParser.hxx:64
librevenge
Definition MWAWDocument.hxx:57
Canvas5ParserInternal::Layer
Internal: the layer of a Canvas5Parser.
Definition Canvas5Parser.cxx:90
Canvas5ParserInternal::Slide
Internal: the slide data of a Canvas5Parser.
Definition Canvas5Parser.cxx:73
Canvas5ParserInternal::State
Internal: the state of a Canvas5Parser.
Definition Canvas5Parser.cxx:111
Canvas5Parser::Item
a structure used to store the item data of a Canvas5Parser
Definition Canvas5Parser.hxx:183
Canvas5Parser::Item::Item
Item()
constructor
Definition Canvas5Parser.hxx:185
Canvas5Parser::Item::m_pos
long m_pos
the data beginning position (may be before the current position: v9)
Definition Canvas5Parser.hxx:201
Canvas5Parser::Item::m_length
long m_length
the data length (from current position)
Definition Canvas5Parser.hxx:199
Canvas5Parser::Item::m_decal
int m_decal
the decal position
Definition Canvas5Parser.hxx:203
Canvas5Parser::Item::m_id
int m_id
the identifier
Definition Canvas5Parser.hxx:195
Canvas5Parser::Item::m_type
unsigned m_type
the type (if known)
Definition Canvas5Parser.hxx:197
Canvas5Structure::Stream
a sub stream of Canvas5Structure
Definition Canvas5Structure.hxx:49