From e3307e5e76d5c35ee79b262d519c4a777acce536 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 27 Jan 2021 16:05:54 +0100 Subject: tdf#123476 filter: Also handle empty ODF This builds on top of commit ada07f303e7cd1e39c73abe0741aefe7d9d73a57, to allow 0-byte ODT, ODS etc. Possible TODO would be somehow use default template for such empty files, getting the template name using SfxObjectFactory::GetStandardTemplate. That would enable using 0-byte ODF files as means to "create new document at this location from default template" workflow. Change-Id: I36e07b80f60c42aecdcc6a7357e5bdd18f62e4f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109989 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit 2854362f429e476d4a1ab4759c6a1f1c04150280) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110060 Reviewed-by: Michael Stahl --- filter/qa/unit/data/empty.odp | 0 filter/qa/unit/data/empty.odt | 0 filter/qa/unit/textfilterdetect.cxx | 20 ++++++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 filter/qa/unit/data/empty.odp create mode 100644 filter/qa/unit/data/empty.odt (limited to 'filter') diff --git a/filter/qa/unit/data/empty.odp b/filter/qa/unit/data/empty.odp new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/filter/qa/unit/data/empty.odt b/filter/qa/unit/data/empty.odt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/filter/qa/unit/textfilterdetect.cxx b/filter/qa/unit/textfilterdetect.cxx index fb1ff1d2ac7e..56dccf8914b9 100644 --- a/filter/qa/unit/textfilterdetect.cxx +++ b/filter/qa/unit/textfilterdetect.cxx @@ -91,6 +91,26 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile) // Without the accompanying fix in place, this test would have failed, as it was opened in // Writer instead. CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument")); + + getComponent()->dispose(); + + // Now also test ODT + aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "empty.odt"; + getComponent() = loadFromDesktop(aURL); + xServiceInfo.set(getComponent(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xServiceInfo.is()); + // Make sure it opens in Writer. + CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextDocument")); + getComponent()->dispose(); + + // ... and ODP + aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "empty.odp"; + getComponent() = loadFromDesktop(aURL); + xServiceInfo.set(getComponent(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xServiceInfo.is()); + // Without the accompanying fix in place, this test would have failed, as it was opened in + // Writer instead. + CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument")); } } -- cgit