include/xmloff/xmltoken.hxx | 2 sc/qa/unit/datatransformation_test.cxx | 34 ----- sc/qa/unit/helper/qahelper.cxx | 24 +++ sc/qa/unit/helper/qahelper.hxx | 11 + sc/qa/unit/parallelism.cxx | 27 ---- sc/qa/unit/range.cxx | 37 ------ sc/qa/unit/rangelst_test.cxx | 37 ------ sc/qa/unit/ucalc.cxx | 46 ------- sc/qa/unit/ucalc_condformat.cxx | 40 ------ sc/qa/unit/ucalc_copypaste.cxx | 37 ------ sc/qa/unit/ucalc_formula.cxx | 41 ------ sc/qa/unit/ucalc_pivottable.cxx | 40 ------ sc/qa/unit/ucalc_sharedformula.cxx | 42 ------ sc/qa/unit/ucalc_sort.cxx | 41 ------ schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng | 10 + xmloff/qa/unit/data/content-control-alias.fodt | 8 + xmloff/qa/unit/text.cxx | 74 ++++++++++++ xmloff/source/core/xmltoken.cxx | 2 xmloff/source/text/txtparae.cxx | 14 ++ xmloff/source/text/xmlcontentcontrolcontext.cxx | 20 +++ xmloff/source/text/xmlcontentcontrolcontext.hxx | 2 xmloff/source/token/tokens.txt | 2 22 files changed, 192 insertions(+), 399 deletions(-)
New commits: commit 888a8c3ca70ed19309c15ff7b9f0968ece337cb5 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Oct 18 11:33:20 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Oct 18 12:40:31 2022 +0200 sw content controls, alias and tag: add ODT filter Map the Alias/Tag UNO properties to: <loext:content-control loext:alias="..." loext:tag="..."> on export, and do the opposite on import. Change-Id: Icecbe9037ede0bf8d72d52f2db44328a8db1d83a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141492 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 93f00d81db2a..bd650daea6e7 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -3508,6 +3508,8 @@ namespace xmloff::token { XML_DATE_FORMAT, XML_DATE_RFC_LANGUAGE_TAG, XML_PLAIN_TEXT, + XML_ALIAS, + XML_TAG, XML_FILL_USE_SLIDE_BACKGROUND, diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng index a26e920aa687..d475e90319b4 100644 --- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng +++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng @@ -2992,6 +2992,16 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. <rng:ref name="boolean"/> </rng:attribute> </rng:optional> + <rng:optional> + <rng:attribute name="loext:alias"> + <rng:ref name="string"/> + </rng:attribute> + </rng:optional> + <rng:optional> + <rng:attribute name="loext:tag"> + <rng:ref name="string"/> + </rng:attribute> + </rng:optional> <rng:zeroOrMore> <rng:element name="loext:list-item"> <rng:attribute name="loext:display-text"> diff --git a/xmloff/qa/unit/data/content-control-alias.fodt b/xmloff/qa/unit/data/content-control-alias.fodt new file mode 100644 index 000000000000..8307f682e474 --- /dev/null +++ b/xmloff/qa/unit/data/content-control-alias.fodt @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:body> + <office:text> + <text:p><loext:content-control loext:alias="my alias" loext:tag="my tag">test</loext:content-control></text:p> + </office:text> + </office:body> +</office:document> diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index ee5e4a580ebb..3476aee49c71 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -935,6 +935,45 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testComboBoxContentControlExport) assertXPath(pXmlDoc, "//loext:content-control", "combobox", "true"); } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAliasContentControlExport) +{ + // Given a document with a content control and its alias around a text portion: + getComponent() = loadFromDesktop("private:factory/swriter"); + uno::Reference<lang::XMultiServiceFactory> xMSF(getComponent(), uno::UNO_QUERY); + uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<text::XText> xText = xTextDocument->getText(); + uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); + xText->insertString(xCursor, "test", /*bAbsorb=*/false); + xCursor->gotoStart(/*bExpand=*/false); + xCursor->gotoEnd(/*bExpand=*/true); + uno::Reference<text::XTextContent> xContentControl( + xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); + xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("my alias"))); + xContentControlProps->setPropertyValue("Tag", uno::Any(OUString("my tag"))); + xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + + // When exporting to ODT: + uno::Reference<frame::XStorable> xStorable(getComponent(), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aStoreProps = comphelper::InitPropertySequence({ + { "FilterName", uno::Any(OUString("writer8")) }, + }); + utl::TempFileNamed aTempFile; + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); + validate(aTempFile.GetFileName(), test::ODF); + + // Then make sure the expected markup is used: + std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, "content.xml"); + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + // Without the accompanying fix in place, this test would have failed with: + // - Expression: prop + // - XPath '//loext:content-control' no attribute 'alias' exist + // i.e. alias was lost on export. + assertXPath(pXmlDoc, "//loext:content-control", "alias", "my alias"); + assertXPath(pXmlDoc, "//loext:content-control", "tag", "my tag"); +} + CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testComboBoxContentControlImport) { // Given an ODF document with a plain-text content control: @@ -965,6 +1004,41 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testComboBoxContentControlImport) CPPUNIT_ASSERT(bComboBox); } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAliasContentControlImport) +{ + // Given an ODF document with a content control and its alias/tag: + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "content-control-alias.fodt"; + + // When loading that document: + getComponent() = loadFromDesktop(aURL); + + // Then make sure that the content control is not lost on import: + uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParagraphsAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParagraphs = xParagraphsAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphs->nextElement(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); + uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); + OUString aPortionType; + xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + uno::Reference<text::XTextContent> xContentControl; + xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); + OUString aAlias; + xContentControlProps->getPropertyValue("Alias") >>= aAlias; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: my alias + // - Actual : + // i.e. the alias was lost on import. + CPPUNIT_ASSERT_EQUAL(OUString("my alias"), aAlias); + OUString aTag; + xContentControlProps->getPropertyValue("Tag") >>= aTag; + CPPUNIT_ASSERT_EQUAL(OUString("my tag"), aTag); +} + CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlAutostyleExport) { // Given a document with a dropdown content control, and formatting that forms an autostyle in diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index ca5c7ec21b08..1dc56ced1114 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3511,6 +3511,8 @@ namespace xmloff::token { TOKEN("date-format", XML_DATE_FORMAT), TOKEN("date-rfc-language-tag", XML_DATE_RFC_LANGUAGE_TAG), TOKEN("plain-text", XML_PLAIN_TEXT), + TOKEN("alias", XML_ALIAS), + TOKEN("tag", XML_TAG), TOKEN("fill-use-slide-background", XML_FILL_USE_SLIDE_BACKGROUND), diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index bbbf5f26b931..f2b10130f71b 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -4036,6 +4036,20 @@ void XMLTextParagraphExport::ExportContentControl( sax::Converter::convertBool(aBuffer, bComboBox); GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_COMBOBOX, aBuffer.makeStringAndClear()); } + + OUString aAlias; + xPropertySet->getPropertyValue("Alias") >>= aAlias; + if (!aAlias.isEmpty()) + { + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_ALIAS, aAlias); + } + + OUString aTag; + xPropertySet->getPropertyValue("Tag") >>= aTag; + if (!aTag.isEmpty()) + { + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_TAG, aTag); + } } SvXMLElementExport aElem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_CONTENT_CONTROL, false, diff --git a/xmloff/source/text/xmlcontentcontrolcontext.cxx b/xmloff/source/text/xmlcontentcontrolcontext.cxx index 0df8d79e9f84..379bbe309bd2 100644 --- a/xmloff/source/text/xmlcontentcontrolcontext.cxx +++ b/xmloff/source/text/xmlcontentcontrolcontext.cxx @@ -133,6 +133,16 @@ void XMLContentControlContext::startFastElement( } break; } + case XML_ELEMENT(LO_EXT, XML_ALIAS): + { + m_aAlias = rIter.toString(); + break; + } + case XML_ELEMENT(LO_EXT, XML_TAG): + { + m_aTag = rIter.toString(); + break; + } default: XMLOFF_WARN_UNKNOWN("xmloff", rIter); } @@ -228,6 +238,16 @@ void XMLContentControlContext::endFastElement(sal_Int32) { xPropertySet->setPropertyValue("ComboBox", uno::Any(m_bComboBox)); } + + if (!m_aAlias.isEmpty()) + { + xPropertySet->setPropertyValue("Alias", uno::Any(m_aAlias)); + } + + if (!m_aTag.isEmpty()) + { + xPropertySet->setPropertyValue("Tag", uno::Any(m_aTag)); + } } css::uno::Reference<css::xml::sax::XFastContextHandler> diff --git a/xmloff/source/text/xmlcontentcontrolcontext.hxx b/xmloff/source/text/xmlcontentcontrolcontext.hxx index e507b02e85cd..0bfca015ec68 100644 --- a/xmloff/source/text/xmlcontentcontrolcontext.hxx +++ b/xmloff/source/text/xmlcontentcontrolcontext.hxx @@ -50,6 +50,8 @@ class XMLContentControlContext : public SvXMLImportContext OUString m_aCurrentDate; bool m_bPlainText = false; bool m_bComboBox = false; + OUString m_aAlias; + OUString m_aTag; public: XMLContentControlContext(SvXMLImport& rImport, sal_Int32 nElement, XMLHints_Impl& rHints, diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 506b9a4cb0e4..5fef52535c63 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3254,5 +3254,7 @@ picture date-format date-rfc-language-tag plain-text +alias +tag fill-use-slide-background TOKEN_END_DUMMY commit 36bffa3cb5d30a6f58253c627ba23d1cde6864c8 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Oct 18 11:11:11 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Oct 18 12:40:16 2022 +0200 sc: Add new wrapper for these tests Change-Id: Idfa3dc085a944fb8ffe5819b08ba9a264d58900b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141490 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/datatransformation_test.cxx b/sc/qa/unit/datatransformation_test.cxx index 9e9f66e4655a..7f33aa21548a 100644 --- a/sc/qa/unit/datatransformation_test.cxx +++ b/sc/qa/unit/datatransformation_test.cxx @@ -12,18 +12,14 @@ #include "helper/qahelper.hxx" #include <document.hxx> #include <datatransformation.hxx> -#include <scdll.hxx> #include <svl/numformat.hxx> #include <tools/time.hxx> -class ScDataTransformationTest : public test::BootstrapFixture +class ScDataTransformationTest : public ScSimpleBootstrapFixture { public: - ScDataTransformationTest(); - virtual void setUp() override; - virtual void tearDown() override; void testColumnRemove(); void testColumnSplit(); @@ -112,10 +108,6 @@ public: CPPUNIT_TEST(testGetMinute); CPPUNIT_TEST(testGetSecond); CPPUNIT_TEST_SUITE_END(); - -private: - ScDocShellRef m_xDocShell; - ScDocument *m_pDoc; }; void ScDataTransformationTest::testColumnRemove() @@ -1000,34 +992,12 @@ void ScDataTransformationTest::testGetSecond() CPPUNIT_ASSERT_DOUBLES_EQUAL(49, m_pDoc->GetValue(2, 3, 0), 0); } -ScDataTransformationTest::ScDataTransformationTest() : - m_pDoc(nullptr) -{ -} - void ScDataTransformationTest::setUp() { - BootstrapFixture::setUp(); - - ScDLL::Init(); - m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - - m_xDocShell->SetIsInUcalc(); - m_xDocShell->DoInitUnitTest(); - m_pDoc = &m_xDocShell->GetDocument(); + ScSimpleBootstrapFixture::setUp(); m_pDoc->InsertTab(0, "Tab"); } -void ScDataTransformationTest::tearDown() -{ - m_xDocShell->DoClose(); - m_xDocShell.clear(); - BootstrapFixture::tearDown(); -} - CPPUNIT_TEST_SUITE_REGISTRATION(ScDataTransformationTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index a6249972e801..6b520bcd2774 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -40,6 +40,7 @@ #include <sfx2/frame.hxx> #include <undoblk.hxx> #include <unotools/tempfile.hxx> +#include <scdll.hxx> #include <scitems.hxx> #include <stringutil.hxx> #include <tokenarray.hxx> @@ -928,6 +929,29 @@ void ScBootstrapFixture::tearDown() test::BootstrapFixture::tearDown(); } +void ScSimpleBootstrapFixture::setUp() +{ + BootstrapFixture::setUp(); + + ScDLL::Init(); + + m_xDocShell + = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS + | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + m_xDocShell->SetIsInUcalc(); + m_xDocShell->DoInitUnitTest(); + + m_pDoc = &m_xDocShell->GetDocument(); +} + +void ScSimpleBootstrapFixture::tearDown() +{ + m_xDocShell->DoClose(); + m_xDocShell.clear(); + + test::BootstrapFixture::tearDown(); +} + std::string to_std_string(const OUString& rStr) { return std::string(rStr.toUtf8().getStr()); diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 78a3fa1eddda..caa449c6a6a9 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -236,6 +236,17 @@ public: virtual void tearDown() override; }; +class SCQAHELPER_DLLPUBLIC ScSimpleBootstrapFixture : public test::BootstrapFixture +{ +public: + virtual void setUp() override; + virtual void tearDown() override; + +protected: + ScDocShellRef m_xDocShell; + ScDocument* m_pDoc; +}; + #define ASSERT_DOUBLES_EQUAL( expected, result ) \ CPPUNIT_ASSERT_DOUBLES_EQUAL( (expected), (result), 1e-14 ) diff --git a/sc/qa/unit/parallelism.cxx b/sc/qa/unit/parallelism.cxx index eb084b95e516..eea2afa4b70a 100644 --- a/sc/qa/unit/parallelism.cxx +++ b/sc/qa/unit/parallelism.cxx @@ -3,7 +3,6 @@ #include <sal/config.h> #include <test/bootstrapfixture.hxx> -#include <scdll.hxx> #include <sfx2/sfxmodelfactory.hxx> #include "helper/qahelper.hxx" @@ -22,11 +21,9 @@ using namespace css; using namespace css::uno; -class ScParallelismTest : public test::BootstrapFixture +class ScParallelismTest : public ScSimpleBootstrapFixture { public: - ScParallelismTest(); - virtual void setUp() override; virtual void tearDown() override; @@ -78,16 +75,9 @@ private: static ScUndoCut* cutToClip(ScDocShell& rDocSh, const ScRange& rRange, ScDocument* pClipDoc, bool bCreateUndo); static void pasteFromClip(ScDocument* pDestDoc, const ScRange& rDestRange, ScDocument* pClipDoc); - ScDocument *m_pDoc; - - ScDocShellRef m_xDocShell; bool m_bThreadingFlagCfg; }; -ScParallelismTest::ScParallelismTest() -{ -} - bool ScParallelismTest::getThreadingFlag() const { return officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::get(); @@ -143,15 +133,7 @@ void ScParallelismTest::pasteFromClip(ScDocument* pDestDoc, const ScRange& rDest void ScParallelismTest::setUp() { - test::BootstrapFixture::setUp(); - - ScDLL::Init(); - - m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_pDoc = &m_xDocShell->GetDocument(); + ScSimpleBootstrapFixture::setUp(); sc::FormulaGroupInterpreter::disableOpenCL_UnitTestsOnly(); @@ -166,10 +148,7 @@ void ScParallelismTest::tearDown() if (!m_bThreadingFlagCfg) setThreadingFlag(false); - m_xDocShell->DoClose(); - m_xDocShell.clear(); - - test::BootstrapFixture::tearDown(); + ScSimpleBootstrapFixture::tearDown(); } void ScParallelismTest::testSUMIFS() diff --git a/sc/qa/unit/range.cxx b/sc/qa/unit/range.cxx index 18e6e0768e49..30f8a1f8cc3c 100644 --- a/sc/qa/unit/range.cxx +++ b/sc/qa/unit/range.cxx @@ -8,7 +8,7 @@ */ #include <sal/config.h> -#include <test/bootstrapfixture.hxx> +#include "helper/qahelper.hxx" #include <unotools/configmgr.hxx> #include <document.hxx> #include <docsh.hxx> @@ -19,12 +19,9 @@ #include <rangeutl.hxx> #include <refupdatecontext.hxx> -class ScRangeTest : public test::BootstrapFixture +class ScRangeTest : public ScSimpleBootstrapFixture { public: - virtual void setUp() override; - virtual void tearDown() override; - CPPUNIT_TEST_SUITE(ScRangeTest); CPPUNIT_TEST(testOverlap); CPPUNIT_TEST(testRangeParsing); @@ -36,9 +33,6 @@ public: void testRangeParsing(); void testAddressParsing(); void testTdf147451(); - -private: - ScDocShellRef m_xDocShRef; }; void ScRangeTest::testOverlap() @@ -63,46 +57,25 @@ void ScRangeTest::testOverlap() void ScRangeTest::testRangeParsing() { ScRange aRange; - ScDocument& rDoc = m_xDocShRef->GetDocument(); - ScRefFlags nRes = aRange.Parse(":1", rDoc, formula::FormulaGrammar::CONV_OOO); + ScRefFlags nRes = aRange.Parse(":1", *m_pDoc, formula::FormulaGrammar::CONV_OOO); CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); } void ScRangeTest::testAddressParsing() { ScAddress aAddr; - ScDocument& rDoc = m_xDocShRef->GetDocument(); - ScRefFlags nRes = aAddr.Parse("1", rDoc, formula::FormulaGrammar::CONV_OOO); + ScRefFlags nRes = aAddr.Parse("1", *m_pDoc, formula::FormulaGrammar::CONV_OOO); CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); } void ScRangeTest::testTdf147451() { ScAddress aAddr; - ScDocument& rDoc = m_xDocShRef->GetDocument(); // "Sheet1" is technically a valid address like "XF1", but it should overflow. - ScRefFlags nRes = aAddr.Parse("Sheet1", rDoc, formula::FormulaGrammar::CONV_OOO); + ScRefFlags nRes = aAddr.Parse("Sheet1", *m_pDoc, formula::FormulaGrammar::CONV_OOO); CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); } -void ScRangeTest::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - m_xDocShRef = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); -} - -void ScRangeTest::tearDown() -{ - m_xDocShRef->DoClose(); - m_xDocShRef.clear(); - BootstrapFixture::tearDown(); -} - class ScRangeUpdaterTest : public CppUnit::TestFixture { public: diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx index 040c8835aac1..48d95dddfcbc 100644 --- a/sc/qa/unit/rangelst_test.cxx +++ b/sc/qa/unit/rangelst_test.cxx @@ -8,23 +8,14 @@ */ #include <sal/config.h> -#include <test/bootstrapfixture.hxx> +#include "helper/qahelper.hxx" #include <docsh.hxx> -#include <scdll.hxx> #include <rangelst.hxx> -class Test : public test::BootstrapFixture +class Test : public ScSimpleBootstrapFixture { public: - Test() - : m_pDoc(nullptr) - { - } - - virtual void setUp() override; - virtual void tearDown() override; - void testDeleteArea_4Ranges(); void testDeleteArea_3Ranges(); void testDeleteArea_3Ranges_Case2(); @@ -84,32 +75,8 @@ public: CPPUNIT_TEST(testInsertRow); CPPUNIT_TEST(testInsertCol); CPPUNIT_TEST_SUITE_END(); - -private: - ScDocument *m_pDoc; - ScDocShellRef m_xDocShRef; }; -void Test::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - m_xDocShRef = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - - m_pDoc = &m_xDocShRef->GetDocument(); -} - -void Test::tearDown() -{ - m_xDocShRef->DoClose(); - m_xDocShRef.clear(); - BootstrapFixture::tearDown(); -} - void Test::testDeleteArea_4Ranges() { ScRangeList aList(ScRange(0,0,0,5,5,0)); diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 271ddc83ee5a..325b3ffbeca3 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -12,7 +12,6 @@ #include <svl/asiancfg.hxx> -#include <scdll.hxx> #include <simpleformulacalc.hxx> #include <stringutil.hxx> #include <scmatrix.hxx> @@ -68,20 +67,13 @@ class ScUndoPaste; class ScUndoCut; -class Test : public test::BootstrapFixture +class Test : public ScSimpleBootstrapFixture { public: - Test(); - void checkPrecisionAsShown(OUString& rCode, double fValue, double fExpectedRoundVal); /** Get a separate new ScDocShell with ScDocument that suits unit test needs. */ void getNewDocShell(ScDocShellRef& rDocShellRef); - /** Close such new ScDocShell. */ - void closeDocShell(ScDocShellRef& rDocShellRef); - - virtual void setUp() override; - virtual void tearDown() override; void testCollator(); void testSharedStringPool(); @@ -330,16 +322,8 @@ public: CPPUNIT_TEST(testProtectedSheetEditByColumn); CPPUNIT_TEST(testInsertColumnsWithFormulaCells); CPPUNIT_TEST_SUITE_END(); - -private: - ScDocShellRef m_xDocShell; - ScDocument* m_pDoc; }; -Test::Test() -{ -} - void Test::getNewDocShell( ScDocShellRef& rDocShellRef ) { rDocShellRef = new ScDocShell( @@ -351,28 +335,6 @@ void Test::getNewDocShell( ScDocShellRef& rDocShellRef ) rDocShellRef->DoInitUnitTest(); } -void Test::closeDocShell( ScDocShellRef& rDocShellRef ) -{ - rDocShellRef->DoClose(); - rDocShellRef.clear(); -} - -void Test::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - - getNewDocShell(m_xDocShell); - m_pDoc = &m_xDocShell->GetDocument(); -} - -void Test::tearDown() -{ - closeDocShell(m_xDocShell); - BootstrapFixture::tearDown(); -} - void Test::testCollator() { sal_Int32 nRes = ScGlobal::GetCollator().compareString("A", "B"); @@ -1127,7 +1089,8 @@ void Test::testCopyToDocument() m_pDoc->GetNote(ScAddress(0, 0, 0))->GetText(), pDestDoc->GetNote(ScAddress(0, 0, 0))->GetText()); pDestDoc->DeleteTab(0); - closeDocShell(xDocSh2); + xDocSh2->DoClose(); + xDocSh2.clear(); m_pDoc->DeleteTab(0); } @@ -5261,7 +5224,8 @@ void Test::testNoteLifeCycle() aClipDoc2.ClosingClipboardSource(); pDoc2->DeleteTab(0); - closeDocShell(xDocSh2); + xDocSh2->DoClose(); + xDocSh2.clear(); pasteFromClip( m_pDoc, aPosB5, &aClipDoc2); // should not crash... tdf#104967 ScPostIt* pNoteB5 = m_pDoc->GetNote(aPosB5); diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx index c5738bf42569..031114770207 100644 --- a/sc/qa/unit/ucalc_condformat.cxx +++ b/sc/qa/unit/ucalc_condformat.cxx @@ -15,7 +15,6 @@ #include <globstr.hrc> #include <scresid.hxx> #include <docfunc.hxx> -#include <scdll.hxx> #include <scitems.hxx> #include <attrib.hxx> #include <fillinfo.hxx> @@ -87,14 +86,9 @@ sal_uInt32 addSingleCellCondFormat(ScDocument* pDoc, const ScAddress& rAddr, sal } -class TestCondformat : public test::BootstrapFixture +class TestCondformat : public ScSimpleBootstrapFixture { public: - TestCondformat(); - - virtual void setUp() override; - virtual void tearDown() override; - void testCondFormatINSDEL(); void testCondFormatInsertRow(); void testCondFormatInsertCol(); @@ -176,40 +170,8 @@ public: CPPUNIT_TEST(testFormulaListenerUpdateDeleteTab); CPPUNIT_TEST_SUITE_END(); - -private: - ScDocShellRef m_xDocShell; - ScDocument* m_pDoc; }; -TestCondformat::TestCondformat() -{ -} - -void TestCondformat::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - - m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_xDocShell->SetIsInUcalc(); - m_xDocShell->DoInitUnitTest(); - - m_pDoc = &m_xDocShell->GetDocument(); -} - -void TestCondformat::tearDown() -{ - m_xDocShell->DoClose(); - m_xDocShell.clear(); - - test::BootstrapFixture::tearDown(); -} - void TestCondformat::testCondFormatINSDEL() { // fdo#62206 diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx index 148accac85f9..497a309461ab 100644 --- a/sc/qa/unit/ucalc_copypaste.cxx +++ b/sc/qa/unit/ucalc_copypaste.cxx @@ -25,23 +25,16 @@ #include <postit.hxx> #include <queryparam.hxx> #include <refundo.hxx> -#include <scdll.hxx> #include <scitems.hxx> #include <scopetools.hxx> -#include <test/bootstrapfixture.hxx> #include <sfx2/docfile.hxx> #include <memory> -class TestCopyPaste : public test::BootstrapFixture +class TestCopyPaste : public ScSimpleBootstrapFixture { public: - TestCopyPaste(); - - virtual void setUp() override; - virtual void tearDown() override; - void testCopyPaste(); void testCopyPasteAsLink(); void testCopyPasteTranspose(); @@ -250,9 +243,6 @@ public: CPPUNIT_TEST_SUITE_END(); private: - ScDocShellRef m_xDocShell; - ScDocument* m_pDoc; - enum CalcMode { NoCalc, @@ -326,31 +316,6 @@ private: OUString getNote(SCCOL nCol, SCROW nRow, SCTAB nTab); }; -TestCopyPaste::TestCopyPaste() {} - -void TestCopyPaste::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - - m_xDocShell - = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS - | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_xDocShell->SetIsInUcalc(); - m_xDocShell->DoInitUnitTest(); - - m_pDoc = &m_xDocShell->GetDocument(); -} - -void TestCopyPaste::tearDown() -{ - m_xDocShell->DoClose(); - m_xDocShell.clear(); - - test::BootstrapFixture::tearDown(); -} - static ScMF lcl_getMergeFlagOfCell(const ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab) { const SfxPoolItem& rPoolItem = rDoc.GetPattern(nCol, nRow, nTab)->GetItem(ATTR_MERGE_FLAG); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 1ade8026f3bc..337028bfbd4f 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -7,7 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/bootstrapfixture.hxx> #include "helper/debughelper.hxx" #include "helper/qahelper.hxx" #include <clipparam.hxx> @@ -24,7 +23,6 @@ #include <docpool.hxx> #include <docoptio.hxx> #include <externalrefmgr.hxx> -#include <scdll.hxx> #include <scmod.hxx> #include <undomanager.hxx> @@ -188,14 +186,9 @@ public: } -class TestFormula : public test::BootstrapFixture +class TestFormula : public ScSimpleBootstrapFixture { public: - TestFormula(); - - virtual void setUp() override; - virtual void tearDown() override; - void testFormulaCreateStringFromTokens(); void testFormulaParseReference(); void testFetchVectorRefArray(); @@ -437,40 +430,8 @@ public: CPPUNIT_TEST(testFuncJumpMatrixArrayOFFSET); CPPUNIT_TEST_SUITE_END(); - -private: - ScDocShellRef m_xDocShell; - ScDocument* m_pDoc; }; -TestFormula::TestFormula() -{ -} - -void TestFormula::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - - m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_xDocShell->SetIsInUcalc(); - m_xDocShell->DoInitUnitTest(); - - m_pDoc = &m_xDocShell->GetDocument(); -} - -void TestFormula::tearDown() -{ - m_xDocShell->DoClose(); - m_xDocShell.clear(); - - test::BootstrapFixture::tearDown(); -} - void TestFormula::testFormulaCreateStringFromTokens() { // Insert sheets. diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx index 3d2d159a8f96..e2b7380ef713 100644 --- a/sc/qa/unit/ucalc_pivottable.cxx +++ b/sc/qa/unit/ucalc_pivottable.cxx @@ -8,7 +8,6 @@ */ #include <rtl/math.hxx> -#include <scdll.hxx> #include "helper/qahelper.hxx" #include <dpshttab.hxx> #include <dpobject.hxx> @@ -191,14 +190,9 @@ ScRange refreshGroups(ScDPCollection* pDPs, ScDPObject* pDPObj) } -class TestPivottable : public test::BootstrapFixture +class TestPivottable : public ScSimpleBootstrapFixture { public: - TestPivottable(); - - virtual void setUp() override; - virtual void tearDown() override; - /** * Basic test for pivot tables. */ @@ -310,40 +304,8 @@ public: CPPUNIT_TEST(testPivotTableMedianFunc); CPPUNIT_TEST_SUITE_END(); - -private: - ScDocShellRef m_xDocShell; - ScDocument* m_pDoc; }; -TestPivottable::TestPivottable() -{ -} - -void TestPivottable::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - - m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_xDocShell->SetIsInUcalc(); - m_xDocShell->DoInitUnitTest(); - - m_pDoc = &m_xDocShell->GetDocument(); -} - -void TestPivottable::tearDown() -{ - m_xDocShell->DoClose(); - m_xDocShell.clear(); - - test::BootstrapFixture::tearDown(); -} - void TestPivottable::testPivotTable() { m_pDoc->InsertTab(0, "Data"); diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 254269bf9716..e82d21dc3b03 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -19,23 +19,16 @@ #include <globalnames.hxx> #include <dbdata.hxx> #include <bcaslot.hxx> -#include <scdll.hxx> #include <undomanager.hxx> #include <sfx2/docfile.hxx> -#include <test/bootstrapfixture.hxx> #include <memory> #include <string_view> -class TestSharedFormula : public test::BootstrapFixture +class TestSharedFormula : public ScSimpleBootstrapFixture { public: - TestSharedFormula(); - - virtual void setUp() override; - virtual void tearDown() override; - void testSharedFormulas(); void testSharedFormulasRefUpdate(); void testSharedFormulasRefUpdateMove(); @@ -95,41 +88,8 @@ public: CPPUNIT_TEST(testSharedFormulaInsertShift); CPPUNIT_TEST_SUITE_END(); - -private: - ScDocShellRef m_xDocShell; - ScDocument* m_pDoc; }; - -TestSharedFormula::TestSharedFormula() -{ -} - -void TestSharedFormula::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - - m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_xDocShell->SetIsInUcalc(); - m_xDocShell->DoInitUnitTest(); - - m_pDoc = &m_xDocShell->GetDocument(); -} - -void TestSharedFormula::tearDown() -{ - m_xDocShell->DoClose(); - m_xDocShell.clear(); - - test::BootstrapFixture::tearDown(); -} - void TestSharedFormula::testSharedFormulas() { m_pDoc->InsertTab(0, "Test"); diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx index 21b734d1d37c..f3008d85a131 100644 --- a/sc/qa/unit/ucalc_sort.cxx +++ b/sc/qa/unit/ucalc_sort.cxx @@ -11,7 +11,6 @@ #include "helper/debughelper.hxx" #include "helper/qahelper.hxx" -#include <scdll.hxx> #include <postit.hxx> #include <sortparam.hxx> #include <dbdata.hxx> @@ -32,14 +31,9 @@ #include <svx/svdpage.hxx> #include <rtl/math.hxx> -class TestSort : public test::BootstrapFixture +class TestSort : public ScSimpleBootstrapFixture { public: - TestSort(); - - virtual void setUp() override; - virtual void tearDown() override; - void testSort(); void testSortHorizontal(); void testSortHorizontalWholeColumn(); @@ -86,41 +80,8 @@ public: CPPUNIT_TEST(testQueryBinarySearch); CPPUNIT_TEST_SUITE_END(); - -private: - ScDocShellRef m_xDocShell; - ScDocument* m_pDoc; }; - -TestSort::TestSort() -{ -} - -void TestSort::setUp() -{ - BootstrapFixture::setUp(); - - ScDLL::Init(); - - m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_xDocShell->SetIsInUcalc(); - m_xDocShell->DoInitUnitTest(); - - m_pDoc = &m_xDocShell->GetDocument(); -} - -void TestSort::tearDown() -{ - m_xDocShell->DoClose(); - m_xDocShell.clear(); - - test::BootstrapFixture::tearDown(); -} - void TestSort::testSort() { m_pDoc->InsertTab(0, "test1");