diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-10-29 17:26:57 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-10-29 21:33:17 -0400 |
commit | 9d131fd36373af5f693355d006e2e9b6c02a7793 (patch) | |
tree | f3db2647577d429b42072227d9022de1591b23c3 /svtools | |
parent | fb01d8e132ab9097ed30b3bc4c7585622df591ad (diff) |
Let's use const where we can.
There still lots of other methods that should take const pointers.
But one step at a time...
Change-Id: I1bae409ddb1939943db8c6f40d1b180f82f42bce
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/inc/svtools/treelist.hxx | 9 | ||||
-rw-r--r-- | svtools/inc/svtools/treelistentry.hxx | 1 | ||||
-rw-r--r-- | svtools/source/contnr/treelist.cxx | 24 |
3 files changed, 16 insertions, 18 deletions
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx index 7f99eb674905..30c5e306280c 100644 --- a/svtools/inc/svtools/treelist.hxx +++ b/svtools/inc/svtools/treelist.hxx @@ -284,7 +284,7 @@ public: void Copy( SvTreeListEntry* pSource, SvTreeListEntry* pTarget ); sal_uLong Copy( SvTreeListEntry* pSource, SvTreeListEntry* pTargetParent, sal_uLong nListPos); - sal_Bool Remove( SvTreeListEntry* pEntry ); + bool Remove( const SvTreeListEntry* pEntry ); void Clear(); sal_Bool HasChildren( SvTreeListEntry* pEntry ) const; @@ -310,10 +310,9 @@ public: sal_uLong GetRelPos( SvTreeListEntry* pChild ) const { return pChild->GetChildListPos(); } - sal_uLong GetChildCount( SvTreeListEntry* pParent ) const; - sal_uInt16 GetDepth( SvTreeListEntry* pEntry ) const; - sal_Bool IsAtRootDepth( SvTreeListEntry* pEntry ) const - { return (sal_Bool)(pEntry->pParent==pRootItem); } + sal_uLong GetChildCount( const SvTreeListEntry* pParent ) const; + sal_uInt16 GetDepth( const SvTreeListEntry* pEntry ) const; + bool IsAtRootDepth( const SvTreeListEntry* pEntry ) const; // das Model ruft zum Clonen von Entries den Clone-Link auf, // damit man sich nicht vom Model ableiten muss, wenn man diff --git a/svtools/inc/svtools/treelistentry.hxx b/svtools/inc/svtools/treelistentry.hxx index c0e99bb29a80..757e4b755ec1 100644 --- a/svtools/inc/svtools/treelistentry.hxx +++ b/svtools/inc/svtools/treelistentry.hxx @@ -47,7 +47,6 @@ #define SV_ENTRYFLAG_USER_FLAGS 0xF000 #define SV_ENTRYFLAG_SEMITRANSPARENT 0x8000 // draw semi-transparent entry bitmaps -class SvTreeEntryList; class SvLBoxItem; class SvTreeListEntry; diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx index 83152993fd48..fcab6fa9a384 100644 --- a/svtools/source/contnr/treelist.cxx +++ b/svtools/source/contnr/treelist.cxx @@ -278,7 +278,7 @@ sal_Bool SvTreeList::IsEntryVisible( const SvListView* pView, SvTreeListEntry* p return bRetVal; } -sal_uInt16 SvTreeList::GetDepth( SvTreeListEntry* pEntry ) const +sal_uInt16 SvTreeList::GetDepth( const SvTreeListEntry* pEntry ) const { DBG_ASSERT(pEntry&&pEntry!=pRootItem,"GetDepth:Bad Entry"); sal_uInt16 nDepth = 0; @@ -290,6 +290,11 @@ sal_uInt16 SvTreeList::GetDepth( SvTreeListEntry* pEntry ) const return nDepth; } +bool SvTreeList::IsAtRootDepth( const SvTreeListEntry* pEntry ) const +{ + return pEntry->pParent == pRootItem; +} + /************************************************************************* |* |* SvTreeList:: @@ -612,7 +617,7 @@ void SvTreeList::CloneChildren( |* *************************************************************************/ -sal_uLong SvTreeList::GetChildCount( SvTreeListEntry* pParent ) const +sal_uLong SvTreeList::GetChildCount( const SvTreeListEntry* pParent ) const { if ( !pParent ) return GetEntryCount(); @@ -625,7 +630,7 @@ sal_uLong SvTreeList::GetChildCount( SvTreeListEntry* pParent ) const sal_uInt16 nActDepth = nRefDepth; do { - pParent = Next( pParent, &nActDepth ); + pParent = Next(const_cast<SvTreeListEntry*>(pParent), &nActDepth); nCount++; } while( pParent && nRefDepth < nActDepth ); nCount--; @@ -1358,12 +1363,7 @@ sal_Bool SvTreeList::Select( SvListView* pView, SvTreeListEntry* pEntry, sal_Boo return sal_True; } -/************************************************************************* -|* -|* SvTreeList::Remove -|* -*************************************************************************/ -sal_Bool SvTreeList::Remove( SvTreeListEntry* pEntry ) +bool SvTreeList::Remove( const SvTreeListEntry* pEntry ) { DBG_ASSERT(pEntry,"Cannot remove root, use clear"); @@ -1376,9 +1376,9 @@ sal_Bool SvTreeList::Remove( SvTreeListEntry* pEntry ) return sal_False; } - Broadcast( LISTACTION_REMOVING, pEntry ); + Broadcast(LISTACTION_REMOVING, const_cast<SvTreeListEntry*>(pEntry)); sal_uLong nRemoved = 1 + GetChildCount(pEntry); - bAbsPositionsValid = sal_False; + bAbsPositionsValid = false; SvTreeListEntry* pParent = pEntry->pParent; SvTreeListEntries& rList = pParent->maChildren; @@ -1411,7 +1411,7 @@ sal_Bool SvTreeList::Remove( SvTreeListEntry* pEntry ) #ifdef CHECK_INTEGRITY CheckIntegrity(); #endif - Broadcast( LISTACTION_REMOVED, pEntry ); + Broadcast(LISTACTION_REMOVED, const_cast<SvTreeListEntry*>(pEntry)); delete pEntry; // deletes any children as well return true; |