summaryrefslogtreecommitdiff
path: root/sc/source/filter/excel/xecontent.cxx
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-11-05 01:24:45 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-11-05 01:26:27 +0100
commitc2e91c7d8cb027f3f8f06130e3d6552a0c6750ab (patch)
tree124e2f4d47762f8fdd944d275ad04e63aac60ab3 /sc/source/filter/excel/xecontent.cxx
parent0f96fa7b59c48f5f00d5987265a7a73091472b24 (diff)
fix several bugs around cond format export to ooxml
Change-Id: I4d9c8ea0cc778f5620136548324054b625938887
Diffstat (limited to 'sc/source/filter/excel/xecontent.cxx')
-rw-r--r--sc/source/filter/excel/xecontent.cxx65
1 files changed, 52 insertions, 13 deletions
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index ffca41ec6e80..557538e46871 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -824,7 +824,7 @@ const char* GetOperatorString(ScConditionMode eMode, bool& bFrmla2)
break;
case SC_COND_NONE:
default:
- pRet = "";
+ pRet = "equal";
break;
}
return pRet;
@@ -852,6 +852,14 @@ const char* GetTypeString(ScConditionMode eMode)
return "containsErrors";
case SC_COND_NOERROR:
return "notContainsErrors";
+ case SC_COND_BEGINS_WITH:
+ return "beginsWith";
+ case SC_COND_ENDS_WITH:
+ return "endsWith";
+ case SC_COND_CONTAINS_TEXT:
+ return "containsText";
+ case SC_COND_NOT_CONTAINS_TEXT:
+ return "notContainsText";
default:
return "cellIs";
}
@@ -873,6 +881,22 @@ bool IsTopBottomRule(ScConditionMode eMode)
return false;
}
+bool IsTextRule(ScConditionMode eMode)
+{
+ switch(eMode)
+ {
+ case SC_COND_BEGINS_WITH:
+ case SC_COND_ENDS_WITH:
+ case SC_COND_CONTAINS_TEXT:
+ case SC_COND_NOT_CONTAINS_TEXT:
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
}
void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
@@ -884,13 +908,23 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
|| eOperation == SC_COND_BOTTOM_PERCENT;
sal_Int32 nPercent = eOperation == SC_COND_TOP_PERCENT ||
eOperation == SC_COND_BOTTOM_PERCENT;
- rtl::OString aRank;
+ rtl::OString aRank("0");
if(IsTopBottomRule(eOperation))
{
// position and formula grammar are not important
// we only store a number there
aRank = XclXmlUtils::ToOString(mrFormatEntry.GetExpression(ScAddress(0,0,0), 0));
}
+ rtl::OString aText;
+ if(IsTextRule(eOperation))
+ {
+ // we need to write the text without quotes
+ // we have to actually get the string from
+ // the token array for that
+ ScTokenArray* pTokenArray = mrFormatEntry.CreateTokenArry(0);
+ if(pTokenArray->GetLen())
+ aText = XclXmlUtils::ToOString(pTokenArray->First()->GetString());
+ }
sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
rWorksheet->startElement( XML_cfRule,
@@ -901,16 +935,20 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
XML_bottom, OString::valueOf( nBottom ).getStr(),
XML_percent, OString::valueOf( nPercent ).getStr(),
XML_rank, aRank.getStr(),
+ XML_text, aText.getStr(),
XML_dxfId, OString::valueOf( GetDxfs().GetDxfId( mrFormatEntry.GetStyle() ) ).getStr(),
FSEND );
- rWorksheet->startElement( XML_formula, FSEND );
- rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 0 ) ));
- rWorksheet->endElement( XML_formula );
- if (bFmla2)
+ if(!IsTextRule(eOperation) && !IsTopBottomRule(eOperation))
{
rWorksheet->startElement( XML_formula, FSEND );
- rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 1 ) ));
+ rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 0 ) ));
rWorksheet->endElement( XML_formula );
+ if (bFmla2)
+ {
+ rWorksheet->startElement( XML_formula, FSEND );
+ rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 1 ) ));
+ rWorksheet->endElement( XML_formula );
+ }
}
// OOXTODO: XML_extLst
rWorksheet->endElement( XML_cfRule );
@@ -1025,7 +1063,7 @@ void XclExpColScaleCol::SaveXml( XclExpXmlStream& rStrm )
// ----------------------------------------------------------------------------
-XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst ) :
+XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst, sal_Int32& rIndex ) :
XclExpRecord( EXC_ID_CONDFMT ),
XclExpRoot( rRoot )
{
@@ -1037,13 +1075,13 @@ XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat
if( const ScFormatEntry* pFormatEntry = rCondFormat.GetEntry( nIndex ) )
{
if(pFormatEntry->GetType() == condformat::CONDITION)
- maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), nIndex ) );
+ maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), ++rIndex ) );
else if(pFormatEntry->GetType() == condformat::COLORSCALE)
- maCFList.AppendNewRecord( new XclExpColorScale( GetRoot(), static_cast<const ScColorScaleFormat&>(*pFormatEntry), nIndex ) );
+ maCFList.AppendNewRecord( new XclExpColorScale( GetRoot(), static_cast<const ScColorScaleFormat&>(*pFormatEntry), ++rIndex ) );
else if(pFormatEntry->GetType() == condformat::DATABAR)
- maCFList.AppendNewRecord( new XclExpDataBar( GetRoot(), static_cast<const ScDataBarFormat&>(*pFormatEntry), nIndex, xExtLst ) );
+ maCFList.AppendNewRecord( new XclExpDataBar( GetRoot(), static_cast<const ScDataBarFormat&>(*pFormatEntry), ++rIndex, xExtLst ) );
else if(pFormatEntry->GetType() == condformat::ICONSET)
- maCFList.AppendNewRecord( new XclExpIconSet( GetRoot(), static_cast<const ScIconSetFormat&>(*pFormatEntry), nIndex ) );
+ maCFList.AppendNewRecord( new XclExpIconSet( GetRoot(), static_cast<const ScIconSetFormat&>(*pFormatEntry), ++rIndex ) );
}
aScRanges.Format( msSeqRef, SCA_VALID, NULL, formula::FormulaGrammar::CONV_XL_A1 );
}
@@ -1293,10 +1331,11 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtL
{
if( const ScConditionalFormatList* pCondFmtList = GetDoc().GetCondFormList(GetCurrScTab()) )
{
+ sal_Int32 nIndex = 0;
for( ScConditionalFormatList::const_iterator itr = pCondFmtList->begin();
itr != pCondFmtList->end(); ++itr)
{
- XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), *itr, xExtLst ) );
+ XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), *itr, xExtLst, nIndex ));
if( xCondfmtRec->IsValid() )
maCondfmtList.AppendRecord( xCondfmtRec );
}