diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-26 11:28:57 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-30 11:23:41 +0200 |
commit | 362a21d3a129b90149f6ef645c127f5e86e0ba61 (patch) | |
tree | 8583cb29b33de56e4489cb8950d2714a1fb2957e /embedserv | |
parent | 81ce629c9e8a4fc26ded9d49157e3f3263991e03 (diff) |
Use explicit function names for fooA/fooW WinAPI; prefer fooW
We should only use generic foo function name when it takes params
that are also dependent on UNICODE define, like
LoadCursor( nullptr, IDC_ARROW )
where IDC_ARROW is defined in MSVC headers synchronised with
LoadCursor definition.
We should always use Unicode API for any file paths operations,
because otherwise we will get "?" for any character in path that
is not in current non-unicode codepage, which will result in failed
file operations.
Change-Id: I3a7f453ca0f893002d8a9764318919709fd8b633
Reviewed-on: https://gerrit.libreoffice.org/42935
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'embedserv')
-rw-r--r-- | embedserv/source/embed/docholder.cxx | 8 | ||||
-rw-r--r-- | embedserv/source/embed/ed_idataobj.cxx | 16 | ||||
-rw-r--r-- | embedserv/source/embed/ed_ipersiststr.cxx | 6 | ||||
-rw-r--r-- | embedserv/source/embed/syswinwrapper.cxx | 20 | ||||
-rw-r--r-- | embedserv/source/embed/tracker.cxx | 11 | ||||
-rw-r--r-- | embedserv/source/inprocserv/dllentry.cxx | 40 |
6 files changed, 50 insertions, 51 deletions
diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx index 929e8d252350..c596af732f93 100644 --- a/embedserv/source/embed/docholder.cxx +++ b/embedserv/source/embed/docholder.cxx @@ -505,12 +505,12 @@ void DocumentHolder::UIDeactivate() void CopyToOLEMenu(HMENU hOrig,WORD origPos,HMENU hDest,WORD destPos) { HMENU subMenu(nullptr); - char buffer[256]; + wchar_t buffer[256]; subMenu = GetSubMenu(hOrig,origPos); - GetMenuString(hOrig,origPos,buffer,256,MF_BYPOSITION); - InsertMenu(hDest,destPos,MF_BYPOSITION | MF_POPUP, - reinterpret_cast<UINT_PTR>(subMenu),LPCTSTR(buffer)); + GetMenuStringW(hOrig,origPos,buffer,256,MF_BYPOSITION); + InsertMenuW(hDest,destPos,MF_BYPOSITION | MF_POPUP, + reinterpret_cast<UINT_PTR>(subMenu),buffer); MENUITEMINFOW mi; memset(&mi,0,sizeof(mi)); diff --git a/embedserv/source/embed/ed_idataobj.cxx b/embedserv/source/embed/ed_idataobj.cxx index f682254e1f9d..fe37ad43ddd6 100644 --- a/embedserv/source/embed/ed_idataobj.cxx +++ b/embedserv/source/embed/ed_idataobj.cxx @@ -118,8 +118,8 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); + CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) ) @@ -157,8 +157,8 @@ STDMETHODIMP EmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM || pFormatetc->dwAspect == DVASPECT_DOCPRINT ) return DV_E_DVASPECT; - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); + CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { @@ -204,8 +204,8 @@ STDMETHODIMP EmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc ) } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); + CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) ) @@ -241,8 +241,8 @@ STDMETHODIMP EmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); + CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); if ( pFormatetcIn->cfFormat == cf_embSource || pFormatetcIn->cfFormat == cf_embObj ) { pFormatetcOut->tymed = TYMED_ISTORAGE; diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx index 0de9ab79fd09..70c8b226a4df 100644 --- a/embedserv/source/embed/ed_ipersiststr.cxx +++ b/embedserv/source/embed/ed_ipersiststr.cxx @@ -422,7 +422,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) if ( hr == S_OK ) { wchar_t const * aCurType = getStorageTypeFromGUID_Impl( &m_guid ); // ??? - CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( pStg, cf, // ??? const_cast<wchar_t *>(aCurType) ); @@ -750,7 +750,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) if ( FAILED( hr ) || !m_pMasterStorage ) return E_FAIL; o3tl::u16string_view aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ??? - CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) ); @@ -801,7 +801,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) if ( hr == S_OK ) { aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ??? - cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) ); diff --git a/embedserv/source/embed/syswinwrapper.cxx b/embedserv/source/embed/syswinwrapper.cxx index 64eefc17af38..ef92307b0d53 100644 --- a/embedserv/source/embed/syswinwrapper.cxx +++ b/embedserv/source/embed/syswinwrapper.cxx @@ -40,7 +40,7 @@ using namespace winwrap; //Notification codes for WM_COMMAND messages #define HWN_BORDERDOUBLECLICKED 1 #define CBHATCHWNDEXTRA (sizeof(LONG)) -#define SZCLASSHATCHWIN TEXT("hatchwin") +#define SZCLASSHATCHWIN L"hatchwin" typedef CHatchWin *PCHatchWin; @@ -106,7 +106,7 @@ HINSTANCE winwrap::CWindow::Instance() BOOL winwrap::HatchWindowRegister(HINSTANCE hInst) { - WNDCLASS wc; + WNDCLASSW wc; //Must have CS_DBLCLKS for border! wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; @@ -120,7 +120,7 @@ BOOL winwrap::HatchWindowRegister(HINSTANCE hInst) wc.lpszMenuName = nullptr; wc.lpszClassName = SZCLASSHATCHWIN; - return RegisterClass(&wc); + return RegisterClassW(&wc); } @@ -141,8 +141,8 @@ CHatchWin::CHatchWin(HINSTANCE hInst,const DocumentHolder* pDocHolder) m_hWndAssociate=nullptr; m_uID=0; - m_dBorderOrg=GetProfileInt(TEXT("windows") - , TEXT("OleInPlaceBorderWidth") + m_dBorderOrg=GetProfileIntW(L"windows" + , L"OleInPlaceBorderWidth" , HATCHWIN_BORDERWIDTHDEFAULT); m_dBorder=m_dBorderOrg; @@ -187,7 +187,7 @@ CHatchWin::~CHatchWin() BOOL CHatchWin::Init(HWND hWndParent, WORD uID, HWND hWndAssoc) { m_hWndParent = hWndParent; - m_hWnd=CreateWindowEx( + m_hWnd=CreateWindowExW( WS_EX_NOPARENTNOTIFY, SZCLASSHATCHWIN , SZCLASSHATCHWIN, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 100, 100, hWndParent @@ -370,14 +370,14 @@ LRESULT APIENTRY winwrap::HatchWndProc( HDC hDC; PAINTSTRUCT ps; - phw=reinterpret_cast<PCHatchWin>(GetWindowLongPtr(hWnd, HWWL_STRUCTURE)); + phw=reinterpret_cast<PCHatchWin>(GetWindowLongPtrW(hWnd, HWWL_STRUCTURE)); POINT ptMouse; switch (iMsg) { case WM_CREATE: phw=static_cast<PCHatchWin>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams); - SetWindowLongPtr(hWnd, HWWL_STRUCTURE, reinterpret_cast<LONG_PTR>(phw)); + SetWindowLongPtrW(hWnd, HWWL_STRUCTURE, reinterpret_cast<LONG_PTR>(phw)); break; case WM_PAINT: hDC=BeginPaint(hWnd,&ps); @@ -421,7 +421,7 @@ LRESULT APIENTRY winwrap::HatchWndProc( */ if (nullptr!=phw->m_hWndAssociate) { - SendMessage( + SendMessageW( phw->m_hWndAssociate, WM_COMMAND, MAKEWPARAM(phw->m_uID, HWN_BORDERDOUBLECLICKED), reinterpret_cast<LPARAM>(hWnd)); @@ -429,7 +429,7 @@ LRESULT APIENTRY winwrap::HatchWndProc( break; default: - return DefWindowProc(hWnd, iMsg, wParam, lParam); + return DefWindowProcW(hWnd, iMsg, wParam, lParam); } return 0; diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx index b39f5499d53f..ae30e630f709 100644 --- a/embedserv/source/embed/tracker.cxx +++ b/embedserv/source/embed/tracker.cxx @@ -255,10 +255,9 @@ void Tracker::Construct() } // get default handle size from Windows profile setting - static const TCHAR szWindows[] = TEXT("windows"); - static const TCHAR szInplaceBorderWidth[] = - TEXT("oleinplaceborderwidth"); - afxHandleSize = GetProfileInt(szWindows, szInplaceBorderWidth, 4); + static const WCHAR szWindows[] = L"windows"; + static const WCHAR szInplaceBorderWidth[] = L"oleinplaceborderwidth"; + afxHandleSize = GetProfileIntW(szWindows, szInplaceBorderWidth, 4); bInitialized = TRUE; afxCursors[0] = afxCursors[2] = LoadCursor(nullptr,IDC_SIZENWSE); @@ -396,7 +395,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) for (;;) { MSG msg; - GetMessage(&msg, nullptr, 0, 0); + GetMessageW(&msg, nullptr, 0, 0); if (GetCapture() != hWnd) break; @@ -461,7 +460,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) // just dispatch rest of the messages default: - DispatchMessage(&msg); + DispatchMessageW(&msg); break; } } diff --git a/embedserv/source/inprocserv/dllentry.cxx b/embedserv/source/inprocserv/dllentry.cxx index a4346eab84c2..f6f3b21d01df 100644 --- a/embedserv/source/inprocserv/dllentry.cxx +++ b/embedserv/source/inprocserv/dllentry.cxx @@ -42,47 +42,47 @@ static ULONG g_nLock = 0; namespace { - void FillCharFromInt( int nValue, char* pBuf, int nLen ) + void FillCharFromInt( int nValue, wchar_t* pBuf, int nLen ) { int nInd = 0; while( nInd < nLen ) { char nSign = ( nValue / ( 1 << ( ( nLen - nInd - 1 ) * 4 ) ) ) % 16; if ( nSign >= 0 && nSign <= 9 ) - pBuf[nInd] = nSign + '0'; + pBuf[nInd] = nSign + L'0'; else if ( nSign >= 10 && nSign <= 15 ) - pBuf[nInd] = nSign - 10 + 'a'; + pBuf[nInd] = nSign - 10 + L'a'; nInd++; } } - int GetStringFromClassID( const GUID& guid, char* pBuf, int nLen ) + int GetStringFromClassID( const GUID& guid, wchar_t* pBuf, int nLen ) { // is not allowed to insert if ( nLen < 38 ) return 0; - pBuf[0] = '{'; + pBuf[0] = L'{'; FillCharFromInt( guid.Data1, &pBuf[1], 8 ); - pBuf[9] = '-'; + pBuf[9] = L'-'; FillCharFromInt( guid.Data2, &pBuf[10], 4 ); - pBuf[14] = '-'; + pBuf[14] = L'-'; FillCharFromInt( guid.Data3, &pBuf[15], 4 ); - pBuf[19] = '-'; + pBuf[19] = L'-'; int nInd = 0; for ( nInd = 0; nInd < 2 ; nInd++ ) FillCharFromInt( guid.Data4[nInd], &pBuf[20 + 2*nInd], 2 ); - pBuf[24] = '-'; + pBuf[24] = L'-'; for ( nInd = 2; nInd < 8 ; nInd++ ) FillCharFromInt( guid.Data4[nInd], &pBuf[20 + 1 + 2*nInd], 2 ); - pBuf[37] = '}'; + pBuf[37] = L'}'; return 38; } - HRESULT WriteLibraryToRegistry( const char* pLibrary, DWORD nLen ) + HRESULT WriteLibraryToRegistry( const wchar_t* pLibrary, DWORD nLen ) { HRESULT hRes = E_FAIL; if ( pLibrary && nLen ) @@ -92,18 +92,18 @@ namespace { hRes = S_OK; for ( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ ) { - const char pSubKeyTemplate[] = "Software\\Classes\\CLSID\\.....................................\\InprocHandler32"; - char pSubKey[SAL_N_ELEMENTS(pSubKeyTemplate)]; - strncpy(pSubKey, pSubKeyTemplate, SAL_N_ELEMENTS(pSubKeyTemplate)); + const wchar_t pSubKeyTemplate[] = L"Software\\Classes\\CLSID\\.....................................\\InprocHandler32"; + wchar_t pSubKey[SAL_N_ELEMENTS(pSubKeyTemplate)]; + wcsncpy(pSubKey, pSubKeyTemplate, SAL_N_ELEMENTS(pSubKeyTemplate)); int nGuidLen = GetStringFromClassID( *guidList[nInd], &pSubKey[23], 38 ); BOOL bLocalSuccess = FALSE; if ( nGuidLen == 38 ) { - if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, pSubKey, &hKey ) ) + if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_LOCAL_MACHINE, pSubKey, &hKey ) ) { - if ( ERROR_SUCCESS == RegSetValueEx( hKey, "", 0, REG_SZ, reinterpret_cast<const BYTE*>(pLibrary), nLen ) ) + if ( ERROR_SUCCESS == RegSetValueExW( hKey, L"", 0, REG_SZ, reinterpret_cast<const BYTE*>(pLibrary), nLen*sizeof(wchar_t) ) ) bLocalSuccess = TRUE; } @@ -199,11 +199,11 @@ STDAPI DllCanUnloadNow() STDAPI DllRegisterServer() { - HMODULE aCurModule = GetModuleHandleA( "inprocserv.dll" ); + HMODULE aCurModule = GetModuleHandleW( L"inprocserv.dll" ); if( aCurModule ) { - char aLibPath[1024]; - DWORD nLen = GetModuleFileNameA( aCurModule, aLibPath, 1019 ); + wchar_t aLibPath[1024]; + DWORD nLen = GetModuleFileNameW( aCurModule, aLibPath, 1019 ); if ( nLen && nLen < 1019 ) { aLibPath[nLen++] = 0; @@ -217,7 +217,7 @@ STDAPI DllRegisterServer() STDAPI DllUnregisterServer() { - return WriteLibraryToRegistry( "ole32.dll", 10 ); + return WriteLibraryToRegistry( L"ole32.dll", 10 ); } |