Commit f37394db authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - fix errors content

parent 41b3c6fb
...@@ -239,7 +239,7 @@ namespace formulasconvert { ...@@ -239,7 +239,7 @@ namespace formulasconvert {
bool odf2oox_converter::Impl::check_formula(std::wstring& expr) bool odf2oox_converter::Impl::check_formula(std::wstring& expr)
{ {
boost::match_results<std::wstring::const_iterator> res; boost::match_results<std::wstring::const_iterator> res;
if (boost::regex_search(expr, res, boost::wregex(L"(?:[\\w]+:)?=(.+)"), boost::match_default)) if (boost::regex_search(expr, res, boost::wregex(L"^(?:[\\w]+:)?=(.+)"), boost::match_default))
{ {
expr = res[1].str(); expr = res[1].str();
while (expr.find(L"=") == 0) while (expr.find(L"=") == 0)
...@@ -431,6 +431,7 @@ namespace formulasconvert { ...@@ -431,6 +431,7 @@ namespace formulasconvert {
if (isFormula) if (isFormula)
{ {
boost::algorithm::replace_all(workstr, L"FDIST(", L"_xlfn.F.DIST("); boost::algorithm::replace_all(workstr, L"FDIST(", L"_xlfn.F.DIST(");
// ROUNDUP( - тут в oox 2 параметра - разрядность нужно - ,0) - EV Requirements v2.2.3.ods
int res_find=0; int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0) if ((res_find = workstr.find(L"CONCATINATE")) > 0)
......
...@@ -399,9 +399,10 @@ void pptx_text_context::Impl::write_t(std::wostream & strm) ...@@ -399,9 +399,10 @@ void pptx_text_context::Impl::write_t(std::wostream & strm)
void pptx_text_context::Impl::write_rPr(std::wostream & strm) void pptx_text_context::Impl::write_rPr(std::wostream & strm)
{ {
if (paragraph_style_name_.length()<1 && span_style_name_.length()<1 && !(hyperlink_hId.length()>0) && base_style_name_.length()<1)return; if (paragraph_style_name_.empty() && span_style_name_.empty() && !(!hyperlink_hId.empty()) && base_style_name_.empty())
return;
odf_reader::text_format_properties_content text_properties_paragraph_; odf_reader::text_format_properties_content text_properties_paragraph_;
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_,odf_types::style_family::Paragraph); ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_,odf_types::style_family::Paragraph);
odf_reader::text_format_properties_content text_properties_span_; odf_reader::text_format_properties_content text_properties_span_;
...@@ -415,6 +416,7 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm) ...@@ -415,6 +416,7 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm)
get_styles_context().start(); get_styles_context().start();
get_styles_context().hlinkClick() = hyperlink_hId; get_styles_context().hlinkClick() = hyperlink_hId;
text_properties_.pptx_convert(pptx_context_); text_properties_.pptx_convert(pptx_context_);
strm << get_styles_context().text_style().str(); strm << get_styles_context().text_style().str();
......
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
#include "xlsx_utils.h" #include "xlsx_utils.h"
#include <vector> #include <vector>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
#include "../formulasconvert/formulasconvert.h" #include "../formulasconvert/formulasconvert.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -84,6 +84,7 @@ namespace oox { ...@@ -84,6 +84,7 @@ namespace oox {
_CP_OPT(std::wstring) formula_type; _CP_OPT(std::wstring) formula_type;
_CP_OPT(std::wstring) text; _CP_OPT(std::wstring) text;
_CP_OPT(std::wstring) formula2; _CP_OPT(std::wstring) formula2;
_CP_OPT(int) rank;
//color scale icon set data_bar //color scale icon set data_bar
std::vector<_cfvo> cfvo; std::vector<_cfvo> cfvo;
//color scale data_bar(1 element) //color scale data_bar(1 element)
...@@ -138,7 +139,8 @@ public: ...@@ -138,7 +139,8 @@ public:
if (c.rules[j].operator_) CP_XML_ATTR(L"operator", *c.rules[j].operator_); if (c.rules[j].operator_) CP_XML_ATTR(L"operator", *c.rules[j].operator_);
if (c.rules[j].stopIfTrue) CP_XML_ATTR(L"stopIfTrue", *c.rules[j].stopIfTrue); if (c.rules[j].stopIfTrue) CP_XML_ATTR(L"stopIfTrue", *c.rules[j].stopIfTrue);
if (c.rules[j].text) CP_XML_ATTR(L"text", *c.rules[j].text); if (c.rules[j].text) CP_XML_ATTR(L"text", *c.rules[j].text);
//CP_XML_ATTR(L"rank" , 0); if (c.rules[j].rank) CP_XML_ATTR(L"rank", *c.rules[j].rank);
//CP_XML_ATTR(L"bottom" , 0); //CP_XML_ATTR(L"bottom" , 0);
//CP_XML_ATTR(L"equalAverage" , 0); //CP_XML_ATTR(L"equalAverage" , 0);
//CP_XML_ATTR(L"aboveAverage" , 0); //CP_XML_ATTR(L"aboveAverage" , 0);
...@@ -271,12 +273,36 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f) ...@@ -271,12 +273,36 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
} }
else if (0 <= (pos = f.find(L"is-between("))) else if (0 <= (pos = f.find(L"is-between(")))
{ {
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(val); impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(val);
} }
else if (0 <= (pos = f.find(L"is-time("))) else if (0 <= (pos = f.find(L"is-time(")))
{ {
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(val); impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(val);
} }
else if (0 <= (pos = f.find(L"duplicate")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
}
else if (0 <= (pos = f.find(L"top")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"top10";
if (0 < (pos = f.find(L"percent")))
{
impl_->conditionalFormattings_.back().rules.back().percent = true;
}
if (0 <= (pos = f.find(L"(")))
{
val = f.substr(pos + 1, f.length() - pos - 2);
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
}
}
else if (0 <= (pos = f.find(L"contains-text")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
impl_->conditionalFormattings_.back().rules.back().text = f.substr(15, f.length() - 17);
}
else else
{ {
impl_->conditionalFormattings_.back().rules.back().formula_type = L"cellIs"; impl_->conditionalFormattings_.back().rules.back().formula_type = L"cellIs";
...@@ -293,11 +319,6 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f) ...@@ -293,11 +319,6 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
{ {
val = converter.convert_named_expr( f ); val = converter.convert_named_expr( f );
} }
else if (0 <= (pos = f.find(L"top")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"top10";
val = converter.convert_named_expr( f );
}
else if (0 <= (pos = f.find(L"!="))) else if (0 <= (pos = f.find(L"!=")))
{ {
impl_->conditionalFormattings_.back().rules.back().operator_ = L"notEqual"; impl_->conditionalFormattings_.back().rules.back().operator_ = L"notEqual";
...@@ -328,12 +349,6 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f) ...@@ -328,12 +349,6 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
impl_->conditionalFormattings_.back().rules.back().operator_ = L"greaterThan"; impl_->conditionalFormattings_.back().rules.back().operator_ = L"greaterThan";
val = converter.convert_named_expr( f.substr(1) ); val = converter.convert_named_expr( f.substr(1) );
} }
else if (0 <= (pos = f.find(L"contains-text")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
impl_->conditionalFormattings_.back().rules.back().text = f.substr(15, f.length() - 17);
val.clear();
}
else if (0 <= (pos = f.find(L"between"))) else if (0 <= (pos = f.find(L"between")))
{ {
impl_->conditionalFormattings_.back().rules.back().operator_ = L"between"; impl_->conditionalFormattings_.back().rules.back().operator_ = L"between";
...@@ -353,8 +368,7 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f) ...@@ -353,8 +368,7 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
if (!val.empty()) if (!val.empty())
impl_->conditionalFormattings_.back().rules.back().formula = val; impl_->conditionalFormattings_.back().rules.back().formula = val;
} }
} }
void xlsx_conditionalFormatting_context::set_dataBar(_CP_OPT(int) min, _CP_OPT(int) max) void xlsx_conditionalFormatting_context::set_dataBar(_CP_OPT(int) min, _CP_OPT(int) max)
{ {
......
...@@ -119,6 +119,7 @@ private: ...@@ -119,6 +119,7 @@ private:
std::wstringstream paragraph_; //перманенто скидываемые параграфы std::wstringstream paragraph_; //перманенто скидываемые параграфы
std::wstringstream run_; //перманенто скидываемые куски с быть может разными свойствами std::wstringstream run_; //перманенто скидываемые куски с быть может разными свойствами
std::wstring store_cell_string_;
xlsx_shared_strings xlsx_shared_strings_; xlsx_shared_strings xlsx_shared_strings_;
std::wstring paragraph_style_name_;//был вектор ... не нужен, так как в один момент времени может быть тока один стиль параграфа,текста,объекта при приходе нового - дампится std::wstring paragraph_style_name_;//был вектор ... не нужен, так как в один момент времени может быть тока один стиль параграфа,текста,объекта при приходе нового - дампится
...@@ -427,12 +428,12 @@ std::wstring xlsx_text_context::Impl::dump_paragraph(/*bool last*/) ...@@ -427,12 +428,12 @@ std::wstring xlsx_text_context::Impl::dump_paragraph(/*bool last*/)
std::wstring xlsx_text_context::Impl::dump_run() std::wstring xlsx_text_context::Impl::dump_run()
{ {
const std::wstring content = xml::utils::replace_text_to_xml(text_.str()); const std::wstring content = xml::utils::replace_text_to_xml(text_.str());
if (content.length()<1) if (content.empty())
return L""; return L"";
std::wstring prefix_draw; std::wstring prefix_draw;
if (in_draw) prefix_draw=L"a:"; if (in_draw) prefix_draw = L"a:";
CP_XML_WRITER(run_) CP_XML_WRITER(run_)
{ {
...@@ -445,6 +446,7 @@ std::wstring xlsx_text_context::Impl::dump_run() ...@@ -445,6 +446,7 @@ std::wstring xlsx_text_context::Impl::dump_run()
CP_XML_NODE(prefix_draw + L"t") CP_XML_NODE(prefix_draw + L"t")
{ {
if (!in_draw)CP_XML_ATTR(L"xml:space", L"preserve"); if (!in_draw)CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content; CP_XML_STREAM() << content;
} }
} }
...@@ -452,19 +454,21 @@ std::wstring xlsx_text_context::Impl::dump_run() ...@@ -452,19 +454,21 @@ std::wstring xlsx_text_context::Impl::dump_run()
} }
} }
hyperlink_hId =L"";
return content; return content;
} }
void xlsx_text_context::Impl::start_cell_content() void xlsx_text_context::Impl::start_cell_content()
{ {
paragraphs_cout_ = 0; paragraphs_cout_ = 0;
local_styles_ptr_ =NULL; local_styles_ptr_ = NULL;
run_.str(std::wstring()); run_.str(std::wstring());
paragraph_.str(std::wstring()); paragraph_.str(std::wstring());
text_.str(std::wstring()); text_.str(std::wstring());
store_cell_string_.clear();
hyperlink_hId.clear();
paragraph_style_name_ = L""; paragraph_style_name_ = L"";
span_style_name_ = L""; span_style_name_ = L"";
...@@ -488,6 +492,13 @@ void xlsx_text_context::Impl::start_comment_content() ...@@ -488,6 +492,13 @@ void xlsx_text_context::Impl::start_comment_content()
} }
void xlsx_text_context::Impl::start_drawing_content() void xlsx_text_context::Impl::start_drawing_content()
{ {
if (in_cell_content)
{
dump_run();
store_cell_string_ = run_.str();
}
paragraphs_cout_ = 0; paragraphs_cout_ = 0;
run_.str(std::wstring()); run_.str(std::wstring());
...@@ -539,9 +550,12 @@ int xlsx_text_context::Impl::end_cell_content() ...@@ -539,9 +550,12 @@ int xlsx_text_context::Impl::end_cell_content()
{ {
dump_run(); dump_run();
const int sharedStrId = run_.str().empty() ? (-1) : static_cast<int>(xlsx_shared_strings_.add(run_.str())); std::wstring cell_string = store_cell_string_ + run_.str();
//???? нужно ли здесь очищать все ????? - проверить стили на кучках - и проверить как меняются стили внутри одной ячейки - то есть здешнее переопределение внешнего стиля store_cell_string_.clear();
in_cell_content = false;
in_cell_content = false;
const int sharedStrId = cell_string.empty() ? (-1) : xlsx_shared_strings_.add(cell_string);
return sharedStrId; return sharedStrId;
} }
......
...@@ -220,8 +220,11 @@ static const _shape_converter _OO_OOX_custom_shapes[]= ...@@ -220,8 +220,11 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"concave-star6" ,L"" ,0 ,0 ,0 }, {L"concave-star6" ,L"" ,0 ,0 ,0 },
{L"signet" ,L"" ,0 ,0 ,0 }, {L"signet" ,L"" ,0 ,0 ,0 },
{L"doorplate" ,L"" ,0 ,0 ,0 }, {L"doorplate" ,L"" ,0 ,0 ,0 },
{L"" ,L"round1Rect" ,0 ,0 ,0 },
{L"" ,L"round1Rect" ,0 ,0 ,0 },
{L"" ,L"round2DiagRect" ,0 ,0 ,0 }, {L"" ,L"round2DiagRect" ,0 ,0 ,0 },
{L"" ,L"snip2DiagRect" ,0 ,0 ,0 },
{L"" ,L"round2SameRect" ,0 ,0 ,0 },
{L"" ,L"mathPlus" ,0 ,0 ,0 }, {L"" ,L"mathPlus" ,0 ,0 ,0 },
{L"" ,L"mathMinus" ,0 ,0 ,0 }, {L"" ,L"mathMinus" ,0 ,0 ,0 },
{L"" ,L"mathMultiply" ,0 ,0 ,0 }, {L"" ,L"mathMultiply" ,0 ,0 ,0 },
......
...@@ -133,6 +133,9 @@ std::wostream & s::text_to_stream(std::wostream & _Wostream) const ...@@ -133,6 +133,9 @@ std::wostream & s::text_to_stream(std::wostream & _Wostream) const
else else
_Wostream << std::wstring(1, L' '); _Wostream << std::wstring(1, L' ');
if (content_)
_Wostream << *content_;
return _Wostream; return _Wostream;
} }
...@@ -140,7 +143,10 @@ void s::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -140,7 +143,10 @@ void s::add_attributes( const xml::attributes_wc_ptr & Attributes )
{ {
CP_APPLY_ATTR(L"text:c", text_c_); CP_APPLY_ATTR(L"text:c", text_c_);
} }
void s::add_text(const std::wstring & Text)
{
content_ = Text;
}
void s::docx_convert(oox::docx_conversion_context & Context) void s::docx_convert(oox::docx_conversion_context & Context)
{ {
Context.add_element_to_run(); Context.add_element_to_run();
......
...@@ -62,6 +62,8 @@ static formulasconvert::odf2oox_converter formulas_converter; ...@@ -62,6 +62,8 @@ static formulasconvert::odf2oox_converter formulas_converter;
int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Context, text_format_properties_content *text_properties) int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Context, text_format_properties_content *text_properties)
{ {
if (elements_.empty()) return -1;
Context.get_table_context().start_cell_content(); Context.get_table_context().start_cell_content();
Context.get_text_context().set_cell_text_properties(text_properties); Context.get_text_context().set_cell_text_properties(text_properties);
...@@ -136,6 +138,7 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -136,6 +138,7 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
ht = ht_s.str(); ht = ht_s.str();
} }
} }
int row_current = Context.current_table_row() + 1;
bool hidden = table_table_row_attlist_.table_visibility_.get_type() == table_visibility::Collapse; bool hidden = table_table_row_attlist_.table_visibility_.get_type() == table_visibility::Collapse;
......
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