chart2/qa/extras/chart2geometry.cxx | 5 - sc/qa/unit/subsequent_export_test.cxx | 26 ++-------- sc/qa/unit/subsequent_filters_test5.cxx | 28 ++++------ sd/qa/unit/export-tests.cxx | 19 +------ sw/qa/extras/globalfilter/globalfilter.cxx | 25 ++------- xmloff/qa/unit/draw.cxx | 12 +--- xmloff/qa/unit/style.cxx | 75 +++++------------------------ xmlsecurity/qa/unit/signing/signing.cxx | 14 +---- xmlsecurity/qa/unit/signing/signing2.cxx | 27 +--------- 9 files changed, 54 insertions(+), 177 deletions(-)
New commits: commit 4dc04a10692dc932658d9d079bbe97fcaf0b4742 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Oct 2 10:06:12 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Oct 2 11:15:09 2024 +0200 qa: use SetODFDefaultVersion everywhere Change-Id: I4a08abea9a6c61a0365d238abf1021806ae6df29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174375 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/chart2/qa/extras/chart2geometry.cxx b/chart2/qa/extras/chart2geometry.cxx index f5d928379611..f5eb3b1f20ea 100644 --- a/chart2/qa/extras/chart2geometry.cxx +++ b/chart2/qa/extras/chart2geometry.cxx @@ -464,9 +464,10 @@ void Chart2GeometryTest::testTdf135366LabelExport() void Chart2GeometryTest::testTdf135366_CustomLabelText() { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // Error was, that custom text in a data label was only exported in ODF extended, // although the used <chart:data-label> element exists since ODF 1.2. - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); SetODFDefaultVersion(SvtSaveOptions::ODFVER_012); loadFromFile(u"pptx/tdf135366_CustomLabelText.pptx"); save(u"impress8"_ustr); @@ -482,8 +483,6 @@ void Chart2GeometryTest::testTdf135366_CustomLabelText() // Verify text content const OUString sOUTextContent = getXPathContent(pXmlDoc, sCustomTextPath); CPPUNIT_ASSERT_EQUAL(u"Custom"_ustr, sOUTextContent); - - SetODFDefaultVersion(nCurrentODFVersion); } CPPUNIT_TEST_SUITE_REGISTRATION(Chart2GeometryTest); diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx index dde63a313271..7adb5e90bf34 100644 --- a/sc/qa/unit/subsequent_export_test.cxx +++ b/sc/qa/unit/subsequent_export_test.cxx @@ -7,7 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <officecfg/Office/Common.hxx> #include <config_fonts.h> #include "helper/debughelper.hxx" @@ -39,6 +38,7 @@ #include <editeng/fhgtitem.hxx> #include <editeng/udlnitem.hxx> #include <editeng/colritem.hxx> +#include <unotools/saveopt.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -707,6 +707,8 @@ static auto verifySpreadsheet13(char const* const pTestName, ScDocument& rDoc) - CPPUNIT_TEST_FIXTURE(ScExportTest, testODF13) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // import createScDoc("ods/spreadsheet13e.ods"); ScDocument* pDoc = getScDoc(); @@ -714,19 +716,9 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testODF13) // check model verifySpreadsheet13("import", *pDoc); - Resetter _([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); - { // export ODF 1.3 - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); // FIXME: Error: unexpected attribute "loext:scale-to-X" skipValidation(); @@ -749,10 +741,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testODF13) } { // export ODF 1.2 Extended - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(9, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_012_EXTENDED); saveAndReload(u"calc8"_ustr); pDoc = getScDoc(); @@ -772,10 +761,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testODF13) } { // export ODF 1.2 - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(4, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_012); save(u"calc8"_ustr); diff --git a/sc/qa/unit/subsequent_filters_test5.cxx b/sc/qa/unit/subsequent_filters_test5.cxx index 9d96f8f97a4e..7ba3267083f0 100644 --- a/sc/qa/unit/subsequent_filters_test5.cxx +++ b/sc/qa/unit/subsequent_filters_test5.cxx @@ -10,7 +10,6 @@ // core, please keep it alphabetically ordered #include <comphelper/configuration.hxx> #include "helper/qahelper.hxx" -#include <officecfg/Office/Common.hxx> #include <test/unoapi_test.hxx> #include <unotools/saveopt.hxx> @@ -73,6 +72,8 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest5, testTdf162963) CPPUNIT_TEST_FIXTURE(ScFiltersTest5, testTdf162963_ODF) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // Verify, that calcext:contains-footer is only written in extended file format versions. // The parameter in DefaultVersion::set need to be adapted, when attribute contains-footer // is included in ODF strict, see issue OFFICE-4169 at OASIS. @@ -87,31 +88,24 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest5, testTdf162963_ODF) UNO_QUERY_THROW); xDBRangePropSet->setPropertyValue(u"TotalsRow"_ustr, uno::Any(true)); - // Backup original ODF default version - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); + // Save to ODF 1.3 extended. + // Adapt to a concrete version when attribute contains-footer is available in ODF strict. + // Make sure attribute is written in calcext namespace + save(u"calc8"_ustr); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, + "/office:document-content/office:body/office:spreadsheet/" + "table:database-ranges/table:database-range[@calcext:contains-footer='true']"_ostr); // Save to ODF 1.3 strict. Make sure attribute is not written. // Adapt to ODF 1.4 strict, when it is available. SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); save(u"calc8"_ustr); // this saves to .ods not to .fods - xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + pXmlDoc = parseExport(u"content.xml"_ustr); assertXPath(pXmlDoc, "/office:document-content/office:body/office:spreadsheet/" "table:database-ranges/table:database-range/contains-footer"_ostr, 0); - - // Save to ODF_LATEST which is currently (Sep 2024) ODF 1.3 extended. - // Adapt to a concrete version when attribute contains-footer is available in ODF strict. - // Make sure attribute is written in calcext namespace - SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_LATEST); - save(u"calc8"_ustr); - pXmlDoc = parseExport(u"content.xml"_ustr); - assertXPath(pXmlDoc, - "/office:document-content/office:body/office:spreadsheet/" - "table:database-ranges/table:database-range[@calcext:contains-footer='true']"_ostr); - - // Set back to original ODF default version. - SetODFDefaultVersion(nCurrentODFVersion); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index ae501d2c5802..0b2ff03c0358 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -9,7 +9,6 @@ #include <sal/config.h> -#include <officecfg/Office/Common.hxx> #include "sdmodeltestbase.hxx" #include <sdpage.hxx> @@ -19,6 +18,7 @@ #include <editeng/outlobj.hxx> #include <editeng/colritem.hxx> #include <editeng/eeitem.hxx> +#include <unotools/saveopt.hxx> #include <svx/svdotext.hxx> #include <svx/svdograf.hxx> @@ -1138,12 +1138,7 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testPageWithTransparentBackground) CPPUNIT_TEST_FIXTURE(SdExportTest, testTextRotation) { // Save behavior depends on whether ODF strict or extended is used. - Resetter _([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); // The contained shape has a text rotation vert="vert" which corresponds to // loext:writing-mode="tb-rl90" in the graphic-properties of the style of the shape in ODF 1.3 @@ -1151,11 +1146,6 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTextRotation) // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when // attribute value "tb-rl90" is included in ODF strict. { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - pBatch->commit(); - createSdImpressDoc("pptx/shape-text-rotate.pptx"); saveAndReload(u"impress8"_ustr); @@ -1168,10 +1158,7 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTextRotation) } // In ODF 1.3 strict the workaround to use the TextRotateAngle is used instead. { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); createSdImpressDoc("pptx/shape-text-rotate.pptx"); saveAndReload(u"impress8"_ustr); diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 5538f6ee856a..60e285be1202 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -37,6 +37,7 @@ #include <IMark.hxx> #include <com/sun/star/awt/FontWeight.hpp> #include <unotools/mediadescriptor.hxx> +#include <unotools/saveopt.hxx> namespace { @@ -962,25 +963,17 @@ auto Test::verifyText13(char const*const pTestName) -> void // test ODF 1.3 new text document features void Test::testODF13() { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // import createSwDoc("text13e.odt"); // check model verifyText13("import"); - Resetter _([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); - { // export ODF 1.3 - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); saveAndReload(u"writer8"_ustr); @@ -1004,10 +997,7 @@ void Test::testODF13() } { // export ODF 1.2 extended - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(9, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_012_EXTENDED); // FIXME: it's not possible to use 'reload' here because the validation fails with // Error: unexpected attribute "loext:contextual-spacing" @@ -1041,10 +1031,7 @@ void Test::testODF13() } { // export ODF 1.2 - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(4, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_012); // don't reload - no point save(u"writer8"_ustr); diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index ee1b59161587..d098f94a1d3f 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -524,13 +524,13 @@ void lcl_assertMetalProperties(std::string_view sInfo, uno::Reference<drawing::X CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeExtended) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); loadFromFile(u"tdf145700_3D_metal_type_MSCompatible.doc"); // verify properties uno::Reference<drawing::XShape> xShape(getShape(0)); lcl_assertMetalProperties("from doc", xShape); // Test, that new attribute is written with loext namespace. Adapt when attribute is added to ODF. - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); SetODFDefaultVersion(SvtSaveOptions::ODFVER_013_EXTENDED); saveAndReload(u"writer8"_ustr); @@ -544,8 +544,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeExtended) // verify properties uno::Reference<drawing::XShape> xShapeReload(getShape(0)); lcl_assertMetalProperties("from ODF 1.3 extended", xShapeReload); - - SetODFDefaultVersion(nCurrentODFVersion); } CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeStrict) @@ -582,6 +580,7 @@ void lcl_assertSpecularityProperty(std::string_view sInfo, uno::Reference<drawin CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularityExtended) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); loadFromFile(u"tdf147580_extrusion-specularity.doc"); // verify property uno::Reference<drawing::XShape> xShape(getShape(0)); @@ -589,7 +588,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularityExtended) // Test, that attribute is written in draw namespace with value 100% and in loext namespace with // value 122.0703125%. - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); SetODFDefaultVersion(SvtSaveOptions::ODFVER_013_EXTENDED); saveAndReload(u"writer8"_ustr); @@ -602,8 +600,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularityExtended) // verify properties uno::Reference<drawing::XShape> xShapeReload(getShape(0)); lcl_assertSpecularityProperty("from ODF 1.3 extended", xShapeReload); - - SetODFDefaultVersion(nCurrentODFVersion); } CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularityStrict) @@ -627,15 +623,13 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularityStrict) CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularity) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); loadFromFile(u"tdf147580_extrusion-specularity.doc"); // The file has c3DSpecularAmt="80000" which results internally in specularity=122%. // Save to ODF 1.3 strict and make sure it does not produce a validation error. - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); SetODFDefaultVersion(SvtSaveOptions::ODFVER_013); save(u"writer8"_ustr); - - SetODFDefaultVersion(nCurrentODFVersion); } namespace diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index e3ee10a5c1d3..4df5afa458c8 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -20,7 +20,6 @@ #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#include <officecfg/Office/Common.hxx> #include <rtl/character.hxx> #include <unotools/saveopt.hxx> @@ -171,25 +170,16 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testRtlGutter) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // Load document. It has a frame style with writing-mode bt-lr. // In ODF 1.3 extended it is written as loext:writing-mode="bt-lr". // In ODF 1.3 strict, there must not be an attribute at all. loadFromFile(u"tdf150407_WritingModeBTLR_style.odt"); - Resetter _([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); - // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when // attribute value "bt-lr" is included in ODF strict. { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - pBatch->commit(); save(u"writer8"_ustr); // With applied fix for tdf150407 still loext:writing-mode="bt-lr" has to be written. @@ -206,10 +196,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR) loadFromFile(u"tdf150407_WritingModeBTLR_style.odt"); // Save to ODF 1.3 strict. { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); save(u"writer8"_ustr); // Without the fix an faulty 'writing-mode="bt-lr"' attribute was written in productive build. @@ -224,25 +211,16 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // Load document. It has a frame position with vertical position relative to bottom margin. // In ODF 1.3 extended it is written as loext:vertical-rel="page-content-bottom". // In ODF 1.3 strict, there must not be an attribute at all. loadFromFile(u"tdf150407_PosRelBottomMargin.docx"); - Resetter _([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); - // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when // attribute value "page-content-bottom" is included in ODF strict. { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - pBatch->commit(); save(u"writer8"_ustr); // With applied fix for tdf150407 still loext:vertical-rel="page-content-bottom" has to be @@ -262,10 +240,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) loadFromFile(u"tdf150407_PosRelBottomMargin.docx"); // Save to ODF 1.3 strict. { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); save(u"writer8"_ustr); // Without the fix an faulty 'vertical-rel="page-content-bottom"' attribute was written in @@ -280,25 +255,16 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // Load document. It has a frame position with vertical position relative to top margin. // In ODF 1.3 extended it is written as loext:vertical-rel="page-content-top". // In ODF 1.3 strict, there must not be an attribute at all. loadFromFile(u"tdf150407_PosRelTopMargin.docx"); - Resetter _([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); - // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when // attribute value "page-content-top" is included in ODF strict. { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - pBatch->commit(); save(u"writer8"_ustr); // With applied fix for tdf150407 still loext:vertical-rel="page-content-top has to be @@ -318,10 +284,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) loadFromFile(u"tdf150407_PosRelTopMargin.docx"); // Save to ODF 1.3 strict. { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); - pBatch->commit(); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); save(u"writer8"_ustr); // Without the fix an faulty 'vertical-rel="page-content-top"' attribute was written in @@ -522,6 +485,8 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_threeStops) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBorderRestoration) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // Load document. It has a shape with color gradient build from color stop yellow at offset 0.5 // and color stop red at offset 1.0. For better backward compatibility such gradient has to be // exported to ODF with a border of 50%. @@ -530,11 +495,9 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBorderRestoration) loadFromFile(u"MCGR_Border_restoration.pptx"); // Backup original ODF default version - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); - // Save to ODF_LATEST which is currently ODF 1.3 extended. Make sure gradient-stop elements have + // Save ODF 1.3 extended. Make sure gradient-stop elements have // offsets 0 and 1, and border is written as 50%. - SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_LATEST); save(u"impress8"_ustr); xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); OString sPath @@ -553,13 +516,12 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBorderRestoration) assertXPath(pXmlDoc, sPath, "start-color"_ostr, u"#ffff00"_ustr); assertXPath(pXmlDoc, sPath, "end-color"_ostr, u"#ff0000"_ustr); assertXPath(pXmlDoc, sPath, "border"_ostr, u"50%"_ustr); - - // Set back to original ODF default version. - SetODFDefaultVersion(nCurrentODFVersion); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testTransparencyBorderRestoration) { + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + // Load document. It has a shape with transparency gradient build from transparency 100% at // offset 0, transparency 100% at offset 0.4 and transparency 10% at offset 1.0. For better // backward compatibility such gradient is exported with a border of 40% in the transparency @@ -567,12 +529,8 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testTransparencyBorderRestoration) // When transparency gradient-stops are integrated in ODF strict, the test needs to be adapted. loadFromFile(u"MCGR_TransparencyBorder_restoration.pptx"); - // Backup original ODF default version - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); - - // Save to ODF_LATEST which is currently ODF 1.3 extended. Make sure transparency gradient-stop + // Save to ODF 1.3 extended. Make sure transparency gradient-stop //elements are written with offset 0 and 1, and border is written as 40%. - SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_LATEST); save(u"impress8"_ustr); xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); OString sPath = "/office:document-styles/office:styles/draw:opacity[1]"_ostr; @@ -590,9 +548,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testTransparencyBorderRestoration) assertXPath(pXmlDoc, sPath, "start"_ostr, u"0%"_ustr); assertXPath(pXmlDoc, sPath, "end"_ostr, u"90%"_ustr); assertXPath(pXmlDoc, sPath, "border"_ostr, u"40%"_ustr); - - // Set back to original ODF default version. - SetODFDefaultVersion(nCurrentODFVersion); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAxialGradientCompatible) diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index 8aa2eb52d5ee..492c725128e8 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -33,6 +33,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <unotools/tempfile.hxx> +#include <unotools/saveopt.hxx> #include <unotools/ucbstreamhelper.hxx> #include <comphelper/storagehelper.hxx> #include <sfx2/sfxbasemodel.hxx> @@ -50,7 +51,6 @@ #include <ucbhelper/interceptedinteraction.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> -#include <officecfg/Office/Common.hxx> #include <comphelper/configuration.hxx> #include <svx/signaturelinehelper.hxx> #include <sfx2/viewsh.hxx> @@ -1466,16 +1466,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testDropMacroTemplateSignature) CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature10) { // set ODF version 1.0 / 1.1 as default - Resetter _([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(2, pBatch); - pBatch->commit(); + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + SetODFDefaultVersion(SvtSaveOptions::ODFVER_011); const OUString aFormats[] = { u"writer8"_ustr, u"writer8_template"_ustr }; diff --git a/xmlsecurity/qa/unit/signing/signing2.cxx b/xmlsecurity/qa/unit/signing/signing2.cxx index 1fd6d19a32b1..8a40eab29f76 100644 --- a/xmlsecurity/qa/unit/signing/signing2.cxx +++ b/xmlsecurity/qa/unit/signing/signing2.cxx @@ -22,12 +22,11 @@ #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/xml/crypto/SEInitializer.hpp> -#include <officecfg/Office/Common.hxx> - #include <sfx2/sfxbasemodel.hxx> #include <sfx2/objsh.hxx> #include <comphelper/documentconstants.hxx> #include <unotools/tempfile.hxx> +#include <unotools/saveopt.hxx> #include <unotools/ucbstreamhelper.hxx> #include <comphelper/storagehelper.hxx> @@ -124,16 +123,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODF13) { // test the old, standard ODF 1.2/1.3/1.4 encryption - Resetter resetter([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); - pBatch->commit(); + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + SetODFDefaultVersion(SvtSaveOptions::ODFVER_013); saveAndReload(u"writer8"_ustr, "password"); @@ -307,16 +298,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODFWholesom { // test the old, standard ODF 1.2/1.3/1.4 encryption - Resetter resetter([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); - return pBatch->commit(); - }); - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); - pBatch->commit(); + Resetter resetter([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); + SetODFDefaultVersion(SvtSaveOptions::ODFVER_013); saveAndReload(u"writer8"_ustr, "password");