WPS8.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwps
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  * Major Contributor(s):
00010  * Copyright (C) 2006, 2007 Andrew Ziem
00011  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00012  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00013  *
00014  * For minor contributions see the git repository.
00015  *
00016  * Alternatively, the contents of this file may be used under the terms
00017  * of the GNU Lesser General Public License Version 2.1 or later
00018  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00019  * applicable instead of those above.
00020  */
00021 
00022 #ifndef WPS8_H
00023 #define WPS8_H
00024 
00025 #include <deque>
00026 #include <vector>
00027 
00028 #include <librevenge/librevenge.h>
00029 
00030 #include "libwps_internal.h"
00031 #include "WPSParser.h"
00032 
00033 class WPSPageSpan;
00034 
00035 namespace WPS8ParserInternal
00036 {
00037 class SubDocument;
00038 struct State;
00039 }
00040 
00041 class WPS8Graph;
00042 class WPS8Table;
00043 class WPS8Text;
00044 
00049 class WPS8Parser : public WPSParser
00050 {
00051         friend class WPS8ParserInternal::SubDocument;
00052         friend class WPS8Graph;
00053         friend class WPS8Table;
00054         friend class WPS8Text;
00055 
00056 public:
00058         WPS8Parser(RVNGInputStreamPtr &input, WPSHeaderPtr &header);
00060         ~WPS8Parser();
00062         void parse(librevenge::RVNGTextInterface *documentInterface);
00063 protected:
00065         bool checkInFile(long pos);
00066 
00068         void newPage(int number);
00070         void setListener(shared_ptr<WPSContentListener> listener);
00072         shared_ptr<WPSContentListener> createListener(librevenge::RVNGTextInterface *interface);
00073 
00075         bool createStructures();
00077         bool createOLEStructures();
00078 
00080         float pageHeight() const;
00082         float pageWidth() const;
00084         int numColumns() const;
00085 
00087         void sendPageFrames();
00088         // interface with text parser
00089 
00091         void sendTextBox(WPSPosition const &pos, int strsid,
00092                          librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList());
00093 
00095         void send(WPSEntry const &entry);
00097         void send(int strsId);
00098 
00100         void sendTextInCell(int strsId, int cellId);
00101 
00102         // interface with table parser
00103 
00105         bool sendTable(Vec2f const &size, int objectId);
00107         int getTableSTRSId(int tableId) const;
00108 
00109         // interface with graph parser
00110 
00116         bool sendObject(Vec2f const &size, int objectId, bool ole);
00117 
00118         //
00119         // low level
00120         //
00121 
00123         bool parseHeaderIndexEntry();
00126         bool parseHeaderIndexEntryEnd(long endPos, WPSEntry &hie,std::string &mess);
00127 
00132         bool parseHeaderIndex();
00133 
00137         bool readDocProperties(WPSEntry const &entry, WPSPageSpan &page);
00138 
00141         bool readFRAM(WPSEntry const &entry);
00142 
00147         bool readSYID(WPSEntry const &entry, std::vector<int> &listId);
00148 
00152         bool readWNPR(WPSEntry const &entry);
00153 
00155         bool readSPELLING(RVNGInputStreamPtr input, std::string const &oleName);
00156 
00157         shared_ptr<WPSContentListener> m_listener; /* the listener (if set)*/
00159         shared_ptr<WPS8Graph> m_graphParser;
00161         shared_ptr<WPS8Table> m_tableParser;
00163         shared_ptr<WPS8Text> m_textParser;
00165         shared_ptr<WPS8ParserInternal::State> m_state;
00166 
00167 private:
00168         std::deque<int> m_sendingTables;
00169 };
00170 
00171 #endif /* WPS8_H */
00172 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */