- Sync with trunk r58248 to bring the latest changes from Amine (headers) and others...
[reactos.git] / dll / win32 / oleacc / main.c
1 /*
2 * Implementation of the OLEACC dll
3 *
4 * Copyright 2003 Mike McCormack for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #define WIN32_NO_STATUS
22 #define _INC_WINDOWS
23 #define COM_NO_WINDOWS_H
24
25 #include <stdarg.h>
26 #include <windef.h>
27 #include <winbase.h>
28 //#include "winuser.h"
29 #include <ole2.h>
30 #include <oleacc.h>
31
32 #include <wine/unicode.h>
33 #include <wine/debug.h>
34
35 WINE_DEFAULT_DEBUG_CHANNEL(oleacc);
36
37 static HINSTANCE oleacc_handle = 0;
38
39 HRESULT WINAPI CreateStdAccessibleObject( HWND hwnd, LONG idObject,
40 REFIID riidInterface, void** ppvObject )
41 {
42 FIXME("%p %d %s %p\n", hwnd, idObject,
43 debugstr_guid( riidInterface ), ppvObject );
44 return E_NOTIMPL;
45 }
46
47 HRESULT WINAPI ObjectFromLresult( LRESULT result, REFIID riid, WPARAM wParam, void **ppObject )
48 {
49 FIXME("%ld %s %ld %p\n", result, debugstr_guid(riid), wParam, ppObject );
50 return E_NOTIMPL;
51 }
52
53 LRESULT WINAPI LresultFromObject( REFIID riid, WPARAM wParam, LPUNKNOWN pAcc )
54 {
55 FIXME("%s %ld %p\n", debugstr_guid(riid), wParam, pAcc );
56 return E_NOTIMPL;
57 }
58
59 HRESULT WINAPI AccessibleObjectFromPoint( POINT ptScreen, IAccessible** ppacc, VARIANT* pvarChild )
60 {
61 FIXME("{%d,%d} %p %p: stub\n", ptScreen.x, ptScreen.y, ppacc, pvarChild );
62 return E_NOTIMPL;
63 }
64
65 HRESULT WINAPI AccessibleObjectFromWindow( HWND hwnd, DWORD dwObjectID,
66 REFIID riid, void** ppvObject )
67 {
68 FIXME("%p %d %s %p\n", hwnd, dwObjectID,
69 debugstr_guid( riid ), ppvObject );
70 return E_NOTIMPL;
71 }
72
73 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
74 LPVOID lpvReserved)
75 {
76 TRACE("%p, %d, %p\n", hinstDLL, fdwReason, lpvReserved);
77
78 switch (fdwReason)
79 {
80 case DLL_PROCESS_ATTACH:
81 oleacc_handle = hinstDLL;
82 DisableThreadLibraryCalls(hinstDLL);
83 break;
84 }
85 return TRUE;
86 }
87
88 HRESULT WINAPI DllRegisterServer(void)
89 {
90 FIXME("\n");
91 return S_OK;
92 }
93
94 HRESULT WINAPI DllUnregisterServer(void)
95 {
96 FIXME("\n");
97 return S_OK;
98 }
99
100 void WINAPI GetOleaccVersionInfo(DWORD* pVersion, DWORD* pBuild)
101 {
102 *pVersion = MAKELONG(2,4); /* Windows XP version of oleacc: 4.2.5406.0 */
103 *pBuild = MAKELONG(0,5406);
104 }
105
106 UINT WINAPI GetRoleTextW(DWORD role, LPWSTR lpRole, UINT rolemax)
107 {
108 INT ret;
109 WCHAR *resptr;
110
111 TRACE("%u %p %u\n", role, lpRole, rolemax);
112
113 /* return role text length */
114 if(!lpRole)
115 return LoadStringW(oleacc_handle, role, (LPWSTR)&resptr, 0);
116
117 ret = LoadStringW(oleacc_handle, role, lpRole, rolemax);
118 if(!(ret > 0)){
119 if(rolemax > 0) lpRole[0] = '\0';
120 return 0;
121 }
122
123 return ret;
124 }
125
126 UINT WINAPI GetRoleTextA(DWORD role, LPSTR lpRole, UINT rolemax)
127 {
128 UINT length;
129 WCHAR *roletextW;
130
131 TRACE("%u %p %u\n", role, lpRole, rolemax);
132
133 length = GetRoleTextW(role, NULL, 0);
134 if((length == 0) || (lpRole && !rolemax))
135 return 0;
136
137 roletextW = HeapAlloc(GetProcessHeap(), 0, (length + 1)*sizeof(WCHAR));
138 if(!roletextW)
139 return 0;
140
141 GetRoleTextW(role, roletextW, length + 1);
142
143 length = WideCharToMultiByte( CP_ACP, 0, roletextW, -1, NULL, 0, NULL, NULL );
144
145 if(!lpRole){
146 HeapFree(GetProcessHeap(), 0, roletextW);
147 return length - 1;
148 }
149
150 WideCharToMultiByte( CP_ACP, 0, roletextW, -1, lpRole, rolemax, NULL, NULL );
151
152 if(rolemax < length){
153 lpRole[rolemax-1] = '\0';
154 length = rolemax;
155 }
156
157 HeapFree(GetProcessHeap(), 0, roletextW);
158
159 return length - 1;
160 }