Sync with trunk r63793.
[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 DllGetClassObject(REFCLSID rclsid, REFIID iid, void **ppv)
89 {
90 FIXME("%s %s %p: stub\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
91 return E_NOTIMPL;
92 }
93
94 HRESULT WINAPI DllRegisterServer(void)
95 {
96 FIXME("\n");
97 return S_OK;
98 }
99
100 HRESULT WINAPI DllUnregisterServer(void)
101 {
102 FIXME("\n");
103 return S_OK;
104 }
105
106 void WINAPI GetOleaccVersionInfo(DWORD* pVersion, DWORD* pBuild)
107 {
108 *pVersion = MAKELONG(2,4); /* Windows XP version of oleacc: 4.2.5406.0 */
109 *pBuild = MAKELONG(0,5406);
110 }
111
112 UINT WINAPI GetRoleTextW(DWORD role, LPWSTR lpRole, UINT rolemax)
113 {
114 INT ret;
115 WCHAR *resptr;
116
117 TRACE("%u %p %u\n", role, lpRole, rolemax);
118
119 /* return role text length */
120 if(!lpRole)
121 return LoadStringW(oleacc_handle, role, (LPWSTR)&resptr, 0);
122
123 ret = LoadStringW(oleacc_handle, role, lpRole, rolemax);
124 if(!(ret > 0)){
125 if(rolemax > 0) lpRole[0] = '\0';
126 return 0;
127 }
128
129 return ret;
130 }
131
132 UINT WINAPI GetRoleTextA(DWORD role, LPSTR lpRole, UINT rolemax)
133 {
134 UINT length;
135 WCHAR *roletextW;
136
137 TRACE("%u %p %u\n", role, lpRole, rolemax);
138
139 length = GetRoleTextW(role, NULL, 0);
140 if((length == 0) || (lpRole && !rolemax))
141 return 0;
142
143 roletextW = HeapAlloc(GetProcessHeap(), 0, (length + 1)*sizeof(WCHAR));
144 if(!roletextW)
145 return 0;
146
147 GetRoleTextW(role, roletextW, length + 1);
148
149 length = WideCharToMultiByte( CP_ACP, 0, roletextW, -1, NULL, 0, NULL, NULL );
150
151 if(!lpRole){
152 HeapFree(GetProcessHeap(), 0, roletextW);
153 return length - 1;
154 }
155
156 WideCharToMultiByte( CP_ACP, 0, roletextW, -1, lpRole, rolemax, NULL, NULL );
157
158 if(rolemax < length){
159 lpRole[rolemax-1] = '\0';
160 length = rolemax;
161 }
162
163 HeapFree(GetProcessHeap(), 0, roletextW);
164
165 return length - 1;
166 }