sc/source/ui/app/inputhdl.cxx | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
New commits: commit f7d71fe0641995344eac290effa3c1552454fb36 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Oct 18 17:28:37 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Oct 21 12:51:22 2023 +0200 fix crash in ScInputHandler::ImplCreateEditEngine() See https://crashreport.libreoffice.org/stats/crash_details/1b2c45b0-6053-4628-94cc-f639899ceb39 Regression from 5484657d2b1677b7e385ab6ef87ad64dcb9934e4 "tdf#156209 Font size increases when copying from cell in edit mode" Change-Id: I84cac26087b0c8908c22bbb45056e309cd66a016 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158123 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 51678d9cf57085bac3c7eba998e0a6d364d36cb2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158049 diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 1267509d4e5f..0735feb01a9b 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -3068,6 +3068,9 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL && pActiveViewSh != SfxViewShell::Current()) return; + if (!pActiveViewSh) + return; + // Macro calls for validity can cause a lot of problems, so inhibit // nested calls of EnterHandler(). if (bInEnterHandler) return; @@ -3097,7 +3100,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL lcl_SelectionToEnd(pTableView); } - vcl::Window* pFrameWin = pActiveViewSh ? pActiveViewSh->GetFrameWin() : nullptr; + vcl::Window* pFrameWin = pActiveViewSh->GetFrameWin(); if (pTopView) pTopView->CompleteAutoCorrect(); // CompleteAutoCorrect for both Views @@ -3109,7 +3112,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL lcl_RemoveTabs(aPreAutoCorrectString); // Test if valid (always with simple string) - if (bModified && nValidation && pActiveViewSh) + if (bModified && nValidation) { ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocument(); const ScValidationData* pData = rDoc.GetValidationEntry( nValidation ); @@ -3159,7 +3162,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL } // Check for input into DataPilot table - if ( bModified && pActiveViewSh && !bForget ) + if ( bModified && !bForget ) { ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocument(); ScDPObject* pDPObj = rDoc.GetDPAtCursor( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab() ); @@ -3181,21 +3184,18 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL { // #i3820# If the spell checker flags numerical input as error, // it still has to be treated as number, not EditEngine object. - if ( pActiveViewSh ) + ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocument(); + // #i67990# don't use pLastPattern in EnterHandler + const ScPatternAttr* pPattern = rDoc.GetPattern( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab() ); + if (pPattern) { - ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocument(); - // #i67990# don't use pLastPattern in EnterHandler - const ScPatternAttr* pPattern = rDoc.GetPattern( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab() ); - if (pPattern) + SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); + // without conditional format, as in ScColumn::SetString + sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter ); + double nVal; + if ( pFormatter->IsNumberFormat( aString, nFormat, nVal ) ) { - SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); - // without conditional format, as in ScColumn::SetString - sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter ); - double nVal; - if ( pFormatter->IsNumberFormat( aString, nFormat, nVal ) ) - { - bSpellErrors = false; // ignore the spelling errors - } + bSpellErrors = false; // ignore the spelling errors } } } @@ -3229,7 +3229,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL const SfxPoolItem* pItem = nullptr; // Find common (cell) attributes before RemoveAdjust - if ( pActiveViewSh && bUniformAttribs ) + if ( bUniformAttribs ) { std::optional<SfxItemSet> pCommonAttrs; for (sal_uInt16 nId = EE_CHAR_START; nId <= EE_CHAR_END; nId++)