diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-13 23:09:53 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-13 23:35:51 -0400 |
commit | f75df5e338af4e109f3bce9ab6c98f681fdd14fa (patch) | |
tree | f8889b046cd5874f6e01651e8c9a99a391c1366a | |
parent | ImpEditView no longer a friend of ImpEditEngine. (diff) | |
download | core-f75df5e338af4e109f3bce9ab6c98f681fdd14fa.tar.gz core-f75df5e338af4e109f3bce9ab6c98f681fdd14fa.zip |
Another svarray to kill.
-rw-r--r-- | editeng/inc/editeng/editeng.hxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 46 | ||||
-rw-r--r-- | editeng/source/editeng/editundo.cxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 11 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 12 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 4 |
7 files changed, 52 insertions, 45 deletions
diff --git a/editeng/inc/editeng/editeng.hxx b/editeng/inc/editeng/editeng.hxx index 9156a59d4f95..f3be3d26a453 100644 --- a/editeng/inc/editeng/editeng.hxx +++ b/editeng/inc/editeng/editeng.hxx @@ -216,11 +216,11 @@ public: void ForceAutoColor( sal_Bool b ); sal_Bool IsForceAutoColor() const; - void InsertView( EditView* pEditView, sal_uInt16 nIndex = EE_APPEND ); + void InsertView(EditView* pEditView, size_t nIndex = EE_APPEND); EditView* RemoveView( EditView* pEditView ); - EditView* RemoveView( sal_uInt16 nIndex = EE_APPEND ); - EditView* GetView( sal_uInt16 nIndex = 0 ) const; - sal_uInt16 GetViewCount() const; + EditView* RemoveView(size_t nIndex = EE_APPEND); + EditView* GetView(size_t nIndex = 0) const; + size_t GetViewCount() const; sal_Bool HasView( EditView* pView ) const; EditView* GetActiveView() const; diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 568a15fee536..f78629f590c2 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -333,15 +333,17 @@ void EditEngine::Draw( OutputDevice* pOutDev, const Rectangle& rOutRect, const P pOutDev->SetClipRegion(); } -void EditEngine::InsertView( EditView* pEditView, sal_uInt16 nIndex ) +void EditEngine::InsertView(EditView* pEditView, size_t nIndex) { DBG_CHKTHIS( EditEngine, 0 ); DBG_CHKOBJ( pEditView, EditView, 0 ); - if ( nIndex > pImpEditEngine->GetEditViews().Count() ) - nIndex = pImpEditEngine->GetEditViews().Count(); + if ( nIndex > pImpEditEngine->GetEditViews().size() ) + nIndex = pImpEditEngine->GetEditViews().size(); + + ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews(); + rViews.insert(rViews.begin()+nIndex, pEditView); - pImpEditEngine->GetEditViews().Insert( pEditView, nIndex ); EditSelection aStartSel; aStartSel = pImpEditEngine->GetEditDoc().GetStartPaM(); pEditView->pImpEditView->SetEditSelection( aStartSel ); @@ -357,13 +359,15 @@ EditView* EditEngine::RemoveView( EditView* pView ) DBG_CHKOBJ( pView, EditView, 0 ); pView->HideCursor(); - EditView* pRemoved = 0; - sal_uInt16 nPos = pImpEditEngine->GetEditViews().GetPos( pView ); - DBG_ASSERT( nPos != USHRT_MAX, "RemoveView with invalid index" ); - if ( nPos != USHRT_MAX ) + EditView* pRemoved = NULL; + ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews(); + ImpEditEngine::ViewsType::iterator it = std::find(rViews.begin(), rViews.end(), pView); + + DBG_ASSERT( it != rViews.end(), "RemoveView with invalid index" ); + if (it != rViews.end()) { - pRemoved = pImpEditEngine->GetEditViews().GetObject( nPos ); - pImpEditEngine->GetEditViews().Remove( nPos ); + pRemoved = *it; + rViews.erase(it); if ( pImpEditEngine->GetActiveView() == pView ) { pImpEditEngine->SetActiveView( 0 ); @@ -375,30 +379,32 @@ EditView* EditEngine::RemoveView( EditView* pView ) return pRemoved; } -EditView* EditEngine::RemoveView( sal_uInt16 nIndex ) +EditView* EditEngine::RemoveView(size_t nIndex) { DBG_CHKTHIS( EditEngine, 0 ); - EditView* pView = pImpEditEngine->GetEditViews().GetObject( nIndex ); + ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews(); + EditView* pView = rViews[nIndex]; if ( pView ) return RemoveView( pView ); return NULL; } -EditView* EditEngine::GetView( sal_uInt16 nIndex ) const +EditView* EditEngine::GetView(size_t nIndex) const { DBG_CHKTHIS( EditEngine, 0 ); - return pImpEditEngine->GetEditViews().GetObject( nIndex ); + return pImpEditEngine->GetEditViews()[nIndex]; } -sal_uInt16 EditEngine::GetViewCount() const +size_t EditEngine::GetViewCount() const { DBG_CHKTHIS( EditEngine, 0 ); - return pImpEditEngine->GetEditViews().Count(); + return pImpEditEngine->GetEditViews().size(); } sal_Bool EditEngine::HasView( EditView* pView ) const { - return pImpEditEngine->GetEditViews().GetPos( pView ) != USHRT_MAX; + ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews(); + return std::find(rViews.begin(), rViews.end(), pView) != rViews.end(); } EditView* EditEngine::GetActiveView() const @@ -429,10 +435,10 @@ void EditEngine::SetPaperSize( const Size& rNewSize ) sal_Bool bAutoPageSize = pImpEditEngine->GetStatus().AutoPageSize(); if ( bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() ) ) { - for ( sal_uInt16 nView = 0; nView < pImpEditEngine->aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < pImpEditEngine->aEditViews.size(); ++nView) { EditView* pView = pImpEditEngine->aEditViews[nView]; - DBG_CHKOBJ( pView, EditView, 0 ); + DBG_CHKOBJ( pView, EditView, 0 ); if ( bAutoPageSize ) pView->pImpEditView->RecalcOutputArea(); else if ( pView->pImpEditView->DoAutoSize() ) @@ -447,7 +453,7 @@ void EditEngine::SetPaperSize( const Size& rNewSize ) // Changing the width has no effect for AutoPageSize, as this is // determined by the text width. // Optimization first after Vobis delivery was enabled ... - pImpEditEngine->FormatFullDoc(); + pImpEditEngine->FormatFullDoc(); pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() ); diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx index 6fae46c4d3b8..81bce92cef6b 100644 --- a/editeng/source/editeng/editundo.cxx +++ b/editeng/source/editeng/editundo.cxx @@ -79,8 +79,8 @@ sal_Bool EditUndoManager::Undo() if ( !pImpEE->GetActiveView() ) { - if ( pImpEE->GetEditViews().Count() ) - pImpEE->SetActiveView( pImpEE->GetEditViews().GetObject(0) ); + if (!pImpEE->GetEditViews().empty()) + pImpEE->SetActiveView(pImpEE->GetEditViews()[0]); else { OSL_FAIL("Undo in engine is not possible without a View! "); @@ -114,8 +114,8 @@ sal_Bool EditUndoManager::Redo() if ( !pImpEE->GetActiveView() ) { - if ( pImpEE->GetEditViews().Count() ) - pImpEE->SetActiveView( pImpEE->GetEditViews().GetObject(0) ); + if (!pImpEE->GetEditViews().empty()) + pImpEE->SetActiveView(pImpEE->GetEditViews()[0]); else { OSL_FAIL( "Redo in Engine ohne View nicht moeglich!" ); diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 452553c316e7..2e32318d9799 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -378,9 +378,6 @@ public: // ImpEditEngine // ---------------------------------------------------------------------- -typedef EditView* EditViewPtr; -SV_DECL_PTRARR( EditViews, EditViewPtr, 0 ) - class ImpEditEngine : public SfxListener, boost::noncopyable { // The Undos have to manipulate directly ( private-Methods ), @@ -399,6 +396,9 @@ class ImpEditEngine : public SfxListener, boost::noncopyable friend class EdtAutoCorrDoc; // For access to Imp-Methods friend class EditDbg; // Debug Routines +public: + typedef std::vector<EditView*> ViewsType; + private: // ================================================================ @@ -414,7 +414,7 @@ private: // Engine Specific data ... EditEngine* pEditEngine; - EditViews aEditViews; + ViewsType aEditViews; EditView* pActiveView; TextRanger* pTextRanger; @@ -706,7 +706,8 @@ public: const ParaPortionList& GetParaPortions() const { return aParaPortionList; } ParaPortionList& GetParaPortions() { return aParaPortionList; } - EditViews& GetEditViews() { return aEditViews; } + ViewsType& GetEditViews() { return aEditViews; } + const ViewsType& GetEditViews() const { return aEditViews; } const Size& GetPaperSize() const { return aPaperSize; } void SetPaperSize( const Size& rSz ) { aPaperSize = rSz; } diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 5612f3b7bc94..ece3367579a7 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -702,7 +702,7 @@ EditPaM ImpEditEngine::Clear() ResetUndoManager(); - for ( sal_uInt16 nView = aEditViews.Count(); nView; ) + for (size_t nView = aEditViews.size(); nView; ) { EditView* pView = aEditViews[--nView]; DBG_CHKOBJ( pView, EditView, 0 ); @@ -718,9 +718,9 @@ EditPaM ImpEditEngine::RemoveText() EditPaM aStartPaM = aEditDoc.GetStartPaM(); EditSelection aEmptySel( aStartPaM, aStartPaM ); - for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < aEditViews.size(); ++nView) { - EditView* pView = aEditViews.GetObject(nView); + EditView* pView = aEditViews[nView]; DBG_CHKOBJ( pView, EditView, 0 ); pView->pImpEditView->SetEditSelection( aEmptySel ); } @@ -742,7 +742,7 @@ void ImpEditEngine::SetText( const XubString& rText ) if ( rText.Len() ) aPaM = ImpInsertText( aEmptySel, rText ); - for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < aEditViews.size(); ++nView) { EditView* pView = aEditViews[nView]; DBG_CHKOBJ( pView, EditView, 0 ); @@ -3349,9 +3349,9 @@ void ImpEditEngine::UpdateSelections() { // Check whether one of the selections is at a deleted node... // If the node is valid, the index has yet to be examined! - for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < aEditViews.size(); ++nView) { - EditView* pView = aEditViews.GetObject(nView); + EditView* pView = aEditViews[nView]; DBG_CHKOBJ( pView, EditView, 0 ); EditSelection aCurSel( pView->pImpEditView->GetEditSelection() ); bool bChanged = false; diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 3d6ed7194cec..0d6877b99088 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -286,7 +286,7 @@ void ImpEditEngine::UpdateViews( EditView* pCurView ) DBG_ASSERT( IsFormatted(), "UpdateViews: Doc not formatted!" ); - for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < aEditViews.size(); ++nView) { EditView* pView = aEditViews[nView]; DBG_CHKOBJ( pView, EditView, 0 ); @@ -336,7 +336,7 @@ IMPL_LINK_NOARG_INLINE_START(ImpEditEngine, IdleFormatHdl) // else probably the idle format timer fired while we're already // downing EditView* pView = aIdleFormatter.GetView(); - for( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < aEditViews.size(); ++nView) { if( aEditViews[nView] == pView ) { @@ -467,7 +467,7 @@ void ImpEditEngine::FormatDoc() CheckAutoPageSize(); else if ( nDiff ) { - for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < aEditViews.size(); ++nView) { EditView* pView = aEditViews[nView]; ImpEditView* pImpView = pView->pImpEditView; @@ -570,7 +570,7 @@ void ImpEditEngine::CheckAutoPageSize() aInvalidRec = Rectangle( Point(), aSz ); - for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < aEditViews.size(); ++nView) { EditView* pView = aEditViews[nView]; pView->pImpEditView->RecalcOutputArea(); diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 25608f8a4301..28121caa4d0b 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -2369,7 +2369,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, sal_Bool bSpel aStatus.GetStatusWord() |= EE_STAT_WRONGWORDCHANGED; CallStatusHdl(); - if ( aEditViews.Count() ) + if (!aEditViews.empty()) { // For SimpleRepaint one was painted over a range without // reaching VDEV, but then one would have to intersect, c @@ -2390,7 +2390,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, sal_Bool bSpel } else if ( bSimpleRepaint ) { - for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) + for (size_t nView = 0; nView < aEditViews.size(); ++nView) { EditView* pView = aEditViews[nView]; Rectangle aClipRec( aInvalidRec ); |