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

(1.2.0.52): ASCOfficeOdfFileW

условное форматирование (расширение & рефакторинг)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56422 954022d7-b5bf-4e40-9824-e11837661b57
parent d6f16088
......@@ -12,19 +12,55 @@ std::wostream & operator << (std::wostream & _Wostream, const iconset_type & _Va
case iconset_type::Arrows3:
_Wostream << L"3Arrows";
break;
case iconset_type::Arrows3Grey:
_Wostream << L"3ArrowsGrey";
case iconset_type::Arrows3Gray:
_Wostream << L"3ArrowsGray";
break;
case iconset_type::Flags3:
_Wostream << L"3Flags";
break;
case iconset_type::Traffic3Lights1:
case iconset_type::Signs3:
_Wostream << L"3Signs";
break;
case iconset_type::Symbols3:
_Wostream << L"3Symbols";
break;
case iconset_type::Symbols3_2:
_Wostream << L"3Symbols2";
break;
case iconset_type::Traffic3Lights1:
_Wostream << L"3TrafficLights1";
break;
case iconset_type::Traffic3Lights2:
case iconset_type::Traffic3Lights2:
_Wostream << L"3TrafficLights2";
break;
default:
case iconset_type::Arrows4:
_Wostream << L"4Arrows";
break;
case iconset_type::Arrows4Gray:
_Wostream << L"4ArrowsGray";
break;
case iconset_type::Rating4:
_Wostream << L"4Rating";
break;
case iconset_type::RedToBlack4:
_Wostream << L"4RedToBlack";
break;
case iconset_type::Traffic4Lights:
_Wostream << L"4TrafficLights";
break;
case iconset_type::Arrows5:
_Wostream << L"5Arrows";
break;
case iconset_type::Arrows5Gray:
_Wostream << L"5ArrowsGray";
break;
case iconset_type::Quarters5:
_Wostream << L"5Quarters";
break;
case iconset_type::Rating5:
_Wostream << L"5Rating";
break;
default:
break;
}
return _Wostream;
......@@ -35,17 +71,41 @@ iconset_type iconset_type::parse(const std::wstring & Str)
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"3Arrows")
if (tmp == L"3Arrows")
return iconset_type( Arrows3 );
else if (tmp == L"3ArrowsGrey")
return iconset_type( Arrows3Grey );
else if (tmp == L"3Flags")
else if (tmp == L"3ArrowsGray")
return iconset_type( Arrows3Gray );
else if (tmp == L"3Flags")
return iconset_type( Flags3 );
else if (tmp == L"3TrafficLights1")
else if (tmp == L"3Signs")
return iconset_type( Signs3 );
else if (tmp == L"3Symbols")
return iconset_type( Symbols3 );
else if (tmp == L"3Symbols2")
return iconset_type( Symbols3_2 );
else if (tmp == L"3TrafficLights1")
return iconset_type( Traffic3Lights1 );
else if (tmp == L"3TrafficLights2")
else if (tmp == L"3TrafficLights2")
return iconset_type( Traffic3Lights2 );
else
else if (tmp == L"4Arrows")
return iconset_type( Arrows4 );
else if (tmp == L"4ArrowsGray")
return iconset_type( Arrows4Gray );
else if (tmp == L"4Rating")
return iconset_type( Rating4 );
else if (tmp == L"4RedToBlack")
return iconset_type( RedToBlack4 );
else if (tmp == L"4TrafficLights")
return iconset_type( Traffic4Lights );
else if (tmp == L"5Arrows")
return iconset_type( Arrows5 );
else if (tmp == L"5ArrowsGray")
return iconset_type( Arrows5Gray );
else if (tmp == L"5Quarters")
return iconset_type( Quarters5 );
else if (tmp == L"5Rating")
return iconset_type( Rating5 );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return iconset_type( Arrows3 );
......
......@@ -13,10 +13,22 @@ public:
enum type
{
Arrows3,
Arrows3Grey,
Arrows3Gray,
Flags3,
Signs3,
Symbols3,
Symbols3_2,
Traffic3Lights1,
Traffic3Lights2
Traffic3Lights2,
Arrows4,
Arrows4Gray,
Rating4,
RedToBlack4,
Traffic4Lights,
Arrows5,
Arrows5Gray,
Quarters5,
Rating5
};
iconset_type() {}
......
......@@ -743,10 +743,10 @@ void ods_table_state::set_cell_text(odf_text_context* text_context, bool cash_va
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
}
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
}
//if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_)
//{
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
//}
}
}
}
......@@ -914,19 +914,37 @@ void ods_table_state::end_conditional_format()
{
current_level_.pop_back();
}
void ods_table_state::start_conditional_rule(std::wstring rule_type)
void ods_table_state::start_conditional_rule(int rule_type)
{
office_element_ptr elm;
if (rule_type == L"dataBar")
{
create_element(L"calcext", L"data-bar",elm,&context_);
}
else if (rule_type == L"iconSet")
switch(rule_type)
{
create_element(L"calcext", L"icon-set",elm,&context_);
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_);
}
current_level_.back()->add_child_element(elm);
current_level_.push_back(elm);
}
......@@ -935,35 +953,67 @@ void ods_table_state::end_conditional_rule()
{
current_level_.pop_back();
}
void ods_table_state::set_conditional_value(std::wstring type, std::wstring value )
void ods_table_state::set_conditional_value(int type, std::wstring value )
{
office_element_ptr elm;
create_element(L"calcext", L"formatting-entry",elm, &context_);
current_level_.back()->add_child_element(elm);
calcext_icon_set* icon_set = dynamic_cast<calcext_icon_set*> (current_level_.back().get());
calcext_data_bar* data_bar = dynamic_cast<calcext_data_bar*> (current_level_.back().get());
calcext_color_scale* color_scale = dynamic_cast<calcext_color_scale*>(current_level_.back().get());
if (icon_set || data_bar)
{
office_element_ptr elm;
create_element(L"calcext", L"formatting-entry",elm, &context_);
current_level_.back()->add_child_element(elm);
calcext_formatting_entry * entry = dynamic_cast<calcext_formatting_entry*>(elm.get());
if (entry)
{
switch(type)
{
case 0: //Formula
case 1: entry->calcext_type_ = calcext_type(calcext_type::AutoMaximum); break;
case 2: entry->calcext_type_ = calcext_type(calcext_type::AutoMinimum); break;
case 4: entry->calcext_type_ = calcext_type(calcext_type::Percent); break;
case 5: //Percentile
case 3: //Number
default: entry->calcext_type_ = calcext_type(calcext_type::Number);
}
}
}
calcext_formatting_entry * entry = dynamic_cast<calcext_formatting_entry*>(elm.get());
if (entry)
if (color_scale)
{
if (value.length() >0) entry->calcext_value_ = value;
else entry->calcext_value_ = L"0";
if (type == L"min") entry->calcext_type_ = calcext_type(calcext_type::AutoMinimum);
else if (type == L"max") entry->calcext_type_ = calcext_type(calcext_type::AutoMaximum);
else if (type == L"percent") entry->calcext_type_ = calcext_type(calcext_type::Percent);
else if (type == L"num") entry->calcext_type_ = calcext_type(calcext_type::Number);
office_element_ptr elm;
create_element(L"calcext", L"color-scale-entry",elm, &context_);
current_level_.back()->add_child_element(elm);
calcext_color_scale_entry * entry = dynamic_cast<calcext_color_scale_entry*>(elm.get());
if (entry)
{
switch(type)
{
case 0: //Formula
case 1: entry->calcext_type_ = calcext_type(calcext_type::Maximum); break;
case 2: entry->calcext_type_ = calcext_type(calcext_type::Minimum); break;
case 4: entry->calcext_type_ = calcext_type(calcext_type::Percent); break;
case 5: //Percentile
case 3: //Number
default: entry->calcext_type_ = calcext_type(calcext_type::Number);
}
}
///color???? - !!
}
}
void ods_table_state::set_conditional_iconset(std::wstring type_iconset)
void ods_table_state::set_conditional_iconset(int type_iconset)
{
calcext_icon_set* cond_format = dynamic_cast<calcext_icon_set*>(current_level_.back().get());
if (cond_format)
{
if (type_iconset == L"3Arrows")
cond_format->calcext_icon_set_attr_.calcext_icon_set_type_ = iconset_type(iconset_type::Arrows3);
else
cond_format->calcext_icon_set_attr_.calcext_icon_set_type_ = iconset_type(iconset_type::Flags3);
cond_format->calcext_icon_set_attr_.calcext_icon_set_type_ = iconset_type((iconset_type::type)type_iconset);
}
}
void ods_table_state::add_conditional_colorscale(_CP_OPT(color) color)
......
......@@ -202,9 +202,9 @@ public:
void start_conditional_formats();
void start_conditional_format(std::wstring ref);
void start_conditional_rule(std::wstring rule_type);
void set_conditional_value(std::wstring type, std::wstring value );
void set_conditional_iconset(std::wstring type_iconset);
void start_conditional_rule(int rule_type);
void set_conditional_value(int type, std::wstring value );
void set_conditional_iconset(int type_iconset);
void add_conditional_colorscale(_CP_OPT(color) color);
void set_conditional_databar_color(_CP_OPT(color) color);
void end_conditional_rule();
......
......@@ -1505,7 +1505,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co
if (oox_cond_rule->m_oType.IsInit())
{
ods_context->current_table().start_conditional_rule(string2std_string(oox_cond_rule->m_oType.get2()));
ods_context->current_table().start_conditional_rule(oox_cond_rule->m_oType->GetValue());
for (long i=0; i< oox_cond_rule->m_arrItems.GetSize(); i++)
convert(oox_cond_rule->m_arrItems[i]);
......@@ -1553,7 +1553,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CIconSet *oox_cond_iconset)
if (!oox_cond_iconset)return;
if (oox_cond_iconset->m_oIconSet.IsInit())
ods_context->current_table().set_conditional_iconset(string2std_string(oox_cond_iconset->m_oIconSet.get2()));
ods_context->current_table().set_conditional_iconset(oox_cond_iconset->m_oIconSet->GetValue());
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMaxLength;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMinLength;
//nullable<SimpleTypes::COnOff<>> m_oShowValue;
......@@ -1564,9 +1564,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatValueObject *oox
{
if (!oox_cond_value)return;
std::wstring val, type;
std::wstring val;
int type = 3;
if (oox_cond_value->m_oVal.IsInit()) val = string2std_string(oox_cond_value->m_oVal.get2());
if (oox_cond_value->m_oType.IsInit()) type = string2std_string(oox_cond_value->m_oType.get2());
if (oox_cond_value->m_oType.IsInit()) type = oox_cond_value->m_oType->GetValue();
ods_context->current_table().set_conditional_value(type,val);
}
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//51
#define INTVER 1,2,0,51
#define STRVER "1,2,0,51\0"
//52
#define INTVER 1,2,0,52
#define STRVER "1,2,0,52\0"
......@@ -1997,5 +1997,213 @@ namespace SimpleTypes
SimpleType_FromString (EDynamicFilterType)
SimpleType_Operator_Equal (CDynamicFilterType)
};
//--------------------------------------------------------
// ST_IconSetType (18.18.42)
//--------------------------------------------------------
enum EIconSetType
{
Arrows3 = 0,
Arrows3Gray = 1,
Flags3 = 2,
Signs3 = 3,
Symbols3 = 4,
Symbols3_2 = 5,
Traffic3Lights1 = 6,
Traffic3Lights2 = 7,
Arrows4 = 8,
Arrows4Gray = 9,
Rating4 = 10,
RedToBlack4 = 11,
Traffic4Lights = 12,
Arrows5 = 13,
Arrows5Gray = 14,
Quarters5 = 15,
Rating5 = 16
};
template<EIconSetType eDefValue = Arrows3>
class ST_IconSetType : public CSimpleType<EIconSetType, eDefValue>
{
public:
ST_IconSetType() {}
virtual EIconSetType FromString(CString &sValue)
{
if(_T("3Arrows") == sValue) m_eValue = Arrows3;
else if(_T("3ArrowsGray") == sValue) m_eValue = Arrows3Gray;
else if(_T("3Flags") == sValue) m_eValue = Flags3;
else if(_T("3Signs") == sValue) m_eValue = Signs3;
else if(_T("3Symbols") == sValue) m_eValue = Symbols3;
else if(_T("3Symbols2") == sValue) m_eValue = Symbols3_2;
else if(_T("3TrafficLights1") == sValue)m_eValue = Traffic3Lights1;
else if(_T("3TrafficLights2") == sValue)m_eValue = Traffic3Lights2;
else if(_T("4Arrows") == sValue) m_eValue = Arrows4;
else if(_T("4ArrowsGray") == sValue) m_eValue = Arrows4Gray;
else if(_T("4Rating") == sValue) m_eValue = Rating4;
else if(_T("4RedToBlack") == sValue) m_eValue = RedToBlack4;
else if(_T("4TrafficLights") == sValue) m_eValue = Traffic4Lights;
else if(_T("5Arrows") == sValue) m_eValue = Arrows5;
else if(_T("5ArrowsGray") == sValue) m_eValue = Arrows5Gray;
else if(_T("5Quarters") == sValue) m_eValue = Quarters5;
else if(_T("5Rating") == sValue) m_eValue = Rating5;
else m_eValue = eDefValue;
return m_eValue;
}
virtual CString ToString () const
{
switch(m_eValue)
{
case Arrows3 : return _T("3Arrows"); break;
case Arrows3Gray : return _T("3ArrowsGray"); break;
case Flags3 : return _T("3Flags"); break;
case Signs3 : return _T("3Signs"); break;
case Symbols3 : return _T("3Symbols"); break;
case Symbols3_2 : return _T("3Symbols2"); break;
case Traffic3Lights1: return _T("3TrafficLights1");break;
case Traffic3Lights2: return _T("3TrafficLights2");break;
case Arrows4 : return _T("4Arrows"); break;
case Arrows4Gray : return _T("4ArrowsGray"); break;
case Rating4 : return _T("4Rating"); break;
case RedToBlack4 : return _T("4RedToBlack"); break;
case Traffic4Lights : return _T("4TrafficLights");break;
case Arrows5 : return _T("5Arrows"); break;
case Arrows5Gray : return _T("5ArrowsGray"); break;
case Quarters5 : return _T("5Quarters"); break;
case Rating5 : return _T("5Rating"); break;
default : return _T("3Arrows");
}
}
SimpleType_FromString (EIconSetType)
SimpleType_Operator_Equal (ST_IconSetType)
};
//----------------------------------------------------
// 18.18.12 ST_CfType (Conditional Format Type)
//----------------------------------------------------
enum ECfType
{
aboveAverage = 0,
beginsWith = 1,
cellIs = 2,
colorScale = 3,
containsBlanks = 4,
containsErrors = 5,
containsText = 6,
dataBar = 7,
duplicateValues = 8,
expression = 9,
iconSet = 10,
notContainsBlanks = 11,
notContainsErrors = 12,
notContainsText = 13,
timePeriod = 14,
top10 = 15,
uniqueValues = 16
};
template<ECfType eDefValue = dataBar>
class ST_CfType : public CSimpleType<ECfType, eDefValue>
{
public:
ST_CfType() {}
virtual ECfType FromString(CString &sValue)
{
if(_T("aboveAverage") == sValue) m_eValue = aboveAverage;
else if(_T("beginsWith") == sValue) m_eValue = beginsWith;
else if(_T("cellIs") == sValue) m_eValue = cellIs;
else if(_T("colorScale") == sValue) m_eValue = colorScale;
else if(_T("containsBlanks") == sValue) m_eValue = containsBlanks;
else if(_T("containsText") == sValue) m_eValue = containsText;
else if(_T("containsErrors") == sValue) m_eValue = containsErrors;
else if(_T("dataBar") == sValue) m_eValue = dataBar;
else if(_T("duplicateValues") == sValue) m_eValue = duplicateValues;
else if(_T("expression") == sValue) m_eValue = expression;
else if(_T("iconSet") == sValue) m_eValue = iconSet;
else if(_T("notContainsBlanks") == sValue) m_eValue = notContainsBlanks;
else if(_T("notContainsErrors") == sValue) m_eValue = notContainsErrors;
else if(_T("notContainsText") == sValue) m_eValue = notContainsText;
else if(_T("timePeriod") == sValue) m_eValue = timePeriod;
else if(_T("top10") == sValue) m_eValue = top10;
else if(_T("uniqueValues") == sValue) m_eValue = uniqueValues;
else m_eValue = eDefValue;
return m_eValue;
}
virtual CString ToString () const
{
switch(m_eValue)
{
case aboveAverage : return _T("aboveAverage"); break;
case beginsWith : return _T("beginsWith"); break;
case cellIs : return _T("cellIs"); break;
case colorScale : return _T("colorScale"); break;
case containsBlanks : return _T("containsBlanks"); break;
case containsErrors : return _T("containsErrors"); break;
case containsText : return _T("containsText"); break;
case dataBar : return _T("dataBar"); break;
case duplicateValues : return _T("duplicateValues"); break;
case expression : return _T("expression"); break;
case iconSet : return _T("iconSet"); break;
case notContainsBlanks : return _T("notContainsBlanks"); break;
case notContainsErrors : return _T("notContainsErrors"); break;
case notContainsText : return _T("notContainsText"); break;
case timePeriod : return _T("timePeriod"); break;
case top10 : return _T("top10"); break;
case uniqueValues : return _T("uniqueValues"); break;
default : return _T("dataBar");
}
}
SimpleType_FromString (ECfType)
SimpleType_Operator_Equal (ST_CfType)
};
//----------------------------------------------------
// 18.18.13 ST_CfvoType (Conditional Format Value Object Type)
//----------------------------------------------------
enum ECfvoType
{
Formula = 0,
Maximum = 1,
Minimum = 2,
Number = 3,
Percent = 4,
Percentile = 5,
};
template<ECfvoType eDefValue = Number>
class ST_CfvoType : public CSimpleType<ECfvoType, eDefValue>
{
public:
ST_CfvoType() {}
virtual ECfvoType FromString(CString &sValue)
{
if(_T("formula") == sValue) m_eValue = Formula;
else if(_T("max") == sValue) m_eValue = Maximum;
else if(_T("min") == sValue) m_eValue = Minimum;
else if(_T("num") == sValue) m_eValue = Number;
else if(_T("percent") == sValue) m_eValue = Percent;
else if(_T("percentile") == sValue) m_eValue = Percentile;
else m_eValue = eDefValue;
return m_eValue;
}
virtual CString ToString () const
{
switch(m_eValue)
{
case Formula: return _T("formula"); break;
case Maximum: return _T("min"); break;
case Minimum: return _T("max"); break;
case Number: return _T("num"); break;
case Percent: return _T("percent"); break;
case Percentile:return _T("percentile"); break;
default : return _T("num");
}
}
SimpleType_FromString (ECfvoType)
SimpleType_Operator_Equal (ST_CfvoType)
};
};// Spreadsheet
} // SimpleTypes
......@@ -72,9 +72,9 @@ namespace OOX
}
public:
nullable<SimpleTypes::COnOff<>> m_oGte;
nullable<CString> m_oType; // ToDo ST_CfvoType (18.18.12)
nullable<CString> m_oVal;
nullable<SimpleTypes::COnOff<>> m_oGte;
nullable<SimpleTypes::Spreadsheet::ST_CfvoType<>> m_oType;
nullable<CString> m_oVal;
};
class CColorScale : public WritingElementWithChilds<WritingElement>
......@@ -346,10 +346,10 @@ namespace OOX
}
public:
nullable<CString> m_oIconSet; // ToDo ST_IconSetType (18.18.42)
nullable<SimpleTypes::COnOff<>> m_oPercent;
nullable<SimpleTypes::COnOff<>> m_oReverse;
nullable<SimpleTypes::COnOff<>> m_oShowValue;
nullable<SimpleTypes::Spreadsheet::ST_IconSetType<>>m_oIconSet;
nullable<SimpleTypes::COnOff<>> m_oPercent;
nullable<SimpleTypes::COnOff<>> m_oReverse;
nullable<SimpleTypes::COnOff<>> m_oShowValue;
};
//:
......@@ -491,7 +491,7 @@ namespace OOX
nullable<SimpleTypes::COnOff<>> m_oStopIfTrue;
nullable<CString> m_oText;
nullable<CString> m_oTimePeriod; // ToDo ST_TimePeriod (18.18.82)
nullable<CString> m_oType; // ToDo ST_CfType (18.18.12)
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