merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / svdde / ddewrap.cxx
blobd6ba8d963bc3003d163c7cb885464c4e1ff7b734
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ddewrap.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svtools.hxx"
34 #define _SVTOOLS_SVDDE_DDEWRAP_CXX_
36 #if defined _MSC_VER
37 #pragma warning(push, 1)
38 #endif
39 #include <windows.h>
40 #if defined _MSC_VER
41 #pragma warning(pop)
42 #endif
43 #include "ddewrap.hxx"
45 //------------------------------------------------------------------------
47 HSZ WINAPI DdeCreateStringHandleW_9x( DWORD idInst, LPCWSTR pszString, int )
49 HSZ hszResult;
50 LPSTR pszANSIString;
51 int nSize;
53 nSize = pszString ? WideCharToMultiByte( CP_ACP, 0, pszString, -1, NULL, 0, NULL, NULL ) : 0;
54 pszANSIString = nSize ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, nSize * sizeof(CHAR) ) : NULL;
56 if ( pszANSIString )
57 WideCharToMultiByte( CP_ACP, 0, pszString, -1, pszANSIString, nSize, NULL, NULL );
59 hszResult = DdeCreateStringHandleA( idInst, pszANSIString, CP_WINANSI );
61 if ( pszANSIString )
62 HeapFree( GetProcessHeap(), 0, pszANSIString );
64 return hszResult;
67 //------------------------------------------------------------------------
69 DWORD WINAPI DdeQueryStringW_9x( DWORD idInst, HSZ hsz, LPWSTR pszString, DWORD cchMax, int )
71 DWORD dwResult;
72 LPSTR pszANSIString;
74 pszANSIString = cchMax ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, cchMax * sizeof(CHAR) ) : NULL;
76 dwResult = DdeQueryStringA( idInst, hsz, pszANSIString, cchMax, CP_WINANSI );
78 if ( dwResult && pszANSIString )
79 MultiByteToWideChar( CP_ACP, 0, pszANSIString, -1, pszString, cchMax );
81 if ( pszANSIString )
82 HeapFree( GetProcessHeap(), 0, pszANSIString );
84 return dwResult;
87 //------------------------------------------------------------------------
89 UINT WINAPI DdeInitializeW_9x( LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes )
91 return DdeInitializeA( pidInst, pfnCallback, afCmd, ulRes );
94 //------------------------------------------------------------------------
96 #define DEFINE_WAPI_FUNC(func) \
97 func##_PROC lpfn##func = (LONG)GetVersion() >= 0 ? func : func##_9x;
100 DEFINE_WAPI_FUNC( DdeCreateStringHandleW );
101 DEFINE_WAPI_FUNC( DdeQueryStringW );
102 DEFINE_WAPI_FUNC( DdeInitializeW );