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

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@54970 954022d7-b5bf-4e40-9824-e11837661b57
parent 85df2bf9
...@@ -30,48 +30,77 @@ namespace odf { ...@@ -30,48 +30,77 @@ namespace odf {
using xml::xml_char_wc; using xml::xml_char_wc;
// //
style_text_properties * style_content::get_style_text_properties() const style_text_properties * style_content::get_style_text_properties()
{ {
//åñëè çàïðîñèëè .. çíà÷èò íàäî - ñîçäàåì
if (!style_text_properties_)
create_element(L"style", L"text-properties",style_text_properties_,Context);
return dynamic_cast<style_text_properties *>(style_text_properties_.get()); return dynamic_cast<style_text_properties *>(style_text_properties_.get());
} }
style_paragraph_properties * style_content::get_style_paragraph_properties() const style_paragraph_properties * style_content::get_style_paragraph_properties()
{ {
return dynamic_cast<style_paragraph_properties *>(style_paragraph_properties_.get()); if (!style_paragraph_properties_)
create_element(L"style", L"paragraph-properties",style_paragraph_properties_,Context);
return dynamic_cast<style_paragraph_properties *>(style_paragraph_properties_.get());
} }
style_graphic_properties * style_content::get_style_graphic_properties() const style_graphic_properties * style_content::get_style_graphic_properties()
{ {
return dynamic_cast<style_graphic_properties *>(style_graphic_properties_.get()); if (!style_graphic_properties_)
create_element(L"style", L"graphic-properties",style_graphic_properties_,Context);
return dynamic_cast<style_graphic_properties *>(style_graphic_properties_.get());
} }
style_table_properties * style_content::get_style_table_properties() const style_table_properties * style_content::get_style_table_properties()
{ {
if (!style_table_properties_)
create_element(L"style", L"table-properties",style_table_properties_,Context);
return dynamic_cast<style_table_properties *>(style_table_properties_.get()); return dynamic_cast<style_table_properties *>(style_table_properties_.get());
} }
style_section_properties * style_content::get_style_section_properties() const style_section_properties * style_content::get_style_section_properties()
{ {
return dynamic_cast<style_section_properties *>(style_section_properties_.get()); if (!style_section_properties_)
create_element(L"style", L"section-properties",style_section_properties_,Context);
return dynamic_cast<style_section_properties *>(style_section_properties_.get());
} }
style_table_cell_properties * style_content::get_style_table_cell_properties() const style_table_cell_properties * style_content::get_style_table_cell_properties()
{ {
return dynamic_cast<style_table_cell_properties *>(style_table_cell_properties_.get()); //åñëè çàïðîñèëè .. çíà÷èò íàäî - ñîçäàåì
if (!style_table_cell_properties_)
create_element(L"style", L"table-cell-properties",style_table_cell_properties_,Context);
return dynamic_cast<style_table_cell_properties *>(style_table_cell_properties_.get());
} }
style_table_row_properties * style_content::get_style_table_row_properties() const style_table_row_properties * style_content::get_style_table_row_properties()
{ {
return dynamic_cast<style_table_row_properties *>(style_table_row_properties_.get()); if (!style_table_row_properties_)
create_element(L"style", L"table-row-properties",style_table_row_properties_,Context);
return dynamic_cast<style_table_row_properties *>(style_table_row_properties_.get());
} }
style_table_column_properties * style_content::get_style_table_column_properties() const style_table_column_properties * style_content::get_style_table_column_properties()
{ {
return dynamic_cast<style_table_column_properties *>(style_table_column_properties_.get()); if (!style_table_column_properties_)
create_element(L"style", L"table-column-properties",style_table_column_properties_,Context);
return dynamic_cast<style_table_column_properties *>(style_table_column_properties_.get());
} }
style_chart_properties * style_content::get_style_chart_properties() const style_chart_properties * style_content::get_style_chart_properties()
{ {
return dynamic_cast<style_chart_properties *>(style_chart_properties_.get()); if (!style_chart_properties_)
create_element(L"style", L"chart-properties",style_chart_properties_,Context);
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() const
//{ //{
...@@ -100,7 +129,7 @@ void style_content::add_child_element(office_element_ptr & child) ...@@ -100,7 +129,7 @@ void style_content::add_child_element(office_element_ptr & child)
} }
} }
void style_content::create_child_element( const std::wstring & Ns, const ::std::wstring & Name, odf_conversion_context * Context) void style_content::create_child_element( const std::wstring & Ns, const ::std::wstring & Name)
{ {
if CP_CHECK_NAME(L"style", L"text-properties") if CP_CHECK_NAME(L"style", L"text-properties")
{ {
...@@ -170,7 +199,7 @@ const wchar_t * default_style::name = L"default-style"; ...@@ -170,7 +199,7 @@ const wchar_t * default_style::name = L"default-style";
void default_style::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) void default_style::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
{ {
style_content_.create_child_element(Ns, Name, getContext()); style_content_.create_child_element(Ns, Name);
} }
void default_style::add_child_element(office_element_ptr & child) void default_style::add_child_element(office_element_ptr & child)
{ {
...@@ -233,7 +262,7 @@ void style::create_child_element( const ::std::wstring & Ns, const ::std::wstri ...@@ -233,7 +262,7 @@ void style::create_child_element( const ::std::wstring & Ns, const ::std::wstri
CP_CREATE_ELEMENT(style_map_); CP_CREATE_ELEMENT(style_map_);
} }
else else
style_content_.create_child_element(Ns, Name, getContext()); style_content_.create_child_element(Ns, Name);
} }
void style::add_child_element(office_element_ptr & child) void style::add_child_element(office_element_ptr & child)
......
...@@ -56,22 +56,25 @@ class style_drawing_page_properties; ...@@ -56,22 +56,25 @@ class style_drawing_page_properties;
class style_content : noncopyable class style_content : noncopyable
{ {
public: public:
void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name, odf_conversion_context * Context); style_content(odf_conversion_context * _context){Context = _context;}
void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name);
void add_child_element(office_element_ptr & child); void add_child_element(office_element_ptr & child);
void serialize(std::wostream & strm); void serialize(std::wostream & strm);
style_text_properties * get_style_text_properties() const; style_text_properties * get_style_text_properties();
style_paragraph_properties * get_style_paragraph_properties() const; style_paragraph_properties * get_style_paragraph_properties() ;
style_graphic_properties * get_style_graphic_properties() const; style_graphic_properties * get_style_graphic_properties() ;
style_table_properties * get_style_table_properties() const; style_table_properties * get_style_table_properties();
style_section_properties * get_style_section_properties() const; style_section_properties * get_style_section_properties();
style_table_cell_properties * get_style_table_cell_properties() const; style_table_cell_properties * get_style_table_cell_properties();
style_table_row_properties * get_style_table_row_properties() const; style_table_row_properties * get_style_table_row_properties() ;
style_table_column_properties * get_style_table_column_properties() const; style_table_column_properties * get_style_table_column_properties() ;
style_chart_properties * get_style_chart_properties() const; style_chart_properties * get_style_chart_properties() ;
style_drawing_page_properties* get_style_drawing_page_properties() const; style_drawing_page_properties* get_style_drawing_page_properties();
private: private:
odf_conversion_context * Context;
style_family style_family_; style_family style_family_;
office_element_ptr style_text_properties_; office_element_ptr style_text_properties_;
...@@ -100,7 +103,7 @@ public: ...@@ -100,7 +103,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
public: public:
default_style() {}; default_style() : style_content_(getContext()) {}
virtual void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name); virtual void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child); virtual void add_child_element(office_element_ptr & child);
...@@ -255,11 +258,10 @@ public: ...@@ -255,11 +258,10 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleStyle; static const ElementType type = typeStyleStyle;
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
style() : style_auto_update_(false) { } style() : style_auto_update_(false), style_content_(getContext()) {}
virtual void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name); virtual void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child); virtual void add_child_element(office_element_ptr & child);
virtual void serialize(std::wostream & strm); virtual void serialize(std::wostream & strm);
......
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
#include "styles.h" #include "styles.h"
#include "style_table_properties.h"
#include "style_text_properties.h"
#include "style_paragraph_properties.h"
#include "style_graphic_properties.h"
using namespace cpdoccore; using namespace cpdoccore;
...@@ -141,50 +146,113 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf::office_element_ ...@@ -141,50 +146,113 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf::office_element_
odf::style_text_properties * text_properties = style->style_content_.get_style_text_properties();// - odf::style_text_properties * text_properties = style->style_content_.get_style_text_properties();// -
if (text_properties == NULL) if (text_properties == NULL)return;
{
style->create_child_element(L"style", L"text-properties");
text_properties = style->style_content_.get_style_text_properties();
if (text_properties == NULL) return;
}
} }
void XlsxConverter::convert(OOX::Spreadsheet::CFill * fill, odf::office_element_ptr & odf_style_) void XlsxConverter::convert(OOX::Spreadsheet::CFill * fill, odf::office_element_ptr & odf_style_)
{ {
if (fill == NULL)return;
odf::style* style = dynamic_cast<odf::style*>(odf_style_.get()); odf::style* style = dynamic_cast<odf::style*>(odf_style_.get());
if (!style)return; if (!style)return;
odf::style_table_cell_properties * cell_properties = style->style_content_.get_style_table_cell_properties();// - odf::style_table_cell_properties * cell_properties = style->style_content_.get_style_table_cell_properties();// -
if (cell_properties == NULL) if (cell_properties == NULL)return;
if (fill->m_oGradientFill.IsInit())
{ {
style->create_child_element(L"style", L"table-cell-properties");
cell_properties = style->style_content_.get_style_table_cell_properties();
if (cell_properties == NULL) return;
} }
if (fill->m_oPatternFill.IsInit())
{//solid, gradient
if (fill->m_oPatternFill->m_oPatternType.IsInit())
{}
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)
{
if (!color)return;
_CP_OPT(odf::color) odf_color;
convert(color, odf_color);
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_)
{
if (!numFmt)return;
}
void XlsxConverter::convert(OOX::Spreadsheet::CBorder *border, odf::office_element_ptr & odf_style_)
{
if (!border)return;
}
void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color) & odf_color)
{
if (!color)return;
if(color->m_oRgb.IsInit())
{
odf_color = odf::color(std::wstring(L"#") + string2std_string(color->m_oRgb->ToString()));
}
if(color->m_oThemeColor.IsInit())
{
}
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])
oRgbColor = new SimpleTypes::Spreadsheet::CHexColor(xlsx_styles->m_oColors->m_oIndexedColors->m_arrItems[ind]->m_oRgb.get());
}
else
{
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
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;
}
}
} }
odf::office_element_ptr XlsxConverter::convert(OOX::Spreadsheet::CXfs * cell_style, int oox_id) odf::office_element_ptr XlsxConverter::convert(OOX::Spreadsheet::CXfs * cell_style, int oox_id)
{ {
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles(); OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
int id_parent = cell_style->m_oXfId.GetPointer() ? cell_style->m_oXfId->GetValue() : -1; //parent int id_parent = cell_style->m_oXfId.IsInit() ? cell_style->m_oXfId->GetValue() : -1; //parent
int fill_id = cell_style->m_oFillId.GetPointer() ? cell_style->m_oFillId->GetValue() : -1; int fill_id = cell_style->m_oFillId.IsInit() ? cell_style->m_oFillId->GetValue() : -1;
int numFmt_id = cell_style->m_oNumFmtId.GetPointer() ? cell_style->m_oNumFmtId->GetValue() : -1; int numFmt_id = cell_style->m_oNumFmtId.IsInit() ? cell_style->m_oNumFmtId->GetValue() : -1;
int font_id = cell_style->m_oFontId.GetPointer() ? cell_style->m_oFontId->GetValue() : -1; int font_id = cell_style->m_oFontId.IsInit() ? cell_style->m_oFontId->GetValue() : -1;
int border_id = cell_style->m_oBorderId.GetPointer() ? cell_style->m_oBorderId->GetValue() : -1; int border_id = cell_style->m_oBorderId.IsInit() ? cell_style->m_oBorderId->GetValue() : -1;
std::wstring cell_style_name_new = L"ce" + boost::lexical_cast<std::wstring>(oox_id+1);// std::wstring cell_style_name_new = L"ce" + boost::lexical_cast<std::wstring>(oox_id+1);//
odf::office_element_ptr elm_style = ods_context->styles_context().add_or_find(cell_style_name_new ,odf::style_family::TableCell, true, oox_id); odf::office_element_ptr elm_style = ods_context->styles_context().add_or_find(cell_style_name_new ,odf::style_family::TableCell, true, oox_id);
// c - () - oox // c - () - oox
convert(xlsx_styles->m_oFonts->m_arrItems[font_id], elm_style); if (xlsx_styles->m_oFonts.IsInit()) convert(xlsx_styles->m_oFonts->m_arrItems[font_id], elm_style); // applyFont
if (xlsx_styles->m_oFills.IsInit()) convert(xlsx_styles->m_oFills->m_arrItems[fill_id], elm_style); // applyFill
convert(xlsx_styles->m_oFills->m_arrItems[fill_id], elm_style); if (xlsx_styles->m_oNumFmts.IsInit()) convert(xlsx_styles->m_oNumFmts->m_arrItems[numFmt_id], elm_style);
if (xlsx_styles->m_oBorders.IsInit()) convert(xlsx_styles->m_oBorders->m_arrItems[border_id], elm_style);
odf::style* style = dynamic_cast<odf::style*>(elm_style.get()); odf::style* style = dynamic_cast<odf::style*>(elm_style.get());
if (!style)return elm_style; if (!style)return elm_style;
......
...@@ -3,15 +3,17 @@ ...@@ -3,15 +3,17 @@
#include "Converter.h" #include "Converter.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <cpdoccore/CPSharedPtr.h> #include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/CPOptional.h>
#include <XlsxFormat\Xlsx.h> #include <XlsxFormat\Xlsx.h>
namespace OOX namespace OOX
{ {
class CDocx; class CDocx;
} }
namespace cpdoccore
namespace cpdoccore
{ {
namespace odf 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;
...@@ -21,9 +23,13 @@ namespace cpdoccore ...@@ -21,9 +23,13 @@ namespace cpdoccore
class odf_document; class odf_document;
} }
class ods_conversion_context; class ods_conversion_context;
class color;
class background_color;
} }
} }
using namespace cpdoccore;
namespace Oox2Odf namespace Oox2Odf
{ {
...@@ -37,18 +43,23 @@ namespace Oox2Odf ...@@ -37,18 +43,23 @@ namespace Oox2Odf
private: private:
OOX::Spreadsheet::CXlsx *xlsx_document; OOX::Spreadsheet::CXlsx *xlsx_document;
cpdoccore::odf::package::odf_document *output_document; odf::package::odf_document *output_document;
cpdoccore::odf::ods_conversion_context *ods_context; odf::ods_conversion_context *ods_context;
void convert_sheets(); void convert_sheets();
void convert_styles(); void convert_styles();
void convert(OOX::Spreadsheet::CWorksheet *oox_sheet); void convert(OOX::Spreadsheet::CWorksheet *oox_sheet);
void convert(OOX::Spreadsheet::CFill * fill, cpdoccore::odf::office_element_ptr & odf_style_); void convert(OOX::Spreadsheet::CFill * fill, odf::office_element_ptr & odf_style_);
void convert(OOX::Spreadsheet::CFont * font, cpdoccore::odf::office_element_ptr & odf_style_); void convert(OOX::Spreadsheet::CFont * font, odf::office_element_ptr & odf_style_);
void convert(OOX::Spreadsheet::CNumFmt *numFmt, odf::office_element_ptr & odf_style_);
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::background_color) & odf_bckgrd_color);
cpdoccore::odf::office_element_ptr convert(OOX::Spreadsheet::CXfs * cell_style, int oox_id); odf::office_element_ptr convert(OOX::Spreadsheet::CXfs * cell_style, int oox_id);
}; };
} }
\ 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