Kaydet (Commit) fa6ac05b authored tarafından Noel Grandin's avatar Noel Grandin

fdo#84938 - replace LIST_ACTION constants with enum

Change-Id: I21c05ada0a793b1e3ddf87481e66b60b83529767
üst b80c468e
...@@ -32,17 +32,20 @@ ...@@ -32,17 +32,20 @@
#include <vector> #include <vector>
#include <boost/ptr_container/ptr_map.hpp> #include <boost/ptr_container/ptr_map.hpp>
#define LISTACTION_INSERTED 1 enum class SvListAction
#define LISTACTION_REMOVING 2 {
#define LISTACTION_REMOVED 3 INSERTED = 1,
#define LISTACTION_MOVING 4 REMOVING = 2,
#define LISTACTION_MOVED 5 REMOVED = 3,
#define LISTACTION_CLEARING 6 MOVING = 4,
#define LISTACTION_INSERTED_TREE 7 MOVED = 5,
#define LISTACTION_INVALIDATE_ENTRY 8 CLEARING = 6,
#define LISTACTION_RESORTING 9 INSERTED_TREE = 7,
#define LISTACTION_RESORTED 10 INVALIDATE_ENTRY = 8,
#define LISTACTION_CLEARED 11 RESORTING = 9,
RESORTED = 10,
CLEARED = 11
};
class SvTreeListEntry; class SvTreeListEntry;
class SvListView; class SvListView;
...@@ -142,27 +145,27 @@ public: ...@@ -142,27 +145,27 @@ public:
{ return ( nPos < aViewList.size() ) ? aViewList[ nPos ] : NULL; } { return ( nPos < aViewList.size() ) ? aViewList[ nPos ] : NULL; }
void Broadcast( void Broadcast(
sal_uInt16 nActionId, SvListAction nActionId,
SvTreeListEntry* pEntry1=0, SvTreeListEntry* pEntry1=0,
SvTreeListEntry* pEntry2=0, SvTreeListEntry* pEntry2=0,
sal_uLong nPos=0 sal_uLong nPos=0
); );
void EnableInvalidate( bool bEnable ); void EnableInvalidate( bool bEnable );
// Notify all Listeners // Notify all Listeners
void InvalidateEntry( SvTreeListEntry* ); void InvalidateEntry( SvTreeListEntry* );
sal_uLong GetEntryCount() const { return nEntryCount; } sal_uLong GetEntryCount() const { return nEntryCount; }
SvTreeListEntry* First() const; SvTreeListEntry* First() const;
SvTreeListEntry* Next( SvTreeListEntry* pEntry, sal_uInt16* pDepth=0 ) const; SvTreeListEntry* Next( SvTreeListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
SvTreeListEntry* Prev( SvTreeListEntry* pEntry, sal_uInt16* pDepth=0 ) const; SvTreeListEntry* Prev( SvTreeListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
SvTreeListEntry* Last() const; SvTreeListEntry* Last() const;
SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const; SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const;
SvTreeListEntry* NextSibling( SvTreeListEntry* pEntry ) const; SvTreeListEntry* NextSibling( SvTreeListEntry* pEntry ) const;
SvTreeListEntry* PrevSibling( SvTreeListEntry* pEntry ) const; SvTreeListEntry* PrevSibling( SvTreeListEntry* pEntry ) const;
SvTreeListEntry* LastSibling( SvTreeListEntry* pEntry ) const; SvTreeListEntry* LastSibling( SvTreeListEntry* pEntry ) const;
sal_uLong Insert( SvTreeListEntry* pEntry,SvTreeListEntry* pPar,sal_uLong nPos = TREELIST_APPEND); sal_uLong Insert( SvTreeListEntry* pEntry,SvTreeListEntry* pPar,sal_uLong nPos = TREELIST_APPEND);
sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND ) sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND )
...@@ -273,7 +276,7 @@ public: ...@@ -273,7 +276,7 @@ public:
void Clear(); void Clear();
virtual void SetModel( SvTreeList* ); virtual void SetModel( SvTreeList* );
virtual void ModelNotification( virtual void ModelNotification(
sal_uInt16 nActionId, SvListAction nActionId,
SvTreeListEntry* pEntry1, SvTreeListEntry* pEntry1,
SvTreeListEntry* pEntry2, SvTreeListEntry* pEntry2,
sal_uLong nPos sal_uLong nPos
......
...@@ -752,7 +752,7 @@ public: ...@@ -752,7 +752,7 @@ public:
void RemoveParentKeepChildren( SvTreeListEntry* pParent ); void RemoveParentKeepChildren( SvTreeListEntry* pParent );
DECL_LINK( DefaultCompare, SvSortData* ); DECL_LINK( DefaultCompare, SvSortData* );
virtual void ModelNotification( sal_uInt16 nActionId, SvTreeListEntry* pEntry1, virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
SvTreeListEntry* pEntry2, sal_uLong nPos ) SAL_OVERRIDE; SvTreeListEntry* pEntry2, sal_uLong nPos ) SAL_OVERRIDE;
void EndSelection(); void EndSelection();
......
...@@ -44,7 +44,7 @@ SvTreeList::~SvTreeList() ...@@ -44,7 +44,7 @@ SvTreeList::~SvTreeList()
} }
void SvTreeList::Broadcast( void SvTreeList::Broadcast(
sal_uInt16 nActionId, SvListAction nActionId,
SvTreeListEntry* pEntry1, SvTreeListEntry* pEntry1,
SvTreeListEntry* pEntry2, SvTreeListEntry* pEntry2,
sal_uLong nPos sal_uLong nPos
...@@ -119,10 +119,10 @@ bool SvTreeList::IsAtRootDepth( const SvTreeListEntry* pEntry ) const ...@@ -119,10 +119,10 @@ bool SvTreeList::IsAtRootDepth( const SvTreeListEntry* pEntry ) const
void SvTreeList::Clear() void SvTreeList::Clear()
{ {
Broadcast( LISTACTION_CLEARING ); Broadcast( SvListAction::CLEARING );
pRootItem->ClearChildren(); pRootItem->ClearChildren();
nEntryCount = 0; nEntryCount = 0;
Broadcast( LISTACTION_CLEARED ); Broadcast( SvListAction::CLEARED );
} }
bool SvTreeList::IsChild(const SvTreeListEntry* pParent, const SvTreeListEntry* pChild) const bool SvTreeList::IsChild(const SvTreeListEntry* pParent, const SvTreeListEntry* pChild) const
...@@ -182,7 +182,7 @@ sal_uLong SvTreeList::Move(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa ...@@ -182,7 +182,7 @@ sal_uLong SvTreeList::Move(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa
pTargetParent = pRootItem; pTargetParent = pRootItem;
DBG_ASSERT(pSrcEntry!=pTargetParent,"Move:Source=Target"); DBG_ASSERT(pSrcEntry!=pTargetParent,"Move:Source=Target");
Broadcast( LISTACTION_MOVING, pSrcEntry, pTargetParent, nListPos ); Broadcast( SvListAction::MOVING, pSrcEntry, pTargetParent, nListPos );
if ( pSrcEntry == pTargetParent ) if ( pSrcEntry == pTargetParent )
// You can't move an entry onto itself as the parent. Just return its // You can't move an entry onto itself as the parent. Just return its
...@@ -260,7 +260,7 @@ sal_uLong SvTreeList::Move(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa ...@@ -260,7 +260,7 @@ sal_uLong SvTreeList::Move(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa
sal_uLong nRetVal = findEntryPosition(rDst, pSrcEntry); sal_uLong nRetVal = findEntryPosition(rDst, pSrcEntry);
OSL_ENSURE(nRetVal == pSrcEntry->GetChildListPos(), "ListPos not valid"); OSL_ENSURE(nRetVal == pSrcEntry->GetChildListPos(), "ListPos not valid");
Broadcast( LISTACTION_MOVED,pSrcEntry,pTargetParent,nRetVal); Broadcast( SvListAction::MOVED,pSrcEntry,pTargetParent,nRetVal);
return nRetVal; return nRetVal;
} }
...@@ -292,7 +292,7 @@ sal_uLong SvTreeList::Copy(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa ...@@ -292,7 +292,7 @@ sal_uLong SvTreeList::Copy(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa
SetListPositions(rDst); // correct list position in target list SetListPositions(rDst); // correct list position in target list
Broadcast( LISTACTION_INSERTED_TREE, pClonedEntry ); Broadcast( SvListAction::INSERTED_TREE, pClonedEntry );
sal_uLong nRetVal = findEntryPosition(rDst, pClonedEntry); sal_uLong nRetVal = findEntryPosition(rDst, pClonedEntry);
return nRetVal; return nRetVal;
} }
...@@ -347,7 +347,7 @@ void SvTreeList::InsertTree(SvTreeListEntry* pSrcEntry, ...@@ -347,7 +347,7 @@ void SvTreeList::InsertTree(SvTreeListEntry* pSrcEntry,
nEntryCount += GetChildCount( pSrcEntry ); nEntryCount += GetChildCount( pSrcEntry );
nEntryCount++; // the parent is new, too nEntryCount++; // the parent is new, too
Broadcast(LISTACTION_INSERTED_TREE, pSrcEntry ); Broadcast(SvListAction::INSERTED_TREE, pSrcEntry );
} }
SvTreeListEntry* SvTreeList::CloneEntry( SvTreeListEntry* pSource ) const SvTreeListEntry* SvTreeList::CloneEntry( SvTreeListEntry* pSource ) const
...@@ -904,7 +904,7 @@ sal_uLong SvTreeList::Insert( SvTreeListEntry* pEntry,SvTreeListEntry* pParent,s ...@@ -904,7 +904,7 @@ sal_uLong SvTreeList::Insert( SvTreeListEntry* pEntry,SvTreeListEntry* pParent,s
else else
pEntry->nListPos = rList.size()-1; pEntry->nListPos = rList.size()-1;
Broadcast( LISTACTION_INSERTED, pEntry ); Broadcast( SvListAction::INSERTED, pEntry );
return nPos; // pEntry->nListPos; return nPos; // pEntry->nListPos;
} }
...@@ -1011,7 +1011,7 @@ bool SvTreeList::Remove( const SvTreeListEntry* pEntry ) ...@@ -1011,7 +1011,7 @@ bool SvTreeList::Remove( const SvTreeListEntry* pEntry )
return false; return false;
} }
Broadcast(LISTACTION_REMOVING, const_cast<SvTreeListEntry*>(pEntry)); Broadcast(SvListAction::REMOVING, const_cast<SvTreeListEntry*>(pEntry));
sal_uLong nRemoved = 1 + GetChildCount(pEntry); sal_uLong nRemoved = 1 + GetChildCount(pEntry);
bAbsPositionsValid = false; bAbsPositionsValid = false;
...@@ -1043,7 +1043,7 @@ bool SvTreeList::Remove( const SvTreeListEntry* pEntry ) ...@@ -1043,7 +1043,7 @@ bool SvTreeList::Remove( const SvTreeListEntry* pEntry )
SetListPositions(rList); SetListPositions(rList);
nEntryCount -= nRemoved; nEntryCount -= nRemoved;
Broadcast(LISTACTION_REMOVED, const_cast<SvTreeListEntry*>(pEntry)); Broadcast(SvListAction::REMOVED, const_cast<SvTreeListEntry*>(pEntry));
delete pEntry; delete pEntry;
return true; return true;
...@@ -1109,7 +1109,7 @@ void SvTreeList::InvalidateEntry( SvTreeListEntry* pEntry ) ...@@ -1109,7 +1109,7 @@ void SvTreeList::InvalidateEntry( SvTreeListEntry* pEntry )
if (!mbEnableInvalidate) if (!mbEnableInvalidate)
return; return;
Broadcast( LISTACTION_INVALIDATE_ENTRY, pEntry ); Broadcast( SvListAction::INVALIDATE_ENTRY, pEntry );
} }
SvTreeListEntry* SvTreeList::GetRootLevelParent( SvTreeListEntry* pEntry ) const SvTreeListEntry* SvTreeList::GetRootLevelParent( SvTreeListEntry* pEntry ) const
...@@ -1225,7 +1225,7 @@ void SvListView::SetModel( SvTreeList* pNewModel ) ...@@ -1225,7 +1225,7 @@ void SvListView::SetModel( SvTreeList* pNewModel )
{ {
pModel->RemoveView( this ); pModel->RemoveView( this );
bBroadcastCleared = true; bBroadcastCleared = true;
ModelNotification( LISTACTION_CLEARING,0,0,0 ); ModelNotification( SvListAction::CLEARING,0,0,0 );
if ( pModel->GetRefCount() == 0 ) if ( pModel->GetRefCount() == 0 )
delete pModel; delete pModel;
} }
...@@ -1233,7 +1233,7 @@ void SvListView::SetModel( SvTreeList* pNewModel ) ...@@ -1233,7 +1233,7 @@ void SvListView::SetModel( SvTreeList* pNewModel )
InitTable(); InitTable();
pNewModel->InsertView( this ); pNewModel->InsertView( this );
if( bBroadcastCleared ) if( bBroadcastCleared )
ModelNotification( LISTACTION_CLEARED,0,0,0 ); ModelNotification( SvListAction::CLEARED,0,0,0 );
} }
...@@ -1394,49 +1394,49 @@ void SvListView::ActionClear() ...@@ -1394,49 +1394,49 @@ void SvListView::ActionClear()
Clear(); Clear();
} }
void SvListView::ModelNotification( sal_uInt16 nActionId, SvTreeListEntry* pEntry1, void SvListView::ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
SvTreeListEntry* pEntry2, sal_uLong nPos ) SvTreeListEntry* pEntry2, sal_uLong nPos )
{ {
switch( nActionId ) switch( nActionId )
{ {
case LISTACTION_INSERTED: case SvListAction::INSERTED:
ActionInserted( pEntry1 ); ActionInserted( pEntry1 );
ModelHasInserted( pEntry1 ); ModelHasInserted( pEntry1 );
break; break;
case LISTACTION_INSERTED_TREE: case SvListAction::INSERTED_TREE:
ActionInsertedTree( pEntry1 ); ActionInsertedTree( pEntry1 );
ModelHasInsertedTree( pEntry1 ); ModelHasInsertedTree( pEntry1 );
break; break;
case LISTACTION_REMOVING: case SvListAction::REMOVING:
ModelIsRemoving( pEntry1 ); ModelIsRemoving( pEntry1 );
ActionRemoving( pEntry1 ); ActionRemoving( pEntry1 );
break; break;
case LISTACTION_REMOVED: case SvListAction::REMOVED:
ActionRemoved( pEntry1 ); ActionRemoved( pEntry1 );
ModelHasRemoved( pEntry1 ); ModelHasRemoved( pEntry1 );
break; break;
case LISTACTION_MOVING: case SvListAction::MOVING:
ModelIsMoving( pEntry1, pEntry2, nPos ); ModelIsMoving( pEntry1, pEntry2, nPos );
ActionMoving( pEntry1, pEntry2, nPos ); ActionMoving( pEntry1, pEntry2, nPos );
break; break;
case LISTACTION_MOVED: case SvListAction::MOVED:
ActionMoved( pEntry1, pEntry2, nPos ); ActionMoved( pEntry1, pEntry2, nPos );
ModelHasMoved( pEntry1 ); ModelHasMoved( pEntry1 );
break; break;
case LISTACTION_CLEARING: case SvListAction::CLEARING:
ActionClear(); ActionClear();
ModelHasCleared(); // sic! for compatibility reasons! ModelHasCleared(); // sic! for compatibility reasons!
break; break;
case LISTACTION_CLEARED: case SvListAction::CLEARED:
break; break;
case LISTACTION_INVALIDATE_ENTRY: case SvListAction::INVALIDATE_ENTRY:
// no action for the base class // no action for the base class
ModelHasEntryInvalidated( pEntry1 ); ModelHasEntryInvalidated( pEntry1 );
break; break;
case LISTACTION_RESORTED: case SvListAction::RESORTED:
bVisPositionsValid = false; bVisPositionsValid = false;
break; break;
case LISTACTION_RESORTING: case SvListAction::RESORTING:
break; break;
default: default:
OSL_FAIL("unknown ActionId"); OSL_FAIL("unknown ActionId");
...@@ -1503,10 +1503,10 @@ sal_Int32 SvTreeList::Compare(const SvTreeListEntry* pLeft, const SvTreeListEntr ...@@ -1503,10 +1503,10 @@ sal_Int32 SvTreeList::Compare(const SvTreeListEntry* pLeft, const SvTreeListEntr
void SvTreeList::Resort() void SvTreeList::Resort()
{ {
Broadcast( LISTACTION_RESORTING ); Broadcast( SvListAction::RESORTING );
bAbsPositionsValid = false; bAbsPositionsValid = false;
ResortChildren( pRootItem ); ResortChildren( pRootItem );
Broadcast( LISTACTION_RESORTED ); Broadcast( SvListAction::RESORTED );
} }
namespace { namespace {
......
...@@ -3644,18 +3644,18 @@ IMPL_LINK( SvTreeListBox, DefaultCompare, SvSortData*, pData ) ...@@ -3644,18 +3644,18 @@ IMPL_LINK( SvTreeListBox, DefaultCompare, SvSortData*, pData )
return pImp->m_pStringSorter->compare(aLeft, aRight); return pImp->m_pStringSorter->compare(aLeft, aRight);
} }
void SvTreeListBox::ModelNotification( sal_uInt16 nActionId, SvTreeListEntry* pEntry1, void SvTreeListBox::ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
SvTreeListEntry* pEntry2, sal_uLong nPos ) SvTreeListEntry* pEntry2, sal_uLong nPos )
{ {
SolarMutexGuard aSolarGuard; SolarMutexGuard aSolarGuard;
if( nActionId == LISTACTION_CLEARING ) if( nActionId == SvListAction::CLEARING )
CancelTextEditing(); CancelTextEditing();
SvListView::ModelNotification( nActionId, pEntry1, pEntry2, nPos ); SvListView::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
switch( nActionId ) switch( nActionId )
{ {
case LISTACTION_INSERTED: case SvListAction::INSERTED:
{ {
SvTreeListEntry* pEntry( dynamic_cast< SvTreeListEntry* >( pEntry1 ) ); SvTreeListEntry* pEntry( dynamic_cast< SvTreeListEntry* >( pEntry1 ) );
if ( !pEntry ) if ( !pEntry )
...@@ -3681,20 +3681,22 @@ void SvTreeListBox::ModelNotification( sal_uInt16 nActionId, SvTreeListEntry* pE ...@@ -3681,20 +3681,22 @@ void SvTreeListBox::ModelNotification( sal_uInt16 nActionId, SvTreeListEntry* pE
} }
break; break;
case LISTACTION_RESORTING: case SvListAction::RESORTING:
SetUpdateMode( false ); SetUpdateMode( false );
break; break;
case LISTACTION_RESORTED: case SvListAction::RESORTED:
// after a selection: show first entry and also keep the selection // after a selection: show first entry and also keep the selection
MakeVisible( (SvTreeListEntry*)pModel->First(), true ); MakeVisible( (SvTreeListEntry*)pModel->First(), true );
SetUpdateMode( true ); SetUpdateMode( true );
break; break;
case LISTACTION_CLEARED: case SvListAction::CLEARED:
if( IsUpdateMode() ) if( IsUpdateMode() )
Update(); Update();
break; break;
default: break;
} }
} }
......
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