VSDParser.h
Go to the documentation of this file.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* This file is part of the libvisio project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef __VSDPARSER_H__
#define __VSDPARSER_H__
#include <stdio.h>
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <librevenge/librevenge.h>
#include "VSDTypes.h"
#include "VSDGeometryList.h"
#include "VSDFieldList.h"
#include "VSDCharacterList.h"
#include "VSDParagraphList.h"
#include "VSDShapeList.h"
#include "VSDLayerList.h"
#include "VSDStencils.h"
namespace libvisio
{
class VSDCollector;
struct Pointer
{
Pointer()
: Type(0), Offset(0), Length(0), Format(0), ListSize(0) {}
Pointer(const Pointer &ptr) = default;
Pointer &operator=(const Pointer &ptr) = default;
unsigned Type;
unsigned Offset;
unsigned Length;
unsigned short Format;
unsigned ListSize;
};
class VSDParser
{
public:
explicit VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter, librevenge::RVNGInputStream *container = nullptr);
virtual ~VSDParser();
bool parseMain();
bool extractStencils();
protected:
// reader functions
void readEllipticalArcTo(librevenge::RVNGInputStream *input);
void readForeignData(librevenge::RVNGInputStream *input);
void readEllipse(librevenge::RVNGInputStream *input);
virtual void readLine(librevenge::RVNGInputStream *input);
virtual void readFillAndShadow(librevenge::RVNGInputStream *input);
virtual void readGeomList(librevenge::RVNGInputStream *input);
void readGeometry(librevenge::RVNGInputStream *input);
void readMoveTo(librevenge::RVNGInputStream *input);
void readLineTo(librevenge::RVNGInputStream *input);
void readArcTo(librevenge::RVNGInputStream *input);
void readNURBSTo(librevenge::RVNGInputStream *input);
void readPolylineTo(librevenge::RVNGInputStream *input);
void readInfiniteLine(librevenge::RVNGInputStream *input);
void readShapeData(librevenge::RVNGInputStream *input);
void readXFormData(librevenge::RVNGInputStream *input);
virtual void readXForm1D(librevenge::RVNGInputStream *input);
void readTxtXForm(librevenge::RVNGInputStream *input);
void readShapeId(librevenge::RVNGInputStream *input);
virtual void readShapeList(librevenge::RVNGInputStream *input);
void readForeignDataType(librevenge::RVNGInputStream *input);
void readPageProps(librevenge::RVNGInputStream *input);
virtual void readShape(librevenge::RVNGInputStream *input);
void readColours(librevenge::RVNGInputStream *input);
void readFont(librevenge::RVNGInputStream *input);
void readFontIX(librevenge::RVNGInputStream *input);
virtual void readCharList(librevenge::RVNGInputStream *input);
virtual void readParaList(librevenge::RVNGInputStream *input);
virtual void readPropList(librevenge::RVNGInputStream *input);
virtual void readPage(librevenge::RVNGInputStream *input);
virtual void readText(librevenge::RVNGInputStream *input);
virtual void readCharIX(librevenge::RVNGInputStream *input);
virtual void readParaIX(librevenge::RVNGInputStream *input);
virtual void readTextBlock(librevenge::RVNGInputStream *input);
virtual void readTabsDataList(librevenge::RVNGInputStream *input);
virtual void readTabsData(librevenge::RVNGInputStream *input);
void readNameList(librevenge::RVNGInputStream *input);
virtual void readName(librevenge::RVNGInputStream *input);
virtual void readNameList2(librevenge::RVNGInputStream *input);
virtual void readName2(librevenge::RVNGInputStream *input);
virtual void readFieldList(librevenge::RVNGInputStream *input);
virtual void readTextField(librevenge::RVNGInputStream *input);
virtual void readStyleSheet(librevenge::RVNGInputStream *input);
void readPageSheet(librevenge::RVNGInputStream *input);
void readSplineStart(librevenge::RVNGInputStream *input);
void readSplineKnot(librevenge::RVNGInputStream *input);
void readStencilShape(librevenge::RVNGInputStream *input);
void readOLEList(librevenge::RVNGInputStream *input);
void readOLEData(librevenge::RVNGInputStream *input);
virtual void readNameIDX(librevenge::RVNGInputStream *input);
virtual void readNameIDX123(librevenge::RVNGInputStream *input);
virtual void readMisc(librevenge::RVNGInputStream *input);
virtual void readLayerList(librevenge::RVNGInputStream *input);
virtual void readLayer(librevenge::RVNGInputStream *input);
virtual void readLayerMem(librevenge::RVNGInputStream *input);
// parser of one pass
bool parseDocument(librevenge::RVNGInputStream *input, unsigned shift);
void parseMetaData();
// Stream handlers
void handleStreams(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned level, std::set<unsigned> &visited);
void handleStream(const Pointer &ptr, unsigned idx, unsigned level, std::set<unsigned> &visited);
void handleChunks(librevenge::RVNGInputStream *input, unsigned level);
void handleChunk(librevenge::RVNGInputStream *input);
void handleBlob(librevenge::RVNGInputStream *input, unsigned shift, unsigned level);
virtual void readPointer(librevenge::RVNGInputStream *input, Pointer &ptr);
virtual void readPointerInfo(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned &listSize, int &pointerCount);
virtual bool getChunkHeader(librevenge::RVNGInputStream *input);
void _handleLevelChange(unsigned level);
Colour _colourFromIndex(unsigned idx);
void _flushShape();
void _nameFromId(VSDName &name, unsigned id, unsigned level);
virtual unsigned getUInt(librevenge::RVNGInputStream *input);
virtual int getInt(librevenge::RVNGInputStream *input);
librevenge::RVNGInputStream *m_input;
librevenge::RVNGDrawingInterface *m_painter;
librevenge::RVNGInputStream *m_container;
ChunkHeader m_header;
VSDCollector *m_collector;
VSDShapeList m_shapeList;
unsigned m_currentLevel;
VSDStencils m_stencils;
VSDStencil *m_currentStencil;
VSDShape m_shape;
bool m_isStencilStarted;
bool m_isInStyles;
unsigned m_currentShapeLevel;
unsigned m_currentShapeID;
unsigned m_currentLayerListLevel;
bool m_extractStencils;
std::vector<Colour> m_colours;
bool m_isBackgroundPage;
bool m_isShapeStarted;
double m_shadowOffsetX;
double m_shadowOffsetY;
VSDGeometryList *m_currentGeometryList;
unsigned m_currentGeomListCount;
std::map<unsigned, VSDName> m_fonts;
std::map<unsigned, VSDName> m_names;
std::map<unsigned, std::map<unsigned, VSDName> > m_namesMapMap;
VSDName m_currentPageName;
std::map<unsigned, VSDTabStop> *m_currentTabSet;
private:
VSDParser();
VSDParser(const VSDParser &);
VSDParser &operator=(const VSDParser &);
};
} // namespace libvisio
#endif // __VSDPARSER_H__
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
VSDCharacterList.h
VSDFieldList.h
VSDGeometryList.h
VSDLayerList.h
VSDParagraphList.h
VSDShapeList.h
VSDStencils.h
VSDTypes.h
libvisio::VSDCollector
Definition VSDCollector.h:21
libvisio::VSDGeometryList
Definition VSDGeometryList.h:48
libvisio::VSDName
Definition VSDTypes.h:171
libvisio::VSDParser::getChunkHeader
virtual bool getChunkHeader(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:51
libvisio::VSDParser::readOLEList
void readOLEList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:781
libvisio::VSDParser::readShape
virtual void readShape(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1283
libvisio::VSDParser::readCharList
virtual void readCharList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:960
libvisio::VSDParser::_handleLevelChange
void _handleLevelChange(unsigned level)
Definition VSDParser.cpp:716
libvisio::VSDParser::getInt
virtual int getInt(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:2303
libvisio::VSDParser::parseMain
bool parseMain()
Definition VSDParser.cpp:107
libvisio::VSDParser::readPointerInfo
virtual void readPointerInfo(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned &listSize, int &pointerCount)
Definition VSDParser.cpp:211
libvisio::VSDParser::readPage
virtual void readPage(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1088
libvisio::VSDParser::readStencilShape
void readStencilShape(librevenge::RVNGInputStream *input)
libvisio::VSDParser::readSplineKnot
void readSplineKnot(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1699
libvisio::VSDParser::m_isBackgroundPage
bool m_isBackgroundPage
Definition VSDParser.h:166
libvisio::VSDParser::handleChunk
void handleChunk(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:461
libvisio::VSDParser::readForeignDataType
void readForeignDataType(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1226
libvisio::VSDParser::readFontIX
void readFontIX(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1776
libvisio::VSDParser::readXFormData
void readXFormData(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1141
libvisio::VSDParser::m_container
librevenge::RVNGInputStream * m_container
Definition VSDParser.h:147
libvisio::VSDParser::readTextField
virtual void readTextField(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:2178
libvisio::VSDParser::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition VSDParser.h:172
libvisio::VSDParser::m_shadowOffsetX
double m_shadowOffsetX
Definition VSDParser.h:169
libvisio::VSDParser::handleChunks
void handleChunks(librevenge::RVNGInputStream *input, unsigned level)
Definition VSDParser.cpp:443
libvisio::VSDParser::m_currentGeomListCount
unsigned m_currentGeomListCount
Definition VSDParser.h:173
libvisio::VSDParser::readNameList
void readNameList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1711
libvisio::VSDParser::readPointer
virtual void readPointer(librevenge::RVNGInputStream *input, Pointer &ptr)
Definition VSDParser.cpp:202
libvisio::VSDParser::readArcTo
void readArcTo(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1128
libvisio::VSDParser::readNameIDX
virtual void readNameIDX(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:814
libvisio::VSDParser::readParaIX
virtual void readParaIX(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1999
libvisio::VSDParser::parseMetaData
void parseMetaData()
Definition VSDParser.cpp:154
libvisio::VSDParser::readEllipticalArcTo
void readEllipticalArcTo(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:747
libvisio::VSDParser::readTxtXForm
void readTxtXForm(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1175
libvisio::VSDParser::readText
virtual void readText(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1909
libvisio::VSDParser::m_namesMapMap
std::map< unsigned, std::map< unsigned, VSDName > > m_namesMapMap
Definition VSDParser.h:177
libvisio::VSDParser::handleBlob
void handleBlob(librevenge::RVNGInputStream *input, unsigned shift, unsigned level)
Definition VSDParser.cpp:427
libvisio::VSDParser::handleStreams
void handleStreams(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned level, std::set< unsigned > &visited)
Definition VSDParser.cpp:222
libvisio::VSDParser::m_input
librevenge::RVNGInputStream * m_input
Definition VSDParser.h:145
libvisio::VSDParser::readNURBSTo
void readNURBSTo(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1343
libvisio::VSDParser::m_extractStencils
bool m_extractStencils
Definition VSDParser.h:163
libvisio::VSDParser::readShapeId
void readShapeId(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1194
libvisio::VSDParser::m_isStencilStarted
bool m_isStencilStarted
Definition VSDParser.h:156
libvisio::VSDParser::readPageProps
void readPageProps(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1254
libvisio::VSDParser::readGeomList
virtual void readGeomList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:930
libvisio::VSDParser::operator=
VSDParser & operator=(const VSDParser &)
libvisio::VSDParser::parseDocument
bool parseDocument(librevenge::RVNGInputStream *input, unsigned shift)
Definition VSDParser.cpp:180
libvisio::VSDParser::readParaList
virtual void readParaList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:982
libvisio::VSDParser::readLineTo
void readLineTo(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1117
libvisio::VSDParser::_colourFromIndex
Colour _colourFromIndex(unsigned idx)
Definition VSDParser.cpp:2291
libvisio::VSDParser::readTabsData
virtual void readTabsData(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:800
libvisio::VSDParser::m_isShapeStarted
bool m_isShapeStarted
Definition VSDParser.h:167
libvisio::VSDParser::readColours
void readColours(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1740
libvisio::VSDParser::VSDParser
VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter, librevenge::RVNGInputStream *container=nullptr)
Definition VSDParser.cpp:26
libvisio::VSDParser::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition VSDParser.h:158
libvisio::VSDParser::handleStream
void handleStream(const Pointer &ptr, unsigned idx, unsigned level, std::set< unsigned > &visited)
Definition VSDParser.cpp:293
libvisio::VSDParser::m_currentShapeID
unsigned m_currentShapeID
Definition VSDParser.h:159
libvisio::VSDParser::readTextBlock
virtual void readTextBlock(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:895
libvisio::VSDParser::readLayerList
virtual void readLayerList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1028
libvisio::VSDParser::m_header
ChunkHeader m_header
Definition VSDParser.h:148
libvisio::VSDParser::m_shapeList
VSDShapeList m_shapeList
Definition VSDParser.h:150
libvisio::VSDParser::m_currentLevel
unsigned m_currentLevel
Definition VSDParser.h:151
libvisio::VSDParser::readLine
virtual void readLine(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:871
libvisio::VSDParser::readShapeList
virtual void readShapeList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1202
libvisio::VSDParser::m_currentStencil
VSDStencil * m_currentStencil
Definition VSDParser.h:154
libvisio::VSDParser::VSDParser
VSDParser(const VSDParser &)
libvisio::VSDParser::~VSDParser
virtual ~VSDParser()
Definition VSDParser.cpp:35
libvisio::VSDParser::_flushShape
void _flushShape()
Definition VSDParser.cpp:637
libvisio::VSDParser::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition VSDParser.h:175
libvisio::VSDParser::extractStencils
bool extractStencils()
Definition VSDParser.cpp:196
libvisio::VSDParser::m_currentPageName
VSDName m_currentPageName
Definition VSDParser.h:178
libvisio::VSDParser::readOLEData
void readOLEData(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:785
libvisio::VSDParser::m_currentLayerListLevel
unsigned m_currentLayerListLevel
Definition VSDParser.h:161
libvisio::VSDParser::m_collector
VSDCollector * m_collector
Definition VSDParser.h:149
libvisio::VSDParser::_nameFromId
void _nameFromId(VSDName &name, unsigned id, unsigned level)
Definition VSDParser.cpp:39
libvisio::VSDParser::readStyleSheet
virtual void readStyleSheet(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1891
libvisio::VSDParser::m_shadowOffsetY
double m_shadowOffsetY
Definition VSDParser.h:170
libvisio::VSDParser::readMisc
virtual void readMisc(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:2247
libvisio::VSDParser::readCharIX
virtual void readCharIX(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1931
libvisio::VSDParser::m_shape
VSDShape m_shape
Definition VSDParser.h:155
libvisio::VSDParser::readForeignData
void readForeignData(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:767
libvisio::VSDParser::m_stencils
VSDStencils m_stencils
Definition VSDParser.h:153
libvisio::VSDParser::readGeometry
void readGeometry(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1095
libvisio::VSDParser::m_isInStyles
bool m_isInStyles
Definition VSDParser.h:157
libvisio::VSDParser::getUInt
virtual unsigned getUInt(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:2298
libvisio::VSDParser::VSDParser
VSDParser()
libvisio::VSDParser::readName2
virtual void readName2(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:2163
libvisio::VSDParser::readNameList2
virtual void readNameList2(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1716
libvisio::VSDParser::readPolylineTo
void readPolylineTo(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1502
libvisio::VSDParser::readEllipse
void readEllipse(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:852
libvisio::VSDParser::readMoveTo
void readMoveTo(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1106
libvisio::VSDParser::readSplineStart
void readSplineStart(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1684
libvisio::VSDParser::readXForm1D
virtual void readXForm1D(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1161
libvisio::VSDParser::readPropList
virtual void readPropList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1004
libvisio::VSDParser::readPageSheet
void readPageSheet(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1903
libvisio::VSDParser::readLayer
virtual void readLayer(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1048
libvisio::VSDParser::readInfiniteLine
void readInfiniteLine(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1601
libvisio::VSDParser::readLayerMem
virtual void readLayerMem(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1071
libvisio::VSDParser::readNameIDX123
virtual void readNameIDX123(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:836
libvisio::VSDParser::m_names
std::map< unsigned, VSDName > m_names
Definition VSDParser.h:176
libvisio::VSDParser::m_currentTabSet
std::map< unsigned, VSDTabStop > * m_currentTabSet
Definition VSDParser.h:180
libvisio::VSDParser::m_painter
librevenge::RVNGDrawingInterface * m_painter
Definition VSDParser.h:146
libvisio::VSDParser::readName
virtual void readName(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:2152
libvisio::VSDParser::m_colours
std::vector< Colour > m_colours
Definition VSDParser.h:164
libvisio::VSDParser::readShapeData
void readShapeData(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1615
libvisio::VSDParser::readFont
void readFont(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1759
libvisio::VSDParser::readFillAndShadow
virtual void readFillAndShadow(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:2084
libvisio::VSDParser::readFieldList
virtual void readFieldList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1721
libvisio::VSDParser::readTabsDataList
virtual void readTabsDataList(librevenge::RVNGInputStream *input)
Definition VSDParser.cpp:1008
libvisio::VSDShapeList
Definition VSDShapeList.h:20
libvisio::VSDShape
Definition VSDStencils.h:28
libvisio::VSDStencil
Definition VSDStencils.h:64
libvisio::VSDStencils
Definition VSDStencils.h:80
libvisio
Definition libvisio_utils.h:47
libvisio::ChunkHeader
Definition VSDTypes.h:59
libvisio::Colour
Definition VSDTypes.h:71
libvisio::Pointer
Definition VSDParser.h:35
libvisio::Pointer::Type
unsigned Type
Definition VSDParser.h:40
libvisio::Pointer::Offset
unsigned Offset
Definition VSDParser.h:41
libvisio::Pointer::Format
unsigned short Format
Definition VSDParser.h:43
libvisio::Pointer::Length
unsigned Length
Definition VSDParser.h:42
libvisio::Pointer::operator=
Pointer & operator=(const Pointer &ptr)=default
libvisio::Pointer::Pointer
Pointer()
Definition VSDParser.h:36
libvisio::Pointer::ListSize
unsigned ListSize
Definition VSDParser.h:44
libvisio::Pointer::Pointer
Pointer(const Pointer &ptr)=default