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

типы данных (все - проценты, числа, даты ...)

форматирование типов данных 

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55321 954022d7-b5bf-4e40-9824-e11837661b57
parent afbb4861
......@@ -301,13 +301,21 @@ void common_value_and_type_attlist::apply_from(const common_value_and_type_attli
}
void common_value_and_type_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"office:value-type", office_value_type_);
CP_XML_ATTR_OPT(L"office:value", office_value_);
CP_XML_ATTR_OPT(L"office:currency", office_currency_);
if (office_value_)
{
CP_XML_ATTR_OPT(L"office:currency", office_currency_);
}
CP_XML_ATTR_OPT(L"office:date-value", office_date_value_);
CP_XML_ATTR_OPT(L"office:time-value", office_time_value_);
CP_XML_ATTR_OPT(L"office:boolean-value", office_boolean_value_);
CP_XML_ATTR_OPT(L"office:string-value", office_string_value_);
if (office_string_value_ || office_boolean_value_|| office_time_value_ || office_date_value_ || office_value_)
{
CP_XML_ATTR_OPT(L"office:value-type", office_value_type_);
//todooo .. .. ???
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -5,7 +5,8 @@
#include "odfattributes.h"
namespace cpdoccore { namespace odf {
namespace cpdoccore {
namespace odf {
class office_value_type
{
......
......@@ -590,29 +590,33 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wstring number_val = L"";
_CP_OPT(bool) bool_val;
int odf_value_type=0;
int odf_value_type = office_value_type::Custom;
if (table_table_cell_attlist_.common_value_and_type_attlist_)
{
const common_value_and_type_attlist & attr = *table_table_cell_attlist_.common_value_and_type_attlist_;
odf_value_type = attr.office_value_type_->get_type();
if (attr.office_value_type_->get_type() == office_value_type::Float)
if (attr.office_value_type_)
odf_value_type = attr.office_value_type_->get_type();
if ((odf_value_type == office_value_type::Float) ||
(odf_value_type == office_value_type::Custom && attr.office_value_))
{
t_val = XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if (attr.office_value_type_->get_type() == office_value_type::Percentage)
else if (odf_value_type == office_value_type::Percentage)
{
t_val = XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if (attr.office_value_type_->get_type() == office_value_type::Currency)
else if (odf_value_type == office_value_type::Currency)
{
t_val = XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if (attr.office_value_type_->get_type() == office_value_type::Date)
{
else if ((odf_value_type == office_value_type::Date) ||
(odf_value_type == office_value_type::Custom && attr.office_date_value_))
{
t_val = XlsxCellType::n;
if (attr.office_date_value_)
{
......@@ -623,7 +627,8 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
}
}
}
else if (attr.office_value_type_->get_type() == office_value_type::Time)
else if ((odf_value_type == office_value_type::Time) ||
(odf_value_type == office_value_type::Custom && attr.office_time_value_))
{
t_val = XlsxCellType::n;
if (attr.office_time_value_)
......@@ -637,15 +642,17 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
}
}
}
else if (attr.office_value_type_->get_type() == office_value_type::Boolean)
else if ((odf_value_type == office_value_type::Boolean) ||
(odf_value_type == office_value_type::Custom && attr.office_boolean_value_))
{
t_val = XlsxCellType::b;
if (attr.office_boolean_value_)
bool_val = oox::parseBoolVal(attr.office_boolean_value_.get());
}
else if (attr.office_value_type_->get_type() == office_value_type::String)
else if ((odf_value_type == office_value_type::String) ||
(odf_value_type == office_value_type::Custom && attr.office_date_value_))
{
t_val = XlsxCellType::s;
t_val = XlsxCellType::s;//
}
}
......
......@@ -1002,6 +1002,22 @@
RelativePath=".\OdfFormat\header_footer.h"
>
</File>
<File
RelativePath=".\OdfFormat\number_style.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\number_style.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_number_styles_context.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\odf_number_styles_context.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_style_context.cpp"
>
......
This diff is collapsed.
This diff is collapsed.
......@@ -8,105 +8,6 @@ namespace odf {
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//class styles_container;
//class style_instance;
//typedef boost::shared_ptr<style_instance> style_instance_ptr;
//typedef boost::shared_ptr<styles_container> styles_container_ptr;
//class style_instance
//{
//public:
// style_instance(
// styles_container * Container,
// const std::wstring & Name,
// style_family::type Type,
// style_content * Content,
// bool IsAutomatic,
// bool IsDefault,
// const std::wstring & ParentStyleName,
// const std::wstring & NextStyleName,
// const std::wstring & DataStyleName
// );
//
//
// const std::wstring & name() const;
// style_family::type type() const;
// style_content * content() const;
// style_instance * parent() const;
// const std::wstring & parent_name() const;
// style_instance * next() const;
// const std::wstring & next_name() const;
// bool is_automatic() const;
// bool is_default() const;
// const styles_container * container() const { return container_; }
// const std::wstring & data_style_name() const;
//
//private:
// styles_container * container_;
// std::wstring name_;
// style_family::type style_type_;
// style_content * content_;
//
// bool is_automatic_;
// bool is_default_;
//
// std::wstring parent_name_;
// std::wstring next_name_;
// mutable style_instance * parent_;
// mutable style_instance * next_;
// std::wstring data_style_name_;
//};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//class styles_container
//{
//public:
// styles_container() : hyperlink_style_pos_(-1)
// {}
//
// typedef std::vector<style_instance_ptr> instances_array;
//
// void add_style(const std::wstring & Name,
// style_family::type Type,
// style_content * Content,
// bool IsAutomatic,
// bool IsDefault,
// const std::wstring & ParentStyleName,
// const std::wstring & NextStyleName,
// const std::wstring & DataStyleName);
//
// void add_master_page_name(const std::wstring & StyleName, const std::wstring & MasterPageName);
//
// style_instance * hyperlink_style();
// style_instance * style_by_name(const std::wstring & Name, style_family::type Type,bool object_in_styles) const;
// style_instance * style_default_by_type(style_family::type Type) const;
//
// const std::wstring master_page_name_by_name(const std::wstring & StyleName) const;
//
// instances_array & instances() { return instances_; }
//
// presentation_layouts_instance & presentation_layouts() { return presentation_layouts_; }
// presentation_masters_instance & presentation_masters() { return presentation_masters_; }
//
//private:
// //presentation_layouts_instance presentation_layouts_;
// //presentation_masters_instance presentation_masters_;
//
// instances_array instances_;
//
// typedef boost::unordered_map<std::wstring, int> map_wstring_int_t;
// map_wstring_int_t map_;
//
// typedef boost::unordered_map<std::wstring, std::wstring> map_wstring_wstring;
// map_wstring_wstring master_page_name_;
//
// typedef boost::unordered_map<style_family::type, int> map_style_family_int;
// map_style_family_int default_map_;
// int hyperlink_style_pos_;
//};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -130,7 +31,9 @@ public:
package::odf_document * output_document_;
odf_style_context & styles_context(){return style_context_;}
odf_number_styles_context & numbers_styles_context() {return style_context_.numbers_styles();}
private:
rels rels_;
......
#pragma once
#include <string>
#include <vector>
#include <boost/unordered_map.hpp>
#include "office_elements.h"
#include "office_elements_create.h"
#include "officevaluetype.h"
namespace cpdoccore {
namespace odf {
class ods_conversion_context;
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
struct number_format_state
{
int oox_num_fmt;//äåôîëòíûå (ïî äîêóìåíòàöèè - íîìåðà 0-163, çà èñêëþ÷åíèåì íåêîòîðûõ)
office_value_type::type ods_type;
std::vector<std::wstring> format_code;
std::wstring style_name;
std::wstring language_code;
std::wstring currency_str;
};
class odf_number_styles_context
{
public:
odf_number_styles_context(odf_conversion_context & Context);
number_format_state & add_or_find(int oox_num_fmt, std::wstring formatCode = L"");
void process_styles(office_element_ptr root );
private:
std::vector<number_format_state> number_format_array_;
boost::unordered_map<int, int> named_link_map_;
void create(int oox_num_fmt, std::wstring formatCode = L"");
void create_default(int oox_num_fmt, std::wstring formatCode = L"");
void create_style(number_format_state & state);
void detect_format(number_format_state & state);
////////////////
odf_conversion_context & context_;
std::vector<office_element_ptr> styles_elments;
//////////////////
void create_number_style(number_format_state & state, office_element_ptr & root_elm);
void create_currency_style(number_format_state & state, office_element_ptr & root_elm);
void create_date_style(number_format_state & state, office_element_ptr & root_elm);
void create_time_style(number_format_state & state, office_element_ptr & root_elm);
void create_boolean_style(number_format_state & state, office_element_ptr & root_elm);
void create_text_style(number_format_state & state, office_element_ptr & root_elm);
void create_percentage_style(number_format_state & state, office_element_ptr & root_elm);
};
}
}
......@@ -13,7 +13,7 @@
namespace cpdoccore {
namespace odf {
odf_style_context::odf_style_context(odf_conversion_context & Context): context_(Context)
odf_style_context::odf_style_context(odf_conversion_context & Context): context_(Context), number_styles_context_(Context)
{
}
......@@ -41,6 +41,14 @@ 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::add_style(office_element_ptr elm, bool automatic, bool root, style_family family)
{
style_state_list_.push_back( odf_style_state(elm, family) );
last_state().set_automatic(automatic);
last_state().set_root(root);
}
void odf_style_context::create_default(const style_family family)
{
office_element_ptr elm;
......@@ -91,6 +99,8 @@ void odf_style_context::process_master(office_element_ptr root )
}
void odf_style_context::process_office(office_element_ptr root )
{
number_styles_context_.process_styles(root );
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_)
......
......@@ -2,6 +2,7 @@
#include <string>
#include "odf_style_state.h"
#include "odf_number_styles_context.h"
namespace cpdoccore {
......@@ -24,6 +25,8 @@ public:
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);
void add_style(office_element_ptr elm, bool automatic = false, bool root = false, style_family style_family=style_family::None);
office_element_ptr & add_or_find(std::wstring name, const style_family family, bool automatic = false, bool root = false, int id = -1);
void process_automatic_styles(office_element_ptr root );
......@@ -42,62 +45,12 @@ public:
bool find_odf_style_state(int oox_id_style, const style_family family, odf_style_state *& state, bool root = false);
//void start_cell(const std::wstring & formula,
// size_t columnsSpanned,
// size_t rowsSpanned);
//void end_cell();
// std::wstring default_row_cell_style() const;
// std::wstring default_column_cell_style() const;
// void start_covered_cell();
// void end_covered_cell();
// void start_cell_content();
// int end_cell_content();
// void set_current_cell_style_id(unsigned int xfId);
// int get_current_cell_style_id();
// int current_column() const;
// int current_row() const;
//void set_table_row_group(int count, bool collapsed, int level);
// void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
// void non_empty_row();
// bool is_empty_row() const;
// void end_row();
// void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName);
// size_t depth() const { return table_state_stack_.size(); }
// unsigned int columns_count();
// void serialize_merge_cells(std::wostream & _Wostream);
//void serialize_table_format(std::wostream & _Wostream);
//xlsx_table_metrics & get_table_metrics();
//
//xlsx_drawing_context & get_drawing_context();
// xlsx_comments_context & get_comments_context();
//
// void table_column_last_width(double w);
// double table_column_last_width() const;
odf_style_state & last_state();
// void start_hyperlink();
//std::wstring end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display);
// void dump_rels_hyperlinks(rels & Rels);
// void serialize_hyperlinks(std::wostream & _Wostream);
odf_number_styles_context & numbers_styles() {return number_styles_context_;}
private:
odf_number_styles_context number_styles_context_;
odf_conversion_context & context_;
......
......@@ -63,6 +63,13 @@ void odf_style_state::set_parent_style_name(std::wstring & name)
style_->style_parent_style_name_ = name;
}
void odf_style_state::set_data_style_name(std::wstring & name)
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return;
style_->style_data_style_name_ = name;
}
//////////////////////////////////////////////////////////////////////
void odf_style_state::set_automatic(bool val)
{
......
......@@ -53,6 +53,7 @@ public:
int get_number_format() {return num_fmt_id_;}
void set_parent_style_name(std::wstring & name) ;
void set_data_style_name(std::wstring & name);
//////////////////////////////////////////////////////////////////////////////////////////
style_text_properties * get_text_properties();
style_paragraph_properties * get_paragraph_properties() ;
......
#include "precompiled_cpodf.h"
#include "logging.h"
#include <boost/foreach.hpp>
#include <iostream>
#include "odf_text_context.h"
#include "odf_style_context.h"
#include "odf_conversion_context.h"
#include "text_elements.h"
#include "paragraph_elements.h"
namespace cpdoccore {
namespace odf
{
odf_text_context::odf_text_context(odf_style_context * styles_context,odf_conversion_context *odf_context)
{
styles_context_ = styles_context;
odf_context_ = odf_context;
last_paragraph_ = NULL;
}
odf_text_context::~odf_text_context()
{
}
void odf_text_context::set_styles_context(odf_style_context* styles_context)
{
styles_context_ = styles_context;
}
void odf_text_context::add_text_content(const std::wstring & text)
{
if (current_level_.size() >=0 )
current_level_.back()->add_text(text);
else
{
}
}
void odf_text_context::start_paragraph(office_element_ptr & elm)
{
office_element_ptr style;
int level = current_level_.size();
odf_text_state state={elm,L"", style,level};
text_elements_list_.push_back(state);
if (current_level_.size()>0)
current_level_.back()->add_child_element(elm);
current_level_.push_back(elm);
//text_p *text_p_ = dynamic_cast<text_p*>(elm.get());
//if (text_p_ == NULL)return;
//
//paragraph *new_paragraph = &(text_p_->paragraph_);
//if (last_paragraph_)
// last_paragraph_->set_next(new_paragraph);
//new_paragraph->set_prev(last_paragraph_);
//last_paragraph_ = new_paragraph;
}
void odf_text_context::end_paragraph()
{
current_level_.pop_back();
}
void odf_text_context::start_element(office_element_ptr & elm)
{
int level = current_level_.size();
odf_text_state state={elm, L"", office_element_ptr(), level};
text_elements_list_.push_back(state);
if (current_level_.size()>0)
current_level_.back()->add_child_element(elm);
current_level_.push_back(elm);
}
void odf_text_context::end_element()
{
current_level_.pop_back();
}
void odf_text_context::start_span()// -
{
if (styles_context_ == NULL)return;
office_element_ptr span_elm;
create_element(L"text", L"span", span_elm, odf_context_);
text_span* span = dynamic_cast<text_span*>(span_elm.get());
if (span == NULL)return;
span->text_style_name_ = style_ref(styles_context_->last_state().get_name());
int level = current_level_.size();
odf_text_state state={ span_elm,
styles_context_->last_state().get_name(),
styles_context_->last_state().get_office_element(),
level};
text_elements_list_.push_back(state);
if (current_level_.size()>0)
current_level_.back()->add_child_element(span_elm);
current_level_.push_back(span_elm);
}
void odf_text_context::end_span()
{
current_level_.pop_back();
}
}
}
\ No newline at end of file
#pragma once
#include <string>
#include <vector>
//
//#include "ods_drawing_context.h"
//#include "ods_comments_context.h"
//#include "ods_hyperlinks.h"
#include "office_elements.h"
#include "office_elements_create.h"
namespace cpdoccore {
namespace odf
{
class odf_conversion_context;
class odf_style_context;
class paragraph;
struct odf_text_state
{
office_element_ptr elm;
std::wstring style_name;
office_element_ptr style_elm;
int level;
};
class odf_text_context: boost::noncopyable
{
public:
odf_text_context(odf_style_context * styles_context_,odf_conversion_context *odf_context);
~odf_text_context();
public:
void set_styles_context(odf_style_context* styles_context);// embedded
void add_text_content(const std::wstring & text);
void start_paragraph(office_element_ptr & elm);
void end_paragraph();
void start_element(office_element_ptr & elm); // t, h, list???
void end_element();
void start_span();
void end_span();
std::vector<office_element_ptr> current_level_;//
std::vector<odf_text_state> text_elements_list_;//, , ... - ( ?? + ????
private:
paragraph * last_paragraph_;
odf_style_context * styles_context_;
odf_conversion_context *odf_context_;
};
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ namespace odf {
ods_conversion_context::ods_conversion_context(package::odf_document * outputDocument)
: odf_conversion_context(outputDocument), ods_table_context_(*this), current_text_context_(NULL)
: odf_conversion_context(outputDocument), table_context_(*this), current_text_context_(NULL)
{
}
......@@ -32,13 +32,13 @@ void ods_conversion_context::start_sheet(std::wstring & name)
{
create_element(L"table", L"table",current_spreadsheet_->getContent(),this);
ods_table_context_.start_table(current_spreadsheet_->getContent().back(),name);
table_context_.start_table(current_spreadsheet_->getContent().back(),name);
}
void ods_conversion_context::end_sheet()
{
ods_table_context_.end_table();
table_context_.end_table();
styles_context().reset_defaults();
}
......@@ -230,9 +230,10 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
}
office_element_ptr style_elm;
int number_format =0;
std::wstring style_cell_name;
office_value_type::type format_value_type = office_value_type::Custom;
if ( xfd_style >=0)
{
odf_style_state *style_state=NULL;
......@@ -240,8 +241,11 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
if (style_state)
{
style_elm = style_state->get_office_element();
number_format = style_state->get_number_format();
style_cell_name = style_state->get_name();
int number_format = style_state->get_number_format();//oox
if (number_format >0)
format_value_type = numbers_styles_context().add_or_find(number_format).ods_type;
}
else
{//error
......@@ -253,7 +257,7 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
current_table().start_cell(cell_elm, style_elm);
current_table().set_cell_format_value(number_format);
current_table().set_cell_format_value(format_value_type);
}
void ods_conversion_context::start_columns()
......
......@@ -38,7 +38,7 @@ public:
void add_merge_cells(std::wstring & ref);
void add_hyperlink(std::wstring & ref, std::wstring & link, std::wstring & display);
///////////////////////////////////////////////////////
ods_table_state & current_table() { return ods_table_context_.state();}
ods_table_state & current_table() { return table_context_.state();}
odf_text_context* current_text_context(){return current_text_context_;}
/////////////////////////////////////////////////////
......@@ -46,11 +46,11 @@ public:
void end_text_context();
private:
ods_table_context ods_table_context_;
ods_table_context table_context_;
odf_text_context* current_text_context_;
office_spreadsheet* current_spreadsheet_;
odf_text_context* current_text_context_;
office_spreadsheet* current_spreadsheet_;
};
......
......@@ -266,32 +266,7 @@ ods_hyperlink_state & ods_table_state::current_hyperlink()
{
}
}
office_value_type::type oox_valuetype_2_odf(int oox_fmt)
{
switch (oox_fmt)
{
case 2:
case 3:
case 4:
return office_value_type::Float;
case 9:
case 10:
return office_value_type::Percentage;
case 14:
case 15:
case 16:
case 17:
return office_value_type::Date;
case 18:
case 19:
return office_value_type::Time;
case 49:
return office_value_type::String;
case 0://general
default:
return office_value_type::String;
}
}
void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr & style_elm)
{
current_row_element()->add_child_element(elm);
......@@ -319,16 +294,16 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
cells_.push_back(state);
}
void ods_table_state::set_cell_format_value(int format_value)
void ods_table_state::set_cell_format_value(office_value_type::type value_type)
{
if (cells_.size() < 1)return;
if (format_value == 0)return; //general .. need detect
if (value_type == office_value_type::Custom)return; //general .. need detect
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
common_value_and_type_attlist cell_type;
cell_type.office_value_type_ = office_value_type(oox_valuetype_2_odf(format_value));
cell_type.office_value_type_ = office_value_type(value_type);
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = cell_type;
......@@ -343,13 +318,16 @@ void ods_table_state::set_cell_type(int type)
_CP_OPT(office_value_type) cell_type;
switch (type)
{
case 0: //cell_type = office_value_type(office_value_type::Boolean);
case 0: cell_type = office_value_type(office_value_type::Boolean);
break;
case 1: cell_type = office_value_type(office_value_type::Date);
break;
case 4: cell_type = office_value_type(office_value_type::Float);
break;
case 3:
case 5:
case 6:
case 2:// error-type
case 3:// inline
case 5:// shared
case 6://
cell_type = office_value_type(office_value_type::String);
break;
}
......@@ -361,6 +339,10 @@ void ods_table_state::set_cell_type(int type)
}
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
}
else
{
// - - numFmt
}
}
void ods_table_state::add_hyperlink(std::wstring & ref,int col, int row, std::wstring & link)
{
......@@ -450,7 +432,6 @@ void ods_table_state::set_cell_value(std::wstring & value)
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_time_value_ = value;
break;
case office_value_type::Currency:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_currency_ = value;//
default:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_ = value;
}
......
......@@ -12,6 +12,8 @@
#include "office_elements.h"
#include "office_elements_create.h"
#include "officevaluetype.h"
namespace cpdoccore {
namespace odf {
......@@ -79,7 +81,7 @@ public:
void end_cell();
void add_default_cell(office_element_ptr & cell, int repeated);
void set_cell_format_value(int format);
void set_cell_format_value(office_value_type::type value_type);
void set_cell_type(int type);
void set_cell_value(std::wstring & value);
......
......@@ -224,7 +224,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
ods_context->start_cell(ref,ifx_style);
int value_type = 0;//general
int value_type = -1;//not defined
if (oox_cell->m_oType.IsInit())
{
value_type = oox_cell->m_oType->GetValue();
......@@ -518,24 +518,27 @@ void XlsxConverter::convert_styles()
if (!xlsx_styles)return;
if (!xlsx_styles->m_oCellStyleXfs.IsInit())return;
for (long i=0; xlsx_styles->m_oNumFmts.IsInit() && i< xlsx_styles->m_oNumFmts->m_oCount->GetValue(); i++)//in styles record
{
convert(xlsx_styles->m_oNumFmts->m_arrItems[i]);
}
for (long i=0;i< xlsx_styles->m_oCellStyleXfs->m_oCount->GetValue(); i++)//in styles record
for (long i=0; xlsx_styles->m_oCellStyleXfs.IsInit() && i< xlsx_styles->m_oCellStyleXfs->m_oCount->GetValue(); i++)//in styles record
{
convert(xlsx_styles->m_oCellStyleXfs->m_arrItems[i] , i, false, true);
convert(xlsx_styles->m_oCellStyleXfs->m_arrItems[i] , i, false, true);// ""
}
///////////////////////////////////
for (long i=0;i< xlsx_styles->m_oCellXfs->m_oCount->GetValue(); i++)
for (long i=0; xlsx_styles->m_oCellXfs.IsInit() && i< xlsx_styles->m_oCellXfs->m_oCount->GetValue(); i++)
{
convert(xlsx_styles->m_oCellXfs->m_arrItems[i],i, true,false);
}
for (long i=0;i< xlsx_styles->m_oCellStyles->m_oCount->GetValue(); i++)//styles.xml
for (long i=0; xlsx_styles->m_oCellStyles.IsInit() && i< xlsx_styles->m_oCellStyles->m_oCount->GetValue(); i++)//styles.xml
{
// 1 .. , , ...
//
convert(xlsx_styles->m_oCellStyles->m_arrItems[i],i);
convert(xlsx_styles->m_oCellStyles->m_arrItems[i],i); //
}
}
......@@ -631,11 +634,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::backgr
if (odf_color)odf_bckgrd_color = odf::background_color(odf_color.get());
}
void XlsxConverter::convert(OOX::Spreadsheet::CNumFmt *numFmt, odf::style_table_cell_properties * cell_properties)
void XlsxConverter::convert(OOX::Spreadsheet::CNumFmt *numFmt)
{
if (!numFmt)return;
if (numFmt->m_oFormatCode.IsInit() && numFmt->m_oNumFmtId.IsInit())
{
ods_context->numbers_styles_context().add_or_find(numFmt->m_oNumFmtId->GetValue(), string2std_string(numFmt->m_oFormatCode.get()));
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CBorder *border, odf::style_table_cell_properties * cell_properties)
{
......@@ -761,10 +767,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
{
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
int id_parent = xfc_style->m_oXfId.IsInit() ? xfc_style->m_oXfId->GetValue() : -1; //parent
int fill_id = xfc_style->m_oFillId.IsInit() ? xfc_style->m_oFillId->GetValue() : -1;
int numFmt_id = xfc_style->m_oNumFmtId.IsInit() ? xfc_style->m_oNumFmtId->GetValue(): 0; //general
int font_id = xfc_style->m_oFontId.IsInit() ? xfc_style->m_oFontId->GetValue() : -1;
int id_parent = xfc_style->m_oXfId.IsInit() ? xfc_style->m_oXfId->GetValue() : -1;
int fill_id = xfc_style->m_oFillId.IsInit() ? xfc_style->m_oFillId->GetValue() : -1;
int numFmt_id = xfc_style->m_oNumFmtId.IsInit() ? xfc_style->m_oNumFmtId->GetValue(): -1;
int font_id = xfc_style->m_oFontId.IsInit() ? xfc_style->m_oFontId->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);
......@@ -780,32 +786,40 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
{
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 (numFmt_id>=0/* && (id_parent < 0 || xfc_style->m_oApplyNumberFormat.IsInit())*/)
{
//if (numFmt_id < xlsx_styles->m_oNumFmts.Count())
//{
// convert(xlsx_styles->m_oNumFmts->m_arrItems[numFmt_id], elm_style);
//}
// .. .. ..
ods_context->styles_context().last_state().set_data_style_name(ods_context->numbers_styles_context().add_or_find(numFmt_id).style_name);
ods_context->styles_context().last_state().set_number_format(numFmt_id);
}
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], table_cell_properties);
}
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);
//table_cell_properties->style_table_cell_properties_attlist_.style_text_align_source_ = odf::text_align_source(odf::text_align_source::Fix);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (id_parent >=0)
{
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::odf_style_state *parent_style_state=NULL;
ods_context->styles_context().find_odf_style_state(id_parent, odf::style_family::TableCell,parent_style_state );
if (parent_style_state)
{
ods_context->styles_context().last_state().set_parent_style_name(parent_style_state->get_name());
if (numFmt_id < 0)
{
ods_context->styles_context().last_state().set_number_format(parent_style_state->get_number_format());
}
}
}
}
} // namespace Docx2Odt
\ No newline at end of file
......@@ -75,17 +75,15 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CRPr *oox_text_pr);
void convert(OOX::Spreadsheet::CText *oox_text);
void convert(OOX::Spreadsheet::CFormula *oox_formula);
void convert(OOX::Spreadsheet::CHyperlink *oox_hyperlink,OOX::Spreadsheet::CWorksheet *oox_sheet);
void convert(OOX::Spreadsheet::CFormula *oox_formula);
void convert(OOX::Spreadsheet::CHyperlink *oox_hyperlink, OOX::Spreadsheet::CWorksheet *oox_sheet);
void convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_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::CNumFmt *numFmt, odf::style_table_cell_properties * cell_properties);
void convert(OOX::Spreadsheet::CBorder *border, odf::style_table_cell_properties * cell_properties);
void convert(OOX::Spreadsheet::CFill *fill, odf::style_table_cell_properties * cell_properties);
void convert(OOX::Spreadsheet::CFont *font, odf::style_text_properties *text_properties);
void convert(OOX::Spreadsheet::CBorder *border, odf::style_table_cell_properties *cell_properties);
void convert(OOX::Spreadsheet::CFill *fill, odf::style_table_cell_properties *cell_properties);
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);
......@@ -93,8 +91,9 @@ namespace Oox2Odf
void convert(double oox_font_size, _CP_OPT(odf::font_size) & odf_font_size);
void convert(double oox_size, _CP_OPT(odf::length) & odf_size);
void convert(OOX::Spreadsheet::CXfs * cell_style, int oox_id, bool automatic=true, bool root = false);
void convert(OOX::Spreadsheet::CCellStyle * cell_style, int oox_id);
void convert(OOX::Spreadsheet::CXfs *cell_style, int oox_id, bool automatic=true, bool root = false);
void convert(OOX::Spreadsheet::CCellStyle *cell_style, int oox_id);
void convert(OOX::Spreadsheet::CNumFmt *numFmt);
void convert_sharing_string(int number);
};
......
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