QXP33Parser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libqxp project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef QXP33PARSER_H_INCLUDED
00011 #define QXP33PARSER_H_INCLUDED
00012 
00013 #include "libqxp_utils.h"
00014 #include "QXPParser.h"
00015 
00016 #include <string>
00017 
00018 namespace libqxp
00019 {
00020 
00021 class QXP33Deobfuscator;
00022 class QXP33Header;
00023 
00024 class QXP33Parser : public QXPParser
00025 {
00026 public:
00027   QXP33Parser(const std::shared_ptr<librevenge::RVNGInputStream> &input, librevenge::RVNGDrawingInterface *painter, const std::shared_ptr<QXP33Header> &header);
00028 
00029   enum class ShapeType
00030   {
00031     UNKNOWN,
00032     LINE,
00033     ORTHOGONAL_LINE,
00034     RECTANGLE,
00035     CORNERED_RECTANGLE,
00036     OVAL,
00037     POLYGON
00038   };
00039 
00040   struct ObjectHeader
00041   {
00042     boost::optional<Fill> fill;
00043 
00044     bool runaround;
00045 
00046     unsigned contentIndex;
00047     unsigned linkId;
00048     unsigned gradientId;
00049 
00050     double rotation;
00051     double skew;
00052 
00053     bool hflip;
00054     bool vflip;
00055     CornerType cornerType;
00056     double cornerRadius;
00057 
00058     ContentType contentType;
00059     ShapeType shapeType;
00060 
00061     Rect boundingBox;
00062 
00063     BoxType boxType;
00064 
00065     ObjectHeader()
00066       : fill(), runaround(false), contentIndex(0), linkId(0), gradientId(0),
00067         rotation(0), skew(0), hflip(false), vflip(false), cornerType(CornerType::DEFAULT),
00068         cornerRadius(0), contentType(ContentType::UNKNOWN), shapeType(ShapeType::UNKNOWN), boundingBox(),
00069         boxType(BoxType::UNKNOWN)
00070     { }
00071   };
00072 
00073 private:
00074   const std::shared_ptr<QXP33Header> m_header;
00075 
00076   bool parseDocument(const std::shared_ptr<librevenge::RVNGInputStream> &docStream, QXPCollector &collector) override;
00077   bool parsePages(const std::shared_ptr<librevenge::RVNGInputStream> &pagesStream, QXPCollector &collector) override;
00078 
00079   void parseColors(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
00080   CharFormat parseCharFormat(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
00081   ParagraphFormat parseParagraphFormat(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
00082   std::shared_ptr<HJ> parseHJ(const std::shared_ptr<librevenge::RVNGInputStream> &stream) override;
00083 
00084   Page parsePage(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
00085 
00086   void parseObject(const std::shared_ptr<librevenge::RVNGInputStream> &stream, QXP33Deobfuscator &deobfuscate, QXPCollector &collector, const Page &page, unsigned index);
00087   ObjectHeader parseObjectHeader(const std::shared_ptr<librevenge::RVNGInputStream> &stream, QXP33Deobfuscator &deobfuscate);
00088   void readObjectFlags(const std::shared_ptr<librevenge::RVNGInputStream> &stream, bool &noColor, bool &noRunaround);
00089   void parseLine(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
00090   void parseTextBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
00091   void parsePictureBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
00092   void parseEmptyBox(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector);
00093   void parseGroup(const std::shared_ptr<librevenge::RVNGInputStream> &stream, const ObjectHeader &header, QXPCollector &collector, const Page &page, unsigned index);
00094 
00095   Frame readFrame(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
00096   std::vector<Point> readPolygonData(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
00097 
00098   std::string readName(const std::shared_ptr<librevenge::RVNGInputStream> &stream);
00099 };
00100 
00101 }
00102 
00103 #endif // QXP33PARSER_H_INCLUDED
00104 
00105 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */