WPS8.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 WPS8_H
00023 #define WPS8_H
00024 
00025 #include <vector>
00026 #include <list>
00027 #include <map>
00028 #include <libwpd/WPXString.h>
00029 
00030 #include "libwps_internal.h"
00031 #include "WPS.h"
00032 #include "WPSContentListener.h"
00033 #include <libwpd-stream/WPXStream.h>
00034 #include "WPSParser.h"
00035 
00041 class HeaderIndexEntries
00042 {
00043 public:
00044         uint32_t offset;
00045         uint32_t length;
00046 };
00047 
00048 typedef std::multimap <std::string, HeaderIndexEntries> HeaderIndexMultiMap; /* string is name */
00049 
00050 class WPS8ContentListener : public WPSContentListener
00051 {
00052 public:
00053         WPS8ContentListener(std::list<WPSPageSpan> &pageList, WPXDocumentInterface *documentInterface);
00054         ~WPS8ContentListener();
00055 
00056         void attributeChange(const bool isOn, const uint8_t attribute);
00057 
00058 private:
00059         WPS8ContentListener(const WPS8ContentListener&);
00060         WPS8ContentListener& operator=(const WPS8ContentListener&);
00061 };
00062 
00063 struct WPSRange
00064 {
00065         uint32_t start;
00066         uint32_t limit;
00067         WPSRange() : start(0), limit(0) {}
00068         ~WPSRange() {}
00069 };
00070 
00071 struct WPSStream
00072 {
00073         uint32_t type;
00074         WPSRange span;
00075         WPSStream() : type(0), span() {}
00076         ~WPSStream() {}
00077 };
00078 
00079 struct WPSNote
00080 {
00081         uint32_t offset;
00082         WPSRange contents;
00083 };
00084 
00085 #define WPS_STREAM_DUMMY 0
00086 #define WPS_STREAM_BODY  1
00087 #define WPS_STREAM_FOOTNOTES 2
00088 #define WPS_STREAM_ENDNOTES 3
00089 
00090 #define WPS_NUM_SEP_PAR  0x0
00091 #define WPS_NUM_SEP_DOT  0x2
00092 
00093 class WPS8Parser : public WPSParser
00094 {
00095 public:
00096         WPS8Parser(WPXInputStream *input, WPSHeader * header);
00097         ~WPS8Parser();
00098 
00099         void parse(WPXDocumentInterface *documentInterface);
00100 private:
00101         void readFontsTable(WPXInputStream * input);
00102         void readStreams(WPXInputStream * input);
00103         void readNotes(std::vector<WPSNote> &dest, WPXInputStream * input, const char *key);
00104         void appendUTF16LE(WPXInputStream *input, WPS8ContentListener *listener);
00105         void readText(WPXInputStream * input, WPS8ContentListener *listener);
00106         void readTextRange(WPXInputStream * input, WPS8ContentListener *listener, uint32_t startpos, uint32_t endpos, uint16_t stream);
00107         void readNote(WPXInputStream * input, WPS8ContentListener *listener, bool is_endnote);
00108         bool readFODPage(WPXInputStream * input, std::vector<FOD> * FODs, uint16_t page_size);
00109         void parseHeaderIndexEntry(WPXInputStream * input);
00110         void parseHeaderIndex(WPXInputStream * input);
00111         void parsePages(std::list<WPSPageSpan> &pageList, WPXInputStream *input);
00112         void parse(WPXInputStream *stream, WPS8ContentListener *listener);
00113         void propertyChangeTextAttribute(const uint32_t newTextAttributeBits, const uint8_t attribute, const uint32_t bit, WPS8ContentListener *listener);
00114         void propertyChangeDelta(uint32_t newTextAttributeBits, WPS8ContentListener *listener);
00115         void propertyChange(std::string rgchProp, WPS8ContentListener *listener);
00116         void propertyChangePara(std::string rgchProp, WPS8ContentListener *listener);
00117         uint32_t offset_eot; /* stream offset to end of text */
00118         uint32_t oldTextAttributeBits;
00119         HeaderIndexMultiMap headerIndexTable;
00120         std::vector<FOD> CHFODs; /* CHaracter FOrmatting Descriptors */         
00121         std::vector<FOD> PAFODs; /* PAragraph FOrmatting Descriptors */         
00122         std::vector<std::string> fonts;
00123         std::vector<WPSStream> streams;
00124         std::vector<WPSNote> footnotes;
00125         std::vector<WPSNote> endnotes;
00126 
00127         std::vector<WPSNote>::iterator fn_iter;
00128         std::vector<WPSNote>::iterator en_iter;
00129 };
00130 
00131 
00132 #endif /* WPS8_H */