WPS4.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwpd
00003  * Copyright (C) 2006, 2007 Andrew Ziem
00004  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00005  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00020  *
00021  */
00022 
00023 #ifndef WPS4_H
00024 #define WPS4_H
00025 
00026 #include <vector>
00027 #include <map>
00028 
00029 #include <libwpd-stream/WPXStream.h>
00030 #include "libwps_internal.h"
00031 #include "WPSDebug.h"
00032 
00033 #include "WPSParser.h"
00034 
00035 class WPXString;
00036 class WPSContentListener;
00037 typedef WPSContentListener WPS4ContentListener;
00038 class WPSEntry;
00039 class WPSPosition;
00040 class WPSPageSpan;
00041 
00042 namespace WPS4ParserInternal
00043 {
00044 class SubDocument;
00045 struct State;
00046 }
00047 
00048 class WPS4Graph;
00049 class WPS4Text;
00050 
00055 class WPS4Parser : public WPSParser
00056 {
00057         friend class WPS4ParserInternal::SubDocument;
00058         friend class WPS4Graph;
00059         friend class WPS4Text;
00060 
00061 public:
00063         WPS4Parser(WPXInputStreamPtr &input, WPSHeaderPtr &header);
00065         ~WPS4Parser();
00067         void parse(WPXDocumentInterface *documentInterface);
00068 protected:
00070         int version() const;
00072         bool getColor(int id, uint32_t &color) const;
00073 
00075         long getSizeFile() const;
00077         void setSizeFile(long sz);
00079         bool checkInFile(long pos);
00080 
00082         void newPage(int number);
00084         void setListener(shared_ptr<WPS4ContentListener> listener);
00085 
00087         bool createStructures();
00089         bool createOLEStructures();
00091         shared_ptr<WPS4ContentListener> createListener(WPXDocumentInterface *interface);
00092 
00093         // interface with text parser
00094 
00096         float pageHeight() const;
00098         float pageWidth() const;
00100         int numColumns() const;
00101 
00105         void createDocument(WPSEntry const &entry, libwps::SubDocumentType type);
00107         void createNote(WPSEntry const &entry, WPXString const &label);
00109         void createTextBox(WPSEntry const &entry, WPSPosition const &pos, WPXPropertyList &extras);
00111         void send(WPSEntry const &entry, libwps::SubDocumentType type);
00112 
00113         // interface with graph parser
00114 
00118         int readObject(WPXInputStreamPtr input, WPSEntry const &entry);
00119 
00123         void sendObject(Vec2f const &size, int id);
00124 
00125         //
00126         // low level
00127         //
00128 
00130         bool findZones();
00131 
00135         bool parseEntry(std::string const &name);
00136 
00138         bool readDocDim();
00139 
00141         bool readPrnt(WPSEntry const &entry);
00142 
00147         bool readDocWindowsInfo(WPSEntry const &entry);
00148 
00150         libwps::DebugFile &ascii()
00151         {
00152                 return m_asciiFile;
00153         }
00154 
00155         shared_ptr<WPS4ContentListener> m_listener; /* the listener (if set)*/
00157         shared_ptr<WPS4Graph> m_graphParser;
00159         shared_ptr<WPS4Text> m_textParser;
00161         shared_ptr<WPS4ParserInternal::State> m_state;
00162 
00164         typedef std::multimap <std::string, WPSEntry> NameMultiMap;
00166         NameMultiMap m_nameMultiMap;
00168         libwps::DebugFile m_asciiFile;
00169 };
00170 
00171 #endif /* WPS4_H */
00172 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */