This commit is contained in:
Elena.Subbotina
2023-10-03 18:22:03 +03:00
parent 45ed2badad
commit 83f280d739
17 changed files with 97 additions and 86 deletions

View File

@ -1650,13 +1650,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
if (oox_column->m_oHidden.IsInit() && oox_column->m_oHidden->ToBool()) width = 0;
if (width <0.01)
if (width < 0.01)
{
width = 0;
ods_context->current_table()->set_column_hidden(true);
}
width = ods_context->convert_symbol_width(width);
ods_context->current_table()->set_column_width_sym(width);
width = ods_context->convert_symbol_width(width);
ods_context->current_table()->set_column_width(width);
std::wstring style_cell_name;
@ -2073,7 +2075,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
odf_writer::style_table_column_properties * column_properties = style->content_.add_get_style_table_column_properties();
if (column_properties)
{
column_properties->style_table_column_properties_attlist_.common_break_attlist_.fo_break_before_ = odf_types::fo_break(odf_types::fo_break::Auto);
column_properties->attlist_.common_break_attlist_.fo_break_before_ = odf_types::fo_break(odf_types::fo_break::Auto);
if (oox_sheet_format_pr->m_oDefaultColWidth.IsInit())
{
width = *oox_sheet_format_pr->m_oDefaultColWidth;
@ -2089,7 +2091,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
width = ods_context->convert_symbol_width(8.43) + 5 * 3 / 4.;
}
ods_context->current_table()->defaut_column_width_ = width;//pt
column_properties->style_table_column_properties_attlist_.style_column_width_ = odf_types::length(odf_types::length(width,odf_types::length::pt).get_value_unit(odf_types::length::cm),odf_types::length::cm);
column_properties->attlist_.style_column_width_ = odf_types::length(odf_types::length(width,odf_types::length::pt).get_value_unit(odf_types::length::cm),odf_types::length::cm);
}
}
ods_context->styles_context()->add_default( ods_context->styles_context()->last_state() );

View File

@ -136,7 +136,7 @@ double odf_conversion_context::convert_symbol_width(double val)
double pixels = (int)(((256. * val + ((int)(128. / font_metrix_.approx_symbol_size))) / 256.) * font_metrix_.approx_symbol_size); //in pixels
return pixels * 0.75; //* 9525. * 72.0 / (360000.0 * 2.54);
return pixels * 0.76; //* 9525. * 72.0 / (360000.0 * 2.54);
}
void odf_conversion_context::set_styles_context(odf_style_context_ptr styles_context)
{

View File

@ -455,10 +455,10 @@ void odf_table_context::set_column_optimal(bool val)
style *style_ = dynamic_cast<style*>(impl_->current_table().columns.back().style_elm.get());
if (style_ == NULL) return;
style_table_column_properties *properties = style_->content_.add_get_style_table_column_properties();
if (properties == NULL) return;
style_table_column_properties * column_properties = style_->content_.add_get_style_table_column_properties();
if (column_properties == NULL) return;
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = val;
column_properties->attlist_.style_use_optimal_column_width_ = val;
}
void odf_table_context::change_current_column_width(double width)
@ -483,18 +483,18 @@ void odf_table_context::change_current_column_width(double width)
style *style_ = dynamic_cast<style*>(impl_->current_table().columns[index].style_elm.get());
if (style_ == NULL) return;
style_table_column_properties *properties = style_->content_.add_get_style_table_column_properties();
if (properties == NULL) return;
style_table_column_properties * column_properties = style_->content_.add_get_style_table_column_properties();
if (column_properties == NULL) return;
length length_ = length(length(width, length::pt).get_value_unit(length::cm), length::cm);
if (!properties->style_table_column_properties_attlist_.style_column_width_)
properties->style_table_column_properties_attlist_.style_column_width_ = length_;
if (!column_properties->attlist_.style_column_width_)
column_properties->attlist_.style_column_width_ = length_;
else
{
double old_width = properties->style_table_column_properties_attlist_.style_column_width_->get_value_unit(length::pt);
double old_width = column_properties->attlist_.style_column_width_->get_value_unit(length::pt);
if (old_width < width/* && width < impl_->odf_context_->page_layout_context()->current_page_width_*/ && old_width < 9)
properties->style_table_column_properties_attlist_.style_column_width_ = length_;
column_properties->attlist_.style_column_width_ = length_;
}
}
@ -504,18 +504,18 @@ void odf_table_context::set_column_width(double width)
if (impl_->current_table().columns.empty())return;
style *style_ = dynamic_cast<style*>(impl_->current_table().columns.back().style_elm.get());
style_table_column_properties *properties = style_ ? style_->content_.add_get_style_table_column_properties() : NULL;
style_table_column_properties * column_properties = style_ ? style_->content_.add_get_style_table_column_properties() : NULL;
if (width > 0)
{
if (properties)
if (column_properties)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
column_properties->attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
//column_properties->attlist_.style_rel_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
if (impl_->optimal_column_width)
{
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
column_properties->attlist_.style_use_optimal_column_width_ = true;
}
}
@ -523,14 +523,14 @@ void odf_table_context::set_column_width(double width)
}
else
{
if (properties)
if (column_properties)
{
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
column_properties->attlist_.style_use_optimal_column_width_ = true;
if (impl_->default_column_width)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(impl_->default_column_width.get(), length::pt).get_value_unit(length::cm), length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(impl_->current_table().table_width,length::pt).get_value_unit(length::cm),length::cm);
column_properties->attlist_.style_column_width_ = length(length(impl_->default_column_width.get(), length::pt).get_value_unit(length::cm), length::cm);
//properties->attlist_.style_rel_column_width_ = length(length(impl_->current_table().table_width,length::pt).get_value_unit(length::cm),length::cm);
}
}
impl_->current_table().table_width += impl_->default_column_width.get_value_or(0);
@ -549,7 +549,7 @@ void odf_table_context::set_row_height(double height)
// style_table_row_properties *properties = style_->content_.get_style_table_row_properties();
// if (properties)
// {
// //properties->style_table_column_properties_attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
// //properties->attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
// }
//}
impl_->current_table().table_height += height;

View File

@ -624,9 +624,9 @@ void ods_conversion_context::add_column(int start_column, int repeated, int leve
if (column_properties == NULL)return; //error ????
if (bBreak)
column_properties->style_table_column_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Page);
column_properties->attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Page);
else
column_properties->style_table_column_properties_attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Auto);
column_properties->attlist_.common_break_attlist_.fo_break_before_ = fo_break(fo_break::Auto);
}
office_element_ptr column_elm;

View File

@ -408,17 +408,27 @@ std::wstring ods_table_state::get_column_default_cell_style(int column)
}
return L"";
}
void ods_table_state::set_column_width_sym(double width)
{
odf_writer::style* style = dynamic_cast<odf_writer::style*>(columns_.back().style_elm.get());
if (!style) return;
style_table_column_properties* column_properties = style->content_.add_get_style_table_column_properties();
if (column_properties == NULL) return; //error ????
column_properties->attlist_.loext_column_width_sym_ = width;
}
void ods_table_state::set_column_width(double width)//pt
{
odf_writer::style* style = dynamic_cast<odf_writer::style*>(columns_.back().style_elm.get());
if (!style)return;
if (!style) return;
style_table_column_properties * column_properties = style->content_.add_get_style_table_column_properties();
if (column_properties == NULL)return; //error ????
columns_.back().size = width; //pt
column_properties->style_table_column_properties_attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
column_properties->attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
}
void ods_table_state::set_column_optimal_width(bool val)
{
@ -428,19 +438,19 @@ void ods_table_state::set_column_optimal_width(bool val)
style_table_column_properties * column_properties = style->content_.add_get_style_table_column_properties();
if (column_properties == NULL)return; //error ????
column_properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = val;
column_properties->attlist_.style_use_optimal_column_width_ = val;
}
void ods_table_state::set_column_hidden(bool val)
{
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
if (column == NULL)return;
if (column == NULL) return;
column->attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
}
void ods_table_state::set_table_dimension(int col, int row)
{
if (col<1 || row <1 )return;
if (col < 1 || row < 1 ) return;
if (dimension_columns < col) dimension_columns = col + 1;
if (dimension_row < row) dimension_row = row + 1;

View File

@ -330,6 +330,7 @@ public:
void set_table_protection_protected_cells(bool Val);
void add_column(office_element_ptr & elm, unsigned int 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);

View File

@ -151,10 +151,11 @@ void style_table_column_properties_attlist::serialize(std::wostream & _Wostream,
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"style:column-width", style_column_width_);
CP_XML_ATTR_OPT(L"style:rel-column-width", style_rel_column_width_);
CP_XML_ATTR_OPT(L"style:use-optimal-column-width", style_use_optimal_column_width_);
CP_XML_ATTR_OPT(L"style:column-width", style_column_width_);
CP_XML_ATTR_OPT(L"style:rel-column-width", style_rel_column_width_);
CP_XML_ATTR_OPT(L"style:use-optimal-column-width", style_use_optimal_column_width_);
CP_XML_ATTR_OPT(L"loext:column-width-sym", loext_column_width_sym_);
common_break_attlist_.serialize(CP_GET_XML_NODE());
}
}
@ -170,7 +171,7 @@ void style_table_column_properties::create_child_element( const std::wstring &
}
void style_table_column_properties::serialize(std::wostream & strm)
{
style_table_column_properties_attlist_.serialize(strm,ns,name);
attlist_.serialize(strm,ns,name);
}
//////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -83,7 +83,6 @@ public:
odf_types::common_keep_with_next_attlist common_keep_with_next_attlist_;
odf_types::common_writing_mode_attlist common_writing_mode_attlist_;
odf_types::common_border_attlist common_border_attlist_;
office_element_ptr style_background_image_;
_CP_OPT(odf_types::Bool) style_use_optimal_column_width_;
@ -91,16 +90,13 @@ public:
};
// style:table-properties
class style_table_properties : public office_element_impl<style_table_properties>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeStyleTableProperties;
static const ElementType type = typeStyleTableProperties;
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child){}
@ -111,7 +107,6 @@ public:
table_format_properties content_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_table_properties)
// style-table-column-properties-attlist
@ -120,9 +115,10 @@ class style_table_column_properties_attlist
public:
void serialize(std::wostream & strm ,const wchar_t * ns, const wchar_t * name );
_CP_OPT(odf_types::length) style_column_width_;
_CP_OPT(odf_types::length) style_rel_column_width_;
_CP_OPT(odf_types::Bool) style_use_optimal_column_width_;
_CP_OPT(double) loext_column_width_sym_;
_CP_OPT(odf_types::length) style_column_width_;
_CP_OPT(odf_types::length) style_rel_column_width_;
_CP_OPT(odf_types::Bool) style_use_optimal_column_width_;
odf_types::common_break_attlist common_break_attlist_;
@ -135,16 +131,13 @@ public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeStyleTableColumnProperties;
static const ElementType type = typeStyleTableColumnProperties;
virtual void create_child_element( const std::wstring & Ns, const std::wstring & Name);
virtual void serialize(std::wostream & strm);
style_table_column_properties_attlist style_table_column_properties_attlist_;
style_table_column_properties_attlist attlist_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_table_column_properties)
// style-table-row-properties-attlist
@ -159,7 +152,7 @@ public:
_CP_OPT(odf_types::keep_together) fo_keep_together_;
odf_types::common_background_color_attlist common_background_color_attlist_;
odf_types::common_break_attlist common_break_attlist_;
odf_types::common_break_attlist common_break_attlist_;
};
// style:table-row-properties
@ -178,10 +171,9 @@ public:
public:
style_table_row_properties_attlist style_table_row_properties_attlist_;
office_element_ptr style_background_image_;
office_element_ptr style_background_image_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_table_row_properties)
// style-table-cell-properties-attlist
@ -227,8 +219,7 @@ public:
class style_table_cell_properties_elements
{
public:
office_element_ptr style_background_image_;
office_element_ptr style_background_image_;
};
// style:table-cell-properties
@ -248,10 +239,9 @@ public:
virtual void serialize(std::wostream & strm);
style_table_cell_properties_attlist content_;
office_element_ptr style_background_image_;
office_element_ptr style_background_image_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_table_cell_properties)
}