Commit af0bf700 authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

OdfFormatReader - правка багов по результатам тестирования

parent ba915264
......@@ -719,7 +719,8 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
CP_XML_WRITER(strm)
{
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_))
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_)
&& !get_table_context().in_table())
{//
CP_XML_NODE(L"w:pPr")
{
......@@ -733,10 +734,12 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
if (!paragraph_style.str().empty() || !ParentId.empty())
{
CP_XML_NODE(L"w:pPr")
{
if ( !get_table_context().in_table() )
{
CP_XML_STREAM() << get_section_context().dump_;
get_section_context().dump_.clear();
}
if (!ParentId.empty())
{
CP_XML_NODE(L"w:pStyle")
......
......@@ -30,6 +30,8 @@ void docx_table_state::start_column(unsigned int repeated, const std::wstring &
std::wstring docx_table_state::get_default_cell_style_col(unsigned int column)
{
if (columnsDefaultCellStyleName_.size() <= column)
return L"";
return columnsDefaultCellStyleName_.at(column);
}
......
......@@ -32,13 +32,12 @@ oox_chart_context_ptr oox_chart_context::create(std::wstring const & name)
{
return boost::make_shared<oox_chart_context>(name);
}
oox_chart_context::oox_chart_context()
: impl_(new oox_chart_context::Impl())
oox_chart_context::oox_chart_context() : impl_(new oox_chart_context::Impl())
{
}
oox_chart_context::oox_chart_context(std::wstring const & name)
: impl_(new oox_chart_context::Impl(name))
oox_chart_context::oox_chart_context(std::wstring const & name) : impl_(new oox_chart_context::Impl(name))
{
}
std::wostream & oox_chart_context::chartData()
{
......@@ -89,6 +88,15 @@ bool oox_chart_context::empty() const
return false;//impl_->empty();
}
void oox_chart_context::set_cache_only (bool val)
{
for (int i = 0 ; i < plot_area_.charts_.size(); i++)
{
plot_area_.charts_[i]->set_cache_only(val);
}
}
}
}
......
......@@ -30,6 +30,7 @@ public:
bool empty() const;
void write_to(std::wostream & strm);
static oox_chart_context_ptr create(std::wstring const & name);
static oox_chart_context_ptr create();
......@@ -83,6 +84,8 @@ public:
plot_area_.properties_ = prop;
plot_area_.fill_ = fill;
}
void set_cache_only (bool val);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
......
......@@ -72,6 +72,11 @@ void oox_chart_series::setFormula(int ind, std::wstring &value)
}
}
void oox_chart_series::set_cache_only (bool val)
{
bLocalTable_ = val;
}
void oox_chart_series::parse_properties()
{
_CP_OPT(int) iSymbolType;
......@@ -100,13 +105,13 @@ void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values)
boost::algorithm::trim(v);
if (ind == 4)
{
values_[ind].strRef_.str_cash.push_back(v);
values_[ind].strRef_.str_cash_count++;
values_[ind].strRef_.str_cache.push_back(v);
values_[ind].strRef_.str_cache_count++;
}
else
{
values_[ind].numRef_.num_cash.push_back(v);
values_[ind].numRef_.num_cash_count++;
values_[ind].numRef_.num_cache.push_back(v);
values_[ind].numRef_.num_cache_count++;
}
}
}
......@@ -136,7 +141,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
{
CP_XML_NODE(values_[i].type)
{
if (values_[i].numRef_.present)
if (values_[i].numRef_.present && !bLocalTable_)
{
CP_XML_NODE(L"c:numRef")
{
......@@ -145,7 +150,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
CP_XML_CONTENT(values_[i].numRef_.formula);
}
if (values_[i].numRef_.num_cash_count>0)
if (values_[i].numRef_.num_cache_count>0)
{
CP_XML_NODE(L"c:numCache")//
{
......@@ -155,10 +160,10 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
}
CP_XML_NODE(L"c:ptCount")
{
CP_XML_ATTR(L"val", values_[i].numRef_.num_cash_count);
CP_XML_ATTR(L"val", values_[i].numRef_.num_cache_count);
}
int j=0;
BOOST_FOREACH(std::wstring & v, values_[i].numRef_.num_cash)
BOOST_FOREACH(std::wstring & v, values_[i].numRef_.num_cache)
{
CP_XML_NODE(L"c:pt")
{
......@@ -177,39 +182,59 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
}
}
}
//if (values_[i].strRef_.present)
//{
// CP_XML_NODE(L"c:strRef")
// {
// CP_XML_NODE(L"c:f")
// {
// CP_XML_CONTENT(values_[i].strRef_.formula);
// }
//
// if (values_[i].strRef_.str_cash_count>0)
// {
// CP_XML_NODE(L"c:strCache")//
// {
// CP_XML_NODE(L"c:ptCount")
// {
// CP_XML_ATTR(L"val", values_[i].strRef_.str_cash_count);
// }
// int j=0;
// BOOST_FOREACH(std::wstring & v, values_[i].strRef_.str_cash)
// {
// CP_XML_NODE(L"c:pt")
// {
// CP_XML_ATTR(L"idx", j++);
// CP_XML_NODE(L"c:v")
// {
// CP_XML_CONTENT(v);
// }
// }
// }
// }
// }
// }
//}
else if (values_[i].numRef_.num_cache_count > 0)
{
CP_XML_NODE(L"c:numLit")
{
CP_XML_NODE(L"c:formatCode")
{
CP_XML_CONTENT(L"General");//????
}
CP_XML_NODE(L"c:ptCount")
{
CP_XML_ATTR(L"val", values_[i].numRef_.num_cache_count);
}
int j=0;
BOOST_FOREACH(std::wstring & v, values_[i].numRef_.num_cache)
{
if (v == L"NaN") continue;
CP_XML_NODE(L"c:pt")
{
CP_XML_ATTR(L"idx", j++);
double val = 0;
try { val = boost::lexical_cast<double>(v);}
catch(...){}
CP_XML_NODE(L"c:v")
{
CP_XML_CONTENT(val);
}
}
}
}
}
else if (values_[i].strRef_.str_cache_count > 0)
{
CP_XML_NODE(L"c:strLit")
{
CP_XML_NODE(L"c:ptCount")
{
CP_XML_ATTR(L"val", values_[i].strRef_.str_cache_count);
}
int j=0;
BOOST_FOREACH(std::wstring & v, values_[i].strRef_.str_cache)
{
CP_XML_NODE(L"c:pt")
{
CP_XML_ATTR(L"idx", j++);
CP_XML_NODE(L"c:v")
{
CP_XML_CONTENT(v);
}
}
}
}
}
}
}
}
......
......@@ -24,7 +24,8 @@ public:
values_[3].type=L"c:bubbleSize";// !!!!
values_[4].type=L"c:cat";//
iSymbolMarkerType_ =0;
iSymbolMarkerType_ = 0;
bLocalTable_ = false;
}
~oox_chart_series(){}
......@@ -43,7 +44,10 @@ public:
void setValues(int ind, std::vector<std::wstring> & values);
void parse_properties();
void set_cache_only (bool val);
int iSymbolMarkerType_;
bool bLocalTable_;
odf_reader::chart::series content_;
......
......@@ -32,8 +32,8 @@ struct _oox_strRef
bool present;
std::wstring formula;
int str_cash_count;
std::vector<std::wstring>str_cash;
int str_cache_count;
std::vector<std::wstring> str_cache;
};
struct _oox_numRef
......@@ -42,8 +42,8 @@ struct _oox_numRef
std::wstring formula;
std::wstring formatCode;
int num_cash_count;
std::vector<std::wstring>num_cash;
int num_cache_count;
std::vector<std::wstring> num_cache;
};
//extLst (Chart Extensibility) 21.2.2.64
......@@ -55,13 +55,12 @@ struct _oox_chart_values
public:
_oox_chart_values()
{
numLit_.present =false;
numRef_.present=false;
numRef_.formatCode = L"General";
numRef_.num_cash_count=0;
numRef_.num_cache_count=0;
strRef_.present=false;
strRef_.str_cash_count=0;
strRef_.str_cache_count=0;
present = false;
}
......@@ -69,7 +68,6 @@ public:
bool present;
std::wstring type;
_oox_numLit numLit_;
_oox_numRef numRef_;
_oox_strRef strRef_;
......
......@@ -10,10 +10,20 @@
namespace cpdoccore {
namespace oox {
void oox_chart::set_cache_only (bool val)
{
for (int i = 0 ; i < series_.size(); i++)
{
series_[i]->set_cache_only(val);
}
}
void oox_chart::set_formula_series(int ind, std::wstring val)
{
oox_series_ptr & current_ptr = series_.back();
current_ptr->setFormula(ind,val);
}
void oox_chart::set_name(std::wstring val)
{
......
......@@ -33,9 +33,10 @@ public:
virtual void add_series(int id){}
void set_formula_series(int ind,std::wstring val);
void set_values_series(int ind, std::vector<std::wstring> & val);
void set_name(std::wstring val);
void set_cache_only (bool val);
void set_formula_series (int ind,std::wstring val);
void set_values_series (int ind, std::vector<std::wstring> & val);
void set_name (std::wstring val);
//void set_showBubbleSize(bool Val){data_labels_.set_showBubbleSize(Val);}
//void set_showCatName(bool Val){data_labels_.set_showCatName(Val);}
......
......@@ -160,6 +160,8 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context)
oox_convert(chart);
chart.set_cache_only(true);
Context.end_chart();
}
else if (object_type_ == 2 && office_text_)
......@@ -197,6 +199,7 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
oox_convert(chart);
chart.set_cache_only(true);
Context.end_chart();
}
else if (object_type_ == 2 && office_text_)
......@@ -208,14 +211,14 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
office_math_->pptx_convert(Context);
}
}
void chart_build::calc_cash_series(std::wstring adress, std::vector<std::wstring> & cash)
void chart_build::calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash)
{
formulasconvert::odf2oox_converter converter;
std::wstring ref_1,ref_2,table;
size_t col_1=0,row_1=0,col_2=0,row_2=0;
std::wstring ref_1, ref_2, table;
size_t col_1=0, row_1=0, col_2=0, row_2=0;
if (!converter.find_first_last_ref(adress,table,ref_1,ref_2))return;
if (!converter.find_first_last_ref(adress, table, ref_1, ref_2))return;
//if ((res = table.find(L"local-table"))<0)return;
oox::getCellAddressInv(ref_1,col_1,row_1);
......@@ -275,13 +278,13 @@ void chart_build::oox_convert(oox::oox_chart_context & chart)
// - = todooo
std::vector<std::wstring> cell_cash;
calc_cash_series(s.cell_range_address_, cell_cash);
calc_cache_series(s.cell_range_address_, cell_cash);
if (domain_cell_range_adress_.length() > 0)
{
std::vector<std::wstring> domain_cash;
calc_cash_series(domain_cell_range_adress_,domain_cash);
calc_cache_series(domain_cell_range_adress_,domain_cash);
if (last_set_type == chart_bubble)
{
......@@ -309,7 +312,7 @@ void chart_build::oox_convert(oox::oox_chart_context & chart)
if (categories_.size() > 0)//
{
std::vector<std::wstring> cat_cash;
calc_cash_series(categories_[0], cat_cash);
calc_cache_series(categories_[0], cat_cash);
current->set_formula_series(4,categories_[0]);
current->set_values_series(4,cat_cash);
......@@ -429,6 +432,11 @@ void process_build_chart::visit(const office_document_content& val)
if (val.office_body_)
val.office_body_->accept(*this);
}
void process_build_chart::visit(office_document_content& val)
{
if (val.office_body_)
val.office_body_->accept(*this);
}
void process_build_chart::visit(office_body& val)
{
if (val.content_)
......
......@@ -109,7 +109,7 @@ public:
void add_point(unsigned int rep, std::wstring const & styleName);
void calc_cash_series(std::wstring adress, std::vector<std::wstring> & cash);
void calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash);
void xlsx_convert(oox::xlsx_conversion_context & Context);
void docx_convert(oox::docx_conversion_context & Context);
......@@ -174,6 +174,7 @@ public:
class process_build_chart : public base_visitor,
public const_visitor<office_document_content>,
public visitor<office_document_content>,
public visitor<office_body>,
public visitor<office_chart>,
......@@ -246,6 +247,7 @@ private:
public:
virtual void visit(const office_document_content& val);
virtual void visit(office_document_content& val);
virtual void visit(office_body & val);
virtual void visit(office_chart & val);
......
......@@ -52,7 +52,7 @@ namespace chart {
std::vector<_property> line_properties_;
simple equation_properties_;
treadline(){bEquation = false;bREquation = false;}
treadline(){bEquation = false; bREquation = false;}
};
struct plot_area : public simple
......
......@@ -99,7 +99,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
Context.get_headers_footers().set_enable_write(true);
if (!Context.get_section_context().dump_.empty())
if (!Context.get_section_context().dump_.empty() && !Context.get_table_context().in_table())
{
Context.output_stream() << Context.get_section_context().dump_;
Context.get_section_context().dump_.clear();
......
......@@ -76,9 +76,14 @@ void style_chart_properties::add_attributes( const xml::attributes_wc_ptr & Attr
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()));
CP_APPLY_ATTR(L"chart:axis-position", strVal);
if (strVal) content_.push_back(_property(L"axis-position", *strVal));
CP_APPLY_ATTR(L"chart:tick-mark-position", strVal);
if (strVal) content_.push_back(_property(L"tick-mark-position", *strVal));
CP_APPLY_ATTR(L"chart:interpolation", strVal);
if (iVal)content_.push_back(_property(L"interpolation", chart_interpolation(chart_interpolation::parse(strVal.get())).get_type()));
if (strVal)content_.push_back(_property(L"interpolation", chart_interpolation(chart_interpolation::parse(strVal.get())).get_type()));
CP_APPLY_ATTR(L"chart:solid-type", strVal);
if (strVal)content_.push_back(_property(L"solid-type", chart_solid_type(chart_solid_type::parse(strVal.get())).get_type()));
......
......@@ -156,15 +156,18 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
const std::wstring id = Context.styles_map_.get( styleInst->name(), styleInst->type() );
std::wostream & _Wostream = Context.output_stream();
_Wostream << L"<w:pPr>";
if ( !Context.get_table_context().in_table())
{
_Wostream << Context.get_section_context().dump_;
Context.get_section_context().dump_.clear();
}
_Wostream << L"<w:pStyle w:val=\"" << id << L"\" />";
Context.docx_serialize_list_properties(_Wostream);
_Wostream << L"</w:pPr>";
return 2;
}
}
else if (!Context.get_section_context().dump_.empty())
else if (!Context.get_section_context().dump_.empty() && !Context.get_table_context().in_table())
{
Context.output_stream() << L"<w:pPr>";
Context.output_stream() << Context.get_section_context().dump_;
......@@ -173,7 +176,7 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
}
return 3;
}
else if (!Context.get_section_context().dump_.empty())
else if (!Context.get_section_context().dump_.empty() && !Context.get_table_context().in_table())
{
Context.output_stream() << L"<w:pPr>";
Context.output_stream() << Context.get_section_context().dump_;
......
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