clang-cl loplugin: svl

The DdeInternal::Cli/SrvCallback functions apparently had broken signatures for
64-bit Windows (32-bit DWORD vs. 64-bit ULONG_PTR parameters), but I assume that
was actually harmless, as I think that, for Windows x86-64, those arguments are
pushed on the stack right-to-left (regardless of CALLBACK), and they are the
last arguments, and SrvCallback doesn't look at them at all, and CliCallback
only looks at the lower 32-bit DWORD of the first one (nInfo1).

Change-Id: Id77749dd2d29180e2d11b0ae2ad248ac1a7f1bdf
Reviewed-on: https://gerrit.libreoffice.org/29848
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2016-10-14 16:46:54 +02:00
parent 0deb7d16f3
commit 6e64342d34
6 changed files with 92 additions and 89 deletions

View File

@@ -226,17 +226,17 @@ bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptTyp
{ {
bool isInstalled = false; bool isInstalled = false;
#ifdef _WIN32 #ifdef _WIN32
int nLayouts = GetKeyboardLayoutList(0, NULL); int nLayouts = GetKeyboardLayoutList(0, nullptr);
if (nLayouts > 0) if (nLayouts > 0)
{ {
HKL *lpList = (HKL*)LocalAlloc(LPTR, (nLayouts * sizeof(HKL))); HKL *lpList = static_cast<HKL*>(LocalAlloc(LPTR, (nLayouts * sizeof(HKL))));
if (lpList) if (lpList)
{ {
nLayouts = GetKeyboardLayoutList(nLayouts, lpList); nLayouts = GetKeyboardLayoutList(nLayouts, lpList);
for(int i = 0; i < nLayouts; ++i) for(int i = 0; i < nLayouts; ++i)
{ {
LCID lang = MAKELCID((WORD)((DWORD_PTR)lpList[i] & 0xffff), SORT_DEFAULT); LCID lang = MAKELCID((WORD)(reinterpret_cast<DWORD_PTR>(lpList[i]) & 0xffff), SORT_DEFAULT);
if (MsLangId::getScriptType(lang) == scriptType) if (MsLangId::getScriptType(lang) == scriptType)
{ {
isInstalled = true; isInstalled = true;

View File

@@ -48,7 +48,7 @@ DdeInstData* ImpInitInstData()
void ImpDeinitInstData() void ImpDeinitInstData()
{ {
delete theDdeInstData; delete theDdeInstData;
theDdeInstData = 0; theDdeInstData = nullptr;
} }
@@ -58,13 +58,13 @@ struct DdeImp
long nStatus; long nStatus;
}; };
HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType, HDDEDATA CALLBACK DdeInternal::CliCallback( UINT nCode, UINT nCbType,
HCONV hConv, HSZ, HSZ hText2, HCONV hConv, HSZ, HSZ hText2,
HDDEDATA hData, DWORD nInfo1, DWORD ) HDDEDATA hData, ULONG_PTR nInfo1, ULONG_PTR )
{ {
HDDEDATA nRet = DDE_FNOTPROCESSED; HDDEDATA nRet = DDE_FNOTPROCESSED;
const std::vector<DdeConnection*> &rAll = DdeConnection::GetConnections(); const std::vector<DdeConnection*> &rAll = DdeConnection::GetConnections();
DdeConnection* self = 0; DdeConnection* self = nullptr;
DdeInstData* pInst = ImpGetInstData(); DdeInstData* pInst = ImpGetInstData();
assert(pInst); assert(pInst);
@@ -90,7 +90,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType,
{ {
nCode = (*iter)->nType & (XCLASS_MASK | XTYP_MASK); nCode = (*iter)->nType & (XCLASS_MASK | XTYP_MASK);
(*iter)->bBusy = false; (*iter)->bBusy = false;
(*iter)->Done( 0 != hData ); (*iter)->Done( nullptr != hData );
bFound = true; bFound = true;
} }
break; break;
@@ -101,7 +101,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType,
? DMLERR_NO_ERROR ? DMLERR_NO_ERROR
: DdeGetLastError( pInst->hDdeInstCli ); : DdeGetLastError( pInst->hDdeInstCli );
iter = self->aTransactions.end(); iter = self->aTransactions.end();
nRet = 0; nRet = nullptr;
bFound = true; bFound = true;
break; break;
@@ -121,7 +121,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType,
if( !hData ) if( !hData )
{ {
static_cast<DdeLink*>(*iter)->Notify(); static_cast<DdeLink*>(*iter)->Notify();
nRet = (HDDEDATA)DDE_FACK; nRet = reinterpret_cast<HDDEDATA>(DDE_FACK);
break; break;
} }
SAL_FALLTHROUGH; SAL_FALLTHROUGH;
@@ -137,7 +137,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType,
d.pImp->nFmt = DdeData::GetInternalFormat( nCbType ); d.pImp->nFmt = DdeData::GetInternalFormat( nCbType );
d.Lock(); d.Lock();
(*iter)->Data( &d ); (*iter)->Data( &d );
nRet = (HDDEDATA)DDE_FACK; nRet = reinterpret_cast<HDDEDATA>(DDE_FACK);
break; break;
} }
} }
@@ -149,7 +149,7 @@ DdeConnection::DdeConnection( const OUString& rService, const OUString& rTopic )
{ {
pImp = new DdeImp; pImp = new DdeImp;
pImp->nStatus = DMLERR_NO_ERROR; pImp->nStatus = DMLERR_NO_ERROR;
pImp->hConv = NULL; pImp->hConv = nullptr;
DdeInstData* pInst = ImpGetInstData(); DdeInstData* pInst = ImpGetInstData();
if( !pInst ) if( !pInst )
@@ -159,7 +159,7 @@ DdeConnection::DdeConnection( const OUString& rService, const OUString& rTopic )
if ( !pInst->hDdeInstCli ) if ( !pInst->hDdeInstCli )
{ {
pImp->nStatus = DdeInitialize( &pInst->hDdeInstCli, pImp->nStatus = DdeInitialize( &pInst->hDdeInstCli,
(PFNCALLBACK)DdeInternal::CliCallback, DdeInternal::CliCallback,
APPCLASS_STANDARD | APPCMD_CLIENTONLY | APPCLASS_STANDARD | APPCMD_CLIENTONLY |
CBF_FAIL_ALLSVRXACTIONS | CBF_FAIL_ALLSVRXACTIONS |
CBF_SKIP_REGISTRATIONS | CBF_SKIP_REGISTRATIONS |
@@ -171,7 +171,7 @@ DdeConnection::DdeConnection( const OUString& rService, const OUString& rTopic )
if ( pImp->nStatus == DMLERR_NO_ERROR ) if ( pImp->nStatus == DMLERR_NO_ERROR )
{ {
pImp->hConv = DdeConnect( pInst->hDdeInstCli,pService->getHSZ(),pTopic->getHSZ(), NULL); pImp->hConv = DdeConnect( pInst->hDdeInstCli,pService->getHSZ(),pTopic->getHSZ(), nullptr);
if( !pImp->hConv ) if( !pImp->hConv )
pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli ); pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli );
} }
@@ -272,25 +272,25 @@ DdeTransaction::~DdeTransaction()
void DdeTransaction::Execute() void DdeTransaction::Execute()
{ {
HSZ hItem = pName->getHSZ(); HSZ hItem = pName->getHSZ();
void* pData = (void*)aDdeData.getData(); void const * pData = aDdeData.getData();
DWORD nData = (DWORD)aDdeData.getSize(); DWORD nData = (DWORD)aDdeData.getSize();
SotClipboardFormatId nIntFmt = aDdeData.pImp->nFmt; SotClipboardFormatId nIntFmt = aDdeData.pImp->nFmt;
UINT nExtFmt = DdeData::GetExternalFormat( nIntFmt ); UINT nExtFmt = DdeData::GetExternalFormat( nIntFmt );
DdeInstData* pInst = ImpGetInstData(); DdeInstData* pInst = ImpGetInstData();
if ( nType == XTYP_EXECUTE ) if ( nType == XTYP_EXECUTE )
hItem = NULL; hItem = nullptr;
if ( nType != XTYP_EXECUTE && nType != XTYP_POKE ) if ( nType != XTYP_EXECUTE && nType != XTYP_POKE )
{ {
pData = NULL; pData = nullptr;
nData = 0L; nData = 0L;
} }
if ( nTime ) if ( nTime )
{ {
HDDEDATA hData = DdeClientTransaction( (unsigned char*)pData, HDDEDATA hData = DdeClientTransaction( static_cast<LPBYTE>(const_cast<void *>(pData)),
nData, rDde.pImp->hConv, nData, rDde.pImp->hConv,
hItem, nExtFmt, (UINT)nType, hItem, nExtFmt, (UINT)nType,
(DWORD)nTime, (DWORD FAR*)NULL ); (DWORD)nTime, nullptr );
rDde.pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli ); rDde.pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli );
if( hData && nType == XTYP_REQUEST ) if( hData && nType == XTYP_REQUEST )
@@ -311,10 +311,12 @@ void DdeTransaction::Execute()
DdeAbandonTransaction( pInst->hDdeInstCli, rDde.pImp->hConv, nId); DdeAbandonTransaction( pInst->hDdeInstCli, rDde.pImp->hConv, nId);
nId = 0; nId = 0;
bBusy = true; bBusy = true;
HDDEDATA hRet = DdeClientTransaction( (unsigned char*)pData, nData, DWORD result;
HDDEDATA hRet = DdeClientTransaction( static_cast<LPBYTE>(const_cast<void *>(pData)), nData,
rDde.pImp->hConv, hItem, nExtFmt, rDde.pImp->hConv, hItem, nExtFmt,
(UINT)nType, TIMEOUT_ASYNC, (UINT)nType, TIMEOUT_ASYNC,
(DWORD FAR *) ((long*) &nId) ); &result );
nId = result;
rDde.pImp->nStatus = hRet ? DMLERR_NO_ERROR rDde.pImp->nStatus = hRet ? DMLERR_NO_ERROR
: DdeGetLastError( pInst->hDdeInstCli ); : DdeGetLastError( pInst->hDdeInstCli );
} }
@@ -356,7 +358,7 @@ DdeLink::~DdeLink()
void DdeLink::Notify() void DdeLink::Notify()
{ {
aNotify.Call( NULL ); aNotify.Call( nullptr );
} }
DdeRequest::DdeRequest( DdeConnection& d, const OUString& i, long n ) DdeRequest::DdeRequest( DdeConnection& d, const OUString& i, long n )
@@ -382,7 +384,7 @@ DdePoke::DdePoke( DdeConnection& d, const OUString& i, const DdeData& rData,
DdeExecute::DdeExecute( DdeConnection& d, const OUString& rData, long n ) DdeExecute::DdeExecute( DdeConnection& d, const OUString& rData, long n )
: DdeTransaction( d, OUString(), n ) : DdeTransaction( d, OUString(), n )
{ {
aDdeData = DdeData( (void*)rData.getStr(), sizeof(sal_Unicode) * (rData.getLength() + 1), SotClipboardFormatId::STRING ); aDdeData = DdeData( rData.getStr(), sizeof(sal_Unicode) * (rData.getLength() + 1), SotClipboardFormatId::STRING );
nType = XTYP_EXECUTE; nType = XTYP_EXECUTE;
} }

View File

@@ -33,17 +33,17 @@
DdeData::DdeData() DdeData::DdeData()
{ {
pImp = new DdeDataImp; pImp = new DdeDataImp;
pImp->hData = NULL; pImp->hData = nullptr;
pImp->nData = 0; pImp->nData = 0;
pImp->pData = NULL; pImp->pData = nullptr;
pImp->nFmt = SotClipboardFormatId::STRING; pImp->nFmt = SotClipboardFormatId::STRING;
} }
DdeData::DdeData(const void* p, long n, SotClipboardFormatId f) DdeData::DdeData(const void* p, long n, SotClipboardFormatId f)
{ {
pImp = new DdeDataImp; pImp = new DdeDataImp;
pImp->hData = NULL; pImp->hData = nullptr;
pImp->pData = (LPBYTE)p; pImp->pData = p;
pImp->nData = n; pImp->nData = n;
pImp->nFmt = f; pImp->nFmt = f;
} }
@@ -51,8 +51,8 @@ DdeData::DdeData(const void* p, long n, SotClipboardFormatId f)
DdeData::DdeData( const OUString& s ) DdeData::DdeData( const OUString& s )
{ {
pImp = new DdeDataImp; pImp = new DdeDataImp;
pImp->hData = NULL; pImp->hData = nullptr;
pImp->pData = (LPBYTE)s.getStr(); pImp->pData = s.getStr();
pImp->nData = s.getLength()+1; pImp->nData = s.getLength()+1;
pImp->nFmt = SotClipboardFormatId::STRING; pImp->nFmt = SotClipboardFormatId::STRING;
} }
@@ -77,7 +77,7 @@ DdeData::~DdeData()
void DdeData::Lock() void DdeData::Lock()
{ {
if ( pImp->hData ) if ( pImp->hData )
pImp->pData = DdeAccessData( pImp->hData, (LPDWORD) &pImp->nData ); pImp->pData = DdeAccessData( pImp->hData, &pImp->nData );
} }
SotClipboardFormatId DdeData::GetFormat() const SotClipboardFormatId DdeData::GetFormat() const
@@ -107,7 +107,7 @@ DdeData& DdeData::operator = ( const DdeData& rData )
DdeData tmp( rData ); DdeData tmp( rData );
delete pImp; delete pImp;
pImp = tmp.pImp; pImp = tmp.pImp;
tmp.pImp = NULL; tmp.pImp = nullptr;
} }
return *this; return *this;

View File

@@ -41,9 +41,9 @@ class DdeInternal
{ {
public: public:
static HDDEDATA CALLBACK CliCallback static HDDEDATA CALLBACK CliCallback
( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); ( UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, ULONG_PTR, ULONG_PTR );
static HDDEDATA CALLBACK SvrCallback static HDDEDATA CALLBACK SvrCallback
( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); ( UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, ULONG_PTR, ULONG_PTR );
static DdeService* FindService( HSZ ); static DdeService* FindService( HSZ );
static DdeTopic* FindTopic( DdeService&, HSZ ); static DdeTopic* FindTopic( DdeService&, HSZ );
static DdeItem* FindItem( DdeTopic&, HSZ ); static DdeItem* FindItem( DdeTopic&, HSZ );
@@ -66,7 +66,7 @@ public:
DdeString( DWORD, const OUString& ); DdeString( DWORD, const OUString& );
~DdeString(); ~DdeString();
int operator==( HSZ ); bool operator==( HSZ );
HSZ getHSZ(); HSZ getHSZ();
OUString toOUString() const { return m_aString; } OUString toOUString() const { return m_aString; }
}; };
@@ -75,8 +75,8 @@ public:
struct DdeDataImp struct DdeDataImp
{ {
HDDEDATA hData; HDDEDATA hData;
LPBYTE pData; void const * pData;
long nData; DWORD nData;
SotClipboardFormatId nFmt; SotClipboardFormatId nFmt;
}; };
@@ -99,7 +99,7 @@ public:
: nRefCount(0) : nRefCount(0)
, hDdeInstSvr(0) , hDdeInstSvr(0)
, nInstanceSvr(0) , nInstanceSvr(0)
, pServicesSvr(NULL) , pServicesSvr(nullptr)
, hDdeInstCli(0) , hDdeInstCli(0)
, nInstanceCli(0) , nInstanceCli(0)
{ {

View File

@@ -26,14 +26,14 @@
DdeString::DdeString( DWORD hDdeInst, const sal_Unicode* p ) DdeString::DdeString( DWORD hDdeInst, const sal_Unicode* p )
: m_aString(p) : m_aString(p)
{ {
hString = DdeCreateStringHandle( hDdeInst, (LPTSTR)p, CP_WINUNICODE ); hString = DdeCreateStringHandle( hDdeInst, p, CP_WINUNICODE );
hInst = hDdeInst; hInst = hDdeInst;
} }
DdeString::DdeString( DWORD hDdeInst, const OUString& r) DdeString::DdeString( DWORD hDdeInst, const OUString& r)
: m_aString(r) : m_aString(r)
{ {
hString = DdeCreateStringHandle( hDdeInst, (LPTSTR)r.getStr(), CP_WINUNICODE ); hString = DdeCreateStringHandle( hDdeInst, r.getStr(), CP_WINUNICODE );
hInst = hDdeInst; hInst = hDdeInst;
} }
@@ -43,7 +43,7 @@ DdeString::~DdeString()
DdeFreeStringHandle( hInst, hString ); DdeFreeStringHandle( hInst, hString );
} }
int DdeString::operator==( HSZ h ) bool DdeString::operator==( HSZ h )
{ {
return( !DdeCmpStringHandles( hString, h ) ); return( !DdeCmpStringHandles( hString, h ) );
} }

View File

@@ -60,8 +60,8 @@ private:
}; };
HDDEDATA CALLBACK DdeInternal::SvrCallback( HDDEDATA CALLBACK DdeInternal::SvrCallback(
WORD nCode, WORD nCbType, HCONV hConv, HSZ hText1, HSZ hText2, UINT nCode, UINT nCbType, HCONV hConv, HSZ hText1, HSZ hText2,
HDDEDATA hData, DWORD, DWORD ) HDDEDATA hData, ULONG_PTR, ULONG_PTR )
{ {
DdeServices& rAll = DdeService::GetServices(); DdeServices& rAll = DdeService::GetServices();
DdeService* pService; DdeService* pService;
@@ -109,7 +109,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
} }
if( !nTopics ) if( !nTopics )
return (HDDEDATA)NULL; return nullptr;
HSZPAIR* pPairs = new HSZPAIR [nTopics + 1]; HSZPAIR* pPairs = new HSZPAIR [nTopics + 1];
@@ -140,12 +140,12 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
} }
} }
q->hszSvc = NULL; q->hszSvc = nullptr;
q->hszTopic = NULL; q->hszTopic = nullptr;
HDDEDATA h = DdeCreateDataHandle( HDDEDATA h = DdeCreateDataHandle(
pInst->hDdeInstSvr, (LPBYTE) pPairs, pInst->hDdeInstSvr, reinterpret_cast<LPBYTE>(pPairs),
sizeof(HSZPAIR) * (nTopics+1), sizeof(HSZPAIR) * (nTopics+1),
0, NULL, nCbType, 0); 0, nullptr, nCbType, 0);
delete [] pPairs; delete [] pPairs;
return h; return h;
} }
@@ -155,11 +155,11 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
if ( pService) if ( pService)
pTopic = FindTopic( *pService, hText1 ); pTopic = FindTopic( *pService, hText1 );
else else
pTopic = NULL; pTopic = nullptr;
if ( pTopic ) if ( pTopic )
return (HDDEDATA)DDE_FACK; return reinterpret_cast<HDDEDATA>(DDE_FACK);
else else
return (HDDEDATA) NULL; return nullptr;
case XTYP_CONNECT_CONFIRM: case XTYP_CONNECT_CONFIRM:
pService = FindService( hText2 ); pService = FindService( hText2 );
@@ -174,7 +174,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
pService->pConv->push_back( pC ); pService->pConv->push_back( pC );
} }
} }
return (HDDEDATA)NULL; return nullptr;
} }
for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI) for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI)
@@ -188,7 +188,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
} }
} }
return (HDDEDATA) DDE_FNOTPROCESSED; return reinterpret_cast<HDDEDATA>(DDE_FNOTPROCESSED);
found: found:
if ( nCode == XTYP_DISCONNECT) if ( nCode == XTYP_DISCONNECT)
@@ -205,7 +205,7 @@ found:
break; break;
} }
} }
return (HDDEDATA)NULL; return nullptr;
} }
bool bExec = nCode == XTYP_EXECUTE; bool bExec = nCode == XTYP_EXECUTE;
@@ -213,12 +213,12 @@ found:
if ( pTopic && !bExec ) if ( pTopic && !bExec )
pItem = FindItem( *pTopic, hText2 ); pItem = FindItem( *pTopic, hText2 );
else else
pItem = NULL; pItem = nullptr;
if ( !bExec && !pService->HasCbFormat( nCbType ) ) if ( !bExec && !pService->HasCbFormat( nCbType ) )
pItem = NULL; pItem = nullptr;
if ( !pItem && !bExec ) if ( !pItem && !bExec )
return (HDDEDATA)DDE_FNOTPROCESSED; return static_cast<HDDEDATA>(DDE_FNOTPROCESSED);
if ( pItem ) if ( pItem )
pTopic->aItem = pItem->GetName(); pTopic->aItem = pItem->GetName();
else else
@@ -249,11 +249,11 @@ found:
if ( !aRes.isEmpty() ) if ( !aRes.isEmpty() )
pData = new DdeData( aRes ); pData = new DdeData( aRes );
else else
pData = NULL; pData = nullptr;
} }
else if( DDEGETPUTITEM == pItem->nType ) else if( DDEGETPUTITEM == pItem->nType )
{ {
pData = ((DdeGetPutItem*)pItem)->Get( DdeData::GetInternalFormat( nCbType ) ); pData = static_cast<DdeGetPutItem*>(pItem)->Get( DdeData::GetInternalFormat( nCbType ) );
} }
else else
{ {
@@ -263,7 +263,7 @@ found:
if ( pData ) if ( pData )
{ {
return DdeCreateDataHandle( pInst->hDdeInstSvr, return DdeCreateDataHandle( pInst->hDdeInstSvr,
(LPBYTE)pData->pImp->pData, static_cast<LPBYTE>(const_cast<void *>(pData->pImp->pData)),
pData->pImp->nData, pData->pImp->nData,
0, hText2, 0, hText2,
DdeData::GetExternalFormat( DdeData::GetExternalFormat(
@@ -281,14 +281,14 @@ found:
d.pImp->nFmt = DdeData::GetInternalFormat( nCbType ); d.pImp->nFmt = DdeData::GetInternalFormat( nCbType );
d.Lock(); d.Lock();
if( DDEGETPUTITEM == pItem->nType ) if( DDEGETPUTITEM == pItem->nType )
bRes = ((DdeGetPutItem*)pItem)->Put( &d ); bRes = static_cast<DdeGetPutItem*>(pItem)->Put( &d );
else else
bRes = pTopic->Put( &d ); bRes = pTopic->Put( &d );
} }
if ( bRes ) if ( bRes )
return (HDDEDATA)DDE_FACK; return reinterpret_cast<HDDEDATA>(DDE_FACK);
else else
return (HDDEDATA) DDE_FNOTPROCESSED; return reinterpret_cast<HDDEDATA>(DDE_FNOTPROCESSED);
case XTYP_ADVSTART: case XTYP_ADVSTART:
{ {
@@ -311,7 +311,7 @@ found:
{ {
// It was exchanged indeed // It was exchanged indeed
delete pItem; delete pItem;
pItem = 0; pItem = nullptr;
break; break;
} }
} }
@@ -320,7 +320,7 @@ found:
// It was not exchange, so back in // It was not exchange, so back in
pTopic->aItems.push_back(pItem); pTopic->aItems.push_back(pItem);
else else
pItem = iter != pTopic->aItems.end() ? *iter : NULL; pItem = iter != pTopic->aItems.end() ? *iter : nullptr;
} }
if (pItem) if (pItem)
@@ -328,11 +328,11 @@ found:
IncMonitor(pItem, hConv); IncMonitor(pItem, hConv);
} }
} }
return (HDDEDATA)sal_True; return reinterpret_cast<HDDEDATA>(TRUE);
case XTYP_ADVSTOP: case XTYP_ADVSTOP:
DecMonitor(pItem, hConv); DecMonitor(pItem, hConv);
return (HDDEDATA)sal_True; return reinterpret_cast<HDDEDATA>(TRUE);
case XTYP_EXECUTE: case XTYP_EXECUTE:
{ {
@@ -342,7 +342,7 @@ found:
aExec.Lock(); aExec.Lock();
OUString aName; OUString aName;
aName = (const sal_Unicode *)aExec.pImp->pData; aName = static_cast<const sal_Unicode *>(aExec.pImp->pData);
if( pTopic->IsSystemTopic() ) if( pTopic->IsSystemTopic() )
bRes = false; bRes = false;
@@ -350,12 +350,12 @@ found:
bRes = pTopic->Execute( &aName ); bRes = pTopic->Execute( &aName );
} }
if ( bRes ) if ( bRes )
return (HDDEDATA)DDE_FACK; return reinterpret_cast<HDDEDATA>(DDE_FACK);
else else
return (HDDEDATA)DDE_FNOTPROCESSED; return reinterpret_cast<HDDEDATA>(DDE_FNOTPROCESSED);
} }
return (HDDEDATA)NULL; return nullptr;
} }
DdeService* DdeInternal::FindService( HSZ hService ) DdeService* DdeInternal::FindService( HSZ hService )
@@ -368,7 +368,7 @@ DdeService* DdeInternal::FindService( HSZ hService )
return s; return s;
} }
return NULL; return nullptr;
} }
DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic ) DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic )
@@ -399,7 +399,7 @@ DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic )
} }
while( bContinue ); while( bContinue );
return 0; return nullptr;
} }
DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem ) DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem )
@@ -429,7 +429,7 @@ DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem )
} }
while( bContinue ); while( bContinue );
return 0; return nullptr;
} }
DdeService::DdeService( const OUString& rService ) DdeService::DdeService( const OUString& rService )
@@ -444,7 +444,7 @@ DdeService::DdeService( const OUString& rService )
{ {
nStatus = sal::static_int_cast< short >( nStatus = sal::static_int_cast< short >(
DdeInitialize( &pInst->hDdeInstSvr, DdeInitialize( &pInst->hDdeInstSvr,
(PFNCALLBACK)DdeInternal::SvrCallback, DdeInternal::SvrCallback,
APPCLASS_STANDARD | APPCLASS_STANDARD |
CBF_SKIP_REGISTRATIONS | CBF_SKIP_REGISTRATIONS |
CBF_SKIP_UNREGISTRATIONS, 0L ) ); CBF_SKIP_UNREGISTRATIONS, 0L ) );
@@ -461,7 +461,7 @@ DdeService::DdeService( const OUString& rService )
pName = new DdeString( pInst->hDdeInstSvr, rService ); pName = new DdeString( pInst->hDdeInstSvr, rService );
if ( nStatus == DMLERR_NO_ERROR ) if ( nStatus == DMLERR_NO_ERROR )
{ {
if ( !DdeNameService( pInst->hDdeInstSvr, pName->getHSZ(), NULL, if ( !DdeNameService( pInst->hDdeInstSvr, pName->getHSZ(), nullptr,
DNS_REGISTER | DNS_FILTEROFF ) ) DNS_REGISTER | DNS_FILTEROFF ) )
{ {
nStatus = DMLERR_SYS_ERROR; nStatus = DMLERR_SYS_ERROR;
@@ -495,7 +495,7 @@ DdeService::~DdeService()
{ {
pInst->hDdeInstSvr = 0; pInst->hDdeInstSvr = 0;
delete pInst->pServicesSvr; delete pInst->pServicesSvr;
pInst->pServicesSvr = NULL; pInst->pServicesSvr = nullptr;
if( pInst->nRefCount == 0) if( pInst->nRefCount == 0)
ImpDeinitInstData(); ImpDeinitInstData();
} }
@@ -518,7 +518,7 @@ DdeServices& DdeService::GetServices()
void DdeService::AddTopic( const DdeTopic& rTopic ) void DdeService::AddTopic( const DdeTopic& rTopic )
{ {
RemoveTopic( rTopic ); RemoveTopic( rTopic );
aTopics.push_back((DdeTopic *) &rTopic); aTopics.push_back(const_cast<DdeTopic *>(&rTopic));
} }
void DdeService::RemoveTopic( const DdeTopic& rTopic ) void DdeService::RemoveTopic( const DdeTopic& rTopic )
@@ -594,7 +594,7 @@ DdeTopic::~DdeTopic()
std::vector<DdeItem*>::iterator iter; std::vector<DdeItem*>::iterator iter;
for (iter = aItems.begin(); iter != aItems.end(); ++iter) for (iter = aItems.begin(); iter != aItems.end(); ++iter)
{ {
(*iter)->pMyTopic = 0; (*iter)->pMyTopic = nullptr;
delete *iter; delete *iter;
} }
@@ -647,7 +647,7 @@ void DdeTopic::RemoveItem( const DdeItem& r )
if ( iter != aItems.end() ) if ( iter != aItems.end() )
{ {
(*iter)->pMyTopic = 0; (*iter)->pMyTopic = nullptr;
delete *iter; delete *iter;
aItems.erase(iter); aItems.erase(iter);
} }
@@ -679,7 +679,7 @@ void DdeInternal::DisconnectTopic(DdeTopic & rTopic, HCONV nId)
DdeData* DdeTopic::Get(SotClipboardFormatId /*nFmt*/) DdeData* DdeTopic::Get(SotClipboardFormatId /*nFmt*/)
{ {
return NULL; return nullptr;
} }
bool DdeTopic::Put( const DdeData* ) bool DdeTopic::Put( const DdeData* )
@@ -703,8 +703,8 @@ DdeItem::DdeItem( const sal_Unicode* p )
assert(pInst); assert(pInst);
pName = new DdeString( pInst->hDdeInstSvr, p ); pName = new DdeString( pInst->hDdeInstSvr, p );
nType = DDEITEM; nType = DDEITEM;
pMyTopic = 0; pMyTopic = nullptr;
pImpData = 0; pImpData = nullptr;
} }
DdeItem::DdeItem( const OUString& r) DdeItem::DdeItem( const OUString& r)
@@ -713,8 +713,8 @@ DdeItem::DdeItem( const OUString& r)
assert(pInst); assert(pInst);
pName = new DdeString( pInst->hDdeInstSvr, r ); pName = new DdeString( pInst->hDdeInstSvr, r );
nType = DDEITEM; nType = DDEITEM;
pMyTopic = 0; pMyTopic = nullptr;
pImpData = 0; pImpData = nullptr;
} }
DdeItem::DdeItem( const DdeItem& r) DdeItem::DdeItem( const DdeItem& r)
@@ -723,8 +723,8 @@ DdeItem::DdeItem( const DdeItem& r)
assert(pInst); assert(pInst);
pName = new DdeString( pInst->hDdeInstSvr, r.pName->toOUString() ); pName = new DdeString( pInst->hDdeInstSvr, r.pName->toOUString() );
nType = DDEITEM; nType = DDEITEM;
pMyTopic = 0; pMyTopic = nullptr;
pImpData = 0; pImpData = nullptr;
} }
DdeItem::~DdeItem() DdeItem::~DdeItem()
@@ -780,7 +780,7 @@ void DdeInternal::DecMonitor(DdeItem *const pItem, HCONV nHCnv)
{ {
if (pItem->pImpData) if (pItem->pImpData)
{ {
for( sal_uInt16 n = 0; n < pItem->pImpData->size(); ++n ) for( size_t n = 0; n < pItem->pImpData->size(); ++n )
{ {
DdeItemImpData* pData = &(*pItem->pImpData)[n]; DdeItemImpData* pData = &(*pItem->pImpData)[n];
if( pData->nHCnv == nHCnv ) if( pData->nHCnv == nHCnv )
@@ -793,7 +793,8 @@ void DdeInternal::DecMonitor(DdeItem *const pItem, HCONV nHCnv)
} }
else else
{ {
delete pItem->pImpData, pItem->pImpData = 0; delete pItem->pImpData;
pItem->pImpData = nullptr;
if (DDEGETPUTITEM == pItem->nType) if (DDEGETPUTITEM == pItem->nType)
{ {
static_cast<DdeGetPutItem*>(pItem)->AdviseLoop(false); static_cast<DdeGetPutItem*>(pItem)->AdviseLoop(false);
@@ -839,7 +840,7 @@ DdeGetPutItem::DdeGetPutItem( const DdeItem& rItem )
DdeData* DdeGetPutItem::Get(SotClipboardFormatId) DdeData* DdeGetPutItem::Get(SotClipboardFormatId)
{ {
return 0; return nullptr;
} }
bool DdeGetPutItem::Put( const DdeData* ) bool DdeGetPutItem::Put( const DdeData* )