You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ji...@apache.org on 2026/10/22 20:28:52 UTC
(openoffice) 07/08: xmloff: write a non-0/1 boolean cell value as a float
This is an automated email from the ASF dual-hosted git repository.
jimjag pushed a commit to branch odf-devel
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 4250607123a41ae3080c43f5d896a0c16f391c1f
Author: Jim Jagielski <ji...@gmail.com>
AuthorDate: Thu Oct 22 16:27:15 2026 -0400
xmloff: write a non-0/1 boolean cell value as a float
---
main/xmloff/source/style/numehelp.cxx | 62 +++++++++++++++++------------------
1 file changed, 30 insertions(+), 32 deletions(-)
diff --git a/main/xmloff/source/style/numehelp.cxx b/main/xmloff/source/style/numehelp.cxx
index 3be8575c66..b74f40be6b 100644
--- a/main/xmloff/source/style/numehelp.cxx
+++ b/main/xmloff/source/style/numehelp.cxx
@@ -189,33 +189,32 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(SvXMLExport& rXMLExp
break;
case util::NumberFormat::LOGICAL:
{
+ const sal_Bool bIsTrue = ::rtl::math::approxEqual( rValue, 1.0 );
+ const sal_Bool bIsFalse = ::rtl::math::approxEqual( rValue, 0.0 );
+ const sal_Bool bAsFloat = bExportValue && !bIsTrue && !bIsFalse;
if (!bWasSetTypeAttribute)
{
- rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_BOOLEAN);
+ rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, bAsFloat ? XML_FLOAT : XML_BOOLEAN);
bWasSetTypeAttribute = sal_True;
}
if (bExportValue)
{
- double fTempValue = rValue;
- if (::rtl::math::approxEqual( fTempValue, 1.0 ))
+ if (bIsTrue)
{
rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TRUE);
}
+ else if (bIsFalse)
+ {
+ rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_FALSE);
+ }
else
{
- if (::rtl::math::approxEqual( rValue, 0.0 ))
- {
- rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_FALSE);
- }
- else
- {
- rtl::OUString sValue( ::rtl::math::doubleToUString(
- fTempValue,
- rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max, '.',
- sal_True));
- rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, sValue);
- }
+ rtl::OUString sValue( ::rtl::math::doubleToUString(
+ rValue,
+ rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, '.',
+ sal_True));
+ rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE, sValue);
}
}
}
@@ -472,33 +471,32 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
break;
case util::NumberFormat::LOGICAL:
{
+ const sal_Bool bIsTrue = ::rtl::math::approxEqual( rValue, 1.0 );
+ const sal_Bool bIsFalse = ::rtl::math::approxEqual( rValue, 0.0 );
+ const sal_Bool bAsFloat = bExportValue && !bIsTrue && !bIsFalse;
if (!bWasSetTypeAttribute)
{
- pExport->AddAttribute(sAttrValueType, XML_BOOLEAN);
+ pExport->AddAttribute(sAttrValueType, bAsFloat ? XML_FLOAT : XML_BOOLEAN);
bWasSetTypeAttribute = sal_True;
}
if (bExportValue)
{
- double fTempValue = rValue;
- if (::rtl::math::approxEqual( fTempValue, 1.0 ))
+ if (bIsTrue)
{
pExport->AddAttribute(sAttrBooleanValue, XML_TRUE);
}
+ else if (bIsFalse)
+ {
+ pExport->AddAttribute(sAttrBooleanValue, XML_FALSE);
+ }
else
{
- if (::rtl::math::approxEqual( rValue, 0.0 ))
- {
- pExport->AddAttribute(sAttrBooleanValue, XML_FALSE);
- }
- else
- {
- rtl::OUString sValue( ::rtl::math::doubleToUString(
- fTempValue,
- rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max, '.',
- sal_True));
- pExport->AddAttribute(sAttrBooleanValue, sValue);
- }
+ rtl::OUString sValue( ::rtl::math::doubleToUString(
+ rValue,
+ rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, '.',
+ sal_True));
+ pExport->AddAttribute(sAttrValue, sValue);
}
}
}