Debian Codegraph @

src/lib/QXP33Parser.h

raw
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: */