VSDXMLParserBase.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 __VSDXMLPARSERBASE_H__
#define __VSDXMLPARSERBASE_H__
#include <map>
#include <memory>
#include <stack>
#include <string>
#include <optional>
#include "VSDXMLHelper.h"
#include "VSDCharacterList.h"
#include "VSDParagraphList.h"
#include "VSDShapeList.h"
#include "VSDStencils.h"
namespace libvisio
{
class VSDCollector;
class XMLErrorWatcher;
class VSDXMLParserBase
{
public:
explicit VSDXMLParserBase();
virtual ~VSDXMLParserBase();
virtual bool parseMain() = 0;
virtual bool extractStencils() = 0;
protected:
// Protected data
VSDCollector *m_collector;
VSDStencils m_stencils;
std::unique_ptr<VSDStencil> m_currentStencil;
VSDShape m_shape;
bool m_isStencilStarted;
unsigned m_currentStencilID;
bool m_extractStencils;
bool m_isInStyles;
unsigned m_currentLevel;
unsigned m_currentShapeLevel;
std::map<unsigned, Colour> m_colours;
VSDFieldList m_fieldList;
VSDShapeList m_shapeList;
librevenge::RVNGBinaryData m_currentBinaryData;
std::stack<VSDShape> m_shapeStack;
std::stack<unsigned> m_shapeLevelStack;
bool m_isShapeStarted;
bool m_isPageStarted;
VSDGeometryList *m_currentGeometryList;
unsigned m_currentGeometryListIndex;
std::map<unsigned, VSDName> m_fonts;
std::map<unsigned, VSDTabStop> *m_currentTabSet;
XMLErrorWatcher *m_watcher;
// Helper functions
int readByteData(unsigned char &value, xmlTextReaderPtr reader);
int readByteData(std::optional<unsigned char> &value, xmlTextReaderPtr reader);
int readUnsignedData(std::optional<unsigned> &value, xmlTextReaderPtr reader);
int readLongData(std::optional<long> &value, xmlTextReaderPtr reader);
int readLongData(long &value, xmlTextReaderPtr reader);
int readDoubleData(std::optional<double> &value, xmlTextReaderPtr reader);
int readDoubleData(double &value, xmlTextReaderPtr reader);
int readBoolData(std::optional<bool> &value, xmlTextReaderPtr reader);
int readBoolData(bool &value, xmlTextReaderPtr reader);
int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader);
int readExtendedColourData(Colour &value, xmlTextReaderPtr reader);
int readExtendedColourData(std::optional<Colour> &value, xmlTextReaderPtr reader);
bool readColourOrColourIndex(Colour &value, long &idx, xmlTextReaderPtr reader);
int readNURBSData(std::optional<NURBSData> &data, xmlTextReaderPtr reader);
int readPolylineData(std::optional<PolylineData> &data, xmlTextReaderPtr reader);
int readStringData(VSDName &text, xmlTextReaderPtr reader);
void readTriggerId(unsigned &id, xmlTextReaderPtr reader);
virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
unsigned getIX(xmlTextReaderPtr reader);
virtual void _handleLevelChange(unsigned level);
void _flushShape();
virtual int getElementToken(xmlTextReaderPtr reader) = 0;
virtual int getElementDepth(xmlTextReaderPtr reader) = 0;
// Functions reading the DiagramML document content
void readEllipticalArcTo(xmlTextReaderPtr reader);
void readEllipse(xmlTextReaderPtr reader);
void readGeometry(xmlTextReaderPtr reader);
void readMoveTo(xmlTextReaderPtr reader);
void readLineTo(xmlTextReaderPtr reader);
void readArcTo(xmlTextReaderPtr reader);
void readNURBSTo(xmlTextReaderPtr reader);
void readPolylineTo(xmlTextReaderPtr reader);
void readInfiniteLine(xmlTextReaderPtr reader);
void readRelCubBezTo(xmlTextReaderPtr reader);
void readRelEllipticalArcTo(xmlTextReaderPtr reader);
void readRelLineTo(xmlTextReaderPtr reader);
void readRelMoveTo(xmlTextReaderPtr reader);
void readRelQuadBezTo(xmlTextReaderPtr reader);
void readForeignData(xmlTextReaderPtr reader);
virtual void getBinaryData(xmlTextReaderPtr reader) = 0;
void readShape(xmlTextReaderPtr reader);
void readColours(xmlTextReaderPtr reader);
void readPage(xmlTextReaderPtr reader);
void readText(xmlTextReaderPtr reader);
void readCharIX(xmlTextReaderPtr reader);
void readParaIX(xmlTextReaderPtr reader);
void readLayerIX(xmlTextReaderPtr reader);
void readLayerMember(xmlTextReaderPtr reader);
void readStyleSheet(xmlTextReaderPtr reader);
void readPageSheet(xmlTextReaderPtr reader);
void readSplineStart(xmlTextReaderPtr reader);
void readSplineKnot(xmlTextReaderPtr reader);
void readStencil(xmlTextReaderPtr reader);
void handlePagesStart(xmlTextReaderPtr reader);
void handlePagesEnd(xmlTextReaderPtr reader);
void handlePageStart(xmlTextReaderPtr reader);
void handlePageEnd(xmlTextReaderPtr reader);
void handleMastersStart(xmlTextReaderPtr reader);
void handleMastersEnd(xmlTextReaderPtr reader);
void handleMasterStart(xmlTextReaderPtr reader);
void handleMasterEnd(xmlTextReaderPtr reader);
void skipPages(xmlTextReaderPtr reader);
void skipMasters(xmlTextReaderPtr reader);
private:
VSDXMLParserBase(const VSDXMLParserBase &);
VSDXMLParserBase &operator=(const VSDXMLParserBase &);
void initColours();
};
} // namespace libvisio
#endif // __VSDXMLPARSERBASE_H__
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
VSDCharacterList.h
VSDParagraphList.h
VSDShapeList.h
VSDStencils.h
VSDXMLHelper.h
libvisio::VSDCollector
Definition VSDCollector.h:21
libvisio::VSDFieldList
Definition VSDFieldList.h:88
libvisio::VSDGeometryList
Definition VSDGeometryList.h:48
libvisio::VSDName
Definition VSDTypes.h:171
libvisio::VSDShapeList
Definition VSDShapeList.h:20
libvisio::VSDShape
Definition VSDStencils.h:28
libvisio::VSDStencils
Definition VSDStencils.h:80
libvisio::VSDXMLParserBase::getElementDepth
virtual int getElementDepth(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::readColourOrColourIndex
bool readColourOrColourIndex(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2242
libvisio::VSDXMLParserBase::getBinaryData
virtual void getBinaryData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::handleMasterStart
void handleMasterStart(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1921
libvisio::VSDXMLParserBase::readUnsignedData
int readUnsignedData(std::optional< unsigned > &value, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2170
libvisio::VSDXMLParserBase::readDoubleData
int readDoubleData(std::optional< double > &value, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2105
libvisio::VSDXMLParserBase::readGeometry
void readGeometry(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:48
libvisio::VSDXMLParserBase::readRelLineTo
void readRelLineTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:772
libvisio::VSDXMLParserBase::VSDXMLParserBase
VSDXMLParserBase(const VSDXMLParserBase &)
libvisio::VSDXMLParserBase::readParaIX
void readParaIX(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1419
libvisio::VSDXMLParserBase::handleMastersStart
void handleMastersStart(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1898
libvisio::VSDXMLParserBase::readStringData
int readStringData(VSDName &text, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2089
libvisio::VSDXMLParserBase::m_shapeLevelStack
std::stack< unsigned > m_shapeLevelStack
Definition VSDXMLParserBase.h:56
libvisio::VSDXMLParserBase::readPageSheet
void readPageSheet(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1581
libvisio::VSDXMLParserBase::m_isStencilStarted
bool m_isStencilStarted
Definition VSDXMLParserBase.h:44
libvisio::VSDXMLParserBase::initColours
void initColours()
Definition VSDXMLParserBase.cpp:1012
libvisio::VSDXMLParserBase::readText
void readText(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1093
libvisio::VSDXMLParserBase::m_currentGeometryListIndex
unsigned m_currentGeometryListIndex
Definition VSDXMLParserBase.h:60
libvisio::VSDXMLParserBase::readLayerMember
void readLayerMember(xmlTextReaderPtr reader)
libvisio::VSDXMLParserBase::readNURBSTo
void readNURBSTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:457
libvisio::VSDXMLParserBase::m_currentStencil
std::unique_ptr< VSDStencil > m_currentStencil
Definition VSDXMLParserBase.h:42
libvisio::VSDXMLParserBase::m_shapeList
VSDShapeList m_shapeList
Definition VSDXMLParserBase.h:53
libvisio::VSDXMLParserBase::handleMasterEnd
void handleMasterEnd(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1930
libvisio::VSDXMLParserBase::readStencil
void readStencil(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1707
libvisio::VSDXMLParserBase::readStyleSheet
void readStyleSheet(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1565
libvisio::VSDXMLParserBase::readArcTo
void readArcTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:271
libvisio::VSDXMLParserBase::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition VSDXMLParserBase.h:62
libvisio::VSDXMLParserBase::parseMain
virtual bool parseMain()=0
libvisio::VSDXMLParserBase::readEllipse
void readEllipse(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:391
libvisio::VSDXMLParserBase::readTriggerId
void readTriggerId(unsigned &id, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2279
libvisio::VSDXMLParserBase::m_stencils
VSDStencils m_stencils
Definition VSDXMLParserBase.h:41
libvisio::VSDXMLParserBase::operator=
VSDXMLParserBase & operator=(const VSDXMLParserBase &)
libvisio::VSDXMLParserBase::readColours
void readColours(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1041
libvisio::VSDXMLParserBase::handleMastersEnd
void handleMastersEnd(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1912
libvisio::VSDXMLParserBase::readRelCubBezTo
void readRelCubBezTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:706
libvisio::VSDXMLParserBase::readPolylineTo
void readPolylineTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:528
libvisio::VSDXMLParserBase::readByteData
int readByteData(unsigned char &value, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2179
libvisio::VSDXMLParserBase::~VSDXMLParserBase
virtual ~VSDXMLParserBase()
Definition VSDXMLParserBase.cpp:42
libvisio::VSDXMLParserBase::m_currentLevel
unsigned m_currentLevel
Definition VSDXMLParserBase.h:49
libvisio::VSDXMLParserBase::m_currentBinaryData
librevenge::RVNGBinaryData m_currentBinaryData
Definition VSDXMLParserBase.h:54
libvisio::VSDXMLParserBase::m_extractStencils
bool m_extractStencils
Definition VSDXMLParserBase.h:47
libvisio::VSDXMLParserBase::readSplineKnot
void readSplineKnot(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1653
libvisio::VSDXMLParserBase::getElementToken
virtual int getElementToken(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::readNURBSData
int readNURBSData(std::optional< NURBSData > &data, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1979
libvisio::VSDXMLParserBase::extractStencils
virtual bool extractStencils()=0
libvisio::VSDXMLParserBase::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition VSDXMLParserBase.h:50
libvisio::VSDXMLParserBase::_handleLevelChange
virtual void _handleLevelChange(unsigned level)
Definition VSDXMLParserBase.cpp:1857
libvisio::VSDXMLParserBase::handlePagesStart
void handlePagesStart(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1863
libvisio::VSDXMLParserBase::m_collector
VSDCollector * m_collector
Definition VSDXMLParserBase.h:40
libvisio::VSDXMLParserBase::readRelMoveTo
void readRelMoveTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:822
libvisio::VSDXMLParserBase::m_currentTabSet
std::map< unsigned, VSDTabStop > * m_currentTabSet
Definition VSDXMLParserBase.h:64
libvisio::VSDXMLParserBase::handlePageStart
void handlePageStart(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1878
libvisio::VSDXMLParserBase::m_isShapeStarted
bool m_isShapeStarted
Definition VSDXMLParserBase.h:57
libvisio::VSDXMLParserBase::readForeignData
void readForeignData(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1720
libvisio::VSDXMLParserBase::m_isInStyles
bool m_isInStyles
Definition VSDXMLParserBase.h:48
libvisio::VSDXMLParserBase::m_currentStencilID
unsigned m_currentStencilID
Definition VSDXMLParserBase.h:45
libvisio::VSDXMLParserBase::readStringData
virtual xmlChar * readStringData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::skipMasters
void skipMasters(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1951
libvisio::VSDXMLParserBase::readLineTo
void readLineTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:221
libvisio::VSDXMLParserBase::m_shape
VSDShape m_shape
Definition VSDXMLParserBase.h:43
libvisio::VSDXMLParserBase::readCharIX
void readCharIX(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1186
libvisio::VSDXMLParserBase::readRelEllipticalArcTo
void readRelEllipticalArcTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:640
libvisio::VSDXMLParserBase::handlePagesEnd
void handlePagesEnd(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1871
libvisio::VSDXMLParserBase::readBoolData
int readBoolData(std::optional< bool > &value, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2157
libvisio::VSDXMLParserBase::readShape
void readShape(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:930
libvisio::VSDXMLParserBase::readMoveTo
void readMoveTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:171
libvisio::VSDXMLParserBase::getIX
unsigned getIX(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2270
libvisio::VSDXMLParserBase::m_isPageStarted
bool m_isPageStarted
Definition VSDXMLParserBase.h:58
libvisio::VSDXMLParserBase::handlePageEnd
void handlePageEnd(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1885
libvisio::VSDXMLParserBase::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition VSDXMLParserBase.h:59
libvisio::VSDXMLParserBase::readRelQuadBezTo
void readRelQuadBezTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:872
libvisio::VSDXMLParserBase::_flushShape
void _flushShape()
Definition VSDXMLParserBase.cpp:1758
libvisio::VSDXMLParserBase::skipPages
void skipPages(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1965
libvisio::VSDXMLParserBase::readExtendedColourData
int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2196
libvisio::VSDXMLParserBase::readSplineStart
void readSplineStart(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1587
libvisio::VSDXMLParserBase::readEllipticalArcTo
void readEllipticalArcTo(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:325
libvisio::VSDXMLParserBase::readLayerIX
void readLayerIX(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1368
libvisio::VSDXMLParserBase::m_fieldList
VSDFieldList m_fieldList
Definition VSDXMLParserBase.h:52
libvisio::VSDXMLParserBase::readInfiniteLine
void readInfiniteLine(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:582
libvisio::VSDXMLParserBase::m_watcher
XMLErrorWatcher * m_watcher
Definition VSDXMLParserBase.h:66
libvisio::VSDXMLParserBase::m_colours
std::map< unsigned, Colour > m_colours
Definition VSDXMLParserBase.h:51
libvisio::VSDXMLParserBase::readPolylineData
int readPolylineData(std::optional< PolylineData > &data, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2032
libvisio::VSDXMLParserBase::readPage
void readPage(xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:1073
libvisio::VSDXMLParserBase::VSDXMLParserBase
VSDXMLParserBase()
Definition VSDXMLParserBase.cpp:29
libvisio::VSDXMLParserBase::readLongData
int readLongData(std::optional< long > &value, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2131
libvisio::VSDXMLParserBase::m_shapeStack
std::stack< VSDShape > m_shapeStack
Definition VSDXMLParserBase.h:55
libvisio::XMLErrorWatcher
Definition libvisio_xml.h:25
libvisio
Definition libvisio_utils.h:47
libvisio::Colour
Definition VSDTypes.h:71