1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 2 /* libwps 3 * Version: MPL 2.0 / LGPLv2.1+ 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * Major Contributor(s): 10 * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr) 11 * Copyright (C) 2006, 2007 Andrew Ziem 12 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch) 13 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net) 14 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca) 15 * 16 * For minor contributions see the git repository. 17 * 18 * Alternatively, the contents of this file may be used under the terms 19 * of the GNU Lesser General Public License Version 2.1 or later 20 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are 21 * applicable instead of those above. 22 * 23 * For further information visit http://libwps.sourceforge.net 24 */ 25 26 #ifndef WPS8_GRAPH 27 # define WPS8_GRAPH 28 29 #include <list> 30 #include <vector> 31 32 #include "libwps_internal.h" 33 34 #include "WPSDebug.h" 35 36 struct WPSOLEParserObject; 37 class WPS8Parser; 38 39 namespace WPS8GraphInternal 40 { 41 struct State; 42 } 43 44 /** \brief the main class to read/store pictures in a Pc MS Works document v5-8 45 * 46 * This class must be associated with a WPS8Parser. It contains code to read 47 * the BDR/WBDR, PICT/MEF4, IBGF entries and to store the pictures which are found 48 * in the other ole parts. 49 * 50 * \note As the pictures seems always be given with characters positions, many functions 51 * which exists to maintain the same structures that exist in the other WPS*MNGraph classes 52 * do almost nothing. 53 */ 54 class WPS8Graph 55 { 56 friend class WPS8Parser; 57 public: 58 //! constructor 59 WPS8Graph(WPS8Parser &parser); 60 61 //! destructor 62 ~WPS8Graph(); 63 64 //! sets the listener setListener(WPSContentListenerPtr & listen)65 void setListener(WPSContentListenerPtr &listen) 66 { 67 m_listener = listen; 68 } 69 70 /** computes the final position of all found figures. 71 * 72 * In reality, as all the pictures seemed to be given with characters positions, 73 * it does nothing*/ 74 void computePositions() const; 75 76 //! returns the number page where we find a picture. In practice, 0/1 77 int numPages() const; 78 79 /** sends an object 80 * \param pos the object position in the document 81 * \param id the object identificator 82 * \param ole indicated if we look for objects coming from a ole zone or objects coming from a Pict zone */ 83 bool sendObject(WPSPosition const &pos, int id, bool ole); 84 85 //! sends data corresponding to a ibgf entry on a given \a pos position 86 bool sendIBGF(WPSPosition const &pos, int ibgfId); 87 88 /** send all the objects of a given page: 89 * \param page if page < 0, sends all the pictures which have not been used, 90 * \param pageToIgnore pictures on this pages are not send 91 * 92 * As all the pictures seemed to be given with characters positions, this 93 * function only does something if page < 0. 94 */ 95 void sendObjects(int page, int pageToIgnore=-2); 96 97 protected: 98 //! returns the file version 99 int version() const; 100 101 /** sends the border frames. 102 * 103 * Actually, sends the eight consecutive pictures which form a border on 3 consecutive lines*/ 104 void sendBorder(int borderId); 105 106 //! adds a list of objects with given ids in the ole lists 107 void storeObjects(std::vector<WPSOLEParserObject> const &objects, 108 std::vector<int> const &ids); 109 110 //! finds all entries which correspond to some pictures, parses them and stores data 111 bool readStructures(RVNGInputStreamPtr input); 112 113 // low level 114 115 /** reads a PICT/MEF4 entry : reads uncompressed picture of sx*sy of rgb 116 * 117 * This kind of entry seems mainly used to store a background picture */ 118 bool readPICT(RVNGInputStreamPtr input, WPSEntry const &entry); 119 120 /** reads a IBGF zone: an entry to a background picture 121 * 122 * This small entry seems to contain only an identificator which pointed to a PICT Zone 123 */ 124 bool readIBGF(RVNGInputStreamPtr input, WPSEntry const &entry); 125 126 //! parsed BDR/WBDR zone: a complex border formed with 8 pictures 127 bool readBDR(RVNGInputStreamPtr input, WPSEntry const &entry); 128 129 /** \brief reads METAFILE/CODE 130 * 131 * \warning we must probably also recognize the enhanced metafile format: EMF */ 132 bool readMetaFile(RVNGInputStreamPtr input, long endPos, librevenge::RVNGBinaryData &pict); 133 134 //! returns the debug file ascii()135 libwps::DebugFile &ascii() 136 { 137 return m_asciiFile; 138 } 139 private: 140 WPS8Graph(WPS8Graph const &orig); 141 WPS8Graph &operator=(WPS8Graph const &orig); 142 143 protected: 144 //! the listener 145 WPSContentListenerPtr m_listener; 146 147 //! the main parser 148 WPS8Parser &m_mainParser; 149 150 //! the state 151 mutable shared_ptr<WPS8GraphInternal::State> m_state; 152 153 //! the ascii file 154 libwps::DebugFile &m_asciiFile; 155 }; 156 157 #endif 158 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ 159