include/unotools/fcm.hxx                           |   11 +++++++++++
 sw/qa/extras/ooxmlexport/data/deleted_pageref.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport21.cxx         |   18 ++++++++++++++++++
 3 files changed, 29 insertions(+)

New commits:
commit acf704eca7e14a2faea1d3b6e66718db07f8b041
Author:     Mike Kaganski <[email protected]>
AuthorDate: Tue Nov 26 00:37:53 2024 +0500
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Nov 26 10:40:10 2024 +0100

    tdf#146269: don't set modified when connecting frame, model and controller
    
    Change-Id: I487a989a97389af11c98e10ac001c860d7855aec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177300
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>
    (cherry picked from commit 1e54b2037a4d58dacc821bd8833e924f6691a7fd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177317
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/include/unotools/fcm.hxx b/include/unotools/fcm.hxx
index 30df362884ba..6fd6b8283777 100644
--- a/include/unotools/fcm.hxx
+++ b/include/unotools/fcm.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/util/XModifiable2.hpp>
 
 namespace utl
 {
@@ -40,12 +41,22 @@ ConnectFrameControllerModel(const 
css::uno::Reference<css::frame::XFrame>& xFram
                             const 
css::uno::Reference<css::frame::XController2>& xController,
                             const css::uno::Reference<css::frame::XModel>& 
xModel)
 {
+    auto xModifiable = xModel.query<css::util::XModifiable2>();
+    bool bOldModifiable = false;
+    if (xModifiable)
+    {
+        bOldModifiable = xModifiable->isSetModifiedEnabled();
+        if (bOldModifiable)
+            xModifiable->disableSetModified();
+    }
     ConnectModelController(xModel, xController);
     if (xFrame)
         xFrame->setComponent(xController->getComponentWindow(), xController);
     // creates the view and menu
     // for correct menu creation the initialized component must be already set 
into the frame
     xController->attachFrame(xFrame);
+    if (xModifiable && bOldModifiable)
+        xModifiable->enableSetModified();
 }
 }
 
diff --git a/sw/qa/extras/ooxmlexport/data/deleted_pageref.docx 
b/sw/qa/extras/ooxmlexport/data/deleted_pageref.docx
new file mode 100644
index 000000000000..3b34327eaa40
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/deleted_pageref.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index ea9d652b44a3..41c3061fb8e7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -857,6 +857,24 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf162746)
     assertXPath(pDump, "//page[1]/body/tab/infos/prtBounds"_ostr, 
"width"_ostr, u"9360"_ustr);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf146269)
+{
+    // Given a focument with a field in a redline:
+    createSwDoc("deleted_pageref.docx");
+    // It must open unmodified:
+    {
+        auto xModifiable = mxComponent.queryThrow<util::XModifiable>();
+        CPPUNIT_ASSERT(!xModifiable->isModified());
+    }
+
+    // Test also after save-and-reload:
+    saveAndReload(u"Office Open XML Text"_ustr);
+    {
+        auto xModifiable = mxComponent.queryThrow<util::XModifiable>();
+        CPPUNIT_ASSERT(!xModifiable->isModified());
+    }
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 

Reply via email to