mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
.
This commit is contained in:
@ -58,11 +58,11 @@ namespace cpdoccore {
|
||||
|
||||
namespace odf_writer {
|
||||
|
||||
int ods_table_state::current_table_column_ = 0;
|
||||
int ods_table_state::current_table_row_ = 0;
|
||||
_INT32 ods_table_state::current_table_column_ = 0;
|
||||
_INT32 ods_table_state::current_table_row_ = 0;
|
||||
|
||||
int ods_table_state::tmp_column_ =0;
|
||||
int ods_table_state::tmp_row_ =0;
|
||||
_INT32 ods_table_state::tmp_column_ =0;
|
||||
_INT32 ods_table_state::tmp_row_ =0;
|
||||
|
||||
namespace utils//////////////////////////////////////////// ОБЩАЯ хрень .. вытащить что ли в utils ???
|
||||
|
||||
@ -347,15 +347,15 @@ void ods_table_state::end_headers()
|
||||
{
|
||||
current_level_.pop_back();
|
||||
}
|
||||
void ods_table_state::add_column_break(int val)
|
||||
void ods_table_state::add_column_break(_INT32 val)
|
||||
{
|
||||
column_breaks_.push_back(val + 1);
|
||||
}
|
||||
void ods_table_state::add_row_break(int val)
|
||||
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, unsigned int 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);
|
||||
|
||||
@ -364,7 +364,7 @@ void ods_table_state::add_column(office_element_ptr & elm, unsigned int repeated
|
||||
odf_writer::style* style = dynamic_cast<odf_writer::style*>(style_elm.get());
|
||||
if (style)style_name = style->style_name_;
|
||||
|
||||
ods_element_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;//????
|
||||
|
||||
@ -389,13 +389,13 @@ void ods_table_state::set_column_default_cell_style(std::wstring & style_name)
|
||||
|
||||
columns_.back().cell_style_name = style_name;
|
||||
}
|
||||
std::wstring ods_table_state::get_column_default_cell_style(int column)
|
||||
std::wstring ods_table_state::get_column_default_cell_style(_INT32 column)
|
||||
{
|
||||
int curr=0;
|
||||
_INT32 curr = 0;
|
||||
|
||||
for (size_t i=0; i < columns_.size(); i++)
|
||||
{
|
||||
if (curr + (int)columns_[i].repeated < column + 1)continue;
|
||||
if (curr + (_INT32)columns_[i].repeated < column + 1) continue;
|
||||
else
|
||||
{
|
||||
return columns_[i].cell_style_name;
|
||||
@ -443,7 +443,7 @@ void ods_table_state::set_column_hidden(bool val)
|
||||
|
||||
column->attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
|
||||
}
|
||||
void ods_table_state::set_table_dimension(int col, int row)
|
||||
void ods_table_state::set_table_dimension(_INT32 col, _INT32 row)
|
||||
{
|
||||
if (col < 1 || row < 1 ) return;
|
||||
|
||||
@ -451,7 +451,7 @@ void ods_table_state::set_table_dimension(int col, int row)
|
||||
if (dimension_row < row) dimension_row = row + 1;
|
||||
}
|
||||
|
||||
void ods_table_state::add_row(office_element_ptr & elm, unsigned int repeated, office_element_ptr & style_elm)
|
||||
void ods_table_state::add_row(office_element_ptr & elm, _UINT32 repeated, office_element_ptr & style_elm)
|
||||
{
|
||||
current_table_column_ = 0;
|
||||
current_table_row_ += repeated;
|
||||
@ -466,7 +466,6 @@ void ods_table_state::add_row(office_element_ptr & elm, unsigned int repeated, o
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
current_level_.back()->add_child_element(elm);
|
||||
|
||||
std::wstring style_name;
|
||||
@ -474,7 +473,7 @@ void ods_table_state::add_row(office_element_ptr & elm, unsigned int repeated, o
|
||||
odf_writer::style* style = dynamic_cast<odf_writer::style*>(style_elm.get());
|
||||
if (style)style_name = style->style_name_;
|
||||
|
||||
ods_element_state state(elm, repeated, style_name, style_elm, defaut_row_height_ , current_level_.size());
|
||||
ods_row_state state(elm, repeated, style_name, style_elm, defaut_row_height_, current_level_.size());
|
||||
|
||||
rows_.push_back(state);
|
||||
|
||||
@ -492,7 +491,7 @@ void ods_table_state::add_row_repeated()
|
||||
table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
|
||||
if (row == NULL)return;
|
||||
|
||||
unsigned int t = rows_.back().repeated;
|
||||
_UINT32 t = rows_.back().repeated;
|
||||
rows_.back().repeated++;
|
||||
current_table_row_++;
|
||||
|
||||
@ -551,31 +550,31 @@ bool ods_table_state::is_cell_comment()
|
||||
bool ods_table_state::is_cell_data_validation()
|
||||
{
|
||||
if (cells_.empty()) return false;
|
||||
return cells_.back().data_validation_name.empty() ? true : false;
|
||||
return cells_.back().data_validation_idx >= 0 ? true : false;
|
||||
}
|
||||
int ods_table_state::is_cell_hyperlink(int col, int row)
|
||||
_INT32 ods_table_state::is_cell_hyperlink(_INT32 col, _INT32 row)
|
||||
{
|
||||
for (size_t i = 0; i < hyperlinks_.size(); i++)
|
||||
{
|
||||
if (hyperlinks_[i].col == col && hyperlinks_[i].row == row)
|
||||
{
|
||||
return (int)i;
|
||||
return (_INT32)i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
std::wstring ods_table_state::is_cell_data_validation(int col, int row, unsigned int repeate_col, data_validation_state::_ref & ref)
|
||||
_INT32 ods_table_state::is_cell_data_validation(_INT32 col, _INT32 row, _UINT32 repeate_col, data_validation_state::_ref & ref)
|
||||
{
|
||||
for (size_t i = 0; i < data_validations_.size(); i++)
|
||||
{
|
||||
if (data_validations_[i].in_ref(col, row, repeate_col, ref))
|
||||
{
|
||||
return data_validations_[i].name;
|
||||
return (_INT32)i;
|
||||
}
|
||||
}
|
||||
return L"";
|
||||
return -1;
|
||||
}
|
||||
int ods_table_state::is_row_validation(int row, int & repeate_row)
|
||||
_INT32 ods_table_state::is_row_validation(_INT32 row, _INT32 & repeate_row)
|
||||
{
|
||||
for (size_t i = 0; i < data_validations_.size(); i++)
|
||||
{
|
||||
@ -590,18 +589,18 @@ int ods_table_state::is_row_validation(int row, int & repeate_row)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int ods_table_state::is_cell_comment(int col, int row, unsigned int repeate_col)
|
||||
_INT32 ods_table_state::is_cell_comment(_INT32 col, _INT32 row, _UINT32 repeate_col)
|
||||
{
|
||||
for (size_t i = 0; i < comments_.size(); i++)
|
||||
{
|
||||
if ((comments_[i].col < col + (int)repeate_col && comments_[i].col >= col) && comments_[i].row == row && comments_[i].used == false)
|
||||
if ((comments_[i].col < col + (_INT32)repeate_col && comments_[i].col >= col) && comments_[i].row == row && comments_[i].used == false)
|
||||
{
|
||||
return (int)i;
|
||||
return (_INT32)i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int ods_table_state::is_row_comment(int row, int repeate_row)
|
||||
_INT32 ods_table_state::is_row_comment(_INT32 row, _INT32 repeate_row)
|
||||
{
|
||||
for (size_t i = 0; i < comments_.size(); i++)
|
||||
{
|
||||
@ -612,18 +611,18 @@ int ods_table_state::is_row_comment(int row, int repeate_row)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int ods_table_state::current_column() const
|
||||
_INT32 ods_table_state::current_column() const
|
||||
{
|
||||
return current_table_column_;
|
||||
}
|
||||
|
||||
|
||||
int ods_table_state::current_row() const
|
||||
_INT32 ods_table_state::current_row() const
|
||||
{
|
||||
return current_table_row_;
|
||||
}
|
||||
|
||||
unsigned int ods_table_state::get_last_row_repeated ()
|
||||
_UINT32 ods_table_state::get_last_row_repeated ()
|
||||
{
|
||||
return rows_.empty() ? 1 : rows_.back().repeated;
|
||||
}
|
||||
@ -691,11 +690,10 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
|
||||
state.row = current_table_row_; state.col = current_table_column_ + 1;
|
||||
|
||||
data_validation_state::_ref ref;
|
||||
std::wstring validation_name = is_cell_data_validation(state.col, state.row, 1, ref);
|
||||
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, state.row);
|
||||
state.comment_idx = is_cell_comment(state.col, state.row);
|
||||
state.data_validation_name = validation_name;
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, state.row);
|
||||
state.comment_idx = is_cell_comment(state.col, state.row);
|
||||
state.data_validation_idx = is_cell_data_validation(state.col, state.row, 1, ref);
|
||||
|
||||
current_table_column_ += state.repeated;
|
||||
cells_.push_back(state);
|
||||
@ -760,7 +758,7 @@ void ods_table_state::add_definded_expression(office_element_ptr & elm)
|
||||
if (!table_defined_expressions_)return;
|
||||
table_defined_expressions_->add_child_element(elm);
|
||||
}
|
||||
void ods_table_state::add_hyperlink(const std::wstring & ref,int col, int row, const std::wstring & link, const std::wstring & location)
|
||||
void ods_table_state::add_hyperlink(const std::wstring & ref, _INT32 col, _INT32 row, const std::wstring & link, const std::wstring & location)
|
||||
{
|
||||
ods_hyperlink_state state;
|
||||
state.row = row; state.col = col; state.ref = ref;
|
||||
@ -779,7 +777,7 @@ void ods_table_state::add_hyperlink(const std::wstring & ref,int col, int row, c
|
||||
|
||||
hyperlinks_.push_back(state);
|
||||
}
|
||||
void ods_table_state::start_comment(int col, int row, std::wstring & author)
|
||||
void ods_table_state::start_comment(_INT32 col, _INT32 row, std::wstring & author)
|
||||
{
|
||||
ods_comment_state state;
|
||||
|
||||
@ -787,7 +785,7 @@ void ods_table_state::start_comment(int col, int row, std::wstring & author)
|
||||
create_element(L"office", L"annotation", state.elm, context_);
|
||||
|
||||
office_annotation * annotation = dynamic_cast<office_annotation*>(state.elm.get());
|
||||
if (!annotation)return;
|
||||
if (!annotation) return;
|
||||
|
||||
context_->styles_context()->create_style(L"", style_family::Graphic, true, false, -1);
|
||||
|
||||
@ -859,15 +857,15 @@ void ods_table_state::end_comment(odf_text_context *text_context)
|
||||
|
||||
void ods_table_state::check_spanned_cells()
|
||||
{
|
||||
for (std::map<int, std::map<int, _spanned_info>>::iterator it = map_merged_cells.begin(); it != map_merged_cells.end(); ++it)
|
||||
for (std::map<_INT32, std::map<_INT32, _spanned_info>>::iterator it = map_merged_cells.begin(); it != map_merged_cells.end(); ++it)
|
||||
{
|
||||
for (std::map<int, _spanned_info>::iterator jt = it->second.begin(); jt != it->second.end(); ++jt)
|
||||
for (std::map<_INT32, _spanned_info>::iterator jt = it->second.begin(); jt != it->second.end(); ++jt)
|
||||
{
|
||||
int start_row = it->first;
|
||||
int end_row = it->first + jt->second.spanned_rows;
|
||||
_INT32 start_row = it->first;
|
||||
_INT32 end_row = it->first + jt->second.spanned_rows;
|
||||
|
||||
int start_col = jt->first;
|
||||
int end_col = jt->first + jt->second.spanned_cols;
|
||||
_INT32 start_col = jt->first;
|
||||
_INT32 end_col = jt->first + jt->second.spanned_cols;
|
||||
|
||||
for (size_t i = 0; i < cells_.size(); ++i) //todooo cells_ vector -> map by row
|
||||
{
|
||||
@ -891,7 +889,7 @@ void ods_table_state::check_spanned_cells()
|
||||
}
|
||||
}
|
||||
|
||||
void ods_table_state::set_merge_cells(int start_col, int start_row, int end_col, int end_row)
|
||||
void ods_table_state::set_merge_cells(_INT32 start_col, _INT32 start_row, _INT32 end_col, _INT32 end_row)
|
||||
{
|
||||
if (end_col - start_col < 0) return;
|
||||
if (end_row - start_row < 0) return;
|
||||
@ -903,18 +901,18 @@ void ods_table_state::set_merge_cells(int start_col, int start_row, int end_col,
|
||||
|
||||
//if (info.spanned_cols > 10000) info.spanned_cols = 1024;
|
||||
|
||||
std::map<int, std::map<int, _spanned_info>>::iterator pFindRow = map_merged_cells.find(start_row);
|
||||
std::map<_INT32, std::map<_INT32, _spanned_info>>::iterator pFindRow = map_merged_cells.find(start_row);
|
||||
|
||||
if (pFindRow == map_merged_cells.end())
|
||||
{
|
||||
std::map<int, _spanned_info> mapCols;
|
||||
std::map<_INT32, _spanned_info> mapCols;
|
||||
mapCols.insert(std::make_pair(start_col, info));
|
||||
|
||||
map_merged_cells.insert(std::make_pair(start_row, mapCols));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<int, _spanned_info>::iterator pFindCol = pFindRow->second.find(start_col);
|
||||
std::map<_INT32, _spanned_info>::iterator pFindCol = pFindRow->second.find(start_col);
|
||||
if (pFindCol == pFindRow->second.end())
|
||||
{
|
||||
pFindRow->second.insert(std::make_pair(start_col, info));
|
||||
@ -923,15 +921,15 @@ void ods_table_state::set_merge_cells(int start_col, int start_row, int end_col,
|
||||
//else нереально pFindCol->second.insert(info);
|
||||
}
|
||||
}
|
||||
bool ods_table_state::isSpannedCell(int col, int row, int &spanned_cols, int &spanned_rows )
|
||||
bool ods_table_state::isSpannedCell(_INT32 col, _INT32 row, _INT32&spanned_cols, _INT32&spanned_rows )
|
||||
{
|
||||
spanned_cols = spanned_rows = 0;
|
||||
|
||||
std::map<int, std::map<int, _spanned_info>>::iterator pFindRow = map_merged_cells.find(row);
|
||||
std::map<_INT32, std::map<_INT32, _spanned_info>>::iterator pFindRow = map_merged_cells.find(row);
|
||||
|
||||
if (pFindRow != map_merged_cells.end())
|
||||
{
|
||||
std::map<int, _spanned_info>::iterator pFindCol = pFindRow->second.find(col);
|
||||
std::map<_INT32, _spanned_info>::iterator pFindCol = pFindRow->second.find(col);
|
||||
if (pFindCol != pFindRow->second.end())
|
||||
{
|
||||
spanned_cols = pFindCol->second.spanned_cols;
|
||||
@ -961,7 +959,7 @@ bool ods_table_state::isSpannedCell(int col, int row, int &spanned_cols, int &sp
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool ods_table_state::isCoveredCell( int col, int repeated_cols)
|
||||
bool ods_table_state::isCoveredCell(_INT32 col, _INT32 repeated_cols)
|
||||
{
|
||||
if (current_covered_cols_ > 0) return true;
|
||||
|
||||
@ -976,7 +974,7 @@ bool ods_table_state::isCoveredCell( int col, int repeated_cols)
|
||||
|
||||
return false;
|
||||
}
|
||||
void ods_table_state::set_cell_spanned(int spanned_cols, int spanned_rows)
|
||||
void ods_table_state::set_cell_spanned(_INT32 spanned_cols, _INT32 spanned_rows)
|
||||
{
|
||||
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
|
||||
if (cell == NULL)return;
|
||||
@ -1068,10 +1066,10 @@ std::wstring ods_table_state::replace_cell_row(boost::wsmatch const & what)
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring ref_formula = what[1].str();
|
||||
int col_formula=0, row_formula=0;
|
||||
_INT32 col_formula = 0, row_formula = 0;
|
||||
utils::parsing_ref(ref_formula, col_formula, row_formula);col_formula--;//инче отсчет с 1
|
||||
|
||||
ref_formula = utils::getColAddress(col_formula) + std::to_wstring(row_formula +current_table_row_ - tmp_row_);
|
||||
ref_formula = utils::getColAddress(col_formula) + std::to_wstring(row_formula + current_table_row_ - tmp_row_);
|
||||
|
||||
|
||||
return ref_formula;
|
||||
@ -1088,10 +1086,10 @@ std::wstring ods_table_state::replace_cell_column(boost::wsmatch const & what)
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring ref_formula = what[1].str();
|
||||
int col_formula=0, row_formula=0;
|
||||
_INT32 col_formula = 0, row_formula =0;
|
||||
utils::parsing_ref(ref_formula, col_formula, row_formula);col_formula--;
|
||||
|
||||
ref_formula = utils::getColAddress(col_formula+current_table_column_ -tmp_column_)+boost::lexical_cast<std::wstring>(row_formula);
|
||||
ref_formula = utils::getColAddress(col_formula+current_table_column_ - tmp_column_)+boost::lexical_cast<std::wstring>(row_formula);
|
||||
|
||||
return ref_formula;
|
||||
}
|
||||
@ -1103,7 +1101,7 @@ std::wstring ods_table_state::replace_cell_column(boost::wsmatch const & what)
|
||||
return L"";
|
||||
}
|
||||
|
||||
void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, std::wstring ref, int ind)
|
||||
void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, std::wstring ref, _INT32 ind)
|
||||
{
|
||||
if (ind < 0)return;
|
||||
|
||||
@ -1122,22 +1120,22 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
|
||||
boost::algorithm::split(distance, ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
|
||||
if (distance.size() > 1)
|
||||
{
|
||||
int col1, row1, col2, row2;
|
||||
_INT32 col1, row1, col2, row2;
|
||||
utils::parsing_ref(distance[0], col1, row1);
|
||||
utils::parsing_ref(distance[1], col2, row2);
|
||||
|
||||
if (row2 - row1 > 0) moving_type = 2;
|
||||
if (col2 - col1 > 0)moving_type = 1;
|
||||
if (col2 - col1 > 0) moving_type = 1;
|
||||
}
|
||||
ods_shared_formula_state state = {(unsigned int)ind, odf_formula,ref, current_table_column_,current_table_row_, moving_type};
|
||||
shared_formulas_.insert(std::make_pair((unsigned int)ind, state));
|
||||
ods_shared_formula_state state = {(_UINT32)ind, odf_formula,ref, current_table_column_,current_table_row_, moving_type};
|
||||
shared_formulas_.insert(std::make_pair((_UINT32)ind, state));
|
||||
|
||||
cell->attlist_.table_formula_ = odf_formula;
|
||||
cells_.back().empty = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<unsigned int, ods_shared_formula_state>::iterator pFind = shared_formulas_.find(ind);
|
||||
std::map<_UINT32, ods_shared_formula_state>::iterator pFind = shared_formulas_.find(ind);
|
||||
|
||||
if (pFind != shared_formulas_.end())
|
||||
{
|
||||
@ -1182,13 +1180,13 @@ void ods_table_state::set_cell_array_formula(std::wstring & formula, std::wstrin
|
||||
std::vector<std::wstring> ref_cells;
|
||||
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
|
||||
|
||||
int row_span = 0;
|
||||
int col_span = 0;
|
||||
_INT32 row_span = 0;
|
||||
_INT32 col_span = 0;
|
||||
|
||||
if (ref_cells.size() ==2)
|
||||
{
|
||||
int col1 = -1, row1 = -1;
|
||||
int col2 = -1, row2 = -1;
|
||||
_INT32 col1 = -1, row1 = -1;
|
||||
_INT32 col2 = -1, row2 = -1;
|
||||
|
||||
utils::parsing_ref (ref_cells[0], col1, row1);
|
||||
utils::parsing_ref (ref_cells[1], col2, row2);
|
||||
@ -1226,7 +1224,7 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x,
|
||||
|
||||
for (i = 0; i < columns_.size(); i++)
|
||||
{
|
||||
if (oox_pos.col >(int)(columns_[i].repeated + curr_col))
|
||||
if (oox_pos.col >(_INT32)(columns_[i].repeated + curr_col))
|
||||
{
|
||||
sz_col += (columns_[i].repeated ) * columns_[i].size;
|
||||
}
|
||||
@ -1239,7 +1237,7 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x,
|
||||
curr_col += columns_[i].repeated;
|
||||
}
|
||||
|
||||
if ((int)curr_col < oox_pos.col && false == columns_.empty())
|
||||
if ((_INT32)curr_col < oox_pos.col && false == columns_.empty())
|
||||
{
|
||||
sz_col += (oox_pos.col - curr_col) * columns_[columns_.size() - 1].size;
|
||||
}
|
||||
@ -1251,7 +1249,7 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x,
|
||||
size_t curr_row =0 ;
|
||||
for (i = 0; i < rows_.size(); i++)
|
||||
{
|
||||
if (oox_pos.row >(int)(rows_[i].repeated + curr_row))
|
||||
if (oox_pos.row >(_INT32)(rows_[i].repeated + curr_row))
|
||||
{
|
||||
sz_row += (rows_[i].repeated ) * rows_[i].size;
|
||||
}
|
||||
@ -1265,7 +1263,7 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x,
|
||||
curr_row += rows_[i].repeated;
|
||||
}
|
||||
|
||||
if ((int)curr_row < oox_pos.row && false == rows_.empty())
|
||||
if ((_INT32)curr_row < oox_pos.row && false == rows_.empty())
|
||||
{
|
||||
sz_row += (oox_pos.row - curr_row ) * rows_[rows_.size() - 1].size;
|
||||
}
|
||||
@ -1485,10 +1483,11 @@ void ods_table_state::end_cell()
|
||||
cells_.back().elm->add_child_element(comm_elm);
|
||||
comments_[cells_.back().comment_idx].used = true;
|
||||
}
|
||||
if (false == cells_.back().data_validation_name.empty())
|
||||
if (cells_.back().data_validation_idx >= 0)
|
||||
{
|
||||
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
|
||||
if (cell)cell->attlist_.table_content_validation_name_ = cells_.back().data_validation_name;
|
||||
if (cell)
|
||||
cell->attlist_.table_content_validation_name_ = data_validations_[cells_.back().data_validation_idx].name;
|
||||
}
|
||||
if (cells_.back().empty)
|
||||
{
|
||||
@ -1501,15 +1500,15 @@ void ods_table_state::end_cell()
|
||||
}
|
||||
}
|
||||
|
||||
void ods_table_state::add_default_cell( int repeated)
|
||||
void ods_table_state::add_default_cell(_INT32 repeated)
|
||||
{
|
||||
if (repeated < 1) return;
|
||||
|
||||
int comment_idx = is_cell_comment(current_table_column_ + 1, current_table_row_, repeated);
|
||||
_INT32 comment_idx = is_cell_comment(current_table_column_ + 1, current_table_row_, repeated);
|
||||
if (comment_idx >= 0 && repeated > 1)
|
||||
{
|
||||
//делим на 3 - до, с комметом, после;
|
||||
int c = current_table_column_;
|
||||
_INT32 c = current_table_column_;
|
||||
|
||||
add_default_cell(comments_[comment_idx].col - c - 1);
|
||||
add_default_cell(1);
|
||||
@ -1518,19 +1517,19 @@ void ods_table_state::add_default_cell( int repeated)
|
||||
return;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------
|
||||
std::map<int, std::map<int, _spanned_info>>::iterator pFindRow = map_merged_cells.find(current_table_row_);
|
||||
std::map<_INT32, std::map<_INT32, _spanned_info>>::iterator pFindRow = map_merged_cells.find(current_table_row_);
|
||||
|
||||
bool bSpanned = false;
|
||||
if (pFindRow != map_merged_cells.end())
|
||||
{
|
||||
for (std::map<int, _spanned_info>::iterator it = pFindRow->second.begin(); !bSpanned && it != pFindRow->second.end(); ++it)
|
||||
for (std::map<_INT32, _spanned_info>::iterator it = pFindRow->second.begin(); !bSpanned && it != pFindRow->second.end(); ++it)
|
||||
{
|
||||
if (it->first < current_table_column_ + repeated + 1 && it->first >= current_table_column_ + 1)
|
||||
{
|
||||
if (repeated > 1)
|
||||
{
|
||||
//делим на 3 - до, с spanned, после;
|
||||
int c = current_table_column_;
|
||||
_INT32 c = current_table_column_;
|
||||
|
||||
add_default_cell(it->first - c - 1);
|
||||
add_default_cell(1);
|
||||
@ -1548,14 +1547,14 @@ void ods_table_state::add_default_cell( int repeated)
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------
|
||||
data_validation_state::_ref ref;
|
||||
std::wstring validation_name = is_cell_data_validation(current_table_column_ + 1, current_table_row_, repeated, ref);
|
||||
_INT32 data_validation_idx = is_cell_data_validation(current_table_column_ + 1, current_table_row_, repeated, ref);
|
||||
|
||||
int repeated_validation = (std::min)(ref.col_end, current_table_column_ + (int)repeated) - (std::max)(ref.col_start, current_table_column_ + 1) + 1;
|
||||
_INT32 repeated_validation = (std::min)(ref.col_end, current_table_column_ + (_INT32)repeated) - (std::max)(ref.col_start, current_table_column_ + 1) + 1;
|
||||
|
||||
if (false == validation_name.empty() && repeated > 1 && repeated_validation != repeated)
|
||||
if (data_validation_idx >= 0 && repeated > 1 && repeated_validation != repeated)
|
||||
{
|
||||
//делим на 3 - до, с validation, после;
|
||||
int c = current_table_column_;
|
||||
_INT32 c = current_table_column_;
|
||||
|
||||
add_default_cell(ref.col_start - c - 1);
|
||||
add_default_cell(repeated_validation);
|
||||
@ -1578,8 +1577,8 @@ void ods_table_state::add_default_cell( int repeated)
|
||||
else if (!( current_table_column_ + repeated < current_covered_rows_[i].start_col ||
|
||||
current_table_column_ > current_covered_rows_[i].start_col + current_covered_rows_[i].count_cols))
|
||||
{
|
||||
int c = current_table_column_;
|
||||
int split = current_covered_rows_[i].start_col > current_table_column_ ? current_covered_rows_[i].start_col :
|
||||
_INT32 c = current_table_column_;
|
||||
_INT32 split = current_covered_rows_[i].start_col > current_table_column_ ? current_covered_rows_[i].start_col :
|
||||
current_covered_rows_[i].start_col + current_covered_rows_[i].count_cols;
|
||||
|
||||
if (split != current_table_column_ && split != current_table_column_ + repeated)
|
||||
@ -1609,7 +1608,7 @@ void ods_table_state::add_default_cell( int repeated)
|
||||
|
||||
if (bSpanned)
|
||||
{
|
||||
int spanned_rows = 0, spanned_cols = 0;
|
||||
_INT32 spanned_rows = 0, spanned_cols = 0;
|
||||
if (cell && isSpannedCell(current_table_column_, current_table_row_, spanned_cols, spanned_rows))
|
||||
{
|
||||
cell->attlist_extra_.table_number_columns_spanned_ = spanned_cols;
|
||||
@ -1625,9 +1624,9 @@ void ods_table_state::add_default_cell( int repeated)
|
||||
state.row = current_table_row_;
|
||||
state.col = current_table_column_ + 1;
|
||||
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, current_table_row_);
|
||||
state.data_validation_name = validation_name;
|
||||
state.comment_idx = comment_idx;
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, current_table_row_);
|
||||
state.data_validation_idx = data_validation_idx;
|
||||
state.comment_idx = comment_idx;
|
||||
|
||||
cells_.push_back(state);
|
||||
|
||||
|
||||
@ -52,9 +52,9 @@ namespace cpdoccore {
|
||||
|
||||
struct oox_table_position
|
||||
{
|
||||
int col;
|
||||
_INT32 col;
|
||||
double col_off;
|
||||
int row;
|
||||
_INT32 row;
|
||||
double row_off;
|
||||
};
|
||||
|
||||
@ -88,7 +88,7 @@ namespace utils
|
||||
else
|
||||
return std::wstring(1, (wchar_t)(L'A' + col));
|
||||
}
|
||||
static int getColAddressInv(const std::wstring & a_)
|
||||
static _INT32 getColAddressInv(const std::wstring & a_)
|
||||
{
|
||||
std::wstring a = a_;
|
||||
XmlUtils::GetUpper(a);
|
||||
@ -109,11 +109,11 @@ namespace utils
|
||||
}
|
||||
return res;
|
||||
}
|
||||
static int getRowAdderssInv(const std::wstring & a_)
|
||||
static _INT32 getRowAdderssInv(const std::wstring & a_)
|
||||
{
|
||||
if (!a_.empty())
|
||||
{
|
||||
return boost::lexical_cast<int>(a_) - 1;
|
||||
return boost::lexical_cast<_INT32>(a_) - 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
@ -138,7 +138,7 @@ namespace utils
|
||||
std::reverse(col.begin(), col.end());
|
||||
std::reverse(row.begin(), row.end());
|
||||
}
|
||||
static void parsing_ref (std::wstring ref, int & col, int & row)
|
||||
static void parsing_ref (std::wstring ref, _INT32& col, _INT32& row)
|
||||
{
|
||||
if (std::wstring::npos != ref.find(L" "))
|
||||
return;
|
||||
@ -170,32 +170,43 @@ namespace utils
|
||||
struct ods_element_state
|
||||
{
|
||||
ods_element_state(){}
|
||||
ods_element_state(office_element_ptr &elm_, unsigned int repeated_, const std::wstring &style_name_, office_element_ptr &style_elm_, double size_, size_t level_)
|
||||
: elm(elm_), repeated(repeated_), style_name(style_name_), style_elm(style_elm_), size(size_), level(level_)
|
||||
ods_element_state(office_element_ptr &elm_, _UINT32 repeated_, const std::wstring &style_name_, office_element_ptr &style_elm_, size_t level_)
|
||||
: elm(elm_), repeated(repeated_), style_name(style_name_), style_elm(style_elm_), level(level_)
|
||||
{}
|
||||
|
||||
office_element_ptr elm;
|
||||
|
||||
unsigned int repeated = 1;
|
||||
_UINT32 repeated = 1;
|
||||
std::wstring style_name;
|
||||
office_element_ptr style_elm;
|
||||
|
||||
double size = 0;
|
||||
|
||||
size_t level = 1;
|
||||
|
||||
_UINT32 level = 1;
|
||||
};
|
||||
struct ods_column_state : ods_element_state
|
||||
{
|
||||
ods_column_state(office_element_ptr& elm_, _UINT32 repeated_, const std::wstring& style_name_, office_element_ptr& style_elm_, double size_, size_t level_)
|
||||
{
|
||||
elm = elm_;
|
||||
repeated = repeated_;
|
||||
style_name = style_name_;
|
||||
style_elm = style_elm_;
|
||||
size = size_;
|
||||
level = level_;
|
||||
}
|
||||
double size = 0;
|
||||
std::wstring cell_style_name;
|
||||
};
|
||||
typedef ods_column_state ods_row_state;
|
||||
|
||||
struct ods_cell_state : ods_element_state
|
||||
{
|
||||
int col = -1;
|
||||
int row = -1;
|
||||
_INT32 col = -1;
|
||||
_INT32 row = -1;
|
||||
|
||||
int hyperlink_idx = -1;
|
||||
int comment_idx = -1;
|
||||
_INT32 hyperlink_idx = -1;
|
||||
_INT32 comment_idx = -1;
|
||||
|
||||
std::wstring data_validation_name;
|
||||
_INT32 data_validation_idx = -1;
|
||||
|
||||
bool empty = true;
|
||||
};
|
||||
@ -203,16 +214,16 @@ struct ods_cell_state : ods_element_state
|
||||
struct ods_hyperlink_state
|
||||
{
|
||||
std::wstring ref;
|
||||
int col = -1;
|
||||
int row = -1;
|
||||
_INT32 col = -1;
|
||||
_INT32 row = -1;
|
||||
|
||||
std::wstring link;
|
||||
bool bLocation = false;
|
||||
};
|
||||
struct ods_comment_state
|
||||
{
|
||||
int col = -1;
|
||||
int row = -1;
|
||||
_INT32 col = -1;
|
||||
_INT32 row = -1;
|
||||
std::wstring author;
|
||||
|
||||
office_element_ptr elm;
|
||||
@ -223,12 +234,12 @@ struct ods_comment_state
|
||||
};
|
||||
struct ods_shared_formula_state
|
||||
{
|
||||
unsigned int index;
|
||||
_UINT32 index;
|
||||
std::wstring formula;
|
||||
std::wstring ref;
|
||||
|
||||
int base_column;
|
||||
int base_row;
|
||||
_INT32 base_column;
|
||||
_INT32 base_row;
|
||||
|
||||
int moving_type; //1 - col, 2 - row
|
||||
};
|
||||
@ -243,13 +254,13 @@ struct table_part_state
|
||||
std::wstring name;
|
||||
std::wstring ref;
|
||||
|
||||
int col_start = 0;
|
||||
int row_start = 0;
|
||||
_INT32 col_start = 0;
|
||||
_INT32 row_start = 0;
|
||||
|
||||
int col_end = 0;
|
||||
int row_end = 0;
|
||||
_INT32 col_end = 0;
|
||||
_INT32 row_end = 0;
|
||||
|
||||
bool in_ref(int col, int row)
|
||||
bool in_ref(_INT32 col, _INT32 row)
|
||||
{
|
||||
return (col >= col_start && col <= col_end && row >= row_start && row <= row_end);
|
||||
}
|
||||
@ -267,34 +278,34 @@ struct data_validation_state
|
||||
struct _ref
|
||||
{
|
||||
std::wstring ref;
|
||||
int col_start = 0;
|
||||
int row_start = 0;
|
||||
_INT32 col_start = 0;
|
||||
_INT32 row_start = 0;
|
||||
|
||||
int col_end = 0;
|
||||
int row_end = 0;
|
||||
_INT32 col_end = 0;
|
||||
_INT32 row_end = 0;
|
||||
};
|
||||
std::vector<_ref> refs;
|
||||
|
||||
std::wstring condition;
|
||||
|
||||
bool in_ref(int col, int row, unsigned int repeate_col, _ref & ref)
|
||||
bool in_ref(_INT32 col, _INT32 row, _UINT32 repeate_col, _ref & ref)
|
||||
{
|
||||
for (size_t i = 0; i < refs.size(); i++)
|
||||
{
|
||||
if (row < refs[i].row_start || row > refs[i].row_end) continue;
|
||||
|
||||
if (col + (int)repeate_col <= refs[i].col_start || col > refs[i].col_end) continue;
|
||||
if (col + (_INT32)repeate_col <= refs[i].col_start || col > refs[i].col_end) continue;
|
||||
|
||||
ref = refs[i];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool in_row(int row, unsigned int repeate_row, _ref & ref)
|
||||
bool in_row(_INT32 row, _UINT32 repeate_row, _ref & ref)
|
||||
{
|
||||
for (size_t i = 0; i < refs.size(); i++)
|
||||
{
|
||||
if (row + (int)repeate_row <= refs[i].row_start || row > refs[i].row_end) continue;
|
||||
if (row + (_INT32)repeate_row <= refs[i].row_start || row > refs[i].row_end) continue;
|
||||
|
||||
ref = refs[i];
|
||||
return true;
|
||||
@ -318,7 +329,7 @@ public:
|
||||
void set_table_master_page(std::wstring name);
|
||||
void set_table_rtl(bool Val);
|
||||
void set_table_tab_color(_CP_OPT(odf_types::color) & _color);
|
||||
void set_table_dimension(int col, int row);
|
||||
void set_table_dimension(_INT32 col, _INT32 row);
|
||||
void set_table_print_ranges(const std::wstring &ranges);
|
||||
|
||||
void set_table_protection(bool Val);
|
||||
@ -329,39 +340,39 @@ public:
|
||||
void set_table_protection_unprotected_cells(bool Val);
|
||||
void set_table_protection_protected_cells(bool Val);
|
||||
|
||||
void add_column(office_element_ptr & elm, unsigned int repeated, office_element_ptr & style);
|
||||
void add_column(office_element_ptr & elm, _UINT32 repeated, office_element_ptr & style);
|
||||
void set_column_width_sym(double width);
|
||||
void set_column_width(double width);
|
||||
void set_column_optimal_width(bool val);
|
||||
void set_column_hidden(bool val);
|
||||
void set_column_default_cell_style(std::wstring & style_name);
|
||||
|
||||
std::wstring get_column_default_cell_style(int column);
|
||||
std::wstring get_column_default_cell_style(_INT32 column);
|
||||
|
||||
void add_row_break(int val);
|
||||
void add_column_break(int val);
|
||||
void add_row_break(_INT32 val);
|
||||
void add_column_break(_INT32 val);
|
||||
|
||||
void start_group(office_element_ptr & elm);
|
||||
void end_group();
|
||||
|
||||
int current_level() {return (int)current_level_.size()-1;}
|
||||
_INT32 current_level() {return (_INT32)current_level_.size() - 1;}
|
||||
|
||||
void start_headers(office_element_ptr & elm);
|
||||
void end_headers();
|
||||
|
||||
void add_row(office_element_ptr & elm, unsigned int repeated , office_element_ptr & style);//const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
|
||||
void add_row(office_element_ptr & elm, _UINT32 repeated , office_element_ptr & style);//const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
|
||||
void set_row_hidden(bool Val);
|
||||
void set_row_optimal_height(bool val);
|
||||
void set_row_height(double height);
|
||||
void set_row_default_cell_style(std::wstring & style_name);
|
||||
void add_row_repeated();
|
||||
|
||||
bool isSpannedCell(int col, int row, int &spanned_cols, int &spanned_rows );
|
||||
bool isCoveredCell(int col, int repeated_cols = 1);
|
||||
bool isSpannedCell(_INT32 col, _INT32 row, _INT32 &spanned_cols, _INT32 &spanned_rows);
|
||||
bool isCoveredCell(_INT32 col, _INT32 repeated_cols = 1);
|
||||
|
||||
void start_cell(office_element_ptr & elm ,office_element_ptr & style);
|
||||
void end_cell();
|
||||
void add_default_cell(int repeated);
|
||||
void add_default_cell(_INT32 repeated);
|
||||
|
||||
void check_spanned_cells();
|
||||
|
||||
@ -371,8 +382,8 @@ public:
|
||||
void set_cell_text(odf_text_context *text_context, bool cash_value = false);
|
||||
void set_cell_formula(std::wstring &formula);
|
||||
void set_cell_array_formula(std::wstring & formula, std::wstring ref);
|
||||
void set_cell_spanned(int spanned_cols, int spanned_rows);
|
||||
void add_or_find_cell_shared_formula(std::wstring & formula, std::wstring ref, int ind);
|
||||
void set_cell_spanned(_INT32 spanned_cols, _INT32 spanned_rows);
|
||||
void add_or_find_cell_shared_formula(std::wstring & formula, std::wstring ref, _INT32 ind);
|
||||
|
||||
void start_cell_text();
|
||||
void end_cell_text();
|
||||
@ -454,17 +465,17 @@ public:
|
||||
void end_sparkline_group();
|
||||
void end_sparkline_groups();
|
||||
///////////////////////////////
|
||||
void add_hyperlink(const std::wstring & ref,int col, int row, const std::wstring & link, const std::wstring & location);
|
||||
void add_hyperlink(const std::wstring & ref, _INT32 col, _INT32 row, const std::wstring & link, const std::wstring & location);
|
||||
|
||||
void add_definded_expression(office_element_ptr & elm);
|
||||
|
||||
void start_comment(int col, int row, std::wstring & author);
|
||||
void start_comment(_INT32 col, _INT32 row, std::wstring & author);
|
||||
void set_comment_rect(double l, double t, double w, double h);
|
||||
void set_comment_visible(bool val);
|
||||
void set_comment_color(const std::wstring & color);
|
||||
void end_comment(odf_text_context *text_context);
|
||||
|
||||
void set_merge_cells(int start_col, int start_row, int end_col, int end_row);
|
||||
void set_merge_cells(_INT32 start_col, _INT32 start_row, _INT32 end_col, _INT32 end_row);
|
||||
|
||||
office_element_ptr & current_row_element();
|
||||
office_element_ptr & current_cell_element();
|
||||
@ -473,13 +484,13 @@ public:
|
||||
bool is_cell_hyperlink();
|
||||
bool is_cell_comment();
|
||||
|
||||
int is_cell_hyperlink(int col, int row);
|
||||
int is_cell_comment(int col, int row, unsigned int repeate_col = 1);
|
||||
int is_row_comment(int row, int repeate_row = 1);
|
||||
int is_row_validation(int row, int & repeate_row);
|
||||
std::wstring is_cell_data_validation(int col, int row, unsigned int repeate_col, data_validation_state::_ref & ref);
|
||||
_INT32 is_cell_hyperlink(_INT32 col, _INT32 row);
|
||||
_INT32 is_cell_comment(_INT32 col, _INT32 row, _UINT32 repeate_col = 1);
|
||||
_INT32 is_row_comment(_INT32 row, _INT32 repeate_row = 1);
|
||||
_INT32 is_row_validation(_INT32 row, _INT32& repeate_row);
|
||||
_INT32 is_cell_data_validation(_INT32 col, _INT32 row, _UINT32 repeate_col, data_validation_state::_ref & ref);
|
||||
|
||||
unsigned int get_last_row_repeated ();
|
||||
_UINT32 get_last_row_repeated ();
|
||||
|
||||
ods_hyperlink_state & current_hyperlink();
|
||||
|
||||
@ -488,18 +499,18 @@ public:
|
||||
return table_parts_;
|
||||
}
|
||||
|
||||
int current_column() const;
|
||||
int current_row() const;
|
||||
_INT32 current_column() const;
|
||||
_INT32 current_row() const;
|
||||
|
||||
int dimension_columns;
|
||||
int dimension_row;
|
||||
_INT32 dimension_columns;
|
||||
_INT32 dimension_row;
|
||||
|
||||
double defaut_column_width_sym_ = 0;
|
||||
double defaut_column_width_;
|
||||
double defaut_row_height_;
|
||||
|
||||
std::vector<int> column_breaks_;
|
||||
std::vector<int> row_breaks_;
|
||||
std::vector<_INT32> column_breaks_;
|
||||
std::vector<_INT32> row_breaks_;
|
||||
|
||||
void convert_position(oox_table_position & oox_pos, double & x, double & y);
|
||||
|
||||
@ -514,19 +525,19 @@ private:
|
||||
|
||||
struct _spanned_info
|
||||
{
|
||||
int spanned_cols = 0;
|
||||
int spanned_rows = 0;
|
||||
int state = 0;
|
||||
_INT32 spanned_cols = 0;
|
||||
_INT32 spanned_rows = 0;
|
||||
_INT32 state = 0;
|
||||
};
|
||||
struct _covered_info
|
||||
{
|
||||
int start_col = 0;
|
||||
int count_cols = 0;
|
||||
_INT32 start_col = 0;
|
||||
_INT32 count_cols = 0;
|
||||
|
||||
int count_rows = 0; // от текущей строки
|
||||
_INT32 count_rows = 0; // от текущей строки
|
||||
};
|
||||
std::vector<_covered_info> current_covered_rows_;
|
||||
int current_covered_cols_;
|
||||
_INT32 current_covered_cols_;
|
||||
|
||||
odf_conversion_context *context_;
|
||||
|
||||
@ -536,24 +547,24 @@ private:
|
||||
|
||||
std::wstring row_default_cell_style_name_;
|
||||
|
||||
static int current_table_column_;
|
||||
static int current_table_row_;
|
||||
static _INT32 current_table_column_;
|
||||
static _INT32 current_table_row_;
|
||||
|
||||
static int tmp_column_;
|
||||
static int tmp_row_;
|
||||
static _INT32 tmp_column_;
|
||||
static _INT32 tmp_row_;
|
||||
|
||||
std::vector<ods_element_state> columns_;
|
||||
std::vector<ods_element_state> rows_;
|
||||
std::vector<ods_column_state> columns_;
|
||||
std::vector<ods_row_state> rows_;
|
||||
|
||||
// row column
|
||||
std::map<int, std::map<int, _spanned_info>> map_merged_cells;
|
||||
std::map<_INT32, std::map<_INT32, _spanned_info>> map_merged_cells;
|
||||
|
||||
std::vector<office_element_ptr> current_level_;//постоянно меняющийся список уровней ("0-й элемент - сама таблица)
|
||||
|
||||
std::vector<ods_cell_state> cells_;
|
||||
|
||||
std::vector<ods_hyperlink_state> hyperlinks_;
|
||||
std::map<unsigned int, ods_shared_formula_state> shared_formulas_;
|
||||
std::map<_UINT32, ods_shared_formula_state> shared_formulas_;
|
||||
|
||||
std::map<std::wstring, std::wstring> mapTabled; // for formula used ... perhaps
|
||||
|
||||
|
||||
Reference in New Issue
Block a user