sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 32 +++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-)
New commits: commit 7f85266b390aaf784af6a8d4afa139cd1b6988e4 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Nov 28 20:11:54 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Nov 29 08:18:29 2023 +0100 CppunitTest_sw_ooxmlexport16: rework to avoid preTest() This keeps all code of a test in a single place, if we don't trigger the preTest() magic. Change-Id: Ib97bf07cde6e235d9f9705cbff2f163fbc6d72b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160055 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index f7e62615e8a8..dd1b87f147aa 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -30,29 +30,12 @@ #include <unotools/fltrcfg.hxx> #include <unoprnms.hxx> #include <o3tl/string_view.hxx> +#include <comphelper/scopeguard.hxx> class Test : public SwModelTestBase { public: Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {} - -virtual std::unique_ptr<Resetter> preTest(const char* filename) override - { - if (filename == std::string_view("tdf135774_numberingShading.docx")) - { - bool bIsExportAsShading = SvtFilterOptions::Get().IsCharBackground2Shading(); - // This function is run at the end of the test - returning the filter options to normal. - std::unique_ptr<Resetter> pResetter(new Resetter( - [bIsExportAsShading] () { - if (bIsExportAsShading) - SvtFilterOptions::Get().SetCharBackground2Shading(); - })); - // For these tests, ensure exporting CharBackground as w:highlight. - SvtFilterOptions::Get().SetCharBackground2Highlighting(); - return pResetter; - } - return nullptr; - } }; CPPUNIT_TEST_FIXTURE(Test, testTdf143860NonPrimitiveCustomShape) @@ -542,8 +525,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf134951_duplicates) CPPUNIT_TEST_FIXTURE(Test, testTdf135773_numberingShading) { + bool bIsExportAsShading = SvtFilterOptions::Get().IsCharBackground2Shading(); + // This function is run at the end of the test - returning the filter options to normal. + comphelper::ScopeGuard g( + [bIsExportAsShading] + { + if (bIsExportAsShading) + SvtFilterOptions::Get().SetCharBackground2Shading(); + }); + // For these test, ensure exporting CharBackground as w:highlight. + SvtFilterOptions::Get().SetCharBackground2Highlighting(); + loadAndSave("tdf135774_numberingShading.docx"); - // This test uses preTest to export CharBackground as Highlight instead of the 7.0 default of Shading. + // This test uses a custom setting to export CharBackground as Highlight instead of the 7.0 default of Shading. // Before the fix, the imported shading was converted into a red highlight. xmlDocUniquePtr pXmlStyles = parseExport("word/numbering.xml");