[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Sun Jul 28 05:59:45 PDT 2013


 sc/source/ui/unoobj/exceldetect.cxx |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 8c1e1d99f10894718975300a052358de7e3fef2c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Sat Jul 27 20:00:51 2013 -0400

    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 at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/sc/source/ui/unoobj/exceldetect.cxx b/sc/source/ui/unoobj/exceldetect.cxx
index db040e3..fb15a3c 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();


More information about the Libreoffice-commits mailing list