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

Herbert Dürr hdu at apache.org
Fri Mar 22 15:42:01 PDT 2013


 sc/source/core/data/validat.cxx |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

New commits:
commit 3620920babb60177dc2b8e1f61c75cf08cc0f949
Author: Herbert Dürr <hdu at apache.org>
Date:   Wed Aug 1 12:47:33 2012 +0000

    i#93128# fix data validity check
    
    for criteria "Allow text length" and numeric cells
    
    Patch-by: Zhang Lu
    Reported-by: amy2008, eberlein
    Review-by: Herbert Duerr
    (cherry picked from commit 3a4882779d58e382abb866fc848d6c7a935181de)
    
    Conflicts:
    	sc/source/core/data/validat.cxx
    
    Change-Id: I7c528da3cf2e12122cecbbde3ec84684307f3248

diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 5b74716..dd3ff74 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -416,19 +416,18 @@ sal_Bool ScValidationData::DoError( Window* pParent, const String& rInput,
 sal_Bool ScValidationData::IsDataValid( const String& rTest, const ScPatternAttr& rPattern,
                                     const ScAddress& rPos ) const
 {
-    if ( eDataMode == SC_VALID_ANY )
-        return sal_True;                        // alles erlaubt
+    if ( eDataMode == SC_VALID_ANY ) // check if any cell content is allowed
+        return sal_True;
 
-    if ( rTest.GetChar(0) == '=' )
-        return false;                       // Formeln sind sonst immer ungueltig
+    if ( rTest.GetChar(0) == '=' )   // formulas do not pass the validity test
+        return sal_False;
 
-    if ( !rTest.Len() )
-        return IsIgnoreBlank();             // leer: wie eingestellt
+    if ( !rTest.Len() )              // check whether empty cells are allowed
+        return IsIgnoreBlank();
 
     SvNumberFormatter* pFormatter = GetDocument()->GetFormatTable();
 
-    //  Test, was es denn ist - wie in ScColumn::SetString
-
+    // get the value if any
     sal_uInt32 nFormat = rPattern.GetNumberFormat( pFormatter );
 
     double nVal;
@@ -439,7 +438,15 @@ sal_Bool ScValidationData::IsDataValid( const String& rTest, const ScPatternAttr
     else
         pCell = new ScStringCell( rTest );
 
-    sal_Bool bRet = IsDataValid( pCell, rPos );
+    sal_Bool bRet;
+    if (SC_VALID_TEXTLEN == eDataMode)
+    {
+        const double nLenVal = static_cast<double>( rTest.Len() );
+        ScValueCell aTmpCell( nLenVal );
+        bRet = IsCellValid( &aTmpCell, rPos );
+    }
+    else
+        bRet = IsDataValid( pCell, rPos );
 
     pCell->Delete();
     return bRet;


More information about the Libreoffice-commits mailing list