MWAWChart.hxx Source File documentation

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();
67 Axis &operator=(Axis const &)=default;
69 ~Axis();
71 void addContentTo(std::string const &sheetName, int coord, librevenge::RVNGPropertyList &propList) const;
73 void addStyleTo(librevenge::RVNGPropertyList &propList) const;
75 friend std::ostream &operator<<(std::ostream &o, Axis const &axis);
77 Type m_type;
79 bool m_showGrid;
81 bool m_showLabel;
83 MWAWBox2i m_labelRange;
85 MWAWGraphicStyle m_style;
86 };
88 struct Legend {
90 Legend()
91 : m_show(false)
92 , m_autoPosition(true)
93 , m_relativePosition(libmwaw::RightBit)
94 , m_position(0,0)
95 , m_font()
96 , m_style()
97 {
98 }
100 void addContentTo(librevenge::RVNGPropertyList &propList) const;
102 void addStyleTo(librevenge::RVNGPropertyList &propList, std::shared_ptr<MWAWFontConverter> fontConverter) const;
104 friend std::ostream &operator<<(std::ostream &o, Legend const &legend);
106 bool m_show;
108 bool m_autoPosition;
110 int m_relativePosition;
112 MWAWVec2f m_position;
114 MWAWFont m_font;
116 MWAWGraphicStyle m_style;
117 };
119 struct Series {
121 enum Type { S_Area, S_Bar, S_Column, S_Line, S_Pie, S_Scatter, S_Stock };
123 Series();
124 Series(Series const &)=default;
126 virtual ~Series();
128 void addContentTo(std::string const &sheetName, librevenge::RVNGPropertyList &propList) const;
130 void addStyleTo(librevenge::RVNGPropertyList &propList) const;
132 static std::string getSeriesTypeName(Type type);
134 friend std::ostream &operator<<(std::ostream &o, Series const &series);
136 Type m_type;
138 MWAWBox2i m_range;
140 MWAWGraphicStyle m_style;
141 };
143 struct TextZone {
145 enum Type { T_Title, T_SubTitle, T_AxisX, T_AxisY, T_AxisZ };
147 enum ContentType { C_Cell, C_Text };
148
150 TextZone();
151 TextZone(TextZone const &)=default;
152 TextZone &operator=(TextZone const &)=default;
154 ~TextZone();
156 void addContentTo(std::string const &sheetName, librevenge::RVNGPropertyList &propList) const;
158 void addStyleTo(librevenge::RVNGPropertyList &propList, std::shared_ptr<MWAWFontConverter> fontConverter) const;
160 friend std::ostream &operator<<(std::ostream &o, TextZone const &zone);
162 Type m_type;
164 ContentType m_contentType;
166 MWAWVec2f m_position;
168 MWAWVec2i m_cell;
170 MWAWEntry m_textEntry;
172 MWAWFont m_font;
174 MWAWGraphicStyle m_style;
175 };
176
178 MWAWChart(std::string const &sheetName, MWAWFontConverterPtr const &fontConverter, MWAWVec2f const &dim=MWAWVec2f());
180 virtual ~MWAWChart();
182 void sendChart(MWAWSpreadsheetListenerPtr &listener, librevenge::RVNGSpreadsheetInterface *interface);
184 virtual void sendContent(TextZone const &zone, MWAWListenerPtr &listener)=0;
185
187 void setDataType(Series::Type type, bool dataStacked)
188 {
189 m_type=type;
190 m_dataStacked=dataStacked;
191 }
192
194 MWAWVec2f const &getDimension() const
195 {
196 return m_dim;
197 }
199 void setDimension(MWAWVec2f const &dim)
200 {
201 m_dim=dim;
202 }
204 void add(int coord, Axis const &axis);
206 Axis const &getAxis(int coord) const;
207
209 void set(Legend const &legend)
210 {
211 m_legend=legend;
212 }
214 Legend const &getLegend() const
215 {
216 return m_legend;
217 }
218
220 void add(Series const &series);
222 std::vector<Series> const &getSeries() const
223 {
224 return m_seriesList;
225 }
226
228 void add(TextZone const &textZone);
230 bool getTextZone(TextZone::Type type, TextZone &textZone);
231
232 protected:
234 void sendTextZoneContent(TextZone::Type type, MWAWListenerPtr &listener);
235
236 protected:
238 std::string m_sheetName;
240 MWAWVec2f m_dim;
242 Series::Type m_type;
244 bool m_dataStacked;
246 Axis m_axis[4];
248 Legend m_legend;
250 std::vector<Series> m_seriesList;
252 std::map<TextZone::Type, TextZone> m_textZoneMap;
254 MWAWFontConverterPtr m_fontConverter;
255 private:
256 explicit MWAWChart(MWAWChart const &orig) = delete;
257 MWAWChart &operator=(MWAWChart const &orig) = delete;
258 };
259
260 #endif
261 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWChart::sendTextZoneContent
void sendTextZoneContent(TextZone::Type type, MWAWListenerPtr &listener)
sends a textzone content
Definition: MWAWChart.cxx:162
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MWAWChart::m_axis
Axis m_axis[4]
the x,y,z and a bad axis
Definition: MWAWChart.hxx:246
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
MWAWChart.hxx
MWAWChart::Series::S_Pie
@ S_Pie
Definition: MWAWChart.hxx:121
MWAWChart::~MWAWChart
virtual ~MWAWChart()
the destructor
Definition: MWAWChart.cxx:127
MWAWChart::Series::m_style
MWAWGraphicStyle m_style
the graphic style
Definition: MWAWChart.hxx:140
MWAWChart::TextZone::m_cell
MWAWVec2i m_cell
the cell position ( for title and subtitle )
Definition: MWAWChart.hxx:168
MWAWChart::Legend::m_relativePosition
int m_relativePosition
the automatic position libmwaw::LeftBit|...
Definition: MWAWChart.hxx:110
MWAWChart::getAxis
const Axis & getAxis(int coord) const
return an axis (corresponding to a coord)
Definition: MWAWChart.cxx:140
MWAWChartInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: MWAWChart.cxx:72
MWAWChart::operator=
MWAWChart & operator=(MWAWChart const &orig)=delete
MWAWChart::TextZone::ContentType
ContentType
the text content type
Definition: MWAWChart.hxx:147
MWAWFontConverterPtr
std::shared_ptr< MWAWFontConverter > MWAWFontConverterPtr
a smart pointer of MWAWFontConverter
Definition: libmwaw_internal.hxx:543
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
operator<<
std::ostream & operator<<(std::ostream &o, MWAWChart::Axis const &axis)
Definition: MWAWChart.cxx:388
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
MWAWChart::m_dim
MWAWVec2f m_dim
the chart dimension in point
Definition: MWAWChart.hxx:240
MWAWChart::Axis
a axis in a chart
Definition: MWAWChart.hxx:62
MWAWGraphicStyle::setSurfaceColor
void setSurfaceColor(MWAWColor const &col, float opacity=1)
set the surface color
Definition: MWAWGraphicStyle.hxx:325
MWAWChartInternal
Internal: the structures of a MWAWChart.
Definition: MWAWChart.cxx:57
MWAWChart::Axis::A_Numeric
@ A_Numeric
Definition: MWAWChart.hxx:64
MWAWChart::Series::addContentTo
void addContentTo(std::string const &sheetName, librevenge::RVNGPropertyList &propList) const
add content to the propList
Definition: MWAWChart.cxx:518
MWAWChart::TextZone::addStyleTo
void addStyleTo(librevenge::RVNGPropertyList &propList, std::shared_ptr< MWAWFontConverter > fontConverter) const
add to the propList
Definition: MWAWChart.cxx:634
MWAWChart::TextZone::T_Title
@ T_Title
Definition: MWAWChart.hxx:145
MWAWChart::Axis::A_Logarithmic
@ A_Logarithmic
Definition: MWAWChart.hxx:64
libmwaw::BottomBit
@ BottomBit
Definition: libmwaw_internal.hxx:178
libmwaw::DOC_CHART_ZONE
@ DOC_CHART_ZONE
Definition: libmwaw_internal.hxx:188
MWAWChart::Axis::A_None
@ A_None
Definition: MWAWChart.hxx:64
MWAWChart::m_dataStacked
bool m_dataStacked
a flag to know if the data are stacked or not
Definition: MWAWChart.hxx:244
MWAWChart::set
void set(Legend const &legend)
set the legend
Definition: MWAWChart.hxx:209
MWAWEntry.hxx
MWAWFontConverter.hxx
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
MWAWChart::TextZone::C_Text
@ C_Text
Definition: MWAWChart.hxx:147
MWAWChart::Series::S_Bar
@ S_Bar
Definition: MWAWChart.hxx:121
MWAWChart::Legend::operator<<
friend std::ostream & operator<<(std::ostream &o, Legend const &legend)
operator<<
Definition: MWAWChart.cxx:451
MWAWChart::TextZone::T_AxisY
@ T_AxisY
Definition: MWAWChart.hxx:145
MWAWChartInternal::SubDocument::m_textZone
MWAWChart::TextZone::Type m_textZone
the textzone type
Definition: MWAWChart.cxx:90
MWAWChart::Legend::m_style
MWAWGraphicStyle m_style
the graphic style
Definition: MWAWChart.hxx:116
MWAWChart::setDataType
void setDataType(Series::Type type, bool dataStacked)
sets the chart type
Definition: MWAWChart.hxx:187
MWAW_FALLTHROUGH
#define MWAW_FALLTHROUGH
Definition: libmwaw_internal.hxx:118
MWAWChart::Series::getSeriesTypeName
static std::string getSeriesTypeName(Type type)
returns a string corresponding to a series type
Definition: MWAWChart.cxx:493
MWAWChart::Legend
a legend in a chart
Definition: MWAWChart.hxx:88
MWAWChart::TextZone::C_Cell
@ C_Cell
Definition: MWAWChart.hxx:147
MWAWChart::TextZone::m_textEntry
MWAWEntry m_textEntry
the text entry
Definition: MWAWChart.hxx:170
MWAWSubDocument
abstract class used to store a subdocument (with a comparison function)
Definition: MWAWSubDocument.hxx:41
MWAWChart::Legend::m_position
MWAWVec2f m_position
the position in points
Definition: MWAWChart.hxx:112
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
MWAWChartInternal::SubDocument
Internal: the subdocument of a MWAWChart.
Definition: MWAWChart.cxx:61
MWAWChart::Series::S_Line
@ S_Line
Definition: MWAWChart.hxx:121
MWAWChart::Series::~Series
virtual ~Series()
destructor
Definition: MWAWChart.cxx:489
MWAWChart::Series::Type
Type
the series type
Definition: MWAWChart.hxx:121
MWAWChart::TextZone
a text zone a chart
Definition: MWAWChart.hxx:143
MWAWChart::Series::Series
Series()
constructor
Definition: MWAWChart.cxx:480
MWAWChart::Series::S_Stock
@ S_Stock
Definition: MWAWChart.hxx:121
MWAWChart::TextZone::addContentTo
void addContentTo(std::string const &sheetName, librevenge::RVNGPropertyList &propList) const
add content to the propList
Definition: MWAWChart.cxx:599
MWAWChart::Legend::Legend
Legend()
constructor
Definition: MWAWChart.hxx:90
MWAWSubDocument.hxx
MWAWChart::Axis::operator<<
friend std::ostream & operator<<(std::ostream &o, Axis const &axis)
operator<<
Definition: MWAWChart.cxx:388
MWAWChart::Series::operator<<
friend std::ostream & operator<<(std::ostream &o, Series const &series)
operator<<
Definition: MWAWChart.cxx:544
MWAWChart::TextZone::m_style
MWAWGraphicStyle m_style
the graphic style
Definition: MWAWChart.hxx:174
MWAWChart::m_seriesList
std::vector< Series > m_seriesList
the list of series
Definition: MWAWChart.hxx:250
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
MWAWChartInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: MWAWChart.cxx:96
MWAWChart::sendContent
virtual void sendContent(TextZone const &zone, MWAWListenerPtr &listener)=0
send the zone content (called when the zone is of text type)
MWAWSpreadsheetListenerPtr
std::shared_ptr< MWAWSpreadsheetListener > MWAWSpreadsheetListenerPtr
a smart pointer of MWAWSpreadsheetListener
Definition: libmwaw_internal.hxx:563
MWAWChart::TextZone::T_AxisZ
@ T_AxisZ
Definition: MWAWChart.hxx:145
libmwaw_internal.hxx
MWAWGraphicStyle::m_lineWidth
float m_lineWidth
the linewidth
Definition: MWAWGraphicStyle.hxx:418
MWAWPosition.hxx
MWAWChart::TextZone::TextZone
TextZone()
constructor
Definition: MWAWChart.cxx:583
MWAWChart::getLegend
const Legend & getLegend() const
return the legend
Definition: MWAWChart.hxx:214
MWAWChart::Series::S_Column
@ S_Column
Definition: MWAWChart.hxx:121
MWAWChart::add
void add(int coord, Axis const &axis)
adds an axis (corresponding to a coord)
Definition: MWAWChart.cxx:131
MWAWChart::Series::S_Area
@ S_Area
Definition: MWAWChart.hxx:121
MWAWChart::TextZone::~TextZone
~TextZone()
destructor
Definition: MWAWChart.cxx:595
MWAWChart::Legend::addStyleTo
void addStyleTo(librevenge::RVNGPropertyList &propList, std::shared_ptr< MWAWFontConverter > fontConverter) const
add style to the propList
Definition: MWAWChart.cxx:444
MWAWChart::Axis::m_showLabel
bool m_showLabel
show or not the label
Definition: MWAWChart.hxx:81
MWAWChart::getSeries
const std::vector< Series > & getSeries() const
return the list of series
Definition: MWAWChart.hxx:222
MWAWChart::TextZone::operator=
TextZone & operator=(TextZone const &)=default
libmwaw::RightBit
@ RightBit
Definition: libmwaw_internal.hxx:178
MWAWVec2< float >
MWAWChart::Axis::operator=
Axis & operator=(Axis const &)=default
MWAWChart::Axis::m_showGrid
bool m_showGrid
show or not the grid
Definition: MWAWChart.hxx:79
MWAWChart::Legend::m_autoPosition
bool m_autoPosition
automatic position
Definition: MWAWChart.hxx:108
MWAWChart::getTextZone
bool getTextZone(TextZone::Type type, TextZone &textZone)
returns a textzone content(if set)
Definition: MWAWChart.cxx:154
MWAWChart::getDimension
const MWAWVec2f & getDimension() const
return the chart dimension
Definition: MWAWChart.hxx:194
MWAWChart::Axis::addContentTo
void addContentTo(std::string const &sheetName, int coord, librevenge::RVNGPropertyList &propList) const
add content to the propList
Definition: MWAWChart.cxx:346
MWAWChartInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: MWAWChart.cxx:75
MWAWChart::Axis::A_Sequence
@ A_Sequence
Definition: MWAWChart.hxx:64
MWAWChart::Series::m_range
MWAWBox2i m_range
the data range
Definition: MWAWChart.hxx:138
MWAWChart::TextZone::T_SubTitle
@ T_SubTitle
Definition: MWAWChart.hxx:145
MWAWChart::m_sheetName
std::string m_sheetName
the sheet name
Definition: MWAWChart.hxx:238
MWAWChartInternal::SubDocument::m_chart
MWAWChart * m_chart
the chart
Definition: MWAWChart.cxx:88
MWAWChart::Axis::m_labelRange
MWAWBox2i m_labelRange
the label range if defined
Definition: MWAWChart.hxx:83
MWAWChart::m_type
Series::Type m_type
the chart type (if no series)
Definition: MWAWChart.hxx:242
libmwaw::LeftBit
@ LeftBit
Definition: libmwaw_internal.hxx:178
MWAWChartInternal::SubDocument::SubDocument
SubDocument(MWAWChart *chart, MWAWChart::TextZone::Type textZone)
Definition: MWAWChart.cxx:64
MWAWChart::MWAWChart
MWAWChart(std::string const &sheetName, MWAWFontConverterPtr const &fontConverter, MWAWVec2f const &dim=MWAWVec2f())
the constructor
Definition: MWAWChart.cxx:115
MWAWGraphicStyle.hxx
MWAWChart::TextZone::m_type
Type m_type
the zone type
Definition: MWAWChart.hxx:162
MWAWChart::Axis::A_Sequence_Skip_Empty
@ A_Sequence_Skip_Empty
Definition: MWAWChart.hxx:64
MWAWChart::Series
a series in a chart
Definition: MWAWChart.hxx:119
MWAWChart::Series::S_Scatter
@ S_Scatter
Definition: MWAWChart.hxx:121
MWAWChart::Axis::Axis
Axis()
constructor
Definition: MWAWChart.cxx:332
libmwaw::TopBit
@ TopBit
Definition: libmwaw_internal.hxx:178
MWAWChart
a class used to store a chart associated to a spreadsheet ....
Definition: MWAWChart.hxx:57
MWAWChart::TextZone::m_contentType
ContentType m_contentType
the content type
Definition: MWAWChart.hxx:164
MWAWChart::TextZone::Type
Type
the text type
Definition: MWAWChart.hxx:145
MWAWChart::TextZone::m_font
MWAWFont m_font
the zone format
Definition: MWAWChart.hxx:172
MWAWListener.hxx
MWAWSpreadsheetListener.hxx
MWAWChart::Axis::~Axis
~Axis()
destructor
Definition: MWAWChart.cxx:342
MWAWBox2::size
MWAWVec2< T > size() const
the box size
Definition: libmwaw_internal.hxx:1067
MWAWChart::m_textZoneMap
std::map< TextZone::Type, TextZone > m_textZoneMap
a map text zone type to text zone
Definition: MWAWChart.hxx:252
MWAWChart::m_fontConverter
MWAWFontConverterPtr m_fontConverter
the font converter
Definition: MWAWChart.hxx:254
MWAWChartInternal::SubDocument::operator=
SubDocument & operator=(SubDocument const &orig)=delete
MWAWChart::TextZone::m_position
MWAWVec2f m_position
the position in the zone
Definition: MWAWChart.hxx:166
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:50
MWAWInputStream.hxx
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
MWAWFont.hxx
MWAWChart::TextZone::operator<<
friend std::ostream & operator<<(std::ostream &o, TextZone const &zone)
operator<<
Definition: MWAWChart.cxx:640
MWAWChart::Series::addStyleTo
void addStyleTo(librevenge::RVNGPropertyList &propList) const
add style to the propList
Definition: MWAWChart.cxx:539
MWAWBox2< int >
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MWAWChart::Legend::m_show
bool m_show
show or not the legend
Definition: MWAWChart.hxx:106
MWAWChart::sendChart
void sendChart(MWAWSpreadsheetListenerPtr &listener, librevenge::RVNGSpreadsheetInterface *interface)
send the chart to the listener
Definition: MWAWChart.cxx:176
MWAWChart::Axis::m_style
MWAWGraphicStyle m_style
the graphic style
Definition: MWAWChart.hxx:85
MWAWChart::m_legend
Legend m_legend
the legend
Definition: MWAWChart.hxx:248
MWAWChart::Series::m_type
Type m_type
the type
Definition: MWAWChart.hxx:136
MWAWChart::Axis::addStyleTo
void addStyleTo(librevenge::RVNGPropertyList &propList) const
add style to the propList
Definition: MWAWChart.cxx:378
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:199
MWAWChart::Axis::m_type
Type m_type
the sequence type
Definition: MWAWChart.hxx:77
MWAWChart::Legend::m_font
MWAWFont m_font
the font
Definition: MWAWChart.hxx:114
MWAWChart::Legend::addContentTo
void addContentTo(librevenge::RVNGPropertyList &propList) const
add content to the propList
Definition: MWAWChart.cxx:424
MWAWChart::TextZone::T_AxisX
@ T_AxisX
Definition: MWAWChart.hxx:145