From aaed16eef8b2d32ac02c8cb3a42ca25246cb0d33 Mon Sep 17 00:00:00 2001 From: David Hashe Date: Wed, 26 Mar 2025 14:38:19 -0400 Subject: [PATCH] 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 --- sw/qa/extras/odfexport/odfexport.cxx | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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 #include #include +#include +#include #include #include @@ -1381,6 +1383,52 @@ DECLARE_ODFEXPORT_TEST(testTextFrameVertAdjust, "textframe-vertadjust.odt") CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty(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 xContext + = comphelper::getProcessComponentContext(); + uno::Reference xModel(mxComponent, uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + uno::Reference xConfigSupplier(xModel, uno::UNO_QUERY); + CPPUNIT_ASSERT(xConfigSupplier.is()); + uno::Reference xConfigManager + = xConfigSupplier->getUIConfigurationManager(); + return xConfigManager; + }; + + // Create and persist a custom toolbar to the document + { + uno::Reference xConfigManager = getUIConfigManager(); + + uno::Reference xIndexContainer(xConfigManager->createSettings(), + uno::UNO_SET_THROW); + uno::Reference xIndexAccess(xIndexContainer, uno::UNO_QUERY_THROW); + uno::Reference xProps(xIndexContainer, uno::UNO_QUERY_THROW); + + xProps->setPropertyValue(u"UIName"_ustr, uno::Any(u"Custom Toolbar 1"_ustr)); + + xConfigManager->insertSettings(sToolBarName, xIndexAccess); + + uno::Reference xPersistence(xConfigManager, + uno::UNO_QUERY_THROW); + xPersistence->store(); + } + + saveAndReload(mpFilter); + + // Without the fix, the toolbar will be gone after save-and-reload + { + uno::Reference xConfigManager = getUIConfigManager(); + + CPPUNIT_ASSERT(xConfigManager->hasSettings(sToolBarName)); + } +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */