/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * This file is part of the libqxp project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef QXPPARSER_H_INCLUDED #define QXPPARSER_H_INCLUDED #include "libqxp_utils.h" #include "QXPBlockParser.h" #include "QXPTextParser.h" #include "QXPTypes.h" #include #include #include #include #include namespace libqxp { class QXPCollector; class QXPHeader; class QXPParser { // disable copying QXPParser(const QXPParser &other) = delete; QXPParser &operator=(const QXPParser &other) = delete; public: QXPParser(const std::shared_ptr &input, librevenge::RVNGDrawingInterface *painter, const std::shared_ptr &header); virtual ~QXPParser() = default; bool parse(); protected: const std::shared_ptr m_input; librevenge::RVNGDrawingInterface *m_painter; const bool be; // big endian QXPBlockParser m_blockParser; QXPTextParser m_textParser; std::map m_colors; std::map m_fonts; std::vector> m_charFormats; std::vector> m_paragraphFormats; std::map m_lineStyles; std::vector m_arrows; std::deque> m_hjs; std::set m_groupObjects; Color getColor(unsigned id, Color defaultColor = Color(0, 0, 0)) const; const LineStyle *getLineStyle(unsigned id) const; std::string getFont(int id, std::string defaultFont = "Arial") const; void convertCharFormatFlags(unsigned flags, CharFormat &format); TabStopType convertTabStopType(unsigned type); virtual bool parseDocument(const std::shared_ptr &docStream, QXPCollector &collector) = 0; virtual bool parsePages(const std::shared_ptr &stream, QXPCollector &collector) = 0; void skipRecord(const std::shared_ptr &stream); void parseFonts(const std::shared_ptr &stream); void parseHJs(const std::shared_ptr &stream); void parseCharFormats(const std::shared_ptr &stream); void parseCommonCharFormatProps(const std::shared_ptr &stream, CharFormat &result); void parseHJProps(const std::shared_ptr &stream, HJ &result); TabStop parseTabStop(const std::shared_ptr &stream); void parseParagraphFormats(const std::shared_ptr &stream); virtual CharFormat parseCharFormat(const std::shared_ptr &stream) = 0; virtual ParagraphFormat parseParagraphFormat(const std::shared_ptr &stream) = 0; virtual std::shared_ptr parseHJ(const std::shared_ptr &stream) = 0; void parseCollection(const std::shared_ptrstream, std::function itemHandler); std::vector parsePageSettings(const std::shared_ptr &stream); std::shared_ptr parseText(unsigned index, unsigned linkId, QXPCollector &collector); uint32_t readRecordEndOffset(const std::shared_ptr &stream); uint8_t readColorComp(const std::shared_ptr &stream); Rect readObjectBBox(const std::shared_ptr &stream); Gradient readGradient(const std::shared_ptr &stream, const Color &color1); HorizontalAlignment readHorAlign(const std::shared_ptr &stream); VerticalAlignment readVertAlign(const std::shared_ptr &stream); Point readYX(const std::shared_ptr &stream); std::shared_ptr readParagraphRule(const std::shared_ptr &stream); uint8_t readParagraphFlags(const std::shared_ptr &stream, bool &incrementalLeading, bool &ruleAbove, bool &ruleBelow); uint8_t readObjectFlags(const std::shared_ptr &stream, bool &noColor); void readGroupElements(const std::shared_ptr &stream, unsigned count, unsigned objectsCount, unsigned index, std::vector &elements); void setArrow(const unsigned index, Frame &frame) const; void skipFileInfo(const std::shared_ptr &stream); private: const std::shared_ptr m_header; }; } #endif // QXPPARSER_H_INCLUDED /* vim:set shiftwidth=2 softtabstop=2 expandtab: */