diff options
author | Eike Rathke <erack@redhat.com> | 2020-05-29 00:22:14 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2020-05-29 23:36:25 +0200 |
commit | ad46c30506fbb9cdbf51310b48401ec37bdc8b8a (patch) | |
tree | b4970ce8d9cab8cfed721ced0fa70840e849f6df /sc/source | |
parent | bde0aac4ccf7b830b5ef21d5b9e75e62aee6aaf9 (diff) |
Resolves: tdf#133485 Append % character also for a leading decimal separator
... starting input in a percent formatted cell, as such .12 input
is recognized as valid number.
Change-Id: I97c0b5824ec8644ea58e20960aa27381607cba0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95092
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 15 | ||||
-rw-r--r-- | sc/source/ui/inc/inputhdl.hxx | 3 |
2 files changed, 12 insertions, 6 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 83079851a552..9fa0b7da23a4 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -741,6 +741,7 @@ ScInputHandler::ScInputHandler() nTipVisibleSec( nullptr ), nFormSelStart( 0 ), nFormSelEnd( 0 ), + nCellPercentFormatDecSep( 0 ), nAutoPar( 0 ), eMode( SC_INPUT_NONE ), bUseTab( false ), @@ -755,7 +756,6 @@ ScInputHandler::ScInputHandler() bCommandErrorShown( false ), bInOwnChange( false ), bProtected( false ), - bCellHasPercentFormat( false ), bLastIsSymbol( false ), mbDocumentDisposing(false), nValidation( 0 ), @@ -2359,11 +2359,13 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn if ( SfxItemState::SET == rAttrSet.GetItemState( ATTR_VALUE_FORMAT, true, &pItem ) ) { sal_uInt32 nFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue(); - bCellHasPercentFormat = ( SvNumFormatType::PERCENT == - rDoc.GetFormatTable()->GetType( nFormat ) ); + if (SvNumFormatType::PERCENT == rDoc.GetFormatTable()->GetType( nFormat )) + nCellPercentFormatDecSep = rDoc.GetFormatTable()->GetFormatDecimalSep( nFormat).toChar(); + else + nCellPercentFormatDecSep = 0; } else - bCellHasPercentFormat = false; // Default: no percent + nCellPercentFormatDecSep = 0; // Default: no percent // Validity specified? if ( SfxItemState::SET == rAttrSet.GetItemState( ATTR_VALIDDATA, true, &pItem ) ) @@ -3669,8 +3671,11 @@ bool ScInputHandler::KeyInput( const KeyEvent& rKEvt, bool bStartEdit /* = false { OUString aStrLoP; - if ( bStartEdit && bCellHasPercentFormat && ((nChar >= '0' && nChar <= '9') || nChar == '-') ) + if (bStartEdit && nCellPercentFormatDecSep != 0 && + ((nChar >= '0' && nChar <= '9') || nChar == '-' || nChar == nCellPercentFormatDecSep)) + { aStrLoP = "%"; + } if (pTableView) { diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index a71c810845d4..9f45e2b9a41e 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -83,6 +83,8 @@ private: sal_Int32 nFormSelStart; // Selection for autopilot function sal_Int32 nFormSelEnd; + sal_Unicode nCellPercentFormatDecSep; // 0:= no percent format, else which decimal separator + sal_uInt16 nAutoPar; // autom.parentheses than can be overwritten ScAddress aCursorPos; @@ -100,7 +102,6 @@ private: bool bInOwnChange:1; bool bProtected:1; - bool bCellHasPercentFormat:1; bool bLastIsSymbol:1; bool mbDocumentDisposing:1; sal_uLong nValidation; |