1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 29 // MARKER(update_precomp.py): autogen include statement, do not remove 30 #include "precompiled_svl.hxx" 31 #define _SVTOOLS_SVDDE_DDEWRAP_CXX_ 32 33 #if defined _MSC_VER 34 #pragma warning(push, 1) 35 #endif 36 #include <windows.h> 37 #if defined _MSC_VER 38 #pragma warning(pop) 39 #endif 40 #include "ddewrap.hxx" 41 42 //------------------------------------------------------------------------ 43 44 HSZ WINAPI DdeCreateStringHandleW_9x( DWORD idInst, LPCWSTR pszString, int ) 45 { 46 HSZ hszResult; 47 LPSTR pszANSIString; 48 int nSize; 49 50 nSize = pszString ? WideCharToMultiByte( CP_ACP, 0, pszString, -1, NULL, 0, NULL, NULL ) : 0; 51 pszANSIString = nSize ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, nSize * sizeof(CHAR) ) : NULL; 52 53 if ( pszANSIString ) 54 WideCharToMultiByte( CP_ACP, 0, pszString, -1, pszANSIString, nSize, NULL, NULL ); 55 56 hszResult = DdeCreateStringHandleA( idInst, pszANSIString, CP_WINANSI ); 57 58 if ( pszANSIString ) 59 HeapFree( GetProcessHeap(), 0, pszANSIString ); 60 61 return hszResult; 62 } 63 64 //------------------------------------------------------------------------ 65 66 DWORD WINAPI DdeQueryStringW_9x( DWORD idInst, HSZ hsz, LPWSTR pszString, DWORD cchMax, int ) 67 { 68 DWORD dwResult; 69 LPSTR pszANSIString; 70 71 pszANSIString = cchMax ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, cchMax * sizeof(CHAR) ) : NULL; 72 73 dwResult = DdeQueryStringA( idInst, hsz, pszANSIString, cchMax, CP_WINANSI ); 74 75 if ( dwResult && pszANSIString ) 76 MultiByteToWideChar( CP_ACP, 0, pszANSIString, -1, pszString, cchMax ); 77 78 if ( pszANSIString ) 79 HeapFree( GetProcessHeap(), 0, pszANSIString ); 80 81 return dwResult; 82 } 83 84 //------------------------------------------------------------------------ 85 86 UINT WINAPI DdeInitializeW_9x( LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes ) 87 { 88 return DdeInitializeA( pidInst, pfnCallback, afCmd, ulRes ); 89 } 90 91 //------------------------------------------------------------------------ 92 93 #define DEFINE_WAPI_FUNC(func) \ 94 func##_PROC lpfn##func = (LONG)GetVersion() >= 0 ? func : func##_9x; 95 96 97 DEFINE_WAPI_FUNC( DdeCreateStringHandleW ); 98 DEFINE_WAPI_FUNC( DdeQueryStringW ); 99 DEFINE_WAPI_FUNC( DdeInitializeW ); 100 101