| 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_CHART_H |
| 23 | #define WKS4_CHART_H |
| 24 | |
| 25 | #include <ostream> |
| 26 | #include <map> |
| 27 | #include <vector> |
| 28 | |
| 29 | #include <librevenge-stream/librevenge-stream.h> |
| 30 | |
| 31 | #include "libwps_internal.h" |
| 32 | |
| 33 | #include "WPSDebug.h" |
| 34 | #include "WKSContentListener.h" |
| 35 | |
| 36 | namespace WKS4ChartInternal |
| 37 | { |
| 38 | class Chart; |
| 39 | struct State; |
| 40 | |
| 41 | } |
| 42 | |
| 43 | class WKS4Parser; |
| 44 | |
| 45 | /** |
| 46 | * This class parses Microsoft Works chart file |
| 47 | * |
| 48 | */ |
| 49 | class WKS4Chart |
| 50 | { |
| 51 | public: |
| 52 | friend class WKS4Parser; |
| 53 | friend class WKS4ChartInternal::Chart; |
| 54 | |
| 55 | //! constructor |
| 56 | explicit WKS4Chart(WKS4Parser &parser); |
| 57 | //! destructor |
| 58 | ~WKS4Chart(); |
| 59 | //! sets the listener |
| 60 | void setListener(WKSContentListenerPtr &listen) |
| 61 | { |
| 62 | m_listener = listen; |
| 63 | } |
| 64 | |
| 65 | protected: |
| 66 | //! return true if the pos is in the file, update the file size if need |
| 67 | bool checkFilePosition(long pos); |
| 68 | //! return the file version |
| 69 | int version() const; |
| 70 | |
| 71 | /// reset the main input |
| 72 | void resetInput(RVNGInputStreamPtr const &input); |
| 73 | |
| 74 | //! return the number of chart |
| 75 | int getNumCharts() const; |
| 76 | //! update a chart, so that it can be send |
| 77 | void updateChart(WKS4ChartInternal::Chart &chart); |
| 78 | |
| 79 | //! try to send the charts |
| 80 | bool sendCharts(); |
| 81 | //! try to send the text |
| 82 | bool sendText(WPSEntry const &entry); |
| 83 | |
| 84 | //! reads a structure which define a chart: 2d(default), 2e(name + value) |
| 85 | bool readChart(); |
| 86 | |
| 87 | //! reads the axis(or second yaxis) data: zone 0x14 |
| 88 | bool readChartAxis(); |
| 89 | |
| 90 | //! reads a list of series definition: zone 0x15 |
| 91 | bool readChartSeries(); |
| 92 | |
| 93 | //! reads the series style: zone 0x16 |
| 94 | bool readChartSeriesStyles(); |
| 95 | |
| 96 | //! reads the chart's series color map: zone 0x31 |
| 97 | bool readChartSeriesColorMap(); |
| 98 | //! reads the chart name or title: 41 |
| 99 | bool readChartName(); |
| 100 | |
| 101 | //! reads a structure which seems to define some dimension (only present in windows file): 35 |
| 102 | bool readChartDim(); |
| 103 | //! reads a structure which seems to define two chart font (only present in windows file): 40 |
| 104 | bool readChartFont(); |
| 105 | //! reads a structure which stores zfront, zfar: 44 |
| 106 | bool readChart3D(); |
| 107 | |
| 108 | //! reads a structure which seems to define four chart font (only present in windows file): 84 |
| 109 | bool readChart2Font(); |
| 110 | |
| 111 | //! reads end/begin of chart (only present in windows file): 80,81 |
| 112 | bool readChartLimit(); |
| 113 | |
| 114 | private: |
| 115 | WKS4Chart(WKS4Chart const &orig) = delete; |
| 116 | WKS4Chart &operator=(WKS4Chart const &orig) = delete; |
| 117 | //! returns the debug file |
| 118 | libwps::DebugFile &ascii() |
| 119 | { |
| 120 | return m_asciiFile; |
| 121 | } |
| 122 | /** the input */ |
| 123 | RVNGInputStreamPtr m_input; |
| 124 | std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/ |
| 125 | //! the main parser |
| 126 | WKS4Parser &m_mainParser; |
| 127 | //! the internal state |
| 128 | std::shared_ptr<WKS4ChartInternal::State> m_state; |
| 129 | //! the ascii file |
| 130 | libwps::DebugFile &m_asciiFile; |
| 131 | }; |
| 132 | |
| 133 | #endif /* WPS4_H */ |
| 134 | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |