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

Noel Grandin noel at peralex.com
Tue Aug 26 02:30:34 PDT 2014


 basctl/source/basicide/basobj2.cxx     |    2 
 basic/source/classes/eventatt.cxx      |    2 
 basic/source/classes/sb.cxx            |   10 ++--
 basic/source/classes/sbunoobj.cxx      |    8 +--
 basic/source/classes/sbxmod.cxx        |   10 ++--
 basic/source/comp/codegen.cxx          |    2 
 basic/source/comp/dim.cxx              |    2 
 basic/source/runtime/methods.cxx       |    2 
 basic/source/runtime/methods1.cxx      |    6 +-
 basic/source/runtime/runtime.cxx       |   18 ++++----
 basic/source/runtime/stdobj.cxx        |    4 -
 basic/source/sbx/sbxarray.cxx          |   10 ++--
 basic/source/sbx/sbxbase.cxx           |   16 ++++---
 basic/source/sbx/sbxexec.cxx           |    2 
 basic/source/sbx/sbxobj.cxx            |    8 +--
 basic/source/sbx/sbxvalue.cxx          |    4 -
 basic/source/sbx/sbxvar.cxx            |    6 +-
 include/basic/sbx.hxx                  |    6 +-
 include/basic/sbxcore.hxx              |   30 +++++++-------
 include/basic/sbxdef.hxx               |   68 ++++++++++++++++++++++-----------
 scripting/source/basprov/basscript.cxx |    2 
 21 files changed, 123 insertions(+), 95 deletions(-)

New commits:
commit 37b9ea92ba81d74764a2345a9c75c65bfd272d2b
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Aug 21 14:41:58 2014 +0200

    convert SBX flag bits to type-safe enum
    
    Change-Id: I18d5d6a27f06ee60a5cb3dc393bf05b51bba4817
    Reviewed-on: https://gerrit.libreoffice.org/11070
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index f2edd2b..eee39ba 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -228,7 +228,7 @@ namespace
         // take ownership of the data
         boost::scoped_ptr< MacroExecutionData > pData( i_pData );
 
-        SAL_WARN_IF( !(pData->xMethod->GetParent()->GetFlags() & SBX_EXTSEARCH), "basctl.basicide","No EXTSEARCH!" );
+        SAL_WARN_IF( (pData->xMethod->GetParent()->GetFlags() & SBX_EXTSEARCH) == SBX_NONE, "basctl.basicide","No EXTSEARCH!" );
 
         // in case this is a document-local macro, try to protect the document's Undo Manager from
         // flawed scripts
diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx
index ee75d0f..b7b6fdc 100644
--- a/basic/source/classes/eventatt.cxx
+++ b/basic/source/classes/eventatt.cxx
@@ -269,7 +269,7 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any
                     if( aName == aLibName )
                     {
                         // Search only in the lib, not automatically in application basic
-                        sal_uInt16 nFlags = pBasic->GetFlags();
+                        SbxFlagBits nFlags = pBasic->GetFlags();
                         pBasic->ResetFlag( SBX_GBLSEARCH );
                         pMethVar = pBasic->Find( aMacro, SbxCLASS_DONTCARE );
                         pBasic->SetFlags( nFlags );
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 61a1d72..db8487d 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -558,7 +558,7 @@ SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj )
                 {
                     pDest->unoAddDim( 0, -1 ); // variant array
                 }
-                sal_uInt16 nSavFlags = pVar->GetFlags();
+                SbxFlagBits nSavFlags = pVar->GetFlags();
                 pNewProp->ResetFlag( SBX_FIXED );
                 // need to reset the FIXED flag
                 // when calling PutObject ( because the type will not match Object )
@@ -648,7 +648,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule )
             SbMethod* pMethod = PTR_CAST(SbMethod, pVar );
             if( pMethod )
             {
-                sal_uInt16 nFlags_ = pMethod->GetFlags();
+                SbxFlagBits nFlags_ = pMethod->GetFlags();
                 pMethod->SetFlag( SBX_NO_BROADCAST );
                 SbMethod* pNewMethod = new SbMethod( *pMethod );
                 pNewMethod->ResetFlag( SBX_NO_BROADCAST );
@@ -700,7 +700,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule )
         SbProcedureProperty* pProcedureProp = PTR_CAST( SbProcedureProperty, pVar );
         if( pProcedureProp )
         {
-            sal_uInt16 nFlags_ = pProcedureProp->GetFlags();
+            SbxFlagBits nFlags_ = pProcedureProp->GetFlags();
             pProcedureProp->SetFlag( SBX_NO_BROADCAST );
             SbProcedureProperty* pNewProp = new SbProcedureProperty
                 ( pProcedureProp->GetName(), pProcedureProp->GetType() );
@@ -715,7 +715,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule )
             SbxProperty* pProp = PTR_CAST( SbxProperty, pVar );
             if( pProp )
             {
-                sal_uInt16 nFlags_ = pProp->GetFlags();
+                SbxFlagBits nFlags_ = pProp->GetFlags();
                 pProp->SetFlag( SBX_NO_BROADCAST );
                 SbxProperty* pNewProp = new SbxProperty( *pProp );
 
@@ -1361,7 +1361,7 @@ SbxVariable* StarBASIC::Find( const OUString& rName, SbxClassType t )
                 }
                 // otherwise check if the element is available
                 // unset GBLSEARCH-Flag (due to Rekursion)
-                sal_uInt16 nGblFlag = p->GetFlags() & SBX_GBLSEARCH;
+                SbxFlagBits nGblFlag = p->GetFlags() & SBX_GBLSEARCH;
                 p->ResetFlag( SBX_GBLSEARCH );
                 pRes = p->Find( rName, t );
                 p->SetFlag( nGblFlag );
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index f9938f5..8a5e761 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -669,7 +669,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
                     if ( pArray )
                     {
                         SbxDimArrayRef xArray = pArray;
-                        sal_uInt16 nFlags = pVar->GetFlags();
+                        SbxFlagBits nFlags = pVar->GetFlags();
                         pVar->ResetFlag( SBX_FIXED );
                         pVar->PutObject( (SbxDimArray*)xArray );
                         pVar->SetFlags( nFlags );
@@ -799,7 +799,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
             }
 
             // return the Array
-            sal_uInt16 nFlags = pVar->GetFlags();
+            SbxFlagBits nFlags = pVar->GetFlags();
             pVar->ResetFlag( SBX_FIXED );
             pVar->PutObject( (SbxDimArray*)xArray );
             pVar->SetFlags( nFlags );
@@ -2586,7 +2586,7 @@ SbxInfo* SbUnoMethod::GetInfo()
                 OUString aParamName = rInfo.aName;
 
                 SbxDataType t = SbxVARIANT;
-                sal_uInt16 nFlags_ = SBX_READ;
+                SbxFlagBits nFlags_ = SBX_READ;
                 pInfo->AddParam( aParamName, t, nFlags_ );
             }
         }
@@ -3960,7 +3960,7 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet
                     if( pVar )
                     {
                         // #95792 Avoid a second call
-                        sal_uInt16 nFlags = pVar->GetFlags();
+                        SbxFlagBits nFlags = pVar->GetFlags();
                         pVar->SetFlag( SBX_NO_BROADCAST );
                         *pRet = sbxToUnoValueImpl( pVar );
                         pVar->SetFlags( nFlags );
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 8c26024..6f1332f 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -248,7 +248,7 @@ DocObjectWrapper::invoke( const OUString& aFunctionName, const Sequence< Any >&
         sal_uInt16 n = 1;
         for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) )
         {
-            if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != 0 )
+            if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != SBX_NONE )
                 ++nSbxOptional;
             else
                 nSbxOptional = 0;
@@ -389,7 +389,7 @@ SbMethodRef DocObjectWrapper::getMethod( const OUString& aName ) throw (RuntimeE
     SbMethodRef pMethod = NULL;
     if ( m_pMod )
     {
-        sal_uInt16 nSaveFlgs = m_pMod->GetFlags();
+        SbxFlagBits nSaveFlgs = m_pMod->GetFlags();
         // Limit search to this module
         m_pMod->ResetFlag( SBX_GBLSEARCH );
         pMethod = dynamic_cast<SbMethod*>(m_pMod->SbModule::Find(aName,  SbxCLASS_METHOD));
@@ -404,7 +404,7 @@ SbPropertyRef DocObjectWrapper::getProperty( const OUString& aName ) throw (Runt
     SbPropertyRef pProperty = NULL;
     if ( m_pMod )
     {
-        sal_uInt16 nSaveFlgs = m_pMod->GetFlags();
+        SbxFlagBits nSaveFlgs = m_pMod->GetFlags();
         // Limit search to this module.
         m_pMod->ResetFlag( SBX_GBLSEARCH );
         pProperty = dynamic_cast<SbProperty*>(m_pMod->SbModule::Find(aName,  SbxCLASS_PROPERTY));
@@ -1123,7 +1123,7 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth )
             StarBASIC* pMSOMacroRuntimeLib = PTR_CAST(StarBASIC,pMSOMacroRuntimeLibVar);
             if( pMSOMacroRuntimeLib )
             {
-                sal_uInt16 nGblFlag = pMSOMacroRuntimeLib->GetFlags() & SBX_GBLSEARCH;
+                SbxFlagBits nGblFlag = pMSOMacroRuntimeLib->GetFlags() & SBX_GBLSEARCH;
                 pMSOMacroRuntimeLib->ResetFlag( SBX_GBLSEARCH );
                 SbxVariable* pAppSymbol = pMSOMacroRuntimeLib->Find( "Application", SbxCLASS_METHOD );
                 pMSOMacroRuntimeLib->SetFlag( nGblFlag );
@@ -2172,7 +2172,7 @@ void SbMethod::Broadcast( sal_uIntPtr nHintId )
         pCst = pSave;
         pSave->Broadcast( SbxHint( nHintId, pThisCopy ) );
 
-        sal_uInt16 nSaveFlags = GetFlags();
+        SbxFlagBits nSaveFlags = GetFlags();
         SetFlag( SBX_READWRITE );
         pCst = NULL;
         Put( pThisCopy->GetValues_Impl() );
diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index d71c843..5c1d06a 100644
--- a/basic/source/comp/codegen.cxx
+++ b/basic/source/comp/codegen.cxx
@@ -313,7 +313,7 @@ void SbiCodeGen::Save()
                             t = (SbxDataType) ( t | SbxARRAY );
                         }
                         // #33677 hand-over an Optional-Info
-                        sal_uInt16 nFlags = SBX_READ;
+                        SbxFlagBits nFlags = SBX_READ;
                         if( pPar->IsOptional() )
                         {
                             nFlags |= SBX_OPTIONAL;
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index a796040..a838be8 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -650,7 +650,7 @@ void SbiParser::DefType( bool bPrivate )
                     }
                     else
                         pArray->unoAddDim( 0, -1 ); // variant array
-                    sal_uInt16 nSavFlags = pTypeElem->GetFlags();
+                    SbxFlagBits nSavFlags = pTypeElem->GetFlags();
                     // need to reset the FIXED flag
                     // when calling PutObject ( because the type will not match Object )
                     pTypeElem->ResetFlag( SBX_FIXED );
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 3397f56..d6fcad2 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -4374,7 +4374,7 @@ RTLFUNC(StrConv)
         }
 
         SbxVariableRef refVar = rPar.Get(0);
-        sal_uInt16 nFlags = refVar->GetFlags();
+        SbxFlagBits nFlags = refVar->GetFlags();
         refVar->ResetFlag( SBX_FIXED );
         refVar->PutObject( pArray );
         refVar->SetFlags( nFlags );
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 255ffd1..8a8c9ea 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -841,7 +841,7 @@ RTLFUNC(Array)
 
     // return array
     SbxVariableRef refVar = rPar.Get(0);
-    sal_uInt16 nFlags = refVar->GetFlags();
+    SbxFlagBits nFlags = refVar->GetFlags();
     refVar->ResetFlag( SBX_FIXED );
     refVar->PutObject( pArray );
     refVar->SetFlags( nFlags );
@@ -881,7 +881,7 @@ RTLFUNC(DimArray)
         pArray->unoAddDim( 0, -1 );
     }
     SbxVariableRef refVar = rPar.Get(0);
-    sal_uInt16 nFlags = refVar->GetFlags();
+    SbxFlagBits nFlags = refVar->GetFlags();
     refVar->ResetFlag( SBX_FIXED );
     refVar->PutObject( pArray );
     refVar->SetFlags( nFlags );
@@ -1831,7 +1831,7 @@ RTLFUNC(Split)
 
     // return array
     SbxVariableRef refVar = rPar.Get(0);
-    sal_uInt16 nFlags = refVar->GetFlags();
+    SbxFlagBits nFlags = refVar->GetFlags();
     refVar->ResetFlag( SBX_FIXED );
     refVar->PutObject( pArray );
     refVar->SetFlags( nFlags );
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index bfa5bc5..c7de8ab 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1711,7 +1711,7 @@ void SbiRuntime::StepPUT()
     SbxVariableRef refVar = PopVar();
     // store on its own method (inside a function)?
     bool bFlagsChanged = false;
-    sal_uInt16 n = 0;
+    SbxFlagBits n = SBX_NONE;
     if( (SbxVariable*) refVar == (SbxVariable*) pMeth )
     {
         bFlagsChanged = true;
@@ -1863,7 +1863,7 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
     else
     {
         bool bFlagsChanged = false;
-        sal_uInt16 n = 0;
+        SbxFlagBits n = SBX_NONE;
         if( (SbxVariable*) refVar == (SbxVariable*) pMeth )
         {
             bFlagsChanged = true;
@@ -2064,7 +2064,7 @@ void SbiRuntime::StepLSET()
     }
     else
     {
-        sal_uInt16 n = refVar->GetFlags();
+        SbxFlagBits n = refVar->GetFlags();
         if( (SbxVariable*) refVar == (SbxVariable*) pMeth )
         {
             refVar->SetFlag( SBX_WRITE );
@@ -2100,7 +2100,7 @@ void SbiRuntime::StepRSET()
     }
     else
     {
-        sal_uInt16 n = refVar->GetFlags();
+        SbxFlagBits n = refVar->GetFlags();
         if( (SbxVariable*) refVar == (SbxVariable*) pMeth )
         {
             refVar->SetFlag( SBX_WRITE );
@@ -2200,7 +2200,7 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar )
             // a dimension (like for Uno-Sequences of the length 0)
             pArray->unoAddDim( 0, -1 );
         }
-        sal_uInt16 nSavFlags = refVar->GetFlags();
+        SbxFlagBits nSavFlags = refVar->GetFlags();
         refVar->ResetFlag( SBX_FIXED );
         refVar->PutObject( pArray );
         refVar->SetFlags( nSavFlags );
@@ -2333,7 +2333,7 @@ void SbiRuntime::StepREDIMP_ERASE()
 
 static void lcl_clearImpl( SbxVariableRef& refVar, SbxDataType& eType )
 {
-    sal_uInt16 nSavFlags = refVar->GetFlags();
+    SbxFlagBits nSavFlags = refVar->GetFlags();
     refVar->ResetFlag( SBX_FIXED );
     refVar->SetType( SbxDataType(eType & 0x0FFF) );
     refVar->SetFlags( nSavFlags );
@@ -3553,7 +3553,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt
             // shall the type be converted?
             SbxDataType t2 = pElem->GetType();
             bool bSet = false;
-            if( !( pElem->GetFlags() & SBX_FIXED ) )
+            if( (pElem->GetFlags() & SBX_FIXED) == SBX_NONE )
             {
                 if( t != SbxVARIANT && t != t2 &&
                     t >= SbxINTEGER && t <= SbxSTRING )
@@ -3566,7 +3566,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt
 
             // remove potential rests of the last call of the SbxMethod
             // free Write before, so that there's no error
-            sal_uInt16 nSavFlags = pElem->GetFlags();
+            SbxFlagBits nSavFlags = pElem->GetFlags();
             pElem->SetFlag( SBX_READWRITE | SBX_NO_BROADCAST );
             pElem->SbxValue::Clear();
             pElem->SetFlags( nSavFlags );
@@ -4115,7 +4115,7 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
             if ( pInfo )
             {
                 const SbxParamInfo* pParam = pInfo->GetParam( i );
-                if( pParam && ( (pParam->nFlags & SBX_OPTIONAL) != 0 ) )
+                if( pParam && ( (pParam->nFlags & SBX_OPTIONAL) != SBX_NONE ) )
                 {
                     // Default value?
                     sal_uInt16 nDefaultId = (sal_uInt16)(pParam->nUserData & 0x0ffff);
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index af89c8f..9a69bea 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -789,7 +789,7 @@ SbxVariable* SbiStdObject::Find( const OUString& rName, SbxClassType t )
         if( bFound )
         {
             // isolate Args-fields:
-            short nAccess = ( p->nArgs & _RWMASK ) >> 8;
+            SbxFlagBits nAccess = static_cast<SbxFlagBits>(( p->nArgs & _RWMASK ) >> 8);
             short nType   = ( p->nArgs & _TYPEMASK );
             if( p->nArgs & _CONST )
                 nAccess |= SBX_CONST;
@@ -869,7 +869,7 @@ SbxInfo* SbiStdObject::GetInfo( short nIdx )
     {
         p++;
         OUString aName_ = OUString::createFromAscii( p->pName );
-        sal_uInt16 nFlags_ = ( p->nArgs >> 8 ) & 0x03;
+        SbxFlagBits nFlags_ = static_cast<SbxFlagBits>(( p->nArgs >> 8 ) & 0x03);
         if( p->nArgs & _OPT )
         {
             nFlags_ |= SBX_OPTIONAL;
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index 651ef33..eafb2d2 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -408,7 +408,7 @@ SbxVariable* SbxArray::FindUserData( sal_uInt32 nData )
                 case SbxCLASS_OBJECT:
                 {
                     // Objects are not allowed to scan their parent.
-                    sal_uInt16 nOld = pEntry->mpVar->GetFlags();
+                    SbxFlagBits nOld = pEntry->mpVar->GetFlags();
                     pEntry->mpVar->ResetFlag(SBX_GBLSEARCH);
                     p = static_cast<SbxObject&>(*pEntry->mpVar).FindUserData(nData);
                     pEntry->mpVar->SetFlags(nOld);
@@ -468,7 +468,7 @@ SbxVariable* SbxArray::Find( const OUString& rName, SbxClassType t )
                 case SbxCLASS_OBJECT:
                 {
                     // Objects are not allowed to scan their parent.
-                    sal_uInt16 nOld = pEntry->mpVar->GetFlags();
+                    SbxFlagBits nOld = pEntry->mpVar->GetFlags();
                     pEntry->mpVar->ResetFlag(SBX_GBLSEARCH);
                     p = static_cast<SbxObject&>(*pEntry->mpVar).Find(rName, t);
                     pEntry->mpVar->SetFlags(nOld);
@@ -497,7 +497,7 @@ bool SbxArray::LoadData( SvStream& rStrm, sal_uInt16 nVer )
     sal_uInt16 nElem;
     Clear();
     bool bRes = true;
-    sal_uInt16 f = nFlags;
+    SbxFlagBits f = nFlags;
     nFlags |= SBX_WRITE;
     rStrm.ReadUInt16( nElem );
     nElem &= 0x7FFF;
@@ -531,14 +531,14 @@ bool SbxArray::StoreData( SvStream& rStrm ) const
     for( n = 0; n < mpVarEntries->size(); n++ )
     {
         SbxVarEntry* pEntry = (*mpVarEntries)[n];
-        if (pEntry->mpVar && !(pEntry->mpVar->GetFlags() & SBX_DONTSTORE))
+        if (pEntry->mpVar && (pEntry->mpVar->GetFlags() & SBX_DONTSTORE) == SBX_NONE)
             nElem++;
     }
     rStrm.WriteUInt16( (sal_uInt16) nElem );
     for( n = 0; n < mpVarEntries->size(); n++ )
     {
         SbxVarEntry* pEntry = (*mpVarEntries)[n];
-        if (pEntry->mpVar && !(pEntry->mpVar->GetFlags() & SBX_DONTSTORE))
+        if (pEntry->mpVar && (pEntry->mpVar->GetFlags() & SBX_DONTSTORE) == SBX_NONE)
         {
             rStrm.WriteUInt16( (sal_uInt16) n );
             if (!pEntry->mpVar->Store(rStrm))
diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx
index 766f5ef..f7458e2 100644
--- a/basic/source/sbx/sbxbase.cxx
+++ b/basic/source/sbx/sbxbase.cxx
@@ -200,12 +200,13 @@ SbxObject* SbxBase::CreateObject( const OUString& rClass )
 
 SbxBase* SbxBase::Load( SvStream& rStrm )
 {
-    sal_uInt16 nSbxId, nFlags, nVer;
+    sal_uInt16 nSbxId, nFlagsTmp, nVer;
     sal_uInt32 nCreator, nSize;
-    rStrm.ReadUInt32( nCreator ).ReadUInt16( nSbxId ).ReadUInt16( nFlags ).ReadUInt16( nVer );
+    rStrm.ReadUInt32( nCreator ).ReadUInt16( nSbxId ).ReadUInt16( nFlagsTmp ).ReadUInt16( nVer );
+    SbxFlagBits nFlags = static_cast<SbxFlagBits>(nFlagsTmp);
 
     // Correcting a foolishness of mine:
-    if( nFlags & SBX_RESERVED )
+    if( (nFlags & SBX_RESERVED) != SBX_NONE )
         nFlags = ( nFlags & ~SBX_RESERVED ) | SBX_GBLSEARCH;
 
     sal_Size nOldPos = rStrm.Tell();
@@ -256,7 +257,7 @@ void SbxBase::Skip( SvStream& rStrm )
 
 bool SbxBase::Store( SvStream& rStrm )
 {
-    if( !( nFlags & SBX_DONTSTORE ) )
+    if( ( nFlags & SBX_DONTSTORE ) == SBX_NONE )
     {
         rStrm.WriteUInt32( (sal_uInt32) GetCreator() )
              .WriteUInt16( (sal_uInt16) GetSbxId() )
@@ -330,7 +331,7 @@ SbxObject* SbxFactory::CreateObject( const OUString& )
 SbxInfo::~SbxInfo()
 {}
 
-void SbxInfo::AddParam(const OUString& rName, SbxDataType eType, sal_uInt16 nFlags)
+void SbxInfo::AddParam(const OUString& rName, SbxDataType eType, SbxFlagBits nFlags)
 {
     aParams.push_back(new SbxParamInfo(rName, eType, nFlags));
 }
@@ -354,11 +355,12 @@ bool SbxInfo::LoadData( SvStream& rStrm, sal_uInt16 nVer )
     rStrm.ReadUInt32( nHelpId ).ReadUInt16( nParam );
     while( nParam-- )
     {
-        sal_uInt16 nType, nFlags;
+        sal_uInt16 nType, nFlagsTmp;
         sal_uInt32 nUserData = 0;
         OUString aName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm,
             RTL_TEXTENCODING_ASCII_US);
-        rStrm.ReadUInt16( nType ).ReadUInt16( nFlags );
+        rStrm.ReadUInt16( nType ).ReadUInt16( nFlagsTmp );
+        SbxFlagBits nFlags = static_cast<SbxFlagBits>(nFlagsTmp);
         if( nVer > 1 )
             rStrm.ReadUInt32( nUserData );
         AddParam( aName, (SbxDataType) nType, nFlags );
diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx
index 9d34b7f..c777193 100644
--- a/basic/source/sbx/sbxexec.cxx
+++ b/basic/source/sbx/sbxexec.cxx
@@ -288,7 +288,7 @@ static SbxVariable* Element
     SbxVariableRef refVar;
     if( !aSym.isEmpty() )
     {
-        sal_uInt16 nOld = pObj->GetFlags();
+        SbxFlagBits nOld = pObj->GetFlags();
         if( pObj == pGbl )
         {
             pObj->SetFlag( SBX_GBLSEARCH );
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index 4505628..1544369 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -200,10 +200,10 @@ SbxVariable* SbxObject::FindUserData( sal_uInt32 nData )
         while( !pRes && pCur->pParent )
         {
             // I myself was already searched!
-            sal_uInt16 nOwn = pCur->GetFlags();
+            SbxFlagBits nOwn = pCur->GetFlags();
             pCur->ResetFlag( SBX_EXTSEARCH );
             // I search already global!
-            sal_uInt16 nPar = pCur->pParent->GetFlags();
+            SbxFlagBits nPar = pCur->pParent->GetFlags();
             pCur->pParent->ResetFlag( SBX_GBLSEARCH );
             pRes = pCur->pParent->FindUserData( nData );
             pCur->SetFlags( nOwn );
@@ -273,10 +273,10 @@ SbxVariable* SbxObject::Find( const OUString& rName, SbxClassType t )
         while( !pRes && pCur->pParent )
         {
             // I myself was already searched!
-            sal_uInt16 nOwn = pCur->GetFlags();
+            SbxFlagBits nOwn = pCur->GetFlags();
             pCur->ResetFlag( SBX_EXTSEARCH );
             // I search already global!
-            sal_uInt16 nPar = pCur->pParent->GetFlags();
+            SbxFlagBits nPar = pCur->pParent->GetFlags();
             pCur->pParent->ResetFlag( SBX_GBLSEARCH );
             pRes = pCur->pParent->Find( rName, t );
             pCur->SetFlags( nOwn );
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 1a5b8e2..d7e5369 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -601,7 +601,7 @@ bool SbxValue::PutStringExt( const OUString& r )
 
     // #34939: For Strings which contain a number, and if this has a Num-Type,
     // set a Fixed flag so that the type will not be changed
-    sal_uInt16 nFlags_ = GetFlags();
+    SbxFlagBits nFlags_ = GetFlags();
     if( ( eTargetType >= SbxINTEGER && eTargetType <= SbxCURRENCY ) ||
         ( eTargetType >= SbxCHAR && eTargetType <= SbxUINT ) ||
         eTargetType == SbxBOOL )
@@ -706,7 +706,7 @@ PUT( PutDecimal,  SbxDECIMAL,    SbxDecimal*,      pDecimal )
 
 bool SbxValue::IsFixed() const
 {
-    return ( (GetFlags() & SBX_FIXED) | (aData.eType & SbxBYREF) ) != 0;
+    return ((GetFlags() & SBX_FIXED) != SBX_NONE) || ((aData.eType & SbxBYREF) != 0);
 }
 
 // A variable is numeric, if it is EMPTY or really numeric
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index 6776c0b..89b712c 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -166,7 +166,7 @@ void SbxVariable::Broadcast( sal_uIntPtr nHintId )
         // Avoid further broadcasting
         SfxBroadcaster* pSave = pCst;
         pCst = NULL;
-        sal_uInt16 nSaveFlags = GetFlags();
+        SbxFlagBits nSaveFlags = GetFlags();
         SetFlag( SBX_READWRITE );
         if( mpPar.Is() )
         {
@@ -250,7 +250,7 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const
         {
             aTmp += ",";
         }
-        if( i->nFlags & SBX_OPTIONAL )
+        if( (i->nFlags & SBX_OPTIONAL) != SBX_NONE )
         {
             aTmp += OUString( SbxRes( STRING_OPTIONAL ) );
         }
@@ -589,7 +589,7 @@ bool SbxVariable::StoreData( SvStream& rStrm ) const
         // #50200 Avoid that objects , which during the runtime
         // as return-value are saved in the method as a value were saved
         SbxVariable* pThis = (SbxVariable*)this;
-        sal_uInt16 nSaveFlags = GetFlags();
+        SbxFlagBits nSaveFlags = GetFlags();
         pThis->SetFlag( SBX_WRITE );
         pThis->SbxValue::Clear();
         pThis->SetFlags( nSaveFlags );
diff --git a/include/basic/sbx.hxx b/include/basic/sbx.hxx
index 76e1bcc..c7532a1 100644
--- a/include/basic/sbx.hxx
+++ b/include/basic/sbx.hxx
@@ -52,9 +52,9 @@ struct SbxParamInfo
     const OUString aName;          // Name of the parameter
     SbxBaseRef     aTypeRef;       // Object, if object type
     SbxDataType    eType;          // Data type
-    sal_uInt16     nFlags;         // Flag-Bits
+    SbxFlagBits    nFlags;         // Flag-Bits
     sal_uInt32     nUserData;      // IDs etc.
-    SbxParamInfo( const OUString& s, SbxDataType t, sal_uInt16 n, SbxBase* b = NULL )
+    SbxParamInfo( const OUString& s, SbxDataType t, SbxFlagBits n, SbxBase* b = NULL )
         : aName( s ), aTypeRef( b ), eType( t ), nFlags( n ), nUserData( 0 ) {}
     ~SbxParamInfo() {}
 };
@@ -79,7 +79,7 @@ public:
     SbxInfo();
     SbxInfo( const OUString&, sal_uInt32 );
 
-    void                AddParam( const OUString&, SbxDataType, sal_uInt16=SBX_READ );
+    void                AddParam( const OUString&, SbxDataType, SbxFlagBits=SBX_READ );
     const SbxParamInfo* GetParam( sal_uInt16 n ) const; // index starts with 1!
     const OUString&     GetComment() const              { return aComment; }
     const OUString&     GetHelpFile() const             { return aHelpFile; }
diff --git a/include/basic/sbxcore.hxx b/include/basic/sbxcore.hxx
index 4745fe3..c755a6f 100644
--- a/include/basic/sbxcore.hxx
+++ b/include/basic/sbxcore.hxx
@@ -56,7 +56,7 @@ class BASIC_DLLPUBLIC SbxBase : virtual public SvRefBase
     virtual bool LoadData( SvStream&, sal_uInt16 );
     virtual bool StoreData( SvStream& ) const;
 protected:
-    sal_uInt16 nFlags;          // Flag-Bits
+    SbxFlagBits nFlags;          // Flag-Bits
 
     SbxBase();
     SbxBase( const SbxBase& );
@@ -65,12 +65,12 @@ protected:
     SBX_DECL_PERSIST(0,0,0);
 public:
     TYPEINFO();
-    inline void         SetFlags( sal_uInt16 n );
-    inline sal_uInt16   GetFlags() const;
-    inline void         SetFlag( sal_uInt16 n );
-    inline void         ResetFlag( sal_uInt16 n );
-    inline bool         IsSet( sal_uInt16 n ) const;
-    inline bool         IsReset( sal_uInt16 n ) const;
+    inline void         SetFlags( SbxFlagBits n );
+    inline SbxFlagBits  GetFlags() const;
+    inline void         SetFlag( SbxFlagBits n );
+    inline void         ResetFlag( SbxFlagBits n );
+    inline bool         IsSet( SbxFlagBits n ) const;
+    inline bool         IsReset( SbxFlagBits n ) const;
     inline bool         CanRead() const;
     inline bool         CanWrite() const;
     inline bool         IsModified() const;
@@ -107,23 +107,23 @@ public:
 
 typedef tools::SvRef<SbxBase> SbxBaseRef;
 
-inline void SbxBase::SetFlags( sal_uInt16 n )
+inline void SbxBase::SetFlags( SbxFlagBits n )
 { nFlags = n; }
 
-inline sal_uInt16 SbxBase::GetFlags() const
+inline SbxFlagBits SbxBase::GetFlags() const
 { return nFlags; }
 
-inline void SbxBase::SetFlag( sal_uInt16 n )
+inline void SbxBase::SetFlag( SbxFlagBits n )
 { nFlags |= n; }
 
-inline void SbxBase::ResetFlag( sal_uInt16 n )
+inline void SbxBase::ResetFlag( SbxFlagBits n )
 { nFlags &= ~n; }
 
-inline bool SbxBase::IsSet( sal_uInt16 n ) const
-{ return ( nFlags & n ) != 0; }
+inline bool SbxBase::IsSet( SbxFlagBits n ) const
+{ return ( nFlags & n ) != SBX_NONE; }
 
-inline bool SbxBase::IsReset( sal_uInt16 n ) const
-{ return ( nFlags & n ) == 0; }
+inline bool SbxBase::IsReset( SbxFlagBits n ) const
+{ return ( nFlags & n ) == SBX_NONE; }
 
 inline bool SbxBase::CanRead() const
 { return IsSet( SBX_READ ); }
diff --git a/include/basic/sbxdef.hxx b/include/basic/sbxdef.hxx
index 35ea07f..d9f3b97 100644
--- a/include/basic/sbxdef.hxx
+++ b/include/basic/sbxdef.hxx
@@ -212,29 +212,55 @@ typedef sal_uIntPtr SbxError;           // Preserve old type
 
 
 // Flag-Bits:
-#define SBX_READ        0x0001  // Read permission
-#define SBX_WRITE       0x0002  // Write permission
-#define SBX_READWRITE   0x0003  // Read/Write permission
-#define SBX_DONTSTORE   0x0004  // Don't store object
-#define SBX_MODIFIED    0x0008  // Object was changed
-#define SBX_FIXED       0x0010  // Fixed data type (SbxVariable)
-#define SBX_CONST       0x0020  // Definition of const value
-#define SBX_OPTIONAL    0x0040  // Parameter is optional
-#define SBX_HIDDEN      0x0080  // Element is invisible
-#define SBX_INVISIBLE 0x0100    // Element is not found by Find()
-#define SBX_EXTSEARCH 0x0200    // Object is searched completely
-#define SBX_EXTFOUND  0x0400    // Variable was found through extended search
-#define SBX_GBLSEARCH 0x0800    // Global search via Parents
-#define SBX_RESERVED  0x1000    // reserved
-#define SBX_PRIVATE   0x1000    // #110004, #112015, cannot conflict with SBX_RESERVED
-#define SBX_NO_BROADCAST 0x2000 // No broadcast on Get/Put
-#define SBX_REFERENCE 0x4000    // Parameter is Reference (DLL-call)
-#define SBX_NO_MODIFY 0x8000    // SetModified is suppressed
-#define SBX_WITH_EVENTS 0x0080  // Same value as unused SBX_HIDDEN
-#define SBX_DIM_AS_NEW  0x0800  // Same value as SBX_GBLSEARCH, cannot conflict as one
+enum SbxFlagBits {
+    SBX_NONE         = 0x0000,
+    SBX_READ         = 0x0001,  // Read permission
+    SBX_WRITE        = 0x0002,  // Write permission
+    SBX_READWRITE    = 0x0003,  // Read/Write permission
+    SBX_DONTSTORE    = 0x0004,  // Don't store object
+    SBX_MODIFIED     = 0x0008,  // Object was changed
+    SBX_FIXED        = 0x0010,  // Fixed data type (SbxVariable)
+    SBX_CONST        = 0x0020,  // Definition of const value
+    SBX_OPTIONAL     = 0x0040,  // Parameter is optional
+    SBX_HIDDEN       = 0x0080,  // Element is invisible
+    SBX_INVISIBLE    = 0x0100,  // Element is not found by Find()
+    SBX_EXTSEARCH    = 0x0200,  // Object is searched completely
+    SBX_EXTFOUND     = 0x0400,  // Variable was found through extended search
+    SBX_GBLSEARCH    = 0x0800,  // Global search via Parents
+    SBX_RESERVED     = 0x1000,  // reserved
+    SBX_PRIVATE      = 0x1000,  // #110004, #112015, cannot conflict with SBX_RESERVED
+    SBX_NO_BROADCAST = 0x2000,  // No broadcast on Get/Put
+    SBX_REFERENCE    = 0x4000,  // Parameter is Reference (DLL-call)
+    SBX_NO_MODIFY    = 0x8000,  // SetModified is suppressed
+    SBX_WITH_EVENTS  = 0x0080,  // Same value as unused SBX_HIDDEN
+    SBX_DIM_AS_NEW   = 0x0800,  // Same value as SBX_GBLSEARCH, cannot conflict as one
                                 // is used for objects, the other for variables only
-#define SBX_VAR_TO_DIM  0x2000  // Same value as SBX_NO_BROADCAST, cannot conflict as
+    SBX_VAR_TO_DIM   = 0x2000,  // Same value as SBX_NO_BROADCAST, cannot conflict as
                                 // used for variables without broadcaster only
+};
+// make combining these type-safe
+inline SbxFlagBits operator| (SbxFlagBits lhs, SbxFlagBits rhs)
+{
+    return static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs));
+}
+inline SbxFlagBits operator& (SbxFlagBits lhs, SbxFlagBits rhs)
+{
+    return static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs));
+}
+inline SbxFlagBits& operator|= (SbxFlagBits& lhs, SbxFlagBits rhs)
+{
+    lhs = static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs));
+    return lhs;
+}
+inline SbxFlagBits operator~ (SbxFlagBits rhs)
+{
+    return static_cast<SbxFlagBits>(0xffff & ~(static_cast<sal_uInt16>(rhs)));
+}
+inline SbxFlagBits& operator&= (SbxFlagBits& lhs, SbxFlagBits rhs)
+{
+    lhs = static_cast<SbxFlagBits>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs));
+    return lhs;
+}
 
 // Broadcaster-IDs:
 #define SBX_HINT_DYING          SFX_HINT_DYING
diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx
index f6bac03..3f7ad22 100644
--- a/scripting/source/basprov/basscript.cxx
+++ b/scripting/source/basprov/basscript.cxx
@@ -182,7 +182,7 @@ namespace basprov
                 sal_uInt16 n = 1;
                 for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) )
                 {
-                    if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != 0 )
+                    if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != SBX_NONE )
                         ++nSbxOptional;
                     else
                         nSbxOptional = 0;


More information about the Libreoffice-commits mailing list