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

Change-Id: Id0a3194e20128ad6defb95b51757dd01fcab9eb1
This commit is contained in:
Stephan Bergmann 2015-03-26 15:28:40 +01:00
parent 812e5e8ed7
commit ac3ebf3bde
8 changed files with 19 additions and 19 deletions

View file

@ -384,11 +384,11 @@ Reference< XNameAccess > BibliographyLoader::GetDataColumns() const
xRowSet = NULL;
}
else
((BibliographyLoader*)this)->m_xCursor = xRowSet.get();
const_cast<BibliographyLoader*>(this)->m_xCursor = xRowSet.get();
Reference< sdbcx::XColumnsSupplier > xSupplyCols(m_xCursor, UNO_QUERY);
if (xSupplyCols.is())
((BibliographyLoader*)this)->m_xColumns = xSupplyCols->getColumns();
const_cast<BibliographyLoader*>(this)->m_xColumns = xSupplyCols->getColumns();
}
return m_xColumns;

View file

@ -306,7 +306,7 @@ void BibToolBar::Select()
else
{
Sequence<PropertyValue> aPropVal(2);
PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray());
pPropertyVal[0].Name="QueryText";
OUString aSelection = aEdQuery.GetText();
pPropertyVal[0].Value <<= aSelection;
@ -434,7 +434,7 @@ bool BibToolBar::PreNotify( NotifyEvent& rNEvt )
if(nKey == KEY_RETURN)
{
Sequence<PropertyValue> aPropVal(2);
PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray());
pPropertyVal[0].Name = "QueryText";
OUString aSelection = aEdQuery.GetText();
pPropertyVal[0].Value <<= aSelection;
@ -460,7 +460,7 @@ IMPL_LINK( BibToolBar, SelHdl, ListBox*, /*pLb*/ )
IMPL_LINK( BibToolBar, SendSelHdl, Timer*,/*pT*/)
{
Sequence<PropertyValue> aPropVal(1);
PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray());
pPropertyVal[0].Name = "DataSourceName";
OUString aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource.GetSelectEntry() ) );
OUString aSelection = aEntry;
@ -488,7 +488,7 @@ IMPL_LINK( BibToolBar, MenuHdl, ToolBox*, /*pToolbox*/)
nSelMenuItem=nId;
aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) );
Sequence<PropertyValue> aPropVal(2);
PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray());
pPropertyVal[0].Name = "QueryText";
OUString aSelection = aEdQuery.GetText();
pPropertyVal[0].Value <<= aSelection;

View file

@ -559,8 +559,8 @@ void XPlugin_Impl::loadPlugin()
}
getPluginComm()->
NPP_New( (char*)OUStringToOString( m_aDescription.Mimetype,
m_aEncoding).getStr(),
NPP_New( const_cast<char*>(OUStringToOString( m_aDescription.Mimetype,
m_aEncoding).getStr()),
&getNPPInstance(),
m_aPluginMode == PluginMode::FULL ? NP_FULL : NP_EMBED,
::sal::static_int_cast< int16_t, int >( m_nArgs ),
@ -767,7 +767,7 @@ sal_Bool XPlugin_Impl::provideNewStream(const OUString& mimetype,
#endif
if( ! m_pPluginComm->NPP_NewStream( &m_aInstance,
(char*)aMIME.getStr(),
const_cast<char*>(aMIME.getStr()),
&pStream->getStream(), isfile,
&stype ) )
{

View file

@ -203,7 +203,8 @@ enum CommandAtoms
const char* GetCommandName( CommandAtoms );
#define POST_STRING( x ) x ? x : const_cast<char*>(""), x ? strlen(x) : 1
#define POST_NONCONST_STRING( x ) x ? x : const_cast<char*>(""), x ? strlen(x) : 1
#define POST_STRING( x ) x ? x : "", x ? strlen(x) : 1
#endif // INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_PLUGCON_HXX

View file

@ -886,7 +886,7 @@ IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ )
osl_getAsciiFunctionSymbol( pPluginLib, "NPP_GetMIMEDescription" ));
char* pMIME = pNPP_GetMIMEDescription();
Respond( pMessage->m_nID,
POST_STRING( pMIME ),
POST_NONCONST_STRING( pMIME ),
NULL );
}
break;

View file

@ -310,7 +310,7 @@ IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ )
NPP instance = m_aInstances[ nInstance ]->instance;
const char* pAnswer = NPN_UserAgent( instance );
Respond( pMessage->m_nID,
(char*)pAnswer, strlen( pAnswer ),
const_cast<char*>(pAnswer), strlen( pAnswer ),
NULL );
}
break;
@ -607,7 +607,7 @@ char* UnxPluginComm::NPP_GetMIMEDescription()
Transact( eNPP_GetMIMEDescription,
NULL );
if( ! pMes )
return (char*)"";
return const_cast<char*>("");
if( pDesc )
delete [] pDesc;

View file

@ -276,8 +276,7 @@ void Sane::ReloadOptions()
mppOptions = new const SANE_Option_Descriptor*[ mnOptions ];
mppOptions[ 0 ] = pZero;
for( int i = 1; i < mnOptions; i++ )
mppOptions[ i ] = (SANE_Option_Descriptor*)
p_get_option_descriptor( maHandle, i );
mppOptions[ i ] = p_get_option_descriptor( maHandle, i );
CheckConsistency( NULL, true );
@ -312,7 +311,7 @@ bool Sane::Open( int n )
if( n >= 0 && n < nDevices )
{
mnDevice = n;
return Open( (char*)ppDevices[n]->name );
return Open( ppDevices[n]->name );
}
return false;
}

View file

@ -127,9 +127,9 @@ public:
{ return ppDevices[n]->type ? OUString( ppDevices[n]->type, strlen(ppDevices[n]->type), osl_getThreadTextEncoding() ) : OUString(); }
OUString GetOptionName( int n )
{ return mppOptions[n]->name ? OUString( (char*)mppOptions[n]->name, strlen((char*)mppOptions[n]->name), osl_getThreadTextEncoding() ) : OUString(); }
{ return mppOptions[n]->name ? OUString( mppOptions[n]->name, strlen(mppOptions[n]->name), osl_getThreadTextEncoding() ) : OUString(); }
OUString GetOptionTitle( int n )
{ return mppOptions[n]->title ? OUString( (char*)mppOptions[n]->title, strlen((char*)mppOptions[n]->title), osl_getThreadTextEncoding() ) : OUString(); }
{ return mppOptions[n]->title ? OUString( mppOptions[n]->title, strlen(mppOptions[n]->title), osl_getThreadTextEncoding() ) : OUString(); }
SANE_Value_Type GetOptionType( int n )
{ return mppOptions[n]->type; }
SANE_Unit GetOptionUnit( int n )
@ -140,7 +140,7 @@ public:
SANE_Constraint_Type GetOptionConstraintType( int n )
{ return mppOptions[n]->constraint_type; }
const char** GetStringConstraint( int n )
{ return (const char**)mppOptions[n]->constraint.string_list; }
{ return const_cast<const char**>(mppOptions[n]->constraint.string_list); }
int GetRange( int, double*& );
inline int GetOptionElements( int n );