MSPUBParser2k.h Source File documentation

MSPUBParser2k.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libmspub project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef INCLUDED_MSPUBPARSER2K_H
11 #define INCLUDED_MSPUBPARSER2K_H
12
13 #include <deque>
14 #include <vector>
15 #include <map>
16
17 #include "MSPUBParser.h"
18 #include "ShapeType.h"
19
20 namespace libmspub
21 {
22
23 class MSPUBParser2k : public MSPUBParser
24 {
25 static ShapeType getShapeType(unsigned char shapeSpecifier);
26 std::vector<unsigned> m_imageDataChunkIndices;
27 std::vector<unsigned> m_quillColorEntries;
28 std::map<unsigned, std::vector<unsigned> > m_chunkChildIndicesById;
29 std::deque<unsigned> m_chunksBeingRead;
30
31 protected:
32 // helper functions
33 bool parse2kShapeChunk(const ContentChunkReference &chunk, librevenge::RVNGInputStream *input,
34 boost::optional<unsigned> pageSeqNum = boost::optional<unsigned>(),
35 bool topLevelCall = true);
36 void parseShapeLine(librevenge::RVNGInputStream *input, bool isRectangle, unsigned offset, unsigned seqNum);
37 void parseShapeType(librevenge::RVNGInputStream *input,
38 unsigned seqNum, unsigned chunkOffset,
39 bool &isGroup, bool &isLine, bool &isImage, bool &isRectangle,
40 unsigned &flagsOffset);
41 void parseShapeRotation(librevenge::RVNGInputStream *input, bool isGroup, bool isLine, unsigned seqNum,
42 unsigned chunkOffset);
43 void parseShapeFlips(librevenge::RVNGInputStream *input, unsigned flagsOffset, unsigned seqNum,
44 unsigned chunkOffset);
45 void parseShapeCoordinates(librevenge::RVNGInputStream *input, unsigned seqNum, unsigned chunkOffset);
46 bool parseGroup(librevenge::RVNGInputStream *input, unsigned seqNum, unsigned page);
47 void assignShapeImgIndex(unsigned seqNum);
48 void parseShapeFill(librevenge::RVNGInputStream *input, unsigned seqNum, unsigned chunkOffset);
49 bool parseContents(librevenge::RVNGInputStream *input) override;
50 virtual bool parseDocument(librevenge::RVNGInputStream *input);
51 unsigned getColorIndexByQuillEntry(unsigned entry) override;
52 virtual int translateCoordinateIfNecessary(int coordinate) const;
53 virtual unsigned getFirstLineOffset() const;
54 virtual unsigned getSecondLineOffset() const;
55 virtual unsigned getShapeFillTypeOffset() const;
56 virtual unsigned getShapeFillColorOffset() const;
57 virtual unsigned short getTextMarker() const;
58 virtual unsigned getTextIdOffset() const;
59 static Color getColorBy2kIndex(unsigned char index);
60 static Color getColorBy2kHex(unsigned hex);
61 static unsigned translate2kColorReference(unsigned ref2k);
62 static PageType getPageTypeBySeqNum(unsigned seqNum);
63 virtual void parseContentsTextIfNecessary(librevenge::RVNGInputStream *input);
64 public:
65 explicit MSPUBParser2k(librevenge::RVNGInputStream *input, MSPUBCollector *collector);
66 bool parse() override;
67 ~MSPUBParser2k() override;
68 };
69
70 } // namespace libmspub
71
72 #endif // INCLUDED_MSPUBPARSER2K_H
73
74 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libmspub::MSPUBParser2k::parseShapeFill
void parseShapeFill(librevenge::RVNGInputStream *input, unsigned seqNum, unsigned chunkOffset)
Definition: MSPUBParser2k.cpp:582
libmspub::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libmspub_utils.cpp:292
libmspub::MSPUBParser::parseQuill
bool parseQuill(librevenge::RVNGInputStream *input)
Definition: MSPUBParser.cpp:976
libmspub::Color::r
unsigned char r
Definition: MSPUBTypes.h:203
libmspub::SEAL_24
@ SEAL_24
Definition: ShapeType.h:82
libmspub::MSPUBParser2k::getColorBy2kIndex
static Color getColorBy2kIndex(unsigned char index)
Definition: MSPUBParser2k.cpp:109
libmspub::MSPUBParser2k::translate2kColorReference
static unsigned translate2kColorReference(unsigned ref2k)
Definition: MSPUBParser2k.cpp:231
libmspub::MSPUBParser::m_collector
MSPUBCollector * m_collector
Definition: MSPUBParser.h:150
libmspub::readS32
int32_t readS32(librevenge::RVNGInputStream *input)
Definition: libmspub_utils.cpp:311
MSPUB_DEBUG_MSG
#define MSPUB_DEBUG_MSG(M)
Definition: libmspub_utils.h:55
libmspub::stillReading
bool stillReading(librevenge::RVNGInputStream *input, unsigned long until)
Definition: libmspub_utils.cpp:416
libmspub::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libmspub_utils.cpp:266
libmspub::Color::g
unsigned char g
Definition: MSPUBTypes.h:203
libmspub::MSPUBParser2k::getShapeFillTypeOffset
virtual unsigned getShapeFillTypeOffset() const
Definition: MSPUBParser2k.cpp:572
libmspub::U_TURN_ARROW
@ U_TURN_ARROW
Definition: ShapeType.h:91
libmspub
Definition: Arrow.h:14
libmspub::MSPUBParser2k::~MSPUBParser2k
~MSPUBParser2k() override
Definition: MSPUBParser2k.cpp:73
libmspub::MSPUBParser2k::getTextMarker
virtual unsigned short getTextMarker() const
Definition: MSPUBParser2k.cpp:720
libmspub::Line
Definition: Line.h:21
libmspub::ELLIPSE
@ ELLIPSE
Definition: ShapeType.h:21
libmspub::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libmspub_utils.cpp:285
libmspub::MSPUBParser2k::parseShapeCoordinates
void parseShapeCoordinates(librevenge::RVNGInputStream *input, unsigned seqNum, unsigned chunkOffset)
Definition: MSPUBParser2k.cpp:634
libmspub::MSPUBParser2k::parse2kShapeChunk
bool parse2kShapeChunk(const ContentChunkReference &chunk, librevenge::RVNGInputStream *input, boost::optional< unsigned > pageSeqNum=boost::optional< unsigned >(), bool topLevelCall=true)
Definition: MSPUBParser2k.cpp:506
libmspub::DOCUMENT
@ DOCUMENT
Definition: MSPUBContentChunkType.h:20
libmspub::MSPUBCollector
Definition: MSPUBCollector.h:45
libmspub::MSPUBCollector::setShapeFill
void setShapeFill(unsigned seqNum, std::shared_ptr< Fill > fill, bool skipIfNotBg)
Definition: MSPUBCollector.cpp:1519
MSPUBParser2k.h
libmspub::MSPUBParser2k::assignShapeImgIndex
void assignShapeImgIndex(unsigned seqNum)
Definition: MSPUBParser2k.cpp:617
libmspub::MSPUBParser2k::parseShapeFlips
void parseShapeFlips(librevenge::RVNGInputStream *input, unsigned flagsOffset, unsigned seqNum, unsigned chunkOffset)
Definition: MSPUBParser2k.cpp:650
libmspub::PARALLELOGRAM
@ PARALLELOGRAM
Definition: ShapeType.h:25
libmspub_utils.h
libmspub::IMAGE_2K_DATA
@ IMAGE_2K_DATA
Definition: MSPUBContentChunkType.h:30
libmspub::SEAL_16
@ SEAL_16
Definition: ShapeType.h:59
libmspub::MSPUBParser2k::MSPUBParser2k
MSPUBParser2k(librevenge::RVNGInputStream *input, MSPUBCollector *collector)
Definition: MSPUBParser2k.cpp:51
libmspub::MSPUBParser::m_shapeChunkIndices
std::vector< unsigned > m_shapeChunkIndices
Definition: MSPUBParser.h:155
libmspub::MSPUBCollector::setShapeRotation
void setShapeRotation(unsigned seqNum, double rotation)
Definition: MSPUBCollector.cpp:1461
ColorReference.h
libmspub::MSPUBParser2k::getShapeType
static ShapeType getShapeType(unsigned char shapeSpecifier)
Definition: MSPUBParser2k.cpp:247
libmspub::PALETTE
@ PALETTE
Definition: MSPUBContentChunkType.h:22
libmspub::RECTANGLE
@ RECTANGLE
Definition: ShapeType.h:19
libmspub::MSPUBCollector::addTextShape
void addTextShape(unsigned stringId, unsigned seqNum)
Definition: MSPUBCollector.cpp:1503
libmspub::GROUP
@ GROUP
Definition: MSPUBContentChunkType.h:24
libmspub::TRAPEZOID
@ TRAPEZOID
Definition: ShapeType.h:26
libmspub::MSPUBParser::m_input
librevenge::RVNGInputStream * m_input
Definition: MSPUBParser.h:148
libmspub::SolidFill
Definition: Fill.h:64
libmspub::IRREGULAR_SEAL_1
@ IRREGULAR_SEAL_1
Definition: ShapeType.h:68
libmspub::UP_DOWN_ARROW
@ UP_DOWN_ARROW
Definition: ShapeType.h:67
libmspub::MSPUBParser2k::getTextIdOffset
virtual unsigned getTextIdOffset() const
Definition: MSPUBParser2k.cpp:715
libmspub::PLUS
@ PLUS
Definition: ShapeType.h:29
libmspub::MASTER
@ MASTER
Definition: MSPUBTypes.h:208
MSPUBCollector.h
libmspub::HEART
@ HEART
Definition: ShapeType.h:71
libmspub::MSPUBParser2k::parseGroup
bool parseGroup(librevenge::RVNGInputStream *input, unsigned seqNum, unsigned page)
Definition: MSPUBParser2k.cpp:595
libmspub::translateLineWidth
unsigned short translateLineWidth(unsigned char lineWidth)
Definition: MSPUBParser2k.cpp:78
libmspub::PageType
PageType
Definition: MSPUBTypes.h:207
libmspub::UNKNOWN_SHAPE
@ UNKNOWN_SHAPE
Definition: ShapeType.h:17
libmspub::BENT_ARROW
@ BENT_ARROW
Definition: ShapeType.h:81
libmspub::MSPUBParser2k::parseShapeLine
void parseShapeLine(librevenge::RVNGInputStream *input, bool isRectangle, unsigned offset, unsigned seqNum)
Definition: MSPUBParser2k.cpp:735
libmspub::PENTAGON
@ PENTAGON
Definition: ShapeType.h:56
libmspub::MSPUBParser::m_unknownChunkIndices
std::vector< unsigned > m_unknownChunkIndices
Definition: MSPUBParser.h:159
libmspub::NORMAL
@ NORMAL
Definition: MSPUBTypes.h:209
libmspub::ContentChunkReference::offset
unsigned long offset
Definition: MSPUBTypes.h:96
libmspub::MSPUBParser2k::getFirstLineOffset
virtual unsigned getFirstLineOffset() const
Definition: MSPUBParser2k.cpp:725
libmspub::MSPUBCollector::addPage
bool addPage(unsigned seqNum)
Definition: MSPUBCollector.cpp:1492
libmspub::UNKNOWN_CHUNK
@ UNKNOWN_CHUNK
Definition: MSPUBContentChunkType.h:17
Line.h
libmspub::MSPUBParser2k::m_chunkChildIndicesById
std::map< unsigned, std::vector< unsigned > > m_chunkChildIndicesById
Definition: MSPUBParser2k.h:28
libmspub::MSPUBParser::m_paletteChunkIndices
std::vector< unsigned > m_paletteChunkIndices
Definition: MSPUBParser.h:156
libmspub::MSPUBParser2k::getPageTypeBySeqNum
static PageType getPageTypeBySeqNum(unsigned seqNum)
Definition: MSPUBParser2k.cpp:800
libmspub::MSPUBCollector::setCurrentGroupSeqNum
bool setCurrentGroupSeqNum(unsigned seqNum)
Definition: MSPUBCollector.cpp:590
libmspub::MSPUBCollector::hasPage
bool hasPage(unsigned seqNum) const
Definition: MSPUBCollector.cpp:575
libmspub::MSPUBCollector::addTextColor
void addTextColor(ColorReference c)
Definition: MSPUBCollector.cpp:1974
libmspub::MSPUBParser2k::getSecondLineOffset
virtual unsigned getSecondLineOffset() const
Definition: MSPUBParser2k.cpp:730
libmspub::MSPUBParser2k::parseShapeRotation
void parseShapeRotation(librevenge::RVNGInputStream *input, bool isGroup, bool isLine, unsigned seqNum, unsigned chunkOffset)
Definition: MSPUBParser2k.cpp:490
libmspub::MSPUBParser2k::parse
bool parse() override
Definition: MSPUBParser2k.cpp:773
libmspub::MSPUBCollector::setShapeCoordinatesInEmu
void setShapeCoordinatesInEmu(unsigned seqNum, int xs, int ys, int xe, int ye)
Definition: MSPUBCollector.cpp:1528
libmspub::MSPUBParser2k::m_imageDataChunkIndices
std::vector< unsigned > m_imageDataChunkIndices
Definition: MSPUBParser2k.h:26
libmspub::MSPUBParser
Definition: MSPUBParser.h:66
libmspub::DIAMOND
@ DIAMOND
Definition: ShapeType.h:22
libmspub::WMF
@ WMF
Definition: MSPUBTypes.h:218
libmspub::MSPUBParser2k::m_chunksBeingRead
std::deque< unsigned > m_chunksBeingRead
Definition: MSPUBParser2k.h:29
libmspub::MSPUBParser2k::m_quillColorEntries
std::vector< unsigned > m_quillColorEntries
Definition: MSPUBParser2k.h:27
libmspub::MSPUBCollector::setShapeImgIndex
void setShapeImgIndex(unsigned seqNum, unsigned index)
Definition: MSPUBCollector.cpp:1508
libmspub::BLOCK_ARC
@ BLOCK_ARC
Definition: ShapeType.h:85
libmspub::SHAPE
@ SHAPE
Definition: MSPUBContentChunkType.h:18
libmspub::MSPUBCollector::setShapePage
void setShapePage(unsigned seqNum, unsigned pageSeqNum)
Definition: MSPUBCollector.cpp:1968
libmspub::IRREGULAR_SEAL_2
@ IRREGULAR_SEAL_2
Definition: ShapeType.h:69
libmspub::MSPUBParser2k::getShapeFillColorOffset
virtual unsigned getShapeFillColorOffset() const
Definition: MSPUBParser2k.cpp:577
libmspub::MSPUBCollector::go
bool go()
Definition: MSPUBCollector.cpp:1832
libmspub::MSPUBParser2k
Definition: MSPUBParser2k.h:24
libmspub::LINE
@ LINE
Definition: ShapeType.h:36
libmspub::INSIDE_SHAPE
@ INSIDE_SHAPE
Definition: MSPUBTypes.h:28
libmspub::MSPUBParser2k::getColorIndexByQuillEntry
unsigned getColorIndexByQuillEntry(unsigned entry) override
Definition: MSPUBParser2k.cpp:60
libmspub::MSPUBParser::m_documentChunkIndex
boost::optional< unsigned > m_documentChunkIndex
Definition: MSPUBParser.h:160
libmspub::MSPUBCollector::setShapeBorderPosition
void setShapeBorderPosition(unsigned seqNum, BorderPosition pos)
Definition: MSPUBCollector.cpp:570
Fill.h
libmspub::ContentChunkReference::seqNum
unsigned seqNum
Definition: MSPUBTypes.h:98
libmspub::IMAGE_2K
@ IMAGE_2K
Definition: MSPUBContentChunkType.h:29
libmspub::HEXAGON
@ HEXAGON
Definition: ShapeType.h:27
libmspub::LIGHTNING_BOLT
@ LIGHTNING_BOLT
Definition: ShapeType.h:70
libmspub::MSPUBCollector::beginGroup
void beginGroup()
Definition: MSPUBCollector.cpp:545
libmspub::MSPUBParser::m_pageChunkIndices
std::vector< unsigned > m_pageChunkIndices
Definition: MSPUBParser.h:154
libmspub::MSPUBParser2k::translateCoordinateIfNecessary
virtual int translateCoordinateIfNecessary(int coordinate) const
Definition: MSPUBParser2k.cpp:645
libmspub::ShapeType
ShapeType
Definition: ShapeType.h:16
libmspub::MSPUBParser2k::parseContents
bool parseContents(librevenge::RVNGInputStream *input) override
Definition: MSPUBParser2k.cpp:347
libmspub::DUMMY_PAGE
@ DUMMY_PAGE
Definition: MSPUBTypes.h:210
libmspub::Color
Definition: MSPUBTypes.h:200
libmspub::ColorReference
Definition: ColorReference.h:20
MSPUBParser.h
libmspub::MSPUBCollector::setShapeOrder
void setShapeOrder(unsigned seqNum)
Definition: MSPUBCollector.cpp:601
POINTS_IN_INCH
#define POINTS_IN_INCH
Definition: MSPUBConstants.h:14
libmspub::MSPUBParser2k::getColorBy2kHex
static Color getColorBy2kHex(unsigned hex)
Definition: MSPUBParser2k.cpp:94
libmspub::MSPUBCollector::addPaletteColor
void addPaletteColor(Color)
Definition: MSPUBCollector.cpp:610
libmspub::CUBE
@ CUBE
Definition: ShapeType.h:33
m_chunks
std::deque< unsigned > & m_chunks
Definition: MSPUBParser2k.cpp:46
libmspub::MSPUBCollector::setShapeType
void setShapeType(unsigned seqNum, ShapeType type)
Definition: MSPUBCollector.cpp:1472
libmspub::MSPUBCollector::endGroup
bool endGroup()
Definition: MSPUBCollector.cpp:555
libmspub::WAVE
@ WAVE
Definition: ShapeType.h:61
libmspub::MSPUBParser2k::parseDocument
virtual bool parseDocument(librevenge::RVNGInputStream *input)
Definition: MSPUBParser2k.cpp:475
libmspub::RIGHT_TRIANGLE
@ RIGHT_TRIANGLE
Definition: ShapeType.h:24
libmspub::MSPUBParser2k::parseContentsTextIfNecessary
virtual void parseContentsTextIfNecessary(librevenge::RVNGInputStream *input)
Definition: MSPUBParser2k.cpp:343
libmspub::MSPUBParser::m_lastAddedImage
unsigned m_lastAddedImage
Definition: MSPUBParser.h:162
libmspub::MSPUBCollector::addShapeLine
void addShapeLine(unsigned seqNum, Line line)
Definition: MSPUBCollector.cpp:565
libmspub::UP_ARROW
@ UP_ARROW
Definition: ShapeType.h:65
libmspub::Color::b
unsigned char b
Definition: MSPUBTypes.h:203
libmspub::MSPUBCollector::addImage
bool addImage(unsigned index, ImgType type, librevenge::RVNGBinaryData img)
Definition: MSPUBCollector.cpp:1914
libmspub::MSPUBCollector::setWidthInEmu
void setWidthInEmu(unsigned long)
Definition: MSPUBCollector.cpp:1900
libmspub::ContentChunkReference::type
unsigned type
Definition: MSPUBTypes.h:95
libmspub::ISOCELES_TRIANGLE
@ ISOCELES_TRIANGLE
Definition: ShapeType.h:23
libmspub::STAR
@ STAR
Definition: ShapeType.h:30
libmspub::MSPUBCollector::setHeightInEmu
void setHeightInEmu(unsigned long)
Definition: MSPUBCollector.cpp:1907
libmspub::MSPUBParser::m_contentChunks
std::vector< ContentChunkReference > m_contentChunks
Definition: MSPUBParser.h:152
libmspub::CHEVRON
@ CHEVRON
Definition: ShapeType.h:55
libmspub::ContentChunkReference::parentSeqNum
unsigned parentSeqNum
Definition: MSPUBTypes.h:99
libmspub::ContentChunkReference
Definition: MSPUBTypes.h:91
libmspub::MSPUBParser2k::parseShapeType
void parseShapeType(librevenge::RVNGInputStream *input, unsigned seqNum, unsigned chunkOffset, bool &isGroup, bool &isLine, bool &isImage, bool &isRectangle, unsigned &flagsOffset)
Definition: MSPUBParser2k.cpp:663
ShapeType.h
libmspub::HOME_PLATE
@ HOME_PLATE
Definition: ShapeType.h:32
EMUS_IN_INCH
#define EMUS_IN_INCH
Definition: MSPUBConstants.h:13
libmspub::OCTAGON
@ OCTAGON
Definition: ShapeType.h:28
libmspub::MSPUBCollector::setShapeFlip
void setShapeFlip(unsigned, bool, bool)
Definition: MSPUBCollector.cpp:1467
libmspub::PAGE
@ PAGE
Definition: MSPUBContentChunkType.h:21