From 513fc2916053db5ee7ffaf9f53c271a05cef8981 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 26 Mar 2015 15:32:26 +0100 Subject: const_cast: convert some C-style casts and remove some redundant ones Change-Id: I17c57a85bcda98ef36ddefd6562d4681d0c7d5fc --- include/vcl/window.hxx | 2 +- vcl/generic/fontmanager/fontconfig.cxx | 2 +- vcl/generic/glyphs/gcach_ftyp.cxx | 2 +- vcl/opengl/program.cxx | 4 ++-- vcl/opengl/x11/X11DeviceInfo.cxx | 2 +- vcl/source/app/i18nhelp.cxx | 24 +++++++++---------- vcl/source/app/settings.cxx | 8 +++---- vcl/source/control/field.cxx | 2 +- vcl/source/control/field2.cxx | 2 +- vcl/source/control/tabctrl.cxx | 4 ++-- vcl/source/edit/texteng.cxx | 4 ++-- vcl/source/filter/graphicfilter.cxx | 2 +- vcl/source/filter/ixbm/xbmread.cxx | 2 +- vcl/source/filter/jpeg/JpegWriter.cxx | 2 +- vcl/source/filter/wmf/emfwr.cxx | 20 ++++++++-------- vcl/source/fontsubset/gsub.cxx | 2 +- vcl/source/fontsubset/sft.cxx | 12 +++++----- vcl/source/gdi/animate.cxx | 6 ++--- vcl/source/gdi/bitmap.cxx | 22 +++++++++--------- vcl/source/gdi/bitmapex.cxx | 2 +- vcl/source/gdi/font.cxx | 2 +- vcl/source/gdi/gfxlink.cxx | 2 +- vcl/source/gdi/impgraph.cxx | 6 ++--- vcl/source/gdi/jobset.cxx | 2 +- vcl/source/gdi/pngread.cxx | 2 +- vcl/source/gdi/region.cxx | 8 +++---- vcl/source/gdi/salgdilayout.cxx | 8 +++---- vcl/source/gdi/sallayout.cxx | 2 +- vcl/source/outdev/outdev.cxx | 8 +++---- vcl/source/outdev/polygon.cxx | 2 +- vcl/source/outdev/text.cxx | 2 +- vcl/source/window/accessibility.cxx | 4 ++-- vcl/source/window/builder.cxx | 2 +- vcl/source/window/clipping.cxx | 4 ++-- vcl/source/window/menu.cxx | 2 +- vcl/source/window/splitwin.cxx | 2 +- vcl/source/window/stacking.cxx | 10 ++++---- vcl/source/window/toolbox.cxx | 40 ++++++++++++++++---------------- vcl/source/window/toolbox2.cxx | 6 ++--- vcl/source/window/window.cxx | 10 ++++---- vcl/unx/generic/app/saldisp.cxx | 6 ++--- vcl/unx/generic/gdi/salbmp.cxx | 2 +- vcl/unx/generic/gdi/xrender_peer.hxx | 2 +- vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx | 8 +++---- vcl/unx/gtk/window/gloactiongroup.cxx | 4 ++-- vcl/unx/gtk/window/gtksalmenu.cxx | 8 +++---- 46 files changed, 140 insertions(+), 140 deletions(-) diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index e98a95bea0f2..3712adac90c8 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -506,7 +506,7 @@ private: inline void release() const { if (!--mnRefCnt) - delete const_cast(this); + delete this; } protected: diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx index 8504ef083c39..2a354cca4cf4 100644 --- a/vcl/generic/fontmanager/fontconfig.cxx +++ b/vcl/generic/fontmanager/fontconfig.cxx @@ -922,7 +922,7 @@ IMPL_LINK_NOARG(PrintFontManager, autoInstallFontLangSupport) gchar **fonts = (gchar**)g_malloc((m_aCurrentRequests.size() + 1) * sizeof(gchar*)); gchar **font = fonts; for (std::vector::const_iterator aI = m_aCurrentRequests.begin(); aI != m_aCurrentRequests.end(); ++aI) - *font++ = (gchar*)aI->getStr(); + *font++ = const_cast(aI->getStr()); *font = NULL; gboolean res = dbus_g_proxy_call(proxy, "InstallFontconfigResources", &error, G_TYPE_UINT, xid, /* xid */ diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx index c79c883a4890..887b5f4fb482 100644 --- a/vcl/generic/glyphs/gcach_ftyp.cxx +++ b/vcl/generic/glyphs/gcach_ftyp.cxx @@ -262,7 +262,7 @@ FT_FaceRec_* FtFontInfo::GetFaceFT() if (!maFaceFT && mpFontFile->Map()) { FT_Error rc = FT_New_Memory_Face( aLibFT, - (FT_Byte*)mpFontFile->GetBuffer(), + mpFontFile->GetBuffer(), mpFontFile->GetFileSize(), mnFaceNum, &maFaceFT ); if( (rc != FT_Err_Ok) || (maFaceFT->num_glyphs <= 0) ) maFaceFT = NULL; diff --git a/vcl/opengl/program.cxx b/vcl/opengl/program.cxx index 3504b06847ff..d40aa30695f9 100644 --- a/vcl/opengl/program.cxx +++ b/vcl/opengl/program.cxx @@ -87,7 +87,7 @@ bool OpenGLProgram::Clean() void OpenGLProgram::SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* pData ) { if( rAttrib == SAL_MAX_UINT32 ) - rAttrib = glGetAttribLocation( mnId, (char*) rName.getStr() ); + rAttrib = glGetAttribLocation( mnId, rName.getStr() ); if( (mnEnabledAttribs & ( 1 << rAttrib )) == 0 ) { glEnableVertexAttribArray( rAttrib ); @@ -116,7 +116,7 @@ GLuint OpenGLProgram::GetUniformLocation( const OString& rName ) auto it = maUniformLocations.find( rName ); if( it == maUniformLocations.end() ) { - GLuint nLocation = glGetUniformLocation( mnId, (char*) rName.getStr() ); + GLuint nLocation = glGetUniformLocation( mnId, rName.getStr() ); maUniformLocations[rName] = nLocation; return nLocation; } diff --git a/vcl/opengl/x11/X11DeviceInfo.cxx b/vcl/opengl/x11/X11DeviceInfo.cxx index e7e4b6b10849..74e84c607bd4 100644 --- a/vcl/opengl/x11/X11DeviceInfo.cxx +++ b/vcl/opengl/x11/X11DeviceInfo.cxx @@ -60,7 +60,7 @@ char* strtok_wrapper(const char* aDelims, char** aStr) return nullptr; } - char* ret = (char*)strspnp_wrapper(aDelims, *aStr); + char* ret = const_cast(strspnp_wrapper(aDelims, *aStr)); if (!*ret) { *aStr = ret; diff --git a/vcl/source/app/i18nhelp.cxx b/vcl/source/app/i18nhelp.cxx index c62b4d6f0fdc..0ea1286cd9b0 100644 --- a/vcl/source/app/i18nhelp.cxx +++ b/vcl/source/app/i18nhelp.cxx @@ -64,8 +64,8 @@ utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() co if ( mbTransliterateIgnoreCase ) nModules |= i18n::TransliterationModules_IGNORE_CASE; - ((vcl::I18nHelper*)this)->mpTransliterationWrapper = new utl::TransliterationWrapper( m_xContext, (i18n::TransliterationModules)nModules ); - ((vcl::I18nHelper*)this)->mpTransliterationWrapper->loadModuleIfNeeded( maLanguageTag.getLanguageType() ); + const_cast(this)->mpTransliterationWrapper = new utl::TransliterationWrapper( m_xContext, (i18n::TransliterationModules)nModules ); + const_cast(this)->mpTransliterationWrapper->loadModuleIfNeeded( maLanguageTag.getLanguageType() ); } return *mpTransliterationWrapper; } @@ -74,7 +74,7 @@ LocaleDataWrapper& vcl::I18nHelper::ImplGetLocaleDataWrapper() const { if ( !mpLocaleDataWrapper ) { - ((vcl::I18nHelper*)this)->mpLocaleDataWrapper = new LocaleDataWrapper( m_xContext, maLanguageTag ); + const_cast(this)->mpLocaleDataWrapper = new LocaleDataWrapper( m_xContext, maLanguageTag ); } return *mpLocaleDataWrapper; } @@ -112,15 +112,15 @@ OUString vcl::I18nHelper::filterFormattingChars( const OUString& rStr ) sal_Int32 vcl::I18nHelper::CompareString( const OUString& rStr1, const OUString& rStr2 ) const { - ::osl::Guard< ::osl::Mutex > aGuard( ((vcl::I18nHelper*)this)->maMutex ); + ::osl::Guard< ::osl::Mutex > aGuard( const_cast(this)->maMutex ); if ( mbTransliterateIgnoreCase ) { // Change mbTransliterateIgnoreCase and destroy the wrapper, next call to // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase - ((vcl::I18nHelper*)this)->mbTransliterateIgnoreCase = false; - delete ((vcl::I18nHelper*)this)->mpTransliterationWrapper; - ((vcl::I18nHelper*)this)->mpTransliterationWrapper = NULL; + const_cast(this)->mbTransliterateIgnoreCase = false; + delete const_cast(this)->mpTransliterationWrapper; + const_cast(this)->mpTransliterationWrapper = NULL; } OUString aStr1( filterFormattingChars(rStr1) ); @@ -130,15 +130,15 @@ sal_Int32 vcl::I18nHelper::CompareString( const OUString& rStr1, const OUString& bool vcl::I18nHelper::MatchString( const OUString& rStr1, const OUString& rStr2 ) const { - ::osl::Guard< ::osl::Mutex > aGuard( ((vcl::I18nHelper*)this)->maMutex ); + ::osl::Guard< ::osl::Mutex > aGuard( const_cast(this)->maMutex ); if ( !mbTransliterateIgnoreCase ) { // Change mbTransliterateIgnoreCase and destroy the wrapper, next call to // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase - ((vcl::I18nHelper*)this)->mbTransliterateIgnoreCase = true; - delete ((vcl::I18nHelper*)this)->mpTransliterationWrapper; - ((vcl::I18nHelper*)this)->mpTransliterationWrapper = NULL; + const_cast(this)->mbTransliterateIgnoreCase = true; + delete const_cast(this)->mpTransliterationWrapper; + const_cast(this)->mpTransliterationWrapper = NULL; } OUString aStr1( filterFormattingChars(rStr1) ); @@ -148,7 +148,7 @@ bool vcl::I18nHelper::MatchString( const OUString& rStr1, const OUString& rStr2 bool vcl::I18nHelper::MatchMnemonic( const OUString& rString, sal_Unicode cMnemonicChar ) const { - ::osl::Guard< ::osl::Mutex > aGuard( ((vcl::I18nHelper*)this)->maMutex ); + ::osl::Guard< ::osl::Mutex > aGuard( const_cast(this)->maMutex ); bool bEqual = false; sal_Int32 n = rString.indexOf( '~' ); diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 2906819d0306..b202d64e4d9c 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -2852,7 +2852,7 @@ const LanguageTag& AllSettings::GetUILanguageTag() const const LocaleDataWrapper& AllSettings::GetLocaleDataWrapper() const { if ( !mxData->mpLocaleDataWrapper ) - ((AllSettings*)this)->mxData->mpLocaleDataWrapper = new LocaleDataWrapper( + const_cast(this)->mxData->mpLocaleDataWrapper = new LocaleDataWrapper( comphelper::getProcessComponentContext(), GetLanguageTag() ); return *mxData->mpLocaleDataWrapper; } @@ -2860,7 +2860,7 @@ const LocaleDataWrapper& AllSettings::GetLocaleDataWrapper() const const LocaleDataWrapper& AllSettings::GetUILocaleDataWrapper() const { if ( !mxData->mpUILocaleDataWrapper ) - ((AllSettings*)this)->mxData->mpUILocaleDataWrapper = new LocaleDataWrapper( + const_cast(this)->mxData->mpUILocaleDataWrapper = new LocaleDataWrapper( comphelper::getProcessComponentContext(), GetUILanguageTag() ); return *mxData->mpUILocaleDataWrapper; } @@ -2868,7 +2868,7 @@ const LocaleDataWrapper& AllSettings::GetUILocaleDataWrapper() const const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const { if ( !mxData->mpI18nHelper ) { - ((AllSettings*)this)->mxData->mpI18nHelper = new vcl::I18nHelper( + const_cast(this)->mxData->mpI18nHelper = new vcl::I18nHelper( comphelper::getProcessComponentContext(), GetLanguageTag() ); } return *mxData->mpI18nHelper; @@ -2877,7 +2877,7 @@ const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const const vcl::I18nHelper& AllSettings::GetUILocaleI18nHelper() const { if ( !mxData->mpUII18nHelper ) { - ((AllSettings*)this)->mxData->mpUII18nHelper = new vcl::I18nHelper( + const_cast(this)->mxData->mpUII18nHelper = new vcl::I18nHelper( comphelper::getProcessComponentContext(), GetUILanguageTag() ); } return *mxData->mpUII18nHelper; diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index cab79f5d8cdd..8a9cbedea66d 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -387,7 +387,7 @@ LocaleDataWrapper& FormatterBase::ImplGetLocaleDataWrapper() const { if ( !mpLocaleDataWrapper ) { - ((FormatterBase*)this)->mpLocaleDataWrapper = new LocaleDataWrapper( GetLanguageTag() ); + const_cast(this)->mpLocaleDataWrapper = new LocaleDataWrapper( GetLanguageTag() ); } return *mpLocaleDataWrapper; } diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index c356a827535d..4bf320f61f48 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -1449,7 +1449,7 @@ CalendarWrapper& DateFormatter::GetCalendarWrapper() const { if ( !mpCalendarWrapper ) { - ((DateFormatter*)this)->mpCalendarWrapper = new CalendarWrapper( comphelper::getProcessComponentContext() ); + const_cast(this)->mpCalendarWrapper = new CalendarWrapper( comphelper::getProcessComponentContext() ); mpCalendarWrapper->loadDefaultCalendar( GetLocale() ); } diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index ee09d4074d6b..3d544133c398 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -1611,7 +1611,7 @@ void TabControl::SetTabPageSizePixel( const Size& rSize ) Size TabControl::GetTabPageSizePixel() const { - Rectangle aRect = ((TabControl*)this)->ImplGetTabRect( TAB_PAGERECT ); + Rectangle aRect = const_cast(this)->ImplGetTabRect( TAB_PAGERECT ); return aRect.GetSize(); } @@ -1779,7 +1779,7 @@ sal_uInt16 TabControl::GetPageId( const Point& rPos ) const { for( size_t i = 0; i < mpTabCtrlData->maItemList.size(); ++i ) { - if ( ((TabControl*)this)->ImplGetTabRect( static_cast(i) ).IsInside( rPos ) ) + if ( const_cast(this)->ImplGetTabRect( static_cast(i) ).IsInside( rPos ) ) return mpTabCtrlData->maItemList[ i ].mnId; } diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 644ee1ce30a5..bac8fdbd48d0 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -1149,7 +1149,7 @@ sal_uLong TextEngine::GetTextHeight() const DBG_ASSERT( GetUpdateMode(), "GetTextHeight: GetUpdateMode()" ); if ( !IsFormatted() && !IsFormatting() ) - ((TextEngine*)this)->FormatAndUpdate(); + const_cast(this)->FormatAndUpdate(); return mnCurTextHeight; } @@ -1159,7 +1159,7 @@ sal_uLong TextEngine::GetTextHeight( sal_uLong nParagraph ) const DBG_ASSERT( GetUpdateMode(), "GetTextHeight: GetUpdateMode()" ); if ( !IsFormatted() && !IsFormatting() ) - ((TextEngine*)this)->FormatAndUpdate(); + const_cast(this)->FormatAndUpdate(); return CalcParaHeight( nParagraph ); } diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index fbb4e64f206c..21e643e7af34 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1875,7 +1875,7 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString if( nFormat >= nFormatCount ) return (sal_uInt16) ImplSetError( GRFILTER_FORMATERROR ); - FilterConfigItem aConfigItem( (uno::Sequence< beans::PropertyValue >*)pFilterData ); + FilterConfigItem aConfigItem( const_cast*>(pFilterData) ); OUString aFilterName( pConfig->GetExportFilterName( nFormat ) ); bAbort = false; diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx index 58d8cb79d3dd..ff1eed9ebce1 100644 --- a/vcl/source/filter/ixbm/xbmread.cxx +++ b/vcl/source/filter/ixbm/xbmread.cxx @@ -127,7 +127,7 @@ OString XBMReader::FindTokenLine( SvStream* pInStm, const char* pTok1, long XBMReader::ParseDefine( const sal_Char* pDefine ) { long nRet = 0; - char* pTmp = (char*) pDefine; + char* pTmp = const_cast(pDefine); unsigned char cTmp; // move to end diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx index 16e6ccf17d63..179d3533fe45 100644 --- a/vcl/source/filter/jpeg/JpegWriter.cxx +++ b/vcl/source/filter/jpeg/JpegWriter.cxx @@ -111,7 +111,7 @@ JPEGWriter::JPEGWriter( SvStream& rStream, const css::uno::Sequence< css::beans: mbNative ( false ), mpExpWasGrey ( pExportWasGrey ) { - FilterConfigItem aConfigItem( (css::uno::Sequence< css::beans::PropertyValue >*) pFilterData ); + FilterConfigItem aConfigItem( const_cast*>(pFilterData) ); mbGreys = aConfigItem.ReadInt32( "ColorMode", 0 ) != 0; mnQuality = aConfigItem.ReadInt32( "Quality", 75 ); maChromaSubsampling = aConfigItem.ReadInt32( "ChromaSubsamplingMode", 0 ); diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 6e84f4c8eaa1..ea74f6b618ad 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -899,7 +899,7 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c if( pDXArray ) { nNormWidth = maVDev.GetTextWidth( rText ); - pDX = (long*) pDXArray; + pDX = const_cast(pDXArray); } else { @@ -1405,14 +1405,14 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_LINECOLOR_ACTION ): { - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); mbLineChanged = true; } break; case( META_FILLCOLOR_ACTION ): { - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); mbFillChanged = true; } break; @@ -1423,14 +1423,14 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_TEXTALIGN_ACTION ): case( META_FONT_ACTION ): { - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); mbTextChanged = true; } break; case( META_ISECTRECTCLIPREGION_ACTION ): { - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); ImplBeginRecord( WIN_EMR_INTERSECTCLIPRECT ); ImplWriteRect( static_cast(pAction)->GetRect() ); @@ -1442,18 +1442,18 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_ISECTREGIONCLIPREGION_ACTION ): case( META_MOVECLIPREGION_ACTION ): { - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); } break; case( META_REFPOINT_ACTION ): case( META_MAPMODE_ACTION ): - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); break; case( META_PUSH_ACTION ): { - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); ImplBeginRecord( WIN_EMR_SAVEDC ); ImplEndRecord(); @@ -1462,7 +1462,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_POP_ACTION ): { - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); ImplBeginRecord( WIN_EMR_RESTOREDC ); m_rStm.WriteInt32( -1 ); @@ -1475,7 +1475,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_RASTEROP_ACTION ): { - ( (MetaAction*) pAction )->Execute( &maVDev ); + const_cast(pAction)->Execute( &maVDev ); ImplWriteRasterOp( static_cast(pAction)->GetRasterOp() ); } break; diff --git a/vcl/source/fontsubset/gsub.cxx b/vcl/source/fontsubset/gsub.cxx index 147cba7d735a..6ff77a44fa04 100644 --- a/vcl/source/fontsubset/gsub.cxx +++ b/vcl/source/fontsubset/gsub.cxx @@ -54,7 +54,7 @@ inline sal_uInt16 NEXT_UShort( const unsigned char* &p ) bool ReadGSUB( struct _TrueTypeFont* pTTFile, int nRequestedScript, int nRequestedLangsys ) { - const FT_Byte* pGsubBase = (FT_Byte*)pTTFile->tables[ O_gsub ]; + const FT_Byte* pGsubBase = pTTFile->tables[ O_gsub ]; if( !pGsubBase ) return false; diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 4a0f183e168f..ead68e157cfd 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -300,7 +300,7 @@ _inline int XUnits(int unitsPerEm, int n) _inline const sal_uInt8* getTable( TrueTypeFont *ttf, sal_uInt32 ord) { - return (sal_uInt8*)ttf->tables[ord]; + return ttf->tables[ord]; } _inline sal_uInt32 getTableSize(TrueTypeFont *ttf, sal_uInt32 ord) @@ -1633,7 +1633,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) /* Fixup offsets when only a TTC extract was provided */ if( facenum == (sal_uInt32)~0 ) { - sal_uInt8* pHead = (sal_uInt8*)t->tables[O_head]; + sal_uInt8* pHead = const_cast(t->tables[O_head]); if( !pHead ) return SF_TTFORMAT; /* limit Head candidate to TTC extract's limits */ @@ -1663,7 +1663,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) * Try to fix tables, so we can cope with minor problems. */ - if( (sal_uInt8*)t->tables[i] < t->ptr ) + if( t->tables[i] < t->ptr ) { #if OSL_DEBUG_LEVEL > 1 if( t->tables[i] ) @@ -1672,9 +1672,9 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) t->tlens[i] = 0; t->tables[i] = NULL; } - else if( (sal_uInt8*)t->tables[i] + t->tlens[i] > t->ptr + t->fsize ) + else if( const_cast(t->tables[i]) + t->tlens[i] > t->ptr + t->fsize ) { - int nMaxLen = (t->ptr + t->fsize) - (sal_uInt8*)t->tables[i]; + int nMaxLen = (t->ptr + t->fsize) - t->tables[i]; if( nMaxLen < 0 ) nMaxLen = 0; t->tlens[i] = nMaxLen; @@ -2010,7 +2010,7 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, const sal_uInt8 ptr[] = {0,'T',0,'r',0,'u',0,'e',0,'T',0,'y',0,'p',0,'e',0,'S',0,'u',0,'b',0,'s',0,'e',0,'t'}; NameRecord n1 = {1, 0, 0, 6, 14, const_cast(reinterpret_cast("TrueTypeSubset"))}; NameRecord n2 = {3, 1, 1033, 6, 28, 0}; - n2.sptr = (sal_uInt8 *) ptr; + n2.sptr = const_cast(ptr); name = TrueTypeTableNew_name(0, 0); nameAdd(name, &n1); nameAdd(name, &n2); diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx index 66cfe546d0b3..9efb7fe33c9d 100644 --- a/vcl/source/gdi/animate.cxx +++ b/vcl/source/gdi/animate.cxx @@ -338,9 +338,9 @@ void Animation::Draw( OutputDevice* pOut, const Point& rDestPt, const Size& rDes else { const size_t nOldPos = mnPos; - ( (Animation*) this )->mnPos = mbLoopTerminated ? ( nCount - 1UL ) : mnPos; - delete new ImplAnimView( (Animation*) this, pOut, rDestPt, rDestSz, 0 ); - ( (Animation*) this )->mnPos = nOldPos; + const_cast(this)->mnPos = mbLoopTerminated ? ( nCount - 1UL ) : mnPos; + delete new ImplAnimView( const_cast(this), pOut, rDestPt, rDestSz, 0 ); + const_cast(this)->mnPos = nOldPos; } } } diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index 5a8bad6f341f..2315ab1dbdc7 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -118,7 +118,7 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett } } else - pRealPal = (BitmapPalette*) pPal; + pRealPal = const_cast(pPal); } mpImpBmp = new ImpBitmap; @@ -275,12 +275,12 @@ bool Bitmap::HasGreyPalette() const const sal_uInt16 nBitCount = GetBitCount(); bool bRet = nBitCount == 1; - BitmapInfoAccess* pIAcc = ( (Bitmap*) this )->AcquireInfoAccess(); + BitmapInfoAccess* pIAcc = const_cast(this)->AcquireInfoAccess(); if( pIAcc ) { bRet = pIAcc->HasPalette() && pIAcc->GetPalette().IsGreyPalette(); - ( (Bitmap*) this )->ReleaseAccess( pIAcc ); + const_cast(this)->ReleaseAccess( pIAcc ); } return bRet; @@ -296,7 +296,7 @@ sal_uLong Bitmap::GetChecksum() const if( !nRet ) { - BitmapReadAccess* pRAcc = ( (Bitmap*) this )->AcquireReadAccess(); + BitmapReadAccess* pRAcc = const_cast(this)->AcquireReadAccess(); if( pRAcc && pRAcc->Width() && pRAcc->Height() ) { @@ -334,7 +334,7 @@ sal_uLong Bitmap::GetChecksum() const mpImpBmp->ImplSetChecksum( nRet = nCrc ); } - if (pRAcc) ( (Bitmap*) this )->ReleaseAccess( pRAcc ); + if (pRAcc) const_cast(this)->ReleaseAccess( pRAcc ); } } @@ -846,7 +846,7 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, { if( pBmpSrc && ( *pBmpSrc != *this ) ) { - Bitmap* pSrc = (Bitmap*) pBmpSrc; + Bitmap* pSrc = const_cast(pBmpSrc); const Size aCopySizePix( pSrc->GetSizePixel() ); Rectangle aRectSrc( rRectSrc ); const sal_uInt16 nSrcBitCount = pBmpSrc->GetBitCount(); @@ -1031,7 +1031,7 @@ bool Bitmap::CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangl { if( pBmpSrc && ( *pBmpSrc != *this ) ) { - Bitmap* pSrc = (Bitmap*) pBmpSrc; + Bitmap* pSrc = const_cast(pBmpSrc); const Size aCopySizePix( pSrc->GetSizePixel() ); Rectangle aRectSrc( rRectSrc ); @@ -1191,7 +1191,7 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const if( pWriteAcc ) { - BitmapReadAccess* pReadAcc = ( (Bitmap*) this )->AcquireReadAccess(); + BitmapReadAccess* pReadAcc = const_cast(this)->AcquireReadAccess(); if( pReadAcc ) { @@ -1355,7 +1355,7 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const } } - ( (Bitmap*) this )->ReleaseAccess( pReadAcc ); + const_cast(this)->ReleaseAccess( pReadAcc ); bRet = true; } @@ -1377,7 +1377,7 @@ vcl::Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect ) { vcl::Region aRegion; Rectangle aRect( rRect ); - BitmapReadAccess* pReadAcc = ( (Bitmap*) this )->AcquireReadAccess(); + BitmapReadAccess* pReadAcc = const_cast(this)->AcquireReadAccess(); aRect.Intersection( Rectangle( Point(), GetSizePixel() ) ); aRect.Justify(); @@ -1470,7 +1470,7 @@ vcl::Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect ) //aRegion.ImplEndAddRect(); //aRegion.SetRegionRectangles(aRectangles); - ( (Bitmap*) this )->ReleaseAccess( pReadAcc ); + const_cast(this)->ReleaseAccess( pReadAcc ); } else aRegion = aRect; diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 6d35ec64b3c6..ab451c3f81bc 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -637,7 +637,7 @@ bool BitmapEx::Replace( const Color& rSearchColor, const Color& rReplaceColor, s bool BitmapEx::Replace( const Color* pSearchColors, const Color* pReplaceColors, sal_uLong nColorCount, const sal_uLong* pTols ) { - return !!aBitmap && aBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, (sal_uLong*) pTols ); + return !!aBitmap && aBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, const_cast(pTols) ); } bool BitmapEx::Adjust( short nLuminancePercent, short nContrastPercent, diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx index 43ea999b0cd3..fb7d1368672d 100644 --- a/vcl/source/gdi/font.cxx +++ b/vcl/source/gdi/font.cxx @@ -753,7 +753,7 @@ namespace { bool bResult = false; TrueTypeFont* pTTF = NULL; - if( OpenTTFontBuffer( const_cast(i_pBuffer), i_nSize, 0, &pTTF ) == SF_OK ) + if( OpenTTFontBuffer( i_pBuffer, i_nSize, 0, &pTTF ) == SF_OK ) { TTGlobalFontInfo aInfo; GetTTGlobalFontInfo( pTTF, &aInfo ); diff --git a/vcl/source/gdi/gfxlink.cxx b/vcl/source/gdi/gfxlink.cxx index 2d569659d987..75fd45c356ed 100644 --- a/vcl/source/gdi/gfxlink.cxx +++ b/vcl/source/gdi/gfxlink.cxx @@ -140,7 +140,7 @@ bool GfxLink::IsNative() const const sal_uInt8* GfxLink::GetData() const { if( IsSwappedOut() ) - ( (GfxLink*) this )->SwapIn(); + const_cast(this)->SwapIn(); return( mpBuf ? mpBuf->mpBuffer : NULL ); } diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 98bee4c9bbd1..3f65281a7163 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -891,9 +891,9 @@ void ImpGraphic::ImplDraw( OutputDevice* pOutDev, default: { - ( (ImpGraphic*) this )->maMetaFile.WindStart(); - ( (ImpGraphic*) this )->maMetaFile.Play( pOutDev, rDestPt, rDestSize ); - ( (ImpGraphic*) this )->maMetaFile.WindStart(); + const_cast(this)->maMetaFile.WindStart(); + const_cast(this)->maMetaFile.Play( pOutDev, rDestPt, rDestSize ); + const_cast(this)->maMetaFile.WindStart(); } break; } diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx index 07ddb8326647..df3f47cc043a 100644 --- a/vcl/source/gdi/jobset.cxx +++ b/vcl/source/gdi/jobset.cxx @@ -114,7 +114,7 @@ ImplJobSetup* JobSetup::ImplGetConstData() const ImplJobSetup* JobSetup::ImplGetConstData() const { if ( !mpData ) - ((JobSetup*)this)->mpData = new ImplJobSetup; + const_cast(this)->mpData = new ImplJobSetup; return mpData; } diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx index 4e08ba694e14..38a5bd7b9a3d 100644 --- a/vcl/source/gdi/pngread.cxx +++ b/vcl/source/gdi/pngread.cxx @@ -173,7 +173,7 @@ PNGReaderImpl::PNGReaderImpl( SvStream& rPNGStream ) mpScanPrior ( NULL ), mpTransTab ( NULL ), mpScanCurrent ( NULL ), - mpColorTable ( (sal_uInt8*) mpDefaultColorTable ), + mpColorTable ( const_cast(mpDefaultColorTable) ), mnChunkType ( 0 ), mnChunkLen ( 0 ), mnBPP ( 0 ), diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index fa908deeb253..d6114ef721d4 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -1537,8 +1537,8 @@ bool vcl::Region::operator==( const vcl::Region& rRegion ) const { // one of both has a B2DPolyPolygon based region, ensure both have it // by evtl. conversion - const_cast< vcl::Region* >(this)->GetAsB2DPolyPolygon(); - const_cast< vcl::Region& >(rRegion).GetAsB2DPolyPolygon(); + GetAsB2DPolyPolygon(); + rRegion.GetAsB2DPolyPolygon(); return *rRegion.getB2DPolyPolygon() == *getB2DPolyPolygon(); } @@ -1547,8 +1547,8 @@ bool vcl::Region::operator==( const vcl::Region& rRegion ) const { // one of both has a B2DPolyPolygon based region, ensure both have it // by evtl. conversion - const_cast< vcl::Region* >(this)->GetAsPolyPolygon(); - const_cast< vcl::Region& >(rRegion).GetAsPolyPolygon(); + GetAsPolyPolygon(); + rRegion.GetAsPolyPolygon(); return *rRegion.getPolyPolygon() == *getPolyPolygon(); } diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 0112071adcc5..760f1899f511 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -105,7 +105,7 @@ void SalGraphics::mirror( long& x, const OutputDevice *pOutDev, bool bBack ) con { if( pOutDev && pOutDev->ImplIsAntiparallel() ) { - OutputDevice *pOutDevRef = (OutputDevice*) pOutDev; + OutputDevice *pOutDevRef = const_cast(pOutDev); // mirror this window back if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) { @@ -137,7 +137,7 @@ void SalGraphics::mirror( long& x, long& nWidth, const OutputDevice *pOutDev, bo { if( pOutDev && pOutDev->ImplIsAntiparallel() ) { - OutputDevice *pOutDevRef = (OutputDevice*) pOutDev; + OutputDevice *pOutDevRef = const_cast(pOutDev); // mirror this window back if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) { @@ -172,7 +172,7 @@ bool SalGraphics::mirror( sal_uInt32 nPoints, const SalPoint *pPtAry, SalPoint * if( pOutDev && pOutDev->ImplIsAntiparallel() ) { - OutputDevice *pOutDevRef = (OutputDevice*) pOutDev; + OutputDevice *pOutDevRef = const_cast(pOutDev); // mirror this window back if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) { @@ -295,7 +295,7 @@ basegfx::B2DPoint SalGraphics::mirror( const basegfx::B2DPoint& i_rPoint, const { if( i_pOutDev && !i_pOutDev->IsRTLEnabled() ) { - OutputDevice *pOutDevRef = (OutputDevice*)i_pOutDev; + OutputDevice *pOutDevRef = const_cast(i_pOutDev); // mirror this window back double devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX if( i_bBack ) diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index fbaeb22a468a..9ba3dcc21d02 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -668,7 +668,7 @@ void SalLayout::Release() const if( --mnRefCount > 0 ) return; // const_cast because some compilers violate ANSI C++ spec - delete const_cast(this); + delete this; } Point SalLayout::GetDrawPosition( const Point& rRelative ) const diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 0fe76778cd1e..0747b7b210e8 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -394,7 +394,7 @@ sal_uInt16 OutputDevice::GetBitCount() const // we need a graphics instance if ( !mpGraphics ) { - if ( !((OutputDevice*)this)->AcquireGraphics() ) + if ( !AcquireGraphics() ) return 0; } @@ -656,7 +656,7 @@ void OutputDevice::drawOutDevDirect( const OutputDevice* pSrcDev, SalTwoRect& rP { if ( !pSrcDev->mpGraphics ) { - if ( !((OutputDevice*)pSrcDev)->AcquireGraphics() ) + if ( !pSrcDev->AcquireGraphics() ) return; } pSrcGraphics = pSrcDev->mpGraphics; @@ -669,7 +669,7 @@ void OutputDevice::drawOutDevDirect( const OutputDevice* pSrcDev, SalTwoRect& rP { if ( !pSrcDev->mpGraphics ) { - if ( !((OutputDevice*)pSrcDev)->AcquireGraphics() ) + if ( !pSrcDev->AcquireGraphics() ) return; } pSrcGraphics = pSrcDev->mpGraphics; @@ -814,7 +814,7 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, aRect.Justify(); bDrawn = mpGraphics->DrawEPS( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), - (sal_uInt8*) rGfxLink.GetData(), rGfxLink.GetDataSize(), this ); + const_cast(rGfxLink.GetData()), rGfxLink.GetDataSize(), this ); } // else draw the substitution graphics diff --git a/vcl/source/outdev/polygon.cxx b/vcl/source/outdev/polygon.cxx index fdcb85227543..36f63ac8e4ba 100644 --- a/vcl/source/outdev/polygon.cxx +++ b/vcl/source/outdev/polygon.cxx @@ -435,7 +435,7 @@ void OutputDevice::ImplDrawPolyPolygon( const tools::PolyPolygon& rPolyPoly, con } else { - pPolyPoly = (tools::PolyPolygon*) &rPolyPoly; + pPolyPoly = const_cast(&rPolyPoly); } if( pPolyPoly->Count() == 1 ) { diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 113a42e6e222..9b97d1de1928 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1363,7 +1363,7 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr, pDXPixelArray[i] = pDXArray[i]; } #else /* !VCL_FLOAT_DEVICE_PIXEL */ - pDXPixelArray = (DeviceCoordinate*)pDXArray; + pDXPixelArray = const_cast(pDXArray); #endif /* !VCL_FLOAT_DEVICE_PIXEL */ } } diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx index e21197dc093c..fc3dc74d009d 100644 --- a/vcl/source/window/accessibility.cxx +++ b/vcl/source/window/accessibility.cxx @@ -452,7 +452,7 @@ sal_uInt16 Window::getDefaultAccessibleRole() const nRole = accessibility::AccessibleRole::FRAME; else if( IsScrollable() ) nRole = accessibility::AccessibleRole::SCROLL_PANE; - else if( ((vcl::Window*)this)->ImplGetWindow()->IsMenuFloatingWindow() ) + else if( const_cast(this)->ImplGetWindow()->IsMenuFloatingWindow() ) nRole = accessibility::AccessibleRole::WINDOW; // #106002#, contextmenus are windows (i.e. toplevel) else // #104051# WINDOW seems to be a bad default role, use LAYEREDPANE instead @@ -579,7 +579,7 @@ OUString Window::GetAccessibleDescription() const { // Special code for help text windows. ZT asks the border window for the // description so we have to forward this request to our inner window. - const vcl::Window* pWin = ((vcl::Window *)this)->ImplGetWindow(); + const vcl::Window* pWin = const_cast(this)->ImplGetWindow(); if ( pWin->GetType() == WINDOW_HELPTEXTWINDOW ) aAccessibleDescription = pWin->GetHelpText(); else diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 31736c43f787..f7de2d12130a 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -153,7 +153,7 @@ void VclBuilder::loadTranslations(const LanguageTag &rLanguageTag, const OUStrin break; } - xmlreader::XmlReader reader(const_cast(sStr.getStr()), sStr.getLength()); + xmlreader::XmlReader reader(sStr.getStr(), sStr.getLength()); handleTranslations(reader); break; } diff --git a/vcl/source/window/clipping.cxx b/vcl/source/window/clipping.cxx index b2054f8f77a4..0c24e3051832 100644 --- a/vcl/source/window/clipping.cxx +++ b/vcl/source/window/clipping.cxx @@ -120,12 +120,12 @@ vcl::Region Window::GetWindowClipRegionPixel( sal_uInt16 nFlags ) const if ( nFlags & WINDOW_GETCLIPREGION_NOCHILDREN ) { if ( mpWindowImpl->mbInitWinClipRegion ) - ((vcl::Window*)this)->ImplInitWinClipRegion(); + const_cast(this)->ImplInitWinClipRegion(); aWinClipRegion = mpWindowImpl->maWinClipRegion; } else { - vcl::Region* pWinChildClipRegion = ((vcl::Window*)this)->ImplGetWinChildClipRegion(); + vcl::Region* pWinChildClipRegion = const_cast(this)->ImplGetWinChildClipRegion(); aWinClipRegion = *pWinChildClipRegion; // --- RTL --- remirror clip region before passing it to somebody if( ImplIsAntiparallel() ) diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 5de3bb66120d..8cdcd0f7f346 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2364,7 +2364,7 @@ void Menu::ImplSetSalMenu( SalMenu *pSalMenu ) bool Menu::GetSystemMenuData( SystemMenuData* pData ) const { - Menu* pMenu = (Menu*)this; + Menu* pMenu = const_cast(this); if( pData && pMenu->ImplGetSalMenu() ) { pMenu->ImplGetSalMenu()->GetSystemMenuData( pData ); diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx index c777f371ea37..86db81283a4f 100644 --- a/vcl/source/window/splitwin.cxx +++ b/vcl/source/window/splitwin.cxx @@ -3051,7 +3051,7 @@ long SplitWindow::GetItemSize( sal_uInt16 nId, SplitWindowItemBits nBits ) const return pSet->mpItems[nPos].mnSize; else { - ((SplitWindow*)this)->ImplCalcLayout(); + const_cast(this)->ImplCalcLayout(); long nRelSize = 0; long nPerSize = 0; diff --git a/vcl/source/window/stacking.cxx b/vcl/source/window/stacking.cxx index fc676ed70f8a..ee29a8deabda 100644 --- a/vcl/source/window/stacking.cxx +++ b/vcl/source/window/stacking.cxx @@ -643,7 +643,7 @@ bool Window::IsTopWindow() const if( mpWindowImpl->mpWinData->mnIsTopWindow == (sal_uInt16)~0) // still uninitialized { // #113722#, cache result of expensive queryInterface call - vcl::Window *pThisWin = (vcl::Window*)this; + vcl::Window *pThisWin = const_cast(this); uno::Reference< XTopWindow > xTopWindow( pThisWin->GetComponentInterface(), UNO_QUERY ); pThisWin->mpWindowImpl->mpWinData->mnIsTopWindow = xTopWindow.is() ? 1 : 0; } @@ -654,7 +654,7 @@ vcl::Window* Window::FindWindow( const Point& rPos ) const { Point aPos = OutputToScreenPixel( rPos ); - return ((vcl::Window*)this)->ImplFindWindow( aPos ); + return const_cast(this)->ImplFindWindow( aPos ); } vcl::Window* Window::ImplFindWindow( const Point& rFramePos ) @@ -1079,7 +1079,7 @@ vcl::Window* Window::GetWindow( sal_uInt16 nType ) const case WINDOW_OVERLAP: if ( ImplIsOverlapWindow() ) - return (vcl::Window*)this; + return const_cast(this); else return mpWindowImpl->mpOverlapWindow; @@ -1090,7 +1090,7 @@ vcl::Window* Window::GetWindow( sal_uInt16 nType ) const return mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpOverlapWindow; case WINDOW_CLIENT: - return ((vcl::Window*)this)->ImplGetWindow(); + return const_cast(this)->ImplGetWindow(); case WINDOW_REALPARENT: return ImplGetParent(); @@ -1101,7 +1101,7 @@ vcl::Window* Window::GetWindow( sal_uInt16 nType ) const case WINDOW_BORDER: if ( mpWindowImpl->mpBorderWindow ) return mpWindowImpl->mpBorderWindow->GetWindow( WINDOW_BORDER ); - return (vcl::Window*)this; + return const_cast(this); case WINDOW_FIRSTTOPWINDOWCHILD: return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.begin(); diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index e6b7c1592405..1e92d1d00d1b 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -212,7 +212,7 @@ void ToolBox::ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop, ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( pThis ); // reserve dragarea only for dockable toolbars - int dragwidth = ( pWrapper && !pWrapper->IsLocked() ) ? ImplGetDragWidth( (ToolBox*)pThis ) : 0; + int dragwidth = ( pWrapper && !pWrapper->IsLocked() ) ? ImplGetDragWidth( const_cast(pThis) ) : 0; // no shadow border for dockable toolbars int borderwidth = pWrapper ? 0: 2; @@ -682,39 +682,39 @@ Size ToolBox::ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uIn { pThis->mpData->mbAssumeDocked = true; // force non-floating mode during calculation ImplCalcBorder( WINDOWALIGN_TOP, nLeft, nTop, nRight, nBottom, pThis ); - ((ToolBox*)pThis)->mbHorz = true; + const_cast(pThis)->mbHorz = true; if ( pThis->mbHorz != bOldHorz ) - ((ToolBox*)pThis)->meAlign = WINDOWALIGN_TOP; + const_cast(pThis)->meAlign = WINDOWALIGN_TOP; } else if ( nCalcMode == TB_CALCMODE_VERT ) { pThis->mpData->mbAssumeDocked = true; // force non-floating mode during calculation ImplCalcBorder( WINDOWALIGN_LEFT, nLeft, nTop, nRight, nBottom, pThis ); - ((ToolBox*)pThis)->mbHorz = false; + const_cast(pThis)->mbHorz = false; if ( pThis->mbHorz != bOldHorz ) - ((ToolBox*)pThis)->meAlign = WINDOWALIGN_LEFT; + const_cast(pThis)->meAlign = WINDOWALIGN_LEFT; } else if ( nCalcMode == TB_CALCMODE_FLOAT ) { pThis->mpData->mbAssumeFloating = true; // force non-floating mode during calculation nLeft = nTop = nRight = nBottom = 0; - ((ToolBox*)pThis)->mbHorz = true; + const_cast(pThis)->mbHorz = true; if ( pThis->mbHorz != bOldHorz ) - ((ToolBox*)pThis)->meAlign = WINDOWALIGN_TOP; + const_cast(pThis)->meAlign = WINDOWALIGN_TOP; } if ( (pThis->meAlign != eOldAlign) || (pThis->mbHorz != bOldHorz) || (pThis->ImplIsFloatingMode() != bOldFloatingMode ) ) - ((ToolBox*)pThis)->mbCalc = true; + const_cast(pThis)->mbCalc = true; } else ImplCalcBorder( pThis->meAlign, nLeft, nTop, nRight, nBottom, pThis ); - ((ToolBox*)pThis)->ImplCalcItem(); + const_cast(pThis)->ImplCalcItem(); if( !nCalcMode && pThis->ImplIsFloatingMode() ) { - aSize = ImplCalcFloatSize( ((ToolBox*)pThis), nCalcLines ); + aSize = ImplCalcFloatSize( const_cast(pThis), nCalcLines ); } else { @@ -732,7 +732,7 @@ Size ToolBox::ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uIn aSize.Height() += (TB_BORDER_OFFSET2*2) + nTop + nBottom; nMax = 0; - ((ToolBox*)pThis)->ImplCalcBreaks( TB_MAXNOSCROLL, &nMax, pThis->mbHorz ); + const_cast(pThis)->ImplCalcBreaks( TB_MAXNOSCROLL, &nMax, pThis->mbHorz ); if ( nMax ) aSize.Width() += nMax; @@ -750,7 +750,7 @@ Size ToolBox::ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uIn aSize.Width() += (TB_BORDER_OFFSET2*2) + nLeft + nRight; nMax = 0; - ((ToolBox*)pThis)->ImplCalcBreaks( TB_MAXNOSCROLL, &nMax, pThis->mbHorz ); + const_cast(pThis)->ImplCalcBreaks( TB_MAXNOSCROLL, &nMax, pThis->mbHorz ); if ( nMax ) aSize.Height() += nMax; @@ -765,9 +765,9 @@ Size ToolBox::ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uIn pThis->mpData->mbAssumeFloating = bOldAssumeFloating; if ( (pThis->meAlign != eOldAlign) || (pThis->mbHorz != bOldHorz) ) { - ((ToolBox*)pThis)->meAlign = eOldAlign; - ((ToolBox*)pThis)->mbHorz = bOldHorz; - ((ToolBox*)pThis)->mbCalc = true; + const_cast(pThis)->meAlign = eOldAlign; + const_cast(pThis)->mbHorz = bOldHorz; + const_cast(pThis)->mbCalc = true; } } @@ -4757,8 +4757,8 @@ sal_uInt16 ToolBox::ImplCountLineBreaks( const ToolBox *pThis ) { sal_uInt16 nLines = 0; - std::vector< ImplToolItem >::const_iterator it = ((ToolBox*)pThis)->mpData->m_aItems.begin(); - while ( it != ((ToolBox*)pThis)->mpData->m_aItems.end() ) + std::vector< ImplToolItem >::const_iterator it = const_cast(pThis)->mpData->m_aItems.begin(); + while ( it != const_cast(pThis)->mpData->m_aItems.end() ) { if( it->meType == ToolBoxItemType::BREAK ) ++nLines; @@ -4781,7 +4781,7 @@ Size ToolBox::CalcPopupWindowSizePixel() const } bool bPopup = mpData->mbAssumePopupMode; - ToolBox *pThis = (ToolBox*) this; + ToolBox *pThis = const_cast(this); pThis->mpData->mbAssumePopupMode = true; Size aSize = CalcFloatingWindowSizePixel( nLines ); @@ -4803,11 +4803,11 @@ Size ToolBox::CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines ) const bool bDocking = mpData->mbAssumeDocked; // simulate floating mode and force reformat before calculating - ToolBox *pThis = (ToolBox*) this; + ToolBox *pThis = const_cast(this); pThis->mpData->mbAssumeFloating = true; pThis->mpData->mbAssumeDocked = false; - Size aSize = ImplCalcFloatSize( (ToolBox*) this, nCalcLines ); + Size aSize = ImplCalcFloatSize( const_cast(this), nCalcLines ); pThis->mbFormat = true; pThis->mpData->mbAssumeFloating = bFloat; diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 5b6553fa7cf4..0bf058322410 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -1005,7 +1005,7 @@ Point ToolBox::GetItemPopupPosition( sal_uInt16 nItemId, const Size& rSize ) con Rectangle ToolBox::GetItemRect( sal_uInt16 nItemId ) const { if ( mbCalc || mbFormat ) - ((ToolBox*)this)->ImplFormat(); + const_cast(this)->ImplFormat(); sal_uInt16 nPos = GetItemPos( nItemId ); return GetItemPosRect( nPos ); @@ -1014,7 +1014,7 @@ Rectangle ToolBox::GetItemRect( sal_uInt16 nItemId ) const Rectangle ToolBox::GetItemPosRect( sal_uInt16 nPos ) const { if ( mbCalc || mbFormat ) - ((ToolBox*)this)->ImplFormat(); + const_cast(this)->ImplFormat(); if ( nPos < mpData->m_aItems.size() ) return mpData->m_aItems[nPos].maRect; @@ -1025,7 +1025,7 @@ Rectangle ToolBox::GetItemPosRect( sal_uInt16 nPos ) const Size ToolBox::GetItemContentSize( sal_uInt16 nItemId ) const { if ( mbCalc || mbFormat ) - ((ToolBox*)this)->ImplFormat(); + const_cast(this)->ImplFormat(); sal_uInt16 nPos = GetItemPos( nItemId ); if ( nPos < mpData->m_aItems.size() ) diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index cb931cb85d0a..8d7339fcb696 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -1247,7 +1247,7 @@ ImplWinData* Window::ImplGetWinData() const { static const char* pNoNWF = getenv( "SAL_NO_NWF" ); - ((vcl::Window*)this)->mpWindowImpl->mpWinData = new ImplWinData; + const_cast(this)->mpWindowImpl->mpWinData = new ImplWinData; mpWindowImpl->mpWinData->mpExtOldText = NULL; mpWindowImpl->mpWinData->mpExtOldAttrAry = NULL; mpWindowImpl->mpWinData->mpCursorRect = NULL; @@ -2131,9 +2131,9 @@ long Window::CalcTitleWidth() const // border of external dialogs const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); vcl::Font aFont = GetFont(); - ((vcl::Window*)this)->SetPointFont( rStyleSettings.GetTitleFont() ); + const_cast(this)->SetPointFont( rStyleSettings.GetTitleFont() ); long nTitleWidth = GetTextWidth( GetText() ); - ((vcl::Window*)this)->SetFont( aFont ); + const_cast(this)->SetFont( aFont ); nTitleWidth += rStyleSettings.GetTitleHeight() * 3; nTitleWidth += rStyleSettings.GetBorderSize() * 2; nTitleWidth += 10; @@ -2973,14 +2973,14 @@ long Window::ImplGetUnmirroredOutOffX() Point Window::OutputToNormalizedScreenPixel( const Point& rPos ) const { // relative to top level parent - long offx = ((vcl::Window*) this)->ImplGetUnmirroredOutOffX(); + long offx = const_cast(this)->ImplGetUnmirroredOutOffX(); return Point( rPos.X()+offx, rPos.Y()+mnOutOffY ); } Point Window::NormalizedScreenToOutputPixel( const Point& rPos ) const { // relative to top level parent - long offx = ((vcl::Window*) this)->ImplGetUnmirroredOutOffX(); + long offx = const_cast(this)->ImplGetUnmirroredOutOffX(); return Point( rPos.X()-offx, rPos.Y()-mnOutOffY ); } diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index dcdf0bd16726..47ecec852431 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -2729,7 +2729,7 @@ SalColor SalColormap::GetColor( Pixel nPixel ) const && m_hColormap && m_aVisual.GetDepth() <= 12 && m_aVisual.GetClass() == PseudoColor ) - ((SalColormap*)this)->GetPalette(); + const_cast(this)->GetPalette(); } if( !m_aPalette.empty() && nPixel < m_nUsed ) @@ -2789,7 +2789,7 @@ Pixel SalColormap::GetPixel( SalColor nSalColor ) const && m_hColormap && m_aVisual.GetDepth() <= 12 && m_aVisual.GetClass() == PseudoColor ) // what else ??? - ((SalColormap*)this)->GetPalette(); + const_cast(this)->GetPalette(); if( !m_aPalette.empty() ) for( Pixel i = 0; i < m_nUsed; i++ ) @@ -2850,7 +2850,7 @@ Pixel SalColormap::GetPixel( SalColor nSalColor ) const return nSalColor; } - ((SalColormap*)this)->GetLookupTable(); + const_cast(this)->GetLookupTable(); } // Colormatching ueber Palette diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index f301148cb51f..fb003fb7ce7a 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -368,7 +368,7 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB( nDstFormat = aSrcBuf.mnFormat; pDIB = StretchAndConvert( aSrcBuf, aTwoRect, nDstFormat, - const_cast(pDstPal), &aSrcBuf.maColorMask ); + pDstPal, &aSrcBuf.maColorMask ); XDestroyImage( pImage ); } } diff --git a/vcl/unx/generic/gdi/xrender_peer.hxx b/vcl/unx/generic/gdi/xrender_peer.hxx index 84622e80c4ce..79609d624ba9 100644 --- a/vcl/unx/generic/gdi/xrender_peer.hxx +++ b/vcl/unx/generic/gdi/xrender_peer.hxx @@ -145,7 +145,7 @@ inline void XRenderPeer::AddGlyph( GlyphSet aGS, XRenderGlyph nXRGlyph, const XGlyphInfo& rGI, const char* pBuffer, int nBufSize ) const { XRenderAddGlyphs( mpDisplay, aGS, &nXRGlyph, &rGI, 1, - const_cast(pBuffer), nBufSize ); + pBuffer, nBufSize ); } inline void XRenderPeer::FreeGlyph( GlyphSet aGS, XRenderGlyph nXRGlyph ) const diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index 27886a131b9c..ab0ab95d9d0e 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -1940,8 +1940,8 @@ bool GtkSalGraphics::NWPaintGTKScrollbar( ControlType, ControlPart nPart, Rectangle button21BoundRect = rScrollbarVal.maButton2Rect; // secondary backward GtkArrowType button1Type; // backward GtkArrowType button2Type; // forward - gchar * scrollbarTagH = (gchar *) "hscrollbar"; - gchar * scrollbarTagV = (gchar *) "vscrollbar"; + gchar * scrollbarTagH = const_cast("hscrollbar"); + gchar * scrollbarTagV = const_cast("vscrollbar"); gchar * scrollbarTag = NULL; Rectangle arrowRect; gint slider_width = 0; @@ -2876,7 +2876,7 @@ bool GtkSalGraphics::NWPaintGTKTabItem( ControlType nType, ControlPart, case CTRL_TAB_PANE: gtk_paint_box_gap( gWidgetData[m_nXScreen].gNotebookWidget->style, gdkPixmap, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, gWidgetData[m_nXScreen].gNotebookWidget, - (char *)"notebook", 0, 0, pixmapRect.GetWidth(), pixmapRect.GetHeight(), GTK_POS_TOP, 0, 0 ); + "notebook", 0, 0, pixmapRect.GetWidth(), pixmapRect.GetHeight(), GTK_POS_TOP, 0, 0 ); break; case CTRL_TAB_ITEM: @@ -2896,7 +2896,7 @@ bool GtkSalGraphics::NWPaintGTKTabItem( ControlType nType, ControlPart, g_object_set_data(G_OBJECT(gdkPixmap),tabPrelitDataName,reinterpret_cast(TRUE)); gtk_paint_extension( gWidgetData[m_nXScreen].gNotebookWidget->style, gdkPixmap, stateType, GTK_SHADOW_OUT, NULL, gWidgetData[m_nXScreen].gNotebookWidget, - (char *)"tab", (tabRect.Left() - pixmapRect.Left()), (tabRect.Top() - pixmapRect.Top()), + "tab", (tabRect.Left() - pixmapRect.Left()), (tabRect.Top() - pixmapRect.Top()), tabRect.GetWidth(), tabRect.GetHeight(), GTK_POS_BOTTOM ); g_object_steal_data(G_OBJECT(gdkPixmap),tabPrelitDataName); diff --git a/vcl/unx/gtk/window/gloactiongroup.cxx b/vcl/unx/gtk/window/gloactiongroup.cxx index 8cbc32622ce2..11145e3c44c3 100644 --- a/vcl/unx/gtk/window/gloactiongroup.cxx +++ b/vcl/unx/gtk/window/gloactiongroup.cxx @@ -320,10 +320,10 @@ g_lo_action_group_insert_stateful (GLOActionGroup *group, action->submenu = submenu; if (parameter_type) - action->parameter_type = (GVariantType*) parameter_type; + action->parameter_type = const_cast(parameter_type); if (state_type) - action->state_type = (GVariantType*) state_type; + action->state_type = const_cast(state_type); if (state_hint) action->state_hint = g_variant_ref_sink (state_hint); diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx index 8448a91fd9e4..afe9e7a4be1b 100644 --- a/vcl/unx/gtk/window/gtksalmenu.cxx +++ b/vcl/unx/gtk/window/gtksalmenu.cxx @@ -159,7 +159,7 @@ bool GtkSalMenu::PrepUpdate() const GtkSalFrame* pFrame = GetFrame(); if (pFrame) { - GtkSalFrame* pNonConstFrame = ( GtkSalFrame* ) pFrame; + GtkSalFrame* pNonConstFrame = const_cast(pFrame); GtkSalMenu* pSalMenu = ((GtkSalMenu*) this); if ( !pNonConstFrame->GetMenu() ) @@ -718,7 +718,7 @@ GtkSalMenu* GtkSalMenu::GetMenuForItemCommand( gchar* aCommand, gboolean bGetSub // immediately, and the gchar* pointed to by aItemCommandStr will be // freed before it can be used - fdo#69090 OString aItemCommandOStr = OUStringToOString( aItemCommand, RTL_TEXTENCODING_UTF8 ); - gchar* aItemCommandStr = (gchar*) aItemCommandOStr.getStr(); + gchar* aItemCommandStr = const_cast(aItemCommandOStr.getStr()); if ( g_strcmp0( aItemCommandStr, aCommand ) == 0 ) { @@ -745,7 +745,7 @@ void GtkSalMenu::DispatchCommand( gint itemId, const gchar *aCommand ) if ( !mbMenuBar ) return; - GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( (gchar*) aCommand, FALSE ); + GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast(aCommand), FALSE ); Menu* pSubMenu = ( pSalSubMenu != NULL ) ? pSalSubMenu->GetMenu() : NULL; MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu ); @@ -778,7 +778,7 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand ) if ( !mbMenuBar ) return; - GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( (gchar*) aMenuCommand, TRUE ); + GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast(aMenuCommand), TRUE ); if ( pSalSubMenu != NULL ) { MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu ); -- cgit