summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-10-28 14:54:52 +0100
committerAndras Timar <andras.timar@collabora.com>2020-10-31 22:52:59 +0100
commit44ee2734c1ae6d58e8aee0ff79cfebdf8aef4457 (patch)
tree391f9a628c785c139c9a19c89023b928a9bd5135 /sfx2
parentc7952cb2646f7c385b68f8e7acce5cf2713c567c (diff)
tdf#123476 filter: try to detect 0-byte files based on extension
A 0-byte ("empty") pptx file is obviously junk input, so it's not surprising if the catch-all generic_Text filter is chosen to open it in Writer at the end. But we can do better: if we really get an empty file URL with an extension we can recognize, that we can fake the filter type / filter name, so the empty "presentation" opens in Impress, and also a re-save works as expected. This builds on top of commit 8a201be240b6d408d15166be7ffc576b9e123634 (fdo#68903 Import .tsv and .xls plain text files in Calc by default, 2013-10-27), just the new way works for all supported file extensions and also with filters which would not handle empty input (e.g. pptx refuses the import if the ZIP storage is broken). Change-Id: Ie01650a5eb6ca42c35e090133965467b621bb526 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104939 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105039 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/objstor.cxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 66ec9a8d16f6..50ec51f7e546 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2220,7 +2220,11 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium,
// #i119492# During loading, some OLE objects like chart will be set
// modified flag, so needs to reset the flag to false after loading
- bool bRtn = xLoader->filter( aArgs );
+ bool bRtn = true;
+ if (!tools::isEmptyFileUrl(rMedium.GetName()))
+ {
+ bRtn = xLoader->filter(aArgs);
+ }
uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames();
for ( sal_Int32 n = 0; n < aNames.getLength(); ++n )
{