sd/source/ui/annotations/annotationmanager.cxx |   10 ++++++++++
 1 file changed, 10 insertions(+)

New commits:
commit 1f5a4fa596b993a80fbb12a1736d3d09b0fccb1a
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Jun 17 14:31:20 2024 +0900
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jun 18 13:29:26 2024 +0200

    annot: add undo to annotations inserter when synching
    
    Change-Id: If4b8ddcbee9468655944effb931347c8077abc3c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168980
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sd/source/ui/annotations/annotationmanager.cxx 
b/sd/source/ui/annotations/annotationmanager.cxx
index caeefbb8c3c6..87cfa6014806 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -73,6 +73,7 @@
 #include <drawdoc.hxx>
 #include <svx/annotation/TextAPI.hxx>
 #include <svx/annotation/AnnotationObject.hxx>
+#include <svx/annotation/Annotation.hxx>
 #include <svx/annotation/ObjectAnnotationData.hxx>
 #include <optsitem.hxx>
 #include <sdmod.hxx>
@@ -1013,6 +1014,7 @@ void AnnotationManagerImpl::SyncAnnotationObjects()
         return;
 
     sal_Int32 nIndex = 1;
+    bool bAnnotatonInserted = false;
     for (auto const& xAnnotation : mxCurrentPage->getAnnotations())
     {
         SdrObject* pObject = findAnnotationObjectMatching(xAnnotation);
@@ -1020,6 +1022,11 @@ void AnnotationManagerImpl::SyncAnnotationObjects()
         if (pObject)
             continue;
 
+        if (!bAnnotatonInserted && mpDoc->IsUndoEnabled())
+            mpDoc->BegUndo(SdResId(STR_ANNOTATION_UNDO_INSERT));
+
+        bAnnotatonInserted = true;
+
         auto const& rInfo = xAnnotation->getCreationInfo();
 
         auto* pView = xViewShell->GetView();
@@ -1122,6 +1129,9 @@ void AnnotationManagerImpl::SyncAnnotationObjects()
 
         nIndex++;
     }
+
+    if (bAnnotatonInserted && mpDoc->IsUndoEnabled())
+        mpDoc->EndUndo();
 }
 
 void AnnotationManagerImpl::addListener()

Reply via email to