sc/source/filter/oox/sheetdatacontext.cxx |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit e59fdc8b800aa3ab551b3f4fec4bc58366df582e
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Thu Apr 27 14:56:36 2023 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Thu Apr 27 18:19:05 2023 +0200

    Resolves: tdf#155046 Accept true and false as 1 and 0 for OOXML boolean 
cells
    
    Encountered in the wild written by
    https://www.npmjs.com/package/excel4node
    
https://github.com/advisr-io/excel4node/blob/c14213abb9a511ff786c574e473f53006a85e4f9/source/lib/cell/cell.js#L74
    
    Change-Id: Ib21242a55f0d8530fd9120b07a096a9908f451bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151101
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/source/filter/oox/sheetdatacontext.cxx 
b/sc/source/filter/oox/sheetdatacontext.cxx
index c1a270afb41a..bc5855e9f4b7 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -185,7 +185,16 @@ void SheetDataContext::onEndElement()
             mrSheetData.setValueCell( maCellData, maCellValue.toDouble() );
         break;
         case XML_b:
-            mrSheetData.setBooleanCell( maCellData, maCellValue.toDouble() != 
0.0 );
+            {
+                // Some generators may write true or false instead of 1 or 0.
+                /* XXX NOTE: PivotCacheItem::readBool() may suffer from this as
+                 * well, but for now let's assume that software writing this
+                 * here wrong won't write pivot caches at all.. */
+                bool bValue = (maCellValue.toDouble() != 0.0);
+                if (!bValue && maCellValue.equalsIgnoreAsciiCase(u"true"))
+                    bValue = true;
+                mrSheetData.setBooleanCell( maCellData, bValue );
+            }
         break;
         case XML_e:
             mrSheetData.setErrorCell( maCellData, maCellValue );

Reply via email to