WPS4.h
Go to the documentation of this file.
00001 /* libwpd
00002  * Copyright (C) 2006, 2007 Andrew Ziem
00003  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00004  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00005  *  
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00019  *
00020  */
00021 
00022 #ifndef WPS4_H
00023 #define WPS4_H
00024 
00025 #include <vector>
00026 #include <map>
00027 
00028 #include "libwps_internal.h"
00029 #include "WPS.h"
00030 #include "WPSContentListener.h"
00031 #include "WPSHeader.h"
00032 #include <libwpd-stream/WPXStream.h>
00033 #include <libwpd/WPXString.h>
00034 #include "WPSParser.h"
00035 
00036 
00037 class WPS4ContentListener : public WPSContentListener
00038 {
00039 public:
00040         WPS4ContentListener(std::list<WPSPageSpan> &pageList, WPXDocumentInterface *documentInterface);
00041         ~WPS4ContentListener();
00042 
00043         void attributeChange(const bool isOn, const uint8_t attribute);
00044 
00045         int getCodepage();
00046 
00047 private:
00048         WPS4ContentListener(const WPS4ContentListener&);
00049         WPS4ContentListener& operator=(const WPS4ContentListener&);
00050 };
00051 
00052 struct wpsfont
00053 {
00054         std::string name;
00055         int cp;
00056         wpsfont() : name(), cp(0) {}
00057 };
00058 
00059 class WPS4Parser : public WPSParser
00060 {
00061 public:
00062         WPS4Parser(WPXInputStream *input, WPSHeader * header);
00063         ~WPS4Parser();
00064 
00065         void parse(WPXDocumentInterface *documentInterface);
00066 private:
00067         void parsePages(std::list<WPSPageSpan> &pageList, WPXInputStream *input);
00068         void parse(WPXInputStream *stream, WPS4ContentListener *listener);
00069         void readFontsTable(WPXInputStream * input);
00070         bool readFODPage(WPXInputStream * input, std::vector<FOD> * FODs);      
00071         void propertyChangeTextAttribute(const uint32_t newTextAttributeBits, const uint8_t attribute, const uint32_t bit, WPS4ContentListener *listener);
00072         void propertyChangeDelta(uint32_t newTextAttributeBits, WPS4ContentListener *listener);
00073         void propertyChange(std::string rgchProp, WPS4ContentListener *listener);
00074         void propertyChangePara(std::string rgchProp, WPS4ContentListener *listener);
00075         void appendCP(const uint8_t readVal, int codepage, WPS4ContentListener *listener);
00076         void appendUCS(const uint16_t readVal, WPS4ContentListener *listener);
00077         void appendCP850(const uint8_t readVal, WPS4ContentListener *listener);
00078         void appendCP1252(const uint8_t readVal, WPS4ContentListener *listener);
00079         void readText(WPXInputStream * input, WPS4ContentListener *listener);
00080         uint32_t oldTextAttributeBits;
00081         uint32_t offset_eot; /* stream offset to end of text */
00082         uint32_t offset_eos; /* stream offset to end of MN0 */  
00083         std::vector<FOD> CHFODs; /* CHaracter FOrmatting Descriptors */         
00084         std::vector<FOD> PAFODs; /* PAragraph FOrmatting Descriptors */                 
00085         std::map<uint8_t, wpsfont> fonts; /* fonts in format <index code, <font name, codepage>>  */
00086         const uint8_t m_worksVersion;
00087 };
00088 
00089 #endif /* WPS6_H */