Commit 0b15c314 authored by ElenaSubbotina's avatar ElenaSubbotina

fix bug #35485

parent 44fdbf6d
......@@ -837,7 +837,7 @@ void process_build_object::visit(table_table_rows& val)
}
void process_build_object::visit(const table_table_row & val)
{
unsigned int repeated = val.table_table_row_attlist_.table_number_rows_repeated_;
unsigned int repeated = val.attlist_.table_number_rows_repeated_;
ACCEPT_ALL_CONTENT_CONST(val.content_);
visit_rows(repeated);
}
......@@ -891,13 +891,13 @@ void process_build_object::visit(const table_rows_no_group& val)
}
void process_build_object::visit(const table_table_cell& val)
{
const table_table_cell_attlist & attlist = val.table_table_cell_attlist_;
const table_table_cell_attlist & attlist = val.attlist_;
unsigned int repeated = val.table_table_cell_attlist_.table_number_columns_repeated_;
unsigned int repeated = val.attlist_.table_number_columns_repeated_;
std::wstringstream wstream_temp;
val.table_table_cell_content_.text_to_stream(wstream_temp);
val.content_.text_to_stream(wstream_temp);
std::wstring cell_cash = wstream_temp.str();
std::wstring cell_val;
......@@ -920,7 +920,7 @@ void process_build_object::visit(const table_table_cell& val)
}
void process_build_object::visit(const table_covered_table_cell& val)
{
unsigned int repeated = val.table_table_cell_attlist_.table_number_columns_repeated_;
unsigned int repeated = val.attlist_.table_number_columns_repeated_;
if ( repeated <2)
return;
......
......@@ -376,18 +376,18 @@ const wchar_t * table_table_cell::name = L"table-cell";
std::wostream & table_table_cell::text_to_stream(std::wostream & _Wostream) const
{
return table_table_cell_content_.text_to_stream(_Wostream);
return content_.text_to_stream(_Wostream);
}
void table_table_cell::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
table_table_cell_attlist_.add_attributes(Attributes);
table_table_cell_attlist_extra_.add_attributes(Attributes);
attlist_.add_attributes(Attributes);
attlist_extra_.add_attributes(Attributes);
}
void table_table_cell::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
table_table_cell_content_.add_child_element(Reader, Ns, Name, getContext());
content_.add_child_element(Reader, Ns, Name, getContext());
}
void table_table_cell::add_text(const std::wstring & Text)
......@@ -402,18 +402,18 @@ const wchar_t * table_covered_table_cell::name = L"covered-table-cell";
std::wostream & table_covered_table_cell::text_to_stream(std::wostream & _Wostream) const
{
return table_table_cell_content_.text_to_stream(_Wostream);
return content_.text_to_stream(_Wostream);
}
void table_covered_table_cell::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
table_table_cell_attlist_.add_attributes(Attributes);
attlist_.add_attributes(Attributes);
}
void table_covered_table_cell::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
empty_ = false;
table_table_cell_content_.add_child_element(Reader, Ns, Name, getContext());
content_.add_child_element(Reader, Ns, Name, getContext());
}
void table_covered_table_cell::add_text(const std::wstring & Text)
......@@ -432,7 +432,7 @@ std::wostream & table_table_row::text_to_stream(std::wostream & _Wostream) const
void table_table_row::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
table_table_row_attlist_.add_attributes( Attributes );
attlist_.add_attributes( Attributes );
}
void table_table_row::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
......@@ -519,6 +519,42 @@ void table_rows::add_child_element( xml::sax * Reader, const std::wstring & Ns,
not_applicable_element(L"table-rows", Reader, Ns, Name);
}
}
void table_rows::remove_equals_empty()
{
if (table_table_row_.empty()) return;
while(true)
{
size_t i = table_table_row_.size() - 1;
if (i == 0) break;
if (table_table_row_[i]->get_type() != typeTableTableRow)
break;
if (table_table_row_[i-1]->get_type() != typeTableTableRow)
break;
table_table_row *prev = dynamic_cast<table_table_row*>(table_table_row_[i-1].get());
table_table_row *next = dynamic_cast<table_table_row*>(table_table_row_[i].get());
if (prev->content_.size() > 1 || next->content_.size() > 1) break;
if (prev->attlist_.table_style_name_.get_value_or(L"") != next->attlist_.table_style_name_.get_value_or(L"")) break;
table_table_cell *prev_cell = dynamic_cast<table_table_cell*>(prev->content_[0].get());
table_table_cell *next_cell = dynamic_cast<table_table_cell*>(next->content_[0].get());
if (!prev_cell || !next_cell) break;
if (!prev_cell->content_.elements_.empty() || !next_cell->content_.elements_.empty()) break;
if (prev_cell->attlist_.table_style_name_.get_value_or(L"") != next_cell->attlist_.table_style_name_.get_value_or(L"")) break;
prev->attlist_.table_number_rows_repeated_ += next->attlist_.table_number_rows_repeated_;
table_table_row_.pop_back();
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:rows-no-group
......@@ -561,7 +597,6 @@ void table_rows_no_group::add_child_element( xml::sax * Reader, const std::wstri
else
not_applicable_element(L"table-rows-no-group", Reader, Ns, Name);
}
// table-rows-and-groups
//////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -57,7 +57,6 @@ class table_table_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(bool) table_is_sub_table_;
_CP_OPT(std::wstring) table_name_;
_CP_OPT(std::wstring) table_style_name_;
......@@ -82,7 +81,6 @@ class table_table_row_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_rows_repeated_; // default 1
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_default_cell_style_name_;
......@@ -96,7 +94,6 @@ class table_table_cell_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_content_validation_name_;
......@@ -104,7 +101,6 @@ public:
odf_types::common_value_and_type_attlist common_value_and_type_attlist_;
bool table_protect_; // default false
};
......@@ -115,7 +111,6 @@ class table_table_cell_attlist_extra
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_columns_spanned_; // default 1
unsigned int table_number_rows_spanned_; // default 1
......@@ -130,7 +125,6 @@ class table_table_source_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
odf_types::table_mode table_mode_; // default CopyAll
_CP_OPT(std::wstring) table_table_name_;
......@@ -142,7 +136,6 @@ class table_linked_source_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
odf_types::common_xlink_attlist common_xlink_attlist_;
_CP_OPT(std::wstring) table_filter_name_;
......@@ -182,7 +175,6 @@ public:
void xlsx_convert(oox::xlsx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
office_element_ptr table_table_columns_;
office_element_ptr_array table_table_column_;
......@@ -204,7 +196,6 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
public:
table_columns_no_group();
void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context);
......@@ -214,13 +205,11 @@ public:
static _CP_PTR(table_columns_no_group) create();
public:
table_columns table_columns_1_;
bool was_header_;
office_element_ptr table_table_header_columns_;
table_columns table_columns_2_;
table_columns table_columns_2_;
};
// table:columns-and-groups
......@@ -234,7 +223,6 @@ public:
void xlsx_convert(oox::xlsx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
// office_element_ptr table_table_column_group_;
// table_columns_no_group table_columns_no_group_;
......@@ -248,7 +236,6 @@ class table_table_column_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(std::wstring) table_style_name_;
odf_types::table_visibility table_visibility_; // default Visible
......@@ -340,7 +327,6 @@ class table_table_column_group_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
private:
bool table_display_; // default true
};
......@@ -390,7 +376,6 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
......@@ -398,7 +383,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
table_table_row_attlist table_table_row_attlist_;
table_table_row_attlist attlist_;
office_element_ptr_array content_; // table-table-cell or table-covered-table-cell
};
......@@ -417,8 +402,8 @@ public:
bool pptx_convert(oox::pptx_conversion_context & Context) ;
office_element_ptr_array elements_;
private:
// TODO table-cell-range-source
// TODO table-cell-range-source
// TODO table-detective
};
......@@ -440,7 +425,6 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) ;
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
......@@ -451,9 +435,9 @@ private:
public:
bool last_cell_;
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_attlist_extra table_table_cell_attlist_extra_;
table_table_cell_content table_table_cell_content_;
table_table_cell_attlist attlist_;
table_table_cell_attlist_extra attlist_extra_;
table_table_cell_content content_;
};
......@@ -476,7 +460,6 @@ public:
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
......@@ -489,8 +472,8 @@ public:
bool last_cell_;
bool empty_;
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_content table_table_cell_content_;
table_table_cell_attlist attlist_;
table_table_cell_content content_;
};
......@@ -514,7 +497,6 @@ public:
table_table_rows()
{
}
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
......@@ -543,7 +525,6 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) ;
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
......@@ -569,10 +550,10 @@ public:
void xlsx_convert(oox::xlsx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
office_element_ptr table_table_rows_;
office_element_ptr_array table_table_row_;
void remove_equals_empty();
};
// table:rows-no-group
......@@ -593,8 +574,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
public:
table_rows_no_group();
std::wostream & text_to_stream(std::wostream & _Wostream) const;
void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context);
......@@ -602,7 +583,6 @@ public:
void xlsx_convert(oox::xlsx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
bool was_header_;
table_rows table_rows_1_;
......@@ -617,15 +597,13 @@ class table_rows_and_groups
public:
table_rows_and_groups();
std::wostream & text_to_stream(std::wostream & _Wostream) const;
void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context);
void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context);
void docx_convert(oox::docx_conversion_context & Context);
void xlsx_convert(oox::xlsx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
int get_count(){return content_.size();}//временно .. для группировок
public:
office_element_ptr_array content_;
//int type_;
//office_element_ptr table_table_row_group_;
......
......@@ -67,10 +67,10 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & _Wostream = Context.output_stream();
const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or(L"");
const std::wstring styleName = attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = attlist_.table_default_cell_style_name_.get_value_or(L"");
for (unsigned int i = 0; i < table_table_row_attlist_.table_number_rows_repeated_; ++i)
for (unsigned int i = 0; i < attlist_.table_number_rows_repeated_; ++i)
{
_Wostream << L"<w:tr>";
const style_instance * inst =
......@@ -259,7 +259,7 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & _Wostream = Context.output_stream();
for (unsigned int r = 0; r < table_table_cell_attlist_.table_number_columns_repeated_; ++r)
for (unsigned int r = 0; r < attlist_.table_number_columns_repeated_; ++r)
{
int pushTextPropCount = 0;
......@@ -267,24 +267,24 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
_Wostream << L"<w:tc>";
_Wostream << L"<w:tcPr>";
const std::wstring styleName = table_table_cell_attlist_.table_style_name_.get_value_or(L"");
const std::wstring styleName = attlist_.table_style_name_.get_value_or(L"");
//_Wostream << L"<w:tcW w:w=\"0\" w:type=\"auto\" />";
if (table_table_cell_attlist_extra_.table_number_rows_spanned_ > 1)
if (attlist_extra_.table_number_rows_spanned_ > 1)
{
_Wostream << L"<w:vMerge w:val=\"restart\" />";
Context.get_table_context().set_rows_spanned(Context.get_table_context().current_column(),
table_table_cell_attlist_extra_.table_number_rows_spanned_ - 1,
table_table_cell_attlist_extra_.table_number_columns_spanned_ - 1,
attlist_extra_.table_number_rows_spanned_ - 1,
attlist_extra_.table_number_columns_spanned_ - 1,
styleName
);
}
if (table_table_cell_attlist_extra_.table_number_columns_spanned_ > 1)
if (attlist_extra_.table_number_columns_spanned_ > 1)
{
_Wostream << L"<w:gridSpan w:val=\"" << table_table_cell_attlist_extra_.table_number_columns_spanned_ << "\" />";
Context.get_table_context().set_columns_spanned(table_table_cell_attlist_extra_.table_number_columns_spanned_ - 1);
_Wostream << L"<w:gridSpan w:val=\"" << attlist_extra_.table_number_columns_spanned_ << "\" />";
Context.get_table_context().set_columns_spanned(attlist_extra_.table_number_columns_spanned_ - 1);
}
const style_instance * inst =
......@@ -344,7 +344,7 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
}
// если одержимое не содержит ниодного параграфа, то добавляем параграф, иначе word считает файл битым
if (!table_table_cell_content_.docx_convert(Context))
if (!content_.docx_convert(Context))
{
_Wostream << emptyPar;
}
......@@ -361,11 +361,11 @@ void table_covered_table_cell::docx_convert(oox::docx_conversion_context & Conte
{
std::wostream & _Wostream = Context.output_stream();
for (unsigned int i = 0; i < table_table_cell_attlist_.table_number_columns_repeated_; ++i)
for (unsigned int i = 0; i < attlist_.table_number_columns_repeated_; ++i)
{
if (Context.get_table_context().start_covered_cell(Context))
{
if (!table_table_cell_content_.docx_convert(Context))
if (!content_.docx_convert(Context))
{
_Wostream << emptyPar;
}
......
......@@ -70,10 +70,10 @@ void table_table_row::pptx_convert(oox::pptx_conversion_context & Context)
{
std::wostream & _Wostream = Context.get_table_context().tableData();
const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or(L"");
const std::wstring styleName = attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = attlist_.table_default_cell_style_name_.get_value_or(L"");
for (unsigned int i = 0; i < table_table_row_attlist_.table_number_rows_repeated_; ++i)
for (unsigned int i = 0; i < attlist_.table_number_rows_repeated_; ++i)
{
int height = 0;
......@@ -323,7 +323,7 @@ void table_table_cell::pptx_convert(oox::pptx_conversion_context & Context)
CP_XML_WRITER(_Wostream)
{
for (unsigned int r = 0; r < table_table_cell_attlist_.table_number_columns_repeated_; ++r)
for (unsigned int r = 0; r < attlist_.table_number_columns_repeated_; ++r)
{
Context.get_table_context().start_cell();
CP_XML_NODE(L"a:tc")
......@@ -352,35 +352,35 @@ void table_table_cell::pptx_convert(oox::pptx_conversion_context & Context)
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst);
}
style_name = table_table_cell_attlist_.table_style_name_.get_value_or(L"");
style_name = attlist_.table_style_name_.get_value_or(L"");
if (!style_name.empty())
{
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst);
}
if (table_table_cell_attlist_extra_.table_number_rows_spanned_ > 1)
if (attlist_extra_.table_number_rows_spanned_ > 1)
{
CP_XML_ATTR(L"rowSpan" , table_table_cell_attlist_extra_.table_number_rows_spanned_);
CP_XML_ATTR(L"rowSpan" , attlist_extra_.table_number_rows_spanned_);
CP_XML_ATTR(L"vMerge", 1);
Context.get_table_context().set_rows_spanned(Context.get_table_context().current_column(),
table_table_cell_attlist_extra_.table_number_rows_spanned_ - 1,
table_table_cell_attlist_extra_.table_number_columns_spanned_ - 1,
attlist_extra_.table_number_rows_spanned_ - 1,
attlist_extra_.table_number_columns_spanned_ - 1,
style_name);
}
if (table_table_cell_attlist_extra_.table_number_columns_spanned_ > 1)
if (attlist_extra_.table_number_columns_spanned_ > 1)
{
//CP_XML_ATTR(L"hMerge", true);
CP_XML_ATTR(L"gridSpan" , table_table_cell_attlist_extra_.table_number_columns_spanned_);
CP_XML_ATTR(L"gridSpan" , attlist_extra_.table_number_columns_spanned_);
Context.get_table_context().set_columns_spanned(table_table_cell_attlist_extra_.table_number_columns_spanned_ - 1);
Context.get_table_context().set_columns_spanned(attlist_extra_.table_number_columns_spanned_ - 1);
}
Context.get_text_context().start_object();
bool presentText = table_table_cell_content_.pptx_convert(Context);
bool presentText = content_.pptx_convert(Context);
std::wstring cellContent = Context.get_text_context().end_object();
......@@ -408,11 +408,11 @@ void table_covered_table_cell::pptx_convert(oox::pptx_conversion_context & Conte
{
std::wostream & _Wostream = Context.get_table_context().tableData();
for (unsigned int i = 0; i < table_table_cell_attlist_.table_number_columns_repeated_; ++i)
for (unsigned int i = 0; i < attlist_.table_number_columns_repeated_; ++i)
{
if (Context.get_table_context().start_covered_cell(Context))
{
if (!table_table_cell_content_.pptx_convert(Context))
if (!content_.pptx_convert(Context))
{
_Wostream << emptyParTable;
}
......
This diff is collapsed.
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