include/svl/undo.hxx | 78 ++++++++---------------- include/svx/svddrag.hxx | 2 sd/source/ui/inc/sdundogr.hxx | 2 sd/source/ui/view/outlview.cxx | 14 ++-- svl/source/undo/undo.cxx | 113 +++++++++++++++++++++++++++++++----- sw/source/core/docnode/nodedump.cxx | 2 6 files changed, 136 insertions(+), 75 deletions(-)
New commits: commit 9dd8413a61301305d1bafacc5d3511cf3c3129e2 Author: Kohei Yoshida <[email protected]> Date: Sun Dec 7 01:07:02 2014 -0500 Forward-declare MarkedUndoAction. Change-Id: I1c36077cada47bacfb8436cf3fb659e47d02da60 diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx index d63a69b..24fcbbc 100644 --- a/include/svl/undo.hxx +++ b/include/svl/undo.hxx @@ -25,10 +25,9 @@ #include <boost/scoped_ptr.hpp> -#include <vector> #include <limits> - +struct MarkedUndoAction; class SVL_DLLPUBLIC SfxRepeatTarget { @@ -84,21 +83,7 @@ private: typedef sal_Int32 UndoStackMark; #define MARK_INVALID ::std::numeric_limits< UndoStackMark >::max() - - -struct MarkedUndoAction -{ - SfxUndoAction* pAction; - ::std::vector< UndoStackMark > aMarks; - - MarkedUndoAction( SfxUndoAction* i_action ) - :pAction( i_action ) - ,aMarks() - { - } -}; - -class SfxUndoActions +class SVL_DLLPUBLIC SfxUndoActions { struct Impl; Impl* mpImpl; @@ -114,6 +99,9 @@ public: const MarkedUndoAction& operator[]( size_t i ) const; MarkedUndoAction& operator[]( size_t i ); + const SfxUndoAction* GetUndoAction( size_t i ) const; + SfxUndoAction* GetUndoAction( size_t i ); + 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 ); diff --git a/include/svx/svddrag.hxx b/include/svx/svddrag.hxx index fd43db2..b622999d 100644 --- a/include/svx/svddrag.hxx +++ b/include/svx/svddrag.hxx @@ -25,6 +25,8 @@ #include <tools/fract.hxx> #include <svx/svxdllapi.h> +#include <vector> + // Status information for specialized object dragging. In order for the model // to stay status free, the status data is kept on the View // and handed over to the object at the appropriate time as a parameter. diff --git a/sd/source/ui/inc/sdundogr.hxx b/sd/source/ui/inc/sdundogr.hxx index efb4a2a..47ae469 100644 --- a/sd/source/ui/inc/sdundogr.hxx +++ b/sd/source/ui/inc/sdundogr.hxx @@ -24,6 +24,8 @@ #include "sdundo.hxx" #include "sddllapi.h" +#include <vector> + class SD_DLLPUBLIC SdUndoGroup : public SdUndoAction { std::vector<SdUndoAction*> aCtn; diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index c901efb..fa50067 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -1590,7 +1590,7 @@ void OutlineView::TryToMergeUndoActions() EditUndo* pEditUndo = 0; while( !pEditUndo && nAction ) { - pEditUndo = dynamic_cast< EditUndo* >(pListAction->aUndoActions[--nAction].pAction); + pEditUndo = dynamic_cast< EditUndo* >(pListAction->aUndoActions.GetUndoAction(--nAction)); } sal_uInt16 nEditPos = nAction; // we need this later to remove the merged undo actions @@ -1598,7 +1598,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[--nAction].pAction) ) + if( dynamic_cast< EditUndo* >(pListAction->aUndoActions.GetUndoAction(--nAction)) ) pEditUndo = 0; } @@ -1610,7 +1610,7 @@ void OutlineView::TryToMergeUndoActions() nAction = pPrevListAction->aUndoActions.size(); EditUndo* pPrevEditUndo = 0; while( !pPrevEditUndo && nAction ) - pPrevEditUndo = dynamic_cast< EditUndo* >(pPrevListAction->aUndoActions[--nAction].pAction); + pPrevEditUndo = dynamic_cast< EditUndo* >(pPrevListAction->aUndoActions.GetUndoAction(--nAction)); if( pPrevEditUndo && pPrevEditUndo->Merge( pEditUndo ) ) { @@ -1627,14 +1627,14 @@ void OutlineView::TryToMergeUndoActions() ::svl::IUndoManager* pDocUndoManager = mpDocSh->GetUndoManager(); if( pDocUndoManager && ( pListAction->aUndoActions.size() == 1 )) { - SfxLinkUndoAction* pLinkAction = dynamic_cast< SfxLinkUndoAction* >( pListAction->aUndoActions[0].pAction ); + SfxLinkUndoAction* pLinkAction = dynamic_cast< SfxLinkUndoAction* >( pListAction->aUndoActions.GetUndoAction(0) ); SfxLinkUndoAction* pPrevLinkAction = 0; if( pLinkAction ) { nAction = pPrevListAction->aUndoActions.size(); while( !pPrevLinkAction && nAction ) - pPrevLinkAction = dynamic_cast< SfxLinkUndoAction* >(pPrevListAction->aUndoActions[--nAction].pAction); + pPrevLinkAction = dynamic_cast< SfxLinkUndoAction* >(pPrevListAction->aUndoActions.GetUndoAction(--nAction)); } if( pLinkAction && pPrevLinkAction && @@ -1650,7 +1650,7 @@ void OutlineView::TryToMergeUndoActions() sal_uInt16 nDestAction = pDestinationList->aUndoActions.size(); while( nCount-- ) { - SfxUndoAction* pTemp = pSourceList->aUndoActions[0].pAction; + SfxUndoAction* pTemp = pSourceList->aUndoActions.GetUndoAction(0); pSourceList->aUndoActions.Remove(0); pDestinationList->aUndoActions.Insert( pTemp, nDestAction++ ); } @@ -1673,7 +1673,7 @@ void OutlineView::TryToMergeUndoActions() size_t nDestAction = pPrevListAction->aUndoActions.size(); while( nCount-- ) { - SfxUndoAction* pTemp = pListAction->aUndoActions[0].pAction; + SfxUndoAction* pTemp = pListAction->aUndoActions.GetUndoAction(0); pListAction->aUndoActions.Remove(0); if( pTemp ) pPrevListAction->aUndoActions.Insert( pTemp, nDestAction++ ); diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index 011bd17..772dd43 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -135,6 +135,18 @@ bool SfxUndoAction::CanRepeat(SfxRepeatTarget&) const return true; } +struct MarkedUndoAction +{ + SfxUndoAction* pAction; + ::std::vector< UndoStackMark > aMarks; + + MarkedUndoAction( SfxUndoAction* i_action ) + :pAction( i_action ) + ,aMarks() + { + } +}; + struct SfxUndoActions::Impl { std::vector<MarkedUndoAction> maActions; @@ -173,6 +185,16 @@ 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 ); diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx index 6007a3f..f0be0e2 100644 --- a/sw/source/core/docnode/nodedump.cxx +++ b/sw/source/core/docnode/nodedump.cxx @@ -1024,7 +1024,7 @@ void lcl_dumpSfxUndoAction(WriterHelper& writer, SfxUndoAction* pAction) writer.startElement("list"); writer.writeFormatAttribute("size", TMP_FORMAT, pList->aUndoActions.size()); for (size_t i = 0; i < pList->aUndoActions.size(); ++i) - lcl_dumpSfxUndoAction(writer, pList->aUndoActions[i].pAction); + lcl_dumpSfxUndoAction(writer, pList->aUndoActions.GetUndoAction(i)); writer.endElement(); } commit f28ee9e4004ebf51332a998638aea779e07f6450 Author: Kohei Yoshida <[email protected]> Date: Sat Dec 6 16:36:16 2014 -0500 Pimplize SfxListUndoAction. Change-Id: Ic82755788df237c455c802a039881a9d056f4df2 diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx index 5aed21a..d63a69b 100644 --- a/include/svl/undo.hxx +++ b/include/svl/undo.hxx @@ -74,7 +74,8 @@ public: virtual sal_uInt16 GetId() const; private: - SfxUndoAction& operator=( const SfxUndoAction& ); // n.i.!! + SfxUndoAction( const SfxUndoAction& ); // disabled + SfxUndoAction& operator=( const SfxUndoAction& ); // disabled }; @@ -146,11 +147,16 @@ class SVL_DLLPUBLIC SfxListUndoAction : public SfxUndoAction, public SfxUndoArra Redo and Undo work element wise on SfxListUndoActions. */ { - public: + struct Impl; + Impl* mpImpl; + +public: TYPEINFO_OVERRIDE(); - SfxListUndoAction( const OUString &rComment, - const OUString& rRepeatComment, sal_uInt16 Id, SfxUndoArray *pFather); + SfxListUndoAction( + const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId, SfxUndoArray *pFather ); + ~SfxListUndoAction(); + virtual void Undo() SAL_OVERRIDE; virtual void UndoWithContext( SfxUndoContext& i_context ) SAL_OVERRIDE; virtual void Redo() SAL_OVERRIDE; @@ -165,13 +171,6 @@ class SVL_DLLPUBLIC SfxListUndoAction : public SfxUndoAction, public SfxUndoArra virtual sal_uInt16 GetId() const SAL_OVERRIDE; void SetComment(const OUString& rComment); - - private: - - sal_uInt16 nId; - OUString aComment; - OUString aRepeatComment; - }; diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index 514e842..011bd17 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -1248,45 +1248,52 @@ void SfxUndoManager::RemoveOldestUndoActions( size_t const i_count ) } } +struct SfxListUndoAction::Impl +{ + sal_uInt16 mnId; + + OUString maComment; + OUString maRepeatComment; + + Impl( sal_uInt16 nId, const OUString& rComment, const OUString& rRepeatComment ) : + mnId(nId), maComment(rComment), maRepeatComment(rRepeatComment) {} +}; sal_uInt16 SfxListUndoAction::GetId() const { - return nId; + return mpImpl->mnId; } - OUString SfxListUndoAction::GetComment() const { - return aComment; + return mpImpl->maComment; } - void SfxListUndoAction::SetComment(const OUString& rComment) { - aComment = rComment; + mpImpl->maComment = rComment; } - OUString SfxListUndoAction::GetRepeatComment(SfxRepeatTarget &) const { - return aRepeatComment; + return mpImpl->maRepeatComment; } - - -SfxListUndoAction::SfxListUndoAction -( +SfxListUndoAction::SfxListUndoAction( const OUString &rComment, const OUString &rRepeatComment, - sal_uInt16 Id, - SfxUndoArray *pFather -) -: nId(Id), aComment(rComment), aRepeatComment(rRepeatComment) + sal_uInt16 nId, + SfxUndoArray *pFather ) : + mpImpl(new Impl(nId, rComment, rRepeatComment)) { pFatherUndoArray = pFather; nMaxUndoActions = USHRT_MAX; } +SfxListUndoAction::~SfxListUndoAction() +{ + delete mpImpl; +} void SfxListUndoAction::Undo() { commit 1b6e9f9dfc538841a873774428628124cbdc4fd8 Author: Kohei Yoshida <[email protected]> Date: Sat Dec 6 16:26:01 2014 -0500 Pimplize SfxUndoActions. Change-Id: I35ef457111f4cf8b811a4ee8bb676421746e1d9d diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx index f18ae84..5aed21a 100644 --- a/include/svl/undo.hxx +++ b/include/svl/undo.hxx @@ -99,38 +99,25 @@ struct MarkedUndoAction class SfxUndoActions { -private: - ::std::vector< MarkedUndoAction > m_aActions; + struct Impl; + Impl* mpImpl; public: - SfxUndoActions() - { - } + SfxUndoActions(); + SfxUndoActions( const SfxUndoActions& r ); + ~SfxUndoActions(); - bool empty() const { return m_aActions.empty(); } - size_t size() const { return m_aActions.size(); } + bool empty() const; + size_t size() const; - const MarkedUndoAction& operator[]( size_t i ) const { return m_aActions[i]; } - MarkedUndoAction& operator[]( size_t i ) { return m_aActions[i]; } + const MarkedUndoAction& operator[]( size_t i ) const; + MarkedUndoAction& operator[]( size_t i ); - void Remove( size_t i_pos ) - { - m_aActions.erase( m_aActions.begin() + i_pos ); - } - - void Remove( size_t i_pos, size_t i_count ) - { - m_aActions.erase( m_aActions.begin() + i_pos, m_aActions.begin() + i_pos + i_count ); - } - - void Insert( SfxUndoAction* i_action, size_t i_pos ) - { - m_aActions.insert( m_aActions.begin() + i_pos, MarkedUndoAction( i_action ) ); - } + 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 ); }; - - /** do not make use of these implementation details, unless you really really have to! */ struct SVL_DLLPUBLIC SfxUndoArray diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index f3f855c..514e842 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -135,6 +135,60 @@ bool SfxUndoAction::CanRepeat(SfxRepeatTarget&) const return true; } +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() +{ + delete mpImpl; +} + +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]; +} + +void SfxUndoActions::Remove( size_t i_pos ) +{ + mpImpl->maActions.erase( mpImpl->maActions.begin() + i_pos ); +} + +void SfxUndoActions::Remove( size_t i_pos, size_t i_count ) +{ + mpImpl->maActions.erase( + mpImpl->maActions.begin() + i_pos, mpImpl->maActions.begin() + i_pos + i_count); +} + +void SfxUndoActions::Insert( SfxUndoAction* i_action, size_t i_pos ) +{ + mpImpl->maActions.insert( + mpImpl->maActions.begin() + i_pos, MarkedUndoAction( i_action ) ); +} typedef ::std::vector< SfxUndoListener* > UndoListeners; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
