Commit 4e9da3ea authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

OdfReader - улучшена конвертация диаграм, ..

parent 3e605b02
...@@ -57,10 +57,10 @@ void oox_axis_content::oox_serialize(std::wostream & _Wostream) ...@@ -57,10 +57,10 @@ void oox_axis_content::oox_serialize(std::wostream & _Wostream)
CP_XML_NODE(L"c:valAx") CP_XML_NODE(L"c:valAx")
{ {
oox_serialize_content(CP_XML_STREAM()); oox_serialize_content(CP_XML_STREAM());
//CP_XML_NODE(L"c:crossBetween") CP_XML_NODE(L"c:crossBetween")
//{ {
// CP_XML_ATTR(L"val", L"between"); CP_XML_ATTR(L"val", L"between");
//} }
//CP_XML_NODE(L"c:numFmt") //CP_XML_NODE(L"c:numFmt")
//{ //{
// CP_XML_ATTR(L"sourceLinked", 1); // CP_XML_ATTR(L"sourceLinked", 1);
...@@ -89,7 +89,7 @@ void oox_axis_content::oox_serialize(std::wostream & _Wostream) ...@@ -89,7 +89,7 @@ void oox_axis_content::oox_serialize(std::wostream & _Wostream)
} }
void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
{ {
//odf::_variant Val; oox_chart_shape shape;
_CP_OPT(bool) boolVal; _CP_OPT(bool) boolVal;
oox_title title; oox_title title;
...@@ -101,10 +101,6 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) ...@@ -101,10 +101,6 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
{ {
CP_XML_ATTR(L"val", id_); CP_XML_ATTR(L"val", id_);
} }
CP_XML_NODE(L"c:delete")//visible item
{
CP_XML_ATTR(L"val", 0);
}
CP_XML_NODE(L"c:scaling") CP_XML_NODE(L"c:scaling")
{ {
CP_XML_NODE(L"c:orientation") CP_XML_NODE(L"c:orientation")
...@@ -128,11 +124,20 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) ...@@ -128,11 +124,20 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
} }
} }
} }
CP_XML_NODE(L"c:delete")//visible item
{
CP_XML_ATTR(L"val", 0);
}
CP_XML_NODE(L"c:axPos")
{
if (content_.dimension_ == L"x")
CP_XML_ATTR(L"val",L"b");// "b" | "l" | "r" | "t"// == bottom left right top
if (content_.dimension_ == L"y")
CP_XML_ATTR(L"val",L"l");// "b" | "l" | "r" | "t"// == bottom left right top
}
//oox_serialize_ln(_Wostream,content_.graphic_properties_); //oox_serialize_ln(_Wostream,content_.graphic_properties_);
oox_chart_shape shape;
shape.set(content_.graphic_properties_,content_.fill_) ;
shape.oox_serialize(_Wostream);
BOOST_FOREACH(odf_reader::chart::axis::grid & g, content_.grids_) BOOST_FOREACH(odf_reader::chart::axis::grid & g, content_.grids_)
{ {
_oox_fill fill_null; _oox_fill fill_null;
...@@ -169,6 +174,21 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) ...@@ -169,6 +174,21 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
} }
} }
} }
title.oox_serialize(_Wostream);
odf_reader::GetProperty(content_.properties_,L"display_label",boolVal);
if ((boolVal == true) && (boolVal.get()==true))
{
CP_XML_NODE(L"c:tickLblPos")
{
CP_XML_ATTR(L"val",L"nextTo");//"high" | "low" | "nextTo" | "none"
}
}
shape.set(content_.graphic_properties_,content_.fill_) ;
shape.oox_serialize(_Wostream);
BOOST_FOREACH(int const & ii, cross_id_) BOOST_FOREACH(int const & ii, cross_id_)
{ {
CP_XML_NODE(L"c:crossAx") CP_XML_NODE(L"c:crossAx")
...@@ -176,28 +196,12 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) ...@@ -176,28 +196,12 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
CP_XML_ATTR(L"val", ii); CP_XML_ATTR(L"val", ii);
} }
} }
CP_XML_NODE(L"c:axPos")
{
if (content_.dimension_ == L"x")
CP_XML_ATTR(L"val",L"b");// "b" | "l" | "r" | "t"// == bottom left right top
if (content_.dimension_ == L"y")
CP_XML_ATTR(L"val",L"l");// "b" | "l" | "r" | "t"// == bottom left right top
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
CP_XML_NODE(L"c:crosses") CP_XML_NODE(L"c:crosses")
{ {
CP_XML_ATTR(L"val", L"autoZero"); //""autoZero" | "max" | "min" CP_XML_ATTR(L"val", L"autoZero"); //""autoZero" | "max" | "min"
} }
odf_reader::GetProperty(content_.properties_,L"display_label",boolVal);
if ((boolVal == true) && (boolVal.get()==true))
{
CP_XML_NODE(L"c:tickLblPos")
{
CP_XML_ATTR(L"val",L"nextTo");//"high" | "low" | "nextTo" | "none"
}
}
title.oox_serialize(_Wostream);
} }
} }
......
...@@ -60,6 +60,12 @@ void oox_chart_context::write_to(std::wostream & strm) ...@@ -60,6 +60,12 @@ void oox_chart_context::write_to(std::wostream & strm)
} }
CP_XML_NODE(L"c:chart") CP_XML_NODE(L"c:chart")
{ {
if (plot_area_.current_chart_->is3D_)
{
//CP_XML_NODE(L"c:view3D");
CP_XML_NODE(L"c:floor");
CP_XML_NODE(L"c:backWall");
}
title_.oox_serialize(CP_XML_STREAM()); title_.oox_serialize(CP_XML_STREAM());
plot_area_.oox_serialize(CP_XML_STREAM()); plot_area_.oox_serialize(CP_XML_STREAM());
legend_.oox_serialize(CP_XML_STREAM()); legend_.oox_serialize(CP_XML_STREAM());
...@@ -68,6 +74,14 @@ void oox_chart_context::write_to(std::wostream & strm) ...@@ -68,6 +74,14 @@ void oox_chart_context::write_to(std::wostream & strm)
{ {
CP_XML_ATTR(L"val",1); CP_XML_ATTR(L"val",1);
} }
CP_XML_NODE(L"c:dispBlanksAs")
{
CP_XML_ATTR(L"val", L"zero");
}
CP_XML_NODE(L"c:showDLblsOverMax")
{
CP_XML_ATTR(L"val",1);
}
} }
oox_chart_shape shape; oox_chart_shape shape;
shape.set(graphic_properties_,fill_); shape.set(graphic_properties_,fill_);
......
...@@ -38,17 +38,16 @@ public: ...@@ -38,17 +38,16 @@ public:
{ {
title_.set_content(t); title_.set_content(t);
} }
void add_axis(int type) void add_axis(int type, odf_reader::chart::axis & content)
{ {
plot_area_.add_axis(type); plot_area_.add_axis(type, content);
} }
void set_content_axis(odf_reader::chart::axis & content) void set_3D_chart(bool val)
{ {
plot_area_.set_content_axis(content); for (int i = 0 ; i < plot_area_.charts_.size(); i++)
}
void set_content_series(odf_reader::chart::series & content)
{ {
plot_area_.set_content_series(content); plot_area_.charts_[i]->is3D_ = val;
}
} }
void add_chart(int type) void add_chart(int type)
{ {
......
...@@ -45,7 +45,17 @@ public: ...@@ -45,7 +45,17 @@ public:
} }
} }
}; };
oox_chart_series::oox_chart_series()
{
values_[0].type = L"c:cat";//
values_[1].type = L"c:val";
values_[2].type = L"c:xVal";
values_[3].type = L"c:yVal";
values_[4].type = L"c:bubbleSize";// !!!!
iSymbolMarkerType_ = 0;
bLocalTable_ = false;
}
void oox_chart_series::setName(std::wstring &value) void oox_chart_series::setName(std::wstring &value)
{ {
name_=value; name_=value;
...@@ -55,18 +65,18 @@ void oox_chart_series::setFormula(int ind, std::wstring &value) ...@@ -55,18 +65,18 @@ void oox_chart_series::setFormula(int ind, std::wstring &value)
{ {
formulasconvert::odf2oox_converter converter; formulasconvert::odf2oox_converter converter;
if (ind == 4) if (ind == 0)
{ {
long res = value.find(L"local-table"); long res = value.find(L"local-table");
if (res >=0) return; if (res >=0) return;
values_[ind].strRef_.formula=converter.convert_chart_distance(value); values_[ind].strRef_.formula = converter.convert_chart_distance(value);
values_[ind].strRef_.present = true; values_[ind].strRef_.present = true;
values_[ind].present = true; values_[ind].present = true;
} }
else else
{ {
values_[ind].numRef_.formula=converter.convert_chart_distance(value); values_[ind].numRef_.formula = converter.convert_chart_distance(value);
values_[ind].numRef_.present = true; values_[ind].numRef_.present = true;
values_[ind].present = true; values_[ind].present = true;
} }
...@@ -97,13 +107,13 @@ void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values) ...@@ -97,13 +107,13 @@ void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values)
{ {
values_[ind].present = true; values_[ind].present = true;
if (ind == 4)values_[ind].strRef_.present = true; if (ind == 0) values_[ind].strRef_.present = true;
else values_[ind].numRef_.present = true; else values_[ind].numRef_.present = true;
BOOST_FOREACH(std::wstring & v, values) BOOST_FOREACH(std::wstring & v, values)
{ {
boost::algorithm::trim(v); boost::algorithm::trim(v);
if (ind == 4) if (ind == 0)
{ {
values_[ind].strRef_.str_cache.push_back(v); values_[ind].strRef_.str_cache.push_back(v);
values_[ind].strRef_.str_cache_count++; values_[ind].strRef_.str_cache_count++;
...@@ -135,7 +145,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) ...@@ -135,7 +145,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
} }
shape.oox_serialize(_Wostream); shape.oox_serialize(_Wostream);
for (int i=0; i < 4; i++) for (int i=0; i < 5; i++)
{ {
if (values_[i].present) if (values_[i].present)
{ {
...@@ -147,12 +157,15 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) ...@@ -147,12 +157,15 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
{ {
CP_XML_NODE(L"c:f") CP_XML_NODE(L"c:f")
{ {
if (values_[i].numRef_.formula.empty())
CP_XML_CONTENT(L"label");
else
CP_XML_CONTENT(values_[i].numRef_.formula); 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")// CP_XML_NODE(L"c:numCache")
{ {
CP_XML_NODE(L"c:formatCode") CP_XML_NODE(L"c:formatCode")
{ {
...@@ -214,6 +227,38 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) ...@@ -214,6 +227,38 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
} }
} }
} }
else if (values_[i].strRef_.present > 0 && !bLocalTable_)
{
CP_XML_NODE(L"c:strRef")
{
CP_XML_NODE(L"c:f")
{
if (values_[i].strRef_.formula.empty())
CP_XML_CONTENT(L"label");
else
CP_XML_CONTENT(values_[i].strRef_.formula);
}
CP_XML_NODE(L"c:strCache")
{
CP_XML_NODE(L"c:ptCount")
{
CP_XML_ATTR(L"val", values_[i].strRef_.str_cache_count);
}
int j=0;
BOOST_FOREACH(std::wstring & v, values_[i].strRef_.str_cache)
{
CP_XML_NODE(L"c:pt")
{
CP_XML_ATTR(L"idx", j++);
CP_XML_NODE(L"c:v")
{
CP_XML_CONTENT(v);
}
}
}
}
}
}
else if (values_[i].strRef_.str_cache_count > 0) else if (values_[i].strRef_.str_cache_count > 0)
{ {
CP_XML_NODE(L"c:strLit") CP_XML_NODE(L"c:strLit")
...@@ -342,7 +387,8 @@ _CP_PTR(oox_chart_series) oox_pie_series::create() ...@@ -342,7 +387,8 @@ _CP_PTR(oox_chart_series) oox_pie_series::create()
} }
void oox_pie_series::oox_serialize(std::wostream & _Wostream) void oox_pie_series::oox_serialize(std::wostream & _Wostream)
{ {
content_.graphic_properties_.clear(); // content_.fill_.clear(); //
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"c:ser") CP_XML_NODE(L"c:ser")
...@@ -353,11 +399,11 @@ void oox_pie_series::oox_serialize(std::wostream & _Wostream) ...@@ -353,11 +399,11 @@ void oox_pie_series::oox_serialize(std::wostream & _Wostream)
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
_CP_PTR(oox_chart_series) xlsx_scatter_series::create() _CP_PTR(oox_chart_series) oox_scatter_series::create()
{ {
return boost::make_shared<xlsx_scatter_series>(); return boost::make_shared<oox_scatter_series>();
} }
void xlsx_scatter_series::oox_serialize(std::wostream & _Wostream) void oox_scatter_series::oox_serialize(std::wostream & _Wostream)
{ {
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
...@@ -371,11 +417,11 @@ void xlsx_scatter_series::oox_serialize(std::wostream & _Wostream) ...@@ -371,11 +417,11 @@ void xlsx_scatter_series::oox_serialize(std::wostream & _Wostream)
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
_CP_PTR(oox_chart_series) xlsx_bubble_series::create() _CP_PTR(oox_chart_series) oox_bubble_series::create()
{ {
return boost::make_shared<xlsx_bubble_series>(); return boost::make_shared<oox_bubble_series>();
} }
void xlsx_bubble_series::oox_serialize(std::wostream & _Wostream) void oox_bubble_series::oox_serialize(std::wostream & _Wostream)
{ {
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
......
...@@ -16,39 +16,26 @@ typedef _CP_PTR(oox_chart_series) oox_series_ptr; ...@@ -16,39 +16,26 @@ typedef _CP_PTR(oox_chart_series) oox_series_ptr;
class oox_chart_series class oox_chart_series
{ {
public: public:
oox_chart_series() oox_chart_series();
{
values_[0].type=L"c:val";
values_[1].type=L"c:xVal";
values_[2].type=L"c:yVal";
values_[3].type=L"c:bubbleSize";// !!!!
values_[4].type=L"c:cat";//
iSymbolMarkerType_ = 0;
bLocalTable_ = false;
}
~oox_chart_series(){} ~oox_chart_series(){}
void oox_serialize_common(std::wostream & _Wostream); void oox_serialize_common(std::wostream & _Wostream);
virtual void oox_serialize(std::wostream & _Wostream){} virtual void oox_serialize(std::wostream & _Wostream){}
_oox_chart_values values_[5]; //common,x, y, bubble, cat(labels) _oox_chart_values values_[5]; //cat(labels), common, x, y, bubble,
int id_; int id_;
std::wstring name_; //tx (Series Text) 21.2.2.215 std::wstring name_; //tx (Series Text) 21.2.2.215
int iSymbolMarkerType_;
bool bLocalTable_;
void setName(std::wstring &value); void setName(std::wstring &value);
void setFormula(int ind, std::wstring & value); void setFormula (int ind, std::wstring & value);
void setValues(int ind, std::vector<std::wstring> & values); void setValues (int ind, std::vector<std::wstring> & values);
void parse_properties(); void parse_properties();
void set_cache_only (bool val); void set_cache_only (bool val);
int iSymbolMarkerType_;
bool bLocalTable_;
odf_reader::chart::series content_; odf_reader::chart::series content_;
//dLbls (Data Labels) 21.2.2.49 //dLbls (Data Labels) 21.2.2.49
...@@ -121,14 +108,14 @@ public: ...@@ -121,14 +108,14 @@ public:
//explosion (Explosion) 21.2.2.61 //explosion (Explosion) 21.2.2.61
//val (Values) 21.2.2.224 //val (Values) 21.2.2.224
/////////////////////////////////////////////////////////////////////////////////////////////////////////////class oox_pie_series; /////////////////////////////////////////////////////////////////////////////////////////////////////////////class oox_pie_series;
class xlsx_bubble_series; class oox_bubble_series;
typedef _CP_PTR(xlsx_bubble_series) xlsx_bubble_series_ptr; typedef _CP_PTR(oox_bubble_series) oox_bubble_series_ptr;
class xlsx_bubble_series : public oox_chart_series class oox_bubble_series : public oox_chart_series
{ {
public: public:
xlsx_bubble_series(){} oox_bubble_series(){}
~xlsx_bubble_series(){} ~oox_bubble_series(){}
static oox_series_ptr create(); static oox_series_ptr create();
...@@ -144,14 +131,14 @@ public: ...@@ -144,14 +131,14 @@ public:
//yVal (Y Values) //yVal (Y Values)
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
class xlsx_scatter_series; class oox_scatter_series;
typedef _CP_PTR(xlsx_scatter_series) xlsx_scatter_series_ptr; typedef _CP_PTR(oox_scatter_series) oox_scatter_series_ptr;
class xlsx_scatter_series : public oox_chart_series class oox_scatter_series : public oox_chart_series
{ {
public: public:
xlsx_scatter_series(){} oox_scatter_series(){}
~xlsx_scatter_series(){} ~oox_scatter_series(){}
static oox_series_ptr create(); static oox_series_ptr create();
......
...@@ -56,6 +56,35 @@ void oox_plot_area::add_chart(int type) ...@@ -56,6 +56,35 @@ void oox_plot_area::add_chart(int type)
} }
charts_.push_back(chart); charts_.push_back(chart);
} }
void oox_plot_area::add_axis(int type, odf_reader::chart::axis & content)
{
oox_axis_content_ptr ax=oox_axis_content::create(type);
ax->content_ = content;
axis_.push_back(ax);
}
void oox_plot_area::reset_cross_axis()//
{
BOOST_FOREACH(oox_axis_content_ptr const & ax, axis_)
{
BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
{
ch->add_axis(ax->get_Id());
}
}
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
{
int curr_id = a->get_Id();
BOOST_FOREACH(oox_axis_content_ptr const & b, axis_)
{
if (b->get_Id()==curr_id)continue;
b->add_CrossedId(curr_id);
}
}
}
void oox_plot_area::oox_serialize(std::wostream & _Wostream) void oox_plot_area::oox_serialize(std::wostream & _Wostream)
{ {
reset_cross_axis(); reset_cross_axis();
...@@ -67,7 +96,7 @@ void oox_plot_area::oox_serialize(std::wostream & _Wostream) ...@@ -67,7 +96,7 @@ void oox_plot_area::oox_serialize(std::wostream & _Wostream)
{ {
CP_XML_NODE(L"c:plotArea") CP_XML_NODE(L"c:plotArea")
{ {
CP_XML_NODE(L"c:layout"){} //CP_XML_NODE(L"c:layout"){}
BOOST_FOREACH(oox_chart_ptr const & ch, charts_) BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
{ {
......
...@@ -19,6 +19,7 @@ public: ...@@ -19,6 +19,7 @@ public:
std::vector<oox_chart_ptr> charts_; std::vector<oox_chart_ptr> charts_;
oox_chart_ptr current_chart_; oox_chart_ptr current_chart_;
std::vector<oox_axis_content_ptr> axis_;
std::vector<odf_reader::_property> graphic_properties_; std::vector<odf_reader::_property> graphic_properties_;
std::vector<odf_reader::_property> properties_; std::vector<odf_reader::_property> properties_;
...@@ -28,49 +29,14 @@ public: ...@@ -28,49 +29,14 @@ public:
void oox_serialize(std::wostream & _Wostream); void oox_serialize(std::wostream & _Wostream);
void add_chart(int type); void add_chart (int type);
void add_axis (int type, odf_reader::chart::axis & content);
void add_series(int id) //void set_content_series (odf_reader::chart::series & content);
{
current_chart_->add_series(id);
}
std::vector<oox_axis_content_ptr> axis_; private:
void reset_cross_axis();//
void add_axis(int type)
{
oox_axis_content_ptr ax=oox_axis_content::create(type);
axis_.push_back(ax);
}
void set_content_axis(odf_reader::chart::axis & content)
{
axis_.back()->content_=content;
}
void set_content_series(odf_reader::chart::series & content)
{
current_chart_->series_.back()->content_=content;
}
void reset_cross_axis()//
{
BOOST_FOREACH(oox_axis_content_ptr const & ax, axis_)
{
BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
{
ch->add_axis(ax->get_Id());
}
}
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
{
int curr_id = a->get_Id();
BOOST_FOREACH(oox_axis_content_ptr const & b, axis_)
{
if (b->get_Id()==curr_id)continue;
b->add_CrossedId(curr_id);
}
}
}
//variable charts //variable charts
//catAx (Category Axis Data) 21.2.2.25 //catAx (Category Axis Data) 21.2.2.25
......
...@@ -30,12 +30,16 @@ void oox_chart::set_name(std::wstring val) ...@@ -30,12 +30,16 @@ void oox_chart::set_name(std::wstring val)
oox_series_ptr & current_ptr = series_.back(); oox_series_ptr & current_ptr = series_.back();
current_ptr->setName(val); current_ptr->setName(val);
} }
void oox_chart::set_values_series(int ind,std::vector<std::wstring> & val) void oox_chart::set_content_series(odf_reader::chart::series & content)
{
series_.back()->content_=content;
}
void oox_chart::set_values_series(int ind, std::vector<std::wstring> & val)
{ {
if (val.size()<1)return; if (val.size()<1)return;
oox_series_ptr & current_ptr = series_.back(); oox_series_ptr & current_ptr = series_.back();
current_ptr->setValues(ind,val); current_ptr->setValues (ind, val);
} }
void oox_chart::set_properties(std::vector<odf_reader::_property> g) void oox_chart::set_properties(std::vector<odf_reader::_property> g)
{ {
...@@ -62,10 +66,6 @@ void oox_chart::oox_serialize_common(std::wostream & _Wostream) ...@@ -62,10 +66,6 @@ void oox_chart::oox_serialize_common(std::wostream & _Wostream)
{ {
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
}
if (grouping_.length()>1) if (grouping_.length()>1)
{ {
CP_XML_NODE(L"c:grouping") CP_XML_NODE(L"c:grouping")
...@@ -112,9 +112,12 @@ void oox_bar_chart::set_additional_properties(std::vector<odf_reader::_property> ...@@ -112,9 +112,12 @@ void oox_bar_chart::set_additional_properties(std::vector<odf_reader::_property>
void oox_bar_chart::oox_serialize(std::wostream & _Wostream) void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
{ {
std::wstring strNode = L"c:barChart";
if (is3D_) strNode = L"c:bar3DChart";
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"c:barChart") CP_XML_NODE(strNode )
{ {
CP_XML_NODE(L"c:barDir") CP_XML_NODE(L"c:barDir")
{ {
...@@ -144,7 +147,19 @@ void oox_bar_chart::oox_serialize(std::wostream & _Wostream) ...@@ -144,7 +147,19 @@ void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
CP_XML_ATTR(L"val",iGapWidth.get()); CP_XML_ATTR(L"val",iGapWidth.get());
} }
} }
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
}
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
if (is3D_)
{
CP_XML_NODE(L"c:shape")
{
CP_XML_ATTR(L"val", L"box");
}
}
} }
} }
} }
...@@ -167,10 +182,17 @@ void oox_line_chart::set_properties(std::vector<odf_reader::_property> g) ...@@ -167,10 +182,17 @@ void oox_line_chart::set_properties(std::vector<odf_reader::_property> g)
} }
void oox_line_chart::oox_serialize(std::wostream & _Wostream) void oox_line_chart::oox_serialize(std::wostream & _Wostream)
{ {
std::wstring strNode = L"c:lineChart";
if (is3D_) strNode = L"c:line3DChart";
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"c:lineChart") CP_XML_NODE(strNode)
{
CP_XML_NODE(L"c:varyColors")
{ {
CP_XML_ATTR(L"val", 1);
}
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
} }
...@@ -193,10 +215,17 @@ void oox_area_chart::set_properties(std::vector<odf_reader::_property> g) ...@@ -193,10 +215,17 @@ void oox_area_chart::set_properties(std::vector<odf_reader::_property> g)
} }
void oox_area_chart::oox_serialize(std::wostream & _Wostream) void oox_area_chart::oox_serialize(std::wostream & _Wostream)
{ {
std::wstring strNode = L"c:areaChart";
if (is3D_) strNode = L"c:area3DChart";
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"c:areaChart") CP_XML_NODE(strNode)
{
CP_XML_NODE(L"c:varyColors")
{ {
CP_XML_ATTR(L"val", 1);
}
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
} }
...@@ -209,7 +238,7 @@ _CP_PTR(oox_chart) oox_area_chart::create() ...@@ -209,7 +238,7 @@ _CP_PTR(oox_chart) oox_area_chart::create()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void oox_bubble_chart::add_series(int id) void oox_bubble_chart::add_series(int id)
{ {
series_.push_back(xlsx_bubble_series::create()); series_.push_back(oox_bubble_series::create());
series_.back()->id_= id; series_.back()->id_= id;
} }
...@@ -223,6 +252,10 @@ void oox_bubble_chart::oox_serialize(std::wostream & _Wostream) ...@@ -223,6 +252,10 @@ void oox_bubble_chart::oox_serialize(std::wostream & _Wostream)
{ {
CP_XML_NODE(L"c:bubbleChart") CP_XML_NODE(L"c:bubbleChart")
{ {
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
}
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
//CP_XML_NODE(L"c:bubbleScale") //CP_XML_NODE(L"c:bubbleScale")
//{ //{
...@@ -256,6 +289,10 @@ void oox_doughnut_chart::oox_serialize(std::wostream & _Wostream) ...@@ -256,6 +289,10 @@ void oox_doughnut_chart::oox_serialize(std::wostream & _Wostream)
{ {
CP_XML_NODE(L"c:doughnutChart") CP_XML_NODE(L"c:doughnutChart")
{ {
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
}
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
CP_XML_NODE(L"c:firstSliceAng") CP_XML_NODE(L"c:firstSliceAng")
...@@ -285,10 +322,17 @@ void oox_pie_chart::set_properties(std::vector<odf_reader::_property> g) ...@@ -285,10 +322,17 @@ void oox_pie_chart::set_properties(std::vector<odf_reader::_property> g)
} }
void oox_pie_chart::oox_serialize(std::wostream & _Wostream) void oox_pie_chart::oox_serialize(std::wostream & _Wostream)
{ {
std::wstring strNode = L"c:pieChart";
if (is3D_) strNode = L"c:pie3DChart";
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"c:pieChart") CP_XML_NODE(strNode)
{
CP_XML_NODE(L"c:varyColors")
{ {
CP_XML_ATTR(L"val", 1);
}
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
} }
} }
...@@ -317,6 +361,10 @@ void oox_radar_chart::oox_serialize(std::wostream & _Wostream) ...@@ -317,6 +361,10 @@ void oox_radar_chart::oox_serialize(std::wostream & _Wostream)
{ {
CP_XML_ATTR(L"val", radarStyle_);//"standard","marker","filled" CP_XML_ATTR(L"val", radarStyle_);//"standard","marker","filled"
} }
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
}
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
} }
...@@ -329,7 +377,7 @@ _CP_PTR(oox_chart) oox_radar_chart::create(std::wstring radarStyle) ...@@ -329,7 +377,7 @@ _CP_PTR(oox_chart) oox_radar_chart::create(std::wstring radarStyle)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void oox_scatter_chart::add_series(int id) void oox_scatter_chart::add_series(int id)
{ {
series_.push_back(xlsx_scatter_series::create()); series_.push_back(oox_scatter_series::create());
series_.back()->id_= id; series_.back()->id_= id;
} }
void oox_scatter_chart::set_properties(std::vector<odf_reader::_property> g) void oox_scatter_chart::set_properties(std::vector<odf_reader::_property> g)
...@@ -351,7 +399,10 @@ void oox_scatter_chart::oox_serialize(std::wostream & _Wostream) ...@@ -351,7 +399,10 @@ void oox_scatter_chart::oox_serialize(std::wostream & _Wostream)
{ {
CP_XML_ATTR(L"val", L"lineMarker"); CP_XML_ATTR(L"val", L"lineMarker");
} }
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
}
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
} }
......
...@@ -24,6 +24,7 @@ public: ...@@ -24,6 +24,7 @@ public:
oox_chart() oox_chart()
{ {
grouping_ = L"standard"; grouping_ = L"standard";
is3D_ = false;
} }
~oox_chart(){} ~oox_chart(){}
...@@ -37,6 +38,7 @@ public: ...@@ -37,6 +38,7 @@ public:
void set_formula_series (int ind,std::wstring val); void set_formula_series (int ind,std::wstring val);
void set_values_series (int ind, std::vector<std::wstring> & val); void set_values_series (int ind, std::vector<std::wstring> & val);
void set_name (std::wstring val); void set_name (std::wstring val);
void set_content_series (odf_reader::chart::series & content);
//void set_showBubbleSize(bool Val){data_labels_.set_showBubbleSize(Val);} //void set_showBubbleSize(bool Val){data_labels_.set_showBubbleSize(Val);}
//void set_showCatName(bool Val){data_labels_.set_showCatName(Val);} //void set_showCatName(bool Val){data_labels_.set_showCatName(Val);}
...@@ -53,15 +55,14 @@ public: ...@@ -53,15 +55,14 @@ public:
oox_data_labels data_labels_;//dLbls (Data Labels) 21.2.2.49 oox_data_labels data_labels_;//dLbls (Data Labels) 21.2.2.49
bool is3D_;
std::vector<int> axisId_; //axId (Axis ID) 21.2.2.9
std::vector<int> axisId_;//axId (Axis ID) 21.2.2.9
std::wstring grouping_; // clustered | percentStacked | stacked | standard std::wstring grouping_; // clustered | percentStacked | stacked | standard
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_properties(std::vector<odf_reader::_property> g);
virtual void set_additional_properties(std::vector<odf_reader::_property> g){} virtual void set_additional_properties(std::vector<odf_reader::_property> g){}
std::vector<oox_series_ptr> series_; //ser (Bar Chart Series) 21.2.2.170
//extLst (Chart Extensibility) 21.2.2.64 //extLst (Chart Extensibility) 21.2.2.64
}; };
......
...@@ -247,7 +247,7 @@ void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_p ...@@ -247,7 +247,7 @@ void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_p
odf_reader::text_list_style * text_list_style = odf_context_.listStyleContainer().list_style_by_name(list_style_stack_.back()); odf_reader::text_list_style * text_list_style = odf_context_.listStyleContainer().list_style_by_name(list_style_stack_.back());
if (text_list_style) if ((text_list_style) && (Level < text_list_style->get_content().size()))
{ {
odf_reader::office_element_ptr elm = text_list_style->get_content()[Level]; odf_reader::office_element_ptr elm = text_list_style->get_content()[Level];
odf_reader::office_element_ptr elm_list; odf_reader::office_element_ptr elm_list;
......
...@@ -72,10 +72,11 @@ void chart_build::set_style_name(std::wstring const & val) ...@@ -72,10 +72,11 @@ void chart_build::set_style_name(std::wstring const & val)
void chart_build::start_axis(std::wstring const & dimensionName, std::wstring const & name, std::wstring const & styleName) void chart_build::start_axis(std::wstring const & dimensionName, std::wstring const & name, std::wstring const & styleName)
{ {
in_axis_ = true; in_axis_ = true;
axis ax; axis ax;
ax.dimension_=dimensionName; ax.dimension_ = dimensionName;
ax.chart_name_= name; ax.chart_name_ = name;
ax.style_name_=styleName; ax.style_name_ = styleName;
axises_.push_back(ax); axises_.push_back(ax);
} }
...@@ -113,7 +114,7 @@ void chart_build::add_series(std::wstring const & cellRangeAddress, ...@@ -113,7 +114,7 @@ void chart_build::add_series(std::wstring const & cellRangeAddress,
std::wstring const & styleName) std::wstring const & styleName)
{ {
if (class_ == chart_ring) classType = chart_ring; if (class_ == chart_ring) classType = chart_ring;
if (class_ == chart_stock) classType = chart_stock; //if (class_ == chart_stock) classType = chart_stock;
series_.push_back(series(cellRangeAddress,labelCell, classType, attachedAxis, styleName)); series_.push_back(series(cellRangeAddress,labelCell, classType, attachedAxis, styleName));
} }
...@@ -156,11 +157,11 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context) ...@@ -156,11 +157,11 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context)
if (object_type_ == 1) if (object_type_ == 1)
{ {
Context.start_chart(L""); Context.start_chart(L"");
oox::oox_chart_context & chart = Context.current_chart(); oox::oox_chart_context & chart_context = Context.current_chart();
oox_convert(chart); oox_convert(chart_context);
chart.set_cache_only(true); chart_context.set_cache_only(true);
Context.end_chart(); Context.end_chart();
} }
...@@ -202,11 +203,11 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -202,11 +203,11 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
if (object_type_ == 1) if (object_type_ == 1)
{ {
Context.start_chart(L""); Context.start_chart(L"");
oox::oox_chart_context & chart = Context.current_chart(); oox::oox_chart_context & chart_context = Context.current_chart();
oox_convert(chart); oox_convert(chart_context);
chart.set_cache_only(true); chart_context.set_cache_only(true);
Context.end_chart(); Context.end_chart();
} }
else if (object_type_ == 2 && office_text_) else if (object_type_ == 2 && office_text_)
...@@ -220,6 +221,8 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -220,6 +221,8 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
} }
void chart_build::calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash) void chart_build::calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash)
{ {
if (adress.empty()) return;
formulasconvert::odf2oox_converter converter; formulasconvert::odf2oox_converter converter;
std::wstring ref_1, ref_2, table; std::wstring ref_1, ref_2, table;
...@@ -228,8 +231,8 @@ void chart_build::calc_cache_series(std::wstring adress, std::vector<std::wstrin ...@@ -228,8 +231,8 @@ void chart_build::calc_cache_series(std::wstring adress, std::vector<std::wstrin
if (!converter.find_first_last_ref(adress, table, ref_1, ref_2))return; if (!converter.find_first_last_ref(adress, table, ref_1, ref_2))return;
//if ((res = table.find(L"local-table"))<0)return; //if ((res = table.find(L"local-table"))<0)return;
oox::getCellAddressInv(ref_1,col_1,row_1); oox::getCellAddressInv(ref_1, col_1,row_1);
oox::getCellAddressInv(ref_2,col_2,row_2); oox::getCellAddressInv(ref_2, col_2,row_2);
BOOST_FOREACH(_cell & val,cash_values) BOOST_FOREACH(_cell & val,cash_values)
{ {
...@@ -240,34 +243,45 @@ void chart_build::calc_cache_series(std::wstring adress, std::vector<std::wstrin ...@@ -240,34 +243,45 @@ void chart_build::calc_cache_series(std::wstring adress, std::vector<std::wstrin
} }
} }
} }
void chart_build::oox_convert(oox::oox_chart_context & chart) //----------------------------------------------------------------------------------------
struct axises_sort
{
inline bool operator() (const chart::axis& a1, const chart::axis& a2)
{
return (a1.type_ < a2.type_);
}
};
void chart_build::oox_convert(oox::oox_chart_context & chart_context)
{ {
chart.set_title(title_); chart_context.set_title (title_);
chart.set_wall(wall_); chart_context.set_wall (wall_);
chart.set_floor(floor_); chart_context.set_floor (floor_);
chart.set_legend(legend_); chart_context.set_legend (legend_);
chart.set_plot_area_properties(plot_area_.properties_, plot_area_.fill_);
//chart.set_footer(footer_);
chart.set_chart_graphic_properties(chart_graphic_properties_, chart_fill_);
//chart.set_chart_properties(chart_graphic_properties_);
class_type last_set_type=chart_unknown; chart_context.set_plot_area_properties (plot_area_.properties_, plot_area_.fill_);
chart_context.set_chart_graphic_properties (chart_graphic_properties_, chart_fill_);
//chart_context.set_footer(footer_);
//chart_context.set_chart_properties(chart_graphic_properties_);
class_type last_set_type = chart_unknown;
int series_id =0; int series_id =0;
if (series_.empty()) if (series_.empty())
{ {
chart.add_chart(class_); chart_context.add_chart(class_);
} }
BOOST_FOREACH(series & s, series_) BOOST_FOREACH(series & s, series_)
{ {
if (s.class_ != last_set_type) if (s.class_ != last_set_type) // - .
{// - . {
chart.add_chart(s.class_); chart_context.add_chart(s.class_);
last_set_type = s.class_; last_set_type = s.class_;
} }
oox::oox_chart_ptr current = chart.get_current_chart(); oox::oox_chart_ptr current = chart_context.get_current_chart();
if (!current) continue; if (!current) continue;
...@@ -276,101 +290,109 @@ void chart_build::oox_convert(oox::oox_chart_context & chart) ...@@ -276,101 +290,109 @@ void chart_build::oox_convert(oox::oox_chart_context & chart)
current->add_series(series_id++); current->add_series(series_id++);
if (s.cell_range_address_.length() <1 ) if (s.cell_range_address_.empty() )
s.cell_range_address_ = plot_area_.cell_range_address_; //SplitByColumn (ind_ser,range); s.cell_range_address_ = plot_area_.cell_range_address_; //SplitByColumn (ind_ser,range);
//SplitByRow (ind_ser,range); //SplitByRow (ind_ser,range);
if (s.cell_range_address_.empty())
s.cell_range_address_ = domain_cell_range_adress2_;
// - - // - -
// - // -
// //
// - = todooo // - = todooo
std::vector<std::wstring> cell_cash;
calc_cache_series(s.cell_range_address_, cell_cash);
if (domain_cell_range_adress_.length() > 0)
{
std::vector<std::wstring> domain_cash; std::vector<std::wstring> domain_cash;
std::vector<std::wstring> cell_cash;
std::vector<std::wstring> cat_cash;
calc_cache_series(domain_cell_range_adress_,domain_cash); calc_cache_series (domain_cell_range_adress_, domain_cash);
calc_cache_series (s.cell_range_address_, cell_cash);
calc_cache_series (categories_[0], cat_cash);
if (domain_cell_range_adress_.empty() == false)
{
if (last_set_type == chart_bubble) if (last_set_type == chart_bubble)
{ {
current->set_formula_series(2, domain_cell_range_adress_);//bubble current->set_formula_series(4, domain_cell_range_adress_); //bubble(x)
current->set_formula_series(3, s.cell_range_address_);//y current->set_values_series (4, domain_cash); //bubble(x)
current->set_values_series (2, domain_cash);//x current->set_formula_series(3, s.cell_range_address_); //y
current->set_values_series (3, cell_cash); current->set_values_series (3, cell_cash);
} }
else else
{ {
current->set_formula_series(1, domain_cell_range_adress_);//x current->set_formula_series(2, domain_cell_range_adress_); //x
current->set_formula_series(2, s.cell_range_address_);//y current->set_values_series (2, domain_cash); //x
current->set_values_series (1, domain_cash);//x current->set_formula_series(3, s.cell_range_address_); //y
current->set_values_series (2, cell_cash); current->set_values_series (3, cell_cash); //y
} }
} }
else else
{ {
current->set_formula_series(0, s.cell_range_address_);//common current->set_formula_series(1, s.cell_range_address_); //common
current->set_values_series(0, cell_cash);//common current->set_values_series(1, cell_cash); //common
} }
if (categories_.size() > 0)// if (categories_.empty() == false)//
{ {
std::vector<std::wstring> cat_cash; current->set_formula_series(0, categories_[0]);
calc_cache_series(categories_[0], cat_cash); current->set_values_series(0, cat_cash);
current->set_formula_series(4,categories_[0]);
current->set_values_series(4,cat_cash);
} }
current->set_name(s.name_); current->set_name(s.name_);
chart.set_content_series(s);
current->set_content_series(s);
} }
std::sort(axises_.begin(), axises_.end(), axises_sort());//file_1_ (1).odp
bool x_enabled = false; bool x_enabled = false;
bool y_enabled = false; bool y_enabled = false;
bool z_enabled = false; bool z_enabled = false;
BOOST_FOREACH(axis & a, axises_)
for (int i = 0; i < axises_.size(); i++)
{ {
axis & a = axises_[i];
if (a.dimension_ == L"x" && x_enabled)continue; if (a.dimension_ == L"x" && x_enabled)continue;
if (a.dimension_ == L"y" && y_enabled)continue; if (a.dimension_ == L"y" && y_enabled)continue;
if (a.dimension_ == L"z" && z_enabled)continue; if (a.dimension_ == L"z" && z_enabled)continue;
int type =3; if (a.dimension_ == L"x")// 1, 2, 3, 4
if (a.dimension_ == L"x")
{ {
// 1, 2, 3, 4
type=1;
if (last_set_type == chart_scatter || if (last_set_type == chart_scatter ||
last_set_type == chart_bubble)type = 2; last_set_type == chart_bubble) a.type_ = 2;
if (class_ == chart_stock && a.type_ == 3 )
a.type_ = 4; // .
//if (last_set_type == chart_stock)type = 4; // .
x_enabled = true; x_enabled = true;
} }
else if (a.dimension_ == L"y") else if (a.dimension_ == L"y")
{ {
type=2; a.type_ = 2;
if (last_set_type == chart_bar) if (last_set_type == chart_bar)
{ {
// ???? ( ???) // ???? ( ???)
// ??? // ???
//overlap & gap-width //overlap & gap-width
oox::oox_chart_ptr current = chart.get_current_chart(); oox::oox_chart_ptr current = chart_context.get_current_chart();
current->set_additional_properties(a.properties_); current->set_additional_properties(a.properties_);
} }
y_enabled = true; y_enabled = true;
} }
else if (a.dimension_ == L"z") else if (a.dimension_ == L"z")
{ {
type=2; chart_context.set_3D_chart (true);
z_enabled = true;
continue; continue;
a.type_ = 2;
z_enabled = true;
} }
chart.add_axis(type); chart_context.add_axis(a.type_, a);
chart.set_content_axis(a);
} }
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
process_build_chart::process_build_chart(chart_build & chartBuild, odf_read_context & context) : process_build_chart::process_build_chart(chart_build & chartBuild, odf_read_context & context) :
stop_ (false) stop_ (false)
...@@ -612,7 +634,10 @@ void process_build_chart::visit(const chart_series& val) ...@@ -612,7 +634,10 @@ void process_build_chart::visit(const chart_series& val)
void process_build_chart::visit(const chart_domain& val) void process_build_chart::visit(const chart_domain& val)
{ {
if (chart_build_.domain_cell_range_adress_.empty())
chart_build_.domain_cell_range_adress_ = val.table_cell_range_address_.get_value_or(L""); chart_build_.domain_cell_range_adress_ = val.table_cell_range_address_.get_value_or(L"");
else
chart_build_.domain_cell_range_adress2_ = val.table_cell_range_address_.get_value_or(L"");
} }
void process_build_chart::visit(const chart_grid& val) void process_build_chart::visit(const chart_grid& val)
{ {
...@@ -679,7 +704,14 @@ void process_build_chart::visit(const chart_equation & val) ...@@ -679,7 +704,14 @@ void process_build_chart::visit(const chart_equation & val)
} }
void process_build_chart::visit(const chart_categories& val) void process_build_chart::visit(const chart_categories& val)
{ {
if (val.table_cell_range_address_) chart_build_.add_categories(*val.table_cell_range_address_); if (chart_build_.in_axis_)
{
chart_build_.axises_.back().type_ = 1;
chart_build_.axises_.back().bCategories_ = true;
}
if (val.table_cell_range_address_)
chart_build_.add_categories(*val.table_cell_range_address_);
} }
void process_build_chart::visit(const table_table& val) void process_build_chart::visit(const table_table& val)
{ {
...@@ -750,13 +782,28 @@ void process_build_chart::visit(const table_rows_no_group& val) ...@@ -750,13 +782,28 @@ void process_build_chart::visit(const table_rows_no_group& val)
} }
void process_build_chart::visit(const table_table_cell& val) void process_build_chart::visit(const table_table_cell& val)
{ {
const table_table_cell_attlist & attlist = val.table_table_cell_attlist_;
unsigned int repeated = val.table_table_cell_attlist_.table_number_columns_repeated_; unsigned int repeated = val.table_table_cell_attlist_.table_number_columns_repeated_;
std::wstringstream wstream_temp; std::wstringstream wstream_temp;
val.table_table_cell_content_.text_to_stream(wstream_temp); val.table_table_cell_content_.text_to_stream(wstream_temp);
std::wstring cell_cash = wstream_temp.str();
std::wstring cell_val;
if (attlist.common_value_and_type_attlist_.office_value_) cell_val = *attlist.common_value_and_type_attlist_.office_value_;
else if (attlist.common_value_and_type_attlist_.office_currency_) cell_val = *attlist.common_value_and_type_attlist_.office_currency_;
else if (attlist.common_value_and_type_attlist_.office_date_value_) cell_val = *attlist.common_value_and_type_attlist_.office_date_value_;
else if (attlist.common_value_and_type_attlist_.office_time_value_) cell_val = *attlist.common_value_and_type_attlist_.office_time_value_;
else if (attlist.common_value_and_type_attlist_.office_boolean_value_) cell_val = *attlist.common_value_and_type_attlist_.office_boolean_value_;
else if (attlist.common_value_and_type_attlist_.office_string_value_) cell_val = *attlist.common_value_and_type_attlist_.office_string_value_;
if (cell_cash.empty())
cell_cash = cell_val;
chart_build::_cell cell_={chart_build_.current_table_column_,chart_build_.current_table_row_,wstream_temp.str()}; chart_build::_cell cell_={chart_build_.current_table_column_, chart_build_.current_table_row_, cell_cash};
chart_build_.cash_values.push_back(cell_); chart_build_.cash_values.push_back(cell_);
......
...@@ -113,10 +113,10 @@ public: ...@@ -113,10 +113,10 @@ public:
void calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash); void calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash);
void xlsx_convert(oox::xlsx_conversion_context & Context); void xlsx_convert (oox::xlsx_conversion_context & Context);
void docx_convert(oox::docx_conversion_context & Context); void docx_convert (oox::docx_conversion_context & Context);
void oox_convert(oox::oox_chart_context & chart); void oox_convert (oox::oox_chart_context & chart);
void pptx_convert(oox::pptx_conversion_context & Context); void pptx_convert (oox::pptx_conversion_context & Context);
double width_pt_; double width_pt_;
double height_pt_; double height_pt_;
...@@ -139,6 +139,7 @@ public: ...@@ -139,6 +139,7 @@ public:
std::vector<std::wstring> categories_; std::vector<std::wstring> categories_;
std::wstring domain_cell_range_adress_; std::wstring domain_cell_range_adress_;
std::wstring domain_cell_range_adress2_;
chart::title title_; chart::title title_;
office_element_ptr_array title_odf_context_; office_element_ptr_array title_odf_context_;
...@@ -157,19 +158,20 @@ public: ...@@ -157,19 +158,20 @@ public:
oox::_oox_fill chart_fill_; oox::_oox_fill chart_fill_;
std::vector<_cell> cash_values; std::vector<_cell> cash_values;
public:
std::wstring target_table_;
//---------------------------------------
std::wstring target_table_;
std::wstring table_name_; std::wstring table_name_;
int current_table_column_; int current_table_column_;
int current_table_row_; int current_table_row_;
std::vector<unsigned int> columns_;
unsigned int columns_count_;
unsigned int columns_spanned_num_; unsigned int columns_spanned_num_;
std::vector<oox::xlsx_row_spanned> rows_spanned_; std::vector<oox::xlsx_row_spanned> rows_spanned_;
std::vector<unsigned int> columns_;
unsigned int columns_count_;
/////////////////////////////////////////// ///////////////////////////////////////////
......
...@@ -63,6 +63,7 @@ namespace chart { ...@@ -63,6 +63,7 @@ namespace chart {
}; };
struct axis: public simple struct axis: public simple
{ {
axis() : bCategories_(false), type_(3) {}
struct grid struct grid
{ {
enum grid_type {major, minor}; enum grid_type {major, minor};
...@@ -72,13 +73,14 @@ namespace chart { ...@@ -72,13 +73,14 @@ namespace chart {
std::vector<_property> graphic_properties_; std::vector<_property> graphic_properties_;
}; };
bool bCategories_;
title title_; title title_;
std::wstring dimension_; std::wstring dimension_;
std::wstring chart_name_; std::wstring chart_name_;
std::wstring style_name_; std::wstring style_name_;
std::vector<grid> grids_; std::vector<grid> grids_;
int type_;
}; };
struct series : public simple struct series : public simple
......
...@@ -1249,7 +1249,10 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) ...@@ -1249,7 +1249,10 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
draw_frame *frame = NULL; draw_frame *frame = NULL;
chart_build objectBuild; chart_build objectBuild;
if (contentSubDoc)//Diagramma.odt - //if (!contentSubDoc)//Diagramma.odt -
// return;
if (contentSubDoc)
{ {
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context()); process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context());
contentSubDoc->accept(process_build_object_); contentSubDoc->accept(process_build_object_);
......
...@@ -230,10 +230,9 @@ double text_format_properties_content::process_font_size_impl(const _CP_OPT(font ...@@ -230,10 +230,9 @@ double text_format_properties_content::process_font_size_impl(const _CP_OPT(font
{ {
font_size usedFontSize = (!FontSize) ? font_size(percent(100)) : *FontSize; font_size usedFontSize = (!FontSize) ? font_size(percent(100)) : *FontSize;
if (usedFontSize.get_type() == font_size::Length && if (usedFontSize.get_type() == font_size::Length)
usedFontSize.get_length().get_unit() == length::pt)
{ {
const double w_val = 2.0 * Mul * usedFontSize.get_length().get_value(); const double w_val = 2.0 * Mul * usedFontSize.get_length().get_value_unit(length::pt);
return w_val; return w_val;
} }
else if (usedFontSize.get_type() == font_size::Percent) else if (usedFontSize.get_type() == font_size::Percent)
...@@ -257,7 +256,7 @@ double text_format_properties_content::process_font_size_impl(const _CP_OPT(font ...@@ -257,7 +256,7 @@ double text_format_properties_content::process_font_size_impl(const _CP_OPT(font
} }
else else
{ {
_CP_LOG << L"[docx_convert] convert font_size error (" << FontSize << ")\n"; //_CP_LOG << L"[docx_convert] convert font_size error (" << FontSize << ")\n";
} }
return -1.0; return -1.0;
...@@ -1197,9 +1196,9 @@ void text_format_properties_content::apply_from(const text_format_properties_con ...@@ -1197,9 +1196,9 @@ void text_format_properties_content::apply_from(const text_format_properties_con
void text_format_properties_content::apply_to(std::vector<_property> & properties) void text_format_properties_content::apply_to(std::vector<_property> & properties)
{ {
if (fo_font_weight_) properties.push_back(_property(L"font-weight", fo_font_weight_.get().get_type()) ); if (fo_font_weight_) properties.push_back(_property(L"font-weight", fo_font_weight_.get().get_type()) );
if (fo_font_family_) properties.push_back(_property(L"font-family",fo_font_family_.get()) ); if (fo_font_family_) properties.push_back(_property(L"font-family", fo_font_family_.get()) );
if (style_font_name_) properties.push_back(_property(L"font-name",style_font_name_.get()) ); if (style_font_name_) properties.push_back(_property(L"font-name", style_font_name_.get()) );
if (fo_font_size_) properties.push_back(_property(L"font-size", fo_font_size_.get().get_length().get_value()) ); if (fo_font_size_) properties.push_back(_property(L"font-size", fo_font_size_.get().get_length().get_value_unit(length::pt)) );
if (fo_font_style_) properties.push_back(_property(L"font-style", fo_font_style_.get().get_type()) ); if (fo_font_style_) properties.push_back(_property(L"font-style", fo_font_style_.get().get_type()) );
if (fo_color_) properties.push_back(_property(L"font-color", fo_color_.get().get_hex_value()) ); if (fo_color_) properties.push_back(_property(L"font-color", fo_color_.get().get_hex_value()) );
......
...@@ -58,13 +58,9 @@ void table_table_cell_attlist::add_attributes( const xml::attributes_wc_ptr & At ...@@ -58,13 +58,9 @@ void table_table_cell_attlist::add_attributes( const xml::attributes_wc_ptr & At
CP_APPLY_ATTR(L"table:style-name", table_style_name_); CP_APPLY_ATTR(L"table:style-name", table_style_name_);
CP_APPLY_ATTR(L"table:content-validation-name", table_content_validation_name_); CP_APPLY_ATTR(L"table:content-validation-name", table_content_validation_name_);
CP_APPLY_ATTR(L"table:formula", table_formula_); CP_APPLY_ATTR(L"table:formula", table_formula_);
common_value_and_type_attlist tmp;
if (tmp.add_attributes(Attributes))
common_value_and_type_attlist_ = tmp;
CP_APPLY_ATTR(L"table:protect", table_protect_, (bool)table_protect_); CP_APPLY_ATTR(L"table:protect", table_protect_, (bool)table_protect_);
common_value_and_type_attlist_.add_attributes(Attributes);
} }
// table-table-cell-attlist-extra // table-table-cell-attlist-extra
......
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
_CP_OPT(std::wstring) table_content_validation_name_; _CP_OPT(std::wstring) table_content_validation_name_;
_CP_OPT(std::wstring) table_formula_; _CP_OPT(std::wstring) table_formula_;
_CP_OPT(odf_types::common_value_and_type_attlist) common_value_and_type_attlist_; odf_types::common_value_and_type_attlist common_value_and_type_attlist_;
bool table_protect_; // default false bool table_protect_; // default false
......
...@@ -619,9 +619,9 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -619,9 +619,9 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
office_value_type::type odf_value_type = office_value_type::Custom; office_value_type::type odf_value_type = office_value_type::Custom;
if (table_table_cell_attlist_.common_value_and_type_attlist_) //if (table_table_cell_attlist_.common_value_and_type_attlist_)
{ {
const common_value_and_type_attlist & attr = *table_table_cell_attlist_.common_value_and_type_attlist_; const common_value_and_type_attlist & attr = table_table_cell_attlist_.common_value_and_type_attlist_;
if (attr.office_value_type_) if (attr.office_value_type_)
odf_value_type = attr.office_value_type_->get_type(); odf_value_type = attr.office_value_type_->get_type();
......
...@@ -26,7 +26,7 @@ int _tmain(int argc, _TCHAR* argv[]) ...@@ -26,7 +26,7 @@ int _tmain(int argc, _TCHAR* argv[])
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir); std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password1", L"C:\\Windows\\Fonts", NULL); hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"", L"C:\\Windows\\Fonts", NULL);
if (hr == S_OK) if (hr == S_OK)
{ {
......
...@@ -33,16 +33,23 @@ void FilePass::writeFields(CFRecord& record) ...@@ -33,16 +33,23 @@ void FilePass::writeFields(CFRecord& record)
void FilePass::readFields(CFRecord& record) void FilePass::readFields(CFRecord& record)
{ {
bool bEnabled = false;
record >> wEncryptionType; record >> wEncryptionType;
if(!wEncryptionType) if(!wEncryptionType)
{ {
record >> key; record >> key;
Log::info("FilePass: Encryption type: XOR"); Log::info("FilePass: Encryption type: XOR");
throw;// EXCEPT::STOP::FileIsEncrypted(); //throw EXCEPT::STOP::FileIsEncrypted();
return;
} }
else else
{ {
bEnabled = true;
majorVer = *record.getCurData<unsigned short>(); majorVer = *record.getCurData<unsigned short>();
if(0x0001 == majorVer) // RC4 encryption header structure if(0x0001 == majorVer) // RC4 encryption header structure
{ {
rc4HeaderPtr = CRYPTO::RC4EncryptionHeaderPtr(new CRYPTO::RC4EncryptionHeader()); rc4HeaderPtr = CRYPTO::RC4EncryptionHeaderPtr(new CRYPTO::RC4EncryptionHeader());
...@@ -58,10 +65,12 @@ void FilePass::readFields(CFRecord& record) ...@@ -58,10 +65,12 @@ void FilePass::readFields(CFRecord& record)
{ {
record >> rc4CryptoAPIHeader; record >> rc4CryptoAPIHeader;
Log::info("FilePass: Encryption type: RC4 Non-Standard"); Log::info("FilePass: Encryption type: RC4 Non-Standard");
throw;// EXCEPT::STOP::FileIsEncrypted();
} }
} }
if (bEnabled == false && record.getGlobalWorkbookInfo()->decryptor)
record.getGlobalWorkbookInfo()->decryptor.reset();
} }
} // namespace XLS } // namespace XLS
......
...@@ -26,14 +26,12 @@ public: ...@@ -26,14 +26,12 @@ public:
static const ElementType type = typeFilePass; static const ElementType type = typeFilePass;
//-----------------------------
Boolean<unsigned short> wEncryptionType; Boolean<unsigned short> wEncryptionType;
XORObfuscation key; XORObfuscation key;
_UINT16 majorVer; _UINT16 majorVer;
CRYPTO::RC4EncryptionHeaderPtr rc4HeaderPtr; CRYPTO::RC4EncryptionHeaderPtr rc4HeaderPtr;
CRYPTO::RC4CryptoAPIEncryptionHeader rc4CryptoAPIHeader; CRYPTO::RC4CryptoAPIEncryptionHeader rc4CryptoAPIHeader;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -151,7 +151,11 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) ...@@ -151,7 +151,11 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
if (( proc.getGlobalWorkbookInfo()->decryptor) && if (( proc.getGlobalWorkbookInfo()->decryptor) &&
( proc.getGlobalWorkbookInfo()->decryptor->IsVerify() == false)) ( proc.getGlobalWorkbookInfo()->decryptor->IsVerify() == false))
{ {
if (proc.getGlobalWorkbookInfo()->password.empty())
{
if (!proc.getGlobalWorkbookInfo()->decryptor->SetPassword(L"VelvetSweatshop"))
return false; return false;
}else return false;
} }
} }
}break; }break;
......
...@@ -15,7 +15,18 @@ PropertySetStream::PropertySetStream(XLS::CFStreamPtr stream) ...@@ -15,7 +15,18 @@ PropertySetStream::PropertySetStream(XLS::CFStreamPtr stream)
unsigned int NumPropertySets=0; unsigned int NumPropertySets=0;
_GUID_ Clsid={}; _GUID_ Clsid={};
*stream >> ByteOrder >> Version >> SystemIdentifier >> Clsid >> NumPropertySets; *stream >> ByteOrder >> Version >> SystemIdentifier;
if (ByteOrder != 0xFFFE) //file (53).xls
return;
if (Version != 0x01 && Version != 0x00)
return;
*stream >> SystemIdentifier >> Clsid >> NumPropertySets;
if (NumPropertySets != 0x01 && NumPropertySets != 0x02)
return;
std::vector<unsigned int> property_sets_offsets; std::vector<unsigned int> property_sets_offsets;
for(unsigned int i = 0; i < NumPropertySets; ++i) for(unsigned int i = 0; i < NumPropertySets; ++i)
...@@ -23,6 +34,8 @@ PropertySetStream::PropertySetStream(XLS::CFStreamPtr stream) ...@@ -23,6 +34,8 @@ PropertySetStream::PropertySetStream(XLS::CFStreamPtr stream)
_GUID_ FMTID; _GUID_ FMTID;
unsigned int Offset; unsigned int Offset;
*stream >> FMTID >> Offset; *stream >> FMTID >> Offset;
if (Offset > 0)
property_sets_offsets.push_back(Offset); property_sets_offsets.push_back(Offset);
} }
......
...@@ -287,11 +287,14 @@ namespace agg ...@@ -287,11 +287,14 @@ namespace agg
double c1 = -(projects[iMin].x * m_cos + projects[iMin].y * m_sin); double c1 = -(projects[iMin].x * m_cos + projects[iMin].y * m_sin);
double c2 = -(projects[iMax].x * m_cos + projects[iMax].y * m_sin); double c2 = -(projects[iMax].x * m_cos + projects[iMax].y * m_sin);
if (abs(dFactor) > FLT_EPSILON)
{
m_factor.x = m_cos / dFactor; m_factor.x = m_cos / dFactor;
m_factor.y = m_sin / dFactor; m_factor.y = m_sin / dFactor;
m_offset.x = c1 / dFactor; m_offset.x = c1 / dFactor;
m_offset.y = c2 / dFactor; m_offset.y = c2 / dFactor;
} }
}
private: private:
void CalcColor( int index ) void CalcColor( int index )
......
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