LOK: added .uno:UndoCount and .uno:RedoCount
Added new commands for doc_getCommandValues to get actual undo and redo count. They get undo/redo count directly from SfxUndoManager. Change-Id: I2f7b7fc487eada7c5b1b161dfd4086c54094d747 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180553 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
parent
d23c5560c1
commit
a02cbda34e
@ -6655,6 +6655,34 @@ static char* getUndoOrRedo(LibreOfficeKitDocument* pThis, UndoOrRedo eCommand)
|
||||
return pJson;
|
||||
}
|
||||
|
||||
/// Returns only the number of the undo or redo elements
|
||||
static char* getUndoOrRedoCount(LibreOfficeKitDocument* pThis, UndoOrRedo eCommand)
|
||||
{
|
||||
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
||||
|
||||
auto pBaseModel = dynamic_cast<SfxBaseModel*>(pDocument->mxComponent.get());
|
||||
if (!pBaseModel)
|
||||
return nullptr;
|
||||
|
||||
SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
|
||||
if (!pObjectShell)
|
||||
return nullptr;
|
||||
|
||||
SfxUndoManager* pUndoManager = pObjectShell->GetUndoManager();
|
||||
if (!pUndoManager)
|
||||
return nullptr;
|
||||
|
||||
size_t nCount;
|
||||
if (eCommand == UndoOrRedo::UNDO)
|
||||
nCount = pUndoManager->GetUndoActionCount();
|
||||
else
|
||||
nCount = pUndoManager->GetRedoActionCount();
|
||||
|
||||
OUString aString = OUString::number(nCount);
|
||||
char* pCountStr = convertOUString(aString);
|
||||
return pCountStr;
|
||||
}
|
||||
|
||||
/// Returns the JSON representation of the redline stack.
|
||||
static char* getTrackedChanges(LibreOfficeKitDocument* pThis)
|
||||
{
|
||||
@ -6769,6 +6797,14 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
|
||||
{
|
||||
return getUndoOrRedo(pThis, UndoOrRedo::REDO);
|
||||
}
|
||||
else if (aCommand == ".uno:UndoCount")
|
||||
{
|
||||
return getUndoOrRedoCount(pThis, UndoOrRedo::UNDO);
|
||||
}
|
||||
else if (aCommand == ".uno:RedoCount")
|
||||
{
|
||||
return getUndoOrRedoCount(pThis, UndoOrRedo::REDO);
|
||||
}
|
||||
else if (aCommand == ".uno:AcceptTrackedChanges")
|
||||
{
|
||||
return getTrackedChanges(pThis);
|
||||
|
Loading…
x
Reference in New Issue
Block a user