summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/conditio.hxx24
-rw-r--r--sc/source/core/data/conditio.cxx90
-rw-r--r--sc/source/core/data/documen2.cxx2
-rw-r--r--sc/source/core/data/documen4.cxx10
-rw-r--r--sc/source/filter/excel/xecontent.cxx16
-rw-r--r--sc/source/filter/excel/xestyle.cxx9
6 files changed, 80 insertions, 71 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index a60c836bc7e7..f0acc9004487 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -36,6 +36,8 @@
#include "scdllapi.h"
#include "rangelst.hxx"
+#include <boost/ptr_container/ptr_set.hpp>
+
class ScBaseCell;
class ScFormulaCell;
class ScTokenArray;
@@ -261,13 +263,11 @@ public:
// List of areas and formats:
//
-typedef ScConditionalFormat* ScConditionalFormatPtr;
-
-SV_DECL_PTRARR_SORT(ScConditionalFormats_Impl, ScConditionalFormatPtr,
- SC_COND_GROW)
-
-class ScConditionalFormatList : public ScConditionalFormats_Impl
+class ScConditionalFormatList
{
+private:
+ boost::ptr_set<ScConditionalFormat> maConditionalFormats;
+ typedef boost::ptr_set<ScConditionalFormat> ConditionalFormatContainer;
public:
ScConditionalFormatList() {}
ScConditionalFormatList(const ScConditionalFormatList& rList);
@@ -275,7 +275,7 @@ public:
~ScConditionalFormatList() {}
void InsertNew( ScConditionalFormat* pNew )
- { if (!Insert(pNew)) delete pNew; }
+ { maConditionalFormats.insert(pNew); }
ScConditionalFormat* GetFormat( sal_uInt32 nKey );
@@ -289,6 +289,16 @@ public:
void SourceChanged( const ScAddress& rAddr );
bool operator==( const ScConditionalFormatList& r ) const; // for Ref-Undo
+
+ typedef ConditionalFormatContainer::iterator iterator;
+ typedef ConditionalFormatContainer::const_iterator const_iterator;
+
+ SC_DLLPUBLIC iterator begin();
+ SC_DLLPUBLIC const_iterator begin() const;
+ SC_DLLPUBLIC iterator end();
+ SC_DLLPUBLIC const_iterator end() const;
+
+ size_t size() const;
};
#endif
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 35bc83a45b53..ce70aa71aba8 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -49,10 +49,6 @@
using namespace formula;
//------------------------------------------------------------------------
-SV_IMPL_OP_PTRARR_SORT( ScConditionalFormats_Impl, ScConditionalFormatPtr );
-
-//------------------------------------------------------------------------
-
bool lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, sal_uInt16 nRecursion = 0 )
{
if (pFormula)
@@ -1579,15 +1575,12 @@ bool ScConditionalFormat::MarkUsedExternalReferences() const
//------------------------------------------------------------------------
-ScConditionalFormatList::ScConditionalFormatList(const ScConditionalFormatList& rList) :
- ScConditionalFormats_Impl()
+ScConditionalFormatList::ScConditionalFormatList(const ScConditionalFormatList& rList)
{
// fuer Ref-Undo - echte Kopie mit neuen Tokens!
- sal_uInt16 nCount = rList.Count();
-
- for (sal_uInt16 i=0; i<nCount; i++)
- InsertNew( rList[i]->Clone() );
+ for(const_iterator itr = rList.begin(); itr != rList.end(); ++itr)
+ InsertNew( itr->Clone() );
//! sortierte Eintraege aus rList schneller einfuegen ???
}
@@ -1597,10 +1590,8 @@ ScConditionalFormatList::ScConditionalFormatList(ScDocument* pNewDoc,
{
// fuer neues Dokument - echte Kopie mit neuen Tokens!
- sal_uInt16 nCount = rList.Count();
-
- for (sal_uInt16 i=0; i<nCount; i++)
- InsertNew( rList[i]->Clone(pNewDoc) );
+ for(const_iterator itr = rList.begin(); itr != rList.end(); ++itr)
+ InsertNew( itr->Clone(pNewDoc) );
//! sortierte Eintraege aus rList schneller einfuegen ???
}
@@ -1609,10 +1600,11 @@ bool ScConditionalFormatList::operator==( const ScConditionalFormatList& r ) con
{
// fuer Ref-Undo - interne Variablen werden nicht verglichen
- sal_uInt16 nCount = Count();
- bool bEqual = ( nCount == r.Count() );
- for (sal_uInt16 i=0; i<nCount && bEqual; i++) // Eintraege sind sortiert
- if ( !(*this)[i]->EqualEntries(*r[i]) ) // Eintraege unterschiedlich ?
+ sal_uInt16 nCount = size();
+ bool bEqual = ( nCount == r.size() );
+ const_iterator locIterator = begin();
+ for(const_iterator itr = r.begin(); itr != r.end() && bEqual; ++itr, ++locIterator)
+ if ( !locIterator->EqualEntries(*itr) ) // Eintraege unterschiedlich ?
bEqual = false;
return bEqual;
@@ -1622,10 +1614,9 @@ ScConditionalFormat* ScConditionalFormatList::GetFormat( sal_uInt32 nKey )
{
//! binaer suchen
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- if ((*this)[i]->GetKey() == nKey)
- return (*this)[i];
+ for( iterator itr = begin(); itr != end(); ++itr)
+ if (itr->GetKey() == nKey)
+ return &(*itr);
OSL_FAIL("ScConditionalFormatList: Eintrag nicht gefunden");
return NULL;
@@ -1633,45 +1624,64 @@ ScConditionalFormat* ScConditionalFormatList::GetFormat( sal_uInt32 nKey )
void ScConditionalFormatList::CompileAll()
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->CompileAll();
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->CompileAll();
}
void ScConditionalFormatList::CompileXML()
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->CompileXML();
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->CompileXML();
}
void ScConditionalFormatList::UpdateReference( UpdateRefMode eUpdateRefMode,
const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz );
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz );
}
void ScConditionalFormatList::RenameCellStyle( const String& rOld, const String& rNew )
{
- sal_uLong nCount=Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->RenameCellStyle(rOld,rNew);
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->RenameCellStyle(rOld,rNew);
}
void ScConditionalFormatList::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos )
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->UpdateMoveTab( nOldPos, nNewPos );
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->UpdateMoveTab( nOldPos, nNewPos );
}
void ScConditionalFormatList::SourceChanged( const ScAddress& rAddr )
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->SourceChanged( rAddr );
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->SourceChanged( rAddr );
+}
+
+ScConditionalFormatList::iterator ScConditionalFormatList::begin()
+{
+ return maConditionalFormats.begin();
+}
+
+ScConditionalFormatList::const_iterator ScConditionalFormatList::begin() const
+{
+ return maConditionalFormats.begin();
+}
+
+ScConditionalFormatList::iterator ScConditionalFormatList::end()
+{
+ return maConditionalFormats.end();
+}
+
+ScConditionalFormatList::const_iterator ScConditionalFormatList::end() const
+{
+ return maConditionalFormats.end();
+}
+
+size_t ScConditionalFormatList::size() const
+{
+ return maConditionalFormats.size();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 8df10964205e..b7011c1f8a9c 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -410,7 +410,6 @@ ScDocument::~ScDocument()
if (pCondFormList)
{
- pCondFormList->DeleteAndDestroy( 0, pCondFormList->Count() );
DELETEZ(pCondFormList);
}
if (pValidationList)
@@ -458,7 +457,6 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc )
if (pCondFormList)
{
- pCondFormList->DeleteAndDestroy( 0, pCondFormList->Count() );
DELETEZ(pCondFormList);
}
if (pValidationList)
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 4a73dcaf643a..31185cc20a59 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -608,12 +608,11 @@ sal_uLong ScDocument::AddCondFormat( const ScConditionalFormat& rNew )
pCondFormList = new ScConditionalFormatList;
sal_uLong nMax = 0;
- sal_uInt16 nCount = pCondFormList->Count();
- for (sal_uInt16 i=0; i<nCount; i++)
+ for (ScConditionalFormatList::const_iterator itr = pCondFormList->begin();
+ itr != pCondFormList->end(); ++itr)
{
- const ScConditionalFormat* pForm = (*pCondFormList)[i];
- sal_uLong nKey = pForm->GetKey();
- if ( pForm->EqualEntries( rNew ) )
+ sal_uLong nKey = itr->GetKey();
+ if ( itr->EqualEntries( rNew ) )
return nKey;
if ( nKey > nMax )
nMax = nKey;
@@ -761,7 +760,6 @@ void ScDocument::SetCondFormList(ScConditionalFormatList* pNew)
{
if (pCondFormList)
{
- pCondFormList->DeleteAndDestroy( 0, pCondFormList->Count() );
delete pCondFormList;
}
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 8dfe1cb5c385..fb974d943177 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -936,18 +936,12 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot ) :
{
if( const ScConditionalFormatList* pCondFmtList = GetDoc().GetCondFormList() )
{
- if( const ScConditionalFormatPtr* ppCondFmt = pCondFmtList->GetData() )
+ for( ScConditionalFormatList::const_iterator itr = pCondFmtList->begin();
+ itr != pCondFmtList->end(); ++itr)
{
- const ScConditionalFormatPtr* ppCondEnd = ppCondFmt + pCondFmtList->Count();
- for( ; ppCondFmt < ppCondEnd; ++ppCondFmt )
- {
- if( *ppCondFmt )
- {
- XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), **ppCondFmt ) );
- if( xCondfmtRec->IsValid() )
- maCondfmtList.AppendRecord( xCondfmtRec );
- }
- }
+ XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), *itr ) );
+ if( xCondfmtRec->IsValid() )
+ maCondfmtList.AppendRecord( xCondfmtRec );
}
}
}
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 7d98fcf50ebc..aaed2c99c100 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -2854,15 +2854,14 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
ScConditionalFormatList* pList = rRoot.GetDoc().GetCondFormList();
if (pList)
{
- sal_Int32 nFormatCount = pList->Count();
sal_Int32 nIndex = 0;
- for(sal_Int32 nItem = 0; nItem < nFormatCount; ++nItem)
+ for (ScConditionalFormatList::const_iterator itr = pList->begin();
+ itr != pList->end(); ++itr)
{
- ScConditionalFormat* pFormat = (*pList)[nItem];
- sal_Int32 nEntryCount = pFormat->Count();
+ sal_Int32 nEntryCount = itr->Count();
for (sal_Int32 nFormatEntry = 0; nFormatEntry < nEntryCount; ++nFormatEntry)
{
- const ScCondFormatEntry* pEntry = pFormat->GetEntry(nFormatEntry);
+ const ScCondFormatEntry* pEntry = itr->GetEntry(nFormatEntry);
if (!pEntry)
continue;