Commit 114b80ff authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - поправлены формулы, ссылки и составная графика Vehicle log book.ods

parent caa94587
...@@ -118,7 +118,7 @@ namespace formulasconvert { ...@@ -118,7 +118,7 @@ namespace formulasconvert {
} }
std::wstring replace_named_ref_formater1(boost::wsmatch const & what) std::wstring replace_named_ref_formater1(boost::wsmatch const & what)
{ {
boost::wregex complexRef(L"\\$([^\\.]+?){0,1}\\.(\\$[a-zA-Z]+\\$\\d+)(?::\\.(\\$[a-zA-Z]+\\$\\d+)){0,1}"); boost::wregex complexRef(L"\\$([^\\.]+?){0,1}\\.(\\$[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\$[a-zA-Z]+\\${0,1}\\d+)){0,1}");
std::wstring expr = what[1].str(); std::wstring expr = what[1].str();
const std::wstring res = boost::regex_replace( const std::wstring res = boost::regex_replace(
...@@ -141,8 +141,8 @@ namespace formulasconvert { ...@@ -141,8 +141,8 @@ namespace formulasconvert {
void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr) void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr)
{ {
//boost::wregex simpleRef(L"\\[\\.([a-zA-Z]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]"); //boost::wregex simpleRef(L"\\[\\.([a-zA-Z]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
//boost::wregex complexRef(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([a-zA-Z\\$]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]"); boost::wregex complexRef(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}\\]");
boost::wregex complexRef(L"\\[(.*?)\\]"); //boost::wregex complexRef(L"\\[(.*?)\\]");
/* /*
[ $ Sheet2 . A1 : . B5 ] [ $ Sheet2 . A1 : . B5 ]
...@@ -151,7 +151,7 @@ void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr) ...@@ -151,7 +151,7 @@ void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr)
const std::wstring res = boost::regex_replace( const std::wstring res = boost::regex_replace(
expr, expr,
complexRef, complexRef,
&replace_named_ref_formater1, &replace_named_ref_formater,
boost::match_default | boost::format_all); boost::match_default | boost::format_all);
expr = res; expr = res;
} }
...@@ -160,7 +160,7 @@ void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr) ...@@ -160,7 +160,7 @@ void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr)
void odf2oox_converter::Impl::replace_named_ref(std::wstring & expr) void odf2oox_converter::Impl::replace_named_ref(std::wstring & expr)
{ {
boost::wregex complexRef(L"\\$([^\\.]+?){0,1}\\.(\\$[a-zA-Z]+\\$\\d+)(?::\\.(\\$[a-zA-Z]+\\$\\d+)){0,1}"); boost::wregex complexRef(L"\\$([^\\.]+?){0,1}\\.(\\$[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\$[a-zA-Z]+\\${0,1}\\d+)){0,1}");
const std::wstring res = boost::regex_replace( const std::wstring res = boost::regex_replace(
expr, expr,
......
...@@ -7,36 +7,40 @@ namespace oox { ...@@ -7,36 +7,40 @@ namespace oox {
struct _rect struct _rect
{ {
double width_; _rect() : x(0), y(0), cx(0), cy(0) {}
double height_; _rect(double cx_, double cy_, double x_, double y_) : x(x_), y(y_), cx(cx_), cy(cy_) {}
double x_;
double y_;
};
//+ 3- double cx;
double cy;
double x;
double y;
};
struct drawing_object_description struct drawing_object_description
{ {
std::wstring draw_name_; oox::mediaitems::Type type_;
_CP_OPT(_rect) svg_rect_;
std::wstring anchor_; std::wstring name_;
double anchor_x_; _CP_OPT(_rect) svg_rect_;
double anchor_y_;
std::vector<_hlink_desc> hlinks_; std::wstring anchor_;
double anchor_x_;
double anchor_y_;
std::vector<odf_reader::_property> additional_;//for shapes std::vector<_hlink_desc> hlinks_;
std::vector<odf_reader::_property> additional_; //shape properties
std::wstring xlink_href_;// std::wstring xlink_href_; //
std::wstring clipping_string_; std::wstring clipping_string_;
_oox_fill fill_;
_oox_fill fill_; bool use_image_replace_;
bool in_group_;
bool use_image_replace_; int shape_type_; //default - frame
int type_; //default - frame std::vector<drawing_object_description> child_objects_;
}; };
} }
......
...@@ -84,7 +84,8 @@ void oox_chart_context::write_to(std::wostream & strm) ...@@ -84,7 +84,8 @@ void oox_chart_context::write_to(std::wostream & strm)
} }
} }
oox_chart_shape shape; oox_chart_shape shape;
shape.set(graphic_properties_,fill_); shape.set(graphic_properties_, fill_);
shape.set(graphic_properties_, fill_);
shape.oox_serialize(CP_XML_STREAM()); shape.oox_serialize(CP_XML_STREAM());
......
...@@ -56,6 +56,8 @@ void oox_chart_legend::oox_serialize_default_text(std::wostream & _Wostream) ...@@ -56,6 +56,8 @@ void oox_chart_legend::oox_serialize_default_text(std::wostream & _Wostream)
void oox_chart_legend::oox_serialize(std::wostream & _Wostream) void oox_chart_legend::oox_serialize(std::wostream & _Wostream)
{ {
if (content_.bEnabled ==false) return;
oox_chart_shape shape; oox_chart_shape shape;
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
......
...@@ -76,6 +76,9 @@ void oox_chart_series::setFormula(int ind, std::wstring &value) ...@@ -76,6 +76,9 @@ void oox_chart_series::setFormula(int ind, std::wstring &value)
} }
else else
{ {
long res = value.find(L"local-table");
if (res >=0 && !bLocalTable_ ) return; // xlsx .... table.xml
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;
...@@ -89,19 +92,41 @@ void oox_chart_series::set_cache_only (bool val) ...@@ -89,19 +92,41 @@ void oox_chart_series::set_cache_only (bool val)
void oox_chart_series::parse_properties() void oox_chart_series::parse_properties()
{ {
_CP_OPT(int) iSymbolType; _CP_OPT(int) intVal;
odf_reader::GetProperty(content_.properties_, L"symbol-type",iSymbolType); // noneSymbol, autoSymbol, namedSymbol _CP_OPT(bool) boolVal;
_CP_OPT(std::wstring) strVal;
odf_reader::GetProperty(content_.properties_, L"symbol-type", intVal); // noneSymbol, autoSymbol, namedSymbol
if (iSymbolType) if (intVal)
{ {
iSymbolMarkerType_ = iSymbolType.get() ; iSymbolMarkerType_ = intVal.get() ;
if (iSymbolMarkerType_ == 2) if (iSymbolMarkerType_ == 2)
{ {
odf_reader::GetProperty(content_.properties_, L"symbol-name",iSymbolType); // , ... odf_reader::GetProperty(content_.properties_, L"symbol-name", intVal); // , ...
if (iSymbolType)iSymbolMarkerType_ = iSymbolType.get() ;
else iSymbolMarkerType_ = 0;// if (intVal) iSymbolMarkerType_ = intVal.get() ;
else iSymbolMarkerType_ = 0;//
} }
} }
//odf_reader::GetProperty(content_.properties_, L"data-label-symbol", boolVal);
//if (boolVal)
//{
// if (!data_labels) data_labels_ = oox_data_labels();
// //data_labels_->
//}
odf_reader::GetProperty(content_.properties_, L"data-label-text", boolVal);
if (boolVal)
{
if (!data_labels_) data_labels_ = oox_data_labels();
data_labels_->set_showCatName(*boolVal);
}
odf_reader::GetProperty(content_.properties_, L"data-label-number", intVal);
if (intVal)
{
if (!data_labels_) data_labels_ = oox_data_labels();
if (*intVal == 1) data_labels_->set_showVal(true);
if (*intVal == 2) data_labels_->set_showPercent(true);
}
} }
void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values) void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values)
{ {
...@@ -328,6 +353,28 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) ...@@ -328,6 +353,28 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
} }
} }
if (data_labels_)
data_labels_->oox_serialize(_Wostream);
int indPoint = 0;
for (int i = 0 ; i < content_.points_.size(); i++)
{
for (int j = 0 ; j < content_.points_[i].repeated_; j++)
{
CP_XML_NODE(L"c:dPt")
{
CP_XML_NODE(L"c:idx")
{
CP_XML_ATTR(L"val", indPoint++);
}
if (content_.points_[i].graphic_properties_.size() > 0 && content_.points_[i].fill_.type >= 0)
{
shape.set( content_.points_[i].graphic_properties_, content_.points_[i].fill_);
shape.oox_serialize(CP_XML_STREAM());
}
}
}
}
} }
} }
//backward (Backward) 21.2.2.12 //backward (Backward) 21.2.2.12
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#include "../odf/chart_objects.h" #include "../odf/chart_objects.h"
#include "oox_chart_values.h" #include "oox_chart_values.h"
#include "oox_data_labels.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -21,12 +22,13 @@ public: ...@@ -21,12 +22,13 @@ public:
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]; //cat(labels), common, x, y, bubble, _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_; int iSymbolMarkerType_;
bool bLocalTable_; bool bLocalTable_;
_CP_OPT(oox_data_labels) data_labels_;
void setName(std::wstring &value); void setName(std::wstring &value);
...@@ -38,7 +40,6 @@ public: ...@@ -38,7 +40,6 @@ public:
odf_reader::chart::series content_; odf_reader::chart::series content_;
//dLbls (Data Labels) 21.2.2.49
//dPt (Data Point) 21.2.2.52 //dPt (Data Point) 21.2.2.52
//extLst (Chart Extensibility) 21.2.2.64 //extLst (Chart Extensibility) 21.2.2.64
//idx (Index) 21.2.2.84 //idx (Index) 21.2.2.84
......
...@@ -21,8 +21,8 @@ public: ...@@ -21,8 +21,8 @@ public:
void oox_serialize(std::wostream & _Wostream); void oox_serialize(std::wostream & _Wostream);
private: private:
std::vector<odf_reader::_property> content_; std::vector<odf_reader::_property> content_;
_oox_fill fill_; _oox_fill fill_;
private: private:
......
...@@ -12,13 +12,13 @@ namespace oox { ...@@ -12,13 +12,13 @@ namespace oox {
oox_data_labels::oox_data_labels()// oox_data_labels::oox_data_labels()//
{ {
// //
showBubbleSize_ = false; showBubbleSize_ = false;
showCatName_ = false; showCatName_ = false;
showLeaderLines_ = false; showLeaderLines_ = false;
showLegendKey_ = false; showLegendKey_ = false;
showPercent_ = false; showPercent_ = false;
showSerName_ = false; showSerName_ = false;
showVal_ = false; showVal_ = false;
} }
void oox_data_labels::oox_serialize(std::wostream & _Wostream) void oox_data_labels::oox_serialize(std::wostream & _Wostream)
{ {
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
class oox_data_labels: boost::noncopyable class oox_data_labels
{ {
public: public:
oox_data_labels(); oox_data_labels();
...@@ -18,13 +18,13 @@ public: ...@@ -18,13 +18,13 @@ public:
void oox_serialize(std::wostream & _Wostream); void oox_serialize(std::wostream & _Wostream);
void set_showBubbleSize(bool Val){showBubbleSize_ = Val;} void set_showBubbleSize (bool Val){showBubbleSize_ = Val;}
void set_showCatName(bool Val){showCatName_ = Val;} void set_showCatName (bool Val){showCatName_ = Val;}
void set_showLeaderLines(bool Val){showLeaderLines_ = Val;} void set_showLeaderLines(bool Val){showLeaderLines_ = Val;}
void set_showLegendKey(bool Val){showLegendKey_ = Val;} void set_showLegendKey (bool Val){showLegendKey_ = Val;}
void set_showPercent(bool Val){showPercent_ = Val;} void set_showPercent (bool Val){showPercent_ = Val;}
void set_showSerName(bool Val){showSerName_ = Val;} void set_showSerName (bool Val){showSerName_ = Val;}
void set_showVal(bool Val){showVal_ = Val;} void set_showVal (bool Val){showVal_ = Val;}
private: private:
......
...@@ -72,8 +72,6 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope ...@@ -72,8 +72,6 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
if ((!strStrokeColor && !iStroke && !dStrokeWidth) && !always_draw)return; if ((!strStrokeColor && !iStroke && !dStrokeWidth) && !always_draw)return;
if ((iStroke) && (*iStroke==0)) return; //none
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"a:ln") CP_XML_NODE(L"a:ln")
...@@ -88,9 +86,12 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope ...@@ -88,9 +86,12 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
else dash_style = _ooxDashStyle[iStroke.get()]; else dash_style = _ooxDashStyle[iStroke.get()];
} }
if ((dStrokeWidth) && (dStrokeWidth.get()>= 0)) if ((dStrokeWidth) && (dStrokeWidth.get()>= 0) && fill != L"a:noFill")
{ {
CP_XML_ATTR(L"w",static_cast<size_t>(dStrokeWidth.get() * 12700));//in emu (1 pt = 12700) int val = dStrokeWidth.get() * 12700; //in emu (1 pt = 12700)
if (val < 10) val = 12700;
CP_XML_ATTR(L"w", val);
if (color.length()<1)color = L"729FCF"; if (color.length()<1)color = L"729FCF";
} }
...@@ -98,31 +99,36 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope ...@@ -98,31 +99,36 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
{ {
if (fill != L"a:noFill") if (fill != L"a:noFill")
{ {
if (color.length()<1 && always_draw) color = L"000000"; if (color.length()<1 && always_draw) color = L"000000";
else if (color.length()<1) color = L"ffffff"; else if (color.length()<1) color = L"ffffff";
CP_XML_NODE(L"a:srgbClr") CP_XML_NODE(L"a:srgbClr")
{ {
CP_XML_ATTR(L"val",color); CP_XML_ATTR(L"val",color);
if (strStrokeOpacity)CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val",strStrokeOpacity.get());} if (strStrokeOpacity)CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val",strStrokeOpacity.get());}
} }
} }
} }
_CP_OPT(std::wstring) strVal; if (fill != L"a:noFill")
if (dash_style.length() >0 && dash_style != L"solid")
{
CP_XML_NODE(L"a:prstDash"){CP_XML_ATTR(L"val", dash_style);}
}
odf_reader::GetProperty(prop,L"marker-start", strVal);
if (strVal)
{ {
CP_XML_NODE(L"a:headEnd"){CP_XML_ATTR(L"type", strVal.get());} _CP_OPT(std::wstring) strVal;
}
odf_reader::GetProperty(prop,L"marker-end",strVal); if (dash_style.length() >0 && dash_style != L"solid")
if (strVal) {
{ CP_XML_NODE(L"a:prstDash"){CP_XML_ATTR(L"val", dash_style);}
CP_XML_NODE(L"a:tailEnd"){CP_XML_ATTR(L"type",strVal.get());} }
odf_reader::GetProperty(prop,L"marker-start", strVal);
if (strVal)
{
CP_XML_NODE(L"a:headEnd"){CP_XML_ATTR(L"type", strVal.get());}
}
odf_reader::GetProperty(prop,L"marker-end",strVal);
if (strVal)
{
CP_XML_NODE(L"a:tailEnd"){CP_XML_ATTR(L"type",strVal.get());}
}
} }
} }
} }
...@@ -425,19 +431,19 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst ...@@ -425,19 +431,19 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
_CP_LOG << L"[error!!!] not set size object\n"; _CP_LOG << L"[error!!!] not set size object\n";
} }
//if (val.type == mediaitems::typeGroup) if (val.type == mediaitems::typeGroup)
//{ {
// CP_XML_NODE(L"a:chOff") CP_XML_NODE(L"a:chOff")
// { {
// CP_XML_ATTR(L"x", 0); CP_XML_ATTR(L"x", 0);
// CP_XML_ATTR(L"y", 0); CP_XML_ATTR(L"y", 0);
// } }
// CP_XML_NODE(L"a:chExt") CP_XML_NODE(L"a:chExt")
// { {
// CP_XML_ATTR(L"cx", val.cx); CP_XML_ATTR(L"cx", val.cx);
// CP_XML_ATTR(L"cy", val.cy); CP_XML_ATTR(L"cy", val.cy);
// } }
//} }
} }
} }
} }
......
...@@ -43,8 +43,8 @@ namespace oox { ...@@ -43,8 +43,8 @@ namespace oox {
} }
mediaitems::Type type; mediaitems::Type type;
bool inGroup; bool inGroup;
size_t id; size_t id;
std::wstring name; std::wstring name;
......
...@@ -97,14 +97,21 @@ void oox_plot_area::oox_serialize(std::wostream & _Wostream) ...@@ -97,14 +97,21 @@ 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"){}
bool axisPresent = true;
BOOST_FOREACH(oox_chart_ptr const & ch, charts_) BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
{ {
ch->oox_serialize(CP_XML_STREAM()); ch->oox_serialize(CP_XML_STREAM());
if (ch->type_ == CHART_TYPE_PIE ||
ch->type_ == CHART_TYPE_DOUGHNUT) axisPresent = false;
} }
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_) if (axisPresent)
{ {
a->oox_serialize(CP_XML_STREAM()); BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
{
a->oox_serialize(CP_XML_STREAM());
}
} }
shape.oox_serialize(CP_XML_STREAM()); shape.oox_serialize(CP_XML_STREAM());
} }
......
...@@ -11,8 +11,9 @@ namespace oox { ...@@ -11,8 +11,9 @@ namespace oox {
void oox_title::oox_serialize(std::wostream & _Wostream) void oox_title::oox_serialize(std::wostream & _Wostream)
{ {
if (content_.content_.length()<1)return; if (content_.content_.length()<1) return;
CP_XML_WRITER(_Wostream)
CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"c:title") CP_XML_NODE(L"c:title")
{ {
......
...@@ -10,7 +10,16 @@ ...@@ -10,7 +10,16 @@
#include "oox_chart_series.h" #include "oox_chart_series.h"
#include "oox_data_labels.h" #include "oox_data_labels.h"
#define CHART_TYPE_LINE 1
#define CHART_TYPE_AREA 2
#define CHART_TYPE_PIE 3
#define CHART_TYPE_DOUGHNUT 4
#define CHART_TYPE_SCATTER 5
#define CHART_TYPE_RADAR 6
#define CHART_TYPE_BAR 7
#define CHART_TYPE_STOCK 8
#define CHART_TYPE_BUBBLE 9
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -25,6 +34,7 @@ public: ...@@ -25,6 +34,7 @@ public:
{ {
grouping_ = L"standard"; grouping_ = L"standard";
is3D_ = false; is3D_ = false;
type_ = 0;
} }
~oox_chart(){} ~oox_chart(){}
...@@ -53,8 +63,9 @@ public: ...@@ -53,8 +63,9 @@ public:
axisId_.push_back(id); axisId_.push_back(id);
} }
oox_data_labels data_labels_;//dLbls (Data Labels) 21.2.2.49 oox_data_labels data_labels_;//dLbls (Data Labels) 21.2.2.49
int type_;
bool is3D_; 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
...@@ -75,7 +86,8 @@ class oox_bar_chart: public oox_chart ...@@ -75,7 +86,8 @@ class oox_bar_chart: public oox_chart
public: public:
oox_bar_chart() oox_bar_chart()
{ {
grouping_ = L"clustered"; type_ = CHART_TYPE_BAR;
grouping_ = L"clustered";
} }
~oox_bar_chart(){} ~oox_bar_chart(){}
...@@ -108,6 +120,7 @@ class oox_line_chart: public oox_chart ...@@ -108,6 +120,7 @@ class oox_line_chart: public oox_chart
public: public:
oox_line_chart() oox_line_chart()
{ {
type_ = CHART_TYPE_LINE;
} }
~oox_line_chart(){} ~oox_line_chart(){}
...@@ -137,6 +150,7 @@ class oox_area_chart: public oox_chart ...@@ -137,6 +150,7 @@ class oox_area_chart: public oox_chart
public: public:
oox_area_chart() oox_area_chart()
{ {
type_ = CHART_TYPE_AREA;
//grouping_ = L"clustered"; //grouping_ = L"clustered";
} }
~oox_area_chart(){} ~oox_area_chart(){}
...@@ -159,7 +173,8 @@ class oox_bubble_chart: public oox_chart ...@@ -159,7 +173,8 @@ class oox_bubble_chart: public oox_chart
public: public:
oox_bubble_chart() oox_bubble_chart()
{ {
grouping_ = L""; type_ = CHART_TYPE_BUBBLE;
grouping_ = L"";
} }
~oox_bubble_chart(){} ~oox_bubble_chart(){}
...@@ -185,6 +200,7 @@ class oox_doughnut_chart: public oox_chart ...@@ -185,6 +200,7 @@ class oox_doughnut_chart: public oox_chart
public: public:
oox_doughnut_chart() oox_doughnut_chart()
{ {
type_ = CHART_TYPE_DOUGHNUT;
} }
~oox_doughnut_chart(){} ~oox_doughnut_chart(){}
...@@ -208,6 +224,7 @@ class oox_pie_chart: public oox_chart ...@@ -208,6 +224,7 @@ class oox_pie_chart: public oox_chart
public: public:
oox_pie_chart() oox_pie_chart()
{ {
type_ = CHART_TYPE_PIE;
} }
~oox_pie_chart(){} ~oox_pie_chart(){}
...@@ -229,7 +246,8 @@ class oox_radar_chart: public oox_chart ...@@ -229,7 +246,8 @@ class oox_radar_chart: public oox_chart
public: public:
oox_radar_chart(std::wstring style) oox_radar_chart(std::wstring style)
{ {
grouping_ = L""; type_ = CHART_TYPE_RADAR;
grouping_ = L"";
radarStyle_ = style; radarStyle_ = style;
} }
~oox_radar_chart(){} ~oox_radar_chart(){}
...@@ -253,7 +271,8 @@ class oox_scatter_chart: public oox_chart ...@@ -253,7 +271,8 @@ class oox_scatter_chart: public oox_chart
public: public:
oox_scatter_chart() oox_scatter_chart()
{ {
grouping_ = L""; type_ = CHART_TYPE_SCATTER;
grouping_ = L"";
} }
~oox_scatter_chart(){} ~oox_scatter_chart(){}
...@@ -277,7 +296,8 @@ class oox_stock_chart: public oox_chart ...@@ -277,7 +296,8 @@ class oox_stock_chart: public oox_chart
public: public:
oox_stock_chart() oox_stock_chart()
{ {
grouping_ = L""; type_ = CHART_TYPE_STOCK;
grouping_ = L"";
} }
~oox_stock_chart(){} ~oox_stock_chart(){}
......
...@@ -171,7 +171,7 @@ void pptx_slide_context::default_set() ...@@ -171,7 +171,7 @@ void pptx_slide_context::default_set()
{ {
impl_->object_description_.xlink_href_ = L""; impl_->object_description_.xlink_href_ = L"";
impl_->object_description_.draw_name_ = L""; impl_->object_description_.name_ = L"";
impl_->object_description_.additional_.clear(); impl_->object_description_.additional_.clear();
impl_->object_description_.anchor_ =L""; impl_->object_description_.anchor_ =L"";
...@@ -203,8 +203,7 @@ void pptx_slide_context::set_placeHolder_idx(int idx) ...@@ -203,8 +203,7 @@ void pptx_slide_context::set_placeHolder_idx(int idx)
void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt) void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt)
{ {
_rect r = {width_pt,height_pt,x_pt,y_pt}; impl_->object_description_.svg_rect_ = _rect(width_pt, height_pt, x_pt, y_pt);
impl_->object_description_.svg_rect_= r;
} }
void pptx_slide_context::set_rotate(double angle) void pptx_slide_context::set_rotate(double angle)
...@@ -226,11 +225,10 @@ void pptx_slide_context::set_translate(double x_pt, double y_pt) ...@@ -226,11 +225,10 @@ void pptx_slide_context::set_translate(double x_pt, double y_pt)
{ {
if (impl_->object_description_.svg_rect_) if (impl_->object_description_.svg_rect_)
{ {
_rect r = impl_->object_description_.svg_rect_.get(); _rect & r = impl_->object_description_.svg_rect_.get();
r.x_+=x_pt;
r.y_+=y_pt; r.x += x_pt;
r.y += y_pt;
impl_->object_description_.svg_rect_= r;
} }
} }
...@@ -238,11 +236,10 @@ void pptx_slide_context::set_scale(double cx_pt, double cy_pt) ...@@ -238,11 +236,10 @@ void pptx_slide_context::set_scale(double cx_pt, double cy_pt)
{ {
if (impl_->object_description_.svg_rect_) if (impl_->object_description_.svg_rect_)
{ {
_rect r = impl_->object_description_.svg_rect_.get(); _rect & r = impl_->object_description_.svg_rect_.get();
r.x_*=cx_pt;
r.y_*=cy_pt; r.x *= cx_pt;
r.y *= cy_pt;
impl_->object_description_.svg_rect_= r;
} }
} }
...@@ -303,24 +300,25 @@ void pptx_slide_context::add_background(_oox_fill & fill) ...@@ -303,24 +300,25 @@ void pptx_slide_context::add_background(_oox_fill & fill)
void pptx_slide_context::set_name(std::wstring const & name) void pptx_slide_context::set_name(std::wstring const & name)
{ {
impl_->object_description_.draw_name_ = name; impl_->object_description_.name_ = name;
} }
void pptx_slide_context::start_shape(int type) void pptx_slide_context::start_shape(int type)
{ {
impl_->object_description_.type_ = type; //2,3... impl_->object_description_.type_ = mediaitems::typeShape;
impl_->object_description_.shape_type_ = type; //2,3...
} }
void pptx_slide_context::start_image(std::wstring const & path) void pptx_slide_context::start_image(std::wstring const & path)
{ {
impl_->object_description_.xlink_href_ = path; impl_->object_description_.type_ = mediaitems::typeImage;
impl_->object_description_.type_ = 0; //frame impl_->object_description_.xlink_href_ = path;
} }
void pptx_slide_context::start_table() void pptx_slide_context::start_table()
{ {
impl_->object_description_.type_ = 0; //frame impl_->object_description_.type_ = mediaitems::typeTable;
} }
void pptx_slide_context::set_use_image_replacement() void pptx_slide_context::set_use_image_replacement()
...@@ -334,8 +332,8 @@ void pptx_slide_context::start_object_ole() ...@@ -334,8 +332,8 @@ void pptx_slide_context::start_object_ole()
void pptx_slide_context::start_chart(std::wstring const & path) void pptx_slide_context::start_chart(std::wstring const & path)
{ {
impl_->object_description_.xlink_href_ = path; impl_->object_description_.type_ = mediaitems::typeChart;
impl_->object_description_.type_ = 0; //frame impl_->object_description_.xlink_href_ = path;
} }
void pptx_slide_context::end_object_ole() void pptx_slide_context::end_object_ole()
{ {
...@@ -387,12 +385,16 @@ void pptx_slide_context::process_images() ...@@ -387,12 +385,16 @@ void pptx_slide_context::process_images()
if ((pos_replaicement <0 && pos_preview <0) || pic.use_image_replace_)//, ( ) if ((pos_replaicement <0 && pos_preview <0) || pic.use_image_replace_)//, ( )
{ {
_pptx_drawing drawing=_pptx_drawing(); _pptx_drawing drawing =_pptx_drawing();
drawing.type = pic.type_;
drawing.name = pic.name_;
drawing.id = impl_->next_rId();
process_common_properties(pic,drawing); process_common_properties(pic,drawing);
drawing.fill.bitmap = oox_bitmap_fill::create(); drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2; drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent; _CP_OPT(std::wstring) sTextContent;
GetProperty(pic.additional_,L"text-content",sTextContent); GetProperty(pic.additional_,L"text-content",sTextContent);
...@@ -401,11 +403,7 @@ void pptx_slide_context::process_images() ...@@ -401,11 +403,7 @@ void pptx_slide_context::process_images()
drawing.type = mediaitems::typeShape; drawing.type = mediaitems::typeShape;
drawing.sub_type = 2;//rect drawing.sub_type = 2;//rect
} }
else
drawing.type = mediaitems::typeImage;
drawing.id = impl_->next_rId();
drawing.name = pic.draw_name_;
std::wstring fileName = impl_->odfPacket_ + FILE_SEPARATOR_STR + pic.xlink_href_; std::wstring fileName = impl_->odfPacket_ + FILE_SEPARATOR_STR + pic.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect); drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect);
...@@ -438,12 +436,12 @@ void pptx_slide_context::process_charts() ...@@ -438,12 +436,12 @@ void pptx_slide_context::process_charts()
BOOST_FOREACH(drawing_object_description & pic, impl_->charts_) BOOST_FOREACH(drawing_object_description & pic, impl_->charts_)
{ {
_pptx_drawing drawing=_pptx_drawing(); _pptx_drawing drawing=_pptx_drawing();
process_common_properties(pic,drawing);
drawing.type = mediaitems::typeChart; drawing.type = pic.type_;
drawing.name = pic.draw_name_; drawing.name = pic.name_;
drawing.id = impl_->next_rId(); drawing.id = impl_->next_rId();
process_common_properties(pic,drawing);
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
std::wstring ref; std::wstring ref;
...@@ -459,11 +457,13 @@ void pptx_slide_context::process_tables() ...@@ -459,11 +457,13 @@ void pptx_slide_context::process_tables()
{ {
_pptx_drawing drawing=_pptx_drawing(); _pptx_drawing drawing=_pptx_drawing();
drawing.type = pic.type_;
drawing.name = pic.name_;
drawing.id = impl_->next_rId();
process_common_properties(pic,drawing); process_common_properties(pic,drawing);
drawing.type = mediaitems::typeTable;
drawing.name = pic.draw_name_;
drawing.id = impl_->next_rId();
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
std::wstring ref; std::wstring ref;
...@@ -478,16 +478,16 @@ void pptx_slide_context::process_common_properties(drawing_object_description & ...@@ -478,16 +478,16 @@ void pptx_slide_context::process_common_properties(drawing_object_description &
if (pic.svg_rect_) if (pic.svg_rect_)
{ {
//todooo //todooo
int val = (int)(0.5 + odf_types::length(pic.svg_rect_.get().x_, odf_types::length::pt).get_value_unit(odf_types::length::emu)); int val = (int)(0.5 + odf_types::length(pic.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if (val >= 0) drawing.x = val; if (val >= 0) drawing.x = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_.get().y_, odf_types::length::pt).get_value_unit(odf_types::length::emu)); val = (int)(0.5 + odf_types::length(pic.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if (val >= 0) drawing.y = val; if (val >= 0) drawing.y = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_.get().width_, odf_types::length::pt).get_value_unit(odf_types::length::emu)); val = (int)(0.5 + odf_types::length(pic.svg_rect_->cx, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if (val >=0) drawing.cx = val; if (val >=0) drawing.cx = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_.get().height_, odf_types::length::pt).get_value_unit(odf_types::length::emu)); val = (int)(0.5 + odf_types::length(pic.svg_rect_->cy, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if (val >=0) drawing.cy = val; if (val >=0) drawing.cy = val;
} }
...@@ -505,14 +505,14 @@ void pptx_slide_context::process_shapes() ...@@ -505,14 +505,14 @@ void pptx_slide_context::process_shapes()
{ {
_pptx_drawing drawing=_pptx_drawing(); _pptx_drawing drawing=_pptx_drawing();
drawing.type = pic.type_;
drawing.name = pic.name_;
drawing.id = impl_->next_rId();
process_common_properties(pic,drawing); process_common_properties(pic,drawing);
std::wstring ref; std::wstring ref;
bool isMediaInternal = true; bool isMediaInternal = true;
drawing.type = mediaitems::typeShape;
drawing.name = pic.draw_name_;
drawing.id = impl_->next_rId();
if (drawing.fill.bitmap) if (drawing.fill.bitmap)
{ {
......
...@@ -157,6 +157,30 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val) ...@@ -157,6 +157,30 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
} }
} // CP_XML_WRITER } // CP_XML_WRITER
} }
void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xdr:grpSp")
{
CP_XML_NODE(L"xdr:nvGrpSpPr")
{
CP_XML_NODE(L"xdr:cNvPr")
{
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
}
CP_XML_NODE(L"xdr:cNvGrpSpPr");
}
CP_XML_NODE(L"xdr:grpSpPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
}
CP_XML_STREAM() << val.content_group_;
}
}
}
void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val) void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
{ {
...@@ -194,31 +218,65 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val) ...@@ -194,31 +218,65 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
} // xdr:graphicFrame } // xdr:graphicFrame
} // CP_XML_WRITER } // CP_XML_WRITER
} }
void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
{
if (val.type == mediaitems::typeShape)
{
xlsx_serialize_shape(strm, val);
}
else if (val.type == mediaitems::typeImage)
{
xlsx_serialize_image(strm, val);
}
else if (val.type == mediaitems::typeChart)
{
xlsx_serialize_chart(strm, val);
}
else if (val.type == mediaitems::typeGroup)
{
xlsx_serialize_group(strm, val);
}
}
void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val) void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
{ {
CP_XML_WRITER(strm) if (val.inGroup) return xlsx_serialize_object(strm, val);
CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"xdr:twoCellAnchor") if (val.type_anchor == 1)
{ {
CP_XML_ATTR(L"editAs", L"oneCell");//"absolute"); CP_XML_NODE(L"xdr:twoCellAnchor")
xlsx_serialize(CP_XML_STREAM(), val.from);
xlsx_serialize(CP_XML_STREAM(), val.to);
if (val.type == mediaitems::typeShape)
{ {
xlsx_serialize_shape(CP_XML_STREAM(),val); //CP_XML_ATTR(L"editAs", L"absolute");//"absolute");oneCell
}
else if (val.type == mediaitems::typeImage) xlsx_serialize (CP_XML_STREAM(), val.from_);
{ xlsx_serialize (CP_XML_STREAM(), val.to_);
xlsx_serialize_image(CP_XML_STREAM(),val);
xlsx_serialize_object (CP_XML_STREAM(),val);
CP_XML_NODE(L"xdr:clientData");
} }
else if (val.type == mediaitems::typeChart) }
else
{
CP_XML_NODE(L"xdr:absoluteAnchor")
{ {
xlsx_serialize_chart(CP_XML_STREAM(),val); CP_XML_NODE(L"xdr:pos")
{
CP_XML_ATTR(L"x", val.x);
CP_XML_ATTR(L"y", val.y);
}
CP_XML_NODE(L"xdr:ext")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
xlsx_serialize_object (CP_XML_STREAM(),val);
CP_XML_NODE(L"xdr:clientData");
} }
CP_XML_NODE(L"xdr:clientData");
} }
} }
......
...@@ -25,8 +25,15 @@ struct xlsx_drawing_position ...@@ -25,8 +25,15 @@ struct xlsx_drawing_position
struct _xlsx_drawing : _oox_drawing struct _xlsx_drawing : _oox_drawing
{ {
xlsx_drawing_position from; _xlsx_drawing() : _oox_drawing(), type_anchor(1) {}
xlsx_drawing_position to;
int type_anchor;
xlsx_drawing_position from_;
xlsx_drawing_position to_;
std::wstring content_group_;
friend void xlsx_serialize(std::wostream & _Wostream, _xlsx_drawing & val); friend void xlsx_serialize(std::wostream & _Wostream, _xlsx_drawing & val);
}; };
......
...@@ -15,14 +15,14 @@ namespace cpdoccore { ...@@ -15,14 +15,14 @@ namespace cpdoccore {
namespace oox { namespace oox {
struct drawing_object_description; struct drawing_object_description;
struct xlsx_table_position; struct xlsx_table_position;
class xlsx_table_metrics; class xlsx_table_metrics;
class mediaitems; class mediaitems;
class xlsx_drawings; class xlsx_drawings;
struct _oox_fill; struct _oox_fill;
typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr; typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr;
class xlsx_drawing_context_handle class xlsx_drawing_context_handle
{ {
...@@ -30,8 +30,8 @@ public: ...@@ -30,8 +30,8 @@ public:
xlsx_drawing_context_handle(mediaitems & items); xlsx_drawing_context_handle(mediaitems & items);
~xlsx_drawing_context_handle(); ~xlsx_drawing_context_handle();
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings); std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings);
const std::vector<drawing_elm> & content() const; const std::vector<drawing_elm> & content() const;
friend class xlsx_drawing_context; friend class xlsx_drawing_context;
private: private:
...@@ -39,8 +39,7 @@ private: ...@@ -39,8 +39,7 @@ private:
_CP_PTR(Impl) impl_; _CP_PTR(Impl) impl_;
}; };
//class xlsx_drawings;
//typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr;
class xlsx_drawing_context class xlsx_drawing_context
{ {
...@@ -50,25 +49,11 @@ public: ...@@ -50,25 +49,11 @@ public:
void set_odf_packet_path(std::wstring path){odf_packet_path_ = path;}// void set_odf_packet_path(std::wstring path){odf_packet_path_ = path;}//
void start_shapes(); void start_drawing(std::wstring const & name);
void start_drawing(std::wstring const & name);
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
void set_translate(double x_pt, double y_pt);
void set_scale(double cx_pt, double cy_pt);
void set_rotate(double angle);
void set_anchor(std::wstring anchor, double x_pt, double y_pt);
void set_property(odf_reader::_property p);
std::vector<odf_reader::_property> & get_properties();
void set_clipping(const std::wstring & str );
void set_fill(_oox_fill & fill);
void end_drawing(); void end_drawing();
void end_shapes();
void start_group(std::wstring const & name);
std::wstring add_hyperlink(std::wstring const & ref, bool object); void end_group();
void start_image(std::wstring const & path); void start_image(std::wstring const & path);
void end_image(); void end_image();
...@@ -76,36 +61,58 @@ public: ...@@ -76,36 +61,58 @@ public:
void start_chart(std::wstring const & path); void start_chart(std::wstring const & path);
void end_chart(); void end_chart();
void start_shape(int type); void start_shape(int type);
//... ... //... ...
void end_shape(); void end_shape();
void start_object_ole(); void start_object_ole();
void end_object_ole(); void end_object_ole();
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
void set_translate(double x_pt, double y_pt);
void set_scale(double cx_pt, double cy_pt);
void set_rotate(double angle);
void set_anchor(std::wstring anchor, double x_pt, double y_pt, bool group = false);
void set_property(odf_reader::_property p);
void set_clipping(const std::wstring & str );
void set_fill(_oox_fill & fill);
std::vector<odf_reader::_property> & get_properties();
std::wstring add_hyperlink(std::wstring const & ref, bool object);
void set_use_image_replacement(); void set_use_image_replacement();
bool empty() const; bool empty() const;
void clear();
void write_drawing(std::wostream & strm); void write_drawing(std::wostream & strm);
std::wstring dump_path(std::vector<svg_path::_polyline> & path, double w,double h); std::wstring dump_path(std::vector<svg_path::_polyline> & path, double w,double h);
xlsx_drawings_ptr get_drawings(); xlsx_drawings_ptr get_drawings();
void process_images(xlsx_table_metrics & table_metrics); void process_objects(xlsx_table_metrics & table_metrics);
void process_charts(xlsx_table_metrics & table_metrics);
void process_shapes(xlsx_table_metrics & table_metrics);
void process_position_properties(drawing_object_description & pic,xlsx_table_metrics & table_metrics,xlsx_table_position & from,xlsx_table_position & to);
void process_common_properties(drawing_object_description& pic,_xlsx_drawing & drawing,xlsx_table_metrics & table_metrics);
private: private:
void default_set();
int hlinks_size_;
std::wstring odf_packet_path_ ;
float dpi_;
class Impl; class Impl;
_CP_PTR(Impl) impl_; _CP_PTR(Impl) impl_;
void process_objects (std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_);
void process_group (drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_image (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_chart (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_shape (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_common_properties (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_table_metrics & table_metrics);
void process_position_properties(drawing_object_description & obj, xlsx_table_metrics & table_metrics, xlsx_table_position & from,xlsx_table_position & to);
int hlinks_size_;
std::wstring odf_packet_path_ ;
float dpi_;
}; };
......
...@@ -15,24 +15,20 @@ class xlsx_drawings::Impl ...@@ -15,24 +15,20 @@ class xlsx_drawings::Impl
struct rel_ struct rel_
{ {
rel_(bool is_internal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type) : rel_(bool is_internal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type) :
is_internal_(is_internal), is_internal_(is_internal),
rid_(rid), rid_(rid),
ref_(ref), ref_(ref),
type_(type) type_(type)
{} {}
bool is_internal_; bool is_internal_;
std::wstring rid_; std::wstring rid_;
std::wstring ref_; std::wstring ref_;
mediaitems::Type type_; mediaitems::Type type_;
}; };
public: public:
void add(_xlsx_drawing const & d, void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type)
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{ {
xlsx_drawings_.push_back(d); xlsx_drawings_.push_back(d);
...@@ -51,11 +47,7 @@ public: ...@@ -51,11 +47,7 @@ public:
xlsx_drawing_rels_.push_back(rel_(false, h.hId, h.hRef, mediaitems::typeHyperlink)); xlsx_drawing_rels_.push_back(rel_(false, h.hId, h.hRef, mediaitems::typeHyperlink));
} }
} }
void add(/**/ void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type)
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{ {
bool present = false; bool present = false;
BOOST_FOREACH(rel_ const & r, xlsx_drawing_rels_) BOOST_FOREACH(rel_ const & r, xlsx_drawing_rels_)
...@@ -70,22 +62,33 @@ public: ...@@ -70,22 +62,33 @@ public:
} }
void serialize(std::wostream & strm) void serialize(std::wostream & strm)
{ {
CP_XML_WRITER(strm) if (inGroup)
{ {
CP_XML_NODE(L"xdr:wsDr") BOOST_FOREACH(_xlsx_drawing & d, xlsx_drawings_)
{ {
CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); xlsx_serialize(strm, d);
CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
BOOST_FOREACH(_xlsx_drawing & d, xlsx_drawings_)
{
xlsx_serialize(CP_XML_STREAM(), d);
}
} }
} }
else
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xdr:wsDr")
{
CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
BOOST_FOREACH(_xlsx_drawing & d, xlsx_drawings_)
{
xlsx_serialize(CP_XML_STREAM(), d);
}
}
}
}
} }
bool empty() const bool empty() const
...@@ -130,37 +133,34 @@ public: ...@@ -130,37 +133,34 @@ public:
} }
} }
bool inGroup;
private: private:
std::vector<_xlsx_drawing> xlsx_drawings_; std::vector<_xlsx_drawing> xlsx_drawings_;
std::vector<rel_> xlsx_drawing_rels_;
std::vector<rel_> xlsx_drawing_rels_;
}; };
xlsx_drawings::xlsx_drawings() : impl_( new xlsx_drawings::Impl() ) xlsx_drawings::xlsx_drawings(bool inGroup_) : impl_( new xlsx_drawings::Impl() )
{ {
impl_->inGroup = inGroup_;
} }
xlsx_drawings::~xlsx_drawings() xlsx_drawings::~xlsx_drawings()
{ {
} }
void xlsx_drawings::add(_xlsx_drawing const & d, void xlsx_drawings::add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid,
bool isInternal, std::wstring const & ref, mediaitems::Type type)
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{ {
impl_->add(d, isInternal, rid, ref, type); impl_->add(d, isInternal, rid, ref, type);
} }
void xlsx_drawings::add(/**/
bool isInternal, void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type)
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{ {
impl_->add(isInternal, rid, ref, type); impl_->add(isInternal, rid, ref, type);
} }
void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val) void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val)
{ {
val.impl_->serialize(_Wostream); val.impl_->serialize(_Wostream);
...@@ -176,9 +176,9 @@ void xlsx_drawings::dump_rels(rels & Rels) ...@@ -176,9 +176,9 @@ void xlsx_drawings::dump_rels(rels & Rels)
return impl_->dump_rels(Rels); return impl_->dump_rels(Rels);
} }
xlsx_drawings_ptr xlsx_drawings::create() xlsx_drawings_ptr xlsx_drawings::create(bool inGroup)
{ {
return boost::make_shared<xlsx_drawings>(); return boost::make_shared<xlsx_drawings>(inGroup);
} }
} }
......
...@@ -18,9 +18,9 @@ struct drawing_elm ...@@ -18,9 +18,9 @@ struct drawing_elm
: filename(_filename), content(_content), drawings(_drawings) : filename(_filename), content(_content), drawings(_drawings)
{} {}
std::wstring filename; std::wstring filename;
std::wstring content; std::wstring content;
xlsx_drawings_ptr drawings; xlsx_drawings_ptr drawings;
}; };
struct _xlsx_drawing; struct _xlsx_drawing;
...@@ -29,28 +29,18 @@ class rels; ...@@ -29,28 +29,18 @@ class rels;
class xlsx_drawings class xlsx_drawings
{ {
public: public:
xlsx_drawings(); xlsx_drawings (bool inGroup_);
~xlsx_drawings(); ~xlsx_drawings ();
static xlsx_drawings_ptr create(); static xlsx_drawings_ptr create(bool inGroup);
public: public:
void add(_xlsx_drawing const & d, void add (_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type);
bool isInternal, void add (bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type );
std::wstring const & rid,
std::wstring const & ref, bool empty () const;
mediaitems::Type type void dump_rels (rels & Rels);
);
void add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type
);
bool empty() const;
void dump_rels(rels & Rels);
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val);
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val);
private: private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
......
...@@ -274,7 +274,8 @@ void xl_drawings::write(const std::wstring & RootPath) ...@@ -274,7 +274,8 @@ void xl_drawings::write(const std::wstring & RootPath)
rels_files relFiles; rels_files relFiles;
rels_file_ptr r = rels_file::create(e.filename + L".rels"); rels_file_ptr r = rels_file::create(e.filename + L".rels");
e.drawings->dump_rels(r->get_rels());
e.drawings->dump_rels(r->get_rels());
relFiles.add_rel_file(r); relFiles.add_rel_file(r);
relFiles.write(path); relFiles.write(path);
......
...@@ -274,9 +274,15 @@ void xlsx_text_context::Impl::write_rPr(std::wostream & strm) ...@@ -274,9 +274,15 @@ void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
if (dValFontSize) {CP_XML_ATTR(L"sz", (int)(dValFontSize.get()*100));} if (dValFontSize) {CP_XML_ATTR(L"sz", (int)(dValFontSize.get()*100));}
if ((iValFontStyle) && (iValFontStyle.get() >0)) {CP_XML_ATTR(L"i", "1");} //"true");} Exercícios de Aprendizagem.ods if ((iValFontStyle) && (iValFontStyle.get() >0)) {CP_XML_ATTR(L"i", "1");} //"true");} Exercícios de Aprendizagem.ods
if ((iValFontWeight) && (iValFontWeight.get() >0)) {CP_XML_ATTR(L"b", "1");} //"true");} Exercícios de Aprendizagem.ods if ((iValFontWeight) && (iValFontWeight.get() >0)) {CP_XML_ATTR(L"b", "1");} //"true");} Exercícios de Aprendizagem.ods
if (sValFontFamily) {CP_XML_ATTR(L"typeface", sValFontFamily.get());} if (sValFontColor)
{
CP_XML_NODE(L"a:solidFill") {CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val", sValFontColor.get());}}
}
if (sValFontFamily)
{
CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface", sValFontFamily.get());}
}
if (sValFontColor){CP_XML_NODE(L"a:solidFill") {CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val", sValFontColor.get());}}}
if (hyperlink_hId.length()>0) if (hyperlink_hId.length()>0)
{ {
......
...@@ -293,9 +293,7 @@ void xlsx_conversion_context::end_table() ...@@ -293,9 +293,7 @@ void xlsx_conversion_context::end_table()
get_drawing_context().set_odf_packet_path(root()->get_folder()); get_drawing_context().set_odf_packet_path(root()->get_folder());
get_drawing_context().process_charts(get_table_metrics()); get_drawing_context().process_objects(get_table_metrics());
get_drawing_context().process_images(get_table_metrics());
get_drawing_context().process_shapes(get_table_metrics());
if (!get_drawing_context().empty()) if (!get_drawing_context().empty())
{ {
......
...@@ -96,7 +96,7 @@ void chart_build::add_grid(std::wstring const & className, std::wstring const & ...@@ -96,7 +96,7 @@ void chart_build::add_grid(std::wstring const & className, std::wstring const &
if (!axises_.empty()) if (!axises_.empty())
{ {
axis::grid gr; axis::grid gr;
gr.type_= (className == L"major" ? axis::grid::minor : axis::grid::major); // default: major gr.type_= (className == L"major" ? axis::grid::major : axis::grid::minor); // default: major
gr.style_name_ = styleName; gr.style_name_ = styleName;
axises_.back().grids_.push_back(gr); axises_.back().grids_.push_back(gr);
...@@ -119,11 +119,11 @@ void chart_build::add_series(std::wstring const & cellRangeAddress, ...@@ -119,11 +119,11 @@ void chart_build::add_series(std::wstring const & cellRangeAddress,
series_.push_back(series(cellRangeAddress,labelCell, classType, attachedAxis, styleName)); series_.push_back(series(cellRangeAddress,labelCell, classType, attachedAxis, styleName));
} }
void chart_build::add_point(unsigned int rep, std::wstring const & styleName) void chart_build::add_point(unsigned int rep)
{ {
if (!series_.empty()) if (!series_.empty())
{ {
series_.back().points_.push_back(series::point(rep, styleName)); series_.back().points_.push_back(series::point(rep));
} }
else else
{ {
...@@ -259,8 +259,8 @@ void chart_build::oox_convert(oox::oox_chart_context & chart_context) ...@@ -259,8 +259,8 @@ void chart_build::oox_convert(oox::oox_chart_context & chart_context)
chart_context.set_floor (floor_); chart_context.set_floor (floor_);
chart_context.set_legend (legend_); chart_context.set_legend (legend_);
chart_context.set_plot_area_properties (plot_area_.properties_, plot_area_.fill_); 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_chart_graphic_properties (chart_graphic_properties_ , chart_fill_);
//chart_context.set_footer(footer_); //chart_context.set_footer(footer_);
//chart_context.set_chart_properties(chart_graphic_properties_); //chart_context.set_chart_properties(chart_graphic_properties_);
...@@ -548,6 +548,7 @@ void process_build_chart::visit(const chart_title& val) ...@@ -548,6 +548,7 @@ void process_build_chart::visit(const chart_title& val)
t.pos_x = val.chart_title_attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt); t.pos_x = val.chart_title_attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
t.pos_y = val.chart_title_attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt); t.pos_y = val.chart_title_attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
} }
t.bEnabled = true;
if (chart_build_.in_axis_) if (chart_build_.in_axis_)
chart_build_.axises_.back().title_ = t; chart_build_.axises_.back().title_ = t;
...@@ -568,11 +569,14 @@ void process_build_chart::visit(const chart_subtitle & val) ...@@ -568,11 +569,14 @@ void process_build_chart::visit(const chart_subtitle & val)
t.pos_x = val.chart_title_attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt); t.pos_x = val.chart_title_attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
t.pos_y = val.chart_title_attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt); t.pos_y = val.chart_title_attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
} }
t.bEnabled = true;
chart_build_.sub_title_ = t; chart_build_.sub_title_ = t;
} }
void process_build_chart::visit(const chart_footer& val) void process_build_chart::visit(const chart_footer& val)
{ {
chart_build_.footer_.bEnabled = true;
ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.properties_); ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.properties_);
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.graphic_properties_, chart_build_.footer_.fill_); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.graphic_properties_, chart_build_.footer_.fill_);
ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.text_properties_); ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.text_properties_);
...@@ -580,6 +584,8 @@ void process_build_chart::visit(const chart_footer& val) ...@@ -580,6 +584,8 @@ void process_build_chart::visit(const chart_footer& val)
void process_build_chart::visit(const chart_legend& val) void process_build_chart::visit(const chart_legend& val)
{ {
chart_build_.legend_.bEnabled = true;
ApplyChartProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.properties_); ApplyChartProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.properties_);
ApplyGraphicProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.graphic_properties_,chart_build_.legend_.fill_); ApplyGraphicProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.graphic_properties_,chart_build_.legend_.fill_);
ApplyTextProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.text_properties_); ApplyTextProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.text_properties_);
...@@ -653,6 +659,8 @@ void process_build_chart::visit(const chart_grid& val) ...@@ -653,6 +659,8 @@ void process_build_chart::visit(const chart_grid& val)
} }
void process_build_chart::visit(const chart_wall& val) void process_build_chart::visit(const chart_wall& val)
{ {
chart_build_.wall_.bEnabled = true;
ApplyChartProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.properties_); ApplyChartProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.properties_);
ApplyGraphicProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.graphic_properties_,chart_build_.wall_.fill_); ApplyGraphicProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.graphic_properties_,chart_build_.wall_.fill_);
ApplyTextProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.text_properties_); ApplyTextProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.text_properties_);
...@@ -660,6 +668,8 @@ void process_build_chart::visit(const chart_wall& val) ...@@ -660,6 +668,8 @@ void process_build_chart::visit(const chart_wall& val)
void process_build_chart::visit(const chart_floor& val) void process_build_chart::visit(const chart_floor& val)
{ {
chart_build_.floor_.bEnabled = true;
ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.properties_); ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.properties_);
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.graphic_properties_,chart_build_.floor_.fill_); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.graphic_properties_,chart_build_.floor_.fill_);
ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.text_properties_); ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.text_properties_);
...@@ -667,14 +677,20 @@ void process_build_chart::visit(const chart_floor& val) ...@@ -667,14 +677,20 @@ void process_build_chart::visit(const chart_floor& val)
void process_build_chart::visit(const chart_data_point & val) void process_build_chart::visit(const chart_data_point & val)
{ {
chart_build_.add_point( val.chart_data_point_attlist_.chart_repeated_.get_value_or(0/*1*/), chart_build_.add_point( val.chart_data_point_attlist_.chart_repeated_.get_value_or(1));
val.chart_data_point_attlist_.common_attlist_.chart_style_name_.get_value_or(L"")
); if (val.chart_data_point_attlist_.common_attlist_.chart_style_name_)
{
ApplyGraphicProperties (val.chart_data_point_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),
chart_build_.series_.back().points_.back().graphic_properties_,
chart_build_.series_.back().points_.back().fill_);
}
} }
void process_build_chart::visit(const chart_mean_value & val) void process_build_chart::visit(const chart_mean_value & val)
{ {
ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().mean_value_.properties_); ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().mean_value_.properties_);
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().mean_value_.graphic_properties_,chart_build_.series_.back().mean_value_.fill_); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().mean_value_.graphic_properties_, chart_build_.series_.back().mean_value_.fill_);
} }
void process_build_chart::visit(const chart_error_indicator & val) void process_build_chart::visit(const chart_error_indicator & val)
{ {
......
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
std::wstring const & attachedAxis, std::wstring const & attachedAxis,
std::wstring const & styleName); std::wstring const & styleName);
void add_point(unsigned int rep, std::wstring const & styleName); void add_point(unsigned int rep);
void calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash); void calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash);
......
...@@ -31,26 +31,31 @@ namespace chart { ...@@ -31,26 +31,31 @@ namespace chart {
struct title struct title
{ {
std::wstring content_; title() : bEnabled(false), pos_x(0), pos_y(0) {}
std::vector<_property> text_properties_; bool bEnabled;
double pos_x; std::wstring content_;
double pos_y; std::vector<_property> text_properties_;
double pos_x;
double pos_y;
} ; } ;
struct simple struct simple
{ {
std::vector<_property> properties_; simple() : bEnabled(false) {}
std::vector<_property> text_properties_; bool bEnabled;
std::vector<_property> graphic_properties_; std::vector<_property> properties_;
oox::_oox_fill fill_; std::vector<_property> text_properties_;
std::vector<_property> graphic_properties_;
oox::_oox_fill fill_;
}; };
struct treadline struct treadline
{ {
bool bEquation; bool bEquation;
bool bREquation; bool bREquation;
std::vector<_property> line_properties_; std::vector<_property> line_properties_;
simple equation_properties_; simple equation_properties_;
treadline(){bEquation = false; bREquation = false;} treadline(){bEquation = false; bREquation = false;}
...@@ -68,12 +73,13 @@ namespace chart { ...@@ -68,12 +73,13 @@ namespace chart {
{ {
enum grid_type {major, minor}; enum grid_type {major, minor};
grid_type type_; grid_type type_;
std::wstring style_name_; std::wstring style_name_;
std::vector<_property> graphic_properties_; std::vector<_property> graphic_properties_;
}; };
bool bCategories_; bool bCategories_;
title title_; title title_;
std::wstring dimension_; std::wstring dimension_;
...@@ -87,11 +93,12 @@ namespace chart { ...@@ -87,11 +93,12 @@ namespace chart {
{ {
struct point struct point
{ {
point(unsigned int rep, std::wstring const & styleName) : repeated_(rep), style_name_(styleName) point(unsigned int rep/*, std::wstring const & styleName*/) : repeated_(rep)/*, style_name_(styleName)*/{}
{}
unsigned int repeated_;
std::vector<_property> graphic_properties_;
oox::_oox_fill fill_;
unsigned int repeated_;
std::wstring style_name_;
}; };
std::wstring name_; std::wstring name_;
......
...@@ -235,13 +235,13 @@ public: ...@@ -235,13 +235,13 @@ public:
void serialize(CP_ATTR_NODE); void serialize(CP_ATTR_NODE);
public: public:
_CP_OPT(office_value_type) office_value_type_; _CP_OPT(office_value_type) office_value_type_;
_CP_OPT(std::wstring) office_value_; _CP_OPT(std::wstring) office_value_;
_CP_OPT(std::wstring) office_currency_; _CP_OPT(std::wstring) office_currency_;
_CP_OPT(std::wstring) office_date_value_; _CP_OPT(std::wstring) office_date_value_;
_CP_OPT(std::wstring) office_time_value_; _CP_OPT(std::wstring) office_time_value_;
_CP_OPT(std::wstring) office_boolean_value_; _CP_OPT(std::wstring) office_boolean_value_;
_CP_OPT(std::wstring) office_string_value_; _CP_OPT(std::wstring) office_string_value_;
}; };
......
...@@ -37,10 +37,50 @@ namespace odf_reader { ...@@ -37,10 +37,50 @@ namespace odf_reader {
void draw_g::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_g::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
for (int i = 0 ; i < content_.size(); i++) common_draw_shape_with_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_;
const int z_index = common_draw_attlist_.common_draw_z_index_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_draw_name_attlist_.draw_name_.get_value_or(L"");
//////////////////////////////////////////////////////////////////////////
Context.get_drawing_context().start_group( name);
//const _CP_OPT(length) svg_widthVal = common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_;
// const _CP_OPT(length) svg_heightVal = common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_;
//if (svg_widthVal && svg_heightVal)
//{
// const double width_pt = svg_widthVal.get_value_or(length(0)).get_value_unit(length::pt);
// const double height_pt = svg_heightVal.get_value_or(length(0)).get_value_unit(length::pt);
// const double x_pt = common_draw_attlists_.position_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
// const double y_pt = common_draw_attlists_.position_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
// Context.get_drawing_context().set_rect(width_pt, height_pt, x_pt, y_pt);
//}
////////////////////////////////////////
std::wstring Anchor;
if (common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_)
{
Anchor = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_.get();
const double a_x_pt = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double a_y_pt = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_y_.get_value_or(length(0)).get_value_unit(length::pt);
Context.get_drawing_context().set_anchor(Anchor, a_x_pt, a_y_pt, true);
}
////////////////////////////////////////////////
for (int i = 0; i < content_.size(); i++)
{ {
content_[i]->xlsx_convert(Context); office_element_ptr const & elm = content_[i];
elm->xlsx_convert(Context);
} }
Context.get_drawing_context().end_group();
Context.get_drawing_context().clear();
} }
void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
...@@ -83,10 +123,11 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -83,10 +123,11 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
if (common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_) if (common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_)
{ {
Anchor = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_.get(); Anchor = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_.get();
const double a_x_pt = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_x_.get_value_or(length(0)).get_value_unit(length::pt); const double a_x_pt = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double a_y_pt = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_y_.get_value_or(length(0)).get_value_unit(length::pt); const double a_y_pt = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_y_.get_value_or(length(0)).get_value_unit(length::pt);
Context.get_drawing_context().set_anchor(Anchor,a_x_pt,a_y_pt); Context.get_drawing_context().set_anchor(Anchor, a_x_pt, a_y_pt);
} }
////////////////////////////////////////////// //////////////////////////////////////////////
std::vector<const odf_reader::style_instance *> instances; std::vector<const odf_reader::style_instance *> instances;
...@@ -120,20 +161,14 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -120,20 +161,14 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
Context.root()->odf_context().drawStyles() ,fill); Context.root()->odf_context().drawStyles() ,fill);
Context.get_drawing_context().set_fill(fill); Context.get_drawing_context().set_fill(fill);
//////////////////////////////////////////////// ////////////////////////////////////////////////
//BOOST_FOREACH(office_element_ptr const & elm, content_) for (int i = 0 ; i < content_.size(); i++)
//{
// elm->xlsx_convert(Context);
//}
int i=0;
int size = content_.size();
while(true)
{ {
if (i>=size)break;
office_element_ptr const & elm = content_[i]; office_element_ptr const & elm = content_[i];
elm->xlsx_convert(Context); elm->xlsx_convert(Context);
i++;
} }
Context.get_drawing_context().end_drawing(); Context.get_drawing_context().end_drawing();
Context.get_drawing_context().clear();
} }
void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
...@@ -143,13 +178,9 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -143,13 +178,9 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
//////////////////////////////////// ... //////////////////////////////////// ...
Context.get_text_context().start_drawing_content();//... - Context.get_text_context().start_drawing_content();//... -
int i=0; for (int i = 0 ; i < content_.size(); i++)
int size = content_.size();
while(true)
{ {
if (i>=size)break;
content_[i]->xlsx_convert(Context); content_[i]->xlsx_convert(Context);
i++;
} }
std::wstring text_content_ = Context.get_text_context().end_drawing_content(); std::wstring text_content_ = Context.get_text_context().end_drawing_content();
...@@ -165,17 +196,9 @@ void draw_chart::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -165,17 +196,9 @@ void draw_chart::xlsx_convert(oox::xlsx_conversion_context & Context)
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L""); const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
Context.get_drawing_context().start_chart(href); Context.get_drawing_context().start_chart(href);
//BOOST_FOREACH(office_element_ptr const & elm, content_) for (int i = 0 ; i < content_.size(); i++)
//{
// elm->xlsx_convert(Context);
//}
int i=0;
int size = content_.size();
while(true)
{ {
if (i>=size)break;
content_[i]->xlsx_convert(Context); content_[i]->xlsx_convert(Context);
i++;
} }
Context.get_drawing_context().end_chart(); Context.get_drawing_context().end_chart();
} }
...@@ -184,25 +207,18 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -184,25 +207,18 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context)
Context.get_drawing_context().start_shape(2);//rect Context.get_drawing_context().start_shape(2);//rect
Context.get_text_context().start_drawing_content(); Context.get_text_context().start_drawing_content();
//BOOST_FOREACH(office_element_ptr const & elm, content_) for (int i = 0 ; i < content_.size(); i++)
//{
// elm->xlsx_convert(Context);
//}
int i=0;
int size = content_.size();
while(true)
{ {
if (i>=size)break;
content_[i]->xlsx_convert(Context); content_[i]->xlsx_convert(Context);
i++;
} }
std::wstring text_content_ = Context.get_text_context().end_drawing_content(); std::wstring text_content_ = Context.get_text_context().end_drawing_content();
if (text_content_.length()>0) if (text_content_.length()>0)
{ {
Context.get_drawing_context().set_property(_property(L"text-content",text_content_)); Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
} }
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
} }
void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
......
...@@ -127,6 +127,7 @@ void draw_rect::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -127,6 +127,7 @@ void draw_rect::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_ellipse::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_ellipse::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
...@@ -135,6 +136,7 @@ void draw_ellipse::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -135,6 +136,7 @@ void draw_ellipse::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_circle::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_circle::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
...@@ -143,6 +145,7 @@ void draw_circle::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -143,6 +145,7 @@ void draw_circle::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_line::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_line::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
...@@ -153,6 +156,7 @@ void draw_line::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -153,6 +156,7 @@ void draw_line::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
...@@ -165,6 +169,7 @@ void draw_path::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -165,6 +169,7 @@ void draw_path::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_connector::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_connector::xlsx_convert(oox::xlsx_conversion_context & Context)
...@@ -176,6 +181,7 @@ void draw_connector::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -176,6 +181,7 @@ void draw_connector::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_polygon::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_polygon::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
...@@ -186,6 +192,7 @@ void draw_polygon::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -186,6 +192,7 @@ void draw_polygon::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_polyline::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_polyline::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
...@@ -196,6 +203,7 @@ void draw_polyline::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -196,6 +203,7 @@ void draw_polyline::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_custom_shape::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_custom_shape::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
...@@ -204,6 +212,7 @@ void draw_custom_shape::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -204,6 +212,7 @@ void draw_custom_shape::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_caption::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_caption::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
...@@ -214,7 +223,7 @@ void draw_caption::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -214,7 +223,7 @@ void draw_caption::xlsx_convert(oox::xlsx_conversion_context & Context)
common_xlsx_convert(Context); common_xlsx_convert(Context);
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
} }
void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
......
...@@ -599,43 +599,25 @@ const wchar_t * table_shapes::name = L"shapes"; ...@@ -599,43 +599,25 @@ const wchar_t * table_shapes::name = L"shapes";
void table_shapes::docx_convert(oox::docx_conversion_context & Context) void table_shapes::docx_convert(oox::docx_conversion_context & Context)
{ {
int i=0; for (int i = 0 ; i < content_.size(); i++)
int size = content_.size(); {
while(true)
{
if (i>=size)break;
content_[i]->docx_convert(Context); content_[i]->docx_convert(Context);
i++;
} }
} }
void table_shapes::pptx_convert(oox::pptx_conversion_context & Context) void table_shapes::pptx_convert(oox::pptx_conversion_context & Context)
{ {
int i=0; for (int i = 0 ; i < content_.size(); i++)
int size = content_.size(); {
while(true)
{
if (i>=size)break;
content_[i]->pptx_convert(Context); content_[i]->pptx_convert(Context);
i++;
} }
} }
void table_shapes::xlsx_convert(oox::xlsx_conversion_context & Context) void table_shapes::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
Context.get_drawing_context().start_shapes(); for (int i = 0 ; i < content_.size(); i++)
//BOOST_FOREACH(office_element_ptr const & elm, content_) {
//{
// elm->xlsx_convert(Context);
//}
int i=0;
int size = content_.size();
while(true)
{
if (i>=size)break;
content_[i]->xlsx_convert(Context); content_[i]->xlsx_convert(Context);
i++;
} }
Context.get_drawing_context().end_shapes();
} }
void table_shapes::add_attributes( const xml::attributes_wc_ptr & Attributes ) void table_shapes::add_attributes( const xml::attributes_wc_ptr & Attributes )
......
...@@ -62,12 +62,13 @@ public: ...@@ -62,12 +62,13 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes( const xml::attributes_wc_ptr & Attributes );
public: public:
unsigned int table_number_columns_repeated_; // default 1 unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(odf_types::style_ref) table_style_name_; _CP_OPT(odf_types::style_ref) table_style_name_;
_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_;
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
...@@ -80,10 +81,11 @@ public: ...@@ -80,10 +81,11 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes( const xml::attributes_wc_ptr & Attributes );
public: public:
unsigned int table_number_columns_spanned_; // default 1 unsigned int table_number_columns_spanned_; // default 1
unsigned int table_number_rows_spanned_; // default 1 unsigned int table_number_rows_spanned_; // default 1
_CP_OPT(unsigned int) table_number_matrix_columns_spanned_;
_CP_OPT(unsigned int) table_number_matrix_rows_spanned_; _CP_OPT(unsigned int) table_number_matrix_columns_spanned_;
_CP_OPT(unsigned int) table_number_matrix_rows_spanned_;
}; };
......
...@@ -738,6 +738,16 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -738,6 +738,16 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
CP_XML_NODE(L"f") CP_XML_NODE(L"f")
{ {
if (table_table_cell_attlist_extra_.table_number_matrix_columns_spanned_ && table_table_cell_attlist_extra_.table_number_matrix_rows_spanned_)
{
std::wstring ref = oox::getCellAddress(Context.current_table_column(), Context.current_table_row());
ref += L":";
ref += oox::getCellAddress(Context.current_table_column() + *table_table_cell_attlist_extra_.table_number_matrix_columns_spanned_ - 1,
Context.current_table_row() + *table_table_cell_attlist_extra_.table_number_matrix_rows_spanned_ - 1);
CP_XML_ATTR(L"ref", ref);
CP_XML_ATTR(L"t", L"array");
CP_XML_ATTR(L"aca", false);
}
//CP_XML_CONTENT(xml::utils::replace_lt_gt(xlsxFormula)); //CP_XML_CONTENT(xml::utils::replace_lt_gt(xlsxFormula));
CP_XML_CONTENT(xlsxFormula); CP_XML_CONTENT(xlsxFormula);
} }
......
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