summaryrefslogtreecommitdiff
path: root/sc/source/ui/app
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-05-29 00:22:14 +0200
committerEike Rathke <erack@redhat.com>2020-05-30 02:43:02 +0200
commit575e938641c643e58fea8e7bdabfee87daeffedd (patch)
tree2ad5537f88ce958d3d480787beff5e842e32d726 /sc/source/ui/app
parentd895ea993a789fa2bc2d113700ad54b4b7c49172 (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> (cherry picked from commit 0ed29654eb06958e619994c892b5dbc7d0419fd7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95128
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r--sc/source/ui/app/inputhdl.cxx15
1 files changed, 10 insertions, 5 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)
{