PDBParser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libe-book
00003  * Version: MPL 2.0 / LGPLv2.1+
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  * Alternatively, the contents of this file may be used under the terms
00010  * of the GNU Lesser General Public License Version 2.1 or later
00011  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00012  * applicable instead of those above.
00013  *
00014  * For further information visit http://libebook.sourceforge.net
00015  */
00016 
00017 #ifndef PDBPARSER_H_INCLUDED
00018 #define PDBPARSER_H_INCLUDED
00019 
00020 #include <vector>
00021 
00022 #include <libwpd/WPXString.h>
00023 
00024 #include "PDXParser.h"
00025 
00026 class WPXDocumentInterface;
00027 class WPXInputStream;
00028 
00029 namespace libebook
00030 {
00031 
00032 class EBOOKCharsetConverter;
00033 
00034 class PDBParser : public PDXParser
00035 {
00036   // disable copying
00037   PDBParser(const PDBParser &);
00038   PDBParser &operator=(const PDBParser &);
00039 
00040 public:
00041   explicit PDBParser(WPXInputStream *input, WPXDocumentInterface *document = 0);
00042   virtual ~PDBParser();
00043 
00044 private:
00045   virtual bool isFormatSupported(unsigned type, unsigned creator);
00046 
00047   virtual void readAppInfoRecord(WPXInputStream *record);
00048   virtual void readSortInfoRecord(WPXInputStream *record);
00049   virtual void readIndexRecord(WPXInputStream *record);
00050   virtual void readDataRecord(WPXInputStream *record, bool last);
00051 
00052   void createConverter(const std::vector<char> &text);
00053 
00054   void openDocument();
00055   void closeDocument();
00056   void handleText(const std::vector<char> &text);
00057   void openParagraph();
00058   void closeParagraph(bool continuing = false);
00059   void handleCharacters(const char *text);
00060 
00061 private:
00062   bool m_compressed;
00063   unsigned m_textLength;
00064   unsigned m_recordCount;
00065   unsigned m_recordSize;
00066   unsigned m_read;
00067 
00077   bool m_openedParagraph;
00078   bool m_openedDocument;
00079 
00080   EBOOKCharsetConverter *m_converter;
00081 };
00082 
00083 }
00084 
00085 #endif // PDBPARSER_H_INCLUDED
00086 
00087 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */