Canvas5Parser Class Reference documentation

Canvas5Parser Class Referencefinal

the main class to read a Canvas 5-10 files (and probably some not password protected Windows 11 files) More...

`#include <Canvas5Parser.hxx>`

Inheritance diagram for Canvas5Parser:

## Classes
struct | Item
| a structure used to store the item data of a Canvas5Parser More...

## Public Member Functions
| Canvas5Parser (MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
| constructor
| ~Canvas5Parser () final
| destructor
bool | checkHeader (MWAWHeader *header, bool strict=false) final
| checks if the document header is correct (or not)
void | parse (librevenge::RVNGDrawingInterface *documentInterface) final
| virtual function used to parse the input
Public Member Functions inherited from MWAWGraphicParser
| ~MWAWGraphicParser () override
| destructor
Public Member Functions inherited from MWAWParser
virtual | ~MWAWParser ()
| virtual destructor
int | version () const
| returns the works version
MWAWParserStatePtr | getParserState ()
| returns the parser state
MWAWHeader * | getHeader ()
| returns the header
MWAWInputStreamPtr & | getInput ()
| returns the actual input
MWAWListenerPtr | getMainListener ()
| returns the main listener
MWAWGraphicListenerPtr & | getGraphicListener ()
| returns the graphic listener
MWAWPresentationListenerPtr & | getPresentationListener ()
| returns the presentation listener
MWAWSpreadsheetListenerPtr & | getSpreadsheetListener ()
| returns the spreadsheet listener
MWAWTextListenerPtr & | getTextListener ()
| returns the text listener
MWAWFontConverterPtr & | getFontConverter ()
| returns the font converter
MWAWFontManagerPtr & | getFontManager ()
| returns the font manager
MWAWPageSpan const & | getPageSpan () const
| returns the actual page dimension
MWAWPageSpan & | getPageSpan ()
| returns the actual page dimension
double | getFormLength () const
| returns the form length
double | getFormWidth () const
| returns the form width
double | getPageLength () const
| returns the page length (form length without margin )
double | getPageWidth () const
| returns the page width (form width without margin )
MWAWRSRCParserPtr & | getRSRCParser ()
| returns the rsrc parser
libmwaw::DebugFile & | ascii ()
| a DebugFile used to write what we recognize when we parse the document

## Protected Types
typedef 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

## Protected Member Functions
void | createDocument (librevenge::RVNGDrawingInterface *documentInterface)
| creates the listener which will be associated to the document
bool | isWindowsFile () const
| returns true if the file is a windows file
librevenge::RVNGString | getTextLink (int textLinkId) const
| returns the link corresponding to a text id
bool | createZones ()
| finds the different objects zones
bool | readMainBlock (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the first big block
bool | readMainBlock9 (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the first big block: v9
bool | readFileRSRCs (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the third big block: a list of resource?, font, ...
bool | readSI200 (Canvas5Structure::Stream &stream)
| try to read the SI200 zone: v6
bool | readFileDesc (Canvas5Structure::Stream &stream)
| try to read the last block: some pathes, ...
bool | readFileHeader (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the file header
bool | readDocumentSettings (std::shared_ptr< Canvas5Structure::Stream > stream)
| read the document settings
bool | readLayers (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the different layers
bool | readSlides (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the list of slides
bool | readTextLinks (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the text links
bool | readPrinterRsrc (Canvas5Structure::Stream &stream)
| try to read a printer rsrc
bool | readOLnkRsrc (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the OLnk rsrc block: v6
bool | readObjectDBRsrc (std::shared_ptr< Canvas5Structure::Stream > stream)
| try to read the object database: XOBD v6
bool | readPnot (Canvas5Structure::Stream &stream, MWAWEntry const &entry)
| read the RSRC 0 pnot zone
bool | readPicture (Canvas5Structure::Stream &stream, MWAWEntry const &entry)
| read the RSRC Pict zone
bool | send (Canvas5ParserInternal::Slide const &slide)
| try to send a page/slide
bool | send (Canvas5ParserInternal::Layer const &layer)
| try to send a layer
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
bool | readDouble (Canvas5Structure::Stream &stream, double &val, bool &isNaN) const
| try to read a double 8
double | readDouble (Canvas5Structure::Stream &stream, int fieldSize) const
| try to read a float: either a double: fieldSize=8 or a int32 (divided by 65536)
int | readInteger (Canvas5Structure::Stream &stream, int fieldSize) const
| try to read a int: either a cast a double: fieldSize=8 or a int32/int16
bool | readDataHeader (Canvas5Structure::Stream &stream, int expectedSize, int &N)
| try to read a data header, ie. N fields with a given size
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.
bool | readUsed (Canvas5Structure::Stream &stream, std::string const &what)
| try to read the used list
bool | readDefined (Canvas5Structure::Stream &stream, std::vector< bool > &defined, std::string const &what)
| try to read the defined list
bool | readIndexMap (std::shared_ptr< Canvas5Structure::Stream > stream, std::string const &what, DataFunction const &func=&Canvas5Parser::defDataFunction)
| try to read a index map
bool | readArray9 (std::shared_ptr< Canvas5Structure::Stream > stream, std::string const &what, DataFunction const &func=&Canvas5Parser::defDataFunction)
| try to read an array: v9
bool | readItemHeader9 (Canvas5Structure::Stream &stream, int &id, int &used)
| try to read an array item header: v9
bool | getTAG9 (Canvas5Structure::Stream &stream, std::string &tag, int &type)
| try to return a tag, type:0 means begin, type:1 means end: v9
bool | checkTAG9 (Canvas5Structure::Stream &stream, std::string const &tag, int type)
| try to check is the following is a tag: v9
Protected Member Functions inherited from MWAWGraphicParser
| MWAWGraphicParser (MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
| constructor (protected)
| MWAWGraphicParser (MWAWParserStatePtr const &state)
| constructor using a state
Protected Member Functions inherited from MWAWParser
| MWAWParser (MWAWParserState::Type type, MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
| constructor (protected)
| MWAWParser (MWAWParserStatePtr const &state)
| constructor using a state
void | setVersion (int vers)
| sets the document's version
void | setGraphicListener (MWAWGraphicListenerPtr &listener)
| sets the graphic listener
void | resetGraphicListener ()
| resets the listener
void | setPresentationListener (MWAWPresentationListenerPtr &listener)
| sets the presentation listener
void | resetPresentationListener ()
| resets the listener
void | setSpreadsheetListener (MWAWSpreadsheetListenerPtr &listener)
| sets the spreadsheet listener
void | resetSpreadsheetListener ()
| resets the listener
void | setTextListener (MWAWTextListenerPtr &listener)
| sets the text listener
void | resetTextListener ()
| resets the listener
void | setAsciiName (char const *name)
| Debugging: change the default ascii file.
std::string const & | asciiName () const
| return the ascii file name

## Static Protected Member Functions
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
static void | stringDataFunction (std::shared_ptr< Canvas5Structure::Stream > stream, Item const &item, std::string const &what)
| the default function to parse a string
static MWAWInputStreamPtr | decode (MWAWInputStreamPtr input, int version)
| try to decode the input stream

## Protected Attributes
std::shared_ptr< Canvas5ParserInternal::State > | m_state
| the state
std::shared_ptr< Canvas5Graph > | m_graphParser
| the graph parser
std::shared_ptr< Canvas5Image > | m_imageParser
| the image parser
std::shared_ptr< Canvas5StyleManager > | m_styleManager
| the style manager

## Friends
class | Canvas5Graph
class | Canvas5Image
class | Canvas5StyleManager

## Detailed Description

the main class to read a Canvas 5-10 files (and probably some not password protected Windows 11 files)

## Member Typedef Documentation

## ◆ DataFunction

typedef std::function<void(std::shared_ptr<Canvas5Structure::Stream>, Item const &, std::string const &)> Canvas5Parser::DataFunction
| protected

a function used to parse the data of a index map/a extended header

## Constructor & Destructor Documentation

## ◆ Canvas5Parser()

Canvas5Parser::Canvas5Parser | ( | MWAWInputStreamPtr const & | input,
|  | MWAWRSRCParserPtr const & | rsrcParser,
|  | MWAWHeader * | header )

constructor

## ◆ ~Canvas5Parser()

Canvas5Parser::~Canvas5Parser | ( |  | ) |
| final

destructor

## Member Function Documentation

## ◆ checkHeader()

bool Canvas5Parser::checkHeader | ( | MWAWHeader * | header,
|  | bool | strict = false )
| finalvirtual

checks if the document header is correct (or not)

Implements MWAWParser.

Referenced by Canvas5StyleManager, and parse().

## ◆ checkTAG9()

bool Canvas5Parser::checkTAG9 | ( | Canvas5Structure::Stream & | stream,
|  | std::string const & | tag,
|  | int | type )
| protected

try to check is the following is a tag: v9

Referenced by readArray9(), and readMainBlock9().

## ◆ createDocument()

void Canvas5Parser::createDocument | ( | librevenge::RVNGDrawingInterface * | documentInterface | ) |
| protected

creates the listener which will be associated to the document

FIXME: it is simpler to create a big page which contains the left and right page, but it may be better to create each page and to only keep in each page the used shapes, ie. to translate back the right shape and also decompose the master page shapes in left/right

Referenced by Canvas5StyleManager, and parse().

## ◆ createZones()

bool Canvas5Parser::createZones | ( |  | ) |
| protected

finds the different objects zones

Referenced by Canvas5StyleManager, and parse().

## ◆ decode()

MWAWInputStreamPtr Canvas5Parser::decode | ( | MWAWInputStreamPtr | input,
|  | int | version )
| staticprotected

try to decode the input stream

Referenced by parse().

## ◆ defDataFunction()

void Canvas5Parser::defDataFunction | ( | std::shared_ptr< Canvas5Structure::Stream > | ,
|  | Item const & | ,
|  | std::string const & | )
| inlinestaticprotected

the default function to parse the data of a index map/a extended header

Referenced by readObjectDBRsrc(), readOLnkRsrc(), and readTextLinks().

## ◆ getTAG9()

bool Canvas5Parser::getTAG9 | ( | Canvas5Structure::Stream & | stream,
|  | std::string & | tag,
|  | int & | type )
| protected

try to return a tag, type:0 means begin, type:1 means end: v9

Referenced by checkTAG9(), and readMainBlock9().

## ◆ getTextLink()

librevenge::RVNGString Canvas5Parser::getTextLink | ( | int | textLinkId | ) | const
| protected

returns the link corresponding to a text id

Referenced by Canvas5StyleManager.

## ◆ isWindowsFile()

bool Canvas5Parser::isWindowsFile | ( |  | ) | const
| protected

returns true if the file is a windows file

Referenced by Canvas5StyleManager, readFileRSRCs(), readLayers(), readSI200(), and readString().

## ◆ parse()

void Canvas5Parser::parse | ( | librevenge::RVNGDrawingInterface * | documentInterface | ) |
| finalvirtual

virtual function used to parse the input

Implements MWAWGraphicParser.

Referenced by Canvas5StyleManager.

## ◆ readArray9()

bool Canvas5Parser::readArray9 | ( | std::shared_ptr< Canvas5Structure::Stream > | stream,
|  | std::string const & | what,
|  | Canvas5Parser::DataFunction const & | func = &Canvas5Parser::defDataFunction )
| protected

try to read an array: v9

Referenced by readMainBlock9(), and readSlides().

## ◆ readDataHeader()

bool Canvas5Parser::readDataHeader | ( | Canvas5Structure::Stream & | stream,
|  | int | expectedSize,
|  | int & | N )
| protected

try to read a data header, ie. N fields with a given size

Referenced by readDefined(), readIndexMap(), readOLnkRsrc(), and readUsed().

## ◆ readDefined()

bool Canvas5Parser::readDefined | ( | Canvas5Structure::Stream & | stream,
|  | std::vector< bool > & | defined,
|  | std::string const & | what )
| protected

try to read the defined list

Referenced by readFileRSRCs(), readObjectDBRsrc(), readOLnkRsrc(), readSlides(), and readTextLinks().

## ◆ readDocumentSettings()

bool Canvas5Parser::readDocumentSettings | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

read the document settings

Referenced by Canvas5StyleManager, readMainBlock(), and readMainBlock9().

## ◆ readDouble() [1/2]

bool Canvas5Parser::readDouble | ( | Canvas5Structure::Stream & | stream,
|  | double & | val,
|  | bool & | isNaN ) const
| protected

try to read a double 8

Referenced by Canvas5StyleManager, readDocumentSettings(), readDouble(), readFileRSRCs(), readInteger(), and readSlides().

## ◆ readDouble() [2/2]

double Canvas5Parser::readDouble | ( | Canvas5Structure::Stream & | stream,
|  | int | fieldSize ) const
| protected

try to read a float: either a double: fieldSize=8 or a int32 (divided by 65536)

## ◆ readExtendedHeader()

bool Canvas5Parser::readExtendedHeader | ( | std::shared_ptr< Canvas5Structure::Stream > | stream,
|  | int | expectedValue,
|  | std::string const & | what,
|  | DataFunction const & | func )
| protected

try to read an extended data header, ie.

N0 is expected to be value

Note
  the function func is called on each entry excepted the first one

Referenced by readFileRSRCs(), readObjectDBRsrc(), readOLnkRsrc(), readSlides(), and readTextLinks().

## ◆ readFileDesc()

bool Canvas5Parser::readFileDesc | ( | Canvas5Structure::Stream & | stream | ) |
| protected

try to read the last block: some pathes, ...

Referenced by Canvas5StyleManager, and createZones().

## ◆ readFileHeader()

bool Canvas5Parser::readFileHeader | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the file header

Referenced by Canvas5StyleManager, and createZones().

## ◆ readFileRSRCs()

bool Canvas5Parser::readFileRSRCs | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the third big block: a list of resource?, font, ...

Referenced by Canvas5StyleManager, and createZones().

## ◆ readIndexMap()

bool Canvas5Parser::readIndexMap | ( | std::shared_ptr< Canvas5Structure::Stream > | stream,
|  | std::string const & | what,
|  | DataFunction const & | func = &Canvas5Parser::defDataFunction )
| protected

try to read a index map

Referenced by readFileRSRCs(), readObjectDBRsrc(), readOLnkRsrc(), readSlides(), and readTextLinks().

## ◆ readInteger()

int Canvas5Parser::readInteger | ( | Canvas5Structure::Stream & | stream,
|  | int | fieldSize ) const
| protected

try to read a int: either a cast a double: fieldSize=8 or a int32/int16

Referenced by Canvas5StyleManager.

## ◆ readItemHeader9()

bool Canvas5Parser::readItemHeader9 | ( | Canvas5Structure::Stream & | stream,
|  | int & | id,
|  | int & | used )
| protected

try to read an array item header: v9

Referenced by readArray9().

## ◆ readLayers()

bool Canvas5Parser::readLayers | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the different layers

Referenced by Canvas5StyleManager, readMainBlock(), and readMainBlock9().

## ◆ readMainBlock()

bool Canvas5Parser::readMainBlock | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the first big block

Referenced by Canvas5StyleManager, and createZones().

## ◆ readMainBlock9()

bool Canvas5Parser::readMainBlock9 | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the first big block: v9

Referenced by Canvas5StyleManager, and createZones().

## ◆ readObjectDBRsrc()

bool Canvas5Parser::readObjectDBRsrc | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the object database: XOBD v6

Referenced by Canvas5StyleManager, and readFileRSRCs().

## ◆ readOLnkRsrc()

bool Canvas5Parser::readOLnkRsrc | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the OLnk rsrc block: v6

Referenced by Canvas5StyleManager, and readFileRSRCs().

## ◆ readPicture()

bool Canvas5Parser::readPicture | ( | Canvas5Structure::Stream & | stream,
|  | MWAWEntry const & | entry )
| protected

read the RSRC Pict zone

Referenced by Canvas5StyleManager, and createZones().

## ◆ readPnot()

bool Canvas5Parser::readPnot | ( | Canvas5Structure::Stream & | stream,
|  | MWAWEntry const & | entry )
| protected

read the RSRC 0 pnot zone

Referenced by Canvas5StyleManager, and createZones().

## ◆ readPrinterRsrc()

bool Canvas5Parser::readPrinterRsrc | ( | Canvas5Structure::Stream & | stream | ) |
| protected

try to read a printer rsrc

Referenced by Canvas5StyleManager, and readFileRSRCs().

## ◆ readSI200()

bool Canvas5Parser::readSI200 | ( | Canvas5Structure::Stream & | stream | ) |
| protected

try to read the SI200 zone: v6

Referenced by Canvas5StyleManager, and createZones().

## ◆ readSlides()

bool Canvas5Parser::readSlides | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the list of slides

Referenced by Canvas5StyleManager, readMainBlock(), and readMainBlock9().

## ◆ readString()

bool Canvas5Parser::readString | ( | Canvas5Structure::Stream & | stream,
|  | librevenge::RVNGString & | string,
|  | int | maxSize,
|  | bool | canBeCString = false )
| protected

try to read a pascal string in the data fork or a Pascal/C string depending on the file type

Referenced by Canvas5StyleManager.

## ◆ readTextLinks()

bool Canvas5Parser::readTextLinks | ( | std::shared_ptr< Canvas5Structure::Stream > | stream | ) |
| protected

try to read the text links

Referenced by Canvas5StyleManager, and readMainBlock().

## ◆ readUsed()

bool Canvas5Parser::readUsed | ( | Canvas5Structure::Stream & | stream,
|  | std::string const & | what )
| protected

try to read the used list

Referenced by readFileRSRCs().

## ◆ send() [1/2]

bool Canvas5Parser::send | ( | Canvas5ParserInternal::Layer const & | layer | ) |
| protected

try to send a layer

## ◆ send() [2/2]

bool Canvas5Parser::send | ( | Canvas5ParserInternal::Slide const & | slide | ) |
| protected

try to send a page/slide

Referenced by Canvas5StyleManager, createDocument(), and send().

## ◆ stringDataFunction()

void Canvas5Parser::stringDataFunction | ( | std::shared_ptr< Canvas5Structure::Stream > | stream,
|  | Canvas5Parser::Item const & | item,
|  | std::string const & | what )
| staticprotected

the default function to parse a string

Referenced by readFileRSRCs(), readMainBlock9(), and Canvas5StyleManager::readParaStyles().

## Friends And Related Symbol Documentation

## ◆ Canvas5Graph

friend class Canvas5Graph
| friend

Referenced by Canvas5Graph, and Canvas5Parser().

## ◆ Canvas5Image

friend class Canvas5Image
| friend

Referenced by Canvas5Image, and Canvas5Parser().

## ◆ Canvas5StyleManager

friend class Canvas5StyleManager
| friend

Referenced by Canvas5Parser(), and Canvas5StyleManager.

## Member Data Documentation

## ◆ m_graphParser

std::shared_ptr<Canvas5Graph> Canvas5Parser::m_graphParser
| protected

the graph parser

Referenced by Canvas5Parser(), readMainBlock(), readMainBlock9(), and send().

## ◆ m_imageParser

std::shared_ptr<Canvas5Image> Canvas5Parser::m_imageParser
| protected

the image parser

Referenced by Canvas5Parser(), createZones(), readFileRSRCs(), and readMainBlock9().

## ◆ m_state

std::shared_ptr<Canvas5ParserInternal::State> Canvas5Parser::m_state
| protected

the state

Referenced by Canvas5Parser(), checkHeader(), createDocument(), createZones(), getTextLink(), isWindowsFile(), parse(), readDocumentSettings(), readFileHeader(), readFileRSRCs(), readLayers(), readMainBlock(), readMainBlock9(), readPrinterRsrc(), readSI200(), readSlides(), and send().

## ◆ m_styleManager

std::shared_ptr<Canvas5StyleManager> Canvas5Parser::m_styleManager
| protected

the style manager

Referenced by Canvas5Parser(), readDocumentSettings(), readFileRSRCs(), readMainBlock(), and readMainBlock9().

The documentation for this class was generated from the following files:

- Canvas5Parser.hxx
- Canvas5Parser.cxx