| 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) 2006, 2007 Andrew Ziem |
| 11 | * Copyright (C) 2003-2005 William Lachance ([email protected]) |
| 12 | * Copyright (C) 2003 Marc Maurer ([email protected]) |
| 13 | * |
| 14 | * For minor contributions see the git repository. |
| 15 | * |
| 16 | * Alternatively, the contents of this file may be used under the terms |
| 17 | * of the GNU Lesser General Public License Version 2.1 or later |
| 18 | * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are |
| 19 | * applicable instead of those above. |
| 20 | */ |
| 21 | |
| 22 | #ifndef WKS4_FORMAT_H |
| 23 | #define WKS4_FORMAT_H |
| 24 | |
| 25 | #include <ostream> |
| 26 | #include <vector> |
| 27 | |
| 28 | #include <librevenge-stream/librevenge-stream.h> |
| 29 | |
| 30 | #include "libwps_internal.h" |
| 31 | |
| 32 | #include "WPSDebug.h" |
| 33 | #include "WKSContentListener.h" |
| 34 | |
| 35 | namespace WKS4FormatInternal |
| 36 | { |
| 37 | class Cell; |
| 38 | class Format; |
| 39 | struct State; |
| 40 | } |
| 41 | |
| 42 | class WKS4Parser; |
| 43 | |
| 44 | /** |
| 45 | * This class parses Lotus format file |
| 46 | * |
| 47 | */ |
| 48 | class WKS4Format |
| 49 | { |
| 50 | public: |
| 51 | friend class WKS4Parser; |
| 52 | |
| 53 | //! constructor |
| 54 | explicit WKS4Format(WKS4Parser &parser, RVNGInputStreamPtr const &input); |
| 55 | //! destructor |
| 56 | ~WKS4Format(); |
| 57 | //! try to parse an input |
| 58 | bool parse(); |
| 59 | |
| 60 | protected: |
| 61 | //! return true if the pos is in the file, update the file size if need |
| 62 | bool checkFilePosition(long pos); |
| 63 | |
| 64 | // |
| 65 | // low level |
| 66 | // |
| 67 | //////////////////////// format zone ////////////////////////////// |
| 68 | //! checks if the document header is correct (or not) |
| 69 | bool checkHeader(bool strict=false); |
| 70 | /** finds the different zones */ |
| 71 | bool readZones(); |
| 72 | //! reads a zone |
| 73 | bool readZone(); |
| 74 | |
| 75 | //! reads a format font name: zones 0xae |
| 76 | bool readFontName(); |
| 77 | //! reads a format font sizes zones 0xaf and 0xb1 |
| 78 | bool readFontSize(); |
| 79 | //! reads a format font id zone: 0xb0 |
| 80 | bool readFontId(); |
| 81 | |
| 82 | private: |
| 83 | WKS4Format(WKS4Format const &orig) = delete; |
| 84 | WKS4Format &operator=(WKS4Format const &orig) = delete; |
| 85 | //! returns the debug file |
| 86 | libwps::DebugFile &ascii() |
| 87 | { |
| 88 | return m_asciiFile; |
| 89 | } |
| 90 | /** the input */ |
| 91 | RVNGInputStreamPtr m_input; |
| 92 | //! the main parser |
| 93 | WKS4Parser &m_mainParser; |
| 94 | //! the internal state |
| 95 | std::shared_ptr<WKS4FormatInternal::State> m_state; |
| 96 | //! the ascii file |
| 97 | libwps::DebugFile m_asciiFile; |
| 98 | }; |
| 99 | |
| 100 | #endif /* WPS4_H */ |
| 101 | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |