sc/source/filter/oox/sheetdatacontext.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
New commits: commit 3e7702774b7309e8fa07930d2960e4e619bfb291 Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Apr 27 14:56:36 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Apr 28 10:53:55 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 (cherry picked from commit e45d77a41139aad38151f4d8e48fd894fd9811a6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151119 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> 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 );