Commit a2d37e8a authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormaReader - fix 3d charts with 2 axis

parent b13eba5f
......@@ -47,7 +47,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_UNICODE;UNICODE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
......
......@@ -48,13 +48,19 @@ _CP_PTR(oox_axis_content) oox_axis_content::create(int type)
oox_axis_content::oox_axis_content(int type/*,std::wstring name*/)
{
//id_ = abs((int)*((_UINT32*)this));
if (type == 0)
{
id_ = 0;
}
else
{
id_ = abs((long)this);
type_=type; //dimension
}
type_ = type;
}
void oox_axis_content::oox_serialize(std::wostream & _Wostream)
{
if (id_ <0 )return;//not activate
if (id_ < 1 )return; //not activate, blank axis
CP_XML_WRITER(_Wostream)
{
......
......@@ -153,7 +153,7 @@ void oox_chart_context::serialize(std::wostream & strm)
}
CP_XML_NODE(L"c:dispBlanksAs")
{
CP_XML_ATTR(L"val", L"zero");
CP_XML_ATTR(L"val", plot_area_.current_chart_->dispBlanksAs_);
}
CP_XML_NODE(L"c:showDLblsOverMax")
{
......
......@@ -250,7 +250,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
CP_XML_CONTENT(values_[i].numRef_.formula);
}
if (values_[i].numRef_.num_cache_count>0)
if (values_[i].numRef_.num_cache_count > 0)
{
CP_XML_NODE(L"c:numCache")
{
......
......@@ -31,10 +31,10 @@
*/
#include "oox_plot_area.h"
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/style_text_properties.h"
#include "oox_chart_shape.h"
......@@ -90,7 +90,7 @@ void oox_plot_area::add_chart(int type)
void oox_plot_area::add_axis(int type, odf_reader::chart::axis & content)
{
oox_axis_content_ptr ax=oox_axis_content::create(type);
oox_axis_content_ptr ax = oox_axis_content::create(type);
ax->content_ = content;
axis_.push_back(ax);
......@@ -98,21 +98,25 @@ void oox_plot_area::add_axis(int type, odf_reader::chart::axis & content)
void oox_plot_area::reset_cross_axis()//обязательно после всех добавлений
{
BOOST_FOREACH(oox_axis_content_ptr const & ax, axis_)
for (size_t i = 0; i < axis_.size(); i++)
{
BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
for (size_t j = 0; j < charts_.size(); j++)
{
ch->add_axis(ax->get_Id());
charts_[j]->add_axis(axis_[i]->get_Id());
}
}
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
for (size_t i = 0; i < axis_.size(); i++)
{
int curr_id = a->get_Id();
BOOST_FOREACH(oox_axis_content_ptr const & b, axis_)
int curr_id = axis_[i]->get_Id();
if (curr_id < 1) continue;
for (size_t j = 0; j < axis_.size(); j++)
{
if (b->get_Id()==curr_id)continue;
b->add_CrossedId(curr_id);
if (axis_[j]->get_Id() == curr_id)continue;
axis_[j]->add_CrossedId(curr_id);
}
}
}
......@@ -130,18 +134,18 @@ void oox_plot_area::oox_serialize(std::wostream & _Wostream)
//CP_XML_NODE(L"c:layout"){}
bool axisPresent = true;
BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
for (size_t i = 0; i < charts_.size(); i++)
{
ch->oox_serialize(CP_XML_STREAM());
charts_[i]->oox_serialize(CP_XML_STREAM());
if (ch->type_ == CHART_TYPE_PIE ||
ch->type_ == CHART_TYPE_DOUGHNUT) axisPresent = false;
if (charts_[i]->type_ == CHART_TYPE_PIE ||
charts_[i]->type_ == CHART_TYPE_DOUGHNUT) axisPresent = false;
}
if (axisPresent)
{
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
for (size_t i = 0; i < axis_.size(); i++)
{
a->oox_serialize(CP_XML_STREAM());
axis_[i]->oox_serialize(CP_XML_STREAM());
}
}
shape.oox_serialize(CP_XML_STREAM());
......
......@@ -63,7 +63,7 @@ void oox_chart::set_content_series(odf_reader::chart::series & content)
}
void oox_chart::set_values_series(int ind, std::vector<std::wstring> & val)
{
if (val.size()<1)return;
if (val.empty())return;
oox_series_ptr & current_ptr = series_.back();
current_ptr->setValues (ind, val);
......@@ -74,9 +74,11 @@ void oox_chart::set_properties(std::vector<odf_reader::_property> g)
_CP_OPT(bool) bStacked;
_CP_OPT(bool) bPercent;
_CP_OPT(int) iGapWidth;
odf_reader::GetProperty(g, L"stacked",bStacked);
odf_reader::GetProperty(g, L"percentage",bPercent);
odf_reader::GetProperty(g, L"stacked", bStacked);
odf_reader::GetProperty(g, L"percentage", bPercent);
odf_reader::GetProperty(g, L"gap-width", iGapWidth);
if ( (bStacked) && (bStacked.get()))
{
......@@ -87,6 +89,10 @@ void oox_chart::set_properties(std::vector<odf_reader::_property> g)
{
grouping_ = L"percentStacked";
}
if (iGapWidth)
{
dispBlanksAs_ = L"gap";
}
//solid-type - трехмерные
}
void oox_chart::oox_serialize_common(std::wostream & _Wostream)
......@@ -128,17 +134,15 @@ void oox_bar_chart::set_properties(std::vector<odf_reader::_property> g)
{
oox_chart::set_properties(g);
odf_reader::GetProperty(g, L"vertical",bVertical);
odf_reader::GetProperty(g, L"connect-bars",bConnectBars);
odf_reader::GetProperty(g, L"vertical", bVertical);
odf_reader::GetProperty(g, L"connect-bars", bConnectBars);
odf_reader::GetProperty(g, L"gap-width",iGapWidth);
odf_reader::GetProperty(g, L"overlap",iOverlap);
odf_reader::GetProperty(g, L"gap-width", iGapWidth);
odf_reader::GetProperty(g, L"overlap", iOverlap);
}
void oox_bar_chart::set_additional_properties(std::vector<odf_reader::_property> g)
{
odf_reader::GetProperty(g, L"gap-width",iGapWidth);
odf_reader::GetProperty(g, L"overlap",iOverlap);
}
void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
......@@ -169,13 +173,13 @@ void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
}
CP_XML_NODE(L"c:overlap")//-100 to 100
{
CP_XML_ATTR(L"val",Overlap);
CP_XML_ATTR(L"val", Overlap);
}
if (iGapWidth)
{
CP_XML_NODE(L"c:gapWidth")
{
CP_XML_ATTR(L"val",iGapWidth.get());
CP_XML_ATTR(L"val", iGapWidth.get());
}
}
CP_XML_NODE(L"c:varyColors")
......
......@@ -66,6 +66,7 @@ public:
grouping_ = L"standard";
is3D_ = false;
type_ = 0;
dispBlanksAs_ = L"zero";
}
~oox_chart(){}
......@@ -98,9 +99,10 @@ public:
int type_;
bool is3D_;
std::vector<int> axisId_; //axId (Axis ID) §21.2.2.9
std::wstring dispBlanksAs_;
std::vector<int> axisId_; // axId (Axis ID) §21.2.2.9
std::wstring grouping_; // clustered | percentStacked | stacked | standard
std::vector<oox_series_ptr> series_; //ser (Bar Chart Series) §21.2.2.170
std::vector<oox_series_ptr> series_; // ser (Bar Chart Series) §21.2.2.170
virtual void set_properties(std::vector<odf_reader::_property> g);
virtual void set_additional_properties(std::vector<odf_reader::_property> g){}
......
......@@ -465,6 +465,15 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
bool x_enabled = false;
bool y_enabled = false;
bool z_enabled = false;
bool is3D = false;
_CP_OPT(bool) boolVal;
odf_reader::GetProperty(plot_area_.properties_, L"three-dimensional", boolVal);
if ((boolVal) && (*boolVal))
{
is3D = true;
}
for (int i = 0; i < axises_.size(); i++)
{
......@@ -482,6 +491,8 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
if (class_ == chart_stock && a.type_ == 3 )
a.type_ = 4; //шкала дат.
if (is3D) a.type_ = 1; // шкала категорий
x_enabled = true;
}
else if (a.dimension_ == L"y")
......@@ -499,7 +510,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
}
else if (a.dimension_ == L"z")
{
chart_context.set_3D_chart (true);
is3D = true;
continue;
a.type_ = 2;
z_enabled = true;
......@@ -507,6 +518,18 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
chart_context.add_axis(a.type_, a);
}
if (is3D)
{
if (!z_enabled)
{
chart::axis a;
a.type_ = 0; // blank
chart_context.add_axis(a.type_, a);
}
chart_context.set_3D_chart (true);
}
}
//----------------------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment