summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-27 20:00:51 -0400
committerFridrich Strba <fridrich@documentfoundation.org>2013-07-28 12:59:25 +0000
commit8c1e1d99f10894718975300a052358de7e3fef2c (patch)
tree20cca75bbc2ad93930eb840d914cc15f847b09df
parentdcb4053a43fc71841abcb25ebde90555c36f2bfe (diff)
fdo#67246: Detect BIFF 2 (and 3) file format like we should.
(cherry picked from commit b46688a663b8709e0e0795f25ef8961db1f46cba) Change-Id: I1421cca4b0ef8e9410aab5725cc5a8d9cffef7a9 Reviewed-on: https://gerrit.libreoffice.org/5145 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--sc/source/ui/unoobj/exceldetect.cxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/sc/source/ui/unoobj/exceldetect.cxx b/sc/source/ui/unoobj/exceldetect.cxx
index db040e3e46f7..fb15a3cbbbc3 100644
--- a/sc/source/ui/unoobj/exceldetect.cxx
+++ b/sc/source/ui/unoobj/exceldetect.cxx
@@ -74,6 +74,10 @@ bool hasStream(const uno::Reference<io::XInputStream>& xInStream, const OUString
return xStorage->IsStream(rName);
}
+/**
+ * We detect BIFF 2, 3 and 4 file types together since the only thing that
+ * set them apart is the BOF ID.
+ */
bool isExcel40(const uno::Reference<io::XInputStream>& xInStream)
{
SfxMedium aMedium;
@@ -93,12 +97,18 @@ bool isExcel40(const uno::Reference<io::XInputStream>& xInStream)
sal_uInt16 nBofId, nBofSize;
*pStream >> nBofId >> nBofSize;
- if (nBofId != 0x0409)
- // This ID signifies Excel 4.0 format. It must be 0x0409.
- return false;
+ switch (nBofId)
+ {
+ case 0x0009: // Excel 2.1 worksheet (BIFF 2)
+ case 0x0209: // Excel 3.0 worksheet (BIFF 3)
+ case 0x0409: // Excel 4.0 worksheet (BIFF 4)
+ break;
+ default:
+ return false;
+ }
if (nBofSize < 4 || 16 < nBofSize)
- // BOF record must be sized between 4 and 16 for Excel 4.0 stream.
+ // BOF record must be sized between 4 and 16 for BIFF 2, 3 and 4.
return false;
sal_Size nPos = pStream->Tell();