summaryrefslogtreecommitdiff
path: root/include/tools/stream.hxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-10-28 14:54:52 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-10-28 19:34:45 +0100
commitada07f303e7cd1e39c73abe0741aefe7d9d73a57 (patch)
treefd8c81e5404da2909394a250fce7b8ecdc77b28e /include/tools/stream.hxx
parentdb6c7a486395304f38e9ea52951f576f34749cbc (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
Diffstat (limited to 'include/tools/stream.hxx')
-rw-r--r--include/tools/stream.hxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 0d88c014da65..42084e6566fc 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -568,6 +568,12 @@ inline std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream& rStrm,
[[nodiscard]] TOOLS_DLLPUBLIC bool checkSeek(SvStream &rSt, sal_uInt64 nOffset);
+namespace tools
+{
+/// Is rUrl a file:// URL with no contents?
+TOOLS_DLLPUBLIC bool isEmptyFileUrl(const OUString& rUrl);
+}
+
// FileStream
class TOOLS_DLLPUBLIC SvFileStream final : public SvStream