[go: up one dir, main page]

Menu

[23fa7c]: / src / lib / LotusChart.h  Maximize  Restore  History

Download this file

143 lines (124 with data), 4.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* libwps
* Version: MPL 2.0 / LGPLv2.1+
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Major Contributor(s):
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
* Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms
* of the GNU Lesser General Public License Version 2.1 or later
* (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
* applicable instead of those above.
*/
#ifndef LOTUS_CHART_H
#define LOTUS_CHART_H
#include <ostream>
#include <string>
#include <map>
#include <vector>
#include <librevenge-stream/librevenge-stream.h>
#include "libwps_internal.h"
#include "WPSDebug.h"
#include "WKSChart.h"
#include "WKSContentListener.h"
#include "Lotus.h"
namespace LotusChartInternal
{
class Chart;
struct State;
}
class LotusStyleManager;
class WPSGraphicStyle;
/**
* This class parses Microsoft Works chart file
*
*/
class LotusChart
{
public:
friend class LotusParser;
friend class LotusChartInternal::Chart;
//! constructor
explicit LotusChart(LotusParser &parser);
//! clean internal state
void cleanState();
//! update internal state (must be called one time before sending data)
void updateState();
//! destructor
~LotusChart();
//! sets the listener
void setListener(WKSContentListenerPtr &listen)
{
m_listener = listen;
}
protected:
//! return the file version
int version() const;
//! return the number of chart
int getNumCharts() const;
//! returns a map chart name to chart id map
std::map<std::string,int> getNameToChartIdMap() const;
//! update a chart, so that it can be send
void updateChart(LotusChartInternal::Chart &chart, int id);
//! try to send the charts(for Windows .wk3 file)
bool sendCharts();
//! try to send a chart
bool sendChart(int cId, WPSPosition const &pos, WPSGraphicStyle const &style);
//! try to send the text
bool sendText(std::shared_ptr<WPSStream> stream, WPSEntry const &entry);
//! reads a structure which define a chart: 11
bool readChart(std::shared_ptr<WPSStream> stream);
//! reads the chart name or title: 12
bool readChartName(std::shared_ptr<WPSStream> stream);
// zone 1b
//! reads a chart data: 2710 (wk3mac)
bool readMacHeader(std::shared_ptr<WPSStream> stream, long endPos, int &chartId);
//! reads a placement position(wk3mac): 2774
bool readMacPlacement(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a legend position(wk3mac): 277e
bool readMacLegend(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a plot area position(wk3mac): 2788
bool readMacPlotArea(std::shared_ptr<WPSStream> stream, long endPos);
//! reads an axis style(wk3mac): 27d8
bool readMacAxis(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a serie style(wk3mac): 27e2
bool readMacSerie(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a 3D floor style(wk3mac): 2846
bool readMacFloor(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a manual position(wk3mac): 2904
bool readMacPosition(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a plot area style: 2a30 (unsure)
bool readPlotArea(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a serie style: 2a31
bool readSerie(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a serie name: 2a32 (serie 6-...)
bool readSerieName(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a serie width style: 2a33
bool readSerieWidth(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a list of font style: 2a34
bool readFontsStyle(std::shared_ptr<WPSStream> stream, long endPos);
//! reads a some frame styles: 2a35
bool readFramesStyle(std::shared_ptr<WPSStream> stream, long endPos);
//! convert a link zone in a chart position(if possible)
bool convert(LotusParser::Link const &link, WKSChart::Position(&positions)[2]) const;
private:
LotusChart(LotusChart const &orig) = delete;
LotusChart &operator=(LotusChart const &orig) = delete;
std::shared_ptr<WKSContentListener> m_listener; /** the listener (if set)*/
//! the main parser
LotusParser &m_mainParser;
//! the style manager
std::shared_ptr<LotusStyleManager> m_styleManager;
//! the internal state
std::shared_ptr<LotusChartInternal::State> m_state;
};
#endif /* WPS4_H */
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */