git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55026 954022d7-b5bf-4e40-9824-e11837661b57

This commit is contained in:
Elen.Subbotina
2014-03-20 08:17:35 +00:00
committed by Alexander Trofimov
parent 253a30693b
commit cb754219b4
12 changed files with 108 additions and 38 deletions

View File

@ -94,6 +94,21 @@ std::wstring & odf_style_context::find_odf_style_name(int oox_id_style, const st
}
return std::wstring();
}
office_element_ptr & odf_style_context::find_odf_style(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++)
{
if (it->odf_style_)
{
if (it->style_family_ == family)
{
if (oox_id_style >=0 && it->style_oox_id_ == oox_id_style) return it->get_office_element();
}
}
}
return office_element_ptr();
}
std::wstring odf_style_context::get_name_family(const style_family & family)
{
switch(family.get_type())

View File

@ -31,9 +31,10 @@ public:
void process_office(office_element_ptr root );
std::wstring & find_odf_style_name(int oox_id_style, const style_family family);
std::wstring & find_odf_style_name (int oox_id_style, const style_family family);
office_element_ptr & find_odf_style (int oox_id_style, const style_family family);
//void start_cell(const std::wstring & formula,
// size_t columnsSpanned,
// size_t rowsSpanned);

View File

@ -38,10 +38,10 @@ void ods_conversion_context::end_sheet()
void ods_conversion_context::add_column(int start_column, int repeated, const std::wstring & style_name)
{
if (start_column > ods_table_context_.state().columns_count())
if (start_column > ods_table_context_.state().columns_count()+1)
{
//default_columns
int repeated_default = start_column - ods_table_context_.state().columns_count();
int repeated_default = start_column - ods_table_context_.state().columns_count()-1;
office_element_ptr element_column_default;
create_element(L"table", L"table-column",element_column_default,this);

View File

@ -24,6 +24,8 @@ public:
office_spreadsheet* current_spreadsheet_;
ods_table_state & current_table() { return ods_table_context_.state();}
};

View File

@ -20,11 +20,6 @@ ods_table_state & ods_table_context::state()
return table_state_list_.back();
}
const ods_table_state & ods_table_context::state() const
{
return table_state_list_.back();
}
void ods_table_context::start_table(office_element_ptr & elm, std::wstring & name)
{
table_state_list_.push_back( ods_table_state(context_, elm) );

View File

@ -70,7 +70,6 @@ public:
// double table_column_last_width() const;
ods_table_state & state();
const ods_table_state & state() const;
// void start_hyperlink();
//std::wstring end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display);

View File

@ -13,6 +13,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;
}
void ods_table_state::set_name(std::wstring name)
@ -61,7 +62,13 @@ void ods_table_state::add_column(office_element_ptr & elm, int repeated, const s
column->table_table_column_attlist_.table_style_name_ = style_ref(style_name);
column->table_table_column_attlist_.table_number_columns_repeated_ = repeated;
}
void ods_table_state::set_default_column_cell_style(std::wstring & style_name)
{
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
if (column == NULL)return;
column->table_table_column_attlist_.table_default_cell_style_name_ = style_ref(style_name);
}
unsigned int ods_table_state::columns_count() const

View File

@ -44,7 +44,7 @@ public:
// std::wstring current_row_style() const;
// std::wstring default_row_cell_style() const;
// std::wstring default_column_cell_style() const;
void set_default_column_cell_style(std::wstring & style_name);
//void set_table_row_group(int count, bool collapsed, int level);
// void start_cell(size_t columnsSpanned, size_t rowsSpanned);

View File

@ -118,7 +118,13 @@ void style_table_cell_properties::create_child_element( const ::std::wstring & N
CP_NOT_APPLICABLE_ELM();
}
}
void style_table_cell_properties::apply_from(const style_table_cell_properties * Other)
{
if (Other == NULL)return;
style_table_cell_properties_attlist_.apply_from(Other->style_table_cell_properties_attlist_);
}
void style_table_cell_properties::serialize(std::wostream & strm)
{
style_table_cell_properties_attlist_.serialize(strm,ns,name);

View File

@ -254,6 +254,7 @@ public:
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
void apply_from(const style_table_cell_properties * Other);
virtual void serialize(std::wostream & strm);
style_table_cell_properties_attlist style_table_cell_properties_attlist_;

View File

@ -92,6 +92,10 @@ void XlsxConverter::convert_sheets()
}
void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (oox_sheet->m_oSheetFormatPr.IsInit())
convert(oox_sheet->m_oSheetFormatPr.GetPointer());
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(oox_sheet->m_oCols.IsInit())
{
@ -105,14 +109,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
{
//nullable<SimpleTypes::COnOff<>> m_oBestFit;
//nullable<SimpleTypes::COnOff<>> m_oCollapsed;
//nullable<SimpleTypes::COnOff<>> m_oCustomWidth;
//nullable<SimpleTypes::COnOff<>> m_oHidden;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMax;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMin;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oOutlineLevel;
//nullable<SimpleTypes::COnOff<>> m_oPhonetic;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oStyle;
//nullable<SimpleTypes::CDouble> m_oWidth;
int start_column = oox_column->m_oMin.IsInit() ? oox_column->m_oMin->GetValue() : 0 ;
int repeated = (oox_column->m_oMax.IsInit() ? oox_column->m_oMax->GetValue() : 0) -
(oox_column->m_oMin.IsInit() ? oox_column->m_oMin->GetValue() : 0) + 1;
@ -129,21 +128,26 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
double width = oox_column->m_oWidth.IsInit() ? oox_column->m_oWidth->GetValue() : 0;
if (oox_column->m_oStyle.IsInit())
{
//m_oCustomWidth
}
if (width < 1 || (oox_column->m_oBestFit.IsInit() && oox_column->m_oBestFit->GetValue()==true))
column_properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
else
else if (oox_column->m_oCustomWidth.IsInit() == false || (oox_column->m_oCustomWidth.IsInit() && oox_column->m_oCustomWidth->GetValue()==true))
{
column_properties->style_table_column_properties_attlist_.style_column_width_ = odf::length(width,odf::length::cm);
column_properties->style_table_column_properties_attlist_.style_column_width_ = odf::length(width/2.,odf::length::cm); //<2F><>_<EFBFBD><5F><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !!!
}
ods_context->add_column(start_column, repeated, style->style_name_);
}
if (oox_column->m_oStyle.IsInit())
{
int xfd_id = oox_column->m_oStyle->GetValue();//<2F><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cells - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::wstring style_cell_name = ods_context->styles_context().find_odf_style_name(xfd_id,odf::style_family::TableCell);
ods_context->current_table().set_default_column_cell_style(style_cell_name );
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format)
{
}
void XlsxConverter::convert_styles()
{
if (!ods_context) return;
@ -249,14 +253,17 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFill * fill, odf::office_element_
{//solid, gradient
if (fill->m_oPatternFill->m_oPatternType.IsInit())
{}
if (fill->m_oPatternFill->m_oBgColor.IsInit())
if (fill->m_oPatternFill->m_oFgColor.IsInit())
{
convert(fill->m_oPatternFill->m_oFgColor.GetPointer(),
cell_properties->style_table_cell_properties_attlist_.common_background_color_attlist_.fo_background_color_);
}
else if (fill->m_oPatternFill->m_oBgColor.IsInit())
{
convert(fill->m_oPatternFill->m_oBgColor.GetPointer(),
cell_properties->style_table_cell_properties_attlist_.common_background_color_attlist_.fo_background_color_);
}
if (fill->m_oPatternFill->m_oFgColor.IsInit())
{}
}
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::background_color) & odf_bckgrd_color)
@ -284,24 +291,59 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color)
{
if (!color)return;
if(color->m_oRgb.IsInit())
if(color->m_oRgb.IsInit())//easy, faster,realy !!
{
odf_color = odf::color(std::wstring(L"#") + string2std_string(color->m_oRgb->ToString()));
return;
}
SimpleTypes::Spreadsheet::CHexColor *oRgbColor=NULL;
if(color->m_oThemeColor.IsInit())
{
OOX::CTheme * xlsx_theme= xlsx_document->GetTheme();
int theme_ind = color->m_oThemeColor->GetValue();
//CString strColor = color->m_oThemeColor->ToString();
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
bool res=false;
//<2F> <20><><EFBFBD> <20><><EFBFBD> CColorMapping <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !!!
switch(theme_ind)
{
case SimpleTypes::themecolorLight1:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oLt1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorLight2:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oLt2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorDark1:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oDk1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorDark2:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oDk2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent1:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent2:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent3:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent3.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent4:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent4.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent5:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent5.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent6:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent6.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorFollowedHyperlink:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oFolHlink.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorHyperlink:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oHlink.tryGetRgb(ucR, ucG, ucB, ucA); break;
}
if (res)
oRgbColor = new SimpleTypes::Spreadsheet::CHexColor(ucR,ucG,ucB,ucA);
}
if(color->m_oIndexed.IsInit())
{
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
int ind = color->m_oIndexed->GetValue();
SimpleTypes::Spreadsheet::CHexColor *oRgbColor=NULL;
if(xlsx_styles->m_oColors.IsInit() && xlsx_styles->m_oColors->m_oIndexedColors.IsInit())
{
if (xlsx_styles->m_oColors->m_oIndexedColors->m_arrItems[ind])
@ -313,11 +355,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color)
if(OOX::Spreadsheet::CIndexedColors::GetDefaultRGBAByIndex(ind, ucR, ucG, ucB, ucA))
oRgbColor = new SimpleTypes::Spreadsheet::CHexColor(ucR,ucG,ucB,ucA);
}
if (oRgbColor)
{
odf_color = odf::color(std::wstring(L"#") + string2std_string(oRgbColor->ToString()));
delete oRgbColor;
}
}
if (oRgbColor)
{
CString str=oRgbColor->ToString();
odf_color = odf::color(std::wstring(L"#") + string2std_string(str.Right(str.GetLength()-2)));
delete oRgbColor;
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CCellStyle * cell_style, int oox_id)

View File

@ -54,6 +54,7 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CWorksheet *oox_sheet);
void convert(OOX::Spreadsheet::CCol *oox_column);
void convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format);
void convert(OOX::Spreadsheet::CFill * fill, odf::office_element_ptr & odf_style_);
void convert(OOX::Spreadsheet::CFont * font, odf::office_element_ptr & odf_style_);