filter/qa/unit/textfilterdetect.cxx             |    9 +++++++++
 filter/source/textfilterdetect/filterdetect.cxx |    7 ++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 44f00ff35c7ea5ed2bfb56fe1abab8c72ead7316
Author:     Szymon Kłos <[email protected]>
AuthorDate: Thu Jan 6 09:45:30 2022 +0100
Commit:     Szymon Kłos <[email protected]>
CommitDate: Mon Jan 31 17:05:28 2022 +0100

    Unit test for 0-byte ods detection
    
    Fixed by commit:
    d9a4e323555d01202dd15e71a3a32294bfd568cc
    Open empty (0 bytes) ods as spreadsheet
    
    Change-Id: I9b7220f46f5d00f6e4a73d6325dca51d7ea5b656
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128033
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129166
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <[email protected]>

diff --git a/filter/qa/unit/data/empty.ods b/filter/qa/unit/data/empty.ods
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/filter/qa/unit/textfilterdetect.cxx 
b/filter/qa/unit/textfilterdetect.cxx
index 62d0d60a23a7..bbb9b91b527f 100644
--- a/filter/qa/unit/textfilterdetect.cxx
+++ b/filter/qa/unit/textfilterdetect.cxx
@@ -103,6 +103,15 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile)
     
CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextDocument"));
     getComponent()->dispose();
 
+    // ... and ODS
+    aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "empty.ods";
+    getComponent() = loadFromDesktop(aURL);
+    xServiceInfo.set(getComponent(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xServiceInfo.is());
+    // Make sure it opens in Calc.
+    
CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument"));
+    getComponent()->dispose();
+
     // ... and ODP
     aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "empty.odp";
     getComponent() = loadFromDesktop(aURL);
commit 972760951b3c7a064f482b924c65fd670056d299
Author:     Szymon Kłos <[email protected]>
AuthorDate: Wed Jan 5 17:29:49 2022 +0100
Commit:     Szymon Kłos <[email protected]>
CommitDate: Mon Jan 31 17:05:18 2022 +0100

    Open empty (0 bytes) ods as spreadsheet
    
    Before this patch we opened it with Writer UI because
    we didn't detect any filter with PREFFERED annotation
    
    Change-Id: I6262fb695b5fe20a377120f298f144e2cafbadc9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128015
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129165
    Tested-by: Szymon Kłos <[email protected]>
    Reviewed-by: Szymon Kłos <[email protected]>

diff --git a/filter/source/textfilterdetect/filterdetect.cxx 
b/filter/source/textfilterdetect/filterdetect.cxx
index f8fc5cb865eb..d852ef24c63e 100644
--- a/filter/source/textfilterdetect/filterdetect.cxx
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -155,7 +155,12 @@ bool HandleEmptyFileUrlByExtension(MediaDescriptor& 
rMediaDesc, const OUString&
     std::shared_ptr<const SfxFilter> 
pFilter(SfxFilterMatcher().GetFilter4Extension(rExt, nMust));
     if (!pFilter)
     {
-        return false;
+        // retry without PREFFERED so we can find at least something for 
0-byte *.ods
+        nMust = SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT;
+        pFilter = SfxFilterMatcher().GetFilter4Extension(rExt, nMust);
+
+        if (!pFilter)
+            return false;
     }
 
     rMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= pFilter->GetFilterName();

Reply via email to