From 8293b29304716d6bd117ab233b1238e1385ae592 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 23 Jan 2014 07:19:24 +0200 Subject: Use assert() and SAL_WARN() instead of DBG_ASSERT() and OSL_FAIL() Change-Id: Id3be30bc95325e8f18cf8cb55da2217984a26035 --- sfx2/source/control/objface.cxx | 86 ++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 45 deletions(-) (limited to 'sfx2/source/control/objface.cxx') diff --git a/sfx2/source/control/objface.cxx b/sfx2/source/control/objface.cxx index 9242e94b39fc..431078eed415 100644 --- a/sfx2/source/control/objface.cxx +++ b/sfx2/source/control/objface.cxx @@ -17,8 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - +#include #include + +#include + #include #include @@ -155,9 +158,8 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) for ( pIter = pSlots; nIter <= nCount; ++pIter, ++nIter ) { - DBG_ASSERT( nIter == nCount || - pIter->GetSlotId() != (pIter+1)->GetSlotId(), - "doppelte SID" ); + assert( nIter == nCount || + pIter->GetSlotId() != (pIter+1)->GetSlotId() ); // every master refers to his first slave (ENUM), // all slaves refer to their master. @@ -165,7 +167,7 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) if ( pIter->GetKind() == SFX_KIND_ENUM ) { pIter->pLinkedSlot = GetSlot( pIter->nMasterSlotId ); - DBG_ASSERT( pIter->pLinkedSlot, "slave without master" ); + assert( pIter->pLinkedSlot ); if ( !pIter->pLinkedSlot->pLinkedSlot ) ( (SfxSlot*) pIter->pLinkedSlot)->pLinkedSlot = pIter; @@ -210,7 +212,7 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) { if ( pNext->GetSlotId() <= pIter->GetSlotId() ) - OSL_FAIL("Wrong order!"); + SAL_WARN( "sfx2.control", "Wrong order" ); if ( pIter->GetKind() == SFX_KIND_ENUM ) { @@ -227,7 +229,7 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) aStr.append(" , "); aStr.append(static_cast( pSlave->GetSlotId())); - OSL_FAIL(aStr.getStr()); + SAL_WARN("sfx2.control", aStr.getStr()); } if ( pSlave->nMasterSlotId != pMasterSlot->GetSlotId() ) @@ -238,7 +240,7 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) aStr.append(" , "); aStr.append(static_cast( pSlave->GetSlotId())); - OSL_FAIL(aStr.getStr()); + SAL_WARN("sfx2.control", aStr.getStr()); } pSlave = pSlave->pNextSlot; @@ -256,7 +258,7 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) aStr.append(" , "); aStr.append(static_cast( pIter->pLinkedSlot->GetSlotId())); - OSL_FAIL(aStr.getStr()); + SAL_WARN("sfx2.control", aStr.getStr()); } } @@ -271,7 +273,7 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) pCurSlot->GetSlotId())); aStr.append(" , "); aStr.append(static_cast(pIter->GetSlotId())); - OSL_FAIL(aStr.getStr()); + SAL_WARN("sfx2.control", aStr.getStr()); } } while ( pCurSlot != pIter ); @@ -290,7 +292,7 @@ SfxInterface::~SfxInterface() SfxModule *pMod = pImpData->pModule; sal_Bool bRegistered = pImpData->bRegistered; delete pImpData; - DBG_ASSERT( bRegistered, "Interface not registered!" ); + assert( bRegistered ); if ( bRegistered ) { if ( pMod ) @@ -307,7 +309,9 @@ SfxInterface::~SfxInterface() const SfxSlot* SfxInterface::GetSlot( sal_uInt16 nFuncId ) const { DBG_CHKTHIS(SfxInterface, 0); - DBG_ASSERT( this && pSlots && nCount, "" ); + + assert( pSlots ); + assert( nCount ); // find the id using binary search void* p = bsearch( &nFuncId, pSlots, nCount, sizeof(SfxSlot), @@ -341,13 +345,15 @@ const SfxSlot* SfxInterface::GetSlot( const OUString& rCommand ) const const SfxSlot* SfxInterface::GetRealSlot( const SfxSlot *pSlot ) const { DBG_CHKTHIS(SfxInterface, 0); - DBG_ASSERT( this && pSlots && nCount, "" ); + + assert( pSlots ); + assert( nCount ); if ( !ContainsSlot_Impl(pSlot) ) { if(pGenoType) return pGenoType->GetRealSlot(pSlot); - OSL_FAIL("unknown Slot"); + SAL_WARN( "sfx2.control", "unknown Slot" ); return 0; } @@ -359,14 +365,16 @@ const SfxSlot* SfxInterface::GetRealSlot( const SfxSlot *pSlot ) const const SfxSlot* SfxInterface::GetRealSlot( sal_uInt16 nSlotId ) const { DBG_CHKTHIS(SfxInterface, 0); - DBG_ASSERT( this && pSlots && nCount, "" ); + + assert( pSlots ); + assert( nCount ); const SfxSlot *pSlot = GetSlot(nSlotId); if ( !pSlot ) { if(pGenoType) return pGenoType->GetRealSlot(nSlotId); - OSL_FAIL("unknown Slot"); + SAL_WARN( "sfx2.control", "unknown Slot" ); return 0; } @@ -378,6 +386,7 @@ const SfxSlot* SfxInterface::GetRealSlot( sal_uInt16 nSlotId ) const void SfxInterface::RegisterPopupMenu( const ResId& rResId ) { DBG_CHKTHIS(SfxInterface, 0); + pImpData->aPopupRes = rResId; } @@ -436,10 +445,8 @@ const ResId& SfxInterface::GetObjectBarResId( sal_uInt16 nNo ) const nNo = nNo - nBaseCount; } -#ifdef DBG_UTIL - sal_uInt16 nObjBarCount = pImpData->aObjectBars.size(); - DBG_ASSERT( nNoaObjectBars.size() ); + return pImpData->aObjectBars[nNo]->aResId; } @@ -460,10 +467,8 @@ sal_uInt16 SfxInterface::GetObjectBarPos( sal_uInt16 nNo ) const nNo = nNo - nBaseCount; } -#ifdef DBG_UTIL - sal_uInt16 nObjBarCount = pImpData->aObjectBars.size(); - DBG_ASSERT( nNoaObjectBars.size() ); + return pImpData->aObjectBars[nNo]->nPos; } @@ -510,10 +515,8 @@ sal_uInt32 SfxInterface::GetChildWindowId (sal_uInt16 nNo) const nNo = nNo - nBaseCount; } -#ifdef DBG_UTIL - sal_uInt16 nCWCount = pImpData->aChildWindows.size(); - DBG_ASSERT( nNoaChildWindows.size() ); + sal_uInt32 nRet = pImpData->aChildWindows[nNo]->aResId.GetId(); if ( pImpData->aChildWindows[nNo]->bContext ) nRet += sal_uInt32( nClassId ) << 16; @@ -533,10 +536,8 @@ sal_uInt32 SfxInterface::GetChildWindowFeature (sal_uInt16 nNo) const nNo = nNo - nBaseCount; } -#ifdef DBG_UTIL - sal_uInt16 nCWCount = pImpData->aChildWindows.size(); - DBG_ASSERT( nNoaChildWindows.size() ); + return pImpData->aChildWindows[nNo]->nFeature; } @@ -582,10 +583,8 @@ const OUString* SfxInterface::GetObjectBarName ( sal_uInt16 nNo ) const nNo = nNo - nBaseCount; } -#ifdef DBG_UTIL - sal_uInt16 nObjBarCount = pImpData->aObjectBars.size(); - DBG_ASSERT( nNoaObjectBars.size() ); + return pImpData->aObjectBars[nNo]->pName; } @@ -603,10 +602,8 @@ sal_uInt32 SfxInterface::GetObjectBarFeature ( sal_uInt16 nNo ) const nNo = nNo - nBaseCount; } -#ifdef DBG_UTIL - sal_uInt16 nObjBarCount = pImpData->aObjectBars.size(); - DBG_ASSERT( nNoaObjectBars.size() ); + return pImpData->aObjectBars[nNo]->nFeature; } @@ -624,16 +621,15 @@ sal_Bool SfxInterface::IsObjectBarVisible(sal_uInt16 nNo) const nNo = nNo - nBaseCount; } -#ifdef DBG_UTIL - sal_uInt16 nObjBarCount = pImpData->aObjectBars.size(); - DBG_ASSERT( nNoaObjectBars.size() ); + return pImpData->aObjectBars[nNo]->bVisible; } const SfxInterface* SfxInterface::GetRealInterfaceForSlot( const SfxSlot *pRealSlot ) const { - DBG_ASSERT( pImpData->bRegistered, "Interface not registered!" ); + assert( pImpData->bRegistered ); + const SfxInterface* pInterface = this; // The slot could also originate from the interface of a shell base class. -- cgit v1.2.3