From 5a64b618d84edb65465950d54e3b4afc952a301c Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 1 Mar 2022 06:54:49 +0200 Subject: [PATCH] followup tdf#122098 xlsx export: avoid corrupt format if not bool value Although I can't find any documents that cause a "b" when the value is not 1 or 0, if such should ever happen, then Excel complains about an invalid format and fails to load. (The formatting looks a bit weird, but that is what clang-format produces. How nice.) Change-Id: I090a27829596260cdd6379b6a6daa75ce250b7e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130734 Tested-by: Jenkins Reviewed-by: Justin Luth --- sc/source/filter/excel/xestream.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 2178b0b3abc7..08048e922111 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -673,7 +673,10 @@ void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& rsT rsValue = ToOUString(lcl_GetErrorString(aResValue.mnError)); break; case sc::FormulaResultValue::Value: - rsType = rCell.GetFormatType() == SvNumFormatType::LOGICAL ? "b" : "n"; + rsType = rCell.GetFormatType() == SvNumFormatType::LOGICAL + && (aResValue.mfValue == 0.0 || aResValue.mfValue == 1.0) + ? "b" + : "n"; rsValue = OUString::number(aResValue.mfValue); break; case sc::FormulaResultValue::String: