QXP33Parser.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 libqxp 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 QXP33PARSER_H_INCLUDED
11 #define QXP33PARSER_H_INCLUDED
12
13 #include "libqxp_utils.h"
14 #include "QXPParser.h"
15
16 #include <string>
17
18 namespace libqxp
19 {
20
21 class QXP33Deobfuscator;
22 class QXP33Header;
23
24 class QXP33Parser : public QXPParser
25 {
26 public:
27 QXP33Parser(const std::shared_ptr<librevenge::RVNGInputStream> &input, librevenge::RVNGDrawingInterface *painter, const std::shared_ptr<QXP33Header> &header);
28
29 enum class ShapeType
30 {
31 UNKNOWN,
32 LINE,
33 ORTHOGONAL_LINE,
34 RECTANGLE,
35 CORNERED_RECTANGLE,
36 OVAL,
37 POLYGON
38 };
39
40 struct ObjectHeader
41 {
42 boost::optional<Fill> fill;
43
44 bool runaround;
45
46 unsigned contentIndex;
47 unsigned linkId;
48 unsigned gradientId;
49
50 double rotation;
51 double skew;
52
53 bool hflip;
54 bool vflip;
55 CornerType cornerType;
56 double cornerRadius;
57
58 ContentType contentType;
59 ShapeType shapeType;
60
61 Rect boundingBox;
62
63 BoxType boxType;
64
65 ObjectHeader()
66 : fill(), runaround(false), contentIndex(0), linkId(0), gradientId(0),
67 rotation(0), skew(0), hflip(false), vflip(false), cornerType(CornerType::DEFAULT),
68 cornerRadius(0), contentType(ContentType::UNKNOWN), shapeType(ShapeType::UNKNOWN), boundingBox(),
69 boxType(BoxType::UNKNOWN)
70 { }
71 };
72
73 private:
74 const std::shared_ptr<QXP33Header> m_header;
75
76 bool parseDocument(const std::shared_ptr<librevenge::RVNGInputStream> &docStream, QXPCollector &collector) override;
77 bool parsePages(const std::shared_ptr<librevenge::RVNGInputStream> &pagesStream, QXPCollector &collector) override;
78
79 void parseColors(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
80 CharFormat parseCharFormat(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
81 ParagraphFormat parseParagraphFormat(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
82 std::shared_ptr<HJ> parseHJ(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
83
84 Page parsePage(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
85
86 void parseObject(const std::shared_ptr<librevenge::RVNGInputStream> &stream, QXP33Deobfuscator &deobfuscate, QXPCollector &collector, const Page &page, unsigned index);
87 ObjectHeader parseObjectHeader(const std::shared_ptr<librevenge::RVNGInputStream> &stream, QXP33Deobfuscator &deobfuscate);
88 void readObjectFlags(const std::shared_ptr<librevenge::RVNGInputStream> &stream, bool &noColor, bool &noRunaround);
89 void parseLine(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
90 void parseTextBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
91 void parsePictureBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
92 void parseEmptyBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
93 void parseGroup(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector, const Page &page, unsigned index);
94
95 Frame readFrame(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
96 std::vector<Point> readPolygonData(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
97
98 std::string readName(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
99 };
100
101 }
102
103 #endif // QXP33PARSER_H_INCLUDED
104
105 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libqxp::Color
Definition: QXPTypes.h:68
libqxp::Page
Definition: QXPTypes.h:545
libqxp::QXP33Parser::parseObjectHeader
ObjectHeader parseObjectHeader(const std::shared_ptr< librevenge::RVNGInputStream > &stream, QXP33Deobfuscator &deobfuscate)
Definition: QXP33Parser.cpp:292
libqxp::QXP33Parser::ShapeType::OVAL
libqxp::QXP33Parser::ShapeType::CORNERED_RECTANGLE
libqxp::QXP33Parser::ObjectHeader::fill
boost::optional< Fill > fill
Definition: QXP33Parser.h:42
libqxp::Frame::width
double width
Definition: QXPTypes.h:346
libqxp::readU16
uint16_t readU16(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libqxp_utils.cpp:111
libqxp::ContentType::OBJECTS
libqxp::BoxType::POLYGON
libqxp::QXP33Parser::ObjectHeader
Definition: QXP33Parser.h:40
libqxp::QXPParser::getColor
Color getColor(unsigned id, Color defaultColor=Color(0, 0, 0)) const
Definition: QXPParser.cpp:83
libqxp::QXP33Parser::readName
std::string readName(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXP33Parser.cpp:726
libqxp::QXPParser::be
const bool be
Definition: QXPParser.h:45
libqxp::QXP_33
Definition: QXPHeader.h:28
libqxp::QXPParser::readRecordEndOffset
uint32_t readRecordEndOffset(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:318
libqxp::QXPParser::readColorComp
uint8_t readColorComp(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:324
QXP33Parser.h
libqxp::QXP33Parser::ObjectHeader::cornerRadius
double cornerRadius
Definition: QXP33Parser.h:56
libqxp::QXP33Parser::parseDocument
bool parseDocument(const std::shared_ptr< librevenge::RVNGInputStream > &docStream, QXPCollector &collector) override
Definition: QXP33Parser.cpp:71
libqxp::QXPCollector::collectBox
virtual void collectBox(const std::shared_ptr< Box > &)
Definition: QXPCollector.h:46
libqxp::QXP33Parser::parsePages
bool parsePages(const std::shared_ptr< librevenge::RVNGInputStream > &pagesStream, QXPCollector &collector) override
Definition: QXP33Parser.cpp:103
libqxp
Definition: libqxp_utils.cpp:24
libqxp::QXPParser::readObjectFlags
uint8_t readObjectFlags(const std::shared_ptr< librevenge::RVNGInputStream > &stream, bool &noColor)
Definition: QXPParser.cpp:478
libqxp::QXPCollector::collectTextBox
virtual void collectTextBox(const std::shared_ptr< TextBox > &)
Definition: QXPCollector.h:47
libqxp::QXP33Parser::ObjectHeader::shapeType
ShapeType shapeType
Definition: QXP33Parser.h:59
libqxp::QXP33Parser
Definition: QXP33Parser.h:24
libqxp::QXP33Parser::ObjectHeader::gradientId
unsigned gradientId
Definition: QXP33Parser.h:48
libqxp::ParagraphFormat::leading
double leading
Definition: QXPTypes.h:252
libqxp::QXP33Parser::readPolygonData
std::vector< Point > readPolygonData(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXP33Parser.cpp:705
libqxp::QXPParser::skipRecord
void skipRecord(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:116
libqxp::QXP33Parser::ObjectHeader::contentType
ContentType contentType
Definition: QXP33Parser.h:58
libqxp::QXPParser
Definition: QXPParser.h:30
libqxp::QXPCollector::startPage
virtual void startPage(const Page &)
Definition: QXPCollector.h:40
libqxp::Frame
Definition: QXPTypes.h:344
libqxp::QXP33Parser::ObjectHeader::ObjectHeader
ObjectHeader()
Definition: QXP33Parser.h:65
libqxp::BoxType::RECTANGLE
libqxp::QXPParser::parseTabStop
TabStop parseTabStop(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:200
QXPCollector.h
libqxp::QXPParser::setArrow
void setArrow(const unsigned index, Frame &frame) const
Definition: QXPParser.cpp:492
libqxp::ParagraphFormat::firstLineIndent
double firstLineIndent
Definition: QXPTypes.h:251
libqxp::QXP33Parser::ObjectHeader::contentIndex
unsigned contentIndex
Definition: QXP33Parser.h:46
libqxp::ContentType::NONE
libqxp::seek
void seek(librevenge::RVNGInputStream *const input, const unsigned long pos)
Definition: libqxp_utils.cpp:241
libqxp::readPlatformString
std::string readPlatformString(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libqxp_utils.cpp:229
libqxp::BoxType::OVAL
libqxp::ContentType::TEXT
libqxp::QXPCollector
Definition: QXPCollector.h:27
libqxp_utils.h
libqxp::QXPDummyCollector
Definition: QXPCollector.h:54
libqxp::QXP33Parser::ObjectHeader::boxType
BoxType boxType
Definition: QXP33Parser.h:63
libqxp::QXPParser::parseFonts
void parseFonts(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:125
libqxp::QXP33Parser::m_header
const std::shared_ptr< QXP33Header > m_header
Definition: QXP33Parser.h:74
libqxp::ParagraphFormat::incrementalLeading
bool incrementalLeading
Definition: QXPTypes.h:253
libqxp::BoxType
BoxType
Definition: QXPTypes.h:477
libqxp::ParagraphFormat::tabStops
std::vector< TabStop > tabStops
Definition: QXPTypes.h:256
libqxp::QXPParser::readObjectBBox
Rect readObjectBBox(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:329
libqxp::QXPParser::getLineStyle
const LineStyle * getLineStyle(unsigned id) const
Definition: QXPParser.cpp:94
libqxp::QXPParser::readVertAlign
VerticalAlignment readVertAlign(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:413
libqxp::QXPParser::parseParagraphFormats
void parseParagraphFormats(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:230
libqxp::QXPParser::readYX
Point readYX(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:432
libqxp::readU32
uint32_t readU32(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libqxp_utils.cpp:127
libqxp::QXP33Parser::parsePage
Page parsePage(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXP33Parser.cpp:245
libqxp::QXPParser::m_hjs
std::deque< std::shared_ptr< HJ > > m_hjs
Definition: QXPParser.h:56
libqxp::QXP33Parser::ShapeType::LINE
libqxp::QXP33Parser::ShapeType::UNKNOWN
libqxp::readFraction
double readFraction(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libqxp_utils.cpp:174
libqxp::QXP33Parser::ObjectHeader::runaround
bool runaround
Definition: QXP33Parser.h:44
QXP_DEBUG_MSG
#define QXP_DEBUG_MSG(M)
Definition: libqxp_utils.h:53
libqxp::QXP33Parser::ObjectHeader::skew
double skew
Definition: QXP33Parser.h:51
libqxp::QXP33Parser::parseLine
void parseLine(const std::shared_ptr< librevenge::RVNGInputStream > &stream, const ObjectHeader &header, QXPCollector &collector)
Definition: QXP33Parser.cpp:485
QXP_FALLTHROUGH
#define QXP_FALLTHROUGH
Definition: libqxp_utils.h:40
libqxp::QXPCollector::collectLine
virtual void collectLine(const std::shared_ptr< Line > &)
Definition: QXPCollector.h:45
libqxp::Page::pageSettings
std::vector< PageSettings > pageSettings
Definition: QXPTypes.h:547
libqxp::QXP33Parser::parseColors
void parseColors(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXP33Parser.cpp:130
libqxp::QXP33Parser::QXP33Parser
QXP33Parser(const std::shared_ptr< librevenge::RVNGInputStream > &input, librevenge::RVNGDrawingInterface *painter, const std::shared_ptr< QXP33Header > &header)
Definition: QXP33Parser.cpp:65
libqxp::QXP33Parser::readFrame
Frame readFrame(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXP33Parser.cpp:694
libqxp::CornerType
CornerType
Definition: QXPTypes.h:469
libqxp::QXPParser::readParagraphFlags
uint8_t readParagraphFlags(const std::shared_ptr< librevenge::RVNGInputStream > &stream, bool &incrementalLeading, bool &ruleAbove, bool &ruleBelow)
Definition: QXPParser.cpp:460
libqxp::CharFormat
Definition: QXPTypes.h:144
libqxp::Rect::top
double top
Definition: QXPTypes.h:48
libqxp::QXP33Parser::ObjectHeader::vflip
bool vflip
Definition: QXP33Parser.h:54
libqxp::QXP33Parser::ObjectHeader::cornerType
CornerType cornerType
Definition: QXP33Parser.h:55
libqxp::QXPParser::readParagraphRule
std::shared_ptr< ParagraphRule > readParagraphRule(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:440
libqxp::CharFormat::color
Color color
Definition: QXPTypes.h:149
libqxp::QXP33Parser::parseObject
void parseObject(const std::shared_ptr< librevenge::RVNGInputStream > &stream, QXP33Deobfuscator &deobfuscate, QXPCollector &collector, const Page &page, unsigned index)
Definition: QXP33Parser.cpp:253
libqxp::QXPParser::readGradient
Gradient readGradient(const std::shared_ptr< librevenge::RVNGInputStream > &stream, const Color &color1)
Definition: QXPParser.cpp:339
libqxp::Frame::color
boost::optional< Color > color
Definition: QXPTypes.h:347
libqxp::CharFormat::baselineShift
double baselineShift
Definition: QXPTypes.h:148
libqxp::QXPParser::readGroupElements
void readGroupElements(const std::shared_ptr< librevenge::RVNGInputStream > &stream, unsigned count, unsigned objectsCount, unsigned index, std::vector< unsigned > &elements)
Definition: QXPParser.cpp:560
libqxp::Color::blue
uint8_t blue
Definition: QXPTypes.h:72
libqxp::QXP33Parser::ObjectHeader::linkId
unsigned linkId
Definition: QXP33Parser.h:47
libqxp::QXPParser::parseText
std::shared_ptr< Text > parseText(unsigned index, unsigned linkId, QXPCollector &collector)
Definition: QXPParser.cpp:303
libqxp::CharFormat::isControlChars
bool isControlChars
Definition: QXPTypes.h:163
QXP33Deobfuscator.h
libqxp::Rect::right
double right
Definition: QXPTypes.h:49
QXPTypes.h
libqxp::Rect
Definition: QXPTypes.h:46
libqxp::ParagraphFormat::ruleAbove
std::shared_ptr< ParagraphRule > ruleAbove
Definition: QXPTypes.h:254
libqxp::readU8
uint8_t readU8(librevenge::RVNGInputStream *input, bool)
Definition: libqxp_utils.cpp:99
libqxp::QXPParser::skipFileInfo
void skipFileInfo(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:517
libqxp::QXPParser::m_colors
std::map< unsigned, Color > m_colors
Definition: QXPParser.h:50
libqxp::QXPParser::readHorAlign
HorizontalAlignment readHorAlign(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:392
libqxp::QXP33Parser::readObjectFlags
void readObjectFlags(const std::shared_ptr< librevenge::RVNGInputStream > &stream, bool &noColor, bool &noRunaround)
Definition: QXP33Parser.cpp:472
libqxp::QXP33Parser::parseGroup
void parseGroup(const std::shared_ptr< librevenge::RVNGInputStream > &stream, const ObjectHeader &header, QXPCollector &collector, const Page &page, unsigned index)
Definition: QXP33Parser.cpp:675
libqxp::CornerType::BEVELED
libqxp::QXP33Parser::ObjectHeader::boundingBox
Rect boundingBox
Definition: QXP33Parser.h:61
libqxp::Color::applyShade
Color applyShade(double shade) const
Definition: QXPTypes.cpp:105
libqxp::QXP33Parser::parseCharFormat
CharFormat parseCharFormat(const std::shared_ptr< librevenge::RVNGInputStream > &stream) override
Definition: QXP33Parser.cpp:160
libqxp::QXP33Parser::parseHJ
std::shared_ptr< HJ > parseHJ(const std::shared_ptr< librevenge::RVNGInputStream > &stream) override
Definition: QXP33Parser.cpp:234
libqxp::Rect::bottom
double bottom
Definition: QXPTypes.h:50
libqxp::UNKNOWN
Definition: QXPHeader.h:24
libqxp::QXPCollector::endPage
virtual void endPage()
Definition: QXPCollector.h:41
libqxp::CornerType::ROUNDED
libqxp::QXP33Parser::ShapeType::POLYGON
libqxp::ParagraphFormat::hj
std::shared_ptr< HJ > hj
Definition: QXPTypes.h:257
libqxp::QXPParser::parseCommonCharFormatProps
void parseCommonCharFormatProps(const std::shared_ptr< librevenge::RVNGInputStream > &stream, CharFormat &result)
Definition: QXPParser.cpp:189
libqxp::Color::green
uint8_t green
Definition: QXPTypes.h:71
libqxp::QXP33Parser::parseParagraphFormat
ParagraphFormat parseParagraphFormat(const std::shared_ptr< librevenge::RVNGInputStream > &stream) override
Definition: QXP33Parser.cpp:186
libqxp::ParagraphFormat
Definition: QXPTypes.h:247
libqxp::Rect::left
double left
Definition: QXPTypes.h:51
libqxp::ContentType::PICTURE
libqxp::ContentType
ContentType
Definition: QXPTypes.h:265
libqxp::QXP33Parser::ObjectHeader::rotation
double rotation
Definition: QXP33Parser.h:50
libqxp::skip
void skip(librevenge::RVNGInputStream *input, unsigned long numBytes)
Definition: libqxp_utils.cpp:234
QXPParser.h
libqxp::QXPParser::parseHJProps
void parseHJProps(const std::shared_ptr< librevenge::RVNGInputStream > &stream, HJ &result)
Definition: QXPParser.cpp:176
libqxp::QXPCollector::collectDocumentProperties
virtual void collectDocumentProperties(const QXPDocumentProperties &)
Definition: QXPCollector.h:43
libqxp::QXP33Parser::parseTextBox
void parseTextBox(const std::shared_ptr< librevenge::RVNGInputStream > &stream, const ObjectHeader &header, QXPCollector &collector)
Definition: QXP33Parser.cpp:504
libqxp::QXP33Parser::parseEmptyBox
void parseEmptyBox(const std::shared_ptr< librevenge::RVNGInputStream > &stream, const ObjectHeader &header, QXPCollector &collector)
Definition: QXP33Parser.cpp:651
libqxp::ParseError
Definition: libqxp_utils.h:142
libqxp::QXP33Parser::ShapeType::RECTANGLE
libqxp::QXPParser::m_groupObjects
std::set< unsigned > m_groupObjects
Definition: QXPParser.h:58
libqxp::QXPParser::parseHJs
void parseHJs(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:159
libqxp::QXPParser::parsePageSettings
std::vector< PageSettings > parsePageSettings(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:264
libqxp::QXP33Deobfuscator
Definition: QXP33Deobfuscator.h:19
libqxp::CornerType::DEFAULT
libqxp::GenericException
Definition: libqxp_utils.h:132
libqxp::ParagraphFormat::ruleBelow
std::shared_ptr< ParagraphRule > ruleBelow
Definition: QXPTypes.h:255
libqxp::QXP33Parser::ShapeType::ORTHOGONAL_LINE
libqxp::QXP33Parser::ObjectHeader::hflip
bool hflip
Definition: QXP33Parser.h:53
QXP33Header.h
libqxp::ParagraphFormat::margin
Rect margin
Definition: QXPTypes.h:250
libqxp::QXP33Parser::parsePictureBox
void parsePictureBox(const std::shared_ptr< librevenge::RVNGInputStream > &stream, const ObjectHeader &header, QXPCollector &collector)
Definition: QXP33Parser.cpp:573
libqxp::Color::red
uint8_t red
Definition: QXPTypes.h:70
libqxp::QXPCollector::collectGroup
virtual void collectGroup(const std::shared_ptr< Group > &)
Definition: QXPCollector.h:49
libqxp::getRemainingLength
unsigned long getRemainingLength(librevenge::RVNGInputStream *const input)
Definition: libqxp_utils.cpp:259
libqxp::QXPParser::parseCharFormats
void parseCharFormats(const std::shared_ptr< librevenge::RVNGInputStream > &stream)
Definition: QXPParser.cpp:167
libqxp::QXP33Parser::ShapeType
ShapeType
Definition: QXP33Parser.h:29
libqxp::Page::objectsCount
unsigned objectsCount
Definition: QXPTypes.h:548
libqxp::ParagraphFormat::alignment
HorizontalAlignment alignment
Definition: QXPTypes.h:249
libqxp::CornerType::CONCAVE