Commit e0b5cb34 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

разметка таблиц - стили, наследование стилей, пересечения стилей ячеек, колонок, строк.

строки, колонки, ячейки
цыфровые данные ячеек

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55091 954022d7-b5bf-4e40-9824-e11837661b57
parent 437ff29d
......@@ -41,9 +41,25 @@ void odf_style_context::create_style(std::wstring oox_name,const style_family fa
last_state().style_oox_name_ = oox_name;
}
void odf_style_context::create_default(const style_family family)
{
office_element_ptr elm;
create_element(L"style", L"default-style", elm, &context_);
style_state_list_.push_back( odf_style_state(elm, family) );
///////////////////////////////////////
last_state().set_automatic(false);
last_state().set_root(true);
last_state().set_default(true);
}
void odf_style_context::reset_defaults()
{
default_styles_.clear();
}
void odf_style_context::process_automatic_styles(office_element_ptr root )
{//
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i].automatic_== true && style_state_list_[i].root_== true && style_state_list_[i].odf_style_)
......@@ -52,7 +68,6 @@ void odf_style_context::process_automatic_styles(office_element_ptr root )
}
void odf_style_context::process_automatic(office_element_ptr root )
{//
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (long i =0; i < style_state_list_.size(); i++)
{
if (/*it->automatic_== true && */style_state_list_[i].root_== false && style_state_list_[i].odf_style_)
......@@ -61,7 +76,6 @@ void odf_style_context::process_automatic(office_element_ptr root )
}
void odf_style_context::process_master(office_element_ptr root )
{
//for (std::list<odf_style_state>::iterator it = master_state_list_.begin(); it != master_state_list_.end(); it++)
for (long i =0; i < master_state_list_.size(); i++)
{
root->add_child_element(master_state_list_[i].odf_style_);
......@@ -69,7 +83,6 @@ void odf_style_context::process_master(office_element_ptr root )
}
void odf_style_context::process_office(office_element_ptr root )
{
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i].automatic_== false && style_state_list_[i].root_ == true && style_state_list_[i].odf_style_)
......@@ -78,7 +91,6 @@ void odf_style_context::process_office(office_element_ptr root )
}
std::wstring odf_style_context::find_odf_style_name(int oox_id_style, const style_family family)
{
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i].odf_style_)
......@@ -111,7 +123,6 @@ office_element_ptr odf_style_context::find_odf_style(int oox_id_style, const sty
}
bool odf_style_context::find_odf_style_state(int oox_id_style, const style_family family, odf_style_state *& state, bool root)
{
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (int i=0;i<style_state_list_.size(); i++)
{
if (style_state_list_[i].odf_style_)
......@@ -132,7 +143,6 @@ bool odf_style_context::find_odf_style_state(int oox_id_style, const style_famil
}
office_element_ptr odf_style_context::find_odf_style_default(const style_family family)
{
//for (std::list<odf_style_state>::iterator it = default_styles_.begin(); it != default_styles_.end(); it++)
for (int i=0;i<default_styles_.size(); i++)
{
if (default_styles_[i].odf_style_)
......@@ -144,7 +154,6 @@ office_element_ptr odf_style_context::find_odf_style_default(const style_family
}
std::wstring odf_style_context::find_odf_style_name_default(const style_family family)
{
//for (std::list<odf_style_state>::iterator it = default_styles_.begin(); it != default_styles_.end(); it++)
for (int i=0;i<default_styles_.size(); i++)
{
if (default_styles_[i].odf_style_)
......@@ -182,7 +191,6 @@ std::wstring odf_style_context::find_free_name(const style_family & family)
std::wstring name = get_name_family(family);
int count =1;
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (int i=0;i<style_state_list_.size(); i++)
{
if ((style_state_list_[i].odf_style_) && (style_state_list_[i].style_family_ == family))
......@@ -195,7 +203,6 @@ std::wstring odf_style_context::find_free_name(const style_family & family)
}
office_element_ptr & odf_style_context::add_or_find(std::wstring name, const style_family family, bool automatic , bool root, int oox_id)
{
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (int i=0;i<style_state_list_.size(); i++)
{
if (style_state_list_[i].odf_style_)
......
......@@ -22,6 +22,7 @@ public:
odf_style_context(odf_conversion_context & Context/*, ods_text_context & textCotnext*/);
void create_style(std::wstring name, const style_family style_family, bool automatic = false, bool root = false, int oox_id = -1);
void create_default(const style_family style_family);
office_element_ptr & add_or_find(std::wstring name, const style_family family, bool automatic = false, bool root = false, int id = -1);
......@@ -30,7 +31,7 @@ public:
void process_master(office_element_ptr root );
void process_office(office_element_ptr root );
void clear_defaults() {default_styles_.clear();}
void reset_defaults();
void add_default(odf_style_state & state) {default_styles_.push_back(state);}
std::wstring find_odf_style_name (int oox_id_style, const style_family family);
......
......@@ -9,16 +9,27 @@
namespace cpdoccore {
namespace odf {
odf_style_state::odf_style_state(/*odf_conversion_context & Context, */office_element_ptr & elm, const style_family family )/*: context_(Context)*/
odf_style_state::odf_style_state(office_element_ptr & elm, const style_family family )
{
odf_style_ = elm;
automatic_= false;
default_ = false;
num_fmt_id_ =0;
style_family_ = family;
style* style_ = dynamic_cast<style*>(elm.get());
if (!style_)return;
if (style_)
{
style_->style_family_ = style_family_;
}
default_style* default_style_ = dynamic_cast<default_style*>(elm.get());
style_->style_family_ = style_family_ = family;
if (default_style_)
{
default_style_->style_family_ = style_family_;
}
}
office_element_ptr & odf_style_state::get_office_element()
......@@ -53,6 +64,10 @@ void odf_style_state::set_root(bool val)//
{
root_ = val;
}
void odf_style_state::set_default(bool val)
{
default_ = val;
}
void odf_style_state::convert()
{
if (odf_style_== NULL)return;
......
......@@ -26,12 +26,13 @@ class odf_style_context;
class odf_style_state
{
public:
odf_style_state(/*odf_conversion_context & Context, */office_element_ptr & elm, const style_family style_family );
odf_style_state(office_element_ptr & elm, const style_family style_family );
void set_name(std::wstring);
void set_automatic(bool val);
void set_root(bool val);
void set_default(bool val);
std::wstring & get_name();
......@@ -49,16 +50,16 @@ private:
//
int style_oox_id_;
int num_fmt_id_; //default =0 (general)
int num_fmt_id_; //default =0 (general)
///////
bool automatic_;
bool root_;
bool default_; // root
style_family style_family_;
office_element_ptr odf_style_;
//odf_conversion_context & context_;
friend class odf_style_context;
};
......
......@@ -38,7 +38,7 @@ void ods_conversion_context::end_sheet()
{
ods_table_context_.end_table();
styles_context().clear_defaults();
styles_context().reset_defaults();
}
void ods_conversion_context::start_row(int _start_row, int repeated, bool _default)
{
......@@ -73,6 +73,12 @@ void ods_conversion_context::start_row(int _start_row, int repeated, bool _defau
create_element(L"table", L"table-row",row_elm,this);
ods_table_context_.state().add_row(row_elm, repeated, style_elm);
if ( _default)
{
//std::wstring style_cell_name= styles_context().find_odf_style_name_default(odf::style_family::TableCell);
//current_table().set_row_default_cell_style(style_cell_name);
}
}
void ods_conversion_context::end_row()
{
......@@ -195,8 +201,8 @@ void ods_conversion_context::end_columns()
{
//add default last column - (1024 - )
// - ???
if (ods_table_context_.state().columns_count() < 1024)
add_column(ods_table_context_.state().columns_count()+1,1024,true);
if (ods_table_context_.state().current_column() < 1 )
add_column(ods_table_context_.state().current_column()+1,1024,true);
}
void ods_conversion_context::start_rows()
{
......@@ -209,9 +215,9 @@ void ods_conversion_context::end_rows()
}
void ods_conversion_context::add_column(int start_column, int repeated, bool _default)
{
if (start_column > ods_table_context_.state().columns_count()+1)
if (start_column > ods_table_context_.state().current_column()+1)
{
int repeated_default = start_column - ods_table_context_.state().columns_count()-1;
int repeated_default = start_column - ods_table_context_.state().current_column()-1;
add_column(start_column-repeated_default,repeated_default,true);
}
/////////////////////////////////////////////////////////////////
......
......@@ -20,7 +20,7 @@ namespace odf {
ods_table_state::ods_table_state(ods_conversion_context & Context, office_element_ptr & elm): context_(Context)
{
office_table_ = elm;
columns_count_=0;
current_table_row_ =0;
current_table_column_ =0;
}
......@@ -79,7 +79,9 @@ void ods_table_state::add_column(office_element_ptr & elm, int repeated,office_e
ods_element_state state = {elm, repeated,style_name, style_elm};
columns_count_ += repeated;
if (repeated > 10000)repeated = 1024;//????
current_table_column_ += repeated;
columns_.push_back(state);
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
......@@ -121,10 +123,10 @@ void ods_table_state::set_column_optimal_width(bool val)
}
unsigned int ods_table_state::columns_count() const
void ods_table_state::set_table_dimension(std::wstring ref)
{
return columns_count_;
}
void ods_table_state::add_row(office_element_ptr & elm, int repeated,office_element_ptr & style_elm)
{
current_table_column_ = 0;
......@@ -191,11 +193,14 @@ int ods_table_state::current_row() const
void ods_table_state::set_row_default_cell_style(std::wstring & style_name)
{
table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
if (row == NULL)return;
row_default_cell_style_name_= style_name; // default-style (table_cell)!!!
//if (style_name.length() < 1) return;
//table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
//if (row == NULL)return;
row->table_table_row_attlist_.table_default_cell_style_name_ = style_ref(style_name);
row_default_cell_style_name_= style_name;
//row->table_table_row_attlist_.table_default_cell_style_name_ = style_ref(style_name);
}
office_element_ptr & ods_table_state::current_row_element()
......
......@@ -45,6 +45,7 @@ public:
void set_table_style(office_element_ptr & _style);
void set_table_hidden(bool Val);
void set_table_tab_color(_CP_OPT(color) & _color);
void set_table_dimension(std::wstring ref);
void add_column(office_element_ptr & elm, int repeated ,office_element_ptr & style);
void set_column_width(int width);
......@@ -83,7 +84,6 @@ public:
// unsigned int current_columns_spaned() const;
// unsigned int current_rows_spanned(unsigned int Column) const;
unsigned int columns_count() const;
//
// xlsx_table_metrics & get_table_metrics() { return xlsx_table_metrics_; }
// xlsx_drawing_context & get_drawing_context() { return xlsx_drawing_context_; }
......@@ -128,7 +128,7 @@ private:
std::vector<ods_element_state> rows_;
std::vector<ods_cell_state> cells_;
unsigned int columns_count_;
//unsigned int columns_count_;
// xlsx_merge_cells merge_cells_;
// xlsx_table_metrics xlsx_table_metrics_;
// xlsx_drawing_context xlsx_drawing_context_;
......
......@@ -211,7 +211,7 @@ void default_style::serialize(std::wostream & strm)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR(L"style-family", style_family_);
CP_XML_ATTR(L"style:family", style_family_);
style_content_.serialize(CP_XML_STREAM());
}
}
......
......@@ -128,13 +128,18 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row)
if (oox_row->m_oHidden.IsInit()) ods_context->current_table().set_row_hidden(true);
if (oox_row->m_oCollapsed.IsInit()) ods_context->current_table().set_row_hidden(true);
std::wstring style_cell_name;
if (oox_row->m_oS.IsInit() && ( oox_row->m_oCustomFormat.IsInit() && oox_row->m_oCustomFormat->GetValue()==1))
{
int xfd_id = oox_row->m_oS->GetValue();
std::wstring style_cell_name = ods_context->styles_context().find_odf_style_name(xfd_id,odf::style_family::TableCell);
ods_context->current_table().set_row_default_cell_style(style_cell_name );
style_cell_name = ods_context->styles_context().find_odf_style_name(xfd_id,odf::style_family::TableCell);
}else
{
//style_cell_name = ods_context->styles_context().find_odf_style_name_default(odf::style_family::TableCell);
}
ods_context->current_table().set_row_default_cell_style(style_cell_name );
if (oox_row->m_oHt.IsInit() == true)
{
double height = oox_row->m_oHt->GetValue();
......@@ -259,6 +264,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
///Column///////////////////////////////////////////////////////////////////////////////////////
ods_context->styles_context().create_style(L"",odf::style_family::TableColumn, true, false, -1);
{
double width = 8.1; // MS Office 2010
// xlsx () - . oo -
odf::style* style = dynamic_cast<odf::style*>(ods_context->styles_context().last_state().get_office_element().get());
if (style)
{
......@@ -268,38 +275,42 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
column_properties->style_table_column_properties_attlist_.common_break_attlist_.fo_break_before_ = odf::fo_break(odf::fo_break::Auto);
if (oox_sheet_format_pr->m_oDefaultColWidth.IsInit())
{
double width = oox_sheet_format_pr->m_oDefaultColWidth->GetValue();
column_properties->style_table_column_properties_attlist_.style_column_width_ = odf::length(width/4.35,odf::length::cm);
width = oox_sheet_format_pr->m_oDefaultColWidth->GetValue();
}
column_properties->style_table_column_properties_attlist_.style_column_width_ = odf::length(width/4.35,odf::length::cm);
}
}
ods_context->styles_context().add_default(ods_context->styles_context().last_state());
}
//Row default //////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
if (oox_sheet_format_pr->m_oDefaultRowHeight.IsInit())
{
ods_context->styles_context().create_style(L"",odf::style_family::TableRow, true, false, -1);
double height = oox_sheet_format_pr->m_oDefaultRowHeight->GetValue();
odf::style* style = dynamic_cast<odf::style*>(ods_context->styles_context().last_state().get_office_element().get());
if (style)
ods_context->styles_context().create_style(L"",odf::style_family::TableRow, true, false, -1);
odf::style* style = dynamic_cast<odf::style*>(ods_context->styles_context().last_state().get_office_element().get());
if (style)
{
odf::style_table_row_properties * row_properties = style->style_content_.get_style_table_row_properties();
if (row_properties)
{
odf::style_table_row_properties * row_properties = style->style_content_.get_style_table_row_properties();
if (row_properties)
if (oox_sheet_format_pr->m_oDefaultRowHeight.IsInit())
{
row_properties->style_table_row_properties_attlist_.style_row_height_ = odf::length(height,odf::length::pt);
row_properties->style_table_row_properties_attlist_.style_use_optimal_row_height_ = true; //???? c
row_properties->style_table_row_properties_attlist_.common_break_attlist_.fo_break_before_ = odf::fo_break(odf::fo_break::Auto);
double height = oox_sheet_format_pr->m_oDefaultRowHeight->GetValue();
row_properties->style_table_row_properties_attlist_.style_row_height_ = odf::length(height/32.,odf::length::cm);
}
row_properties->style_table_row_properties_attlist_.style_use_optimal_row_height_ = true; //???? c
row_properties->style_table_row_properties_attlist_.common_break_attlist_.fo_break_before_ = odf::fo_break(odf::fo_break::Auto);
}
ods_context->styles_context().add_default(ods_context->styles_context().last_state());
}
ods_context->styles_context().add_default(ods_context->styles_context().last_state());
}
}
void XlsxConverter::convert_styles()
{
if (!ods_context) return;
// add default styles
ods_context->styles_context().create_default(odf::style_family::TableCell);
///////////////////////////////////////////////////////////////////////////////////////////////////
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
if (!xlsx_styles)return;
......@@ -310,7 +321,7 @@ void XlsxConverter::convert_styles()
{
convert(xlsx_styles->m_oCellStyleXfs->m_arrItems[i] , i, false, true);
}
///////////////////////////////////
for (long i=0;i< xlsx_styles->m_oCellXfs->m_oCount->GetValue(); i++)
{
convert(xlsx_styles->m_oCellXfs->m_arrItems[i],i, true,false);
......@@ -588,7 +599,5 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
}
odf::style_table_cell_properties * cell_properties = style->style_content_.get_style_table_cell_properties();
}
} // namespace Docx2Odt
\ No newline at end of file
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