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

форматированный текст в ячейках

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55297 954022d7-b5bf-4e40-9824-e11837661b57
parent a661dd56
...@@ -42,7 +42,7 @@ void odf_style_state::add_child(office_element_ptr & child) ...@@ -42,7 +42,7 @@ void odf_style_state::add_child(office_element_ptr & child)
odf_style_->add_child_element(child); odf_style_->add_child_element(child);
} }
void odf_style_state::set_name(std::wstring name) void odf_style_state::set_name(std::wstring & name)
{ {
style* style_ = dynamic_cast<style*>(odf_style_.get()); style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return; if (!style_)return;
...@@ -56,6 +56,14 @@ std::wstring & odf_style_state::get_name() ...@@ -56,6 +56,14 @@ std::wstring & odf_style_state::get_name()
return style_->style_name_; return style_->style_name_;
} }
void odf_style_state::set_parent_style_name(std::wstring & name)
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return;
style_->style_parent_style_name_ = name;
}
//////////////////////////////////////////////////////////////////////
void odf_style_state::set_automatic(bool val) void odf_style_state::set_automatic(bool val)
{ {
automatic_ = val; automatic_ = val;
...@@ -68,12 +76,86 @@ void odf_style_state::set_default(bool val) ...@@ -68,12 +76,86 @@ void odf_style_state::set_default(bool val)
{ {
default_ = val; default_ = val;
} }
void odf_style_state::convert() //////////////////////////////////////////////////////////////////
style_text_properties * odf_style_state::get_text_properties()
{ {
if (odf_style_== NULL)return; style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_text_properties();
}
style_paragraph_properties * odf_style_state::get_paragraph_properties()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_paragraph_properties();
} }
style_graphic_properties * odf_style_state::get_graphic_properties()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_graphic_properties();
}
style_table_properties * odf_style_state::get_table_properties()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_table_properties();
}
style_section_properties * odf_style_state::get_section_properties()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_section_properties();
}
style_table_cell_properties * odf_style_state::get_table_cell_properties()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_table_cell_properties();
}
style_table_row_properties * odf_style_state::get_table_row_properties()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_table_row_properties();
}
style_table_column_properties * odf_style_state::get_table_column_properties()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_table_column_properties();
}
style_chart_properties * odf_style_state::get_chart_properties()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return NULL;
return style_->style_content_.get_style_chart_properties();
}
//style_drawing_page_properties * odf_style_state::get_drawing_page_properties()
//{
// style* style_ = dynamic_cast<style*>(odf_style_.get());
// if (!style_)return NULL;
//
// return style_->style_content_.get_style_drawing_page_properties();
//}
///////////////////////
} }
} }
...@@ -21,29 +21,49 @@ namespace odf { ...@@ -21,29 +21,49 @@ namespace odf {
class odf_conversion_context; class odf_conversion_context;
class odf_style_context; class odf_style_context;
//class style; class style_text_properties;
class style_paragraph_properties;
class style_graphic_properties;
class style_table_properties;
class style_section_properties;
class style_table_cell_properties;
class style_table_row_properties;
class style_table_column_properties;
class style_chart_properties;
//class style_drawing_page_properties;
class odf_style_state class odf_style_state
{ {
public: public:
odf_style_state(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_automatic(bool val);
void set_root(bool val); void set_root(bool val);
void set_default(bool val); void set_default(bool val);
std::wstring & get_name();
void convert();
office_element_ptr & get_office_element(); office_element_ptr & get_office_element();
void add_child(office_element_ptr & child); void add_child(office_element_ptr & child);
/////////////////////////////////////////////////////////////////////////////////////////
void set_name(std::wstring & name);
std::wstring & get_name();
void set_number_format(int id) {num_fmt_id_ = id;} void set_number_format(int id) {num_fmt_id_ = id;}
int get_number_format() {return num_fmt_id_;} int get_number_format() {return num_fmt_id_;}
void set_parent_style_name(std::wstring & name) ;
//////////////////////////////////////////////////////////////////////////////////////////
style_text_properties * get_text_properties();
style_paragraph_properties * get_paragraph_properties() ;
style_graphic_properties * get_graphic_properties() ;
style_table_properties * get_table_properties();
style_section_properties * get_section_properties();
style_table_cell_properties * get_table_cell_properties();
style_table_row_properties * get_table_row_properties() ;
style_table_column_properties * get_table_column_properties() ;
style_chart_properties * get_chart_properties() ;
//style_drawing_page_properties* get_drawing_page_properties();
private: private:
std::wstring style_oox_name_; std::wstring style_oox_name_;
......
...@@ -195,7 +195,7 @@ void ods_table_state::set_row_height(double height) ...@@ -195,7 +195,7 @@ void ods_table_state::set_row_height(double height)
style_table_row_properties * row_properties = style->style_content_.get_style_table_row_properties(); style_table_row_properties * row_properties = style->style_content_.get_style_table_row_properties();
if (row_properties == NULL)return; //error ???? if (row_properties == NULL)return; //error ????
row_properties->style_table_row_properties_attlist_.style_row_height_ = length(height/4.85,length::cm); row_properties->style_table_row_properties_attlist_.style_row_height_ = length(height/22.85,length::cm);
} }
int ods_table_state::current_column() const int ods_table_state::current_column() const
......
...@@ -102,9 +102,12 @@ style_chart_properties * style_content::get_style_chart_properties() ...@@ -102,9 +102,12 @@ style_chart_properties * style_content::get_style_chart_properties()
return dynamic_cast<style_chart_properties *>(style_chart_properties_.get()); return dynamic_cast<style_chart_properties *>(style_chart_properties_.get());
} }
//style_drawing_page_properties * style_content::get_style_drawing_page_properties() const //style_drawing_page_properties * style_content::get_style_drawing_page_properties()
//{ //{
// return dynamic_cast<style_drawing_page_properties *>(style_drawing_page_properties_.get()); // if (!style_drawing_page_properties_)
// create_element(L"style", L"drawing-page-properties",style_drawing_page_properties_,Context);
//
// return dynamic_cast<style_drawing_page_properties *>(style_drawing_page_properties_.get());
//} //}
void style_content::add_child_element(office_element_ptr & child) void style_content::add_child_element(office_element_ptr & child)
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
style_table_row_properties * get_style_table_row_properties() ; style_table_row_properties * get_style_table_row_properties() ;
style_table_column_properties * get_style_table_column_properties() ; style_table_column_properties * get_style_table_column_properties() ;
style_chart_properties * get_style_chart_properties() ; style_chart_properties * get_style_chart_properties() ;
style_drawing_page_properties* get_style_drawing_page_properties(); //style_drawing_page_properties* get_style_drawing_page_properties();
private: private:
odf_conversion_context * Context; odf_conversion_context * Context;
......
...@@ -165,7 +165,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row) ...@@ -165,7 +165,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row)
if (oox_row->m_oCustomHeight.IsInit() && oox_row->m_oCustomHeight->GetValue() == 1) if (oox_row->m_oCustomHeight.IsInit() && oox_row->m_oCustomHeight->GetValue() == 1)
{ {
ods_context->current_table().set_row_optimal_height(false); ods_context->current_table().set_row_optimal_height(false);
} }else
ods_context->current_table().set_row_optimal_height(true);
for (long cell = 0 ; cell < oox_row->m_arrItems.GetSize();cell++) for (long cell = 0 ; cell < oox_row->m_arrItems.GetSize();cell++)
{ {
...@@ -285,19 +286,60 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_text_pr) ...@@ -285,19 +286,60 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_text_pr)
bool automatic = true; bool automatic = true;
bool root = false; bool root = false;
ods_context->styles_context().create_style(L"",odf::style_family::Text, automatic, root, -1); ods_context->styles_context().create_style(L"",odf::style_family::Text, automatic, root, -1);
//// odf::style_text_properties * text_properties = ods_context->styles_context().last_state().get_text_properties();
if (text_properties == NULL)return;
if (oox_text_pr->m_oBold.IsInit())
{
if (oox_text_pr->m_oBold->m_oVal.ToBool() ==true)
text_properties->content().fo_font_weight_ = odf::font_weight(odf::font_weight::WBold);
else
text_properties->content().fo_font_weight_ = odf::font_weight(odf::font_weight::WNormal);
}
convert(oox_text_pr->m_oColor.GetPointer(),text_properties->content().fo_color_);
if (oox_text_pr->m_oUnderline.IsInit())
{
//convert_element ????
}
if (oox_text_pr->m_oItalic.IsInit())
{
if (oox_text_pr->m_oItalic->m_oVal.ToBool() ==true)
text_properties->content().fo_font_style_ = odf::font_style(odf::font_style::Italic);
else
text_properties->content().fo_font_style_ = odf::font_style(odf::font_style::Normal);
}
if (oox_text_pr->m_oSz.IsInit())
{
convert(oox_text_pr->m_oSz->m_oVal->GetValue(), text_properties->content().fo_font_size_);
}
if (oox_text_pr->m_oFamily.IsInit())
{
}
if (oox_text_pr->m_oRFont.IsInit())
{
text_properties->content().style_font_name_ = string2std_string(oox_text_pr->m_oRFont->m_sVal.get());
}
//convert(oox_text_pr->m_oVertAlign.GetPointer(),...
//nullable<CCharset> m_oCharset;
//nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oCondense;
//nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oExtend;
//nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oOutline;
//nullable<CFontScheme> m_oScheme;
//nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oShadow;
//nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oStrike;
} }
void XlsxConverter::convert(OOX::Spreadsheet::CText *oox_text) void XlsxConverter::convert(OOX::Spreadsheet::CText *oox_text)
{ {
if (oox_text == NULL)return; if (oox_text == NULL)return;
//ods_context->start_text();
ods_context->add_text_content( string2std_string(oox_text->m_sText) ); ods_context->add_text_content( string2std_string(oox_text->m_sText) );
//ods_context->end_text();
} }
void XlsxConverter::convert(OOX::Spreadsheet::CFormula *oox_formula) void XlsxConverter::convert(OOX::Spreadsheet::CFormula *oox_formula)
{ {
...@@ -461,15 +503,12 @@ void XlsxConverter::convert_styles() ...@@ -461,15 +503,12 @@ void XlsxConverter::convert_styles()
} }
} }
void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf::office_element_ptr & odf_style_)
void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf::style_text_properties * text_properties)
{ {
if (font == NULL)return; if (font == NULL)return;
odf::style* style = dynamic_cast<odf::style*>(odf_style_.get());
if (!style)return;
odf::style_text_properties * text_properties = style->style_content_.get_style_text_properties();// -
if (text_properties == NULL)return; if (text_properties == NULL)return;
if (font->m_oBold.IsInit()) if (font->m_oBold.IsInit())
{ {
if (font->m_oBold->m_oVal.ToBool() ==true) if (font->m_oBold->m_oVal.ToBool() ==true)
...@@ -477,10 +516,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf::office_element_ ...@@ -477,10 +516,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf::office_element_
else else
text_properties->content().fo_font_weight_ = odf::font_weight(odf::font_weight::WNormal); text_properties->content().fo_font_weight_ = odf::font_weight(odf::font_weight::WNormal);
} }
if (font->m_oColor.IsInit()) convert(font->m_oColor.GetPointer(),text_properties->content().fo_color_);
{
convert(font->m_oColor.GetPointer(),text_properties->content().fo_color_);
}
if (font->m_oUnderline.IsInit()) if (font->m_oUnderline.IsInit())
{ {
//convert_element ???? //convert_element ????
...@@ -523,14 +560,9 @@ void XlsxConverter::convert(double oox_size, _CP_OPT(odf::length) & odf_size) ...@@ -523,14 +560,9 @@ void XlsxConverter::convert(double oox_size, _CP_OPT(odf::length) & odf_size)
//??? //???
odf_size = odf::length(oox_size, odf::length::pt); odf_size = odf::length(oox_size, odf::length::pt);
} }
void XlsxConverter::convert(OOX::Spreadsheet::CFill * fill, odf::office_element_ptr & odf_style_) void XlsxConverter::convert(OOX::Spreadsheet::CFill * fill, odf::style_table_cell_properties * cell_properties)
{ {
if (fill == NULL)return; if (fill == NULL)return;
odf::style* style = dynamic_cast<odf::style*>(odf_style_.get());
if (!style)return;
odf::style_table_cell_properties * cell_properties = style->style_content_.get_style_table_cell_properties();// -
if (cell_properties == NULL)return; if (cell_properties == NULL)return;
if (fill->m_oGradientFill.IsInit()) if (fill->m_oGradientFill.IsInit())
...@@ -563,13 +595,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::backgr ...@@ -563,13 +595,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::backgr
if (odf_color)odf_bckgrd_color = odf::background_color(odf_color.get()); if (odf_color)odf_bckgrd_color = odf::background_color(odf_color.get());
} }
void XlsxConverter::convert(OOX::Spreadsheet::CNumFmt *numFmt, odf::office_element_ptr & odf_style_) void XlsxConverter::convert(OOX::Spreadsheet::CNumFmt *numFmt, odf::style_table_cell_properties * cell_properties)
{ {
if (!numFmt)return; if (!numFmt)return;
} }
void XlsxConverter::convert(OOX::Spreadsheet::CBorder *border, odf::office_element_ptr & odf_style_) void XlsxConverter::convert(OOX::Spreadsheet::CBorder *border, odf::style_table_cell_properties * cell_properties)
{ {
if (!border)return; if (!border)return;
...@@ -700,13 +732,18 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool ...@@ -700,13 +732,18 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
int border_id = xfc_style->m_oBorderId.IsInit() ? xfc_style->m_oBorderId->GetValue(): -1; int border_id = xfc_style->m_oBorderId.IsInit() ? xfc_style->m_oBorderId->GetValue(): -1;
ods_context->styles_context().create_style(L"",odf::style_family::TableCell, automatic, root, oox_id); ods_context->styles_context().create_style(L"",odf::style_family::TableCell, automatic, root, oox_id);
odf::office_element_ptr & elm_style = ods_context->styles_context().last_state().get_office_element();
if (xlsx_styles->m_oFonts.IsInit() && font_id >=0 && (id_parent < 0 || xfc_style->m_oApplyFont.IsInit())) odf::style_text_properties * text_properties = ods_context->styles_context().last_state().get_text_properties();
convert(xlsx_styles->m_oFonts->m_arrItems[font_id], elm_style); odf::style_table_cell_properties * table_cell_properties = ods_context->styles_context().last_state().get_table_cell_properties();
if (xlsx_styles->m_oFonts.IsInit() && font_id >=0 && (id_parent < 0 || xfc_style->m_oApplyFont.IsInit()))
{
convert(xlsx_styles->m_oFonts->m_arrItems[font_id], text_properties);
}
if (xlsx_styles->m_oFills.IsInit() && fill_id >=0 && (id_parent < 0 || xfc_style->m_oApplyFill.IsInit())) if (xlsx_styles->m_oFills.IsInit() && fill_id >=0 && (id_parent < 0 || xfc_style->m_oApplyFill.IsInit()))
convert(xlsx_styles->m_oFills->m_arrItems[fill_id], elm_style); {
convert(xlsx_styles->m_oFills->m_arrItems[fill_id], table_cell_properties);
}
if (xlsx_styles->m_oNumFmts.IsInit() && numFmt_id>=0 && (id_parent < 0 || xfc_style->m_oApplyNumberFormat.IsInit())) if (xlsx_styles->m_oNumFmts.IsInit() && numFmt_id>=0 && (id_parent < 0 || xfc_style->m_oApplyNumberFormat.IsInit()))
{ {
//if (numFmt_id < xlsx_styles->m_oNumFmts.Count()) //if (numFmt_id < xlsx_styles->m_oNumFmts.Count())
...@@ -716,19 +753,23 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool ...@@ -716,19 +753,23 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
// .. .. .. // .. .. ..
} }
if (xlsx_styles->m_oBorders.IsInit() && border_id >=0 && (id_parent < 0 || xfc_style->m_oApplyBorder.IsInit())) if (xlsx_styles->m_oBorders.IsInit() && border_id >=0 && (id_parent < 0 || xfc_style->m_oApplyBorder.IsInit()))
convert(xlsx_styles->m_oBorders->m_arrItems[border_id], elm_style); {
convert(xlsx_styles->m_oBorders->m_arrItems[border_id], table_cell_properties);
}
ods_context->styles_context().last_state().set_number_format(numFmt_id); ods_context->styles_context().last_state().set_number_format(numFmt_id);
if (table_cell_properties)
{//default
table_cell_properties->style_table_cell_properties_attlist_.fo_wrap_option_ = odf::wrap_option(odf::wrap_option::Wrap);
table_cell_properties->style_table_cell_properties_attlist_.style_text_align_source_ = odf::text_align_source(odf::text_align_source::Fix);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
odf::style* style = dynamic_cast<odf::style*>(elm_style.get());
if (!style)return;
if (id_parent >=0) if (id_parent >=0)
{ {
style->style_parent_style_name_ = ods_context->styles_context().find_odf_style_name(id_parent, odf::style_family::TableCell); ods_context->styles_context().last_state().set_parent_style_name(ods_context->styles_context().find_odf_style_name(id_parent, odf::style_family::TableCell));
} }
odf::style_table_cell_properties * cell_properties = style->style_content_.get_style_table_cell_properties();
} }
} // namespace Docx2Odt } // namespace Docx2Odt
\ No newline at end of file
...@@ -18,6 +18,17 @@ namespace odf ...@@ -18,6 +18,17 @@ namespace odf
class office_element; class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr; typedef shared_ptr<office_element>::Type office_element_ptr;
class style_text_properties;
class style_paragraph_properties;
class style_graphic_properties;
class style_table_properties;
class style_section_properties;
class style_table_cell_properties;
class style_table_row_properties;
class style_table_column_properties;
class style_chart_properties;
class style_drawing_page_properties;
namespace package namespace package
{ {
class odf_document; class odf_document;
...@@ -66,13 +77,14 @@ namespace Oox2Odf ...@@ -66,13 +77,14 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CFormula *oox_formula); void convert(OOX::Spreadsheet::CFormula *oox_formula);
void convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_pr); void convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_pr);
void convert(OOX::Spreadsheet::CSheetPr *oox_sheet_pr); void convert(OOX::Spreadsheet::CSheetPr *oox_sheet_pr);
void convert(OOX::Spreadsheet::CFont * font, odf::style_text_properties * text_properties);
void convert(OOX::Spreadsheet::CFill * fill, odf::office_element_ptr & odf_style_); void convert(OOX::Spreadsheet::CNumFmt *numFmt, odf::style_table_cell_properties * cell_properties);
void convert(OOX::Spreadsheet::CFont * font, odf::office_element_ptr & odf_style_); void convert(OOX::Spreadsheet::CBorder *border, odf::style_table_cell_properties * cell_properties);
void convert(OOX::Spreadsheet::CNumFmt *numFmt, odf::office_element_ptr & odf_style_); void convert(OOX::Spreadsheet::CFill *fill, odf::style_table_cell_properties * cell_properties);
void convert(OOX::Spreadsheet::CBorder *border, odf::office_element_ptr & odf_style_);
void convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color) & odf_color); void convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color) & odf_color);
void convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::background_color) & odf_bckgrd_color); void convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::background_color) & odf_bckgrd_color);
......
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