mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
fix bug #71976
This commit is contained in:
@ -201,6 +201,7 @@ void ods_conversion_context::start_row(int _start_row, int repeated, int level,
|
||||
|
||||
add_default_row(repeated_default);
|
||||
}
|
||||
if (in_rows_) level += 1;
|
||||
//-------------------------------------------------------------------------------------------
|
||||
while (level < current_table()->current_level())
|
||||
{
|
||||
@ -209,7 +210,7 @@ void ods_conversion_context::start_row(int _start_row, int repeated, int level,
|
||||
while (level > current_table()->current_level())
|
||||
{
|
||||
office_element_ptr row_group_elm;
|
||||
create_element(L"table", L"table-row-group",row_group_elm,this);
|
||||
create_element(L"table", L"table-row-group", row_group_elm, this);
|
||||
current_table()->start_group(row_group_elm);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
@ -264,14 +265,12 @@ void ods_conversion_context::start_row(int _start_row, int repeated, int level,
|
||||
else
|
||||
row_properties->style_table_row_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Auto);
|
||||
}
|
||||
header_row_ = false;
|
||||
in_header_row_ = false;
|
||||
if (_start_row == 1 && (false == current_table()->table_parts().empty()) && (false == current_table()->table_parts().back().columns.empty()))
|
||||
{
|
||||
header_row_ = true;
|
||||
in_header_row_ = true;
|
||||
repeated = 1;
|
||||
}
|
||||
if (header_row_)
|
||||
{
|
||||
|
||||
office_element_ptr row_headers_elm;
|
||||
create_element(L"table", L"table-header-rows", row_headers_elm, this);
|
||||
current_table()->start_headers(row_headers_elm);
|
||||
@ -296,9 +295,16 @@ void ods_conversion_context::end_row()
|
||||
|
||||
current_table()->add_default_cell(repeated);
|
||||
}
|
||||
if (header_row_)
|
||||
if (in_header_row_)
|
||||
{
|
||||
in_header_row_ = false;
|
||||
current_table()->end_headers();
|
||||
|
||||
office_element_ptr rows_elm;
|
||||
create_element(L"table", L"table-rows", rows_elm, this);
|
||||
current_table()->start_rows(rows_elm);
|
||||
|
||||
in_rows_ = true;
|
||||
}
|
||||
}
|
||||
//////////////////////
|
||||
@ -557,10 +563,16 @@ void ods_conversion_context::add_default_row(int repeated)
|
||||
void ods_conversion_context::end_rows()
|
||||
{
|
||||
//add default last row
|
||||
int repeated = (std::max)(current_table()->dimension_row, 64) - current_table()->current_row();
|
||||
int repeated = (std::max)(current_table()->dimension_row, 64) - current_table()->current_row();
|
||||
if (repeated < 0) repeated = 1;
|
||||
|
||||
add_default_row(repeated);
|
||||
|
||||
if (in_rows_)
|
||||
{
|
||||
in_rows_ = false;
|
||||
current_table()->end_rows();
|
||||
}
|
||||
}
|
||||
void ods_conversion_context::add_column(int start_column, int repeated, int level, bool _default)
|
||||
{
|
||||
@ -628,10 +640,21 @@ void ods_conversion_context::add_column(int start_column, int repeated, int leve
|
||||
else
|
||||
column_properties->attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Auto);
|
||||
}
|
||||
|
||||
office_element_ptr column_elm;
|
||||
create_element(L"table", L"table-column", column_elm, this);
|
||||
|
||||
|
||||
if (start_column == 1 && (false == current_table()->table_parts().empty()) && (false == current_table()->table_parts().back().columns.empty()))
|
||||
{
|
||||
office_element_ptr column_headers_elm;
|
||||
create_element(L"table", L"table-header-columns", column_headers_elm, this);
|
||||
|
||||
current_table()->start_headers(column_headers_elm);
|
||||
current_table()->add_column(column_elm, 1, style_elm);
|
||||
current_table()->end_headers();
|
||||
|
||||
repeated -= 1;
|
||||
}
|
||||
|
||||
current_table()->add_column(column_elm, repeated, style_elm);
|
||||
|
||||
if (_default)
|
||||
|
||||
@ -139,7 +139,9 @@ private:
|
||||
ods_table_context table_context_;
|
||||
office_spreadsheet* root_spreadsheet_;
|
||||
bool repeat_at_lasts_ = true;
|
||||
bool header_row_ = false;
|
||||
|
||||
bool in_header_row_ = false;
|
||||
bool in_rows_ = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -586,9 +586,9 @@ void ods_table_context::start_table(office_element_ptr & elm)
|
||||
|
||||
std::wstring style_name_new = L"ta" + boost::lexical_cast<std::wstring>(table_state_list_.size());
|
||||
|
||||
office_element_ptr & style = context_.styles_context()->add_or_find(style_name_new, style_family::Table, true);
|
||||
office_element_ptr& style = context_.styles_context()->add_or_find(style_name_new, style_family::Table, true);
|
||||
style->create_child_element(L"style", L"table-properties");
|
||||
|
||||
|
||||
state()->set_table_style(style);
|
||||
state()->set_table_hidden(false);
|
||||
|
||||
|
||||
@ -320,7 +320,7 @@ void ods_table_state::set_table_style(office_element_ptr & elm)
|
||||
{
|
||||
office_table_style_ = dynamic_cast<style*>(elm.get());
|
||||
|
||||
if (!office_table_style_)return;
|
||||
if (!office_table_style_) return;
|
||||
|
||||
table_table* table = dynamic_cast<table_table*>(office_table_.get());
|
||||
if (table == NULL)return;
|
||||
@ -333,11 +333,19 @@ void ods_table_state::start_group(office_element_ptr & elm)
|
||||
current_level_.back()->add_child_element(elm);
|
||||
current_level_.push_back(elm);
|
||||
}
|
||||
|
||||
void ods_table_state::end_group()
|
||||
{
|
||||
current_level_.pop_back();
|
||||
}
|
||||
void ods_table_state::start_rows(office_element_ptr& elm)
|
||||
{
|
||||
current_level_.back()->add_child_element(elm);
|
||||
current_level_.push_back(elm);
|
||||
}
|
||||
void ods_table_state::end_rows()
|
||||
{
|
||||
current_level_.pop_back();
|
||||
}
|
||||
void ods_table_state::start_headers(office_element_ptr & elm)
|
||||
{
|
||||
current_level_.back()->add_child_element(elm);
|
||||
@ -355,32 +363,31 @@ void ods_table_state::add_row_break(_INT32 val)
|
||||
{
|
||||
row_breaks_.push_back(val + 1);
|
||||
}
|
||||
void ods_table_state::add_column(office_element_ptr & elm, _UINT32 repeated,office_element_ptr & style_elm)
|
||||
void ods_table_state::add_column(office_element_ptr & elm, _UINT32 repeated, office_element_ptr & style_elm)
|
||||
{
|
||||
current_level_.back()->add_child_element(elm);
|
||||
|
||||
std::wstring style_name;
|
||||
|
||||
odf_writer::style* style = dynamic_cast<odf_writer::style*>(style_elm.get());
|
||||
if (style)style_name = style->style_name_;
|
||||
if (style) style_name = style->style_name_;
|
||||
|
||||
ods_column_state state(elm, repeated, style_name, style_elm, defaut_column_width_, current_level_.size());
|
||||
|
||||
ods_column_state state(elm, repeated, style_name, style_elm, defaut_column_width_, current_level_.size());
|
||||
|
||||
//if (repeated > 10000) repeated = 1024;//????
|
||||
|
||||
current_table_column_ += repeated;
|
||||
columns_.push_back(state);
|
||||
columns_.push_back(state);
|
||||
|
||||
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
|
||||
if (column == NULL)return;
|
||||
if (column == NULL) return;
|
||||
|
||||
if (false == style_name.empty()) column->attlist_.table_style_name_ = style_name;
|
||||
column->attlist_.table_number_columns_repeated_ = repeated;
|
||||
|
||||
}
|
||||
void ods_table_state::set_column_default_cell_style(std::wstring & style_name)
|
||||
{
|
||||
if (style_name.length() < 1)return;
|
||||
if (style_name.empty()) return;
|
||||
|
||||
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
|
||||
if (column == NULL)return;
|
||||
@ -471,25 +478,24 @@ void ods_table_state::add_row(office_element_ptr & elm, _UINT32 repeated, office
|
||||
std::wstring style_name;
|
||||
|
||||
odf_writer::style* style = dynamic_cast<odf_writer::style*>(style_elm.get());
|
||||
if (style)style_name = style->style_name_;
|
||||
if (style) style_name = style->style_name_;
|
||||
|
||||
ods_row_state state(elm, repeated, style_name, style_elm, defaut_row_height_, current_level_.size());
|
||||
|
||||
rows_.push_back(state);
|
||||
|
||||
table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
|
||||
if (row == NULL)return;
|
||||
if (row == NULL) return;
|
||||
|
||||
if (false == style_name.empty()) row->attlist_.table_style_name_ = style_name;
|
||||
row->attlist_.table_number_rows_repeated_ = repeated;
|
||||
|
||||
row_default_cell_style_name_ = L"";
|
||||
|
||||
}
|
||||
void ods_table_state::add_row_repeated()
|
||||
{
|
||||
table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
|
||||
if (row == NULL)return;
|
||||
if (row == NULL) return;
|
||||
|
||||
_UINT32 t = rows_.back().repeated;
|
||||
rows_.back().repeated++;
|
||||
@ -666,27 +672,29 @@ ods_hyperlink_state & ods_table_state::current_hyperlink()
|
||||
void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr & style_elm)
|
||||
{
|
||||
current_row_element()->add_child_element(elm);
|
||||
|
||||
|
||||
std::wstring style_name;
|
||||
|
||||
table_table_cell* cell = dynamic_cast<table_table_cell*>(elm.get());
|
||||
table_covered_table_cell* covered_cell = dynamic_cast<table_covered_table_cell*>(elm.get());
|
||||
|
||||
odf_writer::style* style = dynamic_cast<odf_writer::style*>(style_elm.get());
|
||||
if (style) style_name = style->style_name_;
|
||||
else style_name = row_default_cell_style_name_;
|
||||
|
||||
table_table_cell* cell = dynamic_cast<table_table_cell*>(elm.get());
|
||||
if (cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
|
||||
if (cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
|
||||
{
|
||||
cell->attlist_.table_style_name_ = style_name;
|
||||
cell->attlist_.table_style_name_ = style_name;
|
||||
}
|
||||
table_covered_table_cell* covered_cell = dynamic_cast<table_covered_table_cell*>(elm.get());
|
||||
if (covered_cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
|
||||
if (covered_cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
|
||||
{
|
||||
covered_cell->attlist_.table_style_name_ = style_name;
|
||||
covered_cell->attlist_.table_style_name_ = style_name;
|
||||
}
|
||||
|
||||
ods_cell_state state;
|
||||
|
||||
state.empty = true;
|
||||
state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm;
|
||||
state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_name.empty() ? office_element_ptr() : style_elm;
|
||||
state.row = current_table_row_; state.col = current_table_column_ + 1;
|
||||
|
||||
data_validation_state::_ref ref;
|
||||
|
||||
@ -355,6 +355,9 @@ public:
|
||||
void start_group(office_element_ptr & elm);
|
||||
void end_group();
|
||||
|
||||
void start_rows(office_element_ptr& elm);
|
||||
void end_rows();
|
||||
|
||||
_INT32 current_level() {return (_INT32)current_level_.size() - 1;}
|
||||
|
||||
void start_headers(office_element_ptr & elm);
|
||||
@ -521,6 +524,7 @@ public:
|
||||
std::vector<ods_comment_state> comments_;
|
||||
|
||||
std::map<std::wstring, office_element_ptr> mapHeaderFooterImages;
|
||||
|
||||
private:
|
||||
|
||||
struct _spanned_info
|
||||
@ -542,7 +546,7 @@ private:
|
||||
odf_conversion_context *context_;
|
||||
|
||||
office_element_ptr office_table_;
|
||||
style* office_table_style_;//??? может хранить как office_element_ptr ???
|
||||
style* office_table_style_ = NULL;//??? может хранить как office_element_ptr ???
|
||||
office_element_ptr table_defined_expressions_;
|
||||
|
||||
std::wstring row_default_cell_style_name_;
|
||||
|
||||
@ -692,7 +692,7 @@ void table_table_rows::serialize(std::wostream & strm)
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(strm);
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user