Commit 811446bb 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@55075 954022d7-b5bf-4e40-9824-e11837661b57
parent 07f6a35e
......@@ -748,6 +748,14 @@
RelativePath=".\src\odf\datatypes\odfattributes.h"
>
</File>
<File
RelativePath=".\src\odf\datatypes\officevaluetype.cpp"
>
</File>
<File
RelativePath=".\src\odf\datatypes\officevaluetype.h"
>
</File>
<File
RelativePath=".\src\odf\datatypes\pageusage.cpp"
>
......
......@@ -31,34 +31,23 @@ void xlsx_cell_format::set_num_format(int numFmt)
namespace {
struct odf2buildin
int odf2buildin_map[] = {0,0,0,10,15,21,0,49};
//{
// {L"", 0},
// {L"float", 0},
// {L"currency", 0},
// {L"percentage", 10},
// {L"date", 15},
// {L"time", 21},
// {L"boolean", 0},
// {L"string", 49}
//};
//
}
int odf_string_to_build_in(const int odf_type_value)
{
std::wstring odf_string;
int build_in;
};
odf2buildin odf2buildin_map[] =
{
{L"", 0},
{L"float", 0},
{L"percentage", 10},
{L"currency", 0},
{L"date", 15},
{L"time", 21},
{L"boolean", 0},
{L"string", 49}
};
}
int odf_string_to_build_in(const std::wstring & odf_string)
{
BOOST_FOREACH(const odf2buildin & elm, odf2buildin_map)
{
if (elm.odf_string == odf_string)
return elm.build_in;
}
return 0;
return odf2buildin_map[odf_type_value];
}
}
......
......@@ -9,7 +9,7 @@ struct XlsxCellType
enum type { null, b, n, e, s, str, inlineStr };
};
int odf_string_to_build_in(const std::wstring & odf_string);
int odf_string_to_build_in(const int value_type);
class xlsx_cell_format
{
......
......@@ -71,7 +71,7 @@ void xlsx_conversion_context::start_document()
oox::xlsx_cell_format cellFormat;
cellFormat.set_cell_type(XlsxCellType::s);
cellFormat.set_num_format(oox::odf_string_to_build_in(L""));
cellFormat.set_num_format(oox::odf_string_to_build_in(0));
default_style_ = get_style_manager().xfId(&textFormatProperties, &parFormatProperties, &cellFormatProperties, &cellFormat, L"",true);
......
......@@ -274,15 +274,13 @@ void common_xlink_attlist::serialize(CP_ATTR_NODE)
CP_XML_ATTR_OPT(L"xlink:href", href_);
CP_XML_ATTR_OPT(L"xlink:type", type_);
CP_XML_ATTR_OPT(L"xlink:show", show_);
CP_XML_ATTR_OPT(L"xlink:actuate", actuate_);
CP_XML_ATTR_OPT(L"xlink:actuate", actuate_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
bool common_value_and_type_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
if (!CP_APPLY_ATTR(L"office:value-type", office_value_type_, std::wstring(L"") ))
return false;
CP_APPLY_ATTR(L"office:value-type", office_value_type_);
CP_APPLY_ATTR(L"office:value", office_value_);
CP_APPLY_ATTR(L"office:currency", office_currency_);
CP_APPLY_ATTR(L"office:date-value", office_date_value_);
......@@ -293,7 +291,7 @@ bool common_value_and_type_attlist::add_attributes( const xml::attributes_wc_ptr
}
void common_value_and_type_attlist::apply_from(const common_value_and_type_attlist & Other)
{
office_value_type_ = Other.office_value_type_;
_CP_APPLY_PROP(office_value_type_ , Other.office_value_type_);
_CP_APPLY_PROP(office_value_, Other.office_value_);
_CP_APPLY_PROP(office_currency_, Other.office_currency_);
_CP_APPLY_PROP(office_date_value_, Other.office_date_value_);
......@@ -303,8 +301,7 @@ 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(L"office:value-type", office_value_type_);
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_);
CP_XML_ATTR_OPT(L"office:date-value", office_date_value_);
......
......@@ -26,6 +26,7 @@
#include "drawfill.h"
#include "clockvalue.h"
#include "stylerepeat.h"
#include "officevaluetype.h"
#define _CP_APPLY_PROP(A, B) \
if (B) \
......@@ -210,7 +211,7 @@ public:
void serialize(CP_ATTR_NODE);
public:
std::wstring office_value_type_;
_CP_OPT(office_value_type) office_value_type_;
_CP_OPT(std::wstring) office_value_;
_CP_OPT(std::wstring) office_currency_;
_CP_OPT(std::wstring) office_date_value_;
......
#include "precompiled_cpodf.h"
#include "officevaluetype.h"
#include "errors.h"
namespace cpdoccore { namespace odf {
std::wostream & operator << (std::wostream & _Wostream, const office_value_type & _Val)
{
switch(_Val.get_type())
{
case office_value_type::Custom:
//_Wostream << "none";
break;
case office_value_type::Float:
_Wostream << "float";
break;
case office_value_type::Currency:
_Wostream << "currency";
break;
case office_value_type::Percentage:
_Wostream << "percentage";
break;
case office_value_type::Date:
_Wostream << "date";
break;
case office_value_type::Time:
_Wostream << "time";
break;
case office_value_type::Boolean:
_Wostream << "boolean";
break;
case office_value_type::String:
_Wostream << "string";
break;
default:
break;
}
return _Wostream;
}
office_value_type office_value_type::parse(const std::wstring & Str)
{
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"float")
return office_value_type( Float);
else if (tmp == L"currency")
return office_value_type( Currency );
else if (tmp == L"percentage")
return office_value_type( Percentage );
else if (tmp == L"boolean")
return office_value_type( Boolean );
else if (tmp == L"date")
return office_value_type( Date );
else if (tmp == L"time")
return office_value_type( Time );
else if (tmp == L"string")
return office_value_type( String );
else
return office_value_type(Custom);
}
} }
#pragma once
#include <string>
#include <iosfwd>
#include "odfattributes.h"
namespace cpdoccore { namespace odf {
class office_value_type
{
public:
enum type
{
Custom,
Float,
Currency,
Percentage,
Date,
Time,
Boolean,
String
};
office_value_type() {type_ = String;}
office_value_type(type _Type) : type_(_Type)
{}
type get_type() const
{
return type_;
};
static office_value_type parse(const std::wstring & Str);
private:
type type_;
};
std::wostream & operator << (std::wostream & _Wostream, const office_value_type & _Val);
}
APPLY_PARSE_XML_ATTRIBUTES(odf::office_value_type);
}
\ No newline at end of file
......@@ -590,28 +590,28 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wstring number_val = L"";
_CP_OPT(bool) bool_val;
std::wstring value_type;
int odf_value_type=0;
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_;
value_type = attr.office_value_type_;
if (L"float" == value_type)
odf_value_type = attr.office_value_type_->get_type();
if (attr.office_value_type_->get_type() == office_value_type::Float)
{
t_val = XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if (L"percentage" == value_type)
else if (attr.office_value_type_->get_type() == office_value_type::Percentage)
{
t_val = XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if (L"currency" == value_type)
else if (attr.office_value_type_->get_type() == office_value_type::Currency)
{
t_val = XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if (L"date" == value_type)
else if (attr.office_value_type_->get_type() == office_value_type::Date)
{
t_val = XlsxCellType::n;
if (attr.office_date_value_)
......@@ -623,7 +623,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
}
}
}
else if (L"time" == value_type)
else if (attr.office_value_type_->get_type() == office_value_type::Time)
{
t_val = XlsxCellType::n;
if (attr.office_time_value_)
......@@ -637,13 +637,13 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
}
}
}
else if (L"boolean" == value_type)
else if (attr.office_value_type_->get_type() == office_value_type::Boolean)
{
t_val = XlsxCellType::b;
if (attr.office_boolean_value_)
bool_val = oox::parseBoolVal(attr.office_boolean_value_.get());
}
else if (L"string" == value_type)
else if (attr.office_value_type_->get_type() == office_value_type::String)
{
t_val = XlsxCellType::s;
}
......@@ -692,7 +692,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
oox::xlsx_cell_format cellFormat;
cellFormat.set_cell_type(t_val);
cellFormat.set_num_format(oox::odf_string_to_build_in(value_type));
cellFormat.set_num_format(oox::odf_string_to_build_in(odf_value_type));
is_style_visible = true;
......
......@@ -502,6 +502,14 @@
RelativePath="..\..\ASCOfficeOdfFile\src\odf\datatypes\noteclass.h"
>
</File>
<File
RelativePath="..\..\ASCOfficeOdfFile\src\odf\datatypes\officevaluetype.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeOdfFile\src\odf\datatypes\officevaluetype.h"
>
</File>
<File
RelativePath="..\..\ASCOfficeOdfFile\src\odf\datatypes\pageusage.cpp"
>
......
......@@ -21,16 +21,8 @@ odf_style_state & odf_style_context::last_state()
{
return style_state_list_.back();
}
const odf_style_state & odf_style_context::last_state() const
{
return style_state_list_.back();
}
void odf_style_context::create_style(std::wstring oox_name,const style_family family, bool automatic,bool root,int oox_id)
{
if (oox_id < 0) oox_id = style_state_list_.size();
std::wstring odf_name = oox_name;
if (odf_name.length() <1)odf_name = find_free_name(family);
......@@ -38,7 +30,7 @@ void odf_style_context::create_style(std::wstring oox_name,const style_family fa
office_element_ptr elm;
create_element(L"style", L"style", elm, &context_);
style_state_list_.push_back( odf_style_state(context_, elm, family) );
style_state_list_.push_back( odf_style_state(/*context_, */elm, family) );
///////////////////////////////////////
last_state().set_name(odf_name);
......@@ -48,46 +40,52 @@ void odf_style_context::create_style(std::wstring oox_name,const style_family fa
last_state().style_oox_id_ = oox_id;
last_state().style_oox_name_ = oox_name;
}
void odf_style_context::process_automatic_styles(office_element_ptr root )
{//
for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (long i =0; i < style_state_list_.size(); i++)
{
if (it->automatic_== true && it->root_== true && it->odf_style_)
root->add_child_element(it->odf_style_);
if (style_state_list_[i].automatic_== true && style_state_list_[i].root_== true && style_state_list_[i].odf_style_)
root->add_child_element(style_state_list_[i].odf_style_);
}
}
void odf_style_context::process_automatic(office_element_ptr root )
{//
for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (long i =0; i < style_state_list_.size(); i++)
{
if (/*it->automatic_== true && */it->root_== false && it->odf_style_)
root->add_child_element(it->odf_style_);
if (/*it->automatic_== true && */style_state_list_[i].root_== false && style_state_list_[i].odf_style_)
root->add_child_element(style_state_list_[i].odf_style_);
}
}
void odf_style_context::process_master(office_element_ptr root )
{
for (std::list<odf_style_state>::iterator it = master_state_list_.begin(); it != master_state_list_.end(); it++)
//for (std::list<odf_style_state>::iterator it = master_state_list_.begin(); it != master_state_list_.end(); it++)
for (long i =0; i < master_state_list_.size(); i++)
{
root->add_child_element(it->odf_style_);
root->add_child_element(master_state_list_[i].odf_style_);
}
}
void odf_style_context::process_office(office_element_ptr root )
{
for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (long i =0; i < style_state_list_.size(); i++)
{
if (it->automatic_== false && it->root_ == true && it->odf_style_)
root->add_child_element(it->odf_style_);
if (style_state_list_[i].automatic_== false && style_state_list_[i].root_ == true && style_state_list_[i].odf_style_)
root->add_child_element(style_state_list_[i].odf_style_);
}
}
std::wstring odf_style_context::find_odf_style_name(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++)
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (long i =0; i < style_state_list_.size(); i++)
{
if (it->odf_style_)
if (style_state_list_[i].odf_style_)
{
if (it->style_family_ == family)
if (style_state_list_[i].style_family_ == family)
{
if (oox_id_style >=0 && it->style_oox_id_ == oox_id_style) return it->get_name();
if (oox_id_style >=0 && style_state_list_[i].style_oox_id_ == oox_id_style) return style_state_list_[i].get_name();
}
}
......@@ -96,27 +94,48 @@ std::wstring odf_style_context::find_odf_style_name(int oox_id_style, const styl
}
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++)
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (int i=0;i<style_state_list_.size(); i++)
{
if (it->odf_style_)
if (style_state_list_[i].odf_style_)
{
if (it->style_family_ == family)
if (style_state_list_[i].style_family_ == family)
{
if (oox_id_style >=0 && it->style_oox_id_ == oox_id_style) return it->get_office_element();
if (oox_id_style >=0 && style_state_list_[i].style_oox_id_ == oox_id_style) return style_state_list_[i].get_office_element();
}
}
}
return office_element_ptr();
}
bool odf_style_context::find_odf_style_state(int oox_id_style, const style_family family, odf_style_state *& state)
{
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (int i=0;i<style_state_list_.size(); i++)
{
if (style_state_list_[i].odf_style_)
{
if (style_state_list_[i].style_family_ == family)
{
if (oox_id_style >=0 && style_state_list_[i].style_oox_id_ == oox_id_style)
{
state = &style_state_list_[i];
return true;
}
}
}
}
return false;
}
office_element_ptr odf_style_context::find_odf_style_default(const style_family family)
{
for (std::list<odf_style_state>::iterator it = default_styles_.begin(); it != default_styles_.end(); it++)
//for (std::list<odf_style_state>::iterator it = default_styles_.begin(); it != default_styles_.end(); it++)
for (int i=0;i<default_styles_.size(); i++)
{
if (it->odf_style_)
if (style_state_list_[i].odf_style_)
{
if (it->style_family_ == family)return it->get_office_element();
if (style_state_list_[i].style_family_ == family)return default_styles_[i].get_office_element();
}
}
return office_element_ptr();
......@@ -149,9 +168,10 @@ std::wstring odf_style_context::find_free_name(const style_family & family)
std::wstring name = get_name_family(family);
int count =1;
for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (int i=0;i<style_state_list_.size(); i++)
{
if ((it->odf_style_) && (it->style_family_ == family))
if ((style_state_list_[i].odf_style_) && (style_state_list_[i].style_family_ == family))
{
count++;
}
......@@ -161,14 +181,16 @@ std::wstring odf_style_context::find_free_name(const style_family & family)
}
office_element_ptr & odf_style_context::add_or_find(std::wstring name, const style_family family, bool automatic , bool root, int oox_id)
{
for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (int i=0;i<style_state_list_.size(); i++)
{
if (it->odf_style_)
if (style_state_list_[i].odf_style_)
{
if (it->style_family_ == family)
if (style_state_list_[i].style_family_ == family)
{
if (oox_id >=0 && it->style_oox_id_ == oox_id) return it->get_office_element();
if ((name.length() >=0 && it->odf_style_->get_name() == name) && it->root_ == root) return it->get_office_element();
if (oox_id >=0 && style_state_list_[i].style_oox_id_ == oox_id) return style_state_list_[i].get_office_element();
if ((name.length() >=0 && style_state_list_[i].odf_style_->get_name() == name)
&& style_state_list_[i].root_ == root) return style_state_list_[i].get_office_element();
// ( root - )
}
......
......@@ -36,6 +36,8 @@ public:
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);
office_element_ptr find_odf_style_default (const style_family family);
bool find_odf_style_state(int oox_id_style, const style_family family, odf_style_state *& state);
//void start_cell(const std::wstring & formula,
......@@ -85,7 +87,6 @@ public:
// double table_column_last_width() const;
odf_style_state & last_state();
const odf_style_state & last_state() const;
// void start_hyperlink();
//std::wstring end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display);
......@@ -97,11 +98,11 @@ private:
odf_conversion_context & context_;
std::list<odf_style_state> style_state_list_;
std::vector<odf_style_state> style_state_list_;
std::list<odf_style_state> default_styles_;// ..
std::vector<odf_style_state> default_styles_;// ..
std::list<odf_style_state> master_state_list_;
std::vector<odf_style_state> master_state_list_;
std::wstring get_name_family(const style_family & family);
std::wstring find_free_name(const style_family & family);
......
......@@ -9,10 +9,11 @@
namespace cpdoccore {
namespace odf {
odf_style_state::odf_style_state(odf_conversion_context & Context, office_element_ptr & elm, const style_family family ): context_(Context)
odf_style_state::odf_style_state(/*odf_conversion_context & Context, */office_element_ptr & elm, const style_family family )/*: context_(Context)*/
{
odf_style_ = elm;
automatic_= false;
num_fmt_id_ =0;
style* style_ = dynamic_cast<style*>(elm.get());
if (!style_)return;
......
......@@ -26,7 +26,7 @@ class odf_style_context;
class odf_style_state
{
public:
odf_style_state(odf_conversion_context & Context, office_element_ptr & elm, const style_family style_family );
odf_style_state(/*odf_conversion_context & Context, */office_element_ptr & elm, const style_family style_family );
void set_name(std::wstring);
......@@ -40,11 +40,17 @@ public:
office_element_ptr & get_office_element();
void add_child(office_element_ptr & child);
void set_number_format(int id) {num_fmt_id_ = id;}
int get_number_format() {return num_fmt_id_;}
private:
int style_oox_id_;
std::wstring style_oox_name_;
//
int style_oox_id_;
int num_fmt_id_; //default =0 (general)
///////
bool automatic_;
bool root_;
......@@ -52,7 +58,7 @@ private:
office_element_ptr odf_style_;
odf_conversion_context & context_;
//odf_conversion_context & context_;
friend class odf_style_context;
};
......
......@@ -150,9 +150,16 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
}
office_element_ptr style_elm;
int number_format =0;
if ( xfd_style >=0)
{
style_elm = styles_context().find_odf_style(xfd_style, style_family::TableCell);
odf_style_state *style_state=NULL;
styles_context().find_odf_style_state(xfd_style, style_family::TableCell,style_state);
if (style_state)
{
style_elm = style_state->get_office_element();
number_format = style_state->get_number_format();
}
}
office_element_ptr cell_elm;
......@@ -160,6 +167,8 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
ods_table_context_.state().start_cell(cell_elm, style_elm);
ods_table_context_.state().set_cell_ref(ref,col,row);
ods_table_context_.state().set_cell_format_value(number_format);
}
void ods_conversion_context::start_columns()
......
......@@ -188,7 +188,40 @@ office_element_ptr & ods_table_state::current_row_element()
{
}
}
office_element_ptr & ods_table_state::current_cell_element()
{
if (cells_.size()>0)
return cells_.back().elm;
else
{
}
}
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);
......@@ -196,12 +229,128 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
table_table_cell* cell = dynamic_cast<table_table_cell*>(elm.get());
if (cell == NULL)return;
odf::style* style = dynamic_cast<odf::style*>(rows_.back().style_elm.get());
if (style)
std::wstring style_name;
odf::style* style = dynamic_cast<odf::style*>(style_elm.get());
if (style)style_name = style->style_name_;
if (style) cell->table_table_cell_attlist_.table_style_name_= style_name;
ods_cell_state state;
state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm;
state.row=0; state.col =0;
cells_.push_back(state);
}
void ods_table_state::set_cell_format_value(int format_value)
{
if (cells_.size() < 1)return;
if (format_value == 0)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->table_table_cell_attlist_.common_value_and_type_attlist_ = cell_type;
}
void ods_table_state::set_cell_type(int type)
{
if (cells_.size() < 1)return;
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
_CP_OPT(office_value_type) cell_type;
switch (type)
{
case 0: cell_type = office_value_type(office_value_type::Boolean);
break;
case 4: cell_type = office_value_type(office_value_type::Float);
break;
case 3:
case 5:
case 6:
cell_type = office_value_type(office_value_type::String);
break;
}
if (cell_type)
{
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
}
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
}
}
void ods_table_state::set_cell_value(std::wstring & value)
{
if (cells_.size() < 1)return;
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::Float);
//...
}
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_)
{
cell->table_table_cell_attlist_.table_style_name_= style->style_name_;
switch(cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type())
{
case office_value_type::String:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_string_value_ = value;
break;
case office_value_type::Boolean:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_boolean_value_ = value;
break;
case office_value_type::Date:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_date_value_ = value;
break;
case office_value_type::Time:
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;
}
}
else
{
//general !!
}
//
//start_text()
//start_paragraph();
office_element_ptr text_elm;
create_element(L"text", L"p",text_elm, &context_);
cells_.back().elm->add_child_element(text_elm);
//table_table_cell* cell = dynamic_cast<text_p*>(text_elm.get());
//end_paragraph();
//end_text();
}
void ods_table_state::set_cell_ref (std::wstring & ref, int col, int row)
{
if (cells_.size() < 1)return;
cells_.back().ref = ref;
cells_.back().col = col;
cells_.back().row = row;
}
void ods_table_state::end_cell()
{
......
......@@ -29,6 +29,13 @@ struct ods_element_state
office_element_ptr style_elm;
};
struct ods_cell_state : ods_element_state
{
std::wstring ref;
int col;
int row;
};
class ods_table_state
{
public:
......@@ -47,20 +54,25 @@ public:
//void set_row_collapsed(bool Val);
void set_row_optimal_height(bool val);
void set_row_height(double height);
//void set_table_row_group(int count, bool collapsed, int level);
void set_row_default_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*/);
void start_cell(office_element_ptr & elm ,office_element_ptr & style);
void end_cell();
void add_default_cell(office_element_ptr & cell, int repeated);
void start_cell(office_element_ptr & elm ,office_element_ptr & style);
office_element_ptr & current_row_element();
void set_cell_ref (std::wstring & ref, int col, int row);
void set_cell_format_value(int format);
void set_cell_type(int type);
void set_cell_value(std::wstring & value);
// void start_covered_cell();
// void end_covered_cell();
office_element_ptr & current_row_element();
office_element_ptr & current_cell_element();
// void set_current_cell_style_id(unsigned int xfId);
// int get_current_cell_style_id();
......@@ -114,6 +126,8 @@ private:
// std::vector<xlsx_row_spanned> rows_spanned_;
std::vector<ods_element_state> columns_;
std::vector<ods_element_state> rows_;
std::vector<ods_cell_state> cells_;
unsigned int columns_count_;
// xlsx_merge_cells merge_cells_;
// xlsx_table_metrics xlsx_table_metrics_;
......
......@@ -33,26 +33,25 @@ public:
void serialize(std::wostream & strm ,const wchar_t * ns, const wchar_t * name );
private:
optional<length>::Type style_width_;
optional<percent>::Type style_rel_width_;
optional<table_align>::Type table_align_;
_CP_OPT(length) style_width_;
_CP_OPT(percent) style_rel_width_;
_CP_OPT(bool) style_may_break_between_rows_;
_CP_OPT(border_model) table_border_model_;
_CP_OPT(bool) table_display_;
_CP_OPT(table_align) table_align_;
common_horizontal_margin_attlist common_horizontal_margin_attlist_;
common_vertical_margin_attlist common_vertical_margin_attlist_;
common_margin_attlist common_margin_attlist_;
common_page_number_attlist common_page_number_attlist_;
common_break_attlist common_break_attlist_;
common_background_color_attlist common_background_color_attlist_;
common_shadow_attlist common_shadow_attlist_;
common_keep_with_next_attlist common_keep_with_next_attlist_;
common_horizontal_margin_attlist common_horizontal_margin_attlist_;
common_vertical_margin_attlist common_vertical_margin_attlist_;
common_margin_attlist common_margin_attlist_;
common_page_number_attlist common_page_number_attlist_;
common_break_attlist common_break_attlist_;
common_background_color_attlist common_background_color_attlist_;
common_shadow_attlist common_shadow_attlist_;
common_keep_with_next_attlist common_keep_with_next_attlist_;
common_writing_mode_attlist common_writing_mode_attlist_;
office_element_ptr style_background_image_;
optional<bool>::Type style_may_break_between_rows_;
optional<border_model>::Type table_border_model_;
common_writing_mode_attlist common_writing_mode_attlist_;
optional<bool>::Type table_display_;
};
......@@ -86,8 +85,9 @@ public:
_CP_OPT(length) style_column_width_;
_CP_OPT(length) style_rel_column_width_;
_CP_OPT(bool) style_use_optimal_column_width_;
common_break_attlist common_break_attlist_;
_CP_OPT(bool) style_use_optimal_column_width_;
common_break_attlist common_break_attlist_;
};
......@@ -108,7 +108,6 @@ public:
virtual void serialize(std::wostream & strm);
style_table_column_properties_attlist style_table_column_properties_attlist_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_table_column_properties);
......@@ -121,11 +120,11 @@ public:
_CP_OPT(length) style_row_height_;
_CP_OPT(length) style_min_row_height_;
_CP_OPT(bool) style_use_optimal_row_height_;
common_background_color_attlist common_background_color_attlist_;
common_break_attlist common_break_attlist_;
_CP_OPT(bool) style_use_optimal_row_height_;
_CP_OPT(keep_together) fo_keep_together_;
common_background_color_attlist common_background_color_attlist_;
common_break_attlist common_break_attlist_;
};
/// style:table-row-properties
......@@ -162,69 +161,31 @@ public:
void serialize(std::wostream & strm ,const wchar_t * ns, const wchar_t * name );
public:
// 15.11.1
_CP_OPT(vertical_align) style_vertical_align_;
// 15.11.2 style:text-align-source
_CP_OPT(text_align_source) style_text_align_source_;
// 15.11.3 style:direction
_CP_OPT(direction) style_direction_;
// 15.11.4 style:glyph-orientation-vertical
_CP_OPT(std::wstring) style_glyph_orientation_vertical_;
// 15.11.5
common_shadow_attlist common_shadow_attlist_;
// 15.11.6
_CP_OPT(vertical_align) style_vertical_align_;
_CP_OPT(text_align_source) style_text_align_source_;
_CP_OPT(direction) style_direction_;
_CP_OPT(std::wstring) style_glyph_orientation_vertical_;
common_shadow_attlist common_shadow_attlist_;
common_background_color_attlist common_background_color_attlist_;
common_border_attlist common_border_attlist_;
// 15.11.7
common_border_attlist common_border_attlist_;
// 15.11.8
_CP_OPT(std::wstring) style_diagonal_tl_br_;
_CP_OPT(border_widths) style_diagonal_tl_br_widths_;
_CP_OPT(std::wstring) style_diagonal_bl_tr_;
_CP_OPT(border_widths) style_diagonal_bl_tr_widths_;
_CP_OPT(std::wstring) style_diagonal_tl_br_;
_CP_OPT(border_widths) style_diagonal_tl_br_widths_;
_CP_OPT(std::wstring) style_diagonal_bl_tr_;
_CP_OPT(border_widths) style_diagonal_bl_tr_widths_;
// 15.11.9
// common-border-line-width-attlist
common_border_line_width_attlist common_border_line_width_attlist_;
// 15.11.10
common_padding_attlist common_padding_attlist_;
// 15.11.11
// fo:wrap-option
_CP_OPT(wrap_option) fo_wrap_option_;
common_border_line_width_attlist common_border_line_width_attlist_;
common_padding_attlist common_padding_attlist_;
common_rotation_angle_attlist common_rotation_angle_attlist_;
// 15.11.12
common_rotation_angle_attlist common_rotation_angle_attlist_;
// 15.11.13
// style:rotation-align
_CP_OPT(rotation_align) style_rotation_align_;
// 15.11.14
// style:cell-protect
_CP_OPT(std::wstring) style_cell_protect_;
// 15.11.15
// style:print-content
_CP_OPT(bool) style_print_content_;
// 15.11.16
// style:decimal-places
_CP_OPT(unsigned int) style_decimal_places_;
// 15.11.17
// style:repeat-content
_CP_OPT(bool) style_repeat_content_;
// 15.11.18
_CP_OPT(bool) style_shrink_to_fit_;
_CP_OPT(wrap_option) fo_wrap_option_;
_CP_OPT(rotation_align) style_rotation_align_;
_CP_OPT(std::wstring) style_cell_protect_;
_CP_OPT(bool) style_print_content_;
_CP_OPT(unsigned int) style_decimal_places_;
_CP_OPT(bool) style_repeat_content_;
_CP_OPT(bool) style_shrink_to_fit_;
};
......@@ -237,8 +198,6 @@ public:
};
/// \class style_table_cell_properties
/// style-table-cell-properties
/// style:table-cell-properties
class style_table_cell_properties : public office_element_impl<style_table_cell_properties>
{
......
......@@ -471,7 +471,7 @@ void table_table_cell_content::serialize(std::wostream & _Wostream)
{
BOOST_FOREACH(const office_element_ptr & elm, text_content_)
{
elm->serialize(_Wostream);
if (elm) elm->serialize(_Wostream);
}
}
// table:table-cell
......
......@@ -162,10 +162,19 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
ods_context->start_cell(ref,ifx_style);
//nullable<CFormula> m_oFormula;
//nullable<CSi> m_oRichText;
//nullable<CText> m_oValue;
if (oox_cell->m_oType.IsInit())
ods_context->current_table().set_cell_type(oox_cell->m_oType->GetValue());
if (oox_cell->m_oValue.IsInit())
{
ods_context->current_table().set_cell_value (string2std_string(oox_cell->m_oValue->m_sText));
}
if (oox_cell->m_oFormula.IsInit())
{
}
if (oox_cell->m_oRichText.IsInit())
{
}
ods_context->end_cell();
}
void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
......@@ -371,6 +380,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFill * fill, odf::office_element_
convert(fill->m_oPatternFill->m_oBgColor.GetPointer(),
cell_properties->style_table_cell_properties_attlist_.common_background_color_attlist_.fo_background_color_);
}
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::background_color) & odf_bckgrd_color)
......@@ -405,6 +415,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color)
}
SimpleTypes::Spreadsheet::CHexColor *oRgbColor=NULL;
double dTintKf =1;
if (color->m_oTint.IsInit())
{
dTintKf = 1. - color->m_oTint->GetValue();
}
if(color->m_oThemeColor.IsInit())
{
OOX::CTheme * xlsx_theme= xlsx_document->GetTheme();
......@@ -413,37 +431,38 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color)
//CString strColor = color->m_oThemeColor->ToString();
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
bool res=false;
CString test;
//???
switch(theme_ind)// CColorMapping !!!
{
case SimpleTypes::themecolorLight1:
case SimpleTypes::Spreadsheet::themecolorLight1:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oLt1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorLight2:
case SimpleTypes::Spreadsheet::themecolorLight2:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oLt2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorDark1:
case SimpleTypes::Spreadsheet::themecolorDark1:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oDk1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorDark2:
case SimpleTypes::Spreadsheet::themecolorDark2:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oDk2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent1:
case SimpleTypes::Spreadsheet::themecolorAccent1:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent2:
case SimpleTypes::Spreadsheet::themecolorAccent2:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent3:
case SimpleTypes::Spreadsheet::themecolorAccent3:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent3.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent4:
case SimpleTypes::Spreadsheet::themecolorAccent4:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent4.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent5:
case SimpleTypes::Spreadsheet::themecolorAccent5:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent5.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent6:
case SimpleTypes::Spreadsheet::themecolorAccent6:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent6.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorFollowedHyperlink:
case SimpleTypes::Spreadsheet::themecolorFollowedHyperlink:
res=xlsx_theme->m_oThemeElements.m_oClrScheme.m_oFolHlink.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorHyperlink:
case SimpleTypes::Spreadsheet::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);
oRgbColor = new SimpleTypes::Spreadsheet::CHexColor(ucR*dTintKf,ucG*dTintKf,ucB*dTintKf,ucA);
}
if(color->m_oIndexed.IsInit())
{
......@@ -466,7 +485,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color)
if (oRgbColor)
{
CString str=oRgbColor->ToString();
odf_color = odf::color(std::wstring(L"#") + string2std_string(str.Right(str.GetLength()-2)));
odf_color = odf::color(std::wstring(L"#") + string2std_string(str.Right(6)));
delete oRgbColor;
}
}
......@@ -498,7 +517,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
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(): -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 border_id = xfc_style->m_oBorderId.IsInit() ? xfc_style->m_oBorderId->GetValue(): -1;
......@@ -508,9 +527,11 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
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
if (xlsx_styles->m_oNumFmts.IsInit()) convert(xlsx_styles->m_oNumFmts->m_arrItems[numFmt_id], elm_style);
if (xlsx_styles->m_oNumFmts.IsInit()) convert(xlsx_styles->m_oNumFmts->m_arrItems[numFmt_id], elm_style); //+ applyNumberFormat
if (xlsx_styles->m_oBorders.IsInit()) convert(xlsx_styles->m_oBorders->m_arrItems[border_id], elm_style);
ods_context->styles_context().last_state().set_number_format(numFmt_id);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
odf::style* style = dynamic_cast<odf::style*>(elm_style.get());
if (!style)return;
......
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