tdf#69500 Regression test for saving toolbar to document
The regression was introduced in commitda06166015
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-pickda06166015
Change-Id: I569c1172d3e2360a0364768d0b4fa799da9194d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183356 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
f9b487f44f
commit
aaed16eef8
@@ -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: */
|
||||
|
Reference in New Issue
Block a user