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

Eike Rathke erack at redhat.com
Fri Mar 22 15:42:50 PDT 2013


 sc/source/core/data/validat.cxx |   29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

New commits:
commit fdd9f2dbdf7c703cbc8519af932194ebdf95d77c
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Mar 22 23:39:54 2013 +0100

    use input line string length for numeric data length, i#93128
    
    3620920babb60177dc2b8e1f61c75cf08cc0f949 checked the raw input data
    length.
    
    Change-Id: Iebb6e9c4a532b73a64f41261ee8bd382adbe701d

diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index dd3ff74..4e1b1f5 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -429,26 +429,39 @@ sal_Bool ScValidationData::IsDataValid( const String& rTest, const ScPatternAttr
 
     // get the value if any
     sal_uInt32 nFormat = rPattern.GetNumberFormat( pFormatter );
-
     double nVal;
     sal_Bool bIsVal = pFormatter->IsNumberFormat( rTest, nFormat, nVal );
-    ScBaseCell* pCell;
-    if (bIsVal)
-        pCell = new ScValueCell( nVal );
-    else
-        pCell = new ScStringCell( rTest );
 
     sal_Bool bRet;
     if (SC_VALID_TEXTLEN == eDataMode)
     {
-        const double nLenVal = static_cast<double>( rTest.Len() );
+        double nLenVal;
+        if (!bIsVal)
+            nLenVal = static_cast<double>( rTest.Len() );
+        else
+        {
+            // For numeric values use the resulting input line string to
+            // determine length, otherwise a once accepted value maybe could
+            // not be edited again, for example abbreviated dates or leading
+            // zeros or trailing zeros after decimal separator change length.
+            String aStr;
+            pFormatter->GetInputLineString( nVal, nFormat, aStr);
+            nLenVal = static_cast<double>( aStr.Len() );
+        }
         ScValueCell aTmpCell( nLenVal );
         bRet = IsCellValid( &aTmpCell, rPos );
     }
     else
+    {
+        ScBaseCell* pCell;
+        if (bIsVal)
+            pCell = new ScValueCell( nVal );
+        else
+            pCell = new ScStringCell( rTest );
         bRet = IsDataValid( pCell, rPos );
+        pCell->Delete();
+    }
 
-    pCell->Delete();
     return bRet;
 }
 


More information about the Libreoffice-commits mailing list