Kaydet (Commit) 9d131fd3 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst fb01d8e1
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
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