diff options
-rw-r--r-- | include/svl/undo.hxx | 38 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/outlview.cxx | 28 | ||||
-rw-r--r-- | svl/source/undo/undo.cxx | 241 |
4 files changed, 120 insertions, 191 deletions
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx index 434124373666..456a31f56b18 100644 --- a/include/svl/undo.hxx +++ b/include/svl/undo.hxx @@ -26,6 +26,7 @@ #include <limits> #include <memory> +#include <vector> struct MarkedUndoAction; @@ -80,42 +81,31 @@ private: typedef sal_Int32 UndoStackMark; #define MARK_INVALID ::std::numeric_limits< UndoStackMark >::max() -class SVL_DLLPUBLIC SfxUndoActions +struct MarkedUndoAction { - struct Impl; - std::unique_ptr<Impl> mpImpl; - -public: - SfxUndoActions(); - SfxUndoActions( const SfxUndoActions& r ); - ~SfxUndoActions(); - - bool empty() const; - size_t size() const; - - const MarkedUndoAction& operator[]( size_t i ) const; - MarkedUndoAction& operator[]( size_t i ); - - const SfxUndoAction* GetUndoAction( size_t i ) const; - SfxUndoAction* GetUndoAction( size_t i ); + SfxUndoAction* pAction; + ::std::vector< UndoStackMark > aMarks; - void Remove( size_t i_pos ); - void Remove( size_t i_pos, size_t i_count ); - void Insert( SfxUndoAction* i_action, size_t i_pos ); + MarkedUndoAction(SfxUndoAction* p) : pAction(p) {} }; /** do not make use of these implementation details, unless you really really have to! */ struct SVL_DLLPUBLIC SfxUndoArray { - SfxUndoActions aUndoActions; + std::vector<MarkedUndoAction> maUndoActions; size_t nMaxUndoActions; size_t nCurUndoAction; SfxUndoArray *pFatherUndoArray; - SfxUndoArray(size_t nMax=0): - nMaxUndoActions(nMax), nCurUndoAction(0), - pFatherUndoArray(nullptr) {} + + SfxUndoArray(size_t nMax=0) : + nMaxUndoActions(nMax), nCurUndoAction(0), pFatherUndoArray(nullptr) {} virtual ~SfxUndoArray(); + + SfxUndoAction* GetUndoAction(size_t idx) { return maUndoActions[idx].pAction; } + void Remove(int idx); + void Remove( size_t i_pos, size_t i_count ); + void Insert( SfxUndoAction* i_action, size_t i_pos ); }; diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index e410959e8c50..d629152c2217 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -503,9 +503,9 @@ void SdTiledRenderingTest::testSetGraphicSelection() CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetUndoActionCount()); auto pListAction = dynamic_cast<SfxListUndoAction*>(pUndoManager->GetUndoAction()); CPPUNIT_ASSERT(pListAction); - for (size_t i = 0; i < pListAction->aUndoActions.size(); ++i) + for (size_t i = 0; i < pListAction->maUndoActions.size(); ++i) // The second item was -1 here, view shell ID wasn't known. - CPPUNIT_ASSERT_EQUAL(ViewShellId(nView1), pListAction->aUndoActions.GetUndoAction(i)->GetViewShellId()); + CPPUNIT_ASSERT_EQUAL(ViewShellId(nView1), pListAction->GetUndoAction(i)->GetViewShellId()); ::tools::Rectangle aShapeAfter = pObject->GetSnapRect(); // Check that a resize happened, but aspect ratio is not kept. diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index da65b1b355a3..5df2438bd791 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -1488,11 +1488,11 @@ void OutlineView::TryToMergeUndoActions() if( pListAction && pPrevListAction ) { // find the top EditUndo action in the top undo action list - size_t nAction = pListAction->aUndoActions.size(); + size_t nAction = pListAction->maUndoActions.size(); EditUndo* pEditUndo = nullptr; while( !pEditUndo && nAction ) { - pEditUndo = dynamic_cast< EditUndo* >(pListAction->aUndoActions.GetUndoAction(--nAction)); + pEditUndo = dynamic_cast< EditUndo* >(pListAction->GetUndoAction(--nAction)); } sal_uInt16 nEditPos = nAction; // we need this later to remove the merged undo actions @@ -1500,7 +1500,7 @@ void OutlineView::TryToMergeUndoActions() // make sure it is the only EditUndo action in the top undo list while( pEditUndo && nAction ) { - if( dynamic_cast< EditUndo* >(pListAction->aUndoActions.GetUndoAction(--nAction)) ) + if( dynamic_cast< EditUndo* >(pListAction->GetUndoAction(--nAction)) ) pEditUndo = nullptr; } @@ -1509,10 +1509,10 @@ void OutlineView::TryToMergeUndoActions() { // yes, see if we can merge it with the prev undo list - nAction = pPrevListAction->aUndoActions.size(); + nAction = pPrevListAction->maUndoActions.size(); EditUndo* pPrevEditUndo = nullptr; while( !pPrevEditUndo && nAction ) - pPrevEditUndo = dynamic_cast< EditUndo* >(pPrevListAction->aUndoActions.GetUndoAction(--nAction)); + pPrevEditUndo = dynamic_cast< EditUndo* >(pPrevListAction->GetUndoAction(--nAction)); if( pPrevEditUndo && pPrevEditUndo->Merge( pEditUndo ) ) { @@ -1520,26 +1520,26 @@ void OutlineView::TryToMergeUndoActions() // the top EditUndo of the previous undo list // first remove the merged undo action - DBG_ASSERT( pListAction->aUndoActions.GetUndoAction(nEditPos) == pEditUndo, + DBG_ASSERT( pListAction->GetUndoAction(nEditPos) == pEditUndo, "sd::OutlineView::TryToMergeUndoActions(), wrong edit pos!" ); - pListAction->aUndoActions.Remove(nEditPos); + pListAction->Remove(nEditPos); delete pEditUndo; - if ( !pListAction->aUndoActions.empty() ) + if ( !pListAction->maUndoActions.empty() ) { // now we have to move all remaining doc undo actions from the top undo // list to the previous undo list and remove the top undo list - size_t nCount = pListAction->aUndoActions.size(); - size_t nDestAction = pPrevListAction->aUndoActions.size(); + size_t nCount = pListAction->maUndoActions.size(); + size_t nDestAction = pPrevListAction->maUndoActions.size(); while( nCount-- ) { - SfxUndoAction* pTemp = pListAction->aUndoActions.GetUndoAction(0); - pListAction->aUndoActions.Remove(0); + SfxUndoAction* pTemp = pListAction->GetUndoAction(0); + pListAction->Remove(0); if( pTemp ) - pPrevListAction->aUndoActions.Insert( pTemp, nDestAction++ ); + pPrevListAction->Insert( pTemp, nDestAction++ ); } - pPrevListAction->nCurUndoAction = pPrevListAction->aUndoActions.size(); + pPrevListAction->nCurUndoAction = pPrevListAction->maUndoActions.size(); } rOutlineUndo.RemoveLastUndoAction(); diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index 961e1b9af8aa..cc7cb8157ff8 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -136,80 +136,19 @@ void SfxUndoAction::dumpAsXml(xmlTextWriterPtr pWriter) const xmlTextWriterEndElement(pWriter); } -struct MarkedUndoAction +void SfxUndoArray::Remove(int idx) { - SfxUndoAction* pAction; - ::std::vector< UndoStackMark > aMarks; - - explicit MarkedUndoAction( SfxUndoAction* i_action ) - :pAction( i_action ) - ,aMarks() - { - } -}; - -struct SfxUndoActions::Impl -{ - std::vector<MarkedUndoAction> maActions; -}; - -SfxUndoActions::SfxUndoActions() : mpImpl(new Impl) {} - -SfxUndoActions::SfxUndoActions( const SfxUndoActions& r ) : - mpImpl(new Impl) -{ - mpImpl->maActions = r.mpImpl->maActions; -} - -SfxUndoActions::~SfxUndoActions() -{ -} - -bool SfxUndoActions::empty() const -{ - return mpImpl->maActions.empty(); -} - -size_t SfxUndoActions::size() const -{ - return mpImpl->maActions.size(); -} - -const MarkedUndoAction& SfxUndoActions::operator[]( size_t i ) const -{ - return mpImpl->maActions[i]; -} - -MarkedUndoAction& SfxUndoActions::operator[]( size_t i ) -{ - return mpImpl->maActions[i]; -} - -const SfxUndoAction* SfxUndoActions::GetUndoAction( size_t i ) const -{ - return mpImpl->maActions[i].pAction; -} - -SfxUndoAction* SfxUndoActions::GetUndoAction( size_t i ) -{ - return mpImpl->maActions[i].pAction; -} - -void SfxUndoActions::Remove( size_t i_pos ) -{ - mpImpl->maActions.erase( mpImpl->maActions.begin() + i_pos ); + maUndoActions.erase(maUndoActions.begin() + idx); } -void SfxUndoActions::Remove( size_t i_pos, size_t i_count ) +void SfxUndoArray::Remove( size_t i_pos, size_t i_count ) { - mpImpl->maActions.erase( - mpImpl->maActions.begin() + i_pos, mpImpl->maActions.begin() + i_pos + i_count); + maUndoActions.erase(maUndoActions.begin() + i_pos, maUndoActions.begin() + i_pos + i_count); } -void SfxUndoActions::Insert( SfxUndoAction* i_action, size_t i_pos ) +void SfxUndoArray::Insert( SfxUndoAction* i_action, size_t i_pos ) { - mpImpl->maActions.insert( - mpImpl->maActions.begin() + i_pos, MarkedUndoAction( i_action ) ); + maUndoActions.insert( maUndoActions.begin() + i_pos, MarkedUndoAction(i_action) ); } typedef ::std::vector< SfxUndoListener* > UndoListeners; @@ -453,28 +392,28 @@ void SfxUndoManager::SetMaxUndoActionCount( size_t nMaxUndoActionCount ) // Both redo and undo action entries will be removed until we reached the // new nMaxUndoActionCount. - long nNumToDelete = m_xData->pActUndoArray->aUndoActions.size() - nMaxUndoActionCount; + long nNumToDelete = m_xData->pActUndoArray->maUndoActions.size() - nMaxUndoActionCount; while ( nNumToDelete > 0 ) { - size_t nPos = m_xData->pActUndoArray->aUndoActions.size(); + size_t nPos = m_xData->pActUndoArray->maUndoActions.size(); if ( nPos > m_xData->pActUndoArray->nCurUndoAction ) { - SfxUndoAction* pAction = m_xData->pActUndoArray->aUndoActions[nPos-1].pAction; + SfxUndoAction* pAction = m_xData->pActUndoArray->maUndoActions[nPos-1].pAction; aGuard.markForDeletion( pAction ); - m_xData->pActUndoArray->aUndoActions.Remove( nPos-1 ); + m_xData->pActUndoArray->Remove( nPos-1 ); --nNumToDelete; } if ( nNumToDelete > 0 && m_xData->pActUndoArray->nCurUndoAction > 0 ) { - SfxUndoAction* pAction = m_xData->pActUndoArray->aUndoActions[0].pAction; + SfxUndoAction* pAction = m_xData->pActUndoArray->maUndoActions[0].pAction; aGuard.markForDeletion( pAction ); - m_xData->pActUndoArray->aUndoActions.Remove(0); + m_xData->pActUndoArray->Remove(0); --m_xData->pActUndoArray->nCurUndoAction; --nNumToDelete; } - if ( nPos == m_xData->pActUndoArray->aUndoActions.size() ) + if ( nPos == m_xData->pActUndoArray->maUndoActions.size() ) break; // Cannot delete more entries } @@ -486,12 +425,12 @@ void SfxUndoManager::SetMaxUndoActionCount( size_t nMaxUndoActionCount ) void SfxUndoManager::ImplClearCurrentLevel_NoNotify( UndoManagerGuard& i_guard ) { // clear array - while ( !m_xData->pActUndoArray->aUndoActions.empty() ) + while ( !m_xData->pActUndoArray->maUndoActions.empty() ) { - size_t deletePos = m_xData->pActUndoArray->aUndoActions.size() - 1; - SfxUndoAction* pAction = m_xData->pActUndoArray->aUndoActions[ deletePos ].pAction; + size_t deletePos = m_xData->pActUndoArray->maUndoActions.size() - 1; + SfxUndoAction* pAction = m_xData->pActUndoArray->maUndoActions[ deletePos ].pAction; i_guard.markForDeletion( pAction ); - m_xData->pActUndoArray->aUndoActions.Remove( deletePos ); + m_xData->pActUndoArray->Remove( deletePos ); } m_xData->pActUndoArray->nCurUndoAction = 0; @@ -574,8 +513,8 @@ void SfxUndoManager::ImplClearUndo( UndoManagerGuard& i_guard ) { while ( m_xData->pActUndoArray->nCurUndoAction > 0 ) { - SfxUndoAction* pUndoAction = m_xData->pActUndoArray->aUndoActions[0].pAction; - m_xData->pActUndoArray->aUndoActions.Remove( 0 ); + SfxUndoAction* pUndoAction = m_xData->pActUndoArray->maUndoActions[0].pAction; + m_xData->pActUndoArray->Remove( 0 ); i_guard.markForDeletion( pUndoAction ); --m_xData->pActUndoArray->nCurUndoAction; } @@ -589,11 +528,11 @@ void SfxUndoManager::ImplClearRedo( UndoManagerGuard& i_guard, bool const i_curr SfxUndoArray* pUndoArray = ( i_currentLevel == SfxUndoManager::CurrentLevel ) ? m_xData->pActUndoArray : m_xData->pUndoArray.get(); // clearance - while ( pUndoArray->aUndoActions.size() > pUndoArray->nCurUndoAction ) + while ( pUndoArray->maUndoActions.size() > pUndoArray->nCurUndoAction ) { - size_t deletePos = pUndoArray->aUndoActions.size() - 1; - SfxUndoAction* pAction = pUndoArray->aUndoActions[ deletePos ].pAction; - pUndoArray->aUndoActions.Remove( deletePos ); + size_t deletePos = pUndoArray->maUndoActions.size() - 1; + SfxUndoAction* pAction = pUndoArray->maUndoActions[ deletePos ].pAction; + pUndoArray->Remove( deletePos ); i_guard.markForDeletion( pAction ); } @@ -614,7 +553,7 @@ bool SfxUndoManager::ImplAddUndoAction_NoNotify( SfxUndoAction *pAction, bool bT // merge, if required SfxUndoAction* pMergeWithAction = m_xData->pActUndoArray->nCurUndoAction ? - m_xData->pActUndoArray->aUndoActions[m_xData->pActUndoArray->nCurUndoAction-1].pAction : nullptr; + m_xData->pActUndoArray->maUndoActions[m_xData->pActUndoArray->nCurUndoAction-1].pAction : nullptr; if ( bTryMerge && pMergeWithAction ) { bool bMerged = pMergeWithAction->Merge( pAction ); @@ -632,10 +571,10 @@ bool SfxUndoManager::ImplAddUndoAction_NoNotify( SfxUndoAction *pAction, bool bT // respect max number if( m_xData->pActUndoArray == m_xData->pUndoArray.get() ) { - while(m_xData->pActUndoArray->aUndoActions.size() >= m_xData->pActUndoArray->nMaxUndoActions) + while(m_xData->pActUndoArray->maUndoActions.size() >= m_xData->pActUndoArray->nMaxUndoActions) { - i_guard.markForDeletion( m_xData->pActUndoArray->aUndoActions[0].pAction ); - m_xData->pActUndoArray->aUndoActions.Remove(0); + i_guard.markForDeletion( m_xData->pActUndoArray->maUndoActions[0].pAction ); + m_xData->pActUndoArray->Remove(0); if (m_xData->pActUndoArray->nCurUndoAction > 0) { --m_xData->pActUndoArray->nCurUndoAction; @@ -650,7 +589,7 @@ bool SfxUndoManager::ImplAddUndoAction_NoNotify( SfxUndoAction *pAction, bool bT } // append new action - m_xData->pActUndoArray->aUndoActions.Insert( pAction, m_xData->pActUndoArray->nCurUndoAction++ ); + m_xData->pActUndoArray->Insert( pAction, m_xData->pActUndoArray->nCurUndoAction++ ); ImplCheckEmptyActions(); return true; } @@ -685,7 +624,7 @@ OUString SfxUndoManager::GetUndoActionComment( size_t nNo, bool const i_currentL const SfxUndoArray* pUndoArray = i_currentLevel ? m_xData->pActUndoArray : m_xData->pUndoArray.get(); assert(nNo < pUndoArray->nCurUndoAction); if( nNo < pUndoArray->nCurUndoAction ) - sComment = pUndoArray->aUndoActions[ pUndoArray->nCurUndoAction - 1 - nNo ].pAction->GetComment(); + sComment = pUndoArray->maUndoActions[ pUndoArray->nCurUndoAction - 1 - nNo ].pAction->GetComment(); return sComment; } @@ -697,7 +636,7 @@ SfxUndoAction* SfxUndoManager::GetUndoAction( size_t nNo ) const assert(nNo < m_xData->pActUndoArray->nCurUndoAction); if( nNo >= m_xData->pActUndoArray->nCurUndoAction ) return nullptr; - return m_xData->pActUndoArray->aUndoActions[m_xData->pActUndoArray->nCurUndoAction-1-nNo].pAction; + return m_xData->pActUndoArray->maUndoActions[m_xData->pActUndoArray->nCurUndoAction-1-nNo].pAction; } @@ -711,14 +650,14 @@ void SfxUndoManager::RemoveLastUndoAction() m_xData->pActUndoArray->nCurUndoAction--; // delete redo-actions and top action - for ( size_t nPos = m_xData->pActUndoArray->aUndoActions.size(); nPos > m_xData->pActUndoArray->nCurUndoAction; --nPos ) + for ( size_t nPos = m_xData->pActUndoArray->maUndoActions.size(); nPos > m_xData->pActUndoArray->nCurUndoAction; --nPos ) { - aGuard.markForDeletion( m_xData->pActUndoArray->aUndoActions[nPos-1].pAction ); + aGuard.markForDeletion( m_xData->pActUndoArray->maUndoActions[nPos-1].pAction ); } - m_xData->pActUndoArray->aUndoActions.Remove( + m_xData->pActUndoArray->Remove( m_xData->pActUndoArray->nCurUndoAction, - m_xData->pActUndoArray->aUndoActions.size() - m_xData->pActUndoArray->nCurUndoAction ); + m_xData->pActUndoArray->maUndoActions.size() - m_xData->pActUndoArray->nCurUndoAction ); ImplCheckEmptyActions(); } @@ -762,7 +701,7 @@ bool SfxUndoManager::ImplUndo( SfxUndoContext* i_contextOrNull ) return false; } - SfxUndoAction* pAction = m_xData->pActUndoArray->aUndoActions[ --m_xData->pActUndoArray->nCurUndoAction ].pAction; + SfxUndoAction* pAction = m_xData->pActUndoArray->maUndoActions[ --m_xData->pActUndoArray->nCurUndoAction ].pAction; const OUString sActionComment = pAction->GetComment(); try { @@ -782,9 +721,9 @@ bool SfxUndoManager::ImplUndo( SfxUndoContext* i_contextOrNull ) // in theory, somebody might have tampered with all of *m_xData while the mutex was unlocked. So, see if // we still find pAction in our current Undo array size_t nCurAction = 0; - while ( nCurAction < m_xData->pActUndoArray->aUndoActions.size() ) + while ( nCurAction < m_xData->pActUndoArray->maUndoActions.size() ) { - if ( m_xData->pActUndoArray->aUndoActions[ nCurAction++ ].pAction == pAction ) + if ( m_xData->pActUndoArray->maUndoActions[ nCurAction++ ].pAction == pAction ) { // the Undo action is still there ... // assume the error is a permanent failure, and clear the Undo stack @@ -812,7 +751,7 @@ size_t SfxUndoManager::GetRedoActionCount( bool const i_currentLevel ) const size_t SfxUndoManager::ImplGetRedoActionCount_Lock( bool const i_currentLevel ) const { const SfxUndoArray* pUndoArray = i_currentLevel ? m_xData->pActUndoArray : m_xData->pUndoArray.get(); - return pUndoArray->aUndoActions.size() - pUndoArray->nCurUndoAction; + return pUndoArray->maUndoActions.size() - pUndoArray->nCurUndoAction; } @@ -821,11 +760,11 @@ SfxUndoAction* SfxUndoManager::GetRedoAction() const UndoManagerGuard aGuard( *m_xData ); const SfxUndoArray* pUndoArray = m_xData->pActUndoArray; - if ( (pUndoArray->nCurUndoAction) > pUndoArray->aUndoActions.size() ) + if ( (pUndoArray->nCurUndoAction) > pUndoArray->maUndoActions.size() ) { return nullptr; } - return pUndoArray->aUndoActions[ pUndoArray->nCurUndoAction ].pAction; + return pUndoArray->maUndoActions[ pUndoArray->nCurUndoAction ].pAction; } @@ -834,9 +773,9 @@ OUString SfxUndoManager::GetRedoActionComment( size_t nNo, bool const i_currentL OUString sComment; UndoManagerGuard aGuard( *m_xData ); const SfxUndoArray* pUndoArray = i_currentLevel ? m_xData->pActUndoArray : m_xData->pUndoArray.get(); - if ( (pUndoArray->nCurUndoAction + nNo) < pUndoArray->aUndoActions.size() ) + if ( (pUndoArray->nCurUndoAction + nNo) < pUndoArray->maUndoActions.size() ) { - sComment = pUndoArray->aUndoActions[ pUndoArray->nCurUndoAction + nNo ].pAction->GetComment(); + sComment = pUndoArray->maUndoActions[ pUndoArray->nCurUndoAction + nNo ].pAction->GetComment(); } return sComment; } @@ -868,13 +807,13 @@ bool SfxUndoManager::ImplRedo( SfxUndoContext* i_contextOrNull ) return false; } - if ( m_xData->pActUndoArray->nCurUndoAction >= m_xData->pActUndoArray->aUndoActions.size() ) + if ( m_xData->pActUndoArray->nCurUndoAction >= m_xData->pActUndoArray->maUndoActions.size() ) { SAL_WARN("svl", "SfxUndoManager::Redo: redo stack is empty!"); return false; } - SfxUndoAction* pAction = m_xData->pActUndoArray->aUndoActions[ m_xData->pActUndoArray->nCurUndoAction++ ].pAction; + SfxUndoAction* pAction = m_xData->pActUndoArray->maUndoActions[ m_xData->pActUndoArray->nCurUndoAction++ ].pAction; const OUString sActionComment = pAction->GetComment(); try { @@ -894,9 +833,9 @@ bool SfxUndoManager::ImplRedo( SfxUndoContext* i_contextOrNull ) // in theory, somebody might have tampered with all of *m_xData while the mutex was unlocked. So, see if // we still find pAction in our current Undo array size_t nCurAction = 0; - while ( nCurAction < m_xData->pActUndoArray->aUndoActions.size() ) + while ( nCurAction < m_xData->pActUndoArray->maUndoActions.size() ) { - if ( m_xData->pActUndoArray->aUndoActions[ nCurAction ].pAction == pAction ) + if ( m_xData->pActUndoArray->maUndoActions[ nCurAction ].pAction == pAction ) { // the Undo action is still there ... // assume the error is a permanent failure, and clear the Undo stack @@ -919,14 +858,14 @@ bool SfxUndoManager::ImplRedo( SfxUndoContext* i_contextOrNull ) size_t SfxUndoManager::GetRepeatActionCount() const { UndoManagerGuard aGuard( *m_xData ); - return m_xData->pActUndoArray->aUndoActions.size(); + return m_xData->pActUndoArray->maUndoActions.size(); } OUString SfxUndoManager::GetRepeatActionComment(SfxRepeatTarget &rTarget) const { UndoManagerGuard aGuard( *m_xData ); - return m_xData->pActUndoArray->aUndoActions[ m_xData->pActUndoArray->aUndoActions.size() - 1 ].pAction + return m_xData->pActUndoArray->maUndoActions[ m_xData->pActUndoArray->maUndoActions.size() - 1 ].pAction ->GetRepeatComment(rTarget); } @@ -934,9 +873,9 @@ OUString SfxUndoManager::GetRepeatActionComment(SfxRepeatTarget &rTarget) const bool SfxUndoManager::Repeat( SfxRepeatTarget &rTarget ) { UndoManagerGuard aGuard( *m_xData ); - if ( !m_xData->pActUndoArray->aUndoActions.empty() ) + if ( !m_xData->pActUndoArray->maUndoActions.empty() ) { - SfxUndoAction* pAction = m_xData->pActUndoArray->aUndoActions[ m_xData->pActUndoArray->aUndoActions.size() - 1 ].pAction; + SfxUndoAction* pAction = m_xData->pActUndoArray->maUndoActions[ m_xData->pActUndoArray->maUndoActions.size() - 1 ].pAction; aGuard.clear(); if ( pAction->CanRepeat( rTarget ) ) pAction->Repeat( rTarget ); @@ -950,10 +889,10 @@ bool SfxUndoManager::Repeat( SfxRepeatTarget &rTarget ) bool SfxUndoManager::CanRepeat( SfxRepeatTarget &rTarget ) const { UndoManagerGuard aGuard( *m_xData ); - if ( !m_xData->pActUndoArray->aUndoActions.empty() ) + if ( !m_xData->pActUndoArray->maUndoActions.empty() ) { - size_t nActionNo = m_xData->pActUndoArray->aUndoActions.size() - 1; - return m_xData->pActUndoArray->aUndoActions[nActionNo].pAction->CanRepeat(rTarget); + size_t nActionNo = m_xData->pActUndoArray->maUndoActions.size() - 1; + return m_xData->pActUndoArray->maUndoActions[nActionNo].pAction->CanRepeat(rTarget); } return false; } @@ -1088,8 +1027,8 @@ size_t SfxUndoManager::ImplLeaveListAction( const bool i_merge, UndoManagerGuard const size_t nListActionElements = pArrayToLeave->nCurUndoAction; if ( nListActionElements == 0 ) { - SfxUndoAction* pCurrentAction= m_xData->pActUndoArray->aUndoActions[ m_xData->pActUndoArray->nCurUndoAction-1 ].pAction; - m_xData->pActUndoArray->aUndoActions.Remove( --m_xData->pActUndoArray->nCurUndoAction ); + SfxUndoAction* pCurrentAction= m_xData->pActUndoArray->maUndoActions[ m_xData->pActUndoArray->nCurUndoAction-1 ].pAction; + m_xData->pActUndoArray->Remove( --m_xData->pActUndoArray->nCurUndoAction ); i_guard.markForDeletion( pCurrentAction ); i_guard.scheduleNotification( &SfxUndoListener::listActionCancelled ); @@ -1100,7 +1039,7 @@ size_t SfxUndoManager::ImplLeaveListAction( const bool i_merge, UndoManagerGuard // the redo stack ImplClearRedo( i_guard, SfxUndoManager::CurrentLevel ); - SfxUndoAction* pCurrentAction= m_xData->pActUndoArray->aUndoActions[ m_xData->pActUndoArray->nCurUndoAction-1 ].pAction; + SfxUndoAction* pCurrentAction= m_xData->pActUndoArray->maUndoActions[ m_xData->pActUndoArray->nCurUndoAction-1 ].pAction; SfxListUndoAction* pListAction = dynamic_cast< SfxListUndoAction * >( pCurrentAction ); ENSURE_OR_RETURN( pListAction, "SfxUndoManager::ImplLeaveListAction: list action expected at this position!", nListActionElements ); @@ -1111,10 +1050,10 @@ size_t SfxUndoManager::ImplLeaveListAction( const bool i_merge, UndoManagerGuard "SfxUndoManager::ImplLeaveListAction: cannot merge the list action if there's no other action on the same level - check this beforehand!" ); if ( m_xData->pActUndoArray->nCurUndoAction > 1 ) { - SfxUndoAction* pPreviousAction = m_xData->pActUndoArray->aUndoActions[ m_xData->pActUndoArray->nCurUndoAction - 2 ].pAction; - m_xData->pActUndoArray->aUndoActions.Remove( m_xData->pActUndoArray->nCurUndoAction - 2 ); + SfxUndoAction* pPreviousAction = m_xData->pActUndoArray->maUndoActions[ m_xData->pActUndoArray->nCurUndoAction - 2 ].pAction; + m_xData->pActUndoArray->Remove( m_xData->pActUndoArray->nCurUndoAction - 2 ); --m_xData->pActUndoArray->nCurUndoAction; - pListAction->aUndoActions.Insert( pPreviousAction, 0 ); + pListAction->Insert( pPreviousAction, 0 ); ++pListAction->nCurUndoAction; pListAction->SetComment( pPreviousAction->GetComment() ); @@ -1124,11 +1063,11 @@ size_t SfxUndoManager::ImplLeaveListAction( const bool i_merge, UndoManagerGuard // if the undo array has no comment, try to get it from its children if ( pListAction->GetComment().isEmpty() ) { - for( size_t n = 0; n < pListAction->aUndoActions.size(); n++ ) + for( size_t n = 0; n < pListAction->maUndoActions.size(); n++ ) { - if (!pListAction->aUndoActions[n].pAction->GetComment().isEmpty()) + if (!pListAction->maUndoActions[n].pAction->GetComment().isEmpty()) { - pListAction->SetComment( pListAction->aUndoActions[n].pAction->GetComment() ); + pListAction->SetComment( pListAction->maUndoActions[n].pAction->GetComment() ); break; } } @@ -1158,7 +1097,7 @@ UndoStackMark SfxUndoManager::MarkTopUndoAction() return m_xData->mnEmptyMark; } - m_xData->pUndoArray->aUndoActions[ nActionPos-1 ].aMarks.push_back( + m_xData->pUndoArray->maUndoActions[ nActionPos-1 ].aMarks.push_back( ++m_xData->mnMarks ); return m_xData->mnMarks; } @@ -1177,9 +1116,9 @@ void SfxUndoManager::RemoveMark( UndoStackMark const i_mark ) return; } - for ( size_t i=0; i<m_xData->pUndoArray->aUndoActions.size(); ++i ) + for ( size_t i=0; i<m_xData->pUndoArray->maUndoActions.size(); ++i ) { - MarkedUndoAction& rAction = m_xData->pUndoArray->aUndoActions[i]; + MarkedUndoAction& rAction = m_xData->pUndoArray->maUndoActions[i]; for ( ::std::vector< UndoStackMark >::iterator markPos = rAction.aMarks.begin(); markPos != rAction.aMarks.end(); ++markPos @@ -1209,7 +1148,7 @@ bool SfxUndoManager::HasTopUndoActionMark( UndoStackMark const i_mark ) } const MarkedUndoAction& rAction = - m_xData->pUndoArray->aUndoActions[ nActionPos-1 ]; + m_xData->pUndoArray->maUndoActions[ nActionPos-1 ]; for ( ::std::vector< UndoStackMark >::const_iterator markPos = rAction.aMarks.begin(); markPos != rAction.aMarks.end(); ++markPos @@ -1227,7 +1166,7 @@ void SfxUndoManager::RemoveOldestUndoAction() { UndoManagerGuard aGuard( *m_xData ); - SfxUndoAction* pActionToRemove = m_xData->pUndoArray->aUndoActions[0].pAction; + SfxUndoAction* pActionToRemove = m_xData->pUndoArray->maUndoActions[0].pAction; if ( IsInListAction() && ( m_xData->pUndoArray->nCurUndoAction == 1 ) ) { @@ -1236,7 +1175,7 @@ void SfxUndoManager::RemoveOldestUndoAction() } aGuard.markForDeletion( pActionToRemove ); - m_xData->pUndoArray->aUndoActions.Remove( 0 ); + m_xData->pUndoArray->Remove( 0 ); --m_xData->pUndoArray->nCurUndoAction; ImplCheckEmptyActions(); } @@ -1263,7 +1202,7 @@ void SfxUndoManager::dumpAsXml(xmlTextWriterPtr pWriter) const for (size_t i = 0; i < GetUndoActionCount(); ++i) { const SfxUndoArray* pUndoArray = m_xData->pActUndoArray; - pUndoArray->aUndoActions[pUndoArray->nCurUndoAction - 1 - i].pAction->dumpAsXml(pWriter); + pUndoArray->maUndoActions[pUndoArray->nCurUndoAction - 1 - i].pAction->dumpAsXml(pWriter); } xmlTextWriterEndElement(pWriter); @@ -1271,7 +1210,7 @@ void SfxUndoManager::dumpAsXml(xmlTextWriterPtr pWriter) const for (size_t i = 0; i < GetRedoActionCount(); ++i) { const SfxUndoArray* pUndoArray = m_xData->pActUndoArray; - pUndoArray->aUndoActions[pUndoArray->nCurUndoAction + i].pAction->dumpAsXml(pWriter); + pUndoArray->maUndoActions[pUndoArray->nCurUndoAction + i].pAction->dumpAsXml(pWriter); } xmlTextWriterEndElement(pWriter); @@ -1300,7 +1239,7 @@ OUString SfxUndoManager::GetUndoActionsInfo() const const SfxUndoArray* pUndoArray = m_xData->pActUndoArray; for (size_t i = 0; i < GetUndoActionCount(); ++i) { - boost::property_tree::ptree aAction = lcl_ActionToJson(i, pUndoArray->aUndoActions[pUndoArray->nCurUndoAction - 1 - i].pAction); + boost::property_tree::ptree aAction = lcl_ActionToJson(i, pUndoArray->maUndoActions[pUndoArray->nCurUndoAction - 1 - i].pAction); aActions.push_back(std::make_pair("", aAction)); } @@ -1319,7 +1258,7 @@ OUString SfxUndoManager::GetRedoActionsInfo() const for (size_t i = 0; i < nCount; ++i) { size_t nIndex = nCount - i - 1; - boost::property_tree::ptree aAction = lcl_ActionToJson(nIndex, pUndoArray->aUndoActions[pUndoArray->nCurUndoAction + nIndex].pAction); + boost::property_tree::ptree aAction = lcl_ActionToJson(nIndex, pUndoArray->maUndoActions[pUndoArray->nCurUndoAction + nIndex].pAction); aActions.push_back(std::make_pair("", aAction)); } @@ -1339,7 +1278,7 @@ bool SfxUndoManager::IsEmptyActions() const inline bool SfxUndoManager::ImplIsEmptyActions() const { - return m_xData->pUndoArray->nCurUndoAction || m_xData->pUndoArray->aUndoActions.size() - m_xData->pUndoArray->nCurUndoAction; + return m_xData->pUndoArray->nCurUndoAction || m_xData->pUndoArray->maUndoActions.size() - m_xData->pUndoArray->nCurUndoAction; } void SfxUndoManager::ImplCheckEmptyActions() @@ -1413,7 +1352,7 @@ SfxListUndoAction::~SfxListUndoAction() void SfxListUndoAction::Undo() { for(size_t i=nCurUndoAction;i>0;) - aUndoActions[--i].pAction->Undo(); + maUndoActions[--i].pAction->Undo(); nCurUndoAction=0; } @@ -1421,31 +1360,31 @@ void SfxListUndoAction::Undo() void SfxListUndoAction::UndoWithContext( SfxUndoContext& i_context ) { for(size_t i=nCurUndoAction;i>0;) - aUndoActions[--i].pAction->UndoWithContext( i_context ); + maUndoActions[--i].pAction->UndoWithContext( i_context ); nCurUndoAction=0; } void SfxListUndoAction::Redo() { - for(size_t i=nCurUndoAction;i<aUndoActions.size();i++) - aUndoActions[i].pAction->Redo(); - nCurUndoAction = aUndoActions.size(); + for(size_t i=nCurUndoAction;i<maUndoActions.size();i++) + maUndoActions[i].pAction->Redo(); + nCurUndoAction = maUndoActions.size(); } void SfxListUndoAction::RedoWithContext( SfxUndoContext& i_context ) { - for(size_t i=nCurUndoAction;i<aUndoActions.size();i++) - aUndoActions[i].pAction->RedoWithContext( i_context ); - nCurUndoAction = aUndoActions.size(); + for(size_t i=nCurUndoAction;i<maUndoActions.size();i++) + maUndoActions[i].pAction->RedoWithContext( i_context ); + nCurUndoAction = maUndoActions.size(); } void SfxListUndoAction::Repeat(SfxRepeatTarget&rTarget) { for(size_t i=0;i<nCurUndoAction;i++) - aUndoActions[i].pAction->Repeat(rTarget); + maUndoActions[i].pAction->Repeat(rTarget); } @@ -1453,7 +1392,7 @@ bool SfxListUndoAction::CanRepeat(SfxRepeatTarget&r) const { for(size_t i=0;i<nCurUndoAction;i++) { - if(!aUndoActions[i].pAction->CanRepeat(r)) + if(!maUndoActions[i].pAction->CanRepeat(r)) return false; } return true; @@ -1462,28 +1401,28 @@ bool SfxListUndoAction::CanRepeat(SfxRepeatTarget&r) const bool SfxListUndoAction::Merge( SfxUndoAction *pNextAction ) { - return !aUndoActions.empty() && aUndoActions[aUndoActions.size()-1].pAction->Merge( pNextAction ); + return !maUndoActions.empty() && maUndoActions[maUndoActions.size()-1].pAction->Merge( pNextAction ); } void SfxListUndoAction::dumpAsXml(xmlTextWriterPtr pWriter) const { xmlTextWriterStartElement(pWriter, BAD_CAST("SfxListUndoAction")); - xmlTextWriterWriteAttribute(pWriter, BAD_CAST("size"), BAD_CAST(OString::number(aUndoActions.size()).getStr())); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("size"), BAD_CAST(OString::number(maUndoActions.size()).getStr())); SfxUndoAction::dumpAsXml(pWriter); - for (size_t i = 0; i < aUndoActions.size(); ++i) - aUndoActions.GetUndoAction(i)->dumpAsXml(pWriter); + for (size_t i = 0; i < maUndoActions.size(); ++i) + maUndoActions[i].pAction->dumpAsXml(pWriter); xmlTextWriterEndElement(pWriter); } SfxUndoArray::~SfxUndoArray() { - while ( !aUndoActions.empty() ) + while ( !maUndoActions.empty() ) { - SfxUndoAction *pAction = aUndoActions[ aUndoActions.size() - 1 ].pAction; - aUndoActions.Remove( aUndoActions.size() - 1 ); + SfxUndoAction *pAction = maUndoActions.back().pAction; delete pAction; + maUndoActions.pop_back(); } } |