MSPUBParser.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 libmspub 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 INCLUDED_MSPUBPARSER_H
#define INCLUDED_MSPUBPARSER_H
#include <map>
#include <memory>
#include <memory>
#include <set>
#include <vector>
#include <boost/optional.hpp>
#include <librevenge/librevenge.h>
#include "MSPUBTypes.h"
#include "PolygonUtils.h"
namespace libmspub
{
class Fill;
class MSPUBCollector;
struct Coordinate;
class FindBySeqNum
{
unsigned seqNum;
public:
FindBySeqNum(unsigned sn) : seqNum(sn) { }
bool operator()(const libmspub::ContentChunkReference &ref)
{
return ref.seqNum == seqNum;
}
};
class FindByParentSeqNum
{
unsigned seqNum;
public:
FindByParentSeqNum(unsigned sn) : seqNum(sn) { }
bool operator()(const libmspub::ContentChunkReference &ref)
{
return ref.parentSeqNum == seqNum;
}
};
struct FOPTValues
{
std::map<unsigned short, unsigned> m_scalarValues;
std::map<unsigned short, std::vector<unsigned char> > m_complexValues;
FOPTValues() : m_scalarValues(), m_complexValues()
{
}
};
class MSPUBParser
{
public:
explicit MSPUBParser(librevenge::RVNGInputStream *input, MSPUBCollector *collector);
virtual ~MSPUBParser();
virtual bool parse();
protected:
virtual unsigned getColorIndexByQuillEntry(unsigned entry);
struct TextSpanReference
{
TextSpanReference(unsigned short f, unsigned short l, const CharacterStyle &cs) : first(f), last(l), charStyle(cs) { }
unsigned short first;
unsigned short last;
CharacterStyle charStyle;
};
struct TextParagraphReference
{
TextParagraphReference(unsigned short f, unsigned short l, const ParagraphStyle &ps) : first(f), last(l), paraStyle(ps) { }
unsigned short first;
unsigned short last;
ParagraphStyle paraStyle;
};
typedef std::vector<ContentChunkReference>::const_iterator ccr_iterator_t;
MSPUBParser();
MSPUBParser(const MSPUBParser &);
MSPUBParser &operator=(const MSPUBParser &);
virtual bool parseContents(librevenge::RVNGInputStream *input);
bool parseMetaData();
bool parseQuill(librevenge::RVNGInputStream *input);
bool parseEscher(librevenge::RVNGInputStream *input);
bool parseEscherDelay(librevenge::RVNGInputStream *input);
MSPUBBlockInfo parseBlock(librevenge::RVNGInputStream *input, bool skipHierarchicalData = false);
EscherContainerInfo parseEscherContainer(librevenge::RVNGInputStream *input);
bool parseContentChunkReference(librevenge::RVNGInputStream *input, MSPUBBlockInfo block);
QuillChunkReference parseQuillChunkReference(librevenge::RVNGInputStream *input);
bool parseDocumentChunk(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk);
bool parsePageChunk(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk);
bool parsePaletteChunk(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk);
bool parsePageShapeList(librevenge::RVNGInputStream *input, MSPUBBlockInfo block, unsigned pageSeqNum);
bool parseShape(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk);
bool parseBorderArtChunk(librevenge::RVNGInputStream *input,
const ContentChunkReference &chunk);
bool parseFontChunk(librevenge::RVNGInputStream *input,
const ContentChunkReference &chunk);
void parsePaletteEntry(librevenge::RVNGInputStream *input, MSPUBBlockInfo block);
void parseColors(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk);
void parseFonts(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk);
void parseDefaultStyle(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk);
void parseShapeGroup(librevenge::RVNGInputStream *input, const EscherContainerInfo &spgr, Coordinate parentCoordinateSystem, Coordinate parentGroupAbsoluteCoord, unsigned depth = 0);
void skipBlock(librevenge::RVNGInputStream *input, MSPUBBlockInfo block);
void parseEscherShape(librevenge::RVNGInputStream *input, const EscherContainerInfo &sp, Coordinate &parentCoordinateSystem, Coordinate &parentGroupAbsoluteCoord);
bool findEscherContainer(librevenge::RVNGInputStream *input, const EscherContainerInfo &parent, EscherContainerInfo &out, unsigned short type);
bool findEscherContainerWithTypeInSet(librevenge::RVNGInputStream *input, const EscherContainerInfo &parent, EscherContainerInfo &out, std::set<unsigned short> types);
std::map<unsigned short, unsigned> extractEscherValues(librevenge::RVNGInputStream *input, const EscherContainerInfo &record);
FOPTValues extractFOPTValues(librevenge::RVNGInputStream *input,
const libmspub::EscherContainerInfo &record);
std::vector<TextSpanReference> parseCharacterStyles(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk);
std::vector<TextParagraphReference> parseParagraphStyles(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk);
std::vector<Calculation> parseGuides(const std::vector<unsigned char>
&guideData);
std::vector<Vertex> parseVertices(const std::vector<unsigned char>
&vertexData);
std::vector<unsigned> parseTableCellDefinitions(librevenge::RVNGInputStream *input,
const QuillChunkReference &chunk);
std::vector<unsigned short> parseSegments(
const std::vector<unsigned char> &segmentData);
DynamicCustomShape getDynamicCustomShape(
const std::vector<unsigned char> &vertexData,
const std::vector<unsigned char> &segmentData,
const std::vector<unsigned char> &guideData,
unsigned geoWidth, unsigned geoHeight);
int getColorIndex(librevenge::RVNGInputStream *input, const MSPUBBlockInfo &info);
unsigned getFontIndex(librevenge::RVNGInputStream *input, const MSPUBBlockInfo &info);
CharacterStyle getCharacterStyle(librevenge::RVNGInputStream *input);
ParagraphStyle getParagraphStyle(librevenge::RVNGInputStream *input);
std::shared_ptr<Fill> getNewFill(const std::map<unsigned short, unsigned> &foptProperties, bool &skipIfNotBg, std::map<unsigned short, std::vector<unsigned char> > &foptValues);
librevenge::RVNGInputStream *m_input;
unsigned m_length;
MSPUBCollector *m_collector;
std::vector<MSPUBBlockInfo> m_blockInfo;
std::vector<ContentChunkReference> m_contentChunks;
std::vector<unsigned> m_cellsChunkIndices;
std::vector<unsigned> m_pageChunkIndices;
std::vector<unsigned> m_shapeChunkIndices;
std::vector<unsigned> m_paletteChunkIndices;
std::vector<unsigned> m_borderArtChunkIndices;
std::vector<unsigned> m_fontChunkIndices;
std::vector<unsigned> m_unknownChunkIndices;
boost::optional<unsigned> m_documentChunkIndex;
int m_lastSeenSeqNum;
unsigned m_lastAddedImage;
std::vector<int> m_alternateShapeSeqNums;
std::vector<int> m_escherDelayIndices;
static short getBlockDataLength(unsigned type);
static bool isBlockDataString(unsigned type);
static PageType getPageTypeBySeqNum(unsigned seqNum);
static unsigned getEscherElementTailLength(unsigned short type);
static unsigned getEscherElementAdditionalHeaderLength(unsigned short type);
static ImgType imgTypeByBlipType(unsigned short type);
static int getStartOffset(ImgType type, unsigned short initial);
static bool lineExistsByFlagPointer(unsigned *flags,
unsigned *geomFlags = nullptr);
};
} // namespace libmspub
#endif // INCLUDED_MSPUBRAPHICS_H
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
MSPUBTypes.h
PolygonUtils.h
libmspub::Fill
Definition Fill.h:23
libmspub::FindByParentSeqNum::FindByParentSeqNum
FindByParentSeqNum(unsigned sn)
Definition MSPUBParser.h:49
libmspub::FindByParentSeqNum::operator()
bool operator()(const libmspub::ContentChunkReference &ref)
Definition MSPUBParser.h:50
libmspub::FindByParentSeqNum::seqNum
unsigned seqNum
Definition MSPUBParser.h:47
libmspub::FindBySeqNum::FindBySeqNum
FindBySeqNum(unsigned sn)
Definition MSPUBParser.h:38
libmspub::FindBySeqNum::seqNum
unsigned seqNum
Definition MSPUBParser.h:36
libmspub::FindBySeqNum::operator()
bool operator()(const libmspub::ContentChunkReference &ref)
Definition MSPUBParser.h:39
libmspub::MSPUBCollector
Definition MSPUBCollector.h:45
libmspub::MSPUBParser::parseDefaultStyle
void parseDefaultStyle(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk)
Definition MSPUBParser.cpp:1177
libmspub::MSPUBParser::~MSPUBParser
virtual ~MSPUBParser()
Definition MSPUBParser.cpp:123
libmspub::MSPUBParser::parseCharacterStyles
std::vector< TextSpanReference > parseCharacterStyles(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk)
Definition MSPUBParser.cpp:1252
libmspub::MSPUBParser::parseColors
void parseColors(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk)
Definition MSPUBParser.cpp:1205
libmspub::MSPUBParser::m_length
unsigned m_length
Definition MSPUBParser.h:149
libmspub::MSPUBParser::m_lastAddedImage
unsigned m_lastAddedImage
Definition MSPUBParser.h:162
libmspub::MSPUBParser::parseContents
virtual bool parseContents(librevenge::RVNGInputStream *input)
Definition MSPUBParser.cpp:379
libmspub::MSPUBParser::parseVertices
std::vector< Vertex > parseVertices(const std::vector< unsigned char > &vertexData)
Definition MSPUBParser.cpp:2228
libmspub::MSPUBParser::parseEscherContainer
EscherContainerInfo parseEscherContainer(librevenge::RVNGInputStream *input)
Definition MSPUBParser.cpp:2503
libmspub::MSPUBParser::lineExistsByFlagPointer
static bool lineExistsByFlagPointer(unsigned *flags, unsigned *geomFlags=nullptr)
Definition MSPUBParser.cpp:127
libmspub::MSPUBParser::parsePaletteChunk
bool parsePaletteChunk(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk)
Definition MSPUBParser.cpp:2579
libmspub::MSPUBParser::parsePageShapeList
bool parsePageShapeList(librevenge::RVNGInputStream *input, MSPUBBlockInfo block, unsigned pageSeqNum)
Definition MSPUBParser.cpp:697
libmspub::MSPUBParser::getEscherElementAdditionalHeaderLength
static unsigned getEscherElementAdditionalHeaderLength(unsigned short type)
Definition MSPUBParser.cpp:2296
libmspub::MSPUBParser::m_alternateShapeSeqNums
std::vector< int > m_alternateShapeSeqNums
Definition MSPUBParser.h:163
libmspub::MSPUBParser::imgTypeByBlipType
static ImgType imgTypeByBlipType(unsigned short type)
Definition MSPUBParser.cpp:234
libmspub::MSPUBParser::parseTableCellDefinitions
std::vector< unsigned > parseTableCellDefinitions(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk)
Definition MSPUBParser.cpp:964
libmspub::MSPUBParser::findEscherContainerWithTypeInSet
bool findEscherContainerWithTypeInSet(librevenge::RVNGInputStream *input, const EscherContainerInfo &parent, EscherContainerInfo &out, std::set< unsigned short > types)
Definition MSPUBParser.cpp:2307
libmspub::MSPUBParser::m_paletteChunkIndices
std::vector< unsigned > m_paletteChunkIndices
Definition MSPUBParser.h:156
libmspub::MSPUBParser::parseEscher
bool parseEscher(librevenge::RVNGInputStream *input)
Definition MSPUBParser.cpp:1542
libmspub::MSPUBParser::getPageTypeBySeqNum
static PageType getPageTypeBySeqNum(unsigned seqNum)
Definition MSPUBParser.cpp:2565
libmspub::MSPUBParser::m_contentChunks
std::vector< ContentChunkReference > m_contentChunks
Definition MSPUBParser.h:152
libmspub::MSPUBParser::parseFontChunk
bool parseFontChunk(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk)
Definition MSPUBParser.cpp:526
libmspub::MSPUBParser::MSPUBParser
MSPUBParser()
libmspub::MSPUBParser::parsePaletteEntry
void parsePaletteEntry(librevenge::RVNGInputStream *input, MSPUBBlockInfo block)
Definition MSPUBParser.cpp:2606
libmspub::MSPUBParser::getStartOffset
static int getStartOffset(ImgType type, unsigned short initial)
Definition MSPUBParser.cpp:258
libmspub::MSPUBParser::m_documentChunkIndex
boost::optional< unsigned > m_documentChunkIndex
Definition MSPUBParser.h:160
libmspub::MSPUBParser::extractEscherValues
std::map< unsigned short, unsigned > extractEscherValues(librevenge::RVNGInputStream *input, const EscherContainerInfo &record)
Definition MSPUBParser.cpp:2383
libmspub::MSPUBParser::extractFOPTValues
FOPTValues extractFOPTValues(librevenge::RVNGInputStream *input, const libmspub::EscherContainerInfo &record)
Definition MSPUBParser.cpp:2338
libmspub::MSPUBParser::parseQuill
bool parseQuill(librevenge::RVNGInputStream *input)
Definition MSPUBParser.cpp:982
libmspub::MSPUBParser::getEscherElementTailLength
static unsigned getEscherElementTailLength(unsigned short type)
Definition MSPUBParser.cpp:2284
libmspub::MSPUBParser::m_lastSeenSeqNum
int m_lastSeenSeqNum
Definition MSPUBParser.h:161
libmspub::MSPUBParser::getBlockDataLength
static short getBlockDataLength(unsigned type)
Definition MSPUBParser.cpp:142
libmspub::MSPUBParser::parseFonts
void parseFonts(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk)
Definition MSPUBParser.cpp:1159
libmspub::MSPUBParser::parseShape
bool parseShape(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk)
Definition MSPUBParser.cpp:711
libmspub::MSPUBParser::getColorIndexByQuillEntry
virtual unsigned getColorIndexByQuillEntry(unsigned entry)
Definition MSPUBParser.cpp:137
libmspub::MSPUBParser::parseMetaData
bool parseMetaData()
Definition MSPUBParser.cpp:2618
libmspub::MSPUBParser::m_blockInfo
std::vector< MSPUBBlockInfo > m_blockInfo
Definition MSPUBParser.h:151
libmspub::MSPUBParser::getFontIndex
unsigned getFontIndex(librevenge::RVNGInputStream *input, const MSPUBBlockInfo &info)
Definition MSPUBParser.cpp:1504
libmspub::MSPUBParser::getParagraphStyle
ParagraphStyle getParagraphStyle(librevenge::RVNGInputStream *input)
Definition MSPUBParser.cpp:1279
libmspub::MSPUBParser::parseContentChunkReference
bool parseContentChunkReference(librevenge::RVNGInputStream *input, MSPUBBlockInfo block)
Definition MSPUBParser.cpp:2403
libmspub::MSPUBParser::operator=
MSPUBParser & operator=(const MSPUBParser &)
libmspub::MSPUBParser::MSPUBParser
MSPUBParser(librevenge::RVNGInputStream *input, MSPUBCollector *collector)
Definition MSPUBParser.cpp:108
libmspub::MSPUBParser::getNewFill
std::shared_ptr< Fill > getNewFill(const std::map< unsigned short, unsigned > &foptProperties, bool &skipIfNotBg, std::map< unsigned short, std::vector< unsigned char > > &foptValues)
Definition MSPUBParser.cpp:2010
libmspub::MSPUBParser::ccr_iterator_t
std::vector< ContentChunkReference >::const_iterator ccr_iterator_t
Definition MSPUBParser.h:90
libmspub::MSPUBParser::parseEscherDelay
bool parseEscherDelay(librevenge::RVNGInputStream *input)
Definition MSPUBParser.cpp:299
libmspub::MSPUBParser::parseGuides
std::vector< Calculation > parseGuides(const std::vector< unsigned char > &guideData)
Definition MSPUBParser.cpp:2218
libmspub::MSPUBParser::parseParagraphStyles
std::vector< TextParagraphReference > parseParagraphStyles(librevenge::RVNGInputStream *input, const QuillChunkReference &chunk)
Definition MSPUBParser.cpp:1224
libmspub::MSPUBParser::parseSegments
std::vector< unsigned short > parseSegments(const std::vector< unsigned char > &segmentData)
Definition MSPUBParser.cpp:2195
libmspub::MSPUBParser::skipBlock
void skipBlock(librevenge::RVNGInputStream *input, MSPUBBlockInfo block)
Definition MSPUBParser.cpp:2498
libmspub::MSPUBParser::m_unknownChunkIndices
std::vector< unsigned > m_unknownChunkIndices
Definition MSPUBParser.h:159
libmspub::MSPUBParser::parse
virtual bool parse()
Definition MSPUBParser.cpp:185
libmspub::MSPUBParser::m_collector
MSPUBCollector * m_collector
Definition MSPUBParser.h:150
libmspub::MSPUBParser::m_input
librevenge::RVNGInputStream * m_input
Definition MSPUBParser.h:148
libmspub::MSPUBParser::parseShapeGroup
void parseShapeGroup(librevenge::RVNGInputStream *input, const EscherContainerInfo &spgr, Coordinate parentCoordinateSystem, Coordinate parentGroupAbsoluteCoord, unsigned depth=0)
Definition MSPUBParser.cpp:1588
libmspub::MSPUBParser::parseBlock
MSPUBBlockInfo parseBlock(librevenge::RVNGInputStream *input, bool skipHierarchicalData=false)
Definition MSPUBParser.cpp:2514
libmspub::MSPUBParser::parseDocumentChunk
bool parseDocumentChunk(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk)
Definition MSPUBParser.cpp:482
libmspub::MSPUBParser::m_pageChunkIndices
std::vector< unsigned > m_pageChunkIndices
Definition MSPUBParser.h:154
libmspub::MSPUBParser::findEscherContainer
bool findEscherContainer(librevenge::RVNGInputStream *input, const EscherContainerInfo &parent, EscherContainerInfo &out, unsigned short type)
Definition MSPUBParser.cpp:2322
libmspub::MSPUBParser::m_cellsChunkIndices
std::vector< unsigned > m_cellsChunkIndices
Definition MSPUBParser.h:153
libmspub::MSPUBParser::m_shapeChunkIndices
std::vector< unsigned > m_shapeChunkIndices
Definition MSPUBParser.h:155
libmspub::MSPUBParser::MSPUBParser
MSPUBParser(const MSPUBParser &)
libmspub::MSPUBParser::m_borderArtChunkIndices
std::vector< unsigned > m_borderArtChunkIndices
Definition MSPUBParser.h:157
libmspub::MSPUBParser::parseQuillChunkReference
QuillChunkReference parseQuillChunkReference(librevenge::RVNGInputStream *input)
Definition MSPUBParser.cpp:939
libmspub::MSPUBParser::getCharacterStyle
CharacterStyle getCharacterStyle(librevenge::RVNGInputStream *input)
Definition MSPUBParser.cpp:1409
libmspub::MSPUBParser::getDynamicCustomShape
DynamicCustomShape getDynamicCustomShape(const std::vector< unsigned char > &vertexData, const std::vector< unsigned char > &segmentData, const std::vector< unsigned char > &guideData, unsigned geoWidth, unsigned geoHeight)
Definition MSPUBParser.cpp:2183
libmspub::MSPUBParser::getColorIndex
int getColorIndex(librevenge::RVNGInputStream *input, const MSPUBBlockInfo &info)
Definition MSPUBParser.cpp:1525
libmspub::MSPUBParser::m_fontChunkIndices
std::vector< unsigned > m_fontChunkIndices
Definition MSPUBParser.h:158
libmspub::MSPUBParser::parseEscherShape
void parseEscherShape(librevenge::RVNGInputStream *input, const EscherContainerInfo &sp, Coordinate &parentCoordinateSystem, Coordinate &parentGroupAbsoluteCoord)
Definition MSPUBParser.cpp:1613
libmspub::MSPUBParser::m_escherDelayIndices
std::vector< int > m_escherDelayIndices
Definition MSPUBParser.h:164
libmspub::MSPUBParser::isBlockDataString
static bool isBlockDataString(unsigned type)
Definition MSPUBParser.cpp:2494
libmspub::MSPUBParser::parseBorderArtChunk
bool parseBorderArtChunk(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk)
Definition MSPUBParser.cpp:591
libmspub::MSPUBParser::parsePageChunk
bool parsePageChunk(librevenge::RVNGInputStream *input, const ContentChunkReference &chunk)
Definition MSPUBParser.cpp:655
libmspub
Definition Arrow.h:14
libmspub::PageType
PageType
Definition MSPUBTypes.h:207
libmspub::ImgType
ImgType
Definition MSPUBTypes.h:214
libmspub::CharacterStyle
Definition MSPUBTypes.h:113
libmspub::ContentChunkReference
Definition MSPUBTypes.h:91
libmspub::ContentChunkReference::parentSeqNum
unsigned parentSeqNum
Definition MSPUBTypes.h:99
libmspub::ContentChunkReference::seqNum
unsigned seqNum
Definition MSPUBTypes.h:98
libmspub::Coordinate
Definition Coordinate.h:22
libmspub::DynamicCustomShape
Definition PolygonUtils.h:91
libmspub::EscherContainerInfo
Definition MSPUBTypes.h:71
libmspub::FOPTValues
Definition MSPUBParser.h:57
libmspub::FOPTValues::m_complexValues
std::map< unsigned short, std::vector< unsigned char > > m_complexValues
Definition MSPUBParser.h:59
libmspub::FOPTValues::FOPTValues
FOPTValues()
Definition MSPUBParser.h:60
libmspub::FOPTValues::m_scalarValues
std::map< unsigned short, unsigned > m_scalarValues
Definition MSPUBParser.h:58
libmspub::MSPUBBlockInfo
Definition MSPUBTypes.h:79
libmspub::MSPUBParser::TextParagraphReference::paraStyle
ParagraphStyle paraStyle
Definition MSPUBParser.h:87
libmspub::MSPUBParser::TextParagraphReference::last
unsigned short last
Definition MSPUBParser.h:86
libmspub::MSPUBParser::TextParagraphReference::first
unsigned short first
Definition MSPUBParser.h:85
libmspub::MSPUBParser::TextParagraphReference::TextParagraphReference
TextParagraphReference(unsigned short f, unsigned short l, const ParagraphStyle &ps)
Definition MSPUBParser.h:84
libmspub::MSPUBParser::TextSpanReference::last
unsigned short last
Definition MSPUBParser.h:78
libmspub::MSPUBParser::TextSpanReference::charStyle
CharacterStyle charStyle
Definition MSPUBParser.h:79
libmspub::MSPUBParser::TextSpanReference::TextSpanReference
TextSpanReference(unsigned short f, unsigned short l, const CharacterStyle &cs)
Definition MSPUBParser.h:76
libmspub::MSPUBParser::TextSpanReference::first
unsigned short first
Definition MSPUBParser.h:77
libmspub::ParagraphStyle
Definition MSPUBTypes.h:164
libmspub::QuillChunkReference
Definition MSPUBTypes.h:103