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

(1.2.0.80): ASCOfficeOdfFileW

оптимизация по памяти
условное форматирование - стили, расширение типов, ...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56709 954022d7-b5bf-4e40-9824-e11837661b57
parent 8add34ba
......@@ -49,7 +49,9 @@ public:
// SUM(DDA1:BA3) -> of:=SUM([.DDA1:.BA3])
std::wstring convert(std::wstring const & expr);
std::wstring convert_formula(std::wstring const & expr);
std::wstring convert_conditional_formula(std::wstring const & expr);
// 1!$A$1 -> $1.$A$1
std::wstring convert_named_ref(std::wstring const & expr);
......
......@@ -12,6 +12,7 @@ class oox2odf_converter::Impl
public:
std::wstring convert(const std::wstring& expr);
std::wstring convert_formula(const std::wstring& expr);
std::wstring convert_conditional_formula(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr);
static void replace_cells_range(std::wstring& expr);
......@@ -23,7 +24,6 @@ public:
static std::wstring replace_cells_range_formater1(boost::wsmatch const & what);
static std::wstring replace_cells_range_formater2(boost::wsmatch const & what);
static std::wstring replace_arguments(boost::wsmatch const & what);
static std::wstring convert_part_formula(boost::wsmatch const & what);
static std::wstring convert_scobci(boost::wsmatch const & what);
std::wstring replace_arguments1(std::wstring & workstr);
......@@ -115,15 +115,14 @@ public:
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
{
boost::wregex re(L"([:$!])+");
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?");
// $ Sheet2 ! $ A1 : $ B5
//
boost::wsmatch result;
bool b = boost::regex_search(expr, result, re);
if (b)
{
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?");
// $ Sheet2 ! $ A1 : $ B5
std::wstring workstr = expr;
std::wstring res = boost::regex_replace(
......@@ -132,14 +131,12 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
&replace_cells_range_formater1,
boost::match_default | boost::format_all);
//workstr = res;
//res = boost::regex_replace(
//workstr,
//re2,
//&replace_cells_range_formater2,
//boost::match_default | boost::format_all);
expr = res;
}
else
{
}
return;
}
......@@ -507,9 +504,6 @@ std::wstring oox2odf_converter::Impl::convert(const std::wstring& expr)
// of:=(Formula) -> (Formula)
std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
{
if (is_forbidden1(expr))
return L"NULLFORMULA";
std::wstring workstr = expr;
std::wstring res1 = boost::regex_replace(
......@@ -524,9 +518,14 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
if (res1 == res)
{
res = convert(res1);
boost::algorithm::replace_all(res, L"[", L"");
boost::algorithm::replace_all(res, L"]", L"");
res = boost::regex_replace(
res1,
boost::wregex(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?"),
&replace_cells_range_formater1,
boost::match_default | boost::format_all);
replace_vertical(res);
replace_semicolons(res);
}
boost::algorithm::replace_all(res, L"SCOBCAIN", L"(");
......@@ -541,38 +540,42 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
return std::wstring(L"of:=") + res;
}
std::wstring oox2odf_converter::Impl::convert_part_formula(boost::wsmatch const & what)
std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wstring & expr)
{
std::wstring out;
if (what[1].matched)
out = what[1].str();
else if (what[2].matched)
out = what[2].str();
else if (what[3].matched)
{
std::wstring workstr = what[3].str();
int res1 = workstr.find(L"\'");
int res2 = workstr.find(L"\"");
std::wstring workstr = expr;
if (res1 >=0 || res2 >=0)return workstr;
std::wstring res1 = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&oox2odf_converter::Impl::convert_scobci,boost::match_default | boost::format_all);
std::wstring res = boost::regex_replace(
res1,
boost::wregex(L"(?:(?=[()])(.*?)(?=[)]))"),
&oox2odf_converter::Impl::replace_arguments,boost::match_default | boost::format_all);
std::wstring res = boost::regex_replace(
workstr,
boost::wregex(L"(?:(?=[()])(.*?)(?=[)]))|(\".*?\")|('.*?')"),
&oox2odf_converter::Impl::replace_arguments,
if (res1 == res)
{
res = boost::regex_replace(res1,
boost::wregex(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?"),
&replace_cells_range_formater1,
boost::match_default | boost::format_all);
replace_vertical(res);
replace_semicolons(res);
}
boost::algorithm::replace_all(res, L"SCOBCAIN", L"(");
boost::algorithm::replace_all(res, L"SCOBCAOUT", L")");
//if (res == workstr)
//{
// //
// res= convert(workstr);
boost::algorithm::replace_all(res, L"PROBEL", L" ");
boost::algorithm::replace_all(res, L"APOSTROF", L"'");
boost::algorithm::replace_all(res, L"KAVYCHKA", L"\"");
return res;
//}
out = res;
}
return out ;
}
//Sheet2!C3:C19,Sheet2!L27:L34
//
......@@ -647,6 +650,10 @@ std::wstring oox2odf_converter::convert(const std::wstring& expr)
{
return impl_->convert(expr);
}
std::wstring oox2odf_converter::convert_conditional_formula(const std::wstring& expr)
{
return impl_->convert_conditional_formula(expr);
}
std::wstring oox2odf_converter::convert_formula(const std::wstring& expr)
{
return impl_->convert_formula(expr);
......
......@@ -82,7 +82,7 @@ void calcext_conditional_format::serialize(std::wostream & _Wostream)
{
CP_XML_ATTR_OPT(L"calcext:target-range-address",calcext_target_range_address_);
BOOST_FOREACH(const office_element_ptr & item, content_)
BOOST_REVERSE_FOREACH(const office_element_ptr & item, content_)
{
item->serialize(CP_XML_STREAM());
}
......
......@@ -131,7 +131,7 @@ std::wstring odf_style_context::find_odf_style_name(int oox_id_style, const styl
if (style_state_list_[i].odf_style_)
{
if (style_state_list_[i].style_family_ == family &&
style_state_list_[i].root_ == root)
style_state_list_[i].root_ == root && style_state_list_[i].conditional_ == false)
{
if (oox_id_style >=0 && style_state_list_[i].style_oox_id_ == oox_id_style) return style_state_list_[i].get_name();
}
......@@ -148,7 +148,39 @@ office_element_ptr odf_style_context::find_odf_style(int oox_id_style, const sty
if (style_state_list_[i].odf_style_)
{
if (style_state_list_[i].style_family_ == family &&
style_state_list_[i].root_ == root)
style_state_list_[i].root_ == root && style_state_list_[i].conditional_ == false)
{
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();
}
std::wstring odf_style_context::find_conditional_style_name(int oox_id_style, const style_family family)
{
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i].odf_style_)
{
if (style_state_list_[i].style_family_ == family
&& style_state_list_[i].conditional_ == true)
{
if (oox_id_style >=0 && style_state_list_[i].style_oox_id_ == oox_id_style) return style_state_list_[i].get_name();
}
}
}
return L"";
}
office_element_ptr odf_style_context::find_conditional_style(int oox_id_style, const style_family family)
{
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
&& style_state_list_[i].conditional_ == true)
{
if (oox_id_style >=0 && style_state_list_[i].style_oox_id_ == oox_id_style) return style_state_list_[i].get_office_element();
}
......@@ -164,7 +196,7 @@ bool odf_style_context::find_odf_style_state(int oox_id_style, const style_famil
if (style_state_list_[i].odf_style_)
{
if (style_state_list_[i].style_family_ == family &&
style_state_list_[i].root_ == root)
style_state_list_[i].root_ == root && style_state_list_[i].conditional_ == false)
{
if (oox_id_style >=0 && style_state_list_[i].style_oox_id_ == oox_id_style)
{
......
......@@ -47,6 +47,9 @@ public:
std::wstring find_odf_style_name_default(const style_family family);
office_element_ptr find_odf_style_default (const style_family family);
std::wstring find_conditional_style_name(int oox_id_style, const style_family family);
office_element_ptr find_conditional_style (int oox_id_style, const style_family family);
bool find_odf_style_state(int oox_id_style, const style_family family, odf_style_state *& state, bool root = false);
......
......@@ -13,8 +13,9 @@ odf_style_state::odf_style_state(office_element_ptr & elm, const style_family fa
{
odf_style_ = elm;
automatic_= false;
default_ = false;
automatic_ = false;
default_ = false;
conditional_ = false;
num_fmt_id_ =0;
style_family_ = family;
......@@ -85,6 +86,10 @@ void odf_style_state::set_default(bool val)
{
default_ = val;
}
void odf_style_state::set_conditional(bool val)
{
conditional_ = val;
}
//////////////////////////////////////////////////////////////////
style_text_properties * odf_style_state::get_text_properties()
{
......
......@@ -34,6 +34,7 @@ public:
void set_automatic(bool val);
void set_root(bool val);
void set_default(bool val);
void set_conditional(bool val);
office_element_ptr & get_office_element();
......@@ -69,6 +70,7 @@ private:
bool automatic_;
bool root_;
bool default_; // root
bool conditional_; //
style_family style_family_;
......
......@@ -92,6 +92,7 @@ std::wstring convert_time(std::wstring & oox_time)
};
///////////////////////////////////////////////////////////////
static formulasconvert::oox2odf_converter formulas_converter;
ods_table_state::ods_table_state(ods_conversion_context & Context, office_element_ptr & elm): context_(Context),drawing_context_(&Context)
{
......@@ -587,12 +588,15 @@ void ods_table_state::set_merge_cells(__int32 start_col, __int32 start_row, __in
}
}
}
static formulasconvert::oox2odf_converter formulas_converter;
void ods_table_state::set_cell_formula(std::wstring & formula)
{
if (formula.length() < 1)return;
//test external link
int res = formula.find(L"[");
if (res == 0)return; //todoooo
std::wstring odfFormula = formulas_converter.convert_formula(formula);
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
......@@ -832,10 +836,10 @@ void ods_table_state::set_cell_text(odf_text_context* text_context, bool cash_va
odf::style_table_cell_properties * table_cell_properties = style_->style_content_.get_style_table_cell_properties();
if (table_cell_properties)
{
table_cell_properties->style_table_cell_properties_attlist_.style_text_align_source_ = odf::text_align_source(odf::text_align_source::Fix);
}
//if (table_cell_properties && cash_value == false)
//{
// table_cell_properties->style_table_cell_properties_attlist_.style_text_align_source_ = odf::text_align_source(odf::text_align_source::Fix);
//}
}
void ods_table_state::set_cell_value(std::wstring & value)
{
......@@ -1013,40 +1017,52 @@ void ods_table_state::start_conditional_rule(__int32 rule_type)
{
office_element_ptr elm;
switch(rule_type)
if (rule_type == 3) create_element(L"calcext", L"color-scale",elm,&context_);
else if (rule_type == 7)create_element(L"calcext", L"data-bar",elm,&context_);
else if (rule_type ==10)create_element(L"calcext", L"icon-set",elm,&context_);
else if (rule_type ==14)create_element(L"calcext", L"date-is",elm,&context_);
else
{
case 3: /*colorScale*/
create_element(L"calcext", L"color-scale",elm,&context_); break;
case 7: /*dataBar*/
create_element(L"calcext", L"data-bar",elm,&context_); break;
case 10: /*iconSet*/
create_element(L"calcext", L"icon-set",elm,&context_); break;
case 14: /*timePeriod*/
create_element(L"calcext", L"date-is",elm,&context_); break;
case 0: /*aboveAverage*/
case 1: /*beginsWith*/
case 2: /*cellIs*/
case 4: /*containsBlanks*/
case 5: /*containsErrors*/
case 6: /*containsText*/
case 8: /*duplicateValues*/
case 9: /*expression*/
case 11: /*notContainsBlanks*/
case 12: /*notContainsErrors*/
case 13: /*notContainsText*/
case 15: /*top10*/
case 16: /*uniqueValues*/
default:
create_element(L"calcext", L"condition",elm,&context_);
calcext_condition* condition = dynamic_cast<calcext_condition*> (elm.get());
if (condition)
{
calcext_conditional_format* condition_fmt = dynamic_cast<calcext_conditional_format*> (current_level_.back().get());
if ((condition_fmt) && (condition_fmt->calcext_target_range_address_))
{
create_element(L"calcext", L"condition",elm,&context_);
calcext_condition* condition = dynamic_cast<calcext_condition*> (elm.get());
calcext_conditional_format* condition_fmt = dynamic_cast<calcext_conditional_format*> (current_level_.back().get());
if (condition && condition_fmt)
std::wstring cell, table,test = *condition_fmt->calcext_target_range_address_;
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, test, boost::algorithm::is_any_of(L"!"), boost::algorithm::token_compress_on);
if (splitted.size()>1)
{
condition->calcext_condition_attr_.calcext_base_cell_address_=condition_fmt->calcext_target_range_address_;
}
table = splitted[0];
test = splitted[1];
}else table = office_table_name_;
boost::algorithm::split(splitted, test, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
cell = splitted[0];
condition->calcext_condition_attr_.calcext_base_cell_address_ = table + cell;
}
switch(rule_type)
{
case 4: condition->calcext_condition_attr_.calcext_value_ = L"contains-text( )"; break;
case 5: condition->calcext_condition_attr_.calcext_value_ = L"is-error"; break;
case 6: condition->calcext_condition_attr_.calcext_value_ = L"contains-text()"; break;
case 8: condition->calcext_condition_attr_.calcext_value_ = L"duplicate"; break;
case 9: condition->calcext_condition_attr_.calcext_value_ = L"formula-is()"; break;
case 11: condition->calcext_condition_attr_.calcext_value_ = L"not-contains-text( )"; break;
case 12: condition->calcext_condition_attr_.calcext_value_ = L"is-no-error"; break;
case 13: condition->calcext_condition_attr_.calcext_value_ = L"not-contains-text()"; break;
case 15: condition->calcext_condition_attr_.calcext_value_ = L"top-elements()"; break;//bottom-elements ???
case 16: condition->calcext_condition_attr_.calcext_value_ = L"unique"; break;
case 0: /*aboveAverage*/
case 1: /*beginsWith*/
case 2: /*cellIs*/
default: break;
}
}
}
current_level_.back()->add_child_element(elm);
......@@ -1057,11 +1073,29 @@ void ods_table_state::end_conditional_rule()
{
current_level_.pop_back();
}
void ods_table_state::set_conditional_formula(std::wstring formula)
{
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
if (condition)condition->calcext_condition_attr_.calcext_value_= formula;
if (condition)
{
std::wstring odfFormula = formulas_converter.convert_conditional_formula(formula);
std::wstring operator_;
bool s = false;
if (condition->calcext_condition_attr_.calcext_value_)//
{
operator_ = *condition->calcext_condition_attr_.calcext_value_;
int f = operator_.find(L"(");
if (f > 0)
{
s= true;
operator_ = operator_.substr(0,operator_.length() - 2);
}
}
condition->calcext_condition_attr_.calcext_value_= operator_ + (s ? L"(": L"") + odfFormula + (s ? L")": L"");
}
}
void ods_table_state::set_conditional_style_name(std::wstring style_name)
{
......@@ -1070,7 +1104,28 @@ void ods_table_state::set_conditional_style_name(std::wstring style_name)
if (condition)condition->calcext_condition_attr_.calcext_apply_style_name_= style_ref(style_name);
if (date_is) date_is->calcext_date_is_attr_.calcext_style_ = style_ref(style_name);
}
void ods_table_state::set_conditional_operator(__int32 _operator)
{
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
if (condition)
{
switch(_operator)
{
case 0: condition->calcext_condition_attr_.calcext_value_ = L"begins-with()"; break;
case 1: condition->calcext_condition_attr_.calcext_value_ = L"between()"; break;
case 2: condition->calcext_condition_attr_.calcext_value_ = L"contains-text()"; break;
case 3: condition->calcext_condition_attr_.calcext_value_ = L"ends-with()"; break;
case 4: condition->calcext_condition_attr_.calcext_value_ = L"="; break;
case 5: condition->calcext_condition_attr_.calcext_value_ = L">"; break;
case 6: condition->calcext_condition_attr_.calcext_value_ = L">="; break;
case 7: condition->calcext_condition_attr_.calcext_value_ = L"<"; break;
case 8: condition->calcext_condition_attr_.calcext_value_ = L"<="; break;
case 9: condition->calcext_condition_attr_.calcext_value_ = L"not-between()"; break;
case 10:condition->calcext_condition_attr_.calcext_value_ = L"not-contains-text()"; break;
case 11:condition->calcext_condition_attr_.calcext_value_ = L"!="; break;
}
}
}
void ods_table_state::set_conditional_value(__int32 type, std::wstring value )
{
......
......@@ -223,7 +223,9 @@ public:
void set_conditional_iconset(__int32 type_iconset);
void add_conditional_colorscale(_CP_OPT(color) color);
void set_conditional_databar_color(_CP_OPT(color) color);
void set_conditional_style_name(std::wstring style_name);
void set_conditional_operator(__int32 _operator);
void end_conditional_rule();
void end_conditional_format();
void end_conditional_formats();
......
......@@ -134,7 +134,6 @@ void XlsxConverter::convert_sheets()
ods_context->current_table().set_table_hidden(true);
convert(pPairWorksheet->m_value);
delete pPairWorksheet->m_value; pPairWorksheet->m_value = NULL;
ods_context->end_sheet();
}
}
......@@ -657,11 +656,11 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
{
ods_context->current_table().set_column_optimal_width(false);
}
if (width > 0 )
{
width = ods_context->convert_symbol_width(width);
ods_context->current_table().set_column_width(width);
}
if (oox_column->m_oHidden.IsInit() && oox_column->m_oHidden->ToBool()) width = 0;
if (width > 0 ) width = ods_context->convert_symbol_width(width);
if (width >= 0 ) ods_context->current_table().set_column_width(width);
std::wstring style_cell_name;
if (oox_column->m_oStyle.IsInit())
......@@ -828,7 +827,7 @@ void XlsxConverter::convert_styles()
{
if (!ods_context) return;
// add default styles
///////////// default styles
ods_context->styles_context()->create_default_style(odf::style_family::TableCell);
///////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -836,31 +835,36 @@ void XlsxConverter::convert_styles()
if (!xlsx_styles)return;
for (long i=0; xlsx_styles->m_oNumFmts.IsInit() && i< xlsx_styles->m_oNumFmts->m_oCount->GetValue(); i++)//in styles record
////////////
for (long i=0; xlsx_styles->m_oNumFmts.IsInit() && i< xlsx_styles->m_oNumFmts->m_oCount->GetValue(); i++)
{
convert(xlsx_styles->m_oNumFmts->m_arrItems[i]);
}
for (long i=0; xlsx_styles->m_oCellStyleXfs.IsInit() && 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++)
{
//non automatical, root - noname -
convert(xlsx_styles->m_oCellStyleXfs->m_arrItems[i] , i, false, true);// ""
}
///////////////////////////////////
for (long i=0; xlsx_styles->m_oCellXfs.IsInit() && i< xlsx_styles->m_oCellXfs->m_oCount->GetValue(); i++)
{
//automatical, non root
convert(xlsx_styles->m_oCellXfs->m_arrItems[i],i, true,false);
}
}
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); //
//non automatical, root - named -
convert(xlsx_styles->m_oCellStyles->m_arrItems[i],i);
}
////////////
for (long i=0; xlsx_styles->m_oDxfs.IsInit() && i< xlsx_styles->m_oDxfs->m_oCount->GetValue(); i++)
{
convert(xlsx_styles->m_oDxfs->m_arrItems[i],i);
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf::style_text_properties * text_properties)
{
if (font == NULL)return;
......@@ -1048,14 +1052,16 @@ void XlsxConverter::convert(OOX::Spreadsheet::CAligment *aligment, odf::style_pa
paragraph_properties->content().fo_text_align_ = odf::text_align(odf::text_align::Start); break;
case SimpleTypes::Spreadsheet::horizontalalignmentJustify:
paragraph_properties->content().fo_text_align_ = odf::text_align(odf::text_align::Justify); break;
case SimpleTypes::Spreadsheet::horizontalalignmentLeft:
paragraph_properties->content().fo_text_align_ = odf::text_align(odf::text_align::Start); break;
case SimpleTypes::Spreadsheet::horizontalalignmentRight:
paragraph_properties->content().fo_text_align_ = odf::text_align(odf::text_align::End); break;
case SimpleTypes::Spreadsheet::horizontalalignmentLeft:
default:
paragraph_properties->content().fo_text_align_ = odf::text_align(odf::text_align::Start); break;
}
cell_properties->style_table_cell_properties_attlist_.style_text_align_source_ = odf::text_align_source(odf::text_align_source::Fix);
}
if (!paragraph_properties->content().fo_text_align_)
paragraph_properties->content().fo_text_align_ = odf::text_align(odf::text_align::Start);
if (aligment->m_oWrapText.IsInit())
{
......@@ -1307,6 +1313,37 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellStyle * cell_style, int oox_i
//m_oBuiltinId, m_oCustomBuiltin, m_oHidden, m_oILevel; ???????
}
void XlsxConverter::convert(OOX::Spreadsheet::CDxf *dxFmt, int oox_id)
{
if (!dxFmt)return;
ods_context->styles_context()->create_style(L"",odf::style_family::TableCell, false, true, oox_id);
ods_context->styles_context()->last_state().set_conditional(true);
odf::style_text_properties * text_properties = ods_context->styles_context()->last_state().get_text_properties();
odf::style_table_cell_properties * table_cell_properties = ods_context->styles_context()->last_state().get_table_cell_properties();
convert(dxFmt->m_oBorder.GetPointer(), table_cell_properties);
convert(dxFmt->m_oFill.GetPointer(), table_cell_properties);
convert(dxFmt->m_oFont.GetPointer(), text_properties);
if (dxFmt->m_oNumFmt.IsInit())
{
int numFmt_id = dxFmt->m_oNumFmt->m_oNumFmtId.IsInit() ? dxFmt->m_oNumFmt->m_oNumFmtId->GetValue() : -1;
if (numFmt_id >=0)
{
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 (dxFmt->m_oAlignment.IsInit())
{
odf::style_paragraph_properties * paragraph_properties = ods_context->styles_context()->last_state().get_paragraph_properties();
paragraph_properties->content().style_writing_mode_ = odf::writing_mode(odf::writing_mode::Page);
convert(dxFmt->m_oAlignment.GetPointer(), paragraph_properties, table_cell_properties);
}
//convert(dxFmt->m_oProtection.GetPointer(), table_cell_properties);
}
void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool automatic, bool root)
{
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
......@@ -1322,11 +1359,6 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
odf::style_text_properties * text_properties = ods_context->styles_context()->last_state().get_text_properties();
odf::style_table_cell_properties * table_cell_properties = ods_context->styles_context()->last_state().get_table_cell_properties();
if (root)
{
table_cell_properties->style_table_cell_properties_attlist_.style_text_align_source_ = odf::text_align_source(odf::text_align_source::Fix);
}
if (xlsx_styles->m_oFonts.IsInit() && font_id >=0 && (id_parent < 0 || xfc_style->m_oApplyFont.IsInit()))
{
convert(xlsx_styles->m_oFonts->m_arrItems[font_id], text_properties);
......@@ -1759,15 +1791,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co
{
if (oox_cond_rule->m_oDxfId.IsInit())
{
// ... styles dxfs cellXfs
//std::wstring odf_style_name;
//odf::odf_style_state *style_state=NULL;
//odf_context()->styles_context()->find_odf_style_state(oox_cond_rule->m_oDxfId->GetValue(), odf::style_family::TableCell,style_state);
//if (style_state)odf_style_name = style_state->get_name();
std::wstring odf_style_name = odf_context()->styles_context()->find_conditional_style_name(oox_cond_rule->m_oDxfId->GetValue(), odf::style_family::TableCell);
//ods_context->current_table().set_conditional_style_name(odf_style_name);
ods_context->current_table().set_conditional_style_name(odf_style_name);
}
for (long i=0; i< oox_cond_rule->m_arrItems.GetSize(); i++)
if (oox_cond_rule->m_oOperator.IsInit())
ods_context->current_table().set_conditional_operator(oox_cond_rule->m_oOperator->GetValue());
for (long i=0; i< oox_cond_rule->m_arrItems.GetSize(); i++)
convert(oox_cond_rule->m_arrItems[i]);
}
ods_context->current_table().end_conditional_rule();
......
......@@ -34,6 +34,7 @@ namespace OOX
class CBorderProp;
class CAligment;
class CXfs;
class CDxf;
class CCellStyle;
class CNumFmt;
class CCellAnchor;
......@@ -157,6 +158,7 @@ namespace Oox2Odf
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(OOX::Spreadsheet::CDxf *dxFmt, int oox_id);
void convert(OOX::Spreadsheet::CCellAnchor *oox_anchor);
void convert(OOX::Spreadsheet::CDrawing *oox_drawing);
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//78
#define INTVER 1,2,0,78
#define STRVER "1,2,0,78\0"
//80
#define INTVER 1,2,0,80
#define STRVER "1,2,0,80\0"
......@@ -2076,6 +2076,70 @@ namespace SimpleTypes
SimpleType_FromString (EIconSetType)
SimpleType_Operator_Equal (ST_IconSetType)
};
//----------------------------------------------------
// 18.18.15 ST_CfOperator (Conditional Format Operators)
//----------------------------------------------------
enum ECfOperator
{
Operator_beginsWith = 0,
Operator_between = 1,
Operator_containsText = 2,
Operator_endsWith = 3,
Operator_equal = 4,
Operator_greaterThan = 5,
Operator_greaterThanOrEqual = 6,
Operator_lessThan = 7,
Operator_lessThanOrEqual = 8,
Operator_notBetween = 9,
Operator_notContains = 10,
Operator_notEqual = 11
};
template<ECfOperator eDefValue = Operator_equal>
class ST_CfOperator : public CSimpleType<ECfOperator, eDefValue>
{
public:
ST_CfOperator() {}
virtual ECfOperator FromString(CString &sValue)
{
if(_T("beginsWith") == sValue) m_eValue = Operator_beginsWith;
else if(_T("between") == sValue) m_eValue = Operator_between;
else if(_T("containsText") == sValue) m_eValue = Operator_containsText;
else if(_T("endsWith") == sValue) m_eValue = Operator_endsWith;
else if(_T("equal") == sValue) m_eValue = Operator_equal;
else if(_T("greaterThan") == sValue) m_eValue = Operator_greaterThan;
else if(_T("greaterThanOrEqual") == sValue) m_eValue = Operator_greaterThanOrEqual;
else if(_T("lessThan") == sValue) m_eValue = Operator_lessThan;
else if(_T("lessThanOrEqual") == sValue) m_eValue = Operator_lessThanOrEqual;
else if(_T("notBetween") == sValue) m_eValue = Operator_notBetween;
else if(_T("notContains") == sValue) m_eValue = Operator_notContains;
else if(_T("notEqual") == sValue) m_eValue = Operator_notEqual;
return m_eValue;
}
virtual CString ToString () const
{
switch(m_eValue)
{
case Operator_beginsWith : return _T("beginsWith"); break;
case Operator_between : return _T("between"); break;
case Operator_containsText : return _T("containsText"); break;
case Operator_endsWith : return _T("endsWith"); break;
case Operator_equal : return _T("equal"); break;
case Operator_greaterThan : return _T("greaterThan"); break;
case Operator_greaterThanOrEqual: return _T("greaterThanOrEqual");break;
case Operator_lessThan : return _T("lessThan"); break;
case Operator_lessThanOrEqual : return _T("lessThanOrEqual"); break;
case Operator_notBetween : return _T("notBetween"); break;
case Operator_notContains : return _T("notContains"); break;
case Operator_notEqual : return _T("notEqual"); break;
default : return _T("equal");
}
}
SimpleType_FromString (ECfOperator)
SimpleType_Operator_Equal (ST_CfOperator)
};
//----------------------------------------------------
// 18.18.12 ST_CfType (Conditional Format Type)
......
......@@ -479,19 +479,19 @@ namespace OOX
}
public:
nullable<SimpleTypes::COnOff<>> m_oAboveAverage;
nullable<SimpleTypes::COnOff<>> m_oBottom;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oDxfId;
nullable<SimpleTypes::COnOff<>> m_oEqualAverage;
nullable<CString> m_oOperator; // ToDo ST_ConditionalFormattingOperator (18.18.15)
nullable<SimpleTypes::COnOff<>> m_oPercent;
nullable<SimpleTypes::CDecimalNumber<>> m_oPriority;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRank;
nullable<SimpleTypes::CDecimalNumber<>> m_oStdDev;
nullable<SimpleTypes::COnOff<>> m_oStopIfTrue;
nullable<CString> m_oText;
nullable<CString> m_oTimePeriod; // ToDo ST_TimePeriod (18.18.82)
nullable<SimpleTypes::Spreadsheet::ST_CfType<>> m_oType;
nullable<SimpleTypes::COnOff<>> m_oAboveAverage;
nullable<SimpleTypes::COnOff<>> m_oBottom;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oDxfId;
nullable<SimpleTypes::COnOff<>> m_oEqualAverage;
nullable<SimpleTypes::Spreadsheet::ST_CfOperator<>> m_oOperator;
nullable<SimpleTypes::COnOff<>> m_oPercent;
nullable<SimpleTypes::CDecimalNumber<>> m_oPriority;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRank;
nullable<SimpleTypes::CDecimalNumber<>> m_oStdDev;
nullable<SimpleTypes::COnOff<>> m_oStopIfTrue;
nullable<CString> m_oText;
nullable<CString> m_oTimePeriod; // ToDo ST_TimePeriod (18.18.82)
nullable<SimpleTypes::Spreadsheet::ST_CfType<>> m_oType;
};
//:
......
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