Commit 1f6a65e5 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - уточнее диаграмм, работа с ошибочными диапазонами

parent 81c1d7ee
......@@ -142,10 +142,8 @@ 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 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"\\[(.*?)\\]");
/*
[ $ Sheet2 . A1 : . B5 ]
*/
const std::wstring res = boost::regex_replace(
......@@ -246,7 +244,19 @@ std::wstring replace_space_PROBEL(boost::wsmatch const & what)
else if (what[3].matched)
return what[3].str();
}
std::wstring replace_point_ÒÎÑHKA(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
boost::algorithm::replace_all(inner, L".", L"ÒÎÑHKA");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
}
std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
......@@ -314,9 +324,14 @@ std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
if (is_forbidden(expr))
return L"NULLFORMULA()";
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// ïîèñê òîãî ÷òî â àïîñòðîôàõ è çàìåíà òàì òî÷åê íà ÒÎÑHKA
std::wstring workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_ÒÎÑHKA,
boost::match_default | boost::format_all);
std::wstring workstr = expr;
boost::algorithm::replace_all(workstr, L" ", L"PROBEL");
boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
......@@ -332,8 +347,9 @@ std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
//todooo
}
boost::algorithm::replace_all(workstr, L"PROBEL", L" ");
boost::algorithm::replace_all(workstr, L"APOSTROF", L"'");
boost::algorithm::replace_all(workstr, L"PROBEL" , L" ");
boost::algorithm::replace_all(workstr, L"APOSTROF" , L"'");
boost::algorithm::replace_all(workstr, L"TOCHKA" , L".");
return workstr;
}
......@@ -347,10 +363,7 @@ std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring&
return L"NULLFORMULA()";
std::wstring workstr = expr;
//replace_space(workstr);
//return workstr;
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");
// boost::wregex complexRef(L"(\\'(.*?)\\')"); // ïîèñê òîãî ÷òî â àïîñòðîôàõ è çàìåíà òàì ïðîáåëîâ íà PROBEL
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// ïîèñê òîãî ÷òî â àïîñòðîôàõ è çàìåíà òàì ïðîáåëîâ íà PROBEL
workstr = boost::regex_replace(
expr,
......@@ -425,15 +438,35 @@ std::wstring odf2oox_converter::convert_chart_distance(const std::wstring& expr)
}
std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr)
{
std::wstring workstr = expr;
impl_->replace_named_ref(workstr);
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// ïîèñê òîãî ÷òî â àïîñòðîôàõ è çàìåíà òàì òî÷åê íà ÒÎÑHKA
std::wstring workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_ÒÎÑHKA,
boost::match_default | boost::format_all);
boost::algorithm::replace_all(workstr, L" ", L"PROBEL");
boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
impl_->replace_named_ref(workstr);
boost::algorithm::replace_all(workstr, L"PROBEL" , L" ");
boost::algorithm::replace_all(workstr, L"APOSTROF" , L"'");
boost::algorithm::replace_all(workstr, L"TOCHKA" , L".");
return workstr;
}
std::wstring odf2oox_converter::convert_named_expr(const std::wstring& expr)
{
std::wstring workstr = expr;
boost::algorithm::replace_all(workstr, L" ", L"PROBEL");
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// ïîèñê òîãî ÷òî â àïîñòðîôàõ è çàìåíà òàì òî÷åê íà ÒÎÑHKA
std::wstring workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_ÒÎÑHKA,
boost::match_default | boost::format_all);
boost::algorithm::replace_all(workstr, L" ", L"PROBEL");
boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
impl_->replace_cells_range(workstr);
......@@ -447,9 +480,10 @@ std::wstring odf2oox_converter::convert_named_expr(const std::wstring& expr)
//todooo
}
boost::algorithm::replace_all(workstr, L"PROBEL", L" ");
boost::algorithm::replace_all(workstr, L"APOSTROF", L"'");
return workstr;
boost::algorithm::replace_all(workstr, L"PROBEL" , L" ");
boost::algorithm::replace_all(workstr, L"APOSTROF" , L"'");
boost::algorithm::replace_all(workstr, L"TOCHKA" , L".");
return workstr;
}
std::wstring odf2oox_converter::convert_ref(std::wstring const & expr)
......
......@@ -15,7 +15,7 @@ namespace oox {
void oox_chart_legend::oox_serialize_default_text(std::wostream & _Wostream)
{
if (content_.text_properties_.size()<1)return;
if (content_.text_properties_.size() < 1)return;
CP_XML_WRITER(_Wostream)
{
......@@ -56,7 +56,7 @@ void oox_chart_legend::oox_serialize_default_text(std::wostream & _Wostream)
void oox_chart_legend::oox_serialize(std::wostream & _Wostream)
{
if (content_.bEnabled ==false) return;
if (content_.bEnabled == false) return;
oox_chart_shape shape;
......@@ -64,21 +64,21 @@ void oox_chart_legend::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:legend")
{
layout_.oox_serialize(CP_XML_STREAM());
CP_XML_NODE(L"c:overlay")
{
CP_XML_ATTR(L"val", 0);
}
CP_XML_NODE(L"c:legendPos")
{
CP_XML_ATTR(L"val", "r");// "b" | "l" | "r" | "t"// == bottom left right top
}
layout_.oox_serialize(CP_XML_STREAM());
CP_XML_NODE(L"c:overlay")
{
CP_XML_ATTR(L"val", 0);
}
shape.set(content_.graphic_properties_,content_.fill_);
shape.oox_serialize(CP_XML_STREAM());
//oox_chart_shape shape;
//shape.set(content_.graphic_properties_,content_.fill_);
oox_serialize_default_text(CP_XML_STREAM());
......
......@@ -451,6 +451,18 @@ void oox_pie_series::oox_serialize(std::wostream & _Wostream)
CP_XML_NODE(L"c:ser")
{
oox_serialize_common(CP_XML_STREAM());
_CP_OPT(int) iVal;
odf_reader::GetProperty(content_.properties_, L"pie-offset", iVal);
if (iVal)
{
CP_XML_NODE(L"c:explosion")
{
CP_XML_ATTR(L"val", *iVal);
}
}
}
}
}
......
......@@ -66,7 +66,7 @@ void oox_chart::oox_serialize_common(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
if (grouping_.length()>1)
if (!grouping_.empty())
{
CP_XML_NODE(L"c:grouping")
{
......@@ -285,8 +285,6 @@ void oox_doughnut_chart::set_properties(std::vector<odf_reader::_property> g)
}
void oox_doughnut_chart::oox_serialize(std::wostream & _Wostream)
{
grouping_.clear();
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"c:doughnutChart")
......@@ -327,7 +325,7 @@ 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(strNode)
{
......@@ -355,7 +353,7 @@ void oox_radar_chart::set_properties(std::vector<odf_reader::_property> g)
}
void oox_radar_chart::oox_serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"c:radarChart")
{
......
......@@ -38,7 +38,7 @@ public:
}
~oox_chart(){}
virtual void oox_serialize(std::wostream & _Wostream){}
virtual void oox_serialize(std::wostream & _Wostream) = 0;
void oox_serialize_common(std::wostream & _Wostream);
......@@ -200,7 +200,8 @@ class oox_doughnut_chart: public oox_chart
public:
oox_doughnut_chart()
{
type_ = CHART_TYPE_DOUGHNUT;
type_ = CHART_TYPE_DOUGHNUT;
grouping_ = L"";
}
~oox_doughnut_chart(){}
......@@ -224,7 +225,8 @@ class oox_pie_chart: public oox_chart
public:
oox_pie_chart()
{
type_ = CHART_TYPE_PIE;
type_ = CHART_TYPE_PIE;
grouping_ = L"";
}
~oox_pie_chart(){}
......
......@@ -49,7 +49,15 @@ public:
CP_XML_NODE(L"definedName")
{
CP_XML_ATTR(L"name", elm.first);
CP_XML_CONTENT(elm.second);
int pos;
if ( (pos = elm.second.find(L"#REF!")) >= 0 )
{
CP_XML_ATTR(L"comment", elm.second);
CP_XML_CONTENT(L"#REF!");
}
else
CP_XML_CONTENT(elm.second);
}
}
}
......
......@@ -57,22 +57,22 @@ void style_chart_properties::add_attributes( const xml::attributes_wc_ptr & Attr
_CP_OPT(int) iVal;
//CP_APPLY_ATTR(L"chart:symbol-type", iVal); if (iVal)content_.push_back(_property(L"symbol-type", iVal.get()));
CP_APPLY_ATTR(L"chart:gap-width", iVal); if (iVal)content_.push_back(_property(L"gap-width", iVal.get()));
CP_APPLY_ATTR(L"chart:overlap", iVal); if (iVal)content_.push_back(_property(L"overlap", iVal.get()));
CP_APPLY_ATTR(L"chart:spline-order", iVal); if (iVal)content_.push_back(_property(L"spline-order", iVal.get()));
CP_APPLY_ATTR(L"chart:spline-resolution",iVal); if (iVal)content_.push_back(_property(L"spline-resolution", iVal.get()));
CP_APPLY_ATTR(L"chart:pie-offset", iVal); if (iVal)content_.push_back(_property(L"pie-offset", iVal.get()));
CP_APPLY_ATTR(L"chart:interval-minor-divisor",iVal); if (iVal)content_.push_back(_property(L"interval-minor-divisor",iVal.get()));
//CP_APPLY_ATTR(L"chart:symbol-type", iVal); if (iVal)content_.push_back(_property(L"symbol-type", iVal.get()));
CP_APPLY_ATTR(L"chart:gap-width", iVal); if (iVal)content_.push_back(_property(L"gap-width", iVal.get()));
CP_APPLY_ATTR(L"chart:overlap", iVal); if (iVal)content_.push_back(_property(L"overlap", iVal.get()));
CP_APPLY_ATTR(L"chart:spline-order", iVal); if (iVal)content_.push_back(_property(L"spline-order", iVal.get()));
CP_APPLY_ATTR(L"chart:spline-resolution",iVal); if (iVal)content_.push_back(_property(L"spline-resolution", iVal.get()));
CP_APPLY_ATTR(L"chart:pie-offset", iVal); if (iVal)content_.push_back(_property(L"pie-offset", iVal.get()));
CP_APPLY_ATTR(L"chart:interval-minor-divisor",iVal); if (iVal)content_.push_back(_property(L"interval-minor-divisor",iVal.get()));
_CP_OPT(double) dVal;
CP_APPLY_ATTR(L"chart:maximum", dVal); if (dVal)content_.push_back(_property(L"maximum", dVal.get()));
CP_APPLY_ATTR(L"chart:minimum", dVal); if (dVal)content_.push_back(_property(L"minimum", dVal.get()));
CP_APPLY_ATTR(L"chart:origin", dVal); if (dVal)content_.push_back(_property(L"origin", dVal.get()));
CP_APPLY_ATTR(L"chart:interval-major", dVal); if (dVal)content_.push_back(_property(L"interval-major", dVal.get()));
CP_APPLY_ATTR(L"chart:error-percentage",dVal); if (dVal)content_.push_back(_property(L"error-percentage", dVal.get()));
CP_APPLY_ATTR(L"chart:error-margin", dVal); if (dVal)content_.push_back(_property(L"error-margin", dVal.get()));
CP_APPLY_ATTR(L"chart:maximum", dVal); if (dVal)content_.push_back(_property(L"maximum", dVal.get()));
CP_APPLY_ATTR(L"chart:minimum", dVal); if (dVal)content_.push_back(_property(L"minimum", dVal.get()));
CP_APPLY_ATTR(L"chart:origin", dVal); if (dVal)content_.push_back(_property(L"origin", dVal.get()));
CP_APPLY_ATTR(L"chart:interval-major", dVal); if (dVal)content_.push_back(_property(L"interval-major", dVal.get()));
CP_APPLY_ATTR(L"chart:error-percentage",dVal); if (dVal)content_.push_back(_property(L"error-percentage", dVal.get()));
CP_APPLY_ATTR(L"chart:error-margin", dVal); if (dVal)content_.push_back(_property(L"error-margin", dVal.get()));
CP_APPLY_ATTR(L"chart:error-lower-limit",dVal); if (dVal)content_.push_back(_property(L"error-lower-limit", dVal.get()));
CP_APPLY_ATTR(L"chart:error-upper-limit",dVal); if (dVal)content_.push_back(_property(L"error-upper-limit", dVal.get()));
......
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