diff options
-rw-r--r-- | sc/inc/conditio.hxx | 50 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 124 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 9 | ||||
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 9 | ||||
-rw-r--r-- | sc/source/filter/excel/xicontent.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 124 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlg.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/inc/condformatdlg.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/fmtuno.cxx | 20 |
10 files changed, 216 insertions, 151 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index 6a62a2b24fda..9a7f1af0ac15 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -37,6 +37,7 @@ #include "rangelst.hxx" #include <boost/ptr_container/ptr_set.hpp> +#include <boost/ptr_container/ptr_vector.hpp> class ScBaseCell; class ScFormulaCell; @@ -70,7 +71,34 @@ enum ScConditionMode class ScConditionalFormat; -class SC_DLLPUBLIC ScConditionEntry +namespace condformat +{ + +enum ScFormatEntryType +{ + CONDITION, + COLORSCALE, + DATABAR +}; + +} + +class SC_DLLPUBLIC ScFormatEntry +{ +public: + virtual ~ScFormatEntry() {} + + virtual condformat::ScFormatEntryType GetType() const = 0; + virtual void UpdateReference( UpdateRefMode eUpdateRefMode, + const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) = 0; + virtual void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) = 0; + + virtual ScFormatEntry* Clone( ScDocument* pDoc ) const = 0; + + virtual void SetParent( ScConditionalFormat* pNew ) = 0; +}; + +class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry { // stored data: ScConditionMode eOp; @@ -125,7 +153,7 @@ public: int operator== ( const ScConditionEntry& r ) const; - void SetParent( ScConditionalFormat* pNew ) { pCondFormat = pNew; } + virtual void SetParent( ScConditionalFormat* pNew ) { pCondFormat = pNew; } bool IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) const; @@ -156,6 +184,10 @@ public: bool MarkUsedExternalReferences() const; + virtual condformat::ScFormatEntryType GetType() const { return condformat::CONDITION; } + + virtual ScFormatEntry* Clone(ScDocument* pDoc) const; + protected: virtual void DataChanged( const ScRange* pModified ) const; ScDocument* GetDocument() const { return pDoc; } @@ -193,6 +225,7 @@ public: const String& GetStyle() const { return aStyleName; } void UpdateStyleName(const String& rNew) { aStyleName=rNew; } + virtual ScFormatEntry* Clone(ScDocument* pDoc) const; protected: virtual void DataChanged( const ScRange* pModified ) const; @@ -207,8 +240,9 @@ class SC_DLLPUBLIC ScConditionalFormat ScDocument* pDoc; ScRangeList* pAreas; // area for Paint sal_uInt32 nKey; // Index in attributes - ScCondFormatEntry** ppEntries; - sal_uInt16 nEntryCount; + + typedef boost::ptr_vector<ScFormatEntry> CondFormatContainer; + CondFormatContainer maEntries; bool bIsUsed; // temporary at Save ScRangeListRef pRanges; // Ranges for conditional format @@ -220,12 +254,12 @@ public: // true copy of formulas (for Ref-Undo / between documents) ScConditionalFormat* Clone(ScDocument* pNewDoc = NULL) const; - void AddEntry( const ScCondFormatEntry& rNew ); + void AddEntry( ScFormatEntry* pNew ); void AddRangeInfo( const ScRangeListRef& rRanges ); const ScRangeListRef& GetRangeInfo() const { return pRanges; } - bool IsEmpty() const { return (nEntryCount == 0); } - sal_uInt16 Count() const { return nEntryCount; } + bool IsEmpty() const { return maEntries.empty(); } + size_t size() const { return maEntries.size(); } void CompileAll(); void CompileXML(); @@ -236,7 +270,7 @@ public: void SourceChanged( const ScAddress& rAddr ); - const ScCondFormatEntry* GetEntry( sal_uInt16 nPos ) const; + const ScFormatEntry* GetEntry( sal_uInt16 nPos ) const; const String& GetCellStyle( ScBaseCell* pCell, const ScAddress& rPos ) const; diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index cab62b3e35fc..24703f359d57 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1191,6 +1191,11 @@ bool ScConditionEntry::MarkUsedExternalReferences() const return bAllMarked; } +ScFormatEntry* ScConditionEntry::Clone(ScDocument* pDoc) const +{ + return new ScConditionEntry(pDoc, *this); +} + //------------------------------------------------------------------------ ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper, @@ -1244,14 +1249,17 @@ void ScCondFormatEntry::DataChanged( const ScRange* pModified ) const pCondFormat->DoRepaint( pModified ); } +ScFormatEntry* ScCondFormatEntry::Clone( ScDocument* pDoc ) const +{ + return new ScCondFormatEntry( pDoc, *this ); +} + //------------------------------------------------------------------------ ScConditionalFormat::ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument) : pDoc( pDocument ), pAreas( NULL ), nKey( nNewKey ), - ppEntries( NULL ), - nEntryCount( 0 ), pRanges( NULL ) { } @@ -1260,19 +1268,15 @@ ScConditionalFormat::ScConditionalFormat(const ScConditionalFormat& r) : pDoc( r.pDoc ), pAreas( NULL ), nKey( r.nKey ), - ppEntries( NULL ), - nEntryCount( r.nEntryCount ), pRanges( NULL ) { - if (nEntryCount) + for (CondFormatContainer::const_iterator itr = r.maEntries.begin(); itr != r.maEntries.end(); ++itr) { - ppEntries = new ScCondFormatEntry*[nEntryCount]; - for (sal_uInt16 i=0; i<nEntryCount; i++) - { - ppEntries[i] = new ScCondFormatEntry(*r.ppEntries[i]); - ppEntries[i]->SetParent(this); - } + ScFormatEntry* pNewEntry = itr->Clone(r.pDoc); + maEntries.push_back( pNewEntry ); + pNewEntry->SetParent(this); } + if (r.pRanges) pRanges = new ScRangeList( *r.pRanges ); } @@ -1285,17 +1289,12 @@ ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const pNewDoc = pDoc; ScConditionalFormat* pNew = new ScConditionalFormat(nKey, pNewDoc); - OSL_ENSURE(!pNew->ppEntries, "wo kommen die Eintraege her?"); - if (nEntryCount) + for (CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) { - pNew->ppEntries = new ScCondFormatEntry*[nEntryCount]; - for (sal_uInt16 i=0; i<nEntryCount; i++) - { - pNew->ppEntries[i] = new ScCondFormatEntry( pNewDoc, *ppEntries[i] ); - pNew->ppEntries[i]->SetParent(pNew); - } - pNew->nEntryCount = nEntryCount; + ScFormatEntry* pNewEntry = itr->Clone(pNewDoc); + pNew->maEntries.push_back( pNewEntry ); + pNewEntry->SetParent(pNew); } pNew->AddRangeInfo( pRanges ); @@ -1304,14 +1303,16 @@ ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const bool ScConditionalFormat::EqualEntries( const ScConditionalFormat& r ) const { - if ( nEntryCount != r.nEntryCount ) + if( size() != r.size()) return false; //! auf gleiche Eintraege in anderer Reihenfolge testen ??? + /* for (sal_uInt16 i=0; i<nEntryCount; i++) if ( ! (*ppEntries[i] == *r.ppEntries[i]) ) return false; + */ if (pRanges) { @@ -1332,40 +1333,36 @@ void ScConditionalFormat::AddRangeInfo( const ScRangeListRef& rRanges ) pRanges = new ScRangeList( *rRanges ); } -void ScConditionalFormat::AddEntry( const ScCondFormatEntry& rNew ) +void ScConditionalFormat::AddEntry( ScFormatEntry* pNew ) { - ScCondFormatEntry** ppNew = new ScCondFormatEntry*[nEntryCount+1]; - for (sal_uInt16 i=0; i<nEntryCount; i++) - ppNew[i] = ppEntries[i]; - ppNew[nEntryCount] = new ScCondFormatEntry(rNew); - ppNew[nEntryCount]->SetParent(this); - ++nEntryCount; - delete[] ppEntries; - ppEntries = ppNew; + maEntries.push_back(pNew); + pNew->SetParent(this); } ScConditionalFormat::~ScConditionalFormat() { - for (sal_uInt16 i=0; i<nEntryCount; i++) - delete ppEntries[i]; - delete[] ppEntries; - delete pAreas; } -const ScCondFormatEntry* ScConditionalFormat::GetEntry( sal_uInt16 nPos ) const +const ScFormatEntry* ScConditionalFormat::GetEntry( sal_uInt16 nPos ) const { - if ( nPos < nEntryCount ) - return ppEntries[nPos]; + if ( nPos < size() ) + return &maEntries[nPos]; else return NULL; } const String& ScConditionalFormat::GetCellStyle( ScBaseCell* pCell, const ScAddress& rPos ) const { - for (sal_uInt16 i=0; i<nEntryCount; i++) - if ( ppEntries[i]->IsCellValid( pCell, rPos ) ) - return ppEntries[i]->GetStyle(); + for (CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) + { + if(itr->GetType() == condformat::CONDITION) + { + const ScCondFormatEntry& rEntry = static_cast<const ScCondFormatEntry&>(*itr); + if ( rEntry.IsCellValid( pCell, rPos ) ) + return rEntry.GetStyle(); + } + } return EMPTY_STRING; } @@ -1431,6 +1428,7 @@ bool lcl_CutRange( ScRange& rRange, const ScRange& rOther ) void ScConditionalFormat::DoRepaint( const ScRange* pModified ) { + /* SfxObjectShell* pSh = pDoc->GetDocumentShell(); if (pSh) { @@ -1510,6 +1508,7 @@ void ScConditionalFormat::DoRepaint( const ScRange* pModified ) } } } + */ } void ScConditionalFormat::InvalidateArea() @@ -1520,14 +1519,16 @@ void ScConditionalFormat::InvalidateArea() void ScConditionalFormat::CompileAll() { - for (sal_uInt16 i=0; i<nEntryCount; i++) - ppEntries[i]->CompileAll(); + for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) + if(itr->GetType() == condformat::CONDITION) + static_cast<ScCondFormatEntry&>(*itr).CompileAll(); } void ScConditionalFormat::CompileXML() { - for (sal_uInt16 i=0; i<nEntryCount; i++) - ppEntries[i]->CompileXML(); + for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) + if(itr->GetType() == condformat::CONDITION) + static_cast<ScCondFormatEntry&>(*itr).CompileXML(); } void ScConditionalFormat::UpdateReference( UpdateRefMode eUpdateRefMode, @@ -1535,8 +1536,8 @@ void ScConditionalFormat::UpdateReference( UpdateRefMode eUpdateRefMode, { if(pRanges) pRanges->UpdateReference( eUpdateRefMode, pDoc, rRange, nDx, nDy, nDz ); - for (sal_uInt16 i=0; i<nEntryCount; i++) - ppEntries[i]->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz); + for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) + itr->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz); delete pAreas; // aus dem AttrArray kommt beim Einfuegen/Loeschen kein Aufruf pAreas = NULL; @@ -1544,9 +1545,13 @@ void ScConditionalFormat::UpdateReference( UpdateRefMode eUpdateRefMode, void ScConditionalFormat::RenameCellStyle(const String& rOld, const String& rNew) { - for (sal_uInt16 i=0; i<nEntryCount; i++) - if ( ppEntries[i]->GetStyle() == rOld ) - ppEntries[i]->UpdateStyleName( rNew ); + for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) + if(itr->GetType() == condformat::CONDITION) + { + ScCondFormatEntry& rFormat = static_cast<ScCondFormatEntry&>(*itr); + if(rFormat.GetStyle() == rOld) + rFormat.UpdateStyleName( rNew ); + } } void ScConditionalFormat::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) @@ -1585,8 +1590,8 @@ void ScConditionalFormat::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) } } - for (sal_uInt16 i=0; i<nEntryCount; i++) - ppEntries[i]->UpdateMoveTab( nOldPos, nNewPos ); + for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) + itr->UpdateMoveTab( nOldPos, nNewPos ); delete pAreas; // aus dem AttrArray kommt beim Einfuegen/Loeschen kein Aufruf pAreas = NULL; @@ -1594,15 +1599,24 @@ void ScConditionalFormat::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) void ScConditionalFormat::SourceChanged( const ScAddress& rAddr ) { - for (sal_uInt16 i=0; i<nEntryCount; i++) - ppEntries[i]->SourceChanged( rAddr ); + for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) + if(itr->GetType() == condformat::CONDITION) + { + ScCondFormatEntry& rFormat = static_cast<ScCondFormatEntry&>(*itr); + rFormat.SourceChanged( rAddr ); + } } bool ScConditionalFormat::MarkUsedExternalReferences() const { bool bAllMarked = false; - for (sal_uInt16 i=0; !bAllMarked && i<nEntryCount; i++) - bAllMarked = ppEntries[i]->MarkUsedExternalReferences(); + for(CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end() && !bAllMarked; ++itr) + if(itr->GetType() == condformat::CONDITION) + { + const ScCondFormatEntry& rFormat = static_cast<const ScCondFormatEntry&>(*itr); + bAllMarked = rFormat.MarkUsedExternalReferences(); + } + return bAllMarked; } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index fb90b0a3c585..802a1d828962 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1793,10 +1793,14 @@ void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCC const ScConditionalFormat* pFormat = mpCondFormatList->GetFormat(nIndex); if ( pFormat ) { - sal_uInt16 nEntryCount = pFormat->Count(); - for (sal_uInt16 nEntry=0; nEntry<nEntryCount; nEntry++) + size_t nEntryCount = pFormat->size(); + for (size_t nEntry=0; nEntry<nEntryCount; nEntry++) { - String aStyleName = pFormat->GetEntry(nEntry)->GetStyle(); + const ScFormatEntry* pEntry = pFormat->GetEntry(nEntry); + if(pEntry->GetType() != condformat::CONDITION) + continue; + + String aStyleName = static_cast<const ScCondFormatEntry*>(pEntry)->GetStyle(); if (aStyleName.Len()) { SfxStyleSheetBase* pStyleSheet = diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 7c8a34621c08..aa17d60482b9 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -967,9 +967,12 @@ XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat GetAddressConverter().ConvertRangeList( maXclRanges, aScRanges, true ); if( !maXclRanges.empty() ) { - for( sal_uInt16 nIndex = 0, nCount = rCondFormat.Count(); nIndex < nCount; ++nIndex ) - if( const ScCondFormatEntry* pEntry = rCondFormat.GetEntry( nIndex ) ) - maCFList.AppendNewRecord( new XclExpCF( GetRoot(), *pEntry, nIndex ) ); + for( size_t nIndex = 0, nCount = rCondFormat.size(); nIndex < nCount; ++nIndex ) + if( const ScFormatEntry* pFormatEntry = rCondFormat.GetEntry( nIndex ) ) + { + if(pFormatEntry->GetType() == condformat::CONDITION) + maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), nIndex ) ); + } aScRanges.Format( msSeqRef, SCA_VALID, NULL, formula::FormulaGrammar::CONV_XL_A1 ); } } diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 77d9deefe2c5..74ba92ac8ede 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -2861,12 +2861,13 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot ) for (ScConditionalFormatList::const_iterator itr = pList->begin(); itr != pList->end(); ++itr) { - sal_Int32 nEntryCount = itr->Count(); - for (sal_Int32 nFormatEntry = 0; nFormatEntry < nEntryCount; ++nFormatEntry) + size_t nEntryCount = itr->size(); + for (size_t nFormatEntry = 0; nFormatEntry < nEntryCount; ++nFormatEntry) { - const ScCondFormatEntry* pEntry = itr->GetEntry(nFormatEntry); - if (!pEntry) + const ScFormatEntry* pFormatEntry = itr->GetEntry(nFormatEntry); + if (!pFormatEntry || pFormatEntry->GetType() != condformat::CONDITION) continue; + const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry); rtl::OUString aStyleName = pEntry->GetStyle(); if (maStyleNameToDxfId.find(aStyleName) == maStyleNameToDxfId.end()) diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index f8d0ab3789d5..5c739b4f8738 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -637,8 +637,8 @@ void XclImpCondFormat::ReadCF( XclImpStream& rStrm ) mxScCondFmt.reset( new ScConditionalFormat( nKey, GetDocPtr() ) ); } - ScCondFormatEntry aEntry( eMode, xTokArr1.get(), pTokArr2.get(), GetDocPtr(), rPos, aStyleName ); - mxScCondFmt->AddEntry( aEntry ); + ScCondFormatEntry* pEntry = new ScCondFormatEntry( eMode, xTokArr1.get(), pTokArr2.get(), GetDocPtr(), rPos, aStyleName ); + mxScCondFmt->AddEntry( pEntry ); ++mnCondIndex; } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 0afdab06915c..19c562a4086c 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3842,69 +3842,73 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab) ScRangeStringConverter::GetStringFromRangeList( sRanges, pRangeList, pDoc, formula::FormulaGrammar::CONV_ODF ); AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TARGET_RANGE_ADDRESS, sRanges); SvXMLElementExport aElementCondFormat(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMAT, true, true); - sal_Int32 nEntries = itr->Count(); - for(sal_Int32 i = 0; i < nEntries; ++i) + size_t nEntries = itr->size(); + for(size_t i = 0; i < nEntries; ++i) { - const ScCondFormatEntry* pEntry = itr->GetEntry(i); - rtl::OUStringBuffer aCond; - switch(pEntry->GetOperation()) + const ScFormatEntry* pFormatEntry = itr->GetEntry(i); + if(pFormatEntry->GetType()==condformat::CONDITION) { - case SC_COND_EQUAL: - aCond.append('='); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - break; - case SC_COND_LESS: - aCond.append('<'); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - break; - case SC_COND_GREATER: - aCond.append('>'); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - break; - case SC_COND_EQLESS: - aCond.append("<="); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - break; - case SC_COND_EQGREATER: - aCond.append(">="); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - break; - case SC_COND_NOTEQUAL: - aCond.append("!="); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - break; - case SC_COND_BETWEEN: - aCond.append(rtl::OUString("between(")); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - aCond.append(','); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 1, 0, formula::FormulaGrammar::GRAM_ODFF)); - aCond.append(')'); - break; - case SC_COND_NOTBETWEEN: - aCond.append(rtl::OUString("not-between(")); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - aCond.append(','); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 1, 0, formula::FormulaGrammar::GRAM_ODFF)); - aCond.append(')'); - break; - case SC_COND_DUPLICATE: - aCond.append("duplicate"); - break; - case SC_COND_NOTDUPLICATE: - aCond.append("unique"); - break; - case SC_COND_DIRECT: - aCond.append("formula-is("); - aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); - aCond.append(')'); - break; - case SC_COND_NONE: - continue; + const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry); + rtl::OUStringBuffer aCond; + switch(pEntry->GetOperation()) + { + case SC_COND_EQUAL: + aCond.append('='); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + break; + case SC_COND_LESS: + aCond.append('<'); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + break; + case SC_COND_GREATER: + aCond.append('>'); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + break; + case SC_COND_EQLESS: + aCond.append("<="); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + break; + case SC_COND_EQGREATER: + aCond.append(">="); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + break; + case SC_COND_NOTEQUAL: + aCond.append("!="); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + break; + case SC_COND_BETWEEN: + aCond.append(rtl::OUString("between(")); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + aCond.append(','); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 1, 0, formula::FormulaGrammar::GRAM_ODFF)); + aCond.append(')'); + break; + case SC_COND_NOTBETWEEN: + aCond.append(rtl::OUString("not-between(")); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + aCond.append(','); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 1, 0, formula::FormulaGrammar::GRAM_ODFF)); + aCond.append(')'); + break; + case SC_COND_DUPLICATE: + aCond.append("duplicate"); + break; + case SC_COND_NOTDUPLICATE: + aCond.append("unique"); + break; + case SC_COND_DIRECT: + aCond.append("formula-is("); + aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF)); + aCond.append(')'); + break; + case SC_COND_NONE: + continue; + } + rtl::OUString sStyle = pEntry->GetStyle(); + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_APPLY_STYLE_NAME, sStyle); + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, aCond.makeStringAndClear()); + SvXMLElementExport aElementCondEntry(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITION, true, true); } - rtl::OUString sStyle = pEntry->GetStyle(); - AddAttribute(XML_NAMESPACE_CALC_EXT, XML_APPLY_STYLE_NAME, sStyle); - AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, aCond.makeStringAndClear()); - SvXMLElementExport aElementCondEntry(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITION, true, true); } } } diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 6db2584363ad..eb3d34c45d64 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -93,7 +93,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc): SetCondType(); } -ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScCondFormatEntry* pFormatEntry): +ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScFormatEntry* pFormatEntry): Control(pParent, ScResId( RID_COND_ENTRY ) ), mbActive(false), meType(CONDITION), @@ -120,11 +120,12 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScCond SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor()); FreeResource(); - if(pFormatEntry) + if(pFormatEntry && pFormatEntry->GetType() == condformat::CONDITION) { - rtl::OUString aStyleName = pFormatEntry->GetStyle(); + const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry); + rtl::OUString aStyleName = pEntry->GetStyle(); maLbStyle.SelectEntry(aStyleName); - ScConditionMode eMode = pFormatEntry->GetOperation(); + ScConditionMode eMode = pEntry->GetOperation(); maLbType.SelectEntryPos(1); switch(eMode) { @@ -515,8 +516,8 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum if(pFormat) { - sal_Int32 nCount = pFormat->Count(); - for (sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex) + size_t nCount = pFormat->size(); + for (size_t nIndex = 0; nIndex < nCount; ++nIndex) { maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, pFormat->GetEntry(nIndex))); } diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx index 54149bc931d6..f7693fc2699b 100644 --- a/sc/source/ui/inc/condformatdlg.hxx +++ b/sc/source/ui/inc/condformatdlg.hxx @@ -41,7 +41,7 @@ class ScDocument; class ScConditionalFormat; -class ScCondFormatEntry; +class ScFormatEntry; class ScConditionalFormat; enum ScCondFormatEntryType @@ -109,7 +109,7 @@ private: public: ScCondFrmtEntry( Window* pParent, ScDocument* pDoc ); - ScCondFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCondFormatEntry* pFormatEntry ); + ScCondFrmtEntry( Window* pParent, ScDocument* pDoc, const ScFormatEntry* pFormatEntry ); virtual long Notify( NotifyEvent& rNEvt ); diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 0cc06a397965..81e442091b86 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -197,11 +197,15 @@ ScTableConditionalFormat::ScTableConditionalFormat( if (pDoc->IsInExternalReferenceMarking()) pFormat->MarkUsedExternalReferences(); - sal_uInt16 nEntryCount = pFormat->Count(); - for (sal_uInt16 i=0; i<nEntryCount; i++) + size_t nEntryCount = pFormat->size(); + for (size_t i=0; i<nEntryCount; i++) { ScCondFormatEntryItem aItem; - const ScCondFormatEntry* pFormatEntry = pFormat->GetEntry(i); + const ScFormatEntry* pFrmtEntry = pFormat->GetEntry(i); + if(pFrmtEntry->GetType() != condformat::CONDITION) + continue; + + const ScCondFormatEntry* pFormatEntry = static_cast<const ScCondFormatEntry*>(pFrmtEntry); aItem.meMode = pFormatEntry->GetOperation(); aItem.maPos = pFormatEntry->GetValidSrcPos(); aItem.maExpr1 = pFormatEntry->GetExpression(aItem.maPos, 0, 0, eGrammar); @@ -244,26 +248,26 @@ void ScTableConditionalFormat::FillFormat( ScConditionalFormat& rFormat, FormulaGrammar::Grammar eGrammar1 = lclResolveGrammar( eGrammar, aData.meGrammar1 ); FormulaGrammar::Grammar eGrammar2 = lclResolveGrammar( eGrammar, aData.meGrammar2 ); - ScCondFormatEntry aCoreEntry( aData.meMode, aData.maExpr1, aData.maExpr2, + ScCondFormatEntry* pCoreEntry = new ScCondFormatEntry( aData.meMode, aData.maExpr1, aData.maExpr2, pDoc, aData.maPos, aData.maStyle, aData.maExprNmsp1, aData.maExprNmsp2, eGrammar1, eGrammar2 ); if ( aData.maPosStr.Len() ) - aCoreEntry.SetSrcString( aData.maPosStr ); + pCoreEntry->SetSrcString( aData.maPosStr ); if ( aData.maTokens1.getLength() ) { ScTokenArray aTokenArray; if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aData.maTokens1) ) - aCoreEntry.SetFormula1(aTokenArray); + pCoreEntry->SetFormula1(aTokenArray); } if ( aData.maTokens2.getLength() ) { ScTokenArray aTokenArray; if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aData.maTokens2) ) - aCoreEntry.SetFormula2(aTokenArray); + pCoreEntry->SetFormula2(aTokenArray); } - rFormat.AddEntry( aCoreEntry ); + rFormat.AddEntry( pCoreEntry ); } } |