From 812e5e8ed7c408cb7f2388ab718365354bfc9a41 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 26 Mar 2015 15:28:32 +0100 Subject: const_cast: convert some C-style casts and remove some redundant ones Change-Id: I8682fee997d8dac254ca431f96172c9aa58c8c06 --- editeng/source/editeng/editdoc.cxx | 2 +- editeng/source/editeng/editeng.cxx | 4 ++-- editeng/source/editeng/impedit2.cxx | 12 ++++++------ editeng/source/editeng/impedit3.cxx | 2 +- editeng/source/editeng/impedit5.cxx | 2 +- editeng/source/items/frmitems.cxx | 4 ++-- editeng/source/items/svxfont.cxx | 10 +++++----- editeng/source/misc/svxacorr.cxx | 2 +- editeng/source/outliner/outliner.cxx | 2 +- editeng/source/uno/unoforou.cxx | 8 ++++---- editeng/source/uno/unoipset.cxx | 4 ++-- editeng/source/uno/unotext.cxx | 2 +- include/editeng/unotext.hxx | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 9e0f6570d63b..fa956cc1519e 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -3087,7 +3087,7 @@ SvStream& EditEngineItemPool::Store( SvStream& rStream ) const bool b31Format = ( nVersion && ( nVersion <= SOFFICE_FILEFORMAT_31 ) ) ? sal_True : sal_False; - EditEngineItemPool* pThis = (EditEngineItemPool*)this; + EditEngineItemPool* pThis = const_cast(this); if ( b31Format ) pThis->SetStoringRange( 3997, 4022 ); else diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index ad2b3d44c586..afed13934c3b 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -630,7 +630,7 @@ OUString EditEngine::GetWord( sal_Int32 nPara, sal_Int32 nIndex ) ESelection EditEngine::GetWord( const ESelection& rSelection, sal_uInt16 nWordType ) const { // ImpEditEngine-Iteration-Methods should be const! - EditEngine* pE = (EditEngine*)this; + EditEngine* pE = const_cast(this); EditSelection aSel( pE->pImpEditEngine->CreateSel( rSelection ) ); aSel = pE->pImpEditEngine->SelectWord( aSel, nWordType ); @@ -2350,7 +2350,7 @@ EPosition EditEngine::FindDocPosition( const Point& rDocPos ) const { EPosition aPos; // From the point of the API, this is const.... - EditPaM aPaM = ((EditEngine*)this)->pImpEditEngine->GetPaM( rDocPos, false ); + EditPaM aPaM = const_cast(this)->pImpEditEngine->GetPaM( rDocPos, false ); if ( aPaM.GetNode() ) { aPos.nPara = pImpEditEngine->aEditDoc.GetPos( aPaM.GetNode() ); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index fa62ca2d7ba9..bb964c193105 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -1755,7 +1755,7 @@ sal_uInt16 ImpEditEngine::GetI18NScriptType( const EditPaM& rPaM, sal_Int32* pEn sal_Int32 nPara = GetEditDoc().GetPos( rPaM.GetNode() ); const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aScriptInfos.empty() ) - ((ImpEditEngine*)this)->InitScriptTypes( nPara ); + const_cast(this)->InitScriptTypes( nPara ); const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; @@ -1785,7 +1785,7 @@ sal_uInt16 ImpEditEngine::GetItemScriptType( const EditSelection& rSel ) const { const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aScriptInfos.empty() ) - ((ImpEditEngine*)this)->InitScriptTypes( nPara ); + const_cast(this)->InitScriptTypes( nPara ); const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; @@ -1829,7 +1829,7 @@ bool ImpEditEngine::IsScriptChange( const EditPaM& rPaM ) const sal_Int32 nPara = GetEditDoc().GetPos( rPaM.GetNode() ); const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aScriptInfos.empty() ) - ((ImpEditEngine*)this)->InitScriptTypes( nPara ); + const_cast(this)->InitScriptTypes( nPara ); const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; const sal_Int32 nPos = rPaM.GetIndex(); @@ -1851,7 +1851,7 @@ bool ImpEditEngine::HasScriptType( sal_Int32 nPara, sal_uInt16 nType ) const const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aScriptInfos.empty() ) - ((ImpEditEngine*)this)->InitScriptTypes( nPara ); + const_cast(this)->InitScriptTypes( nPara ); const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; for ( size_t n = rTypes.size(); n && !bTypeFound; ) @@ -1940,7 +1940,7 @@ bool ImpEditEngine::IsRightToLeft( sal_Int32 nPara ) const else { // Use pool default - pFrameDirItem = &static_cast(((ImpEditEngine*)this)->GetEmptyItemSet().Get( EE_PARA_WRITINGDIR )); + pFrameDirItem = &static_cast(const_cast(this)->GetEmptyItemSet().Get( EE_PARA_WRITINGDIR )); } } } @@ -1953,7 +1953,7 @@ bool ImpEditEngine::IsRightToLeft( sal_Int32 nPara ) const bool ImpEditEngine::HasDifferentRTLLevels( const ContentNode* pNode ) { - sal_Int32 nPara = GetEditDoc().GetPos( (ContentNode*)pNode ); + sal_Int32 nPara = GetEditDoc().GetPos( pNode ); ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); bool bHasDifferentRTLLevels = false; diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index caba43f74ed9..069a3935b16c 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -4222,7 +4222,7 @@ const SvxNumberFormat* ImpEditEngine::GetNumberFormat( const ContentNode *pNode if (pNode) { // get index of paragraph - sal_Int32 nPara = GetEditDoc().GetPos( const_cast< ContentNode * >(pNode) ); + sal_Int32 nPara = GetEditDoc().GetPos( pNode ); DBG_ASSERT( nPara < EE_PARA_NOT_FOUND, "node not found in array" ); if (nPara < EE_PARA_NOT_FOUND) { diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index d362f258f348..fa733cdecd62 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -401,7 +401,7 @@ SfxItemSet ImpEditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int DBG_ASSERT( pNode, "GetAttribs - unknown paragraph!" ); DBG_ASSERT( nStart <= nEnd, "getAttribs: Start > End not supported!" ); - SfxItemSet aAttribs( ((ImpEditEngine*)this)->GetEmptyItemSet() ); + SfxItemSet aAttribs( const_cast(this)->GetEmptyItemSet() ); if ( pNode ) { diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index f6e2315c4f02..6c2368d745e4 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -672,7 +672,7 @@ bool SvxLRSpaceItem::GetPresentation SvStream& SvxLRSpaceItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const { short nSaveFI = nFirstLineOfst; - ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( 0 ); // nLeftMargin is manipulated together with this, see Create() + const_cast(this)->SetTxtFirstLineOfst( 0 ); // nLeftMargin is manipulated together with this, see Create() sal_uInt16 nMargin = 0; if( nLeftMargin > 0 ) @@ -712,7 +712,7 @@ SvStream& SvxLRSpaceItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) con } } - ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( nSaveFI ); + const_cast(this)->SetTxtFirstLineOfst( nSaveFI ); return rStrm; } diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index a306c68901bd..e93edd42e372 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -440,14 +440,14 @@ Size SvxFont::GetTxtSize( const OutputDevice *pOut, const OUString &rTxt, sal_Int32 nTmp = nLen; if ( nTmp == SAL_MAX_INT32 ) // already initialized? nTmp = rTxt.getLength(); - Font aOldFont( ChgPhysFont((OutputDevice *)pOut) ); + Font aOldFont( ChgPhysFont(const_cast(pOut)) ); Size aTxtSize; if( IsCapital() && !rTxt.isEmpty() ) { aTxtSize = GetCapitalSize( pOut, rTxt, nIdx, nTmp ); } else aTxtSize = GetPhysTxtSize(pOut,rTxt,nIdx,nTmp); - ((OutputDevice *)pOut)->SetFont( aOldFont ); + const_cast(pOut)->SetFont( aOldFont ); return aTxtSize; } @@ -592,7 +592,7 @@ public: SvxDoGetCapitalSize( SvxFont *_pFnt, const OutputDevice *_pOut, const OUString &_rTxt, const sal_Int32 _nIdx, const sal_Int32 _nLen, const short _nKrn ) - : SvxDoCapitals( (OutputDevice*)_pOut, _rTxt, _nIdx, _nLen ), + : SvxDoCapitals( const_cast(_pOut), _rTxt, _nIdx, _nLen ), pFont( _pFnt ), nKern( _nKrn ) { } @@ -633,7 +633,7 @@ Size SvxFont::GetCapitalSize( const OutputDevice *pOut, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen) const { // Start: - SvxDoGetCapitalSize aDo( (SvxFont *)this, pOut, rTxt, nIdx, nLen, nKern ); + SvxDoGetCapitalSize aDo( const_cast(this), pOut, rTxt, nIdx, nLen, nKern ); DoOnCapitals( aDo ); Size aTxtSize( aDo.GetSize() ); @@ -741,7 +741,7 @@ void SvxFont::DrawCapital( OutputDevice *pOut, const Point &rPos, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen ) const { - SvxDoDrawCapital aDo( (SvxFont *)this,pOut,rTxt,nIdx,nLen,rPos,nKern ); + SvxDoDrawCapital aDo( const_cast(this),pOut,rTxt,nIdx,nLen,rPos,nKern ); DoOnCapitals( aDo ); } diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index e74ad5d0901a..7ec0a8b96fb5 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1548,7 +1548,7 @@ bool SvxAutoCorrect::GetPrevAutoCorrWord( SvxAutoCorrDoc& rDoc, if( LANGUAGE_SYSTEM == eLang ) eLang = MsLangId::getSystemLanguage(); - SvxAutoCorrect* pThis = (SvxAutoCorrect*)this; + SvxAutoCorrect* pThis = const_cast(this); CharClass& rCC = pThis->GetCharClass( eLang ); if( lcl_IsSymbolChar( rCC, rTxt, nCapLttrPos, nEnde )) diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 959bb65f639b..b30bd9579a7b 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -1062,7 +1062,7 @@ void Outliner::PaintBullet( sal_Int32 nPara, const Point& rStartPos, else { // Remove CAST when KA made the Draw-Method const - ((GraphicObject*)pFmt->GetBrush()->GetGraphicObject())->Draw( pOutDev, aBulletPos, pPara->aBulSize ); + const_cast(pFmt->GetBrush()->GetGraphicObject())->Draw( pOutDev, aBulletPos, pPara->aBulSize ); } } } diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx index f0d3fbb1be5c..5057f0389812 100644 --- a/editeng/source/uno/unoforou.cxx +++ b/editeng/source/uno/unoforou.cxx @@ -68,7 +68,7 @@ OUString SvxOutlinerForwarder::GetText( const ESelection& rSel ) const { //! GetText (ESelection) should probably also be in the Outliner // in the time being use as the hack for the EditEngine: - EditEngine* pEditEngine = (EditEngine*)&rOutliner.GetEditEngine(); + EditEngine* pEditEngine = const_cast(&rOutliner.GetEditEngine()); return pEditEngine->GetText( rSel, LINEEND_LF ); } @@ -105,7 +105,7 @@ SfxItemSet SvxOutlinerForwarder::GetAttribs( const ESelection& rSel, EditEngineA if( mpAttribsCache && ( EditEngineAttribs_All == nOnlyHardAttrib ) ) { // have we the correct set in cache? - if( ((SvxOutlinerForwarder*)this)->maAttribCacheSelection.IsEqual(rSel) ) + if( const_cast(this)->maAttribCacheSelection.IsEqual(rSel) ) { // yes! just return the cache return *mpAttribsCache; @@ -173,12 +173,12 @@ void SvxOutlinerForwarder::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rS const SfxItemSet* pOldParent = rSet.GetParent(); if( pOldParent ) - ((SfxItemSet*)&rSet)->SetParent( NULL ); + const_cast(&rSet)->SetParent( NULL ); rOutliner.SetParaAttribs( nPara, rSet ); if( pOldParent ) - ((SfxItemSet*)&rSet)->SetParent( pOldParent ); + const_cast(&rSet)->SetParent( pOldParent ); } void SvxOutlinerForwarder::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich ) diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx index 59f08cdb5144..f42c3cda5c0a 100644 --- a/editeng/source/uno/unoipset.cxx +++ b/editeng/source/uno/unoipset.cxx @@ -222,7 +222,7 @@ uno::Any SvxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry* if(eState >= SfxItemState::DEFAULT && pItem) { pItem->QueryValue( aVal, nMemberId ); - ((SvxItemPropertySet*)this)->AddUsrAnyForID(aVal, pMap->nWID); + const_cast(this)->AddUsrAnyForID(aVal, pMap->nWID); } } @@ -253,7 +253,7 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMa { uno::Any* pUsrAny = GetUsrAnyForID(pMap->nWID); if(!pUsrAny) - ((SvxItemPropertySet*)this)->AddUsrAnyForID(rVal, pMap->nWID); + const_cast(this)->AddUsrAnyForID(rVal, pMap->nWID); else *pUsrAny = rVal; } diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 3d00ca00b7a5..0a94a73194c0 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -678,7 +678,7 @@ void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry* pM break; default: - if(!GetPropertyValueHelper( *((SfxItemSet*)(&rSet)), pMap, rAny, &maSelection, GetEditSource() )) + if(!GetPropertyValueHelper( *const_cast(&rSet), pMap, rAny, &maSelection, GetEditSource() )) rAny = mpPropSet->getPropertyValue(pMap, rSet, true, false ); } } diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index 9116df63c8fd..d5a8aefc282f 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -281,7 +281,7 @@ protected: public: // Internal - const ESelection& GetSelection() const throw() { CheckSelection( ((SvxUnoTextRangeBase*)this)->maSelection, mpEditSource->GetTextForwarder() ); return maSelection; }; + const ESelection& GetSelection() const throw() { CheckSelection( const_cast(this)->maSelection, mpEditSource->GetTextForwarder() ); return maSelection; }; void SetSelection( const ESelection& rSelection ) throw(); void CollapseToStart(void) throw(); -- cgit v1.2.3