LotusChart.h
Go to the documentation of this file.
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 (william.lachance@sympatico.ca)
12  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
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 LOTUS_CHART_H
23 #define LOTUS_CHART_H
24 
25 #include <ostream>
26 #include <string>
27 #include <map>
28 #include <vector>
29 
30 #include <librevenge-stream/librevenge-stream.h>
31 
32 #include "libwps_internal.h"
33 
34 #include "WPSDebug.h"
35 #include "WKSChart.h"
36 #include "WKSContentListener.h"
37 
38 #include "Lotus.h"
39 
40 namespace LotusChartInternal
41 {
42 class Chart;
43 struct State;
44 }
45 
46 class LotusStyleManager;
47 class WPSGraphicStyle;
48 
54 {
55 public:
56  friend class LotusParser;
58 
60  explicit LotusChart(LotusParser &parser);
62  void cleanState();
64  void updateState();
66  ~LotusChart();
69  {
70  m_listener = listen;
71  }
72 
73 protected:
75  int version() const;
76 
78  int getNumCharts() const;
80  std::map<std::string,int> getNameToChartIdMap() const;
82  void updateChart(LotusChartInternal::Chart &chart, int id);
84  bool sendCharts();
86  bool sendChart(int cId, WPSPosition const &pos, WPSGraphicStyle const &style);
88  bool sendText(std::shared_ptr<WPSStream> stream, WPSEntry const &entry);
89 
91  bool readChart(std::shared_ptr<WPSStream> stream);
93  bool readChartName(std::shared_ptr<WPSStream> stream);
94 
95  // zone 1b
96 
98  bool readMacHeader(std::shared_ptr<WPSStream> stream, long endPos, int &chartId);
100  bool readMacPlacement(std::shared_ptr<WPSStream> stream, long endPos);
102  bool readMacLegend(std::shared_ptr<WPSStream> stream, long endPos);
104  bool readMacPlotArea(std::shared_ptr<WPSStream> stream, long endPos);
106  bool readMacAxis(std::shared_ptr<WPSStream> stream, long endPos);
108  bool readMacSerie(std::shared_ptr<WPSStream> stream, long endPos);
110  bool readMacFloor(std::shared_ptr<WPSStream> stream, long endPos);
112  bool readMacPosition(std::shared_ptr<WPSStream> stream, long endPos);
113 
115  bool readPlotArea(std::shared_ptr<WPSStream> stream, long endPos);
117  bool readSerie(std::shared_ptr<WPSStream> stream, long endPos);
119  bool readSerieName(std::shared_ptr<WPSStream> stream, long endPos);
121  bool readSerieWidth(std::shared_ptr<WPSStream> stream, long endPos);
123  bool readFontsStyle(std::shared_ptr<WPSStream> stream, long endPos);
125  bool readFramesStyle(std::shared_ptr<WPSStream> stream, long endPos);
126 
128  bool convert(LotusParser::Link const &link, WKSChart::Position(&positions)[2]) const;
129 private:
130  LotusChart(LotusChart const &orig) = delete;
131  LotusChart &operator=(LotusChart const &orig) = delete;
132  std::shared_ptr<WKSContentListener> m_listener;
136  std::shared_ptr<LotusStyleManager> m_styleManager;
138  std::shared_ptr<LotusChartInternal::State> m_state;
139 };
140 
141 #endif /* WPS4_H */
142 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WKSChart::TextZone::m_contentType
ContentType m_contentType
the content type
Definition: WKSChart.h:266
LotusChartInternal::State::m_chartId
int m_chartId
the current chart id(wps3Mac)
Definition: LotusChart.cpp:162
LotusChart::readSerieWidth
bool readSerieWidth(std::shared_ptr< WPSStream > stream, long endPos)
reads a serie width style: 2a33
Definition: LotusChart.cpp:1537
WKSChart::Serie::S_Line
@ S_Line
Definition: WKSChart.h:162
WPSColor::white
static WPSColor white()
return the white color
Definition: libwps_internal.h:311
LotusChart.h
LotusChartInternal::Chart::m_serieFormats
SerieFormat m_serieFormats[6]
the series format
Definition: LotusChart.cpp:100
WKSChart::Axis::A_Logarithmic
@ A_Logarithmic
Definition: WKSChart.h:91
LotusChart::m_listener
std::shared_ptr< WKSContentListener > m_listener
Definition: LotusChart.h:132
WPSPosition::getScaleFactor
static float getScaleFactor(librevenge::RVNGUnit orig, librevenge::RVNGUnit dest)
returns a float which can be used to convert between to unit
Definition: WPSPosition.h:136
WKSChart::TextZone::m_font
WPSFont m_font
the zone format
Definition: WKSChart.h:276
libwps::DebugStream::str
static std::string str()
Definition: WPSDebug.h:200
LotusChartInternal::Chart::SerieFormat::m_align
int m_align
the label alignement
Definition: LotusChart.cpp:96
LotusChart::m_styleManager
std::shared_ptr< LotusStyleManager > m_styleManager
the style manager
Definition: LotusChart.h:136
WKSChart::Serie::P_Diamond
@ P_Diamond
Definition: WKSChart.h:166
libwps::DebugFile::addPos
static void addPos(long)
Definition: WPSDebug.h:220
LotusChartInternal::State::State
State()
constructor
Definition: LotusChart.cpp:132
LotusChart
This class parses Microsoft Works chart file.
Definition: LotusChart.h:53
LotusParser::getSheetName
librevenge::RVNGString getSheetName(int id) const
returns the name of the id's spreadsheet
Definition: Lotus.cpp:318
WKSChart::Serie::P_Automatic
@ P_Automatic
Definition: WKSChart.h:166
WKSChart::Axis::m_titleRange
Position m_titleRange
the title cell range
Definition: WKSChart.h:118
LotusChartInternal::Chart::SerieFormat::m_color
int m_color
the color
Definition: LotusChart.cpp:88
WPSPosition::m_anchorTo
AnchorTo m_anchorTo
anchor position
Definition: WPSPosition.h:239
LotusChart::m_mainParser
LotusParser & m_mainParser
the listener (if set)
Definition: LotusChart.h:134
LotusChart::readMacSerie
bool readMacSerie(std::shared_ptr< WPSStream > stream, long endPos)
reads a serie style(wk3mac): 27e2
Definition: LotusChart.cpp:816
LotusChartInternal::Chart::m_fileType
int m_fileType
the chart type
Definition: LotusChart.cpp:70
WKSChart::Legend::m_show
bool m_show
show or not the legend
Definition: WKSChart.h:146
LotusChart::version
int version() const
return the file version
Definition: LotusChart.cpp:240
LotusChartInternal::Chart
the chart of a Lotus Pro Dos
Definition: LotusChart.cpp:54
LotusChartInternal::Chart::SerieFormat::SerieFormat
SerieFormat()
constructor
Definition: LotusChart.cpp:79
WKSChart::TextZone::T_SubTitle
@ T_SubTitle
Definition: WKSChart.h:234
WKSChart::Serie::P_Vertical_Bar
@ P_Vertical_Bar
Definition: WKSChart.h:169
WKSChart::Serie::P_Bow_Tie
@ P_Bow_Tie
Definition: WKSChart.h:167
LotusChartInternal::State::m_version
int m_version
the file version
Definition: LotusChart.cpp:158
LotusChartInternal::Chart::m_fileSerieStyles
bool m_fileSerieStyles
a flag to know if we have seen some serie style
Definition: LotusChart.cpp:74
WKSChart::Serie::P_Plus
@ P_Plus
Definition: WKSChart.h:168
WKSChart::TextZone::m_textEntryList
std::vector< WPSEntry > m_textEntryList
the text entry (or the list of text entry)
Definition: WKSChart.h:274
WKSChart::TextZone::Type
Type
the text type
Definition: WKSChart.h:234
LotusChart::readMacFloor
bool readMacFloor(std::shared_ptr< WPSStream > stream, long endPos)
reads a 3D floor style(wk3mac): 2846
Definition: LotusChart.cpp:1043
LotusChartInternal::State::m_idChartMap
std::map< int, std::shared_ptr< Chart > > m_idChartMap
list of chart
Definition: LotusChart.cpp:160
LotusStyleManager
This class parses the Lotus style.
Definition: LotusStyleManager.h:47
libwps_tools_win::Font::unicodeString
static librevenge::RVNGString unicodeString(const unsigned char *p, unsigned long size, Type type, bool skipUnknown=true)
converts a list of character in unicode
Definition: libwps_tools_win.cpp:7283
LotusParser::getDefaultFontType
libwps_tools_win::Font::Type getDefaultFontType() const
returns the default font type, ie.
Definition: Lotus.cpp:273
WPSColor::isWhite
bool isWhite() const
return true if the color is white
Definition: libwps_internal.h:350
WKSChart::Serie::P_Arrow_Down
@ P_Arrow_Down
Definition: WKSChart.h:166
LotusChart::m_state
std::shared_ptr< LotusChartInternal::State > m_state
the internal state
Definition: LotusChart.h:138
LotusChart::sendText
bool sendText(std::shared_ptr< WPSStream > stream, WPSEntry const &entry)
try to send the text
Definition: LotusChart.cpp:2120
LotusChartInternal::State::getChart
std::shared_ptr< Chart > getChart(int id, LotusChart &parser, std::shared_ptr< WPSStream > stream)
returns a chart corresponding to an id, create it if needed.
Definition: LotusChart.cpp:143
LotusChart::~LotusChart
~LotusChart()
destructor
Definition: LotusChart.cpp:176
WPSEntry::valid
bool valid(bool checkId=false) const
returns true if the zone length is positive
Definition: WPSEntry.h:87
WKSChart::getAxis
Axis & getAxis(int coord)
return an axis (corresponding to a coord)
Definition: WKSChart.cpp:136
WPSEntry
basic class to store an entry in a file This contained :
Definition: WPSEntry.h:38
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition: libwps_internal.h:702
WKSChart::getSerie
Serie * getSerie(int id, bool create)
return a serie
Definition: WKSChart.cpp:156
LotusChart::readFramesStyle
bool readFramesStyle(std::shared_ptr< WPSStream > stream, long endPos)
reads a some frame styles: 2a35
Definition: LotusChart.cpp:1739
WKSChart::Serie::P_X
@ P_X
Definition: WKSChart.h:168
LotusChartInternal::Chart::SerieFormat::m_format
int m_format
the format
Definition: LotusChart.cpp:94
libwps::readDouble10
bool readDouble10(RVNGInputStreamPtr &input, double &res, bool &isNaN)
read a double store with 10 bytes: mantisse 8 bytes, exponent 2 bytes
Definition: libwps_internal.cpp:224
WPSListenerPtr
std::shared_ptr< WPSListener > WPSListenerPtr
shared pointer to WPSListener
Definition: libwps_internal.h:105
WPSGraphicStyle::Pattern::m_colors
WPSColor m_colors[2]
the two indexed colors
Definition: WPSGraphicStyle.h:189
LotusParser::getLinksList
std::vector< Link > getLinksList(int lId) const
returns a list of links corresponding to an id
Definition: Lotus.cpp:291
LotusChart::getNumCharts
int getNumCharts() const
return the number of chart
Definition: LotusChart.cpp:235
Vec2f
Vec2< float > Vec2f
Vec2 of float.
Definition: libwps_internal.h:704
WPSGraphicStyle::Pattern::getAverageColor
bool getAverageColor(WPSColor &col) const
return the average color
Definition: WPSGraphicStyle.cpp:61
WKSChart::Serie::P_Asterisk
@ P_Asterisk
Definition: WKSChart.h:168
LotusChart::readPlotArea
bool readPlotArea(std::shared_ptr< WPSStream > stream, long endPos)
reads a plot area style: 2a30 (unsure)
Definition: LotusChart.cpp:1572
LotusChart::readMacPlacement
bool readMacPlacement(std::shared_ptr< WPSStream > stream, long endPos)
reads a placement position(wk3mac): 2774
Definition: LotusChart.cpp:990
WKSChart::Serie::S_Area
@ S_Area
Definition: WKSChart.h:162
Vec2< int >
LotusChart::operator=
LotusChart & operator=(LotusChart const &orig)=delete
LotusChart::sendChart
bool sendChart(int cId, WPSPosition const &pos, WPSGraphicStyle const &style)
try to send a chart
Definition: LotusChart.cpp:2165
WKSChart
a class used to store a chart associated to a spreadsheet ....
Definition: WKSChart.h:45
WKSChart::Serie::S_Bar
@ S_Bar
Definition: WKSChart.h:162
WPS_DEBUG_MSG
#define WPS_DEBUG_MSG(M)
Definition: libwps_internal.h:134
WKSChart::Serie::P_Square
@ P_Square
Definition: WKSChart.h:166
LotusParser
This class parses a wk3,wk4,123 Lotus spreadsheet.
Definition: Lotus.h:72
WPSGraphicStyle::emptyStyle
static WPSGraphicStyle emptyStyle()
returns an empty style.
Definition: WPSGraphicStyle.h:237
LotusParser::version
int version() const
return the file version
Definition: Lotus.cpp:265
WPSEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: WPSEntry.h:55
LotusChartInternal::Chart::SerieFormat::m_hash
int m_hash
the hash
Definition: LotusChart.cpp:90
WKSContentListenerPtr
std::shared_ptr< WKSContentListener > WKSContentListenerPtr
shared pointer to WKSContentListener
Definition: libwps_internal.h:114
WPSFont.h
WKSChart::Serie::S_Circle
@ S_Circle
Definition: WKSChart.h:162
WKSChart::Serie::S_Radar
@ S_Radar
Definition: WKSChart.h:162
LotusChart::updateChart
void updateChart(LotusChartInternal::Chart &chart, int id)
update a chart, so that it can be send
Definition: LotusChart.cpp:1937
LotusChart::readSerie
bool readSerie(std::shared_ptr< WPSStream > stream, long endPos)
reads a serie style: 2a31
Definition: LotusChart.cpp:1221
WPSBorder::RightBit
@ RightBit
Definition: libwps_internal.h:401
WPSEntry.h
WPSGraphicStyle
a structure used to define a picture style
Definition: WPSGraphicStyle.h:37
WKSChart::Serie::P_Star
@ P_Star
Definition: WKSChart.h:168
LotusChart::sendCharts
bool sendCharts()
try to send the charts(for Windows .wk3 file)
Definition: LotusChart.cpp:2135
LotusStyleManager.h
libwps::DebugFile::addNote
static void addNote(char const *)
Definition: WPSDebug.h:221
WPSEntry::begin
long begin() const
returns the begin offset
Definition: WPSEntry.h:71
WKSChart::Legend::m_autoPosition
bool m_autoPosition
automatic position
Definition: WKSChart.h:148
libwps::read8
int8_t read8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:59
WKSChart::Axis::A_Numeric
@ A_Numeric
Definition: WKSChart.h:91
LotusChart::LotusChart
LotusChart(LotusParser &parser)
constructor
Definition: LotusChart.cpp:168
LotusChart::readMacPlotArea
bool readMacPlotArea(std::shared_ptr< WPSStream > stream, long endPos)
reads a plot area position(wk3mac): 2788
Definition: LotusChart.cpp:1140
LotusChart::readMacPosition
bool readMacPosition(std::shared_ptr< WPSStream > stream, long endPos)
reads a manual position(wk3mac): 2904
Definition: LotusChart.cpp:1185
WKSChart::getTextZone
TextZone * getTextZone(TextZone::Type type, bool create=false)
returns a textzone content
Definition: WKSChart.cpp:166
WPSPosition::unit
librevenge::RVNGUnit unit() const
returns the unit
Definition: WPSPosition.h:131
Lotus.h
WKSChart::Serie::S_Scatter
@ S_Scatter
Definition: WKSChart.h:162
WPSEntry::length
long length() const
returns the length of the zone
Definition: WPSEntry.h:81
WKSChart::getIdSerieMap
const std::map< int, Serie > & getIdSerieMap() const
returns the list of defined series
Definition: WKSChart.h:314
WKSChart::TextZone::T_Title
@ T_Title
Definition: WKSChart.h:234
LotusChartInternal::Chart::SerieFormat
wk3 serie format
Definition: LotusChart.cpp:76
LotusChartInternal::Chart::m_stream
std::shared_ptr< WPSStream > m_stream
the input stream
Definition: LotusChart.cpp:105
libwps::DebugStream
Definition: WPSDebug.h:191
LotusChart::readChartName
bool readChartName(std::shared_ptr< WPSStream > stream)
reads the chart name or title: 12
Definition: LotusChart.cpp:635
libwps::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:40
LotusChartInternal
Definition: LotusChart.cpp:49
LotusChart::readSerieName
bool readSerieName(std::shared_ptr< WPSStream > stream, long endPos)
reads a serie name: 2a32 (serie 6-...)
Definition: LotusChart.cpp:1489
WKSChart::Serie::P_Horizontal_Bar
@ P_Horizontal_Bar
Definition: WKSChart.h:169
WKSChart::Legend::m_relativePosition
int m_relativePosition
the automatic position libwps::LeftBit|...
Definition: WKSChart.h:150
libwps_tools_win.h
WPSGraphicStyle::setSurfaceColor
void setSurfaceColor(WPSColor const &col, float opacity=1)
set the surface color
Definition: WPSGraphicStyle.h:251
LotusChartInternal::Chart::m_hasLegend
bool m_hasLegend
a flag to know if we have some legend
Definition: LotusChart.cpp:72
WPSPosition::Page
@ Page
Definition: WPSPosition.h:43
WKSChart.h
WPSEntry::setEnd
void setEnd(long e)
sets the end offset
Definition: WPSEntry.h:65
WKSChart::Serie::m_ranges
Position m_ranges[2]
the data range
Definition: WKSChart.h:214
libwps::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:64
WKSChart::Serie::P_None
@ P_None
Definition: WKSChart.h:166
libwps_tools_win::Language::name
std::string name(long id)
returns the name given Windows© id
Definition: libwps_tools_win.cpp:7332
WPSGraphicStyle::m_lineColor
WPSColor m_lineColor
the line color
Definition: WPSGraphicStyle.h:352
LotusChart::readMacLegend
bool readMacLegend(std::shared_ptr< WPSStream > stream, long endPos)
reads a legend position(wk3mac): 277e
Definition: LotusChart.cpp:1093
LotusChartInternal::Chart::Chart
Chart(LotusChart &parser, std::shared_ptr< WPSStream > const &stream)
constructor
Definition: LotusChart.cpp:58
LotusChart::readMacHeader
bool readMacHeader(std::shared_ptr< WPSStream > stream, long endPos, int &chartId)
reads a chart data: 2710 (wk3mac)
Definition: LotusChart.cpp:732
WPSPosition.h
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
LotusChartInternal::Chart::SerieFormat::m_yAxis
int m_yAxis
the y axis
Definition: LotusChart.cpp:92
WPSPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: WPSPosition.h:39
WPSPosition::size
const Vec2f & size() const
returns the frame size
Definition: WPSPosition.h:121
WPSDebug.h
libwps::DebugFile::addDelimiter
static void addDelimiter(long, char)
Definition: WPSDebug.h:222
WKSChart::TextZone::T_Footer
@ T_Footer
Definition: WKSChart.h:234
WKSChart::Serie::P_Arrow_Up
@ P_Arrow_Up
Definition: WKSChart.h:167
libwps::read16
int16_t read16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:71
LotusChart::readChart
bool readChart(std::shared_ptr< WPSStream > stream)
reads a structure which define a chart: 11
Definition: LotusChart.cpp:254
libwps_internal.h
WKSChart::m_type
Serie::Type m_type
the chart type (if no series)
Definition: WKSChart.h:329
LotusChart::readMacAxis
bool readMacAxis(std::shared_ptr< WPSStream > stream, long endPos)
reads an axis style(wk3mac): 27d8
Definition: LotusChart.cpp:776
WKSContentListener.h
WPSGraphicStyle::Pattern
a basic pattern used in a WPSGraphicStyle:
Definition: WPSGraphicStyle.h:88
WPSColor
the class to store a color
Definition: libwps_internal.h:280
WKSChart::Position
a cell position
Definition: WKSChart.h:50
WPSBox2< float >
LotusChart::setListener
void setListener(WKSContentListenerPtr &listen)
sets the listener
Definition: LotusChart.h:68
WPSStream.h
WKSChart::Axis::m_labelRanges
Position m_labelRanges[2]
the label range if defined
Definition: WKSChart.h:113
LotusChartInternal::Chart::m_parser
LotusChart & m_parser
the parser
Definition: LotusChart.cpp:103
WKSChart::TextZone
a text zone a chart
Definition: WKSChart.h:231
LotusChart::getNameToChartIdMap
std::map< std::string, int > getNameToChartIdMap() const
returns a map chart name to chart id map
Definition: LotusChart.cpp:185
libwps::DebugFile
Definition: WPSDebug.h:207
WKSChart::Serie::S_Stock
@ S_Stock
Definition: WKSChart.h:162
WKSChart::TextZone::C_Text
@ C_Text
Definition: WKSChart.h:236
WPSGraphicStyle::m_lineWidth
float m_lineWidth
the linewidth
Definition: WPSGraphicStyle.h:342
LotusChartInternal::State
the state of LotusChart
Definition: LotusChart.cpp:129
WKSChart::getLegend
const Legend & getLegend() const
returns the legend
Definition: WKSChart.h:301
LotusChart::convert
bool convert(LotusParser::Link const &link, WKSChart::Position(&positions)[2]) const
convert a link zone in a chart position(if possible)
Definition: LotusChart.cpp:1926
LotusChartInternal::Chart::sendContent
void sendContent(TextZone const &zone, WPSListenerPtr &listener) const final
send the zone content (called when the zone is of text type)
Definition: LotusChart.cpp:108
WPSGraphicStyle::Pattern::getUniqueColor
bool getUniqueColor(WPSColor &col) const
check if the pattern has only one color; if so returns true...
Definition: WPSGraphicStyle.cpp:45
LotusChart::readFontsStyle
bool readFontsStyle(std::shared_ptr< WPSStream > stream, long endPos)
reads a list of font style: 2a34
Definition: LotusChart.cpp:1697
WPSGraphicStyle::setPattern
void setPattern(Pattern const &pat)
set the pattern
Definition: WPSGraphicStyle.h:262
WPSColor::black
static WPSColor black()
return the back color
Definition: libwps_internal.h:306
LotusChart::updateState
void updateState()
update internal state (must be called one time before sending data)
Definition: LotusChart.cpp:197
WPSColor::isBlack
bool isBlack() const
return true if the color is black
Definition: libwps_internal.h:345
WKSChart::Serie::P_Circle
@ P_Circle
Definition: WKSChart.h:168
LotusChart::cleanState
void cleanState()
clean internal state
Definition: LotusChart.cpp:180

Generated on Sat Sep 11 2021 08:45:27 for libwps by doxygen 1.8.17