Debian Codegraph @

src/lib/QXP4Parser.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 QXP4PARSER_H_INCLUDED
11 #define QXP4PARSER_H_INCLUDED
12
13 #include "QXPParser.h"
14 #include <vector>
15
16 namespace libqxp
17 {
18
19 class QXP4Deobfuscator;
20 class QXP4Header;
21
22 class QXP4Parser : public QXPParser
23 {
24 public:
25 QXP4Parser(const std::shared_ptr<librevenge::RVNGInputStream> &input, librevenge::RVNGDrawingInterface *painter, const std::shared_ptr<QXP4Header> &header);
26
27 enum class ShapeType
28 {
29 UNKNOWN,
30 LINE,
31 ORTHOGONAL_LINE,
32 BEZIER_LINE,
33 RECTANGLE,
34 ROUNDED_RECTANGLE,
35 CONCAVE_RECTANGLE,
36 BEVELED_RECTANGLE,
37 OVAL,
38 BEZIER_BOX
39 };
40
41 struct ObjectHeader
42 {
43 boost::optional<Color> fillColor;
44 Color color;
45
46 unsigned contentIndex;
47 unsigned linkId;
48 unsigned oleId;
49 unsigned gradientId;
50
51 double rotation;
52 double skew;
53
54 bool hflip;
55 bool vflip;
56
57 ContentType contentType;
58 ShapeType shapeType;
59
60 BoxType boxType;
61 CornerType cornerType;
62
63 ObjectHeader()
64 : fillColor(), color(), contentIndex(0), linkId(0), oleId(0), gradientId(0),
65 rotation(0), skew(0), hflip(false), vflip(false),
66 contentType(ContentType::UNKNOWN), shapeType(ShapeType::UNKNOWN),
67 boxType(BoxType::UNKNOWN), cornerType(CornerType::DEFAULT)
68 { }
69 };
70
71 private:
72 struct ColorBlockSpec
73 {
74 unsigned offset;
75 unsigned padding;
76
77 ColorBlockSpec()
78 : offset(0), padding(0)
79 { }
80 };
81
82 const std::shared_ptr<QXP4Header> m_header;
83
84 std::vector<std::vector<TabStop>> m_paragraphTabStops;
85
86 bool parseDocument(const std::shared_ptr<librevenge::RVNGInputStream> &docStream, QXPCollector &collector) override;
87 bool parsePages(const std::shared_ptr<librevenge::RVNGInputStream> &stream, QXPCollector &collector) override;
88
89 void parseColors(const std::shared_ptr<librevenge::RVNGInputStream> &docStream);
90 ColorBlockSpec parseColorBlockSpec(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
91 void parseColor(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const std::vector<ColorBlockSpec> &blocks);
92 void skipParagraphStylesheets(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
93 CharFormat parseCharFormat(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
94 void parseLineStyles(const std::shared_ptr<librevenge::RVNGInputStream> &docStream);
95 void skipTemplates(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
96 void parseTabStops(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
97 ParagraphFormat parseParagraphFormat(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
98 std::shared_ptr<HJ> parseHJ(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
99
100 Page parsePage(const std::shared_ptr<librevenge::RVNGInputStream> &stream, QXP4Deobfuscator &deobfuscate);
101
102 void parseObject(const std::shared_ptr<librevenge::RVNGInputStream> &stream, QXP4Deobfuscator &deobfuscate, QXPCollector &collector, const Page &page, unsigned index);
103 ObjectHeader parseObjectHeader(const std::shared_ptr<librevenge::RVNGInputStream> &stream, QXP4Deobfuscator &deobfuscate);
104 void parseLine(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
105 void parseBezierLine(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
106 void parseBezierEmptyBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
107 void parseEmptyBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
108 void parseBezierPictureBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
109 void parsePictureBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
110 void parseLineText(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
111 void parseBezierText(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
112 void parseBezierTextBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
113 void parseTextBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
114 void parseGroup(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector, const Page &page, unsigned index);
115
116 Frame readFrame(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
117 bool readRunaround(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
118 void readLinkedTextSettings(const std::shared_ptr<librevenge::RVNGInputStream> &stream, LinkedTextSettings &settings);
119 void readTextSettings(const std::shared_ptr<librevenge::RVNGInputStream> &stream, TextSettings &settings);
120 void readTextPathSettings(const std::shared_ptr<librevenge::RVNGInputStream> &stream, TextPathSettings &settings);
121 void readOleObject(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
122 void readPictureSettings(const std::shared_ptr<librevenge::RVNGInputStream> &stream, std::shared_ptr<PictureBox> &picturebox);
123 void readImageData(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
124 void readBezierData(const std::shared_ptr<librevenge::RVNGInputStream> &stream, std::vector<CurveComponent> &curveComponents, Rect &bbox);
125 void skipTextObjectEnd(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, const LinkedTextSettings &linkedTextSettings);
126 };
127
128 }
129
130 #endif // QXP4PARSER_H_INCLUDED
131
132 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */