diff options
-rw-r--r-- | filter/qa/unit/data/empty.odp | 0 | ||||
-rw-r--r-- | filter/qa/unit/data/empty.odt | 0 | ||||
-rw-r--r-- | filter/qa/unit/textfilterdetect.cxx | 20 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 6 |
4 files changed, 24 insertions, 2 deletions
diff --git a/filter/qa/unit/data/empty.odp b/filter/qa/unit/data/empty.odp new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/filter/qa/unit/data/empty.odp diff --git a/filter/qa/unit/data/empty.odt b/filter/qa/unit/data/empty.odt new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/filter/qa/unit/data/empty.odt diff --git a/filter/qa/unit/textfilterdetect.cxx b/filter/qa/unit/textfilterdetect.cxx index cc86fe04c3d5..3bd019aa0685 100644 --- a/filter/qa/unit/textfilterdetect.cxx +++ b/filter/qa/unit/textfilterdetect.cxx @@ -94,6 +94,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")); } } diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 50ec51f7e546..d8d0104ac315 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -438,7 +438,7 @@ bool SfxObjectShell::InitNew( const uno::Reference< embed::XStorage >& xStorage bool SfxObjectShell::Load( SfxMedium& rMedium ) { - return GeneralInit_Impl( rMedium.GetStorage(), true ); + return GeneralInit_Impl(rMedium.GetStorage(), !tools::isEmptyFileUrl(rMedium.GetName())); } void SfxObjectShell::DoInitUnitTest() @@ -674,7 +674,9 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed ) bWarnMediaTypeFallback = false; } - if ( bWarnMediaTypeFallback || !xStorage->getElementNames().getLength() ) + if (bWarnMediaTypeFallback + || (!tools::isEmptyFileUrl(pMedium->GetName()) + && !xStorage->getElementNames().getLength())) SetError(ERRCODE_IO_BROKENPACKAGE); } catch( uno::Exception& ) |