MSWrite.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) 2015 Sean Young <sean@mess.org>
00011  *
00012  * For minor contributions see the git repository.
00013  *
00014  * Alternatively, the contents of this file may be used under the terms
00015  * of the GNU Lesser General Public License Version 2.1 or later
00016  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00017  * applicable instead of those above.
00018  *
00019  * For further information visit http://libwps.sourceforge.net
00020  */
00021 
00022 #ifndef MS_WRITE_H
00023 #define MS_WRITE_H
00024 
00025 #include <vector>
00026 
00027 #include <librevenge-stream/librevenge-stream.h>
00028 #include "libwps_internal.h"
00029 #include "libwps_tools_win.h"
00030 
00031 #include "WPSParser.h"
00032 #include "WPSEntry.h"
00033 #include "WPSPageSpan.h"
00034 
00035 namespace MSWriteParserInternal
00036 {
00037 class SubDocument;
00038 struct Paragraph;
00039 struct Font;
00040 }
00041 
00046 class MSWriteParser : public WPSParser
00047 {
00048         friend class MSWriteParserInternal::SubDocument;
00049         friend struct MSWriteParserInternal::Paragraph;
00050         friend struct MSWriteParserInternal::Font;
00051 
00052 public:
00053         MSWriteParser(RVNGInputStreamPtr &input, WPSHeaderPtr &header,
00054                       libwps_tools_win::Font::Type encoding=libwps_tools_win::Font::WIN3_WEUROPE);
00055 
00056 
00057         ~MSWriteParser();
00058         void parse(librevenge::RVNGTextInterface *const documentInterface);
00059 
00060 private:
00061         MSWriteParser(const MSWriteParser &);
00062         MSWriteParser &operator=(const MSWriteParser &);
00063 
00064         shared_ptr<WPSContentListener> createListener(librevenge::RVNGTextInterface *interface);
00065         void readFIB();
00066         void readFFNTB();
00067         void readSECT();
00068         void readPAP();
00069         void readCHP();
00070         void findZones();
00071         void readText(WPSEntry e);
00072         void processObject(WPSPosition &pos, unsigned long lastPos);
00073         bool processDDB(librevenge::RVNGBinaryData &bmpdata, WPSPosition &pos, unsigned width, unsigned height, unsigned byte_width, unsigned planes, unsigned bits_pixel, unsigned size);
00074         bool processDIB(librevenge::RVNGBinaryData &bmpdata, unsigned size);
00075         bool processWMF(librevenge::RVNGBinaryData &wmfdata, unsigned size);
00076         void processEmbeddedOLE(WPSPosition &pos, unsigned long lastPos);
00077         bool processStaticOLE(librevenge::RVNGBinaryData &, std::string &mimetype, WPSPosition &pos, unsigned long lastPos);
00078         bool readString(std::string &res, unsigned long lastPos);
00079         unsigned insertString(const unsigned char *str, unsigned size, libwps_tools_win::Font::Type type);
00080 
00082         bool checkFilePosition(uint32_t pos) const
00083         {
00084                 return pos<=m_fileLength;
00085         }
00086         // State
00088         uint32_t m_fileLength;
00089         uint32_t m_fcMac;
00090 
00091         std::vector<MSWriteParserInternal::Paragraph> m_paragraphList;
00092         std::vector<MSWriteParserInternal::Font> m_fontList;
00093         std::vector<librevenge::RVNGString> m_fonts;
00094         WPSPageSpan m_pageSpan;
00095         libwps_tools_win::Font::Type m_fontType;
00096 
00097         shared_ptr<WPSContentListener> m_listener; /* the listener (if set)*/
00098 
00099         WPSEntry m_Main, m_Header, m_Footer;
00100         bool m_HeaderPage1, m_FooterPage1;
00101 };
00102 
00103 #endif /* MS_WRITE_H */
00104 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */