Commit d76b1897 authored by konovalovsergey's avatar konovalovsergey

save conditionalFormating to xlsx

parent 857b79ee
...@@ -2077,7 +2077,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_f ...@@ -2077,7 +2077,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_f
if (oox_cond_fmt->m_oSqRef.IsInit()) if (oox_cond_fmt->m_oSqRef.IsInit())
{ {
ods_context->current_table().start_conditional_format(oox_cond_fmt->m_oSqRef->GetValue()); ods_context->current_table().start_conditional_format(oox_cond_fmt->m_oSqRef.get());
for (unsigned int i=0; i< oox_cond_fmt->m_arrItems.size(); i++) for (unsigned int i=0; i< oox_cond_fmt->m_arrItems.size(); i++)
convert(oox_cond_fmt->m_arrItems[i]);//rule convert(oox_cond_fmt->m_arrItems[i]);//rule
......
...@@ -386,7 +386,7 @@ namespace OOX ...@@ -386,7 +386,7 @@ namespace OOX
} }
virtual void toXML(NSStringUtils::CStringBuilder& writer) const virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{ {
if (m_oType.IsInit() && m_oPriority.IsInit() && 0 < m_arrItems.size()) if (isValid())
{ {
writer.WriteString(L"<cfRule"); writer.WriteString(L"<cfRule");
WritingStringAttrString(L"type", m_oType->ToString()); WritingStringAttrString(L"type", m_oType->ToString());
...@@ -398,7 +398,7 @@ namespace OOX ...@@ -398,7 +398,7 @@ namespace OOX
WritingStringNullableAttrInt(L"dxfId", m_oDxfId, m_oDxfId->GetValue()); WritingStringNullableAttrInt(L"dxfId", m_oDxfId, m_oDxfId->GetValue());
if (m_oEqualAverage.IsInit() && true == m_oEqualAverage->ToBool()) if (m_oEqualAverage.IsInit() && true == m_oEqualAverage->ToBool())
writer.WriteString(_T (" equalAverage=\"1\"")); writer.WriteString(_T (" equalAverage=\"1\""));
WritingStringNullableAttrString(L"text", m_oOperator, m_oOperator->ToString()); WritingStringNullableAttrString(L"operator", m_oOperator, m_oOperator->ToString());
if (m_oPercent.IsInit() && true == m_oPercent->ToBool()) if (m_oPercent.IsInit() && true == m_oPercent->ToBool())
writer.WriteString(_T (" percent=\"1\"")); writer.WriteString(_T (" percent=\"1\""));
WritingStringNullableAttrInt(L"rank", m_oRank, m_oRank->GetValue()); WritingStringNullableAttrInt(L"rank", m_oRank, m_oRank->GetValue());
...@@ -443,6 +443,11 @@ namespace OOX ...@@ -443,6 +443,11 @@ namespace OOX
return et_ConditionalFormattingRule; return et_ConditionalFormattingRule;
} }
bool isValid () const
{
return m_oType.IsInit() && m_oPriority.IsInit();
}
private: private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
...@@ -503,11 +508,19 @@ namespace OOX ...@@ -503,11 +508,19 @@ namespace OOX
} }
virtual void toXML(NSStringUtils::CStringBuilder& writer) const virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{ {
if (m_oSqRef.IsInit() && 0 < m_arrItems.size()) bool isValid = false;
for(int i = 0; i < m_arrItems.size(); ++i)
{
if(m_arrItems[i]->isValid())
{
isValid = true;
break;
}
}
if (m_oSqRef.IsInit() && isValid)
{ {
std::wstring sRoot;
writer.WriteString(L"<conditionalFormatting"); writer.WriteString(L"<conditionalFormatting");
WritingStringAttrString(L"sqref", m_oSqRef->ToString()); WritingStringAttrString(L"sqref", m_oSqRef.get());
if (m_oPivot.IsInit() && true == m_oPivot->ToBool()) if (m_oPivot.IsInit() && true == m_oPivot->ToBool())
{ {
...@@ -557,7 +570,7 @@ namespace OOX ...@@ -557,7 +570,7 @@ namespace OOX
} }
public: public:
nullable<SimpleTypes::COnOff<>> m_oPivot; nullable<SimpleTypes::COnOff<>> m_oPivot;
nullable<SimpleTypes::CRelationshipId > m_oSqRef; // ToDo переделать на тип "sqref" (18.18.76) - последовательность "ref", разделенные пробелом nullable<std::wstring > m_oSqRef; // ToDo переделать на тип "sqref" (18.18.76) - последовательность "ref", разделенные пробелом
}; };
} //Spreadsheet } //Spreadsheet
} // namespace OOX } // namespace OOX
......
...@@ -348,7 +348,7 @@ namespace OOX ...@@ -348,7 +348,7 @@ namespace OOX
if(m_oSheetData.IsInit()) if(m_oSheetData.IsInit())
m_oSheetData->toXML(sXml); m_oSheetData->toXML(sXml);
for (unsigned int nIndex = 0, nLength = m_arrConditionalFormatting.size(); nIndex < nLength; ++nIndex) for (unsigned int nIndex = 0, nLength = m_arrConditionalFormatting.size(); nIndex < nLength; ++nIndex)
m_arrConditionalFormatting[nIndex]->toXML(); m_arrConditionalFormatting[nIndex]->toXML(sXml);
if(m_oAutofilter.IsInit()) if(m_oAutofilter.IsInit())
m_oAutofilter->toXML(sXml); m_oAutofilter->toXML(sXml);
if(m_oMergeCells.IsInit()) if(m_oMergeCells.IsInit())
...@@ -425,6 +425,10 @@ namespace OOX ...@@ -425,6 +425,10 @@ namespace OOX
m_mapComments.clear(); m_mapComments.clear();
// delete Conditional Formatting // delete Conditional Formatting
for (unsigned int nIndex = 0, nLength = m_arrConditionalFormatting.size(); nIndex < nLength; ++nIndex)
{
delete m_arrConditionalFormatting[nIndex];
}
m_arrConditionalFormatting.clear(); m_arrConditionalFormatting.clear();
} }
private: private:
......
...@@ -3287,7 +3287,7 @@ namespace BinXlsxRW { ...@@ -3287,7 +3287,7 @@ namespace BinXlsxRW {
if (oConditionalFormatting.m_oSqRef.IsInit()) if (oConditionalFormatting.m_oSqRef.IsInit())
{ {
m_oBcw.m_oStream.WriteBYTE(c_oSer_ConditionalFormatting::SqRef); m_oBcw.m_oStream.WriteBYTE(c_oSer_ConditionalFormatting::SqRef);
m_oBcw.m_oStream.WriteStringW(oConditionalFormatting.m_oSqRef->ToString()); m_oBcw.m_oStream.WriteStringW(oConditionalFormatting.m_oSqRef.get());
} }
if (0 < oConditionalFormatting.m_arrItems.size()) if (0 < oConditionalFormatting.m_arrItems.size())
...@@ -3323,7 +3323,7 @@ namespace BinXlsxRW { ...@@ -3323,7 +3323,7 @@ namespace BinXlsxRW {
} }
if (oConditionalFormattingRule.m_oDxfId.IsInit()) if (oConditionalFormattingRule.m_oDxfId.IsInit())
{ {
nCurPos = m_oBcw.WriteItemStart(c_oSer_TableColumns::DataDxfId); nCurPos = m_oBcw.WriteItemStart(c_oSer_ConditionalFormattingRule::DxfId);
m_oBcw.m_oStream.WriteLONG(oConditionalFormattingRule.m_oDxfId->GetValue()); m_oBcw.m_oStream.WriteLONG(oConditionalFormattingRule.m_oDxfId->GetValue());
m_oBcw.WriteItemEnd(nCurPos); m_oBcw.WriteItemEnd(nCurPos);
} }
......
This diff is collapsed.
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