Kaydet (Commit) 3b9e0676 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

const_cast: convert some C-style casts and remove some redundant ones

Change-Id: Iefbf64608dba0c0ae01e79e5b679a9b42748b73a
üst 23ab1493
...@@ -99,7 +99,7 @@ SfxItemSet::SfxItemSet ...@@ -99,7 +99,7 @@ SfxItemSet::SfxItemSet
(void) bTotalRanges; // avoid warnings (void) bTotalRanges; // avoid warnings
#endif #endif
_pWhichRanges = (sal_uInt16*) _pPool->GetFrozenIdRanges(); _pWhichRanges = const_cast<sal_uInt16*>(_pPool->GetFrozenIdRanges());
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 );
...@@ -232,7 +232,7 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ): ...@@ -232,7 +232,7 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ):
{ {
// Just copy the pointer and increase RefCount // Just copy the pointer and increase RefCount
*ppDst = *ppSrc; *ppDst = *ppSrc;
( (SfxPoolItem*) (*ppDst) )->AddRef(); (*ppDst)->AddRef();
} }
else if ( !(*ppSrc)->Which() ) else if ( !(*ppSrc)->Which() )
*ppDst = (*ppSrc)->Clone(); *ppDst = (*ppSrc)->Clone();
...@@ -258,7 +258,7 @@ SfxItemSet::~SfxItemSet() ...@@ -258,7 +258,7 @@ SfxItemSet::~SfxItemSet()
if( *ppFnd && !IsInvalidItem(*ppFnd) ) if( *ppFnd && !IsInvalidItem(*ppFnd) )
{ {
if( !(*ppFnd)->Which() ) if( !(*ppFnd)->Which() )
delete (SfxPoolItem*) *ppFnd; delete *ppFnd;
else { else {
// Still multiple references present, so just alter the RefCount // Still multiple references present, so just alter the RefCount
if ( 1 < (*ppFnd)->GetRefCount() && !IsDefaultItem(*ppFnd) ) if ( 1 < (*ppFnd)->GetRefCount() && !IsDefaultItem(*ppFnd) )
...@@ -770,7 +770,7 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges ) ...@@ -770,7 +770,7 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges )
if( pNewRanges == GetPool()->GetFrozenIdRanges() ) if( pNewRanges == GetPool()->GetFrozenIdRanges() )
{ {
delete[] _pWhichRanges; delete[] _pWhichRanges;
_pWhichRanges = ( sal_uInt16* ) pNewRanges; _pWhichRanges = const_cast<sal_uInt16*>(pNewRanges);
} }
else else
{ {
......
...@@ -104,7 +104,7 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem, bool b ...@@ -104,7 +104,7 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem, bool b
// Add the transformation to the cache // Add the transformation to the cache
SfxItemModifyImpl aModify; SfxItemModifyImpl aModify;
aModify.pOrigItem = &rOrigItem; aModify.pOrigItem = &rOrigItem;
aModify.pPoolItem = (SfxSetItem*) pNewPoolItem; aModify.pPoolItem = const_cast<SfxSetItem*>(pNewPoolItem);
pCache->push_back( aModify ); pCache->push_back( aModify );
DBG_ASSERT( !pItemToPut || DBG_ASSERT( !pItemToPut ||
......
...@@ -1815,9 +1815,9 @@ OUString SvNumberFormatter::GetFormatDecimalSep( sal_uInt32 nFormat ) const ...@@ -1815,9 +1815,9 @@ OUString SvNumberFormatter::GetFormatDecimalSep( sal_uInt32 nFormat ) const
else else
{ {
LanguageTag aSaveLocale( xLocaleData->getLanguageTag() ); LanguageTag aSaveLocale( xLocaleData->getLanguageTag() );
((SvNumberFormatter*)this)->xLocaleData.changeLocale( LanguageTag( pFormat->GetLanguage()) ); const_cast<SvNumberFormatter*>(this)->xLocaleData.changeLocale( LanguageTag( pFormat->GetLanguage()) );
aRet = xLocaleData->getNumDecimalSep(); aRet = xLocaleData->getNumDecimalSep();
((SvNumberFormatter*)this)->xLocaleData.changeLocale( aSaveLocale ); const_cast<SvNumberFormatter*>(this)->xLocaleData.changeLocale( aSaveLocale );
} }
return aRet; return aRet;
} }
......
...@@ -131,21 +131,21 @@ void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const ...@@ -131,21 +131,21 @@ void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const
switch ( eIdx ) switch ( eIdx )
{ {
case NF_KEY_TRUE : case NF_KEY_TRUE :
((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_TRUE] = const_cast<ImpSvNumberformatScan*>(this)->sKeyword[NF_KEY_TRUE] =
pFormatter->GetCharClass()->uppercase( pFormatter->GetLocaleData()->getTrueWord() ); pFormatter->GetCharClass()->uppercase( pFormatter->GetLocaleData()->getTrueWord() );
if ( sKeyword[NF_KEY_TRUE].isEmpty() ) if ( sKeyword[NF_KEY_TRUE].isEmpty() )
{ {
SAL_WARN( "svl.numbers", "InitSpecialKeyword: TRUE_WORD?" ); SAL_WARN( "svl.numbers", "InitSpecialKeyword: TRUE_WORD?" );
((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_TRUE] = "TRUE"; const_cast<ImpSvNumberformatScan*>(this)->sKeyword[NF_KEY_TRUE] = "TRUE";
} }
break; break;
case NF_KEY_FALSE : case NF_KEY_FALSE :
((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_FALSE] = const_cast<ImpSvNumberformatScan*>(this)->sKeyword[NF_KEY_FALSE] =
pFormatter->GetCharClass()->uppercase( pFormatter->GetLocaleData()->getFalseWord() ); pFormatter->GetCharClass()->uppercase( pFormatter->GetLocaleData()->getFalseWord() );
if ( sKeyword[NF_KEY_FALSE].isEmpty() ) if ( sKeyword[NF_KEY_FALSE].isEmpty() )
{ {
SAL_WARN( "svl.numbers", "InitSpecialKeyword: FALSE_WORD?" ); SAL_WARN( "svl.numbers", "InitSpecialKeyword: FALSE_WORD?" );
((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_FALSE] = "FALSE"; const_cast<ImpSvNumberformatScan*>(this)->sKeyword[NF_KEY_FALSE] = "FALSE";
} }
break; break;
default: default:
...@@ -155,7 +155,7 @@ void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const ...@@ -155,7 +155,7 @@ void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const
void ImpSvNumberformatScan::InitCompatCur() const void ImpSvNumberformatScan::InitCompatCur() const
{ {
ImpSvNumberformatScan* pThis = (ImpSvNumberformatScan*)this; ImpSvNumberformatScan* pThis = const_cast<ImpSvNumberformatScan*>(this);
// currency symbol for old style ("automatic") compatibility format codes // currency symbol for old style ("automatic") compatibility format codes
pFormatter->GetCompatibilityCurrency( pThis->sCurSymbol, pThis->sCurAbbrev ); pFormatter->GetCompatibilityCurrency( pThis->sCurSymbol, pThis->sCurAbbrev );
// currency symbol upper case // currency symbol upper case
...@@ -167,7 +167,7 @@ void ImpSvNumberformatScan::InitKeywords() const ...@@ -167,7 +167,7 @@ void ImpSvNumberformatScan::InitKeywords() const
{ {
if ( !bKeywordsNeedInit ) if ( !bKeywordsNeedInit )
return ; return ;
((ImpSvNumberformatScan*)this)->SetDependentKeywords(); const_cast<ImpSvNumberformatScan*>(this)->SetDependentKeywords();
bKeywordsNeedInit = false; bKeywordsNeedInit = false;
} }
......
...@@ -159,7 +159,7 @@ void DdeTopic::InsertItem( SAL_UNUSED_PARAMETER DdeItem* ) ...@@ -159,7 +159,7 @@ void DdeTopic::InsertItem( SAL_UNUSED_PARAMETER DdeItem* )
DdeItem* DdeTopic::AddItem( const DdeItem& rDdeItem ) DdeItem* DdeTopic::AddItem( const DdeItem& rDdeItem )
{ {
return (DdeItem*) &rDdeItem; return const_cast<DdeItem*>(&rDdeItem);
} }
void DdeTopic::RemoveItem( SAL_UNUSED_PARAMETER const DdeItem& ) void DdeTopic::RemoveItem( SAL_UNUSED_PARAMETER const DdeItem& )
......
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