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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 27 10:35:55 UTC 2020


 basic/source/sbx/sbxvalue.cxx |   30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

New commits:
commit dff273cc00b21b909e5f7b936d6713e9effc89cf
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Oct 27 12:25:40 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Oct 27 11:35:18 2020 +0100

    Put may succeed even if outer error is set
    
    And use SbxValues ctor taking SbxDataType for simplicity
    
    Change-Id: I25622bae33597a8782d9451f88eadce1cf07388d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104860
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index fb8f8518573e..90edef4cb7e7 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -361,8 +361,7 @@ SbxValues SbxValue::Get(SbxDataType t) const
 
 const OUString& SbxValue::GetCoreString() const
 {
-    SbxValues aRes;
-    aRes.eType = SbxCoreSTRING;
+    SbxValues aRes(SbxCoreSTRING);
     if( Get( aRes ) )
     {
         const_cast<SbxValue*>(this)->aToolString = *aRes.pOUString;
@@ -377,8 +376,7 @@ const OUString& SbxValue::GetCoreString() const
 OUString SbxValue::GetOUString() const
 {
     OUString aResult;
-    SbxValues aRes;
-    aRes.eType = SbxSTRING;
+    SbxValues aRes(SbxSTRING);
     if( Get( aRes ) )
     {
         aResult = *aRes.pOUString;
@@ -506,12 +504,10 @@ void SbxValue::PutStringExt( const OUString& r )
     SbxDataType eTargetType = SbxDataType( aData.eType & 0x0FFF );
 
     // tinker a Source-Value
-    SbxValues aRes;
-    aRes.eType = SbxSTRING;
+    SbxValues aRes(SbxSTRING);
 
     // Only if really something was converted, take the copy,
     // otherwise take the original (Unicode remains)
-    bool bRet;
     if( ImpConvStringExt( aStr, eTargetType ) )
         aRes.pOUString = &aStr;
     else
@@ -530,8 +526,7 @@ void SbxValue::PutStringExt( const OUString& r )
             SetFlag( SbxFlagBits::Fixed );
     }
 
-    Put( aRes );
-    bRet = bool( !IsError() );
+    const bool bRet = Put(aRes);
 
     // If FIXED resulted in an error, set it back
     // (UI-Action should not result in an error, but simply fail)
@@ -543,11 +538,9 @@ void SbxValue::PutStringExt( const OUString& r )
 
 bool SbxValue::PutBool( bool b )
 {
-    SbxValues aRes;
-    aRes.eType = SbxBOOL;
+    SbxValues aRes(SbxBOOL);
     aRes.nUShort = sal::static_int_cast< sal_uInt16 >(b ? SbxTRUE : SbxFALSE);
-    Put( aRes );
-    return !IsError();
+    return Put(aRes);
 }
 
 bool SbxValue::PutEmpty()
@@ -587,17 +580,15 @@ void SbxValue::fillAutomationDecimal
 
 bool SbxValue::PutString( const OUString& r )
 {
-    SbxValues aRes;
-    aRes.eType = SbxSTRING;
+    SbxValues aRes(SbxSTRING);
     aRes.pOUString = const_cast<OUString*>(&r);
-    Put( aRes );
-    return !IsError();
+    return Put(aRes);
 }
 
 
 #define PUT( p, e, t, m ) \
 bool SbxValue::p( t n ) \
-{ SbxValues aRes(e); aRes.m = n; Put( aRes ); return !IsError(); }
+{ SbxValues aRes(e); aRes.m = n; return Put(aRes); }
 
 void SbxValue::PutDate( double n )
 { SbxValues aRes(SbxDATE); aRes.nDouble = n; Put( aRes ); }
@@ -758,8 +749,7 @@ bool SbxValue::Convert( SbxDataType eTo )
     }
 
     // Conversion of the data:
-    SbxValues aNew;
-    aNew.eType = eTo;
+    SbxValues aNew(eTo);
     if( Get( aNew ) )
     {
         // The data type could be converted. It ends here with fixed elements,


More information about the Libreoffice-commits mailing list