Kaydet (Commit) bcbbe579 authored tarafından Michael Stahl's avatar Michael Stahl

svl: convert DBG_ASSERTs in SfxItemSet

Change-Id: I37e507226e676ee797e6911a0b3da1d1823e750a
üst d4fce35d
...@@ -292,6 +292,7 @@ certain functionality. ...@@ -292,6 +292,7 @@ certain functionality.
@section svl @section svl
@li @c svl @li @c svl
@li @c svl.items
@li @c svl.numbers @li @c svl.numbers
@section svtools @section svtools
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet ) SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet )
: _rSet( rItemSet ) : _rSet( rItemSet )
{ {
DBG_ASSERTWARNING( _rSet.Count(), "es gibt gar keine Attribute" );
if ( !_rSet._nCount ) if ( !_rSet._nCount )
{ {
_nStt = 1; _nStt = 1;
...@@ -49,16 +47,10 @@ SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet ) ...@@ -49,16 +47,10 @@ SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet )
_nAkt = _nStt; _nAkt = _nStt;
} }
SfxItemIter::~SfxItemIter() SfxItemIter::~SfxItemIter()
{ {
} }
const SfxPoolItem* SfxItemIter::NextItem() const SfxPoolItem* SfxItemIter::NextItem()
{ {
SfxItemArray ppFnd = _rSet._aItems; SfxItemArray ppFnd = _rSet._aItems;
......
...@@ -36,10 +36,6 @@ ...@@ -36,10 +36,6 @@
// STATIC DATA // STATIC DATA
static const sal_uInt16 nInitCount = 10; // Single USHORTs => 5 pairs without '0' static const sal_uInt16 nInitCount = 10; // Single USHORTs => 5 pairs without '0'
#if OSL_DEBUG_LEVEL > 1
static sal_uLong nRangesCopyCount = 0; // How often have ranges been copied?
#endif
#include "nranges.cxx" #include "nranges.cxx"
#include "poolio.hxx" #include "poolio.hxx"
...@@ -58,18 +54,18 @@ const sal_Char *DbgCheckItemSet( const void* pVoid ) ...@@ -58,18 +54,18 @@ const sal_Char *DbgCheckItemSet( const void* pVoid )
if ( pItem ) if ( pItem )
{ {
++nCount; ++nCount;
DBG_ASSERT( IsInvalidItem(pItem) || assert((IsInvalidItem(pItem) ||
pItem->Which() == 0 || pItem->Which() == nWh, pItem->Which() == 0 || pItem->Which() == nWh
"SfxItemSet: invalid which-id" ); ) && "SfxItemSet: invalid which-id" );
DBG_ASSERT( IsInvalidItem(pItem) || !pItem->Which() || assert((IsInvalidItem(pItem) || !pItem->Which() ||
!SfxItemPool::IsWhich(pItem->Which()) || !SfxItemPool::IsWhich(pItem->Which()) ||
pSet->GetPool()->IsItemFlag(nWh, SFX_ITEM_NOT_POOLABLE) || pSet->GetPool()->IsItemFlag(nWh, SFX_ITEM_NOT_POOLABLE) ||
SFX_ITEMS_NULL != pSet->GetPool()->GetSurrogate(pItem), SFX_ITEMS_NULL != pSet->GetPool()->GetSurrogate(pItem)
"SfxItemSet: item in set which is not in pool" ); ) && "SfxItemSet: item in set which is not in pool" );
} }
} }
DBG_ASSERT( pSet->_nCount == nCount, "wrong SfxItemSet::nCount detected" ); assert(pSet->_nCount == nCount);
return 0; return 0;
} }
...@@ -93,7 +89,7 @@ SfxItemSet::SfxItemSet ...@@ -93,7 +89,7 @@ SfxItemSet::SfxItemSet
_pParent( 0 ), _pParent( 0 ),
_nCount( 0 ) _nCount( 0 )
{ {
DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "no Master Pool" ); SAL_WARN_IF(_pPool != _pPool->GetMasterPool(), "svl.items", "no Master Pool");
// DBG_ASSERT( bTotalRanges || abs( &bTotalRanges - this ) < 1000, // DBG_ASSERT( bTotalRanges || abs( &bTotalRanges - this ) < 1000,
// "please use suitable ranges" ); // "please use suitable ranges" );
#if defined DBG_UTIL && defined SFX_ITEMSET_NO_DEFAULT_CTOR #if defined DBG_UTIL && defined SFX_ITEMSET_NO_DEFAULT_CTOR
...@@ -104,7 +100,7 @@ SfxItemSet::SfxItemSet ...@@ -104,7 +100,7 @@ SfxItemSet::SfxItemSet
#endif #endif
_pWhichRanges = (sal_uInt16*) _pPool->GetFrozenIdRanges(); _pWhichRanges = (sal_uInt16*) _pPool->GetFrozenIdRanges();
DBG_ASSERT( _pWhichRanges, "don't create ItemSets with full range before FreezeIdRanges()" ); assert( _pWhichRanges && "don't create ItemSets with full range before FreezeIdRanges()" );
if ( !_pWhichRanges ) if ( !_pWhichRanges )
_pPool->FillItemIdRanges_Impl( _pWhichRanges ); _pPool->FillItemIdRanges_Impl( _pWhichRanges );
...@@ -120,8 +116,8 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhic ...@@ -120,8 +116,8 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhic
_pParent( 0 ), _pParent( 0 ),
_nCount( 0 ) _nCount( 0 )
{ {
DBG_ASSERT( nWhich1 <= nWhich2, "Invalid range" ); assert(nWhich1 <= nWhich2);
DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "no Master Pool" ); SAL_WARN_IF(_pPool != _pPool->GetMasterPool(), "svl.items", "no Master Pool");
InitRanges_Impl(nWhich1, nWhich2); InitRanges_Impl(nWhich1, nWhich2);
} }
...@@ -157,8 +153,8 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool, ...@@ -157,8 +153,8 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool,
_pWhichRanges( 0 ), _pWhichRanges( 0 ),
_nCount( 0 ) _nCount( 0 )
{ {
DBG_ASSERT( nWh1 <= nWh2, "Invalid range" ); assert(nWh1 <= nWh2);
DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "no Master Pool" ); SAL_WARN_IF(_pPool != _pPool->GetMasterPool(), "svl.items", "no Master Pool");
if(!nNull) if(!nNull)
InitRanges_Impl( InitRanges_Impl(
...@@ -179,10 +175,6 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool, ...@@ -179,10 +175,6 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool,
void SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable) void SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable)
{ {
#if OSL_DEBUG_LEVEL > 1
OSL_TRACE("SfxItemSet: Ranges-CopyCount==%ul", ++nRangesCopyCount);
#endif
sal_uInt16 nCnt = 0; sal_uInt16 nCnt = 0;
const sal_uInt16* pPtr = pWhichPairTable; const sal_uInt16* pPtr = pWhichPairTable;
while( *pPtr ) while( *pPtr )
...@@ -209,7 +201,7 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool, const sal_uInt16* pWhichPairTable ) ...@@ -209,7 +201,7 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool, const sal_uInt16* pWhichPairTable )
, _pWhichRanges(0) , _pWhichRanges(0)
, _nCount(0) , _nCount(0)
{ {
DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "no Master Pool" ); SAL_WARN_IF(_pPool != _pPool->GetMasterPool(), "svl.items", "no Master Pool");
// pWhichPairTable == 0 ist f"ur das SfxAllEnumItemSet // pWhichPairTable == 0 ist f"ur das SfxAllEnumItemSet
if ( pWhichPairTable ) if ( pWhichPairTable )
...@@ -221,7 +213,7 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ): ...@@ -221,7 +213,7 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ):
_pParent( rASet._pParent ), _pParent( rASet._pParent ),
_nCount( rASet._nCount ) _nCount( rASet._nCount )
{ {
DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "no Master Pool" ); SAL_WARN_IF(_pPool != _pPool->GetMasterPool(), "svl.items", "no Master Pool");
// Calculate the attribute count // Calculate the attribute count
sal_uInt16 nCnt = 0; sal_uInt16 nCnt = 0;
...@@ -255,9 +247,6 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ): ...@@ -255,9 +247,6 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ):
*ppDst = &_pPool->Put( **ppSrc ); *ppDst = &_pPool->Put( **ppSrc );
// Copy the WhichRanges // Copy the WhichRanges
#if OSL_DEBUG_LEVEL > 1
OSL_TRACE("SfxItemSet: Ranges-CopyCount==%ul", ++nRangesCopyCount);
#endif
std::ptrdiff_t cnt = pPtr - rASet._pWhichRanges+1; std::ptrdiff_t cnt = pPtr - rASet._pWhichRanges+1;
_pWhichRanges = new sal_uInt16[ cnt ]; _pWhichRanges = new sal_uInt16[ cnt ];
memcpy( _pWhichRanges, rASet._pWhichRanges, sizeof( sal_uInt16 ) * cnt); memcpy( _pWhichRanges, rASet._pWhichRanges, sizeof( sal_uInt16 ) * cnt);
...@@ -439,7 +428,7 @@ void SfxItemSet::InvalidateDefaultItems() ...@@ -439,7 +428,7 @@ void SfxItemSet::InvalidateDefaultItems()
void SfxItemSet::InvalidateAllItems() void SfxItemSet::InvalidateAllItems()
{ {
DBG_ASSERT( !_nCount, "There are still Items set" ); assert( !_nCount && "There are still Items set" );
memset( (void*)_aItems, -1, ( _nCount = TotalCount() ) * sizeof( SfxPoolItem*) ); memset( (void*)_aItems, -1, ( _nCount = TotalCount() ) * sizeof( SfxPoolItem*) );
} }
...@@ -660,7 +649,7 @@ void SfxItemSet::PutExtended ...@@ -660,7 +649,7 @@ void SfxItemSet::PutExtended
break; break;
default: default:
OSL_FAIL( "invalid Argument for eDontCareAs" ); assert(!"invalid Argument for eDontCareAs");
} }
} }
else else
...@@ -685,7 +674,7 @@ void SfxItemSet::PutExtended ...@@ -685,7 +674,7 @@ void SfxItemSet::PutExtended
break; break;
default: default:
OSL_FAIL( "invalid Argument for eDefaultAs" ); assert(!"invalid Argument for eDefaultAs");
} }
} }
pPtr += 2; pPtr += 2;
...@@ -890,7 +879,7 @@ const SfxPoolItem* SfxItemSet::GetItem ...@@ -890,7 +879,7 @@ const SfxPoolItem* SfxItemSet::GetItem
return pItem; return pItem;
// Else report error // Else report error
OSL_FAIL( "invalid argument type" ); assert(!"invalid argument type");
} }
// No Item of wrong type found // No Item of wrong type found
...@@ -928,7 +917,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const ...@@ -928,7 +917,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const
#ifdef DBG_UTIL #ifdef DBG_UTIL
const SfxPoolItem *pItem = *ppFnd; const SfxPoolItem *pItem = *ppFnd;
if ( pItem->ISA(SfxVoidItem) || !pItem->Which() ) if ( pItem->ISA(SfxVoidItem) || !pItem->Which() )
DBG_WARNING( "SFX_WARNING: Getting disabled Item" ); SAL_INFO("svl.items", "SFX_WARNING: Getting disabled Item");
#endif #endif
return **ppFnd; return **ppFnd;
} }
...@@ -977,7 +966,7 @@ sal_uInt16 SfxItemSet::TotalCount() const ...@@ -977,7 +966,7 @@ sal_uInt16 SfxItemSet::TotalCount() const
*/ */
void SfxItemSet::Intersect( const SfxItemSet& rSet ) void SfxItemSet::Intersect( const SfxItemSet& rSet )
{ {
DBG_ASSERT(_pPool, "Not implemented without Pool"); assert(_pPool && "Not implemented without Pool");
if( !Count() ) // None set? if( !Count() ) // None set?
return; return;
...@@ -1269,7 +1258,7 @@ static void MergeItem_Impl( SfxItemPool *_pPool, sal_uInt16 &rCount, ...@@ -1269,7 +1258,7 @@ static void MergeItem_Impl( SfxItemPool *_pPool, sal_uInt16 &rCount,
void SfxItemSet::MergeValues( const SfxItemSet& rSet, bool bIgnoreDefaults ) void SfxItemSet::MergeValues( const SfxItemSet& rSet, bool bIgnoreDefaults )
{ {
// WARNING! When making changes/fixing bugs, always update the table above!! // WARNING! When making changes/fixing bugs, always update the table above!!
DBG_ASSERT( GetPool() == rSet.GetPool(), "MergeValues with different Pools" ); assert( GetPool() == rSet.GetPool() && "MergeValues with different Pools" );
// Test if the which Ranges are different // Test if the which Ranges are different
bool bEqual = true; bool bEqual = true;
...@@ -1389,7 +1378,7 @@ sal_uInt16 SfxItemSet::GetWhichByPos( sal_uInt16 nPos ) const ...@@ -1389,7 +1378,7 @@ sal_uInt16 SfxItemSet::GetWhichByPos( sal_uInt16 nPos ) const
nPos = nPos - n; nPos = nPos - n;
pPtr += 2; pPtr += 2;
} }
DBG_ASSERT( false, "We're wrong here" ); assert(false);
return 0; return 0;
} }
...@@ -1412,8 +1401,8 @@ SvStream &SfxItemSet::Store ...@@ -1412,8 +1401,8 @@ SvStream &SfxItemSet::Store
false: Surrogates */ false: Surrogates */
) const ) const
{ {
DBG_ASSERT( _pPool, "No Pool" ); assert(_pPool);
DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "no Master Pool" ); SAL_WARN_IF(_pPool != _pPool->GetMasterPool(), "svl.items", "no Master Pool");
// Remember position of the count (to be able to correct it, if need be) // Remember position of the count (to be able to correct it, if need be)
sal_uLong nCountPos = rStream.Tell(); sal_uLong nCountPos = rStream.Tell();
...@@ -1432,7 +1421,7 @@ SvStream &SfxItemSet::Store ...@@ -1432,7 +1421,7 @@ SvStream &SfxItemSet::Store
pItem = aIter.NextItem() ) pItem = aIter.NextItem() )
{ {
// Let Items (if need be as a Surrogate) be saved via Pool // Let Items (if need be as a Surrogate) be saved via Pool
DBG_ASSERT( !IsInvalidItem(pItem), "can't store invalid items" ); SAL_WARN_IF(IsInvalidItem(pItem), "svl.items", "can't store invalid items");
if ( !IsInvalidItem(pItem) && if ( !IsInvalidItem(pItem) &&
_pPool->StoreItem( rStream, *pItem, bDirect ) ) _pPool->StoreItem( rStream, *pItem, bDirect ) )
// Item was streamed in 'rStream' // Item was streamed in 'rStream'
...@@ -1477,8 +1466,8 @@ SvStream &SfxItemSet::Load ...@@ -1477,8 +1466,8 @@ SvStream &SfxItemSet::Load
(e.g. when inserting documents) */ (e.g. when inserting documents) */
) )
{ {
DBG_ASSERT( _pPool, "No Pool"); assert(_pPool);
DBG_ASSERTWARNING( _pPool == _pPool->GetMasterPool(), "No Master Pool"); SAL_WARN_IF(_pPool != _pPool->GetMasterPool(), "svl.items", "no Master Pool");
// No RefPool => Resolve Surrogates with ItemSet's Pool // No RefPool => Resolve Surrogates with ItemSet's Pool
if ( !pRefPool ) if ( !pRefPool )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment