MWAWChart.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 /*
35 * Structure to store and construct a chart
36 *
37 */
38
39 #ifndef MWAW_CHART
40 # define MWAW_CHART
41
42 #include <iostream>
43 #include <vector>
44 #include <map>
45
46 #include "libmwaw_internal.hxx"
47
48 #include "MWAWEntry.hxx"
49 #include "MWAWFont.hxx"
50 #include "MWAWGraphicStyle.hxx"
51
52 namespace MWAWChartInternal
53 {
54 class SubDocument;
55 }
57 class MWAWChart
58 {
59 friend class MWAWChartInternal::SubDocument;
60 public:
62 struct Axis {
64 enum Type { A_None, A_Numeric, A_Logarithmic, A_Sequence, A_Sequence_Skip_Empty };
66 Axis();
68 ~Axis();
70 void addContentTo(std::string const &sheetName, int coord, librevenge::RVNGPropertyList &propList) const;
72 void addStyleTo(librevenge::RVNGPropertyList &propList) const;
74 friend std::ostream &operator<<(std::ostream &o, Axis const &axis);
76 Type m_type;
78 bool m_showGrid;
80 bool m_showLabel;
82 MWAWBox2i m_labelRange;
84 MWAWGraphicStyle m_style;
85 };
87 struct Legend {
89 Legend()
90 : m_show(false)
91 , m_autoPosition(true)
92 , m_relativePosition(libmwaw::RightBit)
93 , m_position(0,0)
94 , m_font()
95 , m_style()
96 {
97 }
99 void addContentTo(librevenge::RVNGPropertyList &propList) const;
101 void addStyleTo(librevenge::RVNGPropertyList &propList, std::shared_ptr<MWAWFontConverter> fontConverter) const;
103 friend std::ostream &operator<<(std::ostream &o, Legend const &legend);
105 bool m_show;
107 bool m_autoPosition;
109 int m_relativePosition;
111 MWAWVec2f m_position;
113 MWAWFont m_font;
115 MWAWGraphicStyle m_style;
116 };
118 struct Series {
120 enum Type { S_Area, S_Bar, S_Column, S_Line, S_Pie, S_Scatter, S_Stock };
122 Series();
124 virtual ~Series();
126 void addContentTo(std::string const &sheetName, librevenge::RVNGPropertyList &propList) const;
128 void addStyleTo(librevenge::RVNGPropertyList &propList) const;
130 static std::string getSeriesTypeName(Type type);
132 friend std::ostream &operator<<(std::ostream &o, Series const &series);
134 Type m_type;
136 MWAWBox2i m_range;
138 MWAWGraphicStyle m_style;
139 };
141 struct TextZone {
143 enum Type { T_Title, T_SubTitle, T_AxisX, T_AxisY, T_AxisZ };
145 enum ContentType { C_Cell, C_Text };
146
148 TextZone();
150 ~TextZone();
152 void addContentTo(std::string const &sheetName, librevenge::RVNGPropertyList &propList) const;
154 void addStyleTo(librevenge::RVNGPropertyList &propList, std::shared_ptr<MWAWFontConverter> fontConverter) const;
156 friend std::ostream &operator<<(std::ostream &o, TextZone const &zone);
158 Type m_type;
160 ContentType m_contentType;
162 MWAWVec2f m_position;
164 MWAWVec2i m_cell;
166 MWAWEntry m_textEntry;
168 MWAWFont m_font;
170 MWAWGraphicStyle m_style;
171 };
172
174 MWAWChart(std::string const &sheetName, MWAWFontConverterPtr const &fontConverter, MWAWVec2f const &dim=MWAWVec2f());
176 virtual ~MWAWChart();
178 void sendChart(MWAWSpreadsheetListenerPtr &listener, librevenge::RVNGSpreadsheetInterface *interface);
180 virtual void sendContent(TextZone const &zone, MWAWListenerPtr &listener)=0;
181
183 void setDataType(Series::Type type, bool dataStacked)
184 {
185 m_type=type;
186 m_dataStacked=dataStacked;
187 }
188
190 MWAWVec2f const &getDimension() const
191 {
192 return m_dim;
193 }
195 void setDimension(MWAWVec2f const &dim)
196 {
197 m_dim=dim;
198 }
200 void add(int coord, Axis const &axis);
202 Axis const &getAxis(int coord) const;
203
205 void set(Legend const &legend)
206 {
207 m_legend=legend;
208 }
210 Legend const &getLegend() const
211 {
212 return m_legend;
213 }
214
216 void add(Series const &series);
218 std::vector<Series> const &getSeries() const
219 {
220 return m_seriesList;
221 }
222
224 void add(TextZone const &textZone);
226 bool getTextZone(TextZone::Type type, TextZone &textZone);
227
228 protected:
230 void sendTextZoneContent(TextZone::Type type, MWAWListenerPtr &listener);
231
232 protected:
234 std::string m_sheetName;
236 MWAWVec2f m_dim;
238 Series::Type m_type;
240 bool m_dataStacked;
242 Axis m_axis[4];
244 Legend m_legend;
246 std::vector<Series> m_seriesList;
248 std::map<TextZone::Type, TextZone> m_textZoneMap;
250 MWAWFontConverterPtr m_fontConverter;
251 private:
252 explicit MWAWChart(MWAWChart const &orig) = delete;
253 MWAWChart &operator=(MWAWChart const &orig) = delete;
254 };
255
256 #endif
257 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWChart::Legend
a legend in a chart
Definition: MWAWChart.hxx:87
MWAWChart::TextZone::m_textEntry
MWAWEntry m_textEntry
the text entry
Definition: MWAWChart.hxx:166
MWAWChart::Series::m_type
Type m_type
the type
Definition: MWAWChart.hxx:134
MWAWChart::TextZone::Type
Type
the text type
Definition: MWAWChart.hxx:143
MWAWChart::Series::Type
Type
the series type
Definition: MWAWChart.hxx:120
MWAWChart::TextZone::m_font
MWAWFont m_font
the zone format
Definition: MWAWChart.hxx:168
MWAWChartInternal::SubDocument
Internal: the subdocument of a MWAWChart.
Definition: MWAWChart.cxx:61
MWAWChartInternal
Internal: the structures of a MWAWChart.
Definition: MWAWChart.cxx:57
MWAWChart::TextZone::ContentType
ContentType
the text content type
Definition: MWAWChart.hxx:145
BeagleWksDRParserInternal::operator<<
std::ostream & operator<<(std::ostream &o, Shape const &shape)
Definition: BeagleWksDRParser.cxx:107
MWAWChart::TextZone::m_contentType
ContentType m_contentType
the content type
Definition: MWAWChart.hxx:160
MWAWEntry.hxx
libmwaw_internal.hxx
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:549
MWAWChart::Legend::m_autoPosition
bool m_autoPosition
automatic position
Definition: MWAWChart.hxx:107
MWAWSpreadsheetListenerPtr
std::shared_ptr< MWAWSpreadsheetListener > MWAWSpreadsheetListenerPtr
a smart pointer of MWAWSpreadsheetListener
Definition: libmwaw_internal.hxx:559
MWAWChart::m_legend
Legend m_legend
the legend
Definition: MWAWChart.hxx:244
MWAWChart::Axis::m_showGrid
bool m_showGrid
show or not the grid
Definition: MWAWChart.hxx:78
MWAWChart::m_sheetName
std::string m_sheetName
the sheet name
Definition: MWAWChart.hxx:234
MWAWChart::Series
a series in a chart
Definition: MWAWChart.hxx:118
MWAWChart::Legend::m_position
MWAWVec2f m_position
the position in points
Definition: MWAWChart.hxx:111
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
MWAWChart::setDataType
void setDataType(Series::Type type, bool dataStacked)
sets the chart type
Definition: MWAWChart.hxx:183
MWAWChart::Axis::m_showLabel
bool m_showLabel
show or not the label
Definition: MWAWChart.hxx:80
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:50
MWAWChart::Series::m_style
MWAWGraphicStyle m_style
the graphic style
Definition: MWAWChart.hxx:138
MWAWChart::m_seriesList
std::vector< Series > m_seriesList
the list of series
Definition: MWAWChart.hxx:246
MWAWChart::Axis::Type
Type
the axis content
Definition: MWAWChart.hxx:64
MWAWChart::setDimension
void setDimension(MWAWVec2f const &dim)
return the chart dimension
Definition: MWAWChart.hxx:195
MWAWChart::Legend::Legend
Legend()
constructor
Definition: MWAWChart.hxx:89
MWAWChart::Axis
a axis in a chart
Definition: MWAWChart.hxx:62
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MWAWBox2< int >
MWAWChart::Legend::m_font
MWAWFont m_font
the font
Definition: MWAWChart.hxx:113
MWAWChart::m_dim
MWAWVec2f m_dim
the chart dimension in point
Definition: MWAWChart.hxx:236
MWAWFont.hxx
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:838
MWAWChart::Axis::m_style
MWAWGraphicStyle m_style
the graphic style
Definition: MWAWChart.hxx:84
MWAWChart::m_type
Series::Type m_type
the chart type (if no series)
Definition: MWAWChart.hxx:238
MWAWChart::Axis::m_type
Type m_type
the sequence type
Definition: MWAWChart.hxx:76
MWAWChart::m_dataStacked
bool m_dataStacked
a flag to know if the data are stacked or not
Definition: MWAWChart.hxx:240
MWAWChart::TextZone::m_style
MWAWGraphicStyle m_style
the graphic style
Definition: MWAWChart.hxx:170
MWAWChart::m_textZoneMap
std::map< TextZone::Type, TextZone > m_textZoneMap
a map text zone type to text zone
Definition: MWAWChart.hxx:248
MWAWChart::Legend::m_show
bool m_show
show or not the legend
Definition: MWAWChart.hxx:105
MWAWChart::TextZone::m_cell
MWAWVec2i m_cell
the cell position ( for title and subtitle )
Definition: MWAWChart.hxx:164
libmwaw::RightBit
Definition: libmwaw_internal.hxx:178
MWAWChart::getLegend
Legend const & getLegend() const
return the legend
Definition: MWAWChart.hxx:210
MWAWChart::getSeries
std::vector< Series > const & getSeries() const
return the list of series
Definition: MWAWChart.hxx:218
MWAWFontConverterPtr
std::shared_ptr< MWAWFontConverter > MWAWFontConverterPtr
a smart pointer of MWAWFontConverter
Definition: libmwaw_internal.hxx:539
MWAWChart::getDimension
MWAWVec2f const & getDimension() const
return the chart dimension
Definition: MWAWChart.hxx:190
MWAWChart::Legend::m_relativePosition
int m_relativePosition
the automatic position libmwaw::LeftBit|...
Definition: MWAWChart.hxx:109
MWAWChart::m_fontConverter
MWAWFontConverterPtr m_fontConverter
the font converter
Definition: MWAWChart.hxx:250
MWAWChart::TextZone
a text zone a chart
Definition: MWAWChart.hxx:141
MWAWChart::TextZone::m_type
Type m_type
the zone type
Definition: MWAWChart.hxx:158
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MWAWChart::TextZone::m_position
MWAWVec2f m_position
the position in the zone
Definition: MWAWChart.hxx:162
MWAWChart::Axis::m_labelRange
MWAWBox2i m_labelRange
the label range if defined
Definition: MWAWChart.hxx:82
MWAWChart::Legend::m_style
MWAWGraphicStyle m_style
the graphic style
Definition: MWAWChart.hxx:115
MWAWChart
a class used to store a chart associated to a spreadsheet ....
Definition: MWAWChart.hxx:57
MWAWGraphicStyle.hxx
MWAWChart::Series::m_range
MWAWBox2i m_range
the data range
Definition: MWAWChart.hxx:136
MWAWVec2< float >