| 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 ([email protected]) |
| 11 | * Copyright (C) 2006, 2007 Andrew Ziem |
| 12 | * Copyright (C) 2004-2006 Fridrich Strba ([email protected]) |
| 13 | * Copyright (C) 2004 Marc Maurer ([email protected]) |
| 14 | * Copyright (C) 2003-2005 William Lachance ([email protected]) |
| 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 <map> |
| 30 | #include <vector> |
| 31 | |
| 32 | #include "libwps_internal.h" |
| 33 | |
| 34 | #include "WPSDebug.h" |
| 35 | |
| 36 | class WPS8Parser; |
| 37 | |
| 38 | namespace WPS8GraphInternal |
| 39 | { |
| 40 | struct State; |
| 41 | } |
| 42 | |
| 43 | /** \brief the main class to read/store pictures in a Pc MS Works document v5-8 |
| 44 | * |
| 45 | * This class must be associated with a WPS8Parser. It contains code to read |
| 46 | * the BDR/WBDR, PICT/MEF4, IBGF entries and to store the pictures which are found |
| 47 | * in the other ole parts. |
| 48 | * |
| 49 | * \note As the pictures seems always be given with characters positions, many functions |
| 50 | * which exists to maintain the same structures that exist in the other WPS*MNGraph classes |
| 51 | * do almost nothing. |
| 52 | */ |
| 53 | class WPS8Graph |
| 54 | { |
| 55 | friend class WPS8Parser; |
| 56 | public: |
| 57 | //! constructor |
| 58 | explicit WPS8Graph(WPS8Parser &parser); |
| 59 | |
| 60 | //! destructor |
| 61 | ~WPS8Graph(); |
| 62 | |
| 63 | //! sets the listener |
| 64 | void setListener(WPSContentListenerPtr &listen) |
| 65 | { |
| 66 | m_listener = listen; |
| 67 | } |
| 68 | |
| 69 | /** computes the final position of all found figures. |
| 70 | * |
| 71 | * In reality, as all the pictures seemed to be given with characters positions, |
| 72 | * it does nothing*/ |
| 73 | void computePositions() const; |
| 74 | |
| 75 | //! returns the number page where we find a picture. In practice, 0/1 |
| 76 | int numPages() const; |
| 77 | |
| 78 | /** sends an object |
| 79 | * \param pos the object position in the document |
| 80 | * \param id the object identificator |
| 81 | * \param ole indicated if we look for objects coming from a ole zone or objects coming from a Pict zone */ |
| 82 | bool sendObject(WPSPosition const &pos, int id, bool ole); |
| 83 | |
| 84 | //! sends data corresponding to a ibgf entry on a given \a pos position |
| 85 | bool sendIBGF(WPSPosition const &pos, int ibgfId); |
| 86 | |
| 87 | /** send all the objects of a given page: |
| 88 | * \param page if page < 0, sends all the pictures which have not been used, |
| 89 | * \param pageToIgnore pictures on this pages are not send |
| 90 | * |
| 91 | * As all the pictures seemed to be given with characters positions, this |
| 92 | * function only does something if page < 0. |
| 93 | */ |
| 94 | void sendObjects(int page, int pageToIgnore=-2); |
| 95 | |
| 96 | protected: |
| 97 | //! returns the file version |
| 98 | int version() const; |
| 99 | |
| 100 | /** sends the border frames. |
| 101 | * |
| 102 | * Actually, sends the eight consecutive pictures which form a border on 3 consecutive lines*/ |
| 103 | void sendBorder(int borderId); |
| 104 | |
| 105 | //! adds a list of object |
| 106 | void storeObjects(std::map<int,WPSEmbeddedObject> const &objectsMap); |
| 107 | |
| 108 | //! finds all entries which correspond to some pictures, parses them and stores data |
| 109 | bool readStructures(RVNGInputStreamPtr const &input); |
| 110 | |
| 111 | // low level |
| 112 | |
| 113 | /** reads a PICT/MEF4 entry : reads uncompressed picture of sx*sy of rgb |
| 114 | * |
| 115 | * This kind of entry seems mainly used to store a background picture */ |
| 116 | bool readPICT(RVNGInputStreamPtr const &input, WPSEntry const &entry); |
| 117 | |
| 118 | /** reads a IBGF zone: an entry to a background picture |
| 119 | * |
| 120 | * This small entry seems to contain only an identificator which pointed to a PICT Zone |
| 121 | */ |
| 122 | bool readIBGF(RVNGInputStreamPtr const &input, WPSEntry const &entry); |
| 123 | |
| 124 | //! parsed BDR/WBDR zone: a complex border formed with 8 pictures |
| 125 | bool readBDR(RVNGInputStreamPtr const &input, WPSEntry const &entry); |
| 126 | |
| 127 | //! returns the debug file |
| 128 | libwps::DebugFile &ascii() |
| 129 | { |
| 130 | return m_asciiFile; |
| 131 | } |
| 132 | private: |
| 133 | WPS8Graph(WPS8Graph const &orig) = delete; |
| 134 | WPS8Graph &operator=(WPS8Graph const &orig) = delete; |
| 135 | |
| 136 | protected: |
| 137 | //! the listener |
| 138 | WPSContentListenerPtr m_listener; |
| 139 | |
| 140 | //! the main parser |
| 141 | WPS8Parser &m_mainParser; |
| 142 | |
| 143 | //! the state |
| 144 | mutable std::shared_ptr<WPS8GraphInternal::State> m_state; |
| 145 | |
| 146 | //! the ascii file |
| 147 | libwps::DebugFile &m_asciiFile; |
| 148 | }; |
| 149 | |
| 150 | #endif |
| 151 | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |