[Libreoffice-commits] core.git: sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 14 19:16:01 UTC 2020


 sw/source/uibase/app/docst.cxx |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

New commits:
commit c971773afe0852ccdee0267cfad953359c0039be
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Dec 14 11:21:56 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Dec 14 20:15:24 2020 +0100

    tdf#122045 using 'Apply' doesn't keep document modified on later 'Cancel'
    
    Change-Id: I7c6232747785a0c5827fe7344e1dc20758419956
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107683
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index f61a05d4dc10..dd5609af368c 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -554,6 +554,12 @@ public:
         ApplyHdl(nullptr);
     }
     VclPtr<SfxAbstractApplyTabDialog> m_pDlg;
+    // true if the document was initially modified before ApplyStyle was created
+    // or if ApplyStyle:::apply was called
+    bool DocIsModified() const
+    {
+        return m_bModified;
+    }
 private:
     SwDocShell &m_rDocSh;
     bool m_bNew;
@@ -632,6 +638,7 @@ IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone*, void)
     if( !m_bModified )
     {
         pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
+        m_bModified = true;
     }
 
     pWrtShell->EndAllAction();
@@ -906,7 +913,7 @@ void SwDocShell::Edit(
                                     && pStyle->IsUsed()
                                     && !pStyle->IsUserDefined();
 
-        pDlg->StartExecuteAsync([bIsDefaultPage, bModified, bNew, nFamily, nSlot, nNewStyleUndoId, pApplyStyleHelper, pRequest, xTmp, this](sal_Int32 nResult){
+        pDlg->StartExecuteAsync([bIsDefaultPage, bNew, nFamily, nSlot, nNewStyleUndoId, pApplyStyleHelper, pRequest, xTmp, this](sal_Int32 nResult){
             if (RET_OK == nResult)
                 pApplyStyleHelper->apply();
 
@@ -963,6 +970,8 @@ void SwDocShell::Edit(
                 m_pWrtShell->EndUndo(nNewStyleUndoId, &aRewriter);
             }
 
+            bool bDocModified = pApplyStyleHelper->DocIsModified();
+
             if (RET_OK != nResult)
             {
                 if (bNew)
@@ -971,7 +980,7 @@ void SwDocShell::Edit(
                     m_xDoc->GetIDocumentUndoRedo().ClearRedo();
                 }
 
-                if (!bModified)
+                if (!bDocModified)
                     m_xDoc->getIDocumentState().ResetModified();
             }
 
@@ -987,7 +996,7 @@ void SwDocShell::Edit(
             if (pRequest)
                 pRequest->Done();
 
-            if (bIsDefaultPage && bModified)
+            if (bIsDefaultPage && bDocModified)
             {
                 uno::Reference< style::XStyleFamiliesSupplier > xStyleFamSupp(GetModel(), uno::UNO_QUERY);
 


More information about the Libreoffice-commits mailing list