include/svl/undo.hxx              |    1 +
 sc/source/ui/drawfunc/futext3.cxx |    2 ++
 svl/source/undo/undo.cxx          |    5 ++++-
 3 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit b50df5aa72fb1259734794222119c5ad3017ba26
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu May 4 09:10:31 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu May 4 15:14:53 2023 +0200

    Resolves: tdf#134308 if max undo is 0, treat as if no undo
    
    Change-Id: I7eaa71d80718a4350ba6a3d7ff19ce09e1ac3aa3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151354
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index a64a1f5151f3..a7d1e4753712 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ -198,6 +198,7 @@ public:
     virtual                 ~SfxUndoManager();
 
     void                    SetMaxUndoActionCount( size_t nMaxUndoActionCount 
);
+    size_t                  GetMaxUndoActionCount() const;
     virtual void            AddUndoAction( std::unique_ptr<SfxUndoAction> 
pAction, bool bTryMerg=false );
     virtual size_t          GetUndoActionCount( bool const i_currentLevel = 
CurrentLevel ) const;
     OUString                GetUndoActionComment( size_t nNo=0, bool const 
i_currentLevel = CurrentLevel ) const;
diff --git a/sc/source/ui/drawfunc/futext3.cxx 
b/sc/source/ui/drawfunc/futext3.cxx
index a0db57860945..c7e59c5beaba 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -64,6 +64,8 @@ void FuText::StopEditMode()
 
     ScDocShell* pDocShell = rViewData.GetDocShell();
     SfxUndoManager* pUndoMgr = rDoc.IsUndoEnabled() ? 
pDocShell->GetUndoManager() : nullptr;
+    if (pUndoMgr && !pUndoMgr->GetMaxUndoActionCount()) // tdf#134308 if max 
undo is 0, treat as if no undo
+        pUndoMgr = nullptr;
     bool bNewNote = false;
     if( pNote && pUndoMgr )
     {
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 31269438f938..9b90495d593a 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -376,7 +376,6 @@ bool SfxUndoManager::ImplIsUndoEnabled_Lock() const
     return m_xData->mbUndoEnabled;
 }
 
-
 void SfxUndoManager::SetMaxUndoActionCount( size_t nMaxUndoActionCount )
 {
     UndoManagerGuard aGuard( *m_xData );
@@ -411,6 +410,10 @@ void SfxUndoManager::SetMaxUndoActionCount( size_t 
nMaxUndoActionCount )
     ImplCheckEmptyActions();
 }
 
+size_t SfxUndoManager::GetMaxUndoActionCount() const
+{
+    return m_xData->pActUndoArray->nMaxUndoActions;
+}
 
 void SfxUndoManager::ImplClearCurrentLevel_NoNotify( UndoManagerGuard& i_guard 
)
 {

Reply via email to