PMDParser.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 libpagemaker 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 __PMDPARSER_H__
00011 #define __PMDPARSER_H__
00012 
00013 #include <librevenge/librevenge.h>
00014 
00015 #include <stdint.h>
00016 #include <map>
00017 #include <set>
00018 
00019 #include "PMDRecord.h"
00020 #include "geometry.h"
00021 
00022 namespace libpagemaker
00023 {
00024 
00025 class PMDCollector;
00026 class PMDParser
00027 {
00028   librevenge::RVNGInputStream *m_input;
00029   unsigned long m_length;
00030   PMDCollector *m_collector;
00031   std::map<uint16_t, std::vector<unsigned> > m_records;
00032   bool m_bigEndian;
00033   std::vector<PMDRecordContainer> m_recordsInOrder;
00034   std::map<uint32_t, PMDXForm> m_xFormMap;
00035 
00036   /* Private functions. */
00037   void parseGlobalInfo(const PMDRecordContainer &container);
00038   void parseFonts();
00039   void parseColors();
00040   void parsePages(const PMDRecordContainer &container);
00041   void parseShapes(uint16_t seqNum, unsigned pageID);
00042   void parseLine(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
00043   void parseTextBox(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
00044   void parseRectangle(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
00045   void parsePolygon(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
00046   void parseEllipse(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
00047   void parseBitmap(const PMDRecordContainer &container, unsigned recordIndex, unsigned pageID);
00048   void parseHeader(uint32_t *tocOffset, uint16_t *tocLength);
00049   unsigned readNextRecordFromTableOfContents(std::set<unsigned long> &tocOffsets, unsigned &seqNum);
00050   void parseTableOfContents(uint32_t offset, uint16_t length);
00051   std::vector<PMDRecordContainer> getRecordsBySeqNum(const uint16_t seqNum);
00052   std::vector<PMDRecordContainer> getRecordsByRecType(const uint16_t recType);
00053   const PMDRecordContainer &getSingleRecordBySeqNum(const uint16_t seqNum) const;
00054   void parseXforms();
00055   const PMDXForm &getXForm(const uint32_t xFormId) const;
00056 
00057   /* Prevent copy and assignment */
00058   PMDParser &operator=(const PMDParser &);
00059   PMDParser(const PMDParser &);
00060 public:
00061   PMDParser(librevenge::RVNGInputStream *, PMDCollector *);
00062   void parse();
00063 };
00064 
00065 }
00066 
00067 #endif /* __PMDPARSER_H__ */
00068 
00069 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */