diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-27 14:26:31 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-28 10:01:32 -0500 |
commit | 62d7eb4700f86b5a3fc43043ec3ca2efa025cd2e (patch) | |
tree | 48fd0a5efc55ec2fb20bb637689b88a79f2049e7 /svtools | |
parent | Use std::vector over c-style pointer array. (diff) | |
download | core-62d7eb4700f86b5a3fc43043ec3ca2efa025cd2e.tar.gz core-62d7eb4700f86b5a3fc43043ec3ca2efa025cd2e.zip |
Finally merge SvViewData and SvViewDataEntry.
Change-Id: Ic85e2a239990aeaa017eaef95ea25487dd1ec968
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/inc/svtools/treelist.hxx | 12 | ||||
-rw-r--r-- | svtools/inc/svtools/treelistbox.hxx | 4 | ||||
-rw-r--r-- | svtools/inc/svtools/viewdataentry.hxx | 31 | ||||
-rw-r--r-- | svtools/source/contnr/svimpbox.cxx | 2 | ||||
-rw-r--r-- | svtools/source/contnr/treelist.cxx | 36 | ||||
-rw-r--r-- | svtools/source/contnr/treelistbox.cxx | 6 | ||||
-rw-r--r-- | svtools/source/contnr/viewdataentry.cxx | 51 |
7 files changed, 60 insertions, 82 deletions
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx index 1c4d664b271d..ff31dc495497 100644 --- a/svtools/inc/svtools/treelist.hxx +++ b/svtools/inc/svtools/treelist.hxx @@ -46,7 +46,7 @@ class SvTreeListEntry; class SvListView; -class SvViewData; +class SvViewDataEntry; enum SvSortMode { SortAscending, SortDescending, SortNone }; @@ -236,7 +236,7 @@ class SVT_DLLPUBLIC SvListView { friend class SvTreeList; - typedef boost::ptr_map<SvTreeListEntry*, SvViewData> SvDataTable; + typedef boost::ptr_map<SvTreeListEntry*, SvViewDataEntry> SvDataTable; sal_uLong nVisibleCount; sal_uLong nSelectionCount; @@ -343,13 +343,13 @@ public: sal_Bool IsSelected( SvTreeListEntry* pEntry ) const; sal_Bool HasEntryFocus( SvTreeListEntry* pEntry ) const; void SetEntryFocus( SvTreeListEntry* pEntry, sal_Bool bFocus ); - const SvViewData* GetViewData( const SvTreeListEntry* pEntry ) const; - SvViewData* GetViewData( SvTreeListEntry* pEntry ); + const SvViewDataEntry* GetViewData( const SvTreeListEntry* pEntry ) const; + SvViewDataEntry* GetViewData( SvTreeListEntry* pEntry ); sal_Bool HasViewData() const { return maDataTable.size() > 1; } // There's always a ROOT - virtual SvViewData* CreateViewData( SvTreeListEntry* pEntry ); - virtual void InitViewData( SvViewData*, SvTreeListEntry* pEntry ); + virtual SvViewDataEntry* CreateViewData( SvTreeListEntry* pEntry ); + virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ); virtual void ModelHasCleared(); virtual void ModelHasInserted( SvTreeListEntry* pEntry ); diff --git a/svtools/inc/svtools/treelistbox.hxx b/svtools/inc/svtools/treelistbox.hxx index 1a591fd5ad76..ff2cd94ec6e0 100644 --- a/svtools/inc/svtools/treelistbox.hxx +++ b/svtools/inc/svtools/treelistbox.hxx @@ -310,10 +310,10 @@ protected: bool IsEmptyTextAllowed() const; // Return value must be derived from SvViewDataEntry! - virtual SvViewData* CreateViewData( SvTreeListEntry* ); + virtual SvViewDataEntry* CreateViewData( SvTreeListEntry* ); // InitViewData is called right after CreateViewData // The Entry is has not yet been added to the View in InitViewData! - virtual void InitViewData( SvViewData*, SvTreeListEntry* pEntry ); + virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ); // Calls InitViewData for all Items void RecalcViewData(); // Callback of RecalcViewData diff --git a/svtools/inc/svtools/viewdataentry.hxx b/svtools/inc/svtools/viewdataentry.hxx index fa1969e1c24d..35b9a5823c79 100644 --- a/svtools/inc/svtools/viewdataentry.hxx +++ b/svtools/inc/svtools/viewdataentry.hxx @@ -38,18 +38,24 @@ struct SvViewDataItem Size maSize; }; -class SVT_DLLPUBLIC SvViewData +/** + * View-dependent data for an Entry is created in the virtual function + * SvTreeListBox::CreateViewData. The View creation of Items should not be + * changed. + */ +class SVT_DLLPUBLIC SvViewDataEntry { -friend class SvTreeList; -friend class SvListView; + friend class SvTreeList; + friend class SvListView; + std::vector<SvViewDataItem> maItems; sal_uLong nVisPos; -protected: sal_uInt16 nFlags; + public: - SvViewData(); - SvViewData( const SvViewData& ); - virtual ~SvViewData(); + SvViewDataEntry(); + SvViewDataEntry( const SvViewDataEntry& ); + ~SvViewDataEntry(); bool IsSelected() const; bool IsExpanded() const; @@ -60,17 +66,6 @@ public: void SetCursored( bool bCursored ); sal_uInt16 GetFlags() const; void SetSelectable( bool bSelectable ); -}; - -// View-dependent data for an Entry is created in the virtual function -// SvTreeListBox::CreateViewData. The View creation of Items cannot be -// changed (because it's an array) -class SvViewDataEntry : public SvViewData -{ - std::vector<SvViewDataItem> maItems; -public: - SvViewDataEntry(); - virtual ~SvViewDataEntry(); void Init(size_t nSize); diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index a81ec7602802..99612f92fb7a 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -2590,8 +2590,6 @@ void SvImpLBox::LoseFocus() SvTreeListEntry* pEntry = pView->FirstSelected(); while( pEntry ) { - //SvViewData* pViewData = pView->GetViewData( pEntry ); - //pViewData->SetCursored( true ); InvalidateEntry( pEntry ); pEntry = pView->NextSelected( pEntry ); } diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx index 4750c61fae65..9d752eff9349 100644 --- a/svtools/source/contnr/treelist.cxx +++ b/svtools/source/contnr/treelist.cxx @@ -588,7 +588,7 @@ sal_uLong SvTreeList::GetVisiblePos( const SvListView* pView, SvTreeListEntry* p ((SvListView*)pView)->nVisibleCount = 0; GetVisibleCount( const_cast<SvListView*>(pView) ); } - const SvViewData* pViewData = pView->GetViewData( pEntry ); + const SvViewDataEntry* pViewData = pView->GetViewData( pEntry ); return pViewData->nVisPos; } @@ -604,7 +604,7 @@ sal_uLong SvTreeList::GetVisibleCount( SvListView* pView ) const SvTreeListEntry* pEntry = First(); // first entry is always visible while ( pEntry ) { - SvViewData* pViewData = pView->GetViewData( pEntry ); + SvViewDataEntry* pViewData = pView->GetViewData( pEntry ); pViewData->nVisPos = nPos; nPos++; pEntry = NextVisible( pView, pEntry ); @@ -939,7 +939,7 @@ void SvTreeList::Expand( SvListView* pView, SvTreeListEntry* pEntry ) DBG_ASSERT(!pEntry->maChildren.empty(), "SvTreeList::Expand: We expected to have child entries."); - SvViewData* pViewData = pView->GetViewData(pEntry); + SvViewDataEntry* pViewData = pView->GetViewData(pEntry); pViewData->nFlags |= SVLISTENTRYFLAG_EXPANDED; SvTreeListEntry* pParent = pEntry->pParent; // if parent is visible, invalidate status data @@ -958,7 +958,7 @@ void SvTreeList::Collapse( SvListView* pView, SvTreeListEntry* pEntry ) DBG_ASSERT(!pEntry->maChildren.empty(), "SvTreeList::Collapse: We expected have child entries."); - SvViewData* pViewData = pView->GetViewData( pEntry ); + SvViewDataEntry* pViewData = pView->GetViewData( pEntry ); pViewData->nFlags &=(~SVLISTENTRYFLAG_EXPANDED); SvTreeListEntry* pParent = pEntry->pParent; @@ -972,7 +972,7 @@ void SvTreeList::Collapse( SvListView* pView, SvTreeListEntry* pEntry ) sal_Bool SvTreeList::Select( SvListView* pView, SvTreeListEntry* pEntry, sal_Bool bSelect ) { DBG_ASSERT(pView&&pEntry,"Select:View/Entry?"); - SvViewData* pViewData = pView->GetViewData( pEntry ); + SvViewDataEntry* pViewData = pView->GetViewData( pEntry ); if ( bSelect ) { if ( pViewData->IsSelected() || !pViewData->IsSelectable() ) @@ -1053,7 +1053,7 @@ void SvTreeList::SelectAll( SvListView* pView, sal_Bool bSelect ) SvTreeListEntry* pEntry = First(); while ( pEntry ) { - SvViewData* pViewData = pView->GetViewData( pEntry ); + SvViewDataEntry* pViewData = pView->GetViewData( pEntry ); if ( bSelect ) pViewData->nFlags |= SVLISTENTRYFLAG_SELECTED; else @@ -1197,11 +1197,11 @@ void SvListView::InitTable() } SvTreeListEntry* pEntry; - SvViewData* pViewData; + SvViewDataEntry* pViewData; // insert root entry pEntry = pModel->pRootItem; - pViewData = new SvViewData; + pViewData = new SvViewDataEntry; pViewData->nFlags = SVLISTENTRYFLAG_EXPANDED; maDataTable.insert( pEntry, pViewData ); // now all the other entries @@ -1216,10 +1216,10 @@ void SvListView::InitTable() } } -SvViewData* SvListView::CreateViewData( SvTreeListEntry* ) +SvViewDataEntry* SvListView::CreateViewData( SvTreeListEntry* ) { DBG_CHKTHIS(SvListView,0); - return new SvViewData; + return new SvViewDataEntry; } void SvListView::Clear() @@ -1232,7 +1232,7 @@ void SvListView::Clear() { // insert root entry SvTreeListEntry* pEntry = pModel->pRootItem; - SvViewData* pViewData = new SvViewData; + SvViewDataEntry* pViewData = new SvViewDataEntry; pViewData->nFlags = SVLISTENTRYFLAG_EXPANDED; maDataTable.insert( pEntry, pViewData ); } @@ -1307,7 +1307,7 @@ void SvListView::ActionMoving( SvTreeListEntry* pEntry,SvTreeListEntry*,sal_uLon DBG_ASSERT(pParent,"Model not consistent"); if (pParent != pModel->pRootItem && pParent->maChildren.size() == 1) { - SvViewData* pViewData = maDataTable.find( pParent )->second; + SvViewDataEntry* pViewData = maDataTable.find( pParent )->second; pViewData->nFlags &= (~SVLISTENTRYFLAG_EXPANDED); } // vorlaeufig @@ -1328,7 +1328,7 @@ void SvListView::ActionInserted( SvTreeListEntry* pEntry ) { DBG_CHKTHIS(SvListView,0); DBG_ASSERT(pEntry,"Insert:No Entry"); - SvViewData* pData = CreateViewData( pEntry ); + SvViewDataEntry* pData = CreateViewData( pEntry ); InitViewData( pData, pEntry ); #ifdef DBG_UTIL std::pair<SvDataTable::iterator, bool> aSuccess = @@ -1356,7 +1356,7 @@ void SvListView::ActionInsertedTree( SvTreeListEntry* pEntry ) while( pCurEntry ) { DBG_ASSERT(maDataTable.find(pCurEntry) != maDataTable.end(),"Entry already in Table"); - SvViewData* pViewData = CreateViewData( pCurEntry ); + SvViewDataEntry* pViewData = CreateViewData( pCurEntry ); DBG_ASSERT(pViewData,"No ViewData"); InitViewData( pViewData, pEntry ); maDataTable.insert( pCurEntry, pViewData ); @@ -1385,7 +1385,7 @@ void SvListView::ActionRemoving( SvTreeListEntry* pEntry ) DBG_CHKTHIS(SvListView,0); DBG_ASSERT(pEntry,"Remove:No Entry"); - SvViewData* pViewData = maDataTable.find( pEntry )->second; + SvViewDataEntry* pViewData = maDataTable.find( pEntry )->second; sal_uLong nSelRemoved = 0; if ( pViewData->IsSelected() ) nSelRemoved = 1 + pModel->GetChildSelectionCount( this, pEntry ); @@ -1477,7 +1477,7 @@ void SvListView::ModelNotification( sal_uInt16 nActionId, SvTreeListEntry* pEntr } } -void SvListView::InitViewData( SvViewData*, SvTreeListEntry* ) +void SvListView::InitViewData( SvViewDataEntry*, SvTreeListEntry* ) { } @@ -1513,14 +1513,14 @@ void SvListView::SetEntryFocus( SvTreeListEntry* pEntry, sal_Bool bFocus ) itr->second->SetFocus(bFocus); } -const SvViewData* SvListView::GetViewData( const SvTreeListEntry* pEntry ) const +const SvViewDataEntry* SvListView::GetViewData( const SvTreeListEntry* pEntry ) const { SvDataTable::const_iterator itr = maDataTable.find( const_cast<SvTreeListEntry*>(pEntry) ); DBG_ASSERT(itr != maDataTable.end(),"Entry not in model or wrong view"); return itr->second; } -SvViewData* SvListView::GetViewData( SvTreeListEntry* pEntry ) +SvViewDataEntry* SvListView::GetViewData( SvTreeListEntry* pEntry ) { SvDataTable::iterator itr = maDataTable.find( pEntry ); DBG_ASSERT(itr != maDataTable.end(),"Entry not in model or wrong view"); diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index 296a036c2009..6c4eb5e3a230 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -951,14 +951,14 @@ const SvViewDataItem* SvTreeListBox::GetViewDataItem(const SvTreeListEntry* pEnt return pEntryData->GetItem(nItemPos); } -SvViewData* SvTreeListBox::CreateViewData( SvTreeListEntry* ) +SvViewDataEntry* SvTreeListBox::CreateViewData( SvTreeListEntry* ) { DBG_CHKTHIS(SvTreeListBox,0); SvViewDataEntry* pEntryData = new SvViewDataEntry; - return (SvViewData*)pEntryData; + return (SvViewDataEntry*)pEntryData; } -void SvTreeListBox::InitViewData( SvViewData* pData, SvTreeListEntry* pEntry ) +void SvTreeListBox::InitViewData( SvViewDataEntry* pData, SvTreeListEntry* pEntry ) { DBG_CHKTHIS(SvTreeListBox,0); SvTreeListEntry* pInhEntry = (SvTreeListEntry*)pEntry; diff --git a/svtools/source/contnr/viewdataentry.cxx b/svtools/source/contnr/viewdataentry.cxx index 0fda3dd7e594..5288466f8d79 100644 --- a/svtools/source/contnr/viewdataentry.cxx +++ b/svtools/source/contnr/viewdataentry.cxx @@ -21,58 +21,56 @@ #include "tools/debug.hxx" -DBG_NAME(SvViewData); +DBG_NAME(SvViewDataEntry); -SvViewData::SvViewData() +SvViewDataEntry::SvViewDataEntry() : + nVisPos(0), nFlags(0) { - DBG_CTOR(SvViewData,0); - nFlags = 0; - nVisPos = 0; + DBG_CTOR(SvViewDataEntry,0); } -SvViewData::SvViewData( const SvViewData& rData ) +SvViewDataEntry::SvViewDataEntry( const SvViewDataEntry& rData ) : + nVisPos(rData.nVisPos), nFlags(rData.nFlags) { - DBG_CTOR(SvViewData,0); - nFlags = rData.nFlags; + DBG_CTOR(SvViewDataEntry,0); nFlags &= ~( SVLISTENTRYFLAG_SELECTED | SVLISTENTRYFLAG_FOCUSED ); - nVisPos = rData.nVisPos; } -SvViewData::~SvViewData() +SvViewDataEntry::~SvViewDataEntry() { - DBG_DTOR(SvViewData,0); + DBG_DTOR(SvViewDataEntry,0); #ifdef DBG_UTIL nVisPos = 0x12345678; nFlags = 0x1234; #endif } -bool SvViewData::IsSelected() const +bool SvViewDataEntry::IsSelected() const { return (nFlags & SVLISTENTRYFLAG_SELECTED) != 0; } -bool SvViewData::IsExpanded() const +bool SvViewDataEntry::IsExpanded() const { return (nFlags & SVLISTENTRYFLAG_EXPANDED) != 0; } -bool SvViewData::HasFocus() const +bool SvViewDataEntry::HasFocus() const { return (nFlags & SVLISTENTRYFLAG_FOCUSED) != 0; } -bool SvViewData::IsCursored() const +bool SvViewDataEntry::IsCursored() const { return (nFlags & SVLISTENTRYFLAG_CURSORED) != 0; } -bool SvViewData::IsSelectable() const +bool SvViewDataEntry::IsSelectable() const { return (nFlags & SVLISTENTRYFLAG_NOT_SELECTABLE) == 0; } -void SvViewData::SetFocus( bool bFocus ) +void SvViewDataEntry::SetFocus( bool bFocus ) { if ( !bFocus ) nFlags &= (~SVLISTENTRYFLAG_FOCUSED); @@ -80,7 +78,7 @@ void SvViewData::SetFocus( bool bFocus ) nFlags |= SVLISTENTRYFLAG_FOCUSED; } -void SvViewData::SetCursored( bool bCursored ) +void SvViewDataEntry::SetCursored( bool bCursored ) { if ( !bCursored ) nFlags &= (~SVLISTENTRYFLAG_CURSORED); @@ -88,12 +86,12 @@ void SvViewData::SetCursored( bool bCursored ) nFlags |= SVLISTENTRYFLAG_CURSORED; } -sal_uInt16 SvViewData::GetFlags() const +sal_uInt16 SvViewDataEntry::GetFlags() const { return nFlags; } -void SvViewData::SetSelectable( bool bSelectable ) +void SvViewDataEntry::SetSelectable( bool bSelectable ) { if( bSelectable ) nFlags &= (~SVLISTENTRYFLAG_NOT_SELECTABLE); @@ -101,19 +99,6 @@ void SvViewData::SetSelectable( bool bSelectable ) nFlags |= SVLISTENTRYFLAG_NOT_SELECTABLE; } -DBG_NAME(SvViewDataEntry); - -SvViewDataEntry::SvViewDataEntry() - : SvViewData() -{ - DBG_CTOR(SvViewDataEntry,0); -} - -SvViewDataEntry::~SvViewDataEntry() -{ - DBG_DTOR(SvViewDataEntry,0); -} - void SvViewDataEntry::Init(size_t nSize) { maItems.resize(nSize); |