Kaydet (Commit) 3e9e667a authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

loplugin:unusedmethods SfxLinkUndoAction

Change-Id: I1ad7c2452dd9bc80e7404f41484b9667adbcfa7b
Reviewed-on: https://gerrit.libreoffice.org/25542Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 12868914
......@@ -41,19 +41,12 @@ public:
};
class SfxLinkUndoAction;
class SVL_DLLPUBLIC SfxUndoAction
{
private:
SfxLinkUndoAction* mpSfxLinkUndoAction;
public:
SfxUndoAction();
virtual ~SfxUndoAction();
virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction);
virtual void Undo();
virtual void UndoWithContext( SfxUndoContext& i_context );
virtual void Redo();
......@@ -299,8 +292,6 @@ namespace svl { namespace undo { namespace impl
struct SfxUndoManager_Data;
class SVL_DLLPUBLIC SfxUndoManager : public ::svl::IUndoManager
{
friend class SfxLinkUndoAction;
std::unique_ptr< SfxUndoManager_Data >
m_xData;
public:
......@@ -392,48 +383,6 @@ private:
friend class ::svl::undo::impl::LockGuard;
};
class SVL_DLLPUBLIC SfxLinkUndoAction : public SfxUndoAction
/* [Explanation]
SfxLinkUndoAction is used to link two SfxUndoManager. The Undo/Redos inserted
in the first SfxUndoManager redirect their Undo/Redo to the second. With this it
does not matter, if the undo/redo initially was on the first or the second.
After inserting SfxLinkUndoAction on the first SfxUndoManager, you have to
insert it on the second as well. While the second SfxUndoManager is steered
from the first, you must not insert neither Actions nor issue a undo/redo
command to the second, while it is steered by the first.
*/
{
private:
friend class SfxUndoAction;
void LinkedSfxUndoActionDestructed(const SfxUndoAction& rCandidate);
public:
SfxLinkUndoAction(::svl::IUndoManager *pManager);
virtual ~SfxLinkUndoAction();
virtual void Undo() override;
virtual void Redo() override;
virtual bool CanRepeat(SfxRepeatTarget& r) const override;
virtual void Repeat(SfxRepeatTarget&r) override;
virtual OUString GetComment() const override;
virtual OUString GetRepeatComment(SfxRepeatTarget&r) const override;
virtual sal_uInt16 GetId() const override;
SfxUndoAction* GetAction() const { return pAction; }
protected:
::svl::IUndoManager* pUndoManager;
SfxUndoAction* pAction;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -172,8 +172,6 @@ public:
SfxUndoAction* GetWrappedUndo() { return pWrappedUndo; }
void ForgetWrappedUndo();
virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction) override;
virtual void Undo() override;
virtual void Redo() override;
virtual void Repeat(SfxRepeatTarget& rTarget) override;
......
......@@ -38,8 +38,6 @@ public:
SfxUndoAction* GetDrawUndo() { return pDrawUndo; }
void ForgetDrawUndo();
virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction) override;
virtual void Undo() override;
virtual void Redo() override;
virtual void Repeat(SfxRepeatTarget& rTarget) override;
......
......@@ -598,14 +598,6 @@ sal_uInt16 ScUndoWrapper::GetId() const
return 0;
}
void ScUndoWrapper::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
{
if (pWrappedUndo)
pWrappedUndo->SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
else
SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
}
bool ScUndoWrapper::Merge( SfxUndoAction* pNextAction )
{
if (pWrappedUndo)
......
......@@ -62,14 +62,6 @@ sal_uInt16 ScUndoDraw::GetId() const
return 0;
}
void ScUndoDraw::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
{
if (pDrawUndo)
pDrawUndo->SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
else
SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
}
bool ScUndoDraw::Merge( SfxUndoAction* pNextAction )
{
if (pDrawUndo)
......
......@@ -1568,47 +1568,6 @@ void OutlineView::TryToMergeUndoActions()
pListAction->aUndoActions.Remove(nEditPos);
delete pEditUndo;
// now check if we also can merge the draw undo actions
::svl::IUndoManager* pDocUndoManager = mpDocSh->GetUndoManager();
if( pDocUndoManager && ( pListAction->aUndoActions.size() == 1 ))
{
SfxLinkUndoAction* pLinkAction = dynamic_cast< SfxLinkUndoAction* >( pListAction->aUndoActions.GetUndoAction(0) );
SfxLinkUndoAction* pPrevLinkAction = nullptr;
if( pLinkAction )
{
nAction = pPrevListAction->aUndoActions.size();
while( !pPrevLinkAction && nAction )
pPrevLinkAction = dynamic_cast< SfxLinkUndoAction* >(pPrevListAction->aUndoActions.GetUndoAction(--nAction));
}
if( pLinkAction && pPrevLinkAction &&
( pLinkAction->GetAction() == pDocUndoManager->GetUndoAction() ) &&
( pPrevLinkAction->GetAction() == pDocUndoManager->GetUndoAction(1) ) )
{
SfxListUndoAction* pSourceList = dynamic_cast< SfxListUndoAction* >(pLinkAction->GetAction());
SfxListUndoAction* pDestinationList = dynamic_cast< SfxListUndoAction* >(pPrevLinkAction->GetAction());
if( pSourceList && pDestinationList )
{
sal_uInt16 nCount = pSourceList->aUndoActions.size();
sal_uInt16 nDestAction = pDestinationList->aUndoActions.size();
while( nCount-- )
{
SfxUndoAction* pTemp = pSourceList->aUndoActions.GetUndoAction(0);
pSourceList->aUndoActions.Remove(0);
pDestinationList->aUndoActions.Insert( pTemp, nDestAction++ );
}
pDestinationList->nCurUndoAction = pDestinationList->aUndoActions.size();
pListAction->aUndoActions.Remove(0);
delete pLinkAction;
pDocUndoManager->RemoveLastUndoAction();
}
}
}
if ( !pListAction->aUndoActions.empty() )
{
// now we have to move all remaining doc undo actions from the top undo
......
......@@ -45,24 +45,12 @@ SfxUndoContext::~SfxUndoContext()
}
void SfxUndoAction::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
{
mpSfxLinkUndoAction = pSfxLinkUndoAction;
}
SfxUndoAction::~SfxUndoAction()
{
if(mpSfxLinkUndoAction)
{
mpSfxLinkUndoAction->LinkedSfxUndoActionDestructed(*this);
mpSfxLinkUndoAction = nullptr;
}
}
SfxUndoAction::SfxUndoAction()
: mpSfxLinkUndoAction(nullptr)
{
}
......@@ -1396,90 +1384,6 @@ void SfxListUndoAction::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterEndElement(pWriter);
}
/**
* Creates a LinkAction which points to another UndoManager.
* Gets that UndoManagers current Action and sets it as that UndoManager's
* associated Action.
*/
SfxLinkUndoAction::SfxLinkUndoAction(::svl::IUndoManager *pManager)
{
pUndoManager = pManager;
SfxUndoManager* pUndoManagerImplementation = dynamic_cast< SfxUndoManager* >( pManager );
ENSURE_OR_THROW( pUndoManagerImplementation != nullptr, "unsupported undo manager implementation!" );
// yes, this cast is dirty. But reaching into the SfxUndoManager's implementation,
// directly accessing its internal stack, and tampering with an action on that stack
// is dirty, too.
if ( pManager->GetMaxUndoActionCount() )
{
size_t nPos = pManager->GetUndoActionCount()-1;
pAction = pUndoManagerImplementation->m_xData->pActUndoArray->aUndoActions[nPos].pAction;
pAction->SetLinkToSfxLinkUndoAction(this);
}
else
pAction = nullptr;
}
void SfxLinkUndoAction::Undo()
{
if ( pAction )
pUndoManager->Undo();
}
void SfxLinkUndoAction::Redo()
{
if ( pAction )
pUndoManager->Redo();
}
bool SfxLinkUndoAction::CanRepeat(SfxRepeatTarget& r) const
{
return pAction && pAction->CanRepeat(r);
}
void SfxLinkUndoAction::Repeat(SfxRepeatTarget&r)
{
if ( pAction && pAction->CanRepeat( r ) )
pAction->Repeat( r );
}
OUString SfxLinkUndoAction::GetComment() const
{
if ( pAction )
return pAction->GetComment();
return OUString();
}
OUString SfxLinkUndoAction::GetRepeatComment(SfxRepeatTarget&r) const
{
if ( pAction )
return pAction->GetRepeatComment(r);
return OUString();
}
SfxLinkUndoAction::~SfxLinkUndoAction()
{
if( pAction )
pAction->SetLinkToSfxLinkUndoAction(nullptr);
}
void SfxLinkUndoAction::LinkedSfxUndoActionDestructed(const SfxUndoAction& rCandidate)
{
assert(nullptr != pAction);
assert(pAction == &rCandidate && "Oops, the destroyed and linked UndoActions differ (!)");
(void)rCandidate;
pAction = nullptr;
}
SfxUndoArray::~SfxUndoArray()
{
while ( !aUndoActions.empty() )
......@@ -1490,10 +1394,4 @@ SfxUndoArray::~SfxUndoArray()
}
}
sal_uInt16 SfxLinkUndoAction::GetId() const
{
return pAction ? pAction->GetId() : 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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