STOFFChart.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 /* libstaroffice
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 STOFF_CHART
40 # define STOFF_CHART
41 
42 #include <iostream>
43 #include <vector>
44 #include <map>
45 
47 
48 #include "STOFFEntry.hxx"
49 #include "STOFFFont.hxx"
50 #include "STOFFGraphicStyle.hxx"
51 
52 namespace STOFFChartInternal
53 {
54 class SubDocument;
55 }
58 {
60 public:
62  struct Position {
64  explicit Position(STOFFVec2i pos=STOFFVec2i(-1,-1), librevenge::RVNGString const &sheetName="")
65  : m_pos(pos)
66  , m_sheetName(sheetName)
67  {
68  }
70  bool valid() const
71  {
72  return m_pos[0]>=0 && m_pos[1]>=0 && !m_sheetName.empty();
73  }
75  bool valid(Position const &maxPos) const
76  {
77  return valid() && maxPos.valid() && maxPos.m_pos[0]>=m_pos[0] && maxPos.m_pos[1]>=m_pos[1];
78  }
80  librevenge::RVNGString getCellName() const;
82  friend std::ostream &operator<<(std::ostream &o, Position const &pos);
84  bool operator==(Position &pos) const
85  {
86  return m_pos==pos.m_pos && m_sheetName==pos.m_sheetName;
87  }
89  bool operator!=(Position &pos) const
90  {
91  return !(operator==(pos));
92  }
96  librevenge::RVNGString m_sheetName;
97  };
98  struct Axis {
102  Axis();
104  ~Axis();
106  void addContentTo(int coord, librevenge::RVNGPropertyList &propList) const;
108  void addStyleTo(librevenge::RVNGPropertyList &propList) const;
110  friend std::ostream &operator<<(std::ostream &o, Axis const &axis);
123 
129  librevenge::RVNGString m_title;
131  librevenge::RVNGString m_subTitle;
134  };
136  struct Legend {
139  : m_show(false)
140  , m_autoPosition(true)
142  , m_position(0,0)
143  , m_font()
144  , m_style()
145  {
146  }
148  void addContentTo(librevenge::RVNGPropertyList &propList) const;
150  void addStyleTo(librevenge::RVNGPropertyList &propList) const;
152  friend std::ostream &operator<<(std::ostream &o, Legend const &legend);
154  bool m_show;
165  };
167  struct Serie {
171  enum PointType {
176  };
178  Serie();
179  Serie(Serie const &)=default;
180  Serie(Serie &&)=default;
181  Serie &operator=(Serie const &)=default;
182  Serie &operator=(Serie &&)=default;
184  virtual ~Serie();
186  bool is1DStyle() const
187  {
189  }
191  bool valid() const
192  {
193  return m_ranges[0].valid(m_ranges[0]);
194  }
196  void addContentTo(librevenge::RVNGPropertyList &propList) const;
198  void addStyleTo(librevenge::RVNGPropertyList &propList) const;
200  static std::string getSerieTypeName(Type type);
202  friend std::ostream &operator<<(std::ostream &o, Serie const &series);
216  librevenge::RVNGString m_legendText;
221  };
223  struct TextZone {
228 
230  explicit TextZone(Type type);
232  ~TextZone();
234  bool valid() const
235  {
236  if (!m_show) return false;
237  if (m_contentType==C_Cell)
238  return m_cell.valid();
239  if (m_contentType!=C_Text)
240  return false;
241  for (auto &e : m_textEntryList) {
242  if (e.valid()) return true;
243  }
244  return false;
245  }
247  void addContentTo(librevenge::RVNGPropertyList &propList) const;
249  void addStyleTo(librevenge::RVNGPropertyList &propList) const;
251  friend std::ostream &operator<<(std::ostream &o, TextZone const &zone);
257  bool m_show;
263  std::vector<STOFFEntry> m_textEntryList;
268  };
269 
271  STOFFChart(STOFFVec2f const &dim=STOFFVec2f());
273  virtual ~STOFFChart();
275  void sendChart(STOFFSpreadsheetListenerPtr &listener, librevenge::RVNGSpreadsheetInterface *interface);
277  virtual void sendContent(TextZone const &zone, STOFFListenerPtr &listener) const =0;
278 
280  void setGridColor(STOFFColor const &color)
281  {
282  m_gridColor=color;
283  }
285  Axis &getAxis(int coord);
287  Axis const &getAxis(int coord) const;
288 
290  Legend const &getLegend() const
291  {
292  return m_legend;
293  }
296  {
297  return m_legend;
298  }
299 
301  Serie *getSerie(int id, bool create);
303  std::map<int, Serie> const &getIdSerieMap() const
304  {
305  return m_serieMap;
306  }
308  TextZone *getTextZone(TextZone::Type type, bool create=false);
309 
310 protected:
312  void sendTextZoneContent(TextZone::Type type, STOFFListenerPtr &listener) const;
313 
314 public:
326  bool m_is3D;
329 
330  // main
331 
335  librevenge::RVNGString m_name;
336 
337  // plot area
338 
343 
344  // legend
345 
348 
353 
354 protected:
362  std::map<int, Serie> m_serieMap;
364  std::map<TextZone::Type, TextZone> m_textZoneMap;
365 private:
366  explicit STOFFChart(STOFFChart const &orig) = delete;
367  STOFFChart &operator=(STOFFChart const &orig) = delete;
368 };
369 
370 #endif
371 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Internal: the subdocument of a STOFFChart.
Definition: STOFFChart.cxx:62
a class used to store a chart associated to a spreadsheet ....
Definition: STOFFChart.hxx:58
STOFFChart(STOFFVec2f const &dim=STOFFVec2f())
the constructor
Definition: STOFFChart.cxx:118
std::map< int, Serie > const & getIdSerieMap() const
returns the list of defined series
Definition: STOFFChart.hxx:303
bool m_is3DDeep
a flag to know if real 3D or 2D-extended
Definition: STOFFChart.hxx:328
bool m_dataStacked
a flag to know if the data are stacked or not
Definition: STOFFChart.hxx:320
Serie::Type m_type
the chart type (if no series)
Definition: STOFFChart.hxx:318
STOFFColor m_gridColor
the grid color
Definition: STOFFChart.hxx:356
std::map< TextZone::Type, TextZone > m_textZoneMap
a map text zone type to text zone
Definition: STOFFChart.hxx:364
std::map< int, Serie > m_serieMap
the list of series
Definition: STOFFChart.hxx:362
virtual ~STOFFChart()
the destructor
Definition: STOFFChart.cxx:146
STOFFBox2f m_plotAreaPosition
the plot area dimension in percent
Definition: STOFFChart.hxx:340
Legend & getLegend()
returns the legend
Definition: STOFFChart.hxx:295
void sendTextZoneContent(TextZone::Type type, STOFFListenerPtr &listener) const
sends a textzone content
Definition: STOFFChart.cxx:188
STOFFGraphicStyle m_floorStyle
floor
Definition: STOFFChart.hxx:350
bool m_dataPercentStacked
a flag to know if the data are percent stacked or not
Definition: STOFFChart.hxx:322
virtual void sendContent(TextZone const &zone, STOFFListenerPtr &listener) const =0
send the zone content (called when the zone is of text type)
librevenge::RVNGString m_name
the chart name
Definition: STOFFChart.hxx:335
bool m_dataVertical
a flag to know if the data are vertical (for bar)
Definition: STOFFChart.hxx:324
void sendChart(STOFFSpreadsheetListenerPtr &listener, librevenge::RVNGSpreadsheetInterface *interface)
send the chart to the listener
Definition: STOFFChart.cxx:197
STOFFChart(STOFFChart const &orig)=delete
STOFFChart & operator=(STOFFChart const &orig)=delete
Legend m_legend
the legend
Definition: STOFFChart.hxx:360
Axis & getAxis(int coord)
return an axis (corresponding to a coord)
Definition: STOFFChart.cxx:150
STOFFGraphicStyle m_plotAreaStyle
the ploat area style
Definition: STOFFChart.hxx:342
Legend const & getLegend() const
returns the legend
Definition: STOFFChart.hxx:290
Axis m_axis[5]
the x,y,y-second,z and a bad axis
Definition: STOFFChart.hxx:358
STOFFGraphicStyle m_wallStyle
wall
Definition: STOFFChart.hxx:352
STOFFVec2f m_dimension
the chart dimension in point
Definition: STOFFChart.hxx:316
void setGridColor(STOFFColor const &color)
set the grid color
Definition: STOFFChart.hxx:280
STOFFBox2f m_legendPosition
the legend dimension in percent
Definition: STOFFChart.hxx:347
Serie * getSerie(int id, bool create)
return a serie
Definition: STOFFChart.cxx:168
TextZone * getTextZone(TextZone::Type type, bool create=false)
returns a textzone content
Definition: STOFFChart.cxx:178
bool m_is3D
a flag to know if the graphic is 3D
Definition: STOFFChart.hxx:326
STOFFGraphicStyle m_style
the chart style
Definition: STOFFChart.hxx:333
Class to store font.
Definition: STOFFFont.hxx:44
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:45
std::shared_ptr< STOFFSpreadsheetListener > STOFFSpreadsheetListenerPtr
a smart pointer of STOFFSpreadsheetListener
Definition: libstaroffice_internal.hxx:497
std::shared_ptr< STOFFListener > STOFFListenerPtr
a smart pointer of STOFFListener
Definition: libstaroffice_internal.hxx:491
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:767
STOFFVec2< float > STOFFVec2f
STOFFVec2 of float.
Definition: libstaroffice_internal.hxx:771
Internal: the structures of a STOFFChart.
Definition: STOFFChart.cxx:58
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libstaroffice_internal.cxx:51
@ RightBit
Definition: libstaroffice_internal.hxx:180
Definition: STOFFChart.hxx:98
Type m_type
the sequence type
Definition: STOFFChart.hxx:112
Axis()
constructor
Definition: STOFFChart.cxx:379
librevenge::RVNGString m_title
the title label
Definition: STOFFChart.hxx:129
void addContentTo(int coord, librevenge::RVNGPropertyList &propList) const
add content to the propList
Definition: STOFFChart.cxx:398
Position m_labelRanges[2]
the label range if defined
Definition: STOFFChart.hxx:122
void addStyleTo(librevenge::RVNGPropertyList &propList) const
add style to the propList
Definition: STOFFChart.cxx:453
bool m_showTitle
show or not the title/subtitle
Definition: STOFFChart.hxx:125
~Axis()
destructor
Definition: STOFFChart.cxx:394
bool m_automaticScaling
automatic scaling (or manual)
Definition: STOFFChart.hxx:114
Type
the axis content
Definition: STOFFChart.hxx:100
@ A_None
Definition: STOFFChart.hxx:100
@ A_Numeric
Definition: STOFFChart.hxx:100
@ A_Sequence_Skip_Empty
Definition: STOFFChart.hxx:100
@ A_Sequence
Definition: STOFFChart.hxx:100
@ A_Logarithmic
Definition: STOFFChart.hxx:100
bool m_showGrid
show or not the grid
Definition: STOFFChart.hxx:118
friend std::ostream & operator<<(std::ostream &o, Axis const &axis)
operator<<
Definition: STOFFChart.cxx:467
STOFFVec2f m_scaling
the minimum, maximum scaling(if manual)
Definition: STOFFChart.hxx:116
librevenge::RVNGString m_subTitle
the subtitle label
Definition: STOFFChart.hxx:131
Position m_titleRange
the title cell range
Definition: STOFFChart.hxx:127
STOFFGraphicStyle m_style
the graphic style
Definition: STOFFChart.hxx:133
bool m_showLabel
show or not the label
Definition: STOFFChart.hxx:120
a legend in a chart
Definition: STOFFChart.hxx:136
int m_relativePosition
the automatic position libstoff::LeftBit|...
Definition: STOFFChart.hxx:158
Legend()
constructor
Definition: STOFFChart.hxx:138
bool m_show
show or not the legend
Definition: STOFFChart.hxx:154
STOFFGraphicStyle m_style
the graphic style
Definition: STOFFChart.hxx:164
friend std::ostream & operator<<(std::ostream &o, Legend const &legend)
operator<<
Definition: STOFFChart.cxx:539
STOFFVec2f m_position
the position in points
Definition: STOFFChart.hxx:160
STOFFFont m_font
the font
Definition: STOFFChart.hxx:162
void addContentTo(librevenge::RVNGPropertyList &propList) const
add content to the propList
Definition: STOFFChart.cxx:510
void addStyleTo(librevenge::RVNGPropertyList &propList) const
add style to the propList
Definition: STOFFChart.cxx:532
bool m_autoPosition
automatic position
Definition: STOFFChart.hxx:156
a cell position
Definition: STOFFChart.hxx:62
bool operator!=(Position &pos) const
operator!=
Definition: STOFFChart.hxx:89
friend std::ostream & operator<<(std::ostream &o, Position const &pos)
operator<<
Definition: STOFFChart.cxx:367
STOFFVec2i m_pos
the cell column and row
Definition: STOFFChart.hxx:94
Position(STOFFVec2i pos=STOFFVec2i(-1,-1), librevenge::RVNGString const &sheetName="")
constructor
Definition: STOFFChart.hxx:64
bool valid() const
return true if the position is valid
Definition: STOFFChart.hxx:70
bool valid(Position const &maxPos) const
return true if the position is valid
Definition: STOFFChart.hxx:75
librevenge::RVNGString getCellName() const
return the cell name
Definition: STOFFChart.cxx:354
bool operator==(Position &pos) const
operator==
Definition: STOFFChart.hxx:84
librevenge::RVNGString m_sheetName
the cell sheet name
Definition: STOFFChart.hxx:96
a serie in a chart
Definition: STOFFChart.hxx:167
PointType
the point type
Definition: STOFFChart.hxx:171
@ P_Hourglass
Definition: STOFFChart.hxx:173
@ P_Arrow_Down
Definition: STOFFChart.hxx:172
@ P_Star
Definition: STOFFChart.hxx:174
@ P_Arrow_Up
Definition: STOFFChart.hxx:173
@ P_None
Definition: STOFFChart.hxx:172
@ P_Arrow_Left
Definition: STOFFChart.hxx:173
@ P_Circle
Definition: STOFFChart.hxx:174
@ P_Asterisk
Definition: STOFFChart.hxx:174
@ P_Horizontal_Bar
Definition: STOFFChart.hxx:175
@ P_Plus
Definition: STOFFChart.hxx:174
@ P_Diamond
Definition: STOFFChart.hxx:172
@ P_Automatic
Definition: STOFFChart.hxx:172
@ P_Square
Definition: STOFFChart.hxx:172
@ P_Arrow_Right
Definition: STOFFChart.hxx:173
@ P_Bow_Tie
Definition: STOFFChart.hxx:173
@ P_Vertical_Bar
Definition: STOFFChart.hxx:175
@ P_X
Definition: STOFFChart.hxx:174
Position m_legendRange
the legend range if defined
Definition: STOFFChart.hxx:214
Position m_labelRanges[2]
the label ranges if defined(unused)
Definition: STOFFChart.hxx:212
STOFFGraphicStyle m_style
the graphic style
Definition: STOFFChart.hxx:218
Type m_type
the type
Definition: STOFFChart.hxx:204
librevenge::RVNGString m_legendText
the legend name if defined
Definition: STOFFChart.hxx:216
friend std::ostream & operator<<(std::ostream &o, Serie const &series)
operator<<
Definition: STOFFChart.cxx:688
Serie(Serie &&)=default
PointType m_pointType
the point type
Definition: STOFFChart.hxx:220
bool m_useSecondaryY
use or not the secondary y axis
Definition: STOFFChart.hxx:208
bool is1DStyle() const
return true if the serie style is 1D
Definition: STOFFChart.hxx:186
void addStyleTo(librevenge::RVNGPropertyList &propList) const
add style to the propList
Definition: STOFFChart.cxx:667
Type
the series type
Definition: STOFFChart.hxx:169
@ S_Bar
Definition: STOFFChart.hxx:169
@ S_Circle
Definition: STOFFChart.hxx:169
@ S_Line
Definition: STOFFChart.hxx:169
@ S_Ring
Definition: STOFFChart.hxx:169
@ S_Area
Definition: STOFFChart.hxx:169
@ S_Bubble
Definition: STOFFChart.hxx:169
@ S_Radar
Definition: STOFFChart.hxx:169
@ S_Surface
Definition: STOFFChart.hxx:169
@ S_Column
Definition: STOFFChart.hxx:169
@ S_Scatter
Definition: STOFFChart.hxx:169
@ S_Stock
Definition: STOFFChart.hxx:169
@ S_Gantt
Definition: STOFFChart.hxx:169
void addContentTo(librevenge::RVNGPropertyList &propList) const
add content to the propList
Definition: STOFFChart.cxx:618
Serie(Serie const &)=default
Serie & operator=(Serie &&)=default
Serie & operator=(Serie const &)=default
STOFFFont m_font
the label font
Definition: STOFFChart.hxx:210
Position m_ranges[2]
the data range
Definition: STOFFChart.hxx:206
bool valid() const
return true if the serie is valid
Definition: STOFFChart.hxx:191
virtual ~Serie()
destructor
Definition: STOFFChart.cxx:579
static std::string getSerieTypeName(Type type)
returns a string corresponding to a series type
Definition: STOFFChart.cxx:583
Serie()
constructor
Definition: STOFFChart.cxx:568
a text zone a chart
Definition: STOFFChart.hxx:223
Position m_cell
the cell position ( or title and subtitle)
Definition: STOFFChart.hxx:261
TextZone(Type type)
constructor
Definition: STOFFChart.cxx:761
ContentType
the text content type
Definition: STOFFChart.hxx:227
@ C_Cell
Definition: STOFFChart.hxx:227
@ C_Text
Definition: STOFFChart.hxx:227
void addStyleTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition: STOFFChart.cxx:815
bool m_show
true if the zone is visible
Definition: STOFFChart.hxx:257
ContentType m_contentType
the content type
Definition: STOFFChart.hxx:255
bool valid() const
returns true if the textbox is valid
Definition: STOFFChart.hxx:234
STOFFVec2f m_position
the position in the zone
Definition: STOFFChart.hxx:259
STOFFFont m_font
the zone format
Definition: STOFFChart.hxx:265
~TextZone()
destructor
Definition: STOFFChart.cxx:774
friend std::ostream & operator<<(std::ostream &o, TextZone const &zone)
operator<<
Definition: STOFFChart.cxx:821
STOFFGraphicStyle m_style
the graphic style
Definition: STOFFChart.hxx:267
Type m_type
the zone type
Definition: STOFFChart.hxx:253
Type
the text type
Definition: STOFFChart.hxx:225
@ T_SubTitle
Definition: STOFFChart.hxx:225
@ T_Footer
Definition: STOFFChart.hxx:225
@ T_Title
Definition: STOFFChart.hxx:225
std::vector< STOFFEntry > m_textEntryList
the text entry (or the list of text entry)
Definition: STOFFChart.hxx:263
void addContentTo(librevenge::RVNGPropertyList &propList) const
add content to the propList
Definition: STOFFChart.cxx:778
the class to store a color
Definition: libstaroffice_internal.hxx:189

Generated on Wed Mar 15 2023 00:00:00 for libstaroffice by doxygen 1.9.1