CMXParser.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 libcdr 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 __CMXPARSER_H__
#define __CMXPARSER_H__
#include <vector>
#include <map>
#include <memory>
#include <librevenge-stream/librevenge-stream.h>
#include "CDRTransforms.h"
#include "CDRTypes.h"
#include "CommonParser.h"
#define CMX_MASTER_INDEX_TABLE 1
#define CMX_PAGE_INDEX_TABLE 2
#define CMX_MASTER_LAYER_TABLE 3
#define CMX_PROCEDURE_INDEX_TABLE 4
#define CMX_BITMAP_INDEX_TABLE 5
#define CMX_ARROW_INDEX_TABLE 6
#define CMX_FONT_INDEX_TABLE 7
#define CMX_EMBEDDED_FILE_INDEX_TABLE 8
#define CMX_THUMBNAIL_SECTION 10
#define CMX_OUTLINE_DESCRIPTION_SECTION 15
#define CMX_LINE_STYLE_DESCRIPTION_SECTION 16
#define CMX_ARROWHEADS_DESCRIPTION_SECTION 17
#define CMX_SCREEN_DESCRIPTION_SECTION 18
#define CMX_PEN_DESCRIPTION_SECTION 19
#define CMX_DOT_DASH_DESCRIPTION_SECTION 20
#define CMX_COLOR_DESCRIPTION_SECTION 21
#define CMX_COLOR_CORRECTION_SECTION 22
#define CMX_PREVIEW_BOX_SECTION 23
namespace libcdr
{
class CDRCollector;
struct CMXOutline
{
CMXOutline()
: m_lineStyle(0), m_screen(0), m_color(0),
m_arrowHeads(0), m_pen(0), m_dashArray(0) {}
unsigned short m_lineStyle;
unsigned short m_screen;
unsigned short m_color;
unsigned short m_arrowHeads;
unsigned short m_pen;
unsigned short m_dashArray;
};
struct CMXPen
{
CMXPen()
: m_width(0.0), m_aspect(1.0), m_angle(0.0), m_matrix() {}
double m_width;
double m_aspect;
double m_angle;
CDRTransform m_matrix;
};
struct CMXLineStyle
{
CMXLineStyle() : m_spec(0), m_capAndJoin(0) {}
unsigned char m_spec;
unsigned char m_capAndJoin;
};
struct CMXImageInfo
{
CMXImageInfo()
: m_type(0), m_compression(0), m_size(0), m_compressedSize(0) {}
unsigned short m_type;
unsigned short m_compression;
unsigned m_size;
unsigned m_compressedSize;
};
struct CMXParserState
{
CMXParserState()
: m_colorPalette(), m_dashArrays(), m_lineStyles(),
m_pens(), m_outlines(), m_bitmapOffsets(), m_patternOffsets(),
m_arrowOffsets(), m_embeddedOffsets(), m_embeddedOffsetTypes() {}
std::map<unsigned, CDRColor> m_colorPalette;
std::map<unsigned, std::vector<unsigned> > m_dashArrays;
std::map<unsigned, CMXLineStyle> m_lineStyles;
std::map<unsigned, CMXPen> m_pens;
std::map<unsigned, CMXOutline> m_outlines;
std::map<unsigned, unsigned> m_bitmapOffsets;
std::map<unsigned, unsigned> m_patternOffsets;
std::map<unsigned, unsigned> m_arrowOffsets;
std::map<unsigned, unsigned> m_embeddedOffsets;
std::map<unsigned, unsigned> m_embeddedOffsetTypes;
};
class CMXParser : protected CommonParser
{
public:
explicit CMXParser(CDRCollector *collector, CMXParserState &parserState);
~CMXParser() override;
bool parseRecords(librevenge::RVNGInputStream *input, long size = -1, unsigned level = 0);
private:
CMXParser();
CMXParser(const CMXParser &);
CMXParser &operator=(const CMXParser &);
bool parseRecord(librevenge::RVNGInputStream *input, unsigned level = 0);
void readRecord(unsigned fourCC, unsigned long length, librevenge::RVNGInputStream *input);
void parseImage(librevenge::RVNGInputStream *input);
void readCMXHeader(librevenge::RVNGInputStream *input);
void readDisp(librevenge::RVNGInputStream *input);
void readPage(librevenge::RVNGInputStream *input);
void readProc(librevenge::RVNGInputStream *input);
void readRclr(librevenge::RVNGInputStream *input);
void readRotl(librevenge::RVNGInputStream *input);
void readRott(librevenge::RVNGInputStream *input);
void readRdot(librevenge::RVNGInputStream *input);
void readRpen(librevenge::RVNGInputStream *input);
void readIxtl(librevenge::RVNGInputStream *input);
void readIxef(librevenge::RVNGInputStream *input);
void readIxmr(librevenge::RVNGInputStream *input);
void readIxpg(librevenge::RVNGInputStream *input);
void readIxpc(librevenge::RVNGInputStream *input);
void readInfo(librevenge::RVNGInputStream *input);
void readData(librevenge::RVNGInputStream *input);
// Command readers
void readCommands(librevenge::RVNGInputStream *input, unsigned length);
void readBeginPage(librevenge::RVNGInputStream *input);
void readBeginLayer(librevenge::RVNGInputStream *input);
void readBeginGroup(librevenge::RVNGInputStream *input);
void readPolyCurve(librevenge::RVNGInputStream *input);
void readEllipse(librevenge::RVNGInputStream *input);
void readRectangle(librevenge::RVNGInputStream *input);
void readJumpAbsolute(librevenge::RVNGInputStream *input);
void readDrawImage(librevenge::RVNGInputStream *input);
void readBeginProcedure(librevenge::RVNGInputStream *input);
// Types readers
CDRTransform readMatrix(librevenge::RVNGInputStream *input);
CDRBox readBBox(librevenge::RVNGInputStream *input);
librevenge::RVNGString readString(librevenge::RVNGInputStream *input);
bool readFill(librevenge::RVNGInputStream *input);
bool readLens(librevenge::RVNGInputStream *input);
// Complex types readers
bool readRenderingAttributes(librevenge::RVNGInputStream *input);
// Helper Functions
CDRColor getPaletteColor(unsigned id);
CDRColor readColor(librevenge::RVNGInputStream *input, unsigned char colorModel);
CDRLineStyle getLineStyle(unsigned id);
const unsigned *_getOffsetByType(unsigned short type, const std::map<unsigned short, unsigned> &offsets);
bool m_bigEndian;
unsigned short m_unit;
double m_scale;
double m_xmin, m_xmax, m_ymin, m_ymax;
unsigned m_fillIndex;
unsigned long m_nextInstructionOffset;
CMXParserState &m_parserState;
CMXImageInfo m_currentImageInfo;
std::unique_ptr<CDRPattern> m_currentPattern;
std::unique_ptr<CDRBitmap> m_currentBitmap;
};
} // namespace libcdr
#endif // __CMXPARSER_H__
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
CDRTransforms.h
CDRTypes.h
CommonParser.h
libcdr::CDRCollector
Definition CDRCollector.h:62
libcdr::CDRTransform
Definition CDRTransforms.h:20
libcdr::CMXParser::m_currentImageInfo
CMXImageInfo m_currentImageInfo
Definition CMXParser.h:172
libcdr::CMXParser::readBeginGroup
void readBeginGroup(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:543
libcdr::CMXParser::readDrawImage
void readDrawImage(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:770
libcdr::CMXParser::readProc
void readProc(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:481
libcdr::CMXParser::operator=
CMXParser & operator=(const CMXParser &)
libcdr::CMXParser::CMXParser
CMXParser(CDRCollector *collector, CMXParserState &parserState)
Definition CMXParser.cpp:73
libcdr::CMXParser::readPage
void readPage(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:471
libcdr::CMXParser::readMatrix
CDRTransform readMatrix(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:967
libcdr::CMXParser::readLens
bool readLens(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1018
libcdr::CMXParser::getPaletteColor
CDRColor getPaletteColor(unsigned id)
Definition CMXParser.cpp:2213
libcdr::CMXParser::_getOffsetByType
const unsigned * _getOffsetByType(unsigned short type, const std::map< unsigned short, unsigned > &offsets)
Definition CMXParser.cpp:340
libcdr::CMXParser::m_nextInstructionOffset
unsigned long m_nextInstructionOffset
Definition CMXParser.h:170
libcdr::CMXParser::readRenderingAttributes
bool readRenderingAttributes(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1477
libcdr::CMXParser::readIxtl
void readIxtl(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1950
libcdr::CMXParser::parseRecords
bool parseRecords(librevenge::RVNGInputStream *input, long size=-1, unsigned level=0)
Definition CMXParser.cpp:84
libcdr::CMXParser::readIxpc
void readIxpc(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:2067
libcdr::CMXParser::m_currentPattern
std::unique_ptr< CDRPattern > m_currentPattern
Definition CMXParser.h:173
libcdr::CMXParser::readBBox
CDRBox readBBox(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:997
libcdr::CMXParser::parseRecord
bool parseRecord(librevenge::RVNGInputStream *input, unsigned level=0)
Definition CMXParser.cpp:102
libcdr::CMXParser::m_ymax
double m_ymax
Definition CMXParser.h:168
libcdr::CMXParser::m_currentBitmap
std::unique_ptr< CDRBitmap > m_currentBitmap
Definition CMXParser.h:174
libcdr::CMXParser::readPolyCurve
void readPolyCurve(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:590
libcdr::CMXParser::m_unit
unsigned short m_unit
Definition CMXParser.h:166
libcdr::CMXParser::readColor
CDRColor readColor(librevenge::RVNGInputStream *input, unsigned char colorModel)
Definition CMXParser.cpp:2221
libcdr::CMXParser::readRclr
void readRclr(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1684
libcdr::CMXParser::readIxef
void readIxef(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1995
libcdr::CMXParser::CMXParser
CMXParser(const CMXParser &)
libcdr::CMXParser::parseImage
void parseImage(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:154
libcdr::CMXParser::readFill
bool readFill(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1062
libcdr::CMXParser::readCommands
void readCommands(librevenge::RVNGInputStream *input, unsigned length)
Definition CMXParser.cpp:417
libcdr::CMXParser::m_xmin
double m_xmin
Definition CMXParser.h:168
libcdr::CMXParser::m_fillIndex
unsigned m_fillIndex
Definition CMXParser.h:169
libcdr::CMXParser::readCMXHeader
void readCMXHeader(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:215
libcdr::CMXParser::readRotl
void readRotl(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1839
libcdr::CMXParser::readBeginLayer
void readBeginLayer(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:540
libcdr::CMXParser::readEllipse
void readEllipse(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:665
libcdr::CMXParser::m_ymin
double m_ymin
Definition CMXParser.h:168
libcdr::CMXParser::m_parserState
CMXParserState & m_parserState
Definition CMXParser.h:171
libcdr::CMXParser::readBeginPage
void readBeginPage(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:491
libcdr::CMXParser::m_xmax
double m_xmax
Definition CMXParser.h:168
libcdr::CMXParser::~CMXParser
~CMXParser() override
Definition CMXParser.cpp:80
libcdr::CMXParser::readRdot
void readRdot(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1735
libcdr::CMXParser::readString
librevenge::RVNGString readString(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1007
libcdr::CMXParser::getLineStyle
CDRLineStyle getLineStyle(unsigned id)
Definition CMXParser.cpp:2340
libcdr::CMXParser::CMXParser
CMXParser()
libcdr::CMXParser::readBeginProcedure
void readBeginProcedure(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:920
libcdr::CMXParser::readRott
void readRott(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1790
libcdr::CMXParser::readDisp
void readDisp(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:291
libcdr::CMXParser::readInfo
void readInfo(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:2104
libcdr::CMXParser::m_bigEndian
bool m_bigEndian
Definition CMXParser.h:165
libcdr::CMXParser::readJumpAbsolute
void readJumpAbsolute(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1650
libcdr::CMXParser::readRecord
void readRecord(unsigned fourCC, unsigned long length, librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:194
libcdr::CMXParser::m_scale
double m_scale
Definition CMXParser.h:167
libcdr::CMXParser::readRectangle
void readRectangle(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:831
libcdr::CMXParser::readRpen
void readRpen(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:1896
libcdr::CMXParser::readData
void readData(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:2145
libcdr::CMXParser::readIxpg
void readIxpg(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:2032
libcdr::CMXParser::readIxmr
void readIxmr(librevenge::RVNGInputStream *input)
Definition CMXParser.cpp:348
libcdr::CommonParser::CommonParser
CommonParser(CDRCollector *collector)
Definition CommonParser.cpp:18
libcdr
Definition CDRCollector.h:25
libcdr::CDRBox
Definition CDRTypes.h:25
libcdr::CDRColor
Definition CDRTypes.h:54
libcdr::CDRLineStyle
Definition CDRTypes.h:118
libcdr::CMXImageInfo
Definition CMXParser.h:78
libcdr::CMXImageInfo::m_size
unsigned m_size
Definition CMXParser.h:83
libcdr::CMXImageInfo::m_type
unsigned short m_type
Definition CMXParser.h:81
libcdr::CMXImageInfo::m_compressedSize
unsigned m_compressedSize
Definition CMXParser.h:84
libcdr::CMXImageInfo::CMXImageInfo
CMXImageInfo()
Definition CMXParser.h:79
libcdr::CMXImageInfo::m_compression
unsigned short m_compression
Definition CMXParser.h:82
libcdr::CMXLineStyle::m_capAndJoin
unsigned char m_capAndJoin
Definition CMXParser.h:74
libcdr::CMXLineStyle::CMXLineStyle
CMXLineStyle()
Definition CMXParser.h:72
libcdr::CMXLineStyle::m_spec
unsigned char m_spec
Definition CMXParser.h:73
libcdr::CMXOutline::m_screen
unsigned short m_screen
Definition CMXParser.h:53
libcdr::CMXOutline::m_arrowHeads
unsigned short m_arrowHeads
Definition CMXParser.h:55
libcdr::CMXOutline::m_pen
unsigned short m_pen
Definition CMXParser.h:56
libcdr::CMXOutline::m_color
unsigned short m_color
Definition CMXParser.h:54
libcdr::CMXOutline::m_lineStyle
unsigned short m_lineStyle
Definition CMXParser.h:52
libcdr::CMXOutline::m_dashArray
unsigned short m_dashArray
Definition CMXParser.h:57
libcdr::CMXOutline::CMXOutline
CMXOutline()
Definition CMXParser.h:49
libcdr::CMXParserState
Definition CMXParser.h:88
libcdr::CMXParserState::m_pens
std::map< unsigned, CMXPen > m_pens
Definition CMXParser.h:96
libcdr::CMXParserState::CMXParserState
CMXParserState()
Definition CMXParser.h:89
libcdr::CMXParserState::m_embeddedOffsetTypes
std::map< unsigned, unsigned > m_embeddedOffsetTypes
Definition CMXParser.h:102
libcdr::CMXParserState::m_embeddedOffsets
std::map< unsigned, unsigned > m_embeddedOffsets
Definition CMXParser.h:101
libcdr::CMXParserState::m_dashArrays
std::map< unsigned, std::vector< unsigned > > m_dashArrays
Definition CMXParser.h:94
libcdr::CMXParserState::m_colorPalette
std::map< unsigned, CDRColor > m_colorPalette
Definition CMXParser.h:93
libcdr::CMXParserState::m_bitmapOffsets
std::map< unsigned, unsigned > m_bitmapOffsets
Definition CMXParser.h:98
libcdr::CMXParserState::m_outlines
std::map< unsigned, CMXOutline > m_outlines
Definition CMXParser.h:97
libcdr::CMXParserState::m_patternOffsets
std::map< unsigned, unsigned > m_patternOffsets
Definition CMXParser.h:99
libcdr::CMXParserState::m_arrowOffsets
std::map< unsigned, unsigned > m_arrowOffsets
Definition CMXParser.h:100
libcdr::CMXParserState::m_lineStyles
std::map< unsigned, CMXLineStyle > m_lineStyles
Definition CMXParser.h:95
libcdr::CMXPen::m_width
double m_width
Definition CMXParser.h:64
libcdr::CMXPen::CMXPen
CMXPen()
Definition CMXParser.h:62
libcdr::CMXPen::m_angle
double m_angle
Definition CMXParser.h:66
libcdr::CMXPen::m_matrix
CDRTransform m_matrix
Definition CMXParser.h:67
libcdr::CMXPen::m_aspect
double m_aspect
Definition CMXParser.h:65