diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-20 20:20:44 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-22 20:53:30 +0200 |
commit | eef4c133e9649ebd690918bd7b83c2d5dc0dfcff (patch) | |
tree | 1a8d084c5b16056a15258770a05b9cd2d53a40bc /svl/source/svdde | |
parent | bb406680cebd6fa1e1bdb9e2de430cd9a1f44da0 (diff) |
Windows: avoid dependence on UNICODE define; prefer W functions
Change-Id: I95b90128e93f0d88ed73601bcc5a7ca9279d4cf1
Reviewed-on: https://gerrit.libreoffice.org/42560
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svl/source/svdde')
-rw-r--r-- | svl/source/svdde/ddecli.cxx | 13 | ||||
-rw-r--r-- | svl/source/svdde/ddedata.cxx | 10 | ||||
-rw-r--r-- | svl/source/svdde/ddestrg.cxx | 4 | ||||
-rw-r--r-- | svl/source/svdde/ddesvr.cxx | 63 |
4 files changed, 42 insertions, 48 deletions
diff --git a/svl/source/svdde/ddecli.cxx b/svl/source/svdde/ddecli.cxx index d97a9cdf4fe6..c84bb92592de 100644 --- a/svl/source/svdde/ddecli.cxx +++ b/svl/source/svdde/ddecli.cxx @@ -18,7 +18,6 @@ */ -#define UNICODE #include <string.h> #include <algorithm> #include "ddeimp.hxx" @@ -157,12 +156,12 @@ DdeConnection::DdeConnection( const OUString& rService, const OUString& rTopic ) pInst->nInstanceCli++; if ( !pInst->hDdeInstCli ) { - pImp->nStatus = DdeInitialize( &pInst->hDdeInstCli, - DdeInternal::CliCallback, - APPCLASS_STANDARD | APPCMD_CLIENTONLY | - CBF_FAIL_ALLSVRXACTIONS | - CBF_SKIP_REGISTRATIONS | - CBF_SKIP_UNREGISTRATIONS, 0L ); + pImp->nStatus = DdeInitializeW( &pInst->hDdeInstCli, + DdeInternal::CliCallback, + APPCLASS_STANDARD | APPCMD_CLIENTONLY | + CBF_FAIL_ALLSVRXACTIONS | + CBF_SKIP_REGISTRATIONS | + CBF_SKIP_UNREGISTRATIONS, 0L ); } pService = new DdeString( pInst->hDdeInstCli, rService ); diff --git a/svl/source/svdde/ddedata.cxx b/svl/source/svdde/ddedata.cxx index 44817c3d03d8..5ee335ee67ec 100644 --- a/svl/source/svdde/ddedata.cxx +++ b/svl/source/svdde/ddedata.cxx @@ -22,8 +22,6 @@ // Format numbers to be the same! If that's not the case, we need to // adapt the code here. The implementation uses the conversions here. -#define UNICODE - #include <string.h> #include "ddeimp.hxx" #include <svl/svdde.hxx> @@ -136,7 +134,7 @@ sal_uLong DdeData::GetExternalFormat(SotClipboardFormatId nFmt) #if defined(_WIN32) OUString aName( SotExchange::GetFormatName( nFmt ) ); if( !aName.isEmpty() ) - return RegisterClipboardFormat( reinterpret_cast<LPCWSTR>(aName.getStr()) ); + return RegisterClipboardFormatW( SAL_W(aName.getStr()) ); #endif } } @@ -157,10 +155,10 @@ SotClipboardFormatId DdeData::GetInternalFormat(sal_uLong nFmt) #if defined(_WIN32) if( nFmt >= CF_MAX ) { - TCHAR szName[ 256 ]; + WCHAR szName[ 256 ]; - if(GetClipboardFormatName( nFmt, szName, sizeof(szName) )) - return SotExchange::RegisterFormatName( OUString(reinterpret_cast<const sal_Unicode*>(szName)) ); + if(GetClipboardFormatNameW( nFmt, szName, SAL_N_ELEMENTS(szName) )) + return SotExchange::RegisterFormatName( SAL_U(szName) ); } #endif break; diff --git a/svl/source/svdde/ddestrg.cxx b/svl/source/svdde/ddestrg.cxx index 841c3d7e8e28..70cde9aa8594 100644 --- a/svl/source/svdde/ddestrg.cxx +++ b/svl/source/svdde/ddestrg.cxx @@ -18,15 +18,13 @@ */ -#define UNICODE - #include "ddeimp.hxx" #include <svl/svdde.hxx> DdeString::DdeString( DWORD hDdeInst, const OUString& r) : m_aString(r) { - hString = DdeCreateStringHandle( hDdeInst, reinterpret_cast<wchar_t const *>(r.getStr()), CP_WINUNICODE ); + hString = DdeCreateStringHandleW( hDdeInst, SAL_W(r.getStr()), CP_WINUNICODE ); hInst = hDdeInst; } diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx index 36fd9da26d90..5fa56f50f5ad 100644 --- a/svl/source/svdde/ddesvr.cxx +++ b/svl/source/svdde/ddesvr.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#define UNICODE #include "ddeimp.hxx" #include <algorithm> #include <memory> @@ -79,10 +78,10 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( { int nTopics = 0; - TCHAR chTopicBuf[250]; + WCHAR chTopicBuf[250]; if( hText1 ) - DdeQueryString( pInst->hDdeInstSvr, hText1, chTopicBuf, - sizeof(chTopicBuf)/sizeof(TCHAR), CP_WINUNICODE ); + DdeQueryStringW( pInst->hDdeInstSvr, hText1, chTopicBuf, + SAL_N_ELEMENTS(chTopicBuf), CP_WINUNICODE ); for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI) { @@ -98,7 +97,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( while( -1 != n ) { OUString s( sTopics.getToken( 0, '\t', n )); - if( s == reinterpret_cast<const sal_Unicode*>(chTopicBuf) ) + if( s == SAL_U(chTopicBuf) ) ++nTopics; } } @@ -125,7 +124,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( { OUString s( sTopics.getToken( 0, '\t', n )); s = s.replaceAll("\n", "").replaceAll("\r", ""); - if( !hText1 || s == reinterpret_cast<const sal_Unicode*>(chTopicBuf) ) + if( !hText1 || s == SAL_U(chTopicBuf) ) { DdeString aDStr( pInst->hDdeInstSvr, s ); pTopic = FindTopic( *pService, aDStr.getHSZ() ); @@ -233,15 +232,15 @@ found: OUString aRes; // Must be free not until the end! if ( pTopic->IsSystemTopic() ) { - if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_TOPICS) ) + if ( pTopic->aItem == SZDDESYS_ITEM_TOPICS ) aRes = pService->Topics(); - else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_SYSITEMS) ) + else if ( pTopic->aItem == SZDDESYS_ITEM_SYSITEMS ) aRes = pService->SysItems(); - else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_STATUS) ) + else if ( pTopic->aItem == SZDDESYS_ITEM_STATUS ) aRes = pService->Status(); - else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_FORMATS) ) + else if ( pTopic->aItem == SZDDESYS_ITEM_FORMATS ) aRes = pService->Formats(); - else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_HELP) ) + else if ( pTopic->aItem == SZDDESYS_ITEM_HELP ) aRes = OUString(); else aRes = OUString(); @@ -392,8 +391,8 @@ DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic ) break; // Let's query our subclass - TCHAR chBuf[250]; - DdeQueryString(pInst->hDdeInstSvr,hTopic,chBuf,sizeof(chBuf)/sizeof(TCHAR),CP_WINUNICODE ); + WCHAR chBuf[250]; + DdeQueryStringW(pInst->hDdeInstSvr,hTopic,chBuf,SAL_N_ELEMENTS(chBuf),CP_WINUNICODE ); bContinue = false; // We need to search again } @@ -422,9 +421,9 @@ DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem ) break; // Let's query our subclass - TCHAR chBuf[250]; - DdeQueryString(pInst->hDdeInstSvr,hItem,chBuf,sizeof(chBuf)/sizeof(TCHAR),CP_WINUNICODE ); - bContinue = rTopic.MakeItem( reinterpret_cast<const sal_Unicode*>(chBuf) ); + WCHAR chBuf[250]; + DdeQueryStringW(pInst->hDdeInstSvr,hItem,chBuf,SAL_N_ELEMENTS(chBuf),CP_WINUNICODE ); + bContinue = rTopic.MakeItem( SAL_U(chBuf) ); // We need to search again } while( bContinue ); @@ -443,11 +442,11 @@ DdeService::DdeService( const OUString& rService ) if ( !pInst->hDdeInstSvr ) { nStatus = sal::static_int_cast< short >( - DdeInitialize( &pInst->hDdeInstSvr, - DdeInternal::SvrCallback, - APPCLASS_STANDARD | - CBF_SKIP_REGISTRATIONS | - CBF_SKIP_UNREGISTRATIONS, 0L ) ); + DdeInitializeW( &pInst->hDdeInstSvr, + DdeInternal::SvrCallback, + APPCLASS_STANDARD | + CBF_SKIP_REGISTRATIONS | + CBF_SKIP_UNREGISTRATIONS, 0L ) ); pInst->pServicesSvr = new DdeServices; } else @@ -468,12 +467,12 @@ DdeService::DdeService( const OUString& rService ) } } AddFormat( SotClipboardFormatId::STRING ); - pSysTopic = new DdeTopic( reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC) ); - pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_TOPICS) ) ); - pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_SYSITEMS) ) ); - pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_STATUS) ) ); - pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_FORMATS) ) ); - pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_HELP) ) ); + pSysTopic = new DdeTopic( SZDDESYS_TOPIC ); + pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_TOPICS ) ); + pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_SYSITEMS ) ); + pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_STATUS ) ); + pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_FORMATS ) ); + pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_HELP ) ); AddTopic( *pSysTopic ); } @@ -608,7 +607,7 @@ const OUString DdeTopic::GetName() const bool DdeTopic::IsSystemTopic() { - return GetName() == reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC); + return GetName() == SZDDESYS_TOPIC; } DdeItem* DdeTopic::AddItem( const DdeItem& r ) @@ -859,7 +858,7 @@ OUString DdeService::SysItems() std::vector<DdeItem*>::iterator iterItem; for ( iter = aTopics.begin(); iter != aTopics.end(); ++iter ) { - if ( (*iter)->GetName() == reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC) ) + if ( (*iter)->GetName() == SZDDESYS_TOPIC ) { short n = 0; for ( iterItem = (*iter)->aItems.begin(); iterItem != (*iter)->aItems.end(); ++iterItem, n++ ) @@ -913,9 +912,9 @@ OUString DdeService::Formats() break; default: { - TCHAR buf[128]; - GetClipboardFormatName( (UINT)f, buf, sizeof(buf) / sizeof(TCHAR) ); - s += OUString(reinterpret_cast<sal_Unicode*>(buf)); + WCHAR buf[128]; + GetClipboardFormatNameW( (UINT)f, buf, SAL_N_ELEMENTS(buf) ); + s += SAL_U(buf); } break; } |