From 730e6fa063fccbd12913362dd5d3c74ea14957be Mon Sep 17 00:00:00 2001 From: Baole Fang Date: Sat, 27 May 2023 21:05:01 -0400 Subject: tdf#131638: Fix text cell incorrect formula Change-Id: I086f077540f52c6ed5fb4df9f0ea64aa95aea152 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152348 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sc/source/ui/view/viewfunc.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 78080364e928..bc149f62b40e 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -408,8 +408,11 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, bool bFormula = false; + // do not check formula if it is a text cell + sal_uInt32 format = rDoc.GetNumberFormat( nCol, nRow, nTab ); + SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); // a single '=' character is handled as string (needed for special filters) - if ( rString.getLength() > 1 ) + if ( pFormatter->GetType(format) != SvNumFormatType::TEXT && rString.getLength() > 1 ) { if ( rString[0] == '=' ) { @@ -431,10 +434,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, // is non-empty and not a number, handle as formula if ( aString.getLength() > 1 ) { - sal_uInt32 nFormat = rDoc.GetNumberFormat( nCol, nRow, nTab ); - SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); double fNumber = 0; - if ( !pFormatter->IsNumberFormat( aString, nFormat, fNumber ) ) + if ( !pFormatter->IsNumberFormat( aString, format, fNumber ) ) { bFormula = true; } @@ -568,7 +569,6 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, ScFormulaCell aCell(rDoc, aPos, std::move( pArr ), formula::FormulaGrammar::GRAM_DEFAULT, ScMatrixMode::NONE); - SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); for (const auto& rTab : rMark) { i = rTab; -- cgit