basic/source/runtime/methods1.cxx | 2 +- basic/source/runtime/runtime.cxx | 26 +++++++++++++------------- basic/source/sbx/sbxvalue.cxx | 28 ++++++++++++++-------------- include/tools/ref.hxx | 2 ++ 4 files changed, 30 insertions(+), 28 deletions(-)
New commits: commit 6e1d28efb3d314d553e970f197f19636ce4e0ded Author: Juan Picca <jumap...@gmail.com> Date: Sun Feb 1 00:49:08 2015 -0200 fdo#39440: replace C-style cast's * Add get() method to tools::SvRef Change-Id: I3825852176c9c37f3ee21f4fd57328b1c7451951 Reviewed-on: https://gerrit.libreoffice.org/14268 Tested-by: Michael Stahl <mst...@redhat.com> Reviewed-by: Michael Stahl <mst...@redhat.com> diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 11c8bd6..a4376de 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -1832,7 +1832,7 @@ RTLFUNC(Split) { SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); xVar->PutString( vRet[i] ); - pArray->Put( (SbxVariable*)xVar, &i ); + pArray->Put( xVar.get(), &i ); } // return array diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 0dea790..e87a109 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -1278,7 +1278,7 @@ SbiForStack* SbiRuntime::FindForStackItemForCollection( class BasicCollection* p { for (SbiForStack *p = pForStk; p; p = p->pNext) { - SbxVariable* pVar = p->refEnd.Is() ? (SbxVariable*)p->refEnd : NULL; + SbxVariable* pVar = p->refEnd.Is() ? p->refEnd.get() : NULL; if( p->eForType == FOR_EACH_COLLECTION && pVar != NULL && PTR_CAST(BasicCollection,pVar) == pCollection ) { @@ -1713,7 +1713,7 @@ void SbiRuntime::StepPUT() // store on its own method (inside a function)? bool bFlagsChanged = false; SbxFlagBits n = SBX_NONE; - if( (SbxVariable*) refVar == (SbxVariable*) pMeth ) + if( refVar.get() == static_cast<SbxVariable*>(pMeth) ) { bFlagsChanged = true; n = refVar->GetFlags(); @@ -1865,13 +1865,13 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b { bool bFlagsChanged = false; SbxFlagBits n = SBX_NONE; - if( (SbxVariable*) refVar == (SbxVariable*) pMeth ) + if( refVar.get() == static_cast<SbxVariable*>(pMeth) ) { bFlagsChanged = true; n = refVar->GetFlags(); refVar->SetFlag( SBX_WRITE ); } - SbProcedureProperty* pProcProperty = PTR_CAST(SbProcedureProperty,(SbxVariable*)refVar); + SbProcedureProperty* pProcProperty = PTR_CAST(SbProcedureProperty, refVar.get()); if( pProcProperty ) { pProcProperty->setSet( true ); @@ -1907,7 +1907,7 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b SbxObject* pObj = NULL; - pObj = PTR_CAST(SbxObject,(SbxVariable*)refVar); + pObj = PTR_CAST(SbxObject,refVar.get()); // calling GetObject on a SbxEMPTY variable raises // object not set errors, make sure its an Object @@ -2066,7 +2066,7 @@ void SbiRuntime::StepLSET() else { SbxFlagBits n = refVar->GetFlags(); - if( (SbxVariable*) refVar == (SbxVariable*) pMeth ) + if( refVar.get() == static_cast<SbxVariable*>(pMeth) ) { refVar->SetFlag( SBX_WRITE ); } @@ -2102,7 +2102,7 @@ void SbiRuntime::StepRSET() else { SbxFlagBits n = refVar->GetFlags(); - if( (SbxVariable*) refVar == (SbxVariable*) pMeth ) + if( refVar.get() == static_cast<SbxVariable*>(pMeth) ) { refVar->SetFlag( SBX_WRITE ); } @@ -3103,7 +3103,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 ) { Any aElem = p->xEnumeration->nextElement(); SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); - unoToSbxValue( (SbxVariable*)xVar, aElem ); + unoToSbxValue( xVar.get(), aElem ); (*pForStk->refVar) = *xVar; } else @@ -3239,7 +3239,7 @@ bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal, bool bOk = bDefault; SbxDataType t = refVal->GetType(); - SbxVariable* pVal = (SbxVariable*)refVal; + SbxVariable* pVal = refVal.get(); // we don't know the type of uno properties that are (maybevoid) if ( t == SbxEMPTY && refVal->ISA(SbUnoProperty) ) { @@ -3597,7 +3597,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt SbxVariableRef refTemp = pElem; // dissolve the notify while copying variable - SbxVariable* pNew = new SbxVariable( *((SbxVariable*)pElem) ); + SbxVariable* pNew = new SbxVariable( *pElem ); pElem->SetParameters( NULL ); pElem = pNew; } @@ -3816,7 +3816,7 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 ) SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) { SbxArray* pPar; - if( ( pElem->GetType() & SbxARRAY ) && (SbxVariable*)refRedim != pElem ) + if( ( pElem->GetType() & SbxARRAY ) && refRedim.get() != pElem ) { SbxBase* pElemObj = pElem->GetObject(); SbxDimArray* pDimArray = PTR_CAST(SbxDimArray,pElemObj); @@ -4046,7 +4046,7 @@ void SbiRuntime::StepELEM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { SbxVariableRef pObjVar = PopVar(); - SbxObject* pObj = PTR_CAST(SbxObject,(SbxVariable*) pObjVar); + SbxObject* pObj = PTR_CAST(SbxObject, pObjVar.get()); if( !pObj ) { SbxBase* pObjVarObj = pObjVar->GetObject(); @@ -4059,7 +4059,7 @@ void SbiRuntime::StepELEM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // #74254 now per list if( pObj ) { - SaveRef( (SbxVariable*)pObj ); + SaveRef( static_cast<SbxVariable*>(pObj) ); } PushVar( FindElement( pObj, nOp1, nOp2, SbERR_NO_METHOD, false ) ); } diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 2780002..81a1001 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -50,29 +50,29 @@ SbxValue::SbxValue( SbxDataType t, void* p ) : SbxBase() { switch( t & 0x0FFF ) { - case SbxINTEGER: n |= SbxBYREF; aData.pInteger = (sal_Int16*) p; break; - case SbxSALUINT64: n |= SbxBYREF; aData.puInt64 = (sal_uInt64*) p; break; + case SbxINTEGER: n |= SbxBYREF; aData.pInteger = static_cast<sal_Int16*>(p); break; + case SbxSALUINT64: n |= SbxBYREF; aData.puInt64 = static_cast<sal_uInt64*>(p); break; case SbxSALINT64: - case SbxCURRENCY: n |= SbxBYREF; aData.pnInt64 = (sal_Int64*) p; break; - case SbxLONG: n |= SbxBYREF; aData.pLong = (sal_Int32*) p; break; - case SbxSINGLE: n |= SbxBYREF; aData.pSingle = (float*) p; break; + case SbxCURRENCY: n |= SbxBYREF; aData.pnInt64 = static_cast<sal_Int64*>(p); break; + case SbxLONG: n |= SbxBYREF; aData.pLong = static_cast<sal_Int32*>(p); break; + case SbxSINGLE: n |= SbxBYREF; aData.pSingle = static_cast<float*>(p); break; case SbxDATE: - case SbxDOUBLE: n |= SbxBYREF; aData.pDouble = (double*) p; break; - case SbxSTRING: n |= SbxBYREF; aData.pOUString = (OUString*) p; break; + case SbxDOUBLE: n |= SbxBYREF; aData.pDouble = static_cast<double*>(p); break; + case SbxSTRING: n |= SbxBYREF; aData.pOUString = static_cast<OUString*>(p); break; case SbxERROR: case SbxUSHORT: - case SbxBOOL: n |= SbxBYREF; aData.pUShort = (sal_uInt16*) p; break; - case SbxULONG: n |= SbxBYREF; aData.pULong = (sal_uInt32*) p; break; - case SbxCHAR: n |= SbxBYREF; aData.pChar = (sal_Unicode*) p; break; - case SbxBYTE: n |= SbxBYREF; aData.pByte = (sal_uInt8*) p; break; - case SbxINT: n |= SbxBYREF; aData.pInt = (int*) p; break; + case SbxBOOL: n |= SbxBYREF; aData.pUShort = static_cast<sal_uInt16*>(p); break; + case SbxULONG: n |= SbxBYREF; aData.pULong = static_cast<sal_uInt32*>(p); break; + case SbxCHAR: n |= SbxBYREF; aData.pChar = static_cast<sal_Unicode*>(p); break; + case SbxBYTE: n |= SbxBYREF; aData.pByte = static_cast<sal_uInt8*>(p); break; + case SbxINT: n |= SbxBYREF; aData.pInt = static_cast<int*>(p); break; case SbxOBJECT: - aData.pObj = (SbxBase*) p; + aData.pObj = static_cast<SbxBase*>(p); if( p ) aData.pObj->AddFirstRef(); break; case SbxDECIMAL: - aData.pDecimal = (SbxDecimal*) p; + aData.pDecimal = static_cast<SbxDecimal*>(p); if( p ) aData.pDecimal->addRef(); break; diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx index a2cba50..7ae2535 100644 --- a/include/tools/ref.hxx +++ b/include/tools/ref.hxx @@ -76,6 +76,8 @@ public: bool Is() const { return pObj != 0; } + T * get() const { return pObj; } + T * operator &() const { return pObj; } T * operator ->() const { assert(pObj != 0); return pObj; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits