sw/inc/calc.hxx | 3 +++ sw/source/core/bastyp/calc.cxx | 3 ++- sw/source/core/fields/fldbas.cxx | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-)
New commits: commit 82ed010cd39351adcd4015e2bdd1591aa869cf18 Author: Eike Rathke <er...@redhat.com> AuthorDate: Sat Apr 1 17:30:54 2023 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Sun Apr 2 11:29:11 2023 +0200 Resolves: tdf#154218 Use the proper document's SwCalc locale for formula field ... instead of the format's locale to generate the expanded value string to be reinterpreted again. i.e. inherited by SwSetExpField used with Set variable. Change-Id: I0bb545282a50032f2d8d2965020a36e3c5c8914e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149911 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx index e91ede14e6a5..87583f752ff4 100644 --- a/sw/inc/calc.hxx +++ b/sw/inc/calc.hxx @@ -22,6 +22,7 @@ #include <memory> #include <vector> +#include <i18nlangtag/lang.h> #include <basic/sbxvar.hxx> #include <unotools/syslocale.hxx> #include <rtl/ustrbuf.hxx> @@ -260,6 +261,8 @@ public: static bool Str2Double( const OUString& rStr, sal_Int32& rPos, double& rVal, SwDoc const *const pDoc ); + static LanguageType GetDocAppScriptLang( SwDoc const & rDoc ); + SW_DLLPUBLIC static bool IsValidVarName( const OUString& rStr, OUString* pValidName = nullptr ); }; diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index 592f969bde0b..d6b09766fb40 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -195,7 +195,8 @@ CalcOp* FindOperator( const OUString& rSrch ) OperatorCompare )); } -static LanguageType GetDocAppScriptLang( SwDoc const & rDoc ) +// static +LanguageType SwCalc::GetDocAppScriptLang( SwDoc const & rDoc ) { TypedWhichId<SvxLanguageItem> nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 80ae487f93fe..2f816d208938 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -807,6 +807,7 @@ void SwFormulaField::SetFormula(const OUString& rStr) { sal_Int32 nPos = 0; double fTmpValue; + // Uses the SwCalc document locale. if( SwCalc::Str2Double( rStr, nPos, fTmpValue, GetDoc() ) ) SwValueField::SetValue( fTmpValue ); } @@ -824,7 +825,10 @@ void SwFormulaField::SetExpandedFormula( const OUString& rStr ) { SwValueField::SetValue(fTmpValue); - m_sFormula = static_cast<SwValueFieldType *>(GetTyp())->DoubleToString(fTmpValue, nFormat); + // Will get reinterpreted by SwCalc when updating fields, so use + // the proper locale. + m_sFormula = static_cast<SwValueFieldType *>(GetTyp())->DoubleToString( fTmpValue, + SwCalc::GetDocAppScriptLang( *GetDoc())); return; } }