CMXParser.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 libcdr 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 __CMXPARSER_H__
11 #define __CMXPARSER_H__
12 
13 #include <stdio.h>
14 #include <iostream>
15 #include <vector>
16 #include <map>
17 #include <librevenge-stream/librevenge-stream.h>
18 #include "CDRTypes.h"
19 #include "CommonParser.h"
20 
21 #define CMX_MASTER_INDEX_TABLE 1
22 #define CMX_PAGE_INDEX_TABLE 2
23 #define CMX_MASTER_LAYER_TABLE 3
24 #define CMX_PROCEDURE_INDEX_TABLE 4
25 #define CMX_BITMAP_INDEX_TABLE 5
26 #define CMX_ARROW_INDEX_TABLE 6
27 #define CMX_FONT_INDEX_TABLE 7
28 #define CMX_EMBEDDED_FILE_INDEX_TABLE 8
29 #define CMX_THUMBNAIL_SECTION 10
30 #define CMX_OUTLINE_DESCRIPTION_SECTION 15
31 #define CMX_LINE_STYLE_DESCRIPTION_SECTION 16
32 #define CMX_ARROWHEADS_DESCRIPTION_SECTION 17
33 #define CMX_SCREEN_DESCRIPTION_SECTION 18
34 #define CMX_PEN_DESCRIPTION_SECTION 19
35 #define CMX_DOT_DASH_DESCRIPTION_SECTION 20
36 #define CMX_COLOR_DESCRIPTION_SECTION 21
37 #define CMX_COLOR_CORRECTION_SECTION 22
38 #define CMX_PREVIEW_BOX_SECTION 23
39 
40 namespace libcdr
41 {
42 
43 class CDRCollector;
44 
45 struct CMXOutline
46 {
48  : m_lineStyle(0), m_screen(0), m_color(0),
49  m_arrowHeads(0), m_pen(0), m_dashArray(0) {}
50  unsigned short m_lineStyle;
51  unsigned short m_screen;
52  unsigned short m_color;
53  unsigned short m_arrowHeads;
54  unsigned short m_pen;
55  unsigned short m_dashArray;
56 };
57 
58 struct CMXPen
59 {
61  : m_width(0.0), m_aspect(1.0), m_angle(0.0), m_matrix() {}
62  double m_width;
63  double m_aspect;
64  double m_angle;
66 };
67 
69 {
70  CMXLineStyle() : m_spec(0), m_capAndJoin(0) {}
71  unsigned char m_spec;
72  unsigned char m_capAndJoin;
73 };
74 
76 {
78  : m_type(0), m_compression(0), m_size(0), m_compressedSize(0) {}
79  unsigned short m_type;
80  unsigned short m_compression;
81  unsigned m_size;
82  unsigned m_compressedSize;
83 };
84 
86 {
88  : m_colorPalette(), m_dashArrays(), m_lineStyles(),
89  m_pens(), m_outlines(), m_bitmapOffsets(), m_patternOffsets(),
90  m_arrowOffsets(), m_embeddedOffsets(), m_embeddedOffsetTypes() {}
91  std::map<unsigned, CDRColor> m_colorPalette;
92  std::map<unsigned, std::vector<unsigned> > m_dashArrays;
93  std::map<unsigned, CMXLineStyle> m_lineStyles;
94  std::map<unsigned, CMXPen> m_pens;
95  std::map<unsigned, CMXOutline> m_outlines;
96  std::map<unsigned, unsigned> m_bitmapOffsets;
97  std::map<unsigned, unsigned> m_patternOffsets;
98  std::map<unsigned, unsigned> m_arrowOffsets;
99  std::map<unsigned, unsigned> m_embeddedOffsets;
100  std::map<unsigned, unsigned> m_embeddedOffsetTypes;
101 };
102 
103 class CMXParser : protected CommonParser
104 {
105 public:
106  explicit CMXParser(CDRCollector *collector, CMXParserState &parserState);
107  virtual ~CMXParser();
108  bool parseRecords(librevenge::RVNGInputStream *input, long size = -1, unsigned level = 0);
109 
110 private:
111  CMXParser();
112  CMXParser(const CMXParser &);
113  CMXParser &operator=(const CMXParser &);
114  bool parseRecord(librevenge::RVNGInputStream *input, unsigned level = 0);
115  void readRecord(unsigned fourCC, unsigned &length, librevenge::RVNGInputStream *input);
116  void parseImage(librevenge::RVNGInputStream *input);
117 
118  void readCMXHeader(librevenge::RVNGInputStream *input);
119  void readDisp(librevenge::RVNGInputStream *input);
120  void readPage(librevenge::RVNGInputStream *input);
121  void readProc(librevenge::RVNGInputStream *input);
122  void readRclr(librevenge::RVNGInputStream *input);
123  void readRotl(librevenge::RVNGInputStream *input);
124  void readRott(librevenge::RVNGInputStream *input);
125  void readRdot(librevenge::RVNGInputStream *input);
126  void readRpen(librevenge::RVNGInputStream *input);
127  void readIxtl(librevenge::RVNGInputStream *input);
128  void readIxef(librevenge::RVNGInputStream *input);
129  void readIxmr(librevenge::RVNGInputStream *input);
130  void readIxpg(librevenge::RVNGInputStream *input);
131  void readIxpc(librevenge::RVNGInputStream *input);
132  void readInfo(librevenge::RVNGInputStream *input);
133  void readData(librevenge::RVNGInputStream *input);
134 
135  // Command readers
136  void readCommands(librevenge::RVNGInputStream *input, unsigned length);
137  void readBeginPage(librevenge::RVNGInputStream *input);
138  void readBeginLayer(librevenge::RVNGInputStream *input);
139  void readBeginGroup(librevenge::RVNGInputStream *input);
140  void readPolyCurve(librevenge::RVNGInputStream *input);
141  void readEllipse(librevenge::RVNGInputStream *input);
142  void readRectangle(librevenge::RVNGInputStream *input);
143  void readJumpAbsolute(librevenge::RVNGInputStream *input);
144  void readDrawImage(librevenge::RVNGInputStream *input);
145  void readBeginProcedure(librevenge::RVNGInputStream *input);
146 
147  // Types readers
148  CDRTransform readMatrix(librevenge::RVNGInputStream *input);
149  CDRBox readBBox(librevenge::RVNGInputStream *input);
150  librevenge::RVNGString readString(librevenge::RVNGInputStream *input);
151  bool readFill(librevenge::RVNGInputStream *input);
152  bool readLens(librevenge::RVNGInputStream *input);
153 
154  // Complex types readers
155  bool readRenderingAttributes(librevenge::RVNGInputStream *input);
156 
157  // Helper Functions
158  CDRColor getPaletteColor(unsigned id);
159  CDRColor readColor(librevenge::RVNGInputStream *input, unsigned char colorModel);
160  CDRLineStyle getLineStyle(unsigned id);
161  const unsigned *_getOffsetByType(unsigned short type, const std::map<unsigned short, unsigned> &offsets);
162 
164  unsigned short m_unit;
165  double m_scale;
166  double m_xmin, m_xmax, m_ymin, m_ymax;
167  unsigned m_fillIndex;
173 };
174 
175 } // namespace libcdr
176 
177 #endif // __CMXPARSER_H__
178 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
CDRPattern * m_currentPattern
Definition: CMXParser.h:171
CMXOutline()
Definition: CMXParser.h:47
Definition: CMXParser.h:85
Definition: CommonParser.h:22
CMXLineStyle()
Definition: CMXParser.h:70
Definition: CMXParser.h:75
unsigned m_nextInstructionOffset
Definition: CMXParser.h:168
double m_aspect
Definition: CMXParser.h:63
CMXParserState()
Definition: CMXParser.h:87
Definition: CDRTypes.h:23
CMXPen()
Definition: CMXParser.h:60
CDRTransform m_matrix
Definition: CMXParser.h:65
unsigned m_compressedSize
Definition: CMXParser.h:82
Definition: CMXParser.h:58
CDRBitmap * m_currentBitmap
Definition: CMXParser.h:172
unsigned char m_spec
Definition: CMXParser.h:71
std::map< unsigned, unsigned > m_embeddedOffsets
Definition: CMXParser.h:99
unsigned char m_capAndJoin
Definition: CMXParser.h:72
Definition: CDRTransforms.h:21
std::map< unsigned, CDRColor > m_colorPalette
Definition: CMXParser.h:91
unsigned short m_arrowHeads
Definition: CMXParser.h:53
unsigned short m_unit
Definition: CMXParser.h:164
std::map< unsigned, unsigned > m_patternOffsets
Definition: CMXParser.h:97
Definition: CMXParser.h:103
double m_width
Definition: CMXParser.h:62
std::map< unsigned, CMXOutline > m_outlines
Definition: CMXParser.h:95
bool m_bigEndian
Definition: CMXParser.h:163
CMXParserState & m_parserState
Definition: CMXParser.h:169
std::map< unsigned, unsigned > m_arrowOffsets
Definition: CMXParser.h:98
CMXImageInfo m_currentImageInfo
Definition: CMXParser.h:170
Definition: CDRCollector.h:29
unsigned short m_dashArray
Definition: CMXParser.h:55
Definition: CMXParser.h:45
double m_ymin
Definition: CMXParser.h:166
unsigned short m_pen
Definition: CMXParser.h:54
std::map< unsigned, CMXPen > m_pens
Definition: CMXParser.h:94
unsigned short m_lineStyle
Definition: CMXParser.h:50
std::map< unsigned, std::vector< unsigned > > m_dashArrays
Definition: CMXParser.h:92
unsigned m_fillIndex
Definition: CMXParser.h:167
unsigned short m_color
Definition: CMXParser.h:52
unsigned m_size
Definition: CMXParser.h:81
std::map< unsigned, unsigned > m_embeddedOffsetTypes
Definition: CMXParser.h:100
unsigned short m_compression
Definition: CMXParser.h:80
std::map< unsigned, CMXLineStyle > m_lineStyles
Definition: CMXParser.h:93
double m_scale
Definition: CMXParser.h:165
CMXImageInfo()
Definition: CMXParser.h:77
Definition: CDRTypes.h:112
unsigned short m_type
Definition: CMXParser.h:79
Definition: CDRTypes.h:225
Definition: CDRTypes.h:52
Definition: CDRTypes.h:215
double m_angle
Definition: CMXParser.h:64
Definition: CMXParser.h:68
unsigned short m_screen
Definition: CMXParser.h:51
Definition: CDRCollector.h:63
std::map< unsigned, unsigned > m_bitmapOffsets
Definition: CMXParser.h:96

Generated for libcdr by doxygen 1.8.13