sw/qa/extras/odfexport/odfexport.cxx |   48 +++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

New commits:
commit aaed16eef8b2d32ac02c8cb3a42ca25246cb0d33
Author:     David Hashe <m...@dhashe.com>
AuthorDate: Wed Mar 26 14:38:19 2025 -0400
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 27 08:26:14 2025 +0100

    tdf#69500 Regression test for saving toolbar to document
    
    The regression was introduced in commit 
da06166015689eca260c702602bef4cea58afbd3
    for tdf#60700 and fixed in commit 42f4261f835ad4ff7d98126cc7fb3be84dc76126
    
    This change adds a regression test to verify that saving a custom toolbar
    to a fresh document works. It passes for master and fails with
    cherry-pick da06166015689eca260c702602bef4cea58afbd3
    
    Change-Id: I569c1172d3e2360a0364768d0b4fa799da9194d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183356
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/qa/extras/odfexport/odfexport.cxx 
b/sw/qa/extras/odfexport/odfexport.cxx
index b1fc22e16ef2..560fc32585a5 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -38,6 +38,8 @@
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/util/XRefreshable.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
 
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/fileformat.h>
@@ -1381,6 +1383,52 @@ DECLARE_ODFEXPORT_TEST(testTextFrameVertAdjust, 
"textframe-vertadjust.odt")
     CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, 
getProperty<drawing::TextVerticalAdjust>(xFrame, u"TextVerticalAdjust"_ustr));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf69500)
+{
+    createSwDoc();
+
+    static constexpr OUString sToolBarName = 
u"private:resource/toolbar/custom_toolbar_1"_ustr;
+
+    auto getUIConfigManager = [this]() {
+        css::uno::Reference<css::uno::XComponentContext> xContext
+            = comphelper::getProcessComponentContext();
+        uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+        CPPUNIT_ASSERT(xModel.is());
+        uno::Reference<ui::XUIConfigurationManagerSupplier> 
xConfigSupplier(xModel, uno::UNO_QUERY);
+        CPPUNIT_ASSERT(xConfigSupplier.is());
+        uno::Reference<ui::XUIConfigurationManager> xConfigManager
+            = xConfigSupplier->getUIConfigurationManager();
+        return xConfigManager;
+    };
+
+    // Create and persist a custom toolbar to the document
+    {
+        uno::Reference<ui::XUIConfigurationManager> xConfigManager = 
getUIConfigManager();
+
+        uno::Reference<container::XIndexContainer> 
xIndexContainer(xConfigManager->createSettings(),
+                                                                   
uno::UNO_SET_THROW);
+        uno::Reference<container::XIndexAccess> xIndexAccess(xIndexContainer, 
uno::UNO_QUERY_THROW);
+        uno::Reference<beans::XPropertySet> xProps(xIndexContainer, 
uno::UNO_QUERY_THROW);
+
+        xProps->setPropertyValue(u"UIName"_ustr, uno::Any(u"Custom Toolbar 
1"_ustr));
+
+        xConfigManager->insertSettings(sToolBarName, xIndexAccess);
+
+        uno::Reference<ui::XUIConfigurationPersistence> 
xPersistence(xConfigManager,
+                                                                     
uno::UNO_QUERY_THROW);
+        xPersistence->store();
+    }
+
+    saveAndReload(mpFilter);
+
+    // Without the fix, the toolbar will be gone after save-and-reload
+    {
+        uno::Reference<ui::XUIConfigurationManager> xConfigManager = 
getUIConfigManager();
+
+        CPPUNIT_ASSERT(xConfigManager->hasSettings(sToolBarName));
+    }
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to