sw/CppunitTest_sw_rtfimport.mk | 4 +++ sw/qa/extras/ooxmlexport/ooxmllinks.cxx | 38 ++++++++++++++------------------ sw/qa/extras/rtfimport/rtfimport.cxx | 15 ++---------- sw/qa/extras/uiwriter/uiwriter10.cxx | 30 ++++--------------------- 4 files changed, 29 insertions(+), 58 deletions(-)
New commits: commit a99a6e7e17e3dcc50a3f6ee0e4d6bd7bb60729cc Author: Mike Kaganski <[email protected]> AuthorDate: Mon Feb 2 11:04:28 2026 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Feb 2 10:02:34 2026 +0100 Use ScopedConfigValue These tests used ad-hoc structs for the required configuration values, instead of direct use of officecfg headers. Change-Id: I26353b0523d3607e84181de44a702ec007445c8d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198508 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sw/CppunitTest_sw_rtfimport.mk b/sw/CppunitTest_sw_rtfimport.mk index e961c4c2304b..792e35a7f798 100644 --- a/sw/CppunitTest_sw_rtfimport.mk +++ b/sw/CppunitTest_sw_rtfimport.mk @@ -47,6 +47,10 @@ $(eval $(call gb_CppunitTest_set_include,sw_rtfimport,\ $$(INCLUDE) \ )) +$(eval $(call gb_CppunitTest_use_custom_headers,sw_rtfimport,\ + officecfg/registry \ +)) + $(eval $(call gb_CppunitTest_use_api,sw_rtfimport,\ udkapi \ offapi \ diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 337c6916d4ba..2e3976983ade 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -45,7 +45,8 @@ #include <tools/UnitConversion.hxx> #include <rtl/ustring.hxx> #include <comphelper/sequenceashashmap.hxx> -#include <comphelper/configuration.hxx> +#include <officecfg/Office/Linguistic.hxx> +#include <test/commontesttools.hxx> namespace { @@ -865,17 +866,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo68291) CPPUNIT_TEST_FIXTURE(Test, testTdf105511) { - struct DefaultLocale : public comphelper::ConfigurationProperty<DefaultLocale, OUString> - { - static OUString path() - { - return u"/org.openoffice.Office.Linguistic/General/DefaultLocale"_ustr; - } - ~DefaultLocale() = delete; - }; - auto batch = comphelper::ConfigurationChanges::create(); - DefaultLocale::set(u"ru-RU"_ustr, batch); - batch->commit(); + ScopedConfigValue<officecfg::Office::Linguistic::General::DefaultLocale> aCfg(u"ru-RU"_ustr); createSwDoc("tdf105511.rtf"); getParagraph(1, u"\u0418\u043C\u044F"_ustr); } diff --git a/sw/qa/extras/uiwriter/uiwriter10.cxx b/sw/qa/extras/uiwriter/uiwriter10.cxx index 44f5b24a5d2c..78f96a559eb3 100644 --- a/sw/qa/extras/uiwriter/uiwriter10.cxx +++ b/sw/qa/extras/uiwriter/uiwriter10.cxx @@ -17,7 +17,6 @@ #include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <comphelper/propertysequence.hxx> -#include <comphelper/configuration.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <vcl/scheduler.hxx> #include <vcl/settings.hxx> @@ -36,6 +35,8 @@ #include <IDocumentLayoutAccess.hxx> #include <redline.hxx> #include <svx/svxids.hrc> +#include <officecfg/Office/Compatibility.hxx> +#include <test/commontesttools.hxx> /// Second set of tests asserting the behavior of Writer user interface shells. class SwUiWriterTest5 : public SwModelTestBase @@ -1768,30 +1769,9 @@ static uno::Reference<text::XTextRange> getAssociatedTextRange(uno::Any object) CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf123218) { - struct ReverseXAxisOrientationDoughnutChart - : public comphelper::ConfigurationProperty<ReverseXAxisOrientationDoughnutChart, bool> - { - static OUString path() - { - return u"/org.openoffice.Office.Compatibility/View/ReverseXAxisOrientationDoughnutChart"_ustr; - } - ~ReverseXAxisOrientationDoughnutChart() = delete; - }; - - struct ClockwisePieChartDirection - : public comphelper::ConfigurationProperty<ClockwisePieChartDirection, bool> - { - static OUString path() - { - return u"/org.openoffice.Office.Compatibility/View/ClockwisePieChartDirection"_ustr; - } - ~ClockwisePieChartDirection() = delete; - }; - auto batch = comphelper::ConfigurationChanges::create(); - - ReverseXAxisOrientationDoughnutChart::set(false, batch); - ClockwisePieChartDirection::set(true, batch); - batch->commit(); + using CompatViewCfg = officecfg::Office::Compatibility::View; + ScopedConfigValue<CompatViewCfg::ReverseXAxisOrientationDoughnutChart> aCfg1(false); + ScopedConfigValue<CompatViewCfg::ClockwisePieChartDirection> aCfg2(true); createSwDoc(); commit a85beb8036598e36f8899dc76ea1c9e010509770 Author: Mike Kaganski <[email protected]> AuthorDate: Mon Feb 2 11:03:30 2026 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Feb 2 10:02:25 2026 +0100 Replace SetAbsolute with ScopedConfigValue Change-Id: I911b105c8dca2db2161d858d6bc09bbc962f0d46 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198507 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx index e292d1773ca2..d56e30b7e8f1 100644 --- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx @@ -12,12 +12,13 @@ #include <tools/urlobj.hxx> #include <officecfg/Office/Common.hxx> #include <o3tl/string_view.hxx> +#include <test/commontesttools.hxx> // This file contains tests to check relative/absolute hyperlinks handling // decide if output link should be converted to absolute -#define USE_ABSOLUTE true -#define USE_RELATIVE false +#define USE_ABSOLUTE false +#define USE_RELATIVE true class Test : public SwModelTestBase { @@ -27,12 +28,7 @@ public: { } - void SetAbsolute(bool bAbsolute) - { - auto xChanges = comphelper::ConfigurationChanges::create(); - officecfg::Office::Common::Save::URL::FileSystem::set(!bAbsolute, xChanges); - xChanges->commit(); - } + using SaveFilesystemURLCfg = officecfg::Office::Common::Save::URL::FileSystem; // link should be modified to be placed in temp dir - for testing relative links void UseTempDir() @@ -62,7 +58,7 @@ public: CPPUNIT_TEST_FIXTURE(Test, testRelativeToRelativeImport) { - SetAbsolute(USE_RELATIVE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_RELATIVE); createSwDoc("relative-link.docx"); uno::Reference<text::XTextRange> xParagraph = getParagraph(1); uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1); @@ -73,7 +69,7 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeToRelativeImport) CPPUNIT_TEST_FIXTURE(Test, testRelativeToAbsoluteImport) { - SetAbsolute(USE_ABSOLUTE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_ABSOLUTE); createSwDoc("relative-link.docx"); uno::Reference<text::XTextRange> xParagraph = getParagraph(1); uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1); @@ -84,7 +80,7 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeToAbsoluteImport) CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToAbsoluteImport) { - SetAbsolute(USE_ABSOLUTE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_ABSOLUTE); createSwDoc("absolute-link.docx"); uno::Reference<text::XTextRange> xParagraph = getParagraph(1); uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1); @@ -95,7 +91,7 @@ CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToAbsoluteImport) CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToRelativeImport) { - SetAbsolute(USE_RELATIVE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_RELATIVE); createSwDoc("absolute-link.docx"); uno::Reference<text::XTextRange> xParagraph = getParagraph(1); uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1); @@ -106,7 +102,7 @@ CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToRelativeImport) CPPUNIT_TEST_FIXTURE(Test, testTdf123627_import) { - SetAbsolute(USE_RELATIVE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_RELATIVE); createSwDoc("tdf123627.docx"); uno::Reference<text::XTextRange> xText = getRun(getParagraph(1), 1); OUString sTarget = getProperty<OUString>(xText, u"HyperLinkURL"_ustr); @@ -118,7 +114,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf123627_import) CPPUNIT_TEST_FIXTURE(Test, testRelativeToRelativeExport) { - SetAbsolute(USE_RELATIVE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_RELATIVE); createSwDoc("relative-link.docx"); UseTempDir(); saveAndReload(TestFilter::DOCX); @@ -130,7 +126,7 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeToRelativeExport) CPPUNIT_TEST_FIXTURE(Test, testRelativeToAbsoluteExport) { - SetAbsolute(USE_ABSOLUTE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_ABSOLUTE); createSwDoc("relative-link.docx"); // Don't modify link. saveAndReload(TestFilter::DOCX); @@ -143,7 +139,7 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeToAbsoluteExport) CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToRelativeExport) { - SetAbsolute(USE_RELATIVE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_RELATIVE); createSwDoc("absolute-link.docx"); UseTempDir(); saveAndReload(TestFilter::DOCX); @@ -154,7 +150,7 @@ CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToRelativeExport) CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToAbsoluteExport) { - SetAbsolute(USE_ABSOLUTE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_ABSOLUTE); createSwDoc("absolute-link.docx"); // Don't modify link. saveAndReload(TestFilter::DOCX); @@ -167,7 +163,7 @@ CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToAbsoluteExport) CPPUNIT_TEST_FIXTURE(Test, testTdf123627_export) { - SetAbsolute(USE_RELATIVE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_RELATIVE); createSwDoc("tdf123627.docx"); UseTempDir(); saveAndReload(TestFilter::DOCX); @@ -179,7 +175,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf123627_export) CPPUNIT_TEST_FIXTURE(Test, testTdf126590_export) { - SetAbsolute(USE_ABSOLUTE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_ABSOLUTE); createSwDoc("tdf126590.docx"); // Don't modify link. saveAndReload(TestFilter::DOCX); @@ -191,7 +187,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf126590_export) CPPUNIT_TEST_FIXTURE(Test, testTdf126768_export) { - SetAbsolute(USE_ABSOLUTE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_ABSOLUTE); createSwDoc("tdf126768.docx"); // Don't modify link. saveAndReload(TestFilter::DOCX); @@ -203,7 +199,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf126768_export) CPPUNIT_TEST_FIXTURE(Test, testNon_ascii_link_export) { - SetAbsolute(USE_ABSOLUTE); + ScopedConfigValue<SaveFilesystemURLCfg> aCfg(USE_ABSOLUTE); createSwDoc("non_ascii_link.docx"); // Don't modify link. saveAndReload(TestFilter::DOCX);
