PMDParser.h Source File documentation

PMDParser.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 libpagemaker 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 __PMDPARSER_H__
11 #define __PMDPARSER_H__
12
13 #include <map>
14 #include <set>
15 #include <stdint.h>
16
17 #include <librevenge/librevenge.h>
18
19 #include "PMDRecord.h"
20 #include "geometry.h"
21
22 namespace libpagemaker
23 {
24
25 class PMDCollector;
26 class PMDParser
27 {
28 typedef std::vector<PMDRecordContainer> RecordContainerList_t;
29 typedef std::map<uint16_t, std::vector<unsigned> > RecordTypeMap_t;
30
31 librevenge::RVNGInputStream *m_input;
32 unsigned long m_length;
33 PMDCollector *m_collector;
34 RecordTypeMap_t m_records;
35 bool m_bigEndian;
36 RecordContainerList_t m_recordsInOrder;
37 std::map<uint32_t, PMDXForm> m_xFormMap;
38
39 struct ToCState;
40 class RecordIterator;
41
42 /* Private functions. */
43 void parseGlobalInfo(const PMDRecordContainer &container);
44 void parseFonts();
45 void parseColors();
46 void parsePages(const PMDRecordContainer &container);
47 void parseShapes(uint16_t seqNum, unsigned pageID);
48 void parseLine(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
49 void parseTextBox(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
50 void parseRectangle(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
51 void parsePolygon(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
52 void parseEllipse(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
53 void parseBitmap(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
54 void parseHeader(uint32_t *tocOffset, uint16_t *tocLength);
55 void readNextRecordFromTableOfContents(ToCState &state, bool subRecord, uint16_t subRecordType = 0);
56 void readTableOfContents(ToCState &state, uint32_t offset, unsigned records, bool subRecords, uint16_t subRecordType = 0);
57 void parseTableOfContents(uint32_t offset, uint16_t length);
58 void parseXforms();
59 const PMDXForm &getXForm(const uint32_t xFormId) const;
60
61 RecordIterator beginRecordsWithSeqNumber(uint16_t seqNum) const;
62 RecordIterator beginRecordsOfType(uint16_t recType) const;
63 RecordIterator endRecords() const;
64
65 /* Prevent copy and assignment */
66 PMDParser &operator=(const PMDParser &);
67 PMDParser(const PMDParser &);
68 public:
69 PMDParser(librevenge::RVNGInputStream *, PMDCollector *);
70 void parse();
71 };
72
73 }
74
75 #endif /* __PMDPARSER_H__ */
76
77 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
ENDIANNESS_MARKER
const uint16_t ENDIANNESS_MARKER
Definition: constants.h:49
libpagemaker::PMDParser::parseFonts
void parseFonts()
Definition: PMDParser.cpp:698
libpagemaker::PMDParser::parsePolygon
void parsePolygon(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID)
Definition: PMDParser.cpp:498
libpagemaker::PMDFillProperties::m_fillOverprint
uint8_t m_fillOverprint
Definition: PMDTypes.h:47
LINE_RECORD
const uint8_t LINE_RECORD
Definition: constants.h:36
PMDRecord.h
PAGE
const uint8_t PAGE
Definition: constants.h:17
libpagemaker::PMDParser::RecordIterator::m_it
RecordContainerList_t::const_iterator m_it
Definition: PMDParser.cpp:109
libpagemaker::PMDCollector::setDoubleSided
void setDoubleSided(bool)
Definition: PMDCollector.cpp:141
libpagemaker::PMDParser::parseGlobalInfo
void parseGlobalInfo(const PMDRecordContainer &container)
Definition: PMDParser.cpp:251
libpagemaker::PMDParser::ToCState
Definition: PMDParser.cpp:72
libpagemaker::PMDRecordContainer::m_recordType
uint16_t m_recordType
Definition: PMDRecord.h:27
libpagemaker::PMDParser::RecordIterator::m_recIt
boost::optional< RecordTypeMap_t::mapped_type::const_iterator > m_recIt
Definition: PMDParser.cpp:113
libpagemaker::PMDFillProperties::m_fillTint
uint8_t m_fillTint
Definition: PMDTypes.h:48
libpagemaker::PMDParser
Definition: PMDParser.h:26
geometry.h
libpagemaker::PMDParser::RecordIterator::m_recBegin
RecordTypeMap_t::mapped_type::const_iterator m_recBegin
Definition: PMDParser.cpp:114
POLYGON_RECORD
const uint8_t POLYGON_RECORD
Definition: constants.h:41
libpagemaker::LengthUnit
Definition: Units.h:21
GLOBAL_INFO
const uint8_t GLOBAL_INFO
Definition: constants.h:23
HLS
const uint8_t HLS
Definition: constants.h:31
libpagemaker::PMDParser::RecordContainerList_t
std::vector< PMDRecordContainer > RecordContainerList_t
Definition: PMDParser.h:28
libpagemaker::PMDParser::parseLine
void parseLine(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID)
Definition: PMDParser.cpp:272
libpagemaker::PMDRecordContainer
Definition: PMDRecord.h:25
libpagemaker::PMDFont
Definition: PMDTypes.h:32
libpagemaker::PMDParser::getXForm
const PMDXForm & getXForm(const uint32_t xFormId) const
Definition: PMDParser.cpp:216
libpagemaker::PMDCollector::setPageWidth
void setPageWidth(PMDShapeUnit)
Definition: PMDCollector.cpp:147
libpagemaker::readU32
uint32_t readU32(const RVNGInputStreamPtr &input, bool bigEndian)
Definition: libpagemaker_utils.cpp:79
libpagemaker::PMDParser::RecordIterator::m_selector
boost::optional< uint16_t > m_selector
Definition: PMDParser.cpp:112
libpagemaker::PMDParser::RecordIterator::equal
bool equal(const RecordIterator &other) const
Definition: PMDParser.cpp:166
libpagemaker::PMDXForm
Definition: geometry.h:36
libpagemaker::PMDStrokeProperties::m_strokeWidth
uint16_t m_strokeWidth
Definition: PMDTypes.h:56
libpagemaker::PMDParser::parseTableOfContents
void parseTableOfContents(uint32_t offset, uint16_t length)
Definition: PMDParser.cpp:953
REGULAR_POLYGON
const uint8_t REGULAR_POLYGON
Definition: constants.h:44
TABLE_OF_CONTENTS_LENGTH_OFFSET
const unsigned TABLE_OF_CONTENTS_LENGTH_OFFSET
Definition: offsets.h:14
PMDParser.h
libpagemaker::PMDPolygon
Definition: geometry.h:189
ELLIPSE_RECORD
const uint8_t ELLIPSE_RECORD
Definition: constants.h:38
libpagemaker::PMDParser::ToCState::ToCState
ToCState()
Definition: PMDParser.cpp:80
libpagemaker::PMDFillProperties::m_fillType
uint8_t m_fillType
Definition: PMDTypes.h:45
libpagemaker::PMDParser::parseEllipse
void parseEllipse(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID)
Definition: PMDParser.cpp:570
libpagemaker::PMDRectangle
Definition: geometry.h:398
libpagemaker::PMDParser::parseBitmap
void parseBitmap(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID)
Definition: PMDParser.cpp:609
TIFF
const uint8_t TIFF
Definition: constants.h:19
PMD_ERR_MSG
#define PMD_ERR_MSG(M)
Definition: libpagemaker_utils.h:59
libpagemaker::PMDFillProperties::m_fillColor
uint8_t m_fillColor
Definition: PMDTypes.h:46
libpagemaker::readNBytes
const unsigned char * readNBytes(const RVNGInputStreamPtr &input, const unsigned long numBytes)
Definition: libpagemaker_utils.cpp:121
libpagemaker::PMDParser::beginRecordsOfType
RecordIterator beginRecordsOfType(uint16_t recType) const
Definition: PMDParser.cpp:1001
POLYGON_CLOSED
const uint8_t POLYGON_CLOSED
Definition: constants.h:46
libpagemaker::PMDParser::RecordIterator
Definition: PMDParser.cpp:86
libpagemaker::PMDParser::parseHeader
void parseHeader(uint32_t *tocOffset, uint16_t *tocLength)
Definition: PMDParser.cpp:830
libpagemaker::PMDStrokeProperties
Definition: PMDTypes.h:53
libpagemaker::PMDParser::parseTextBox
void parseTextBox(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID)
Definition: PMDParser.cpp:304
libpagemaker::PMDCollector::addShapeToPage
void addShapeToPage(unsigned pageID, const std::shared_ptr< PMDLineSet > &shape)
Definition: PMDCollector.cpp:173
libpagemaker_utils.h
libpagemaker::PMDParser::m_records
RecordTypeMap_t m_records
Definition: PMDParser.h:34
libpagemaker::PMDColor
Definition: PMDTypes.h:20
libpagemaker::PMDParser::RecordIterator::m_end
RecordContainerList_t::const_iterator m_end
Definition: PMDParser.cpp:111
libpagemaker::PMDParser::RecordTypeMap_t
std::map< uint16_t, std::vector< unsigned > > RecordTypeMap_t
Definition: PMDParser.h:29
libpagemaker::PMDParser::parseRectangle
void parseRectangle(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID)
Definition: PMDParser.cpp:460
libpagemaker::PMDParser::m_input
librevenge::RVNGInputStream * m_input
Definition: PMDParser.h:31
libpagemaker::PMDCollector::addFont
void addFont(const PMDFont &font)
Definition: PMDCollector.cpp:168
TEXT_BLOCK
const uint8_t TEXT_BLOCK
Definition: constants.h:25
libpagemaker::seekToRecord
void seekToRecord(librevenge::RVNGInputStream *const input, const PMDRecordContainer &container, const unsigned recordIndex)
Definition: PMDParser.cpp:229
libpagemaker::PMDBitmap
Definition: geometry.h:612
libpagemaker::PMDParser::m_recordsInOrder
RecordContainerList_t m_recordsInOrder
Definition: PMDParser.h:36
PMDCollector.h
libpagemaker::PMDCollector
Builder class for PMD Documents.
Definition: PMDCollector.h:38
libpagemaker::readU8
uint8_t readU8(const RVNGInputStreamPtr &input, bool)
Definition: libpagemaker_utils.cpp:41
libpagemaker::PMDStrokeProperties::m_strokeColor
uint8_t m_strokeColor
Definition: PMDTypes.h:57
XFORM
const uint8_t XFORM
Definition: constants.h:27
libpagemaker::getLength
unsigned long getLength(const RVNGInputStreamPtr &input)
Definition: libpagemaker_utils.cpp:159
libpagemaker::seek
void seek(const RVNGInputStreamPtr &input, const unsigned long pos)
Definition: libpagemaker_utils.cpp:141
libpagemaker::PMDCharProperties
Definition: PMDTypes.h:85
libpagemaker::PMDParser::endRecords
RecordIterator endRecords() const
Definition: PMDParser.cpp:1006
libpagemaker::PMDParser::readTableOfContents
void readTableOfContents(ToCState &state, uint32_t offset, unsigned records, bool subRecords, uint16_t subRecordType=0)
Definition: PMDParser.cpp:924
libpagemaker::PMDParser::ToCState::seqNum
unsigned seqNum
Definition: PMDParser.cpp:77
FONTS
const uint8_t FONTS
Definition: constants.h:21
libpagemaker::PMDParser::RecordIterator::RecordIterator
RecordIterator(const RecordContainerList_t &records)
Definition: PMDParser.cpp:118
libpagemaker::PMDStrokeProperties::m_strokeOverprint
uint8_t m_strokeOverprint
Definition: PMDTypes.h:58
libpagemaker::PMDParser::RecordIterator::m_recEnd
RecordTypeMap_t::mapped_type::const_iterator m_recEnd
Definition: PMDParser.cpp:115
libpagemaker::PMDStrokeProperties::m_strokeType
uint8_t m_strokeType
Definition: PMDTypes.h:55
libpagemaker::PMDParser::parsePages
void parsePages(const PMDRecordContainer &container)
Definition: PMDParser.cpp:808
libpagemaker::PMDParseException
Definition: PMDExceptions.h:22
libpagemaker::Point
Definition: geometry.h:24
libpagemaker::PMDParser::m_bigEndian
bool m_bigEndian
Definition: PMDParser.h:35
libpagemaker::readU16
uint16_t readU16(const RVNGInputStreamPtr &input, bool bigEndian)
Definition: libpagemaker_utils.cpp:58
libpagemaker::PMDParser::RecordIterator::m_begin
RecordContainerList_t::const_iterator m_begin
Definition: PMDParser.cpp:110
libpagemaker::PMDParser::readNextRecordFromTableOfContents
void readNextRecordFromTableOfContents(ToCState &state, bool subRecord, uint16_t subRecordType=0)
Definition: PMDParser.cpp:871
libpagemaker::PMDParser::RecordIterator::increment
void increment()
Definition: PMDParser.cpp:171
libpagemaker::PMDParser::PMDParser
PMDParser(const PMDParser &)
libpagemaker
Definition: geometry.h:22
libpagemaker::skip
void skip(const RVNGInputStreamPtr &input, unsigned long numBytes)
Definition: libpagemaker_utils.cpp:134
METAFILE_RECORD
const uint8_t METAFILE_RECORD
Definition: constants.h:40
libpagemaker::PMDRecordContainer::m_numRecords
uint16_t m_numRecords
Definition: PMDRecord.h:30
constants.h
PMDExceptions.h
PMDTypes.h
libpagemaker::getRecordSize
boost::optional< unsigned > getRecordSize(uint16_t recType)
Definition: PMDRecord.h:38
libpagemaker::PMDParser::m_length
unsigned long m_length
Definition: PMDParser.h:32
libpagemaker::RecordNotFoundException
Definition: PMDExceptions.h:31
libpagemaker::PMDTextBox
Definition: geometry.h:292
libpagemaker::PMDParser::RecordIterator::dereference
reference dereference() const
Definition: PMDParser.cpp:161
libpagemaker::PMDParser::parseShapes
void parseShapes(uint16_t seqNum, unsigned pageID)
Definition: PMDParser.cpp:658
TABLE_OF_CONTENTS_OFFSET_OFFSET
const unsigned TABLE_OF_CONTENTS_OFFSET_OFFSET
Definition: offsets.h:13
libpagemaker::PMDParser::parse
void parse()
Definition: PMDParser.cpp:963
libpagemaker::PMDParser::parseColors
void parseColors()
Definition: PMDParser.cpp:731
RGB
const uint8_t RGB
Definition: constants.h:32
BITMAP_RECORD
const uint8_t BITMAP_RECORD
Definition: constants.h:39
libpagemaker::PMDFillProperties
Definition: PMDTypes.h:43
POLYGON_OPEN
const uint8_t POLYGON_OPEN
Definition: constants.h:45
libpagemaker::PMDStreamException
Definition: libpagemaker_utils.h:92
libpagemaker::PMDShapePoint
Point< PMDShapeUnit > PMDShapePoint
Definition: geometry.h:33
libpagemaker::PMDParser::operator=
PMDParser & operator=(const PMDParser &)
libpagemaker::PMDParser::RecordIterator::decrement
void decrement()
Definition: PMDParser.cpp:192
libpagemaker::PMDEllipse
Definition: geometry.h:506
libpagemaker::PMDStrokeProperties::m_strokeTint
uint8_t m_strokeTint
Definition: PMDTypes.h:59
libpagemaker::PMDLine
Definition: geometry.h:76
offsets.h
COLORS
const uint8_t COLORS
Definition: constants.h:22
WARPED_ENDIANNESS_MARKER
const uint16_t WARPED_ENDIANNESS_MARKER
Definition: constants.h:50
TEXT_RECORD
const uint8_t TEXT_RECORD
Definition: constants.h:35
libpagemaker::PMDParaProperties
Definition: PMDTypes.h:64
libpagemaker::PMDParser::m_xFormMap
std::map< uint32_t, PMDXForm > m_xFormMap
Definition: PMDParser.h:37
ENDIANNESS_MARKER_OFFSET
const unsigned ENDIANNESS_MARKER_OFFSET
Definition: offsets.h:15
libpagemaker::PMDParser::parseXforms
void parseXforms()
Definition: PMDParser.cpp:780
libpagemaker::PMDCollector::setPageHeight
void setPageHeight(PMDShapeUnit)
Definition: PMDCollector.cpp:152
libpagemaker::readPoint
PMDShapePoint readPoint(librevenge::RVNGInputStream *const input, const bool bigEndian)
Definition: PMDParser.cpp:244
libpagemaker::PMDCollector::addPage
unsigned addPage()
Definition: PMDCollector.cpp:157
libpagemaker::PMDParser::beginRecordsWithSeqNumber
RecordIterator beginRecordsWithSeqNumber(uint16_t seqNum) const
Definition: PMDParser.cpp:996
PMD_DEBUG_MSG
#define PMD_DEBUG_MSG(M)
Definition: libpagemaker_utils.h:56
libpagemaker::readS16
int16_t readS16(const RVNGInputStreamPtr &input, const bool bigEndian)
Definition: libpagemaker_utils.cpp:74
libpagemaker::PMDParser::ToCState::parsedBlocks
std::set< unsigned long > parsedBlocks
Definition: PMDParser.cpp:76
libpagemaker::UnknownRecordSizeException
Definition: PMDExceptions.h:60
RECTANGLE_RECORD
const uint8_t RECTANGLE_RECORD
Definition: constants.h:37
libpagemaker::PMDParser::m_collector
PMDCollector * m_collector
Definition: PMDParser.h:33
CMYK
const uint8_t CMYK
Definition: constants.h:30
libpagemaker::PMDCollector::addColor
void addColor(const PMDColor &color)
Definition: PMDCollector.cpp:163
libpagemaker::PMDRecordContainer::m_offset
uint32_t m_offset
Definition: PMDRecord.h:28