[Libreoffice-commits] core.git: sc/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Fri May 29 21:37:00 UTC 2020


 sc/source/ui/app/inputhdl.cxx |   15 ++++++++++-----
 sc/source/ui/inc/inputhdl.hxx |    3 ++-
 2 files changed, 12 insertions(+), 6 deletions(-)

New commits:
commit ad46c30506fbb9cdbf51310b48401ec37bdc8b8a
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Fri May 29 00:22:14 2020 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Fri May 29 23:36:25 2020 +0200

    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 at redhat.com>

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;


More information about the Libreoffice-commits mailing list