смерженные ячейки ..

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55113 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
Elen.Subbotina
2014-03-25 09:38:37 +00:00
committed by Alexander Trofimov
parent f2de90455b
commit e730cab53b
5 changed files with 75 additions and 34 deletions

View File

@ -164,6 +164,23 @@ void parsing_ref (const std::wstring & ref, int & col,int & row)
}
void ods_conversion_context::add_merge_cells(std::wstring & ref)
{
std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (ref_cells.size() !=2) return;//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .. <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
int start_col = -1, start_row = -1;
int end_col = -1, end_row = -1;
parsing_ref (ref_cells[0], start_col, start_row);
parsing_ref (ref_cells[1], end_col, end_row);
current_table().set_merge_cells(start_col,start_row, end_col, end_row);
}
void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
{
int col=0, row=0;
@ -226,6 +243,7 @@ void ods_conversion_context::end_rows()
start_row(current_table().current_row()+1,1024,0,true);
end_row();
}
void ods_conversion_context::add_column(int start_column, int repeated, int level, bool _default)
{
if (start_column > current_table().current_column()+1)

View File

@ -30,6 +30,8 @@ public:
void end_cell(){}
void end_rows();
void add_merge_cells(std::wstring & ref);
ods_table_context ods_table_context_;
office_spreadsheet* current_spreadsheet_;

View File

@ -329,6 +329,39 @@ void ods_table_state::set_cell_type(int type)
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
}
}
void ods_table_state::set_merge_cells(int start_col, int start_row, int end_col, int end_row)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//todooo
if (end_col - start_col < 0)return;
if (end_row - start_row < 0)return;
int spanned_cols = end_col - start_col + 1;
int spanned_rows = end_row - start_row + 1;
if (spanned_cols > 10000)spanned_cols = 1024;
for (int i = 0; i < cells_.size(); i++)
{
if (cells_[i].row > end_row) break;
if (/*cells_[i].row <= end_row && */cells_[i].row >= start_row)
{
if (/*(cells_[i].col <= end_col || cells_[i].col + cells_[i].repeated-1 <= end_col)
&&*/ (cells_[i].col >= start_col/* || cells_[i].col + cells_[i].repeated-1 >= start_col*/))
{
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_[i].elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned_rows;
break;
}
}
}
}
void ods_table_state::set_cell_value(std::wstring & value)
{
@ -382,9 +415,6 @@ void ods_table_state::set_cell_value(std::wstring & value)
//table_table_cell* cell = dynamic_cast<text_p*>(text_elm.get());
//end_paragraph();
//end_text();
}
void ods_table_state::set_cell_ref (std::wstring & ref, int col, int row)
@ -405,6 +435,12 @@ void ods_table_state::add_default_cell(office_element_ptr & elm, int repeated)
table_table_cell* cell = dynamic_cast<table_table_cell*>(elm.get());
if (cell == NULL)return;
ods_cell_state state;
state.elm = elm; state.repeated = repeated; /*state.style_name = style_name;*//* state.style_elm = style_elm;*/
state.row=current_table_row_; state.col =current_table_column_;
cells_.push_back(state);
current_table_column_+=repeated;
cell->table_table_cell_attlist_.table_number_columns_repeated_ = repeated;

View File

@ -64,7 +64,6 @@ public:
//void set_row_collapsed(bool Val);
void set_row_optimal_height(bool val);
void set_row_height(double height);
//void set_table_row_group(int count, bool collapsed, int level);
void set_row_default_cell_style(std::wstring & style_name);
@ -76,6 +75,7 @@ public:
void set_cell_format_value(int format);
void set_cell_type(int type);
void set_cell_value(std::wstring & value);
void set_merge_cells(int start_col, int start_row, int end_col, int end_row);
// void start_covered_cell();
// void end_covered_cell();
@ -83,13 +83,9 @@ public:
office_element_ptr & current_row_element();
office_element_ptr & current_cell_element();
// void set_current_cell_style_id(unsigned int xfId);
// int get_current_cell_style_id();
int current_column() const;
int current_row() const;
//unsigned int current_row_level(unsigned int Column) const;
//
// xlsx_table_metrics & get_table_metrics() { return xlsx_table_metrics_; }
// xlsx_drawing_context & get_drawing_context() { return xlsx_drawing_context_; }
@ -104,54 +100,35 @@ public:
//void serialize_table_format(std::wostream & _Wostream);
//void serialize_merge_cells(std::wostream & _Wostream);
// void serialize_hyperlinks(std::wostream & _Wostream);
// void dump_rels_hyperlinks(rels & Rels);
//struct _group_row
//{
// bool enabled;
// int count;
// int level;
// bool collapsed;
//}group_row_;
private:
ods_conversion_context & context_;
office_element_ptr office_table_;
//office_element_ptr current_level_;
style* office_table_style_;//??? <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> office_element_ptr ???
//std::wstring table_style_;
//std::wstring tableName_;
// std::wstring table_row_style_;
// std::vector<std::wstring> column_default_cell_style_name_;
std::wstring row_default_cell_style_name_;
// std::wstring cell_style_;
int current_table_column_;
int current_table_row_;
int current_column_level_;
// unsigned int columns_spanned_num_;
// std::wstring columns_spanned_style_;
// std::vector<xlsx_row_spanned> rows_spanned_;
std::vector<ods_element_state> columns_;
std::vector<ods_element_state> rows_;
std::vector<office_element_ptr> current_level_;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::vector<ods_cell_state> cells_;
//unsigned int columns_count_;
// xlsx_merge_cells merge_cells_;
// xlsx_table_metrics xlsx_table_metrics_;
// xlsx_drawing_context xlsx_drawing_context_;
// xlsx_merge_cells merge_cells_;
// xlsx_table_metrics xlsx_table_metrics_;
// xlsx_drawing_context xlsx_drawing_context_;
// xlsx_comments_context xlsx_comments_context_;
// xlsx_hyperlinks xlsx_hyperlinks_;
//bool empty_row_;
// double table_column_last_width_;
// xlsx_hyperlinks xlsx_hyperlinks_;
};

View File

@ -114,7 +114,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert(oox_sheet->m_oSheetData->m_arrItems[row]);
}
ods_context->end_rows();
//<2F><><EFBFBD><EFBFBD><EFBFBD>
for (long mrg = 0 ; oox_sheet->m_oMergeCells.IsInit() && mrg < oox_sheet->m_oMergeCells->m_arrItems.GetSize(); mrg++)
{
if (oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.IsInit())
ods_context->add_merge_cells(string2std_string(oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.get()));
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row)
{
int row_number = oox_row->m_oR.IsInit() ? oox_row->m_oR->GetValue() : -1;