summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2017-06-17 13:52:15 -0400
committerJan Holesovsky <kendy@collabora.com>2018-01-18 13:34:53 +0100
commite3c1713807499fdbe63fad0944d0ce3b91b28637 (patch)
tree011c8706d89611714b8583c8acc7221cc26f17a1 /svl
parentba5556e62ed3fda9f02aaf7d3ba23c19af7dbdfc (diff)
lokit: add .uno:DocumentRepair command
Change-Id: I5b13ea6f4785bc91c29111fa63c4a1b0ea9b2660 Reviewed-on: https://gerrit.libreoffice.org/38908 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Henry Castro <hcastro@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/47915 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/undo/undo.cxx39
1 files changed, 39 insertions, 0 deletions
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 770c0821cd82..dfdcd7b3aa8b 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -233,6 +233,7 @@ struct SfxUndoManager_Data
bool mbUndoEnabled;
bool mbDoing;
bool mbClearUntilTopLevel;
+ bool mbEmptyActions;
UndoListeners aListeners;
@@ -245,6 +246,7 @@ struct SfxUndoManager_Data
,mbUndoEnabled( true )
,mbDoing( false )
,mbClearUntilTopLevel( false )
+ ,mbEmptyActions( true )
{
pActUndoArray = pUndoArray;
}
@@ -417,6 +419,7 @@ using namespace ::svl::undo::impl;
SfxUndoManager::SfxUndoManager( size_t nMaxUndoActionCount )
:m_xData( new SfxUndoManager_Data( nMaxUndoActionCount ) )
{
+ m_xData->mbEmptyActions = !ImplIsEmptyActions();
}
@@ -497,6 +500,7 @@ void SfxUndoManager::SetMaxUndoActionCount( size_t nMaxUndoActionCount )
}
m_xData->pActUndoArray->nMaxUndoActions = nMaxUndoActionCount;
+ ImplCheckEmptyActions();
}
@@ -515,6 +519,7 @@ void SfxUndoManager::ImplClearCurrentLevel_NoNotify( UndoManagerGuard& i_guard )
m_xData->mnMarks = 0;
m_xData->mnEmptyMark = MARK_INVALID;
+ ImplCheckEmptyActions();
}
@@ -595,6 +600,7 @@ void SfxUndoManager::ImplClearUndo( UndoManagerGuard& i_guard )
i_guard.markForDeletion( pUndoAction );
--m_xData->pActUndoArray->nCurUndoAction;
}
+ ImplCheckEmptyActions();
// TODO: notifications? We don't have clearedUndo, only cleared and clearedRedo at the SfxUndoListener
}
@@ -612,6 +618,7 @@ void SfxUndoManager::ImplClearRedo( UndoManagerGuard& i_guard, bool const i_curr
i_guard.markForDeletion( pAction );
}
+ ImplCheckEmptyActions();
// notification - only if the top level's stack was cleared
if ( i_currentLevel == IUndoManager::TopLevel )
i_guard.scheduleNotification( &SfxUndoListener::clearedRedo );
@@ -665,6 +672,7 @@ bool SfxUndoManager::ImplAddUndoAction_NoNotify( SfxUndoAction *pAction, bool bT
// append new action
m_xData->pActUndoArray->aUndoActions.Insert( pAction, m_xData->pActUndoArray->nCurUndoAction++ );
+ ImplCheckEmptyActions();
return true;
}
@@ -743,6 +751,7 @@ void SfxUndoManager::RemoveLastUndoAction()
m_xData->pActUndoArray->aUndoActions.Remove(
m_xData->pActUndoArray->nCurUndoAction,
m_xData->pActUndoArray->aUndoActions.size() - m_xData->pActUndoArray->nCurUndoAction );
+ ImplCheckEmptyActions();
}
@@ -932,6 +941,7 @@ bool SfxUndoManager::ImplRedo( SfxUndoContext* i_contextOrNull )
throw;
}
+ ImplCheckEmptyActions();
aGuard.scheduleNotification( &SfxUndoListener::actionRedone, sActionComment );
return true;
@@ -1157,6 +1167,7 @@ size_t SfxUndoManager::ImplLeaveListAction( const bool i_merge, UndoManagerGuard
}
}
+ ImplIsEmptyActions();
// notify listeners
i_guard.scheduleNotification( &SfxUndoListener::listActionLeft, pListAction->GetComment() );
@@ -1260,6 +1271,7 @@ void SfxUndoManager::RemoveOldestUndoAction()
aGuard.markForDeletion( pActionToRemove );
m_xData->pUndoArray->aUndoActions.Remove( 0 );
--m_xData->pUndoArray->nCurUndoAction;
+ ImplCheckEmptyActions();
}
void SfxUndoManager::dumpAsXml(xmlTextWriterPtr pWriter) const
@@ -1351,6 +1363,33 @@ OUString SfxUndoManager::GetRedoActionsInfo() const
return OUString::fromUtf8(aStream.str().c_str());
}
+bool SfxUndoManager::IsEmptyActions() const
+{
+ UndoManagerGuard aGuard(*m_xData);
+
+ return ImplIsEmptyActions();
+}
+
+inline bool SfxUndoManager::ImplIsEmptyActions() const
+{
+ return m_xData->pUndoArray->nCurUndoAction || m_xData->pUndoArray->aUndoActions.size() - m_xData->pUndoArray->nCurUndoAction;
+}
+
+void SfxUndoManager::ImplCheckEmptyActions()
+{
+ bool bEmptyActions = ImplIsEmptyActions();
+ if (m_xData->mbEmptyActions != bEmptyActions)
+ {
+ m_xData->mbEmptyActions = bEmptyActions;
+ EmptyActionsChanged();
+ }
+}
+
+void SfxUndoManager::EmptyActionsChanged()
+{
+
+}
+
struct SfxListUndoAction::Impl
{
sal_uInt16 mnId;