summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/qa/unit/data/empty.doc0
-rw-r--r--filter/qa/unit/textfilterdetect.cxx20
-rw-r--r--filter/source/textfilterdetect/filterdetect.cxx6
-rw-r--r--sfx2/source/doc/objstor.cxx10
4 files changed, 34 insertions, 2 deletions
diff --git a/filter/qa/unit/data/empty.doc b/filter/qa/unit/data/empty.doc
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/filter/qa/unit/data/empty.doc
diff --git a/filter/qa/unit/textfilterdetect.cxx b/filter/qa/unit/textfilterdetect.cxx
index 56dccf8914b9..500e886f5199 100644
--- a/filter/qa/unit/textfilterdetect.cxx
+++ b/filter/qa/unit/textfilterdetect.cxx
@@ -111,6 +111,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();
+
+ // ... and DOC
+ aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "empty.doc";
+ // Without the accompanying fix in place, this test would have failed, the import filter aborted
+ // loading.
+ getComponent() = loadFromDesktop(aURL);
+ xServiceInfo.set(getComponent(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo.is());
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextDocument"));
+ uno::Reference<frame::XModel> xModel(getComponent(), uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aArgs = xModel->getArgs();
+ comphelper::SequenceAsHashMap aMap(aArgs);
+ OUString aFilterName;
+ aMap["FilterName"] >>= aFilterName;
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: MS Word 97
+ // - Actual : MS WinWord 6.0
+ // i.e. opening worked, but saving back failed instead of producing a WW8 binary file.
+ CPPUNIT_ASSERT_EQUAL(OUString("MS Word 97"), aFilterName);
}
}
diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx
index 19696ec9fa17..915020aa117c 100644
--- a/filter/source/textfilterdetect/filterdetect.cxx
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -148,7 +148,11 @@ bool HandleEmptyFileUrlByExtension(MediaDescriptor& rMediaDesc, const OUString&
return false;
}
- std::shared_ptr<const SfxFilter> pFilter(SfxFilterMatcher().GetFilter4Extension(rExt));
+ // Requiring the export+preferred flags helps to find the relevant filter, e.g. .doc -> WW8 (and
+ // not WW6 or Mac_Word).
+ SfxFilterFlags nMust
+ = SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::PREFERED;
+ std::shared_ptr<const SfxFilter> pFilter(SfxFilterMatcher().GetFilter4Extension(rExt, nMust));
if (!pFilter)
{
return false;
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index fd85ce09aabb..9b696bdc0bcb 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -753,7 +753,15 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed )
}
else
{
- bOk = ConvertFrom(*pMedium);
+ if (tools::isEmptyFileUrl(pMedium->GetName()))
+ {
+ // The import filter would fail with empty input.
+ bOk = true;
+ }
+ else
+ {
+ bOk = ConvertFrom(*pMedium);
+ }
InitOwnModel_Impl();
}
}