[2/2] oleacc: implemented GetRoleText[A/W] with some tests

Nikolay Sivov bunglehead at gmail.com
Wed Sep 24 14:54:15 CDT 2008


>From 8444344dbd964a7693ade3402fdad5e893f77b5d Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Wed, 24 Sep 2008 23:47:49 +0400
Subject:  Implemented GetRoleText[A/W] with tests

---
 dlls/oleacc/Makefile.in       |    4 +-
 dlls/oleacc/main.c            |   61 +++++++++++++++++++++++++++
 dlls/oleacc/oleacc.rc         |   24 +++++++++++
 dlls/oleacc/oleacc.spec       |    4 +-
 dlls/oleacc/oleacc_En.rc      |   90 +++++++++++++++++++++++++++++++++++++++++
 dlls/oleacc/tests/Makefile.in |   13 ++++++
 dlls/oleacc/tests/main.c      |   44 ++++++++++++++++++++
 7 files changed, 237 insertions(+), 3 deletions(-)

diff --git a/dlls/oleacc/Makefile.in b/dlls/oleacc/Makefile.in
index 5822916..882edcb 100644
--- a/dlls/oleacc/Makefile.in
+++ b/dlls/oleacc/Makefile.in
@@ -4,11 +4,13 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = oleacc.dll
 IMPORTLIB = oleacc
-IMPORTS   = kernel32
+IMPORTS   = kernel32 user32
 
 C_SRCS = \
 	main.c
 
+RC_SRCS = oleacc.rc
+
 @MAKE_DLL_RULES@
 
 @DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/oleacc/main.c b/dlls/oleacc/main.c
index 9a6f765..7143bed 100644
--- a/dlls/oleacc/main.c
+++ b/dlls/oleacc/main.c
@@ -24,10 +24,13 @@
 #include "winuser.h"
 #include "ole2.h"
 
+#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(oleacc);
 
+static HINSTANCE oleacc_handle = 0;
+
 HRESULT WINAPI CreateStdAccessibleObject( HWND hwnd, LONG idObject,
                              REFIID riidInterface, void** ppvObject )
 {
@@ -50,6 +53,21 @@ HRESULT WINAPI AccessibleObjectFromWindow( HWND hwnd, DWORD dwObjectID,
     return E_NOTIMPL;
 }
 
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
+                    LPVOID lpvReserved)
+{
+    TRACE("%p, %d, %p\n", hinstDLL, fdwReason, lpvReserved);
+
+    switch (fdwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+            oleacc_handle = hinstDLL;
+            DisableThreadLibraryCalls(hinstDLL);
+            break;
+    }
+    return TRUE;
+}
+
 HRESULT WINAPI DllRegisterServer(void)
 {
     FIXME("\n");
@@ -67,3 +85,46 @@ void WINAPI GetOleaccVersionInfo(DWORD* pVersion, DWORD* pBuild)
     *pVersion = MAKELONG(2,4); /* Windows XP version of oleacc: 4.2.5406.0 */
     *pBuild = MAKELONG(0,5406);
 }
+
+UINT WINAPI GetRoleTextW(DWORD role, LPWSTR lpRole, UINT rolemax)
+{
+    INT ret;
+    WCHAR *resptr;
+
+    TRACE("%u %p %u\n", role, lpRole, rolemax);
+
+    /* return role text length */
+    if(!lpRole)
+        return LoadStringW(oleacc_handle, role, (LPWSTR)&resptr, 0);
+
+    ret = LoadStringW(oleacc_handle, role, lpRole, rolemax);
+    if(!(ret > 0))
+        return 0;
+
+    return ret;
+}
+
+UINT WINAPI GetRoleTextA(DWORD role, LPSTR lpRole, UINT rolemax)
+{
+    UINT length;
+    WCHAR *roletext;
+    INT ret;
+
+    TRACE("%u %p %u\n", role, lpRole, rolemax);
+
+    length = GetRoleTextW(role, NULL, 0);
+
+    if(!length || !lpRole)
+        return length;
+
+    roletext = HeapAlloc(GetProcessHeap(), 0, (length + 1)*sizeof(WCHAR));
+    if(!roletext)
+        return 0;
+
+    GetRoleTextW(role, roletext, length + 1);
+
+    ret = WideCharToMultiByte( CP_ACP, 0, roletext, -1, lpRole, rolemax, NULL, NULL );
+    HeapFree(GetProcessHeap(), 0, roletext);
+
+    return ret;
+}
diff --git a/dlls/oleacc/oleacc.rc b/dlls/oleacc/oleacc.rc
new file mode 100644
index 0000000..0795a9b
--- /dev/null
+++ b/dlls/oleacc/oleacc.rc
@@ -0,0 +1,24 @@
+/*
+ * Top level resource file for oleacc
+ *
+ * Copyright 2008 Nikolay Sivov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "windef.h"
+#include "oleacc.h"
+
+#include "oleacc_En.rc"
diff --git a/dlls/oleacc/oleacc.spec b/dlls/oleacc/oleacc.spec
index 23b84b3..75b743a 100644
--- a/dlls/oleacc/oleacc.spec
+++ b/dlls/oleacc/oleacc.spec
@@ -8,8 +8,8 @@
 @ stdcall -private DllRegisterServer()
 @ stdcall -private DllUnregisterServer()
 @ stdcall GetOleaccVersionInfo(ptr ptr)
-@ stub GetRoleTextA
-@ stub GetRoleTextW
+@ stdcall GetRoleTextA(long ptr long)
+@ stdcall GetRoleTextW(long wstr long)
 @ stub GetStateTextA
 @ stub GetStateTextW
 @ stub IID_IAccessible
diff --git a/dlls/oleacc/oleacc_En.rc b/dlls/oleacc/oleacc_En.rc
new file mode 100644
index 0000000..992d29c
--- /dev/null
+++ b/dlls/oleacc/oleacc_En.rc
@@ -0,0 +1,90 @@
+/*
+ * English resources for oleacc
+ *
+ * Copyright 2008 Nikolay Sivov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+STRINGTABLE DISCARDABLE
+{
+    0 "unknown object" /* undocumented */
+    ROLE_SYSTEM_TITLEBAR    "title bar"
+    ROLE_SYSTEM_MENUBAR     "menu bar"
+    ROLE_SYSTEM_SCROLLBAR   "scroll bar"
+    ROLE_SYSTEM_GRIP        "grip"
+    ROLE_SYSTEM_SOUND       "sound"
+    ROLE_SYSTEM_CURSOR      "cursor"
+    ROLE_SYSTEM_CARET       "caret"
+    ROLE_SYSTEM_ALERT       "alert"
+    ROLE_SYSTEM_WINDOW      "window"
+    ROLE_SYSTEM_CLIENT      "client"
+    ROLE_SYSTEM_MENUPOPUP   "popup menu"
+    ROLE_SYSTEM_MENUITEM    "menu item"
+    ROLE_SYSTEM_TOOLTIP     "tool tip"
+    ROLE_SYSTEM_APPLICATION "application"
+    ROLE_SYSTEM_DOCUMENT    "document"
+    ROLE_SYSTEM_PANE        "pane"
+    ROLE_SYSTEM_CHART       "chart"
+    ROLE_SYSTEM_DIALOG      "dialog"
+    ROLE_SYSTEM_BORDER      "border"
+    ROLE_SYSTEM_GROUPING    "grouping"
+    ROLE_SYSTEM_SEPARATOR   "separator"
+    ROLE_SYSTEM_TOOLBAR     "tool bar"
+    ROLE_SYSTEM_STATUSBAR   "status bar"
+    ROLE_SYSTEM_TABLE        "table"
+    ROLE_SYSTEM_COLUMNHEADER "column header"
+    ROLE_SYSTEM_ROWHEADER    "row header"
+    ROLE_SYSTEM_COLUMN       "column"
+    ROLE_SYSTEM_ROW          "row"
+    ROLE_SYSTEM_CELL         "cell"
+    ROLE_SYSTEM_LINK         "link"
+    ROLE_SYSTEM_HELPBALLOON  "help balloon"
+    ROLE_SYSTEM_CHARACTER    "character"
+    ROLE_SYSTEM_LIST         "list"
+    ROLE_SYSTEM_LISTITEM     "list item"
+    ROLE_SYSTEM_OUTLINE      "outline"
+    ROLE_SYSTEM_OUTLINEITEM  "outline item"
+    ROLE_SYSTEM_PAGETAB      "page tab"
+    ROLE_SYSTEM_PROPERTYPAGE "property page"
+    ROLE_SYSTEM_INDICATOR    "indicator"
+    ROLE_SYSTEM_GRAPHIC      "graphic"
+    ROLE_SYSTEM_STATICTEXT   "static text"
+    ROLE_SYSTEM_TEXT         "text"
+    ROLE_SYSTEM_PUSHBUTTON   "push button"
+    ROLE_SYSTEM_CHECKBUTTON  "check button"
+    ROLE_SYSTEM_RADIOBUTTON  "radio button"
+    ROLE_SYSTEM_COMBOBOX     "combo box"
+    ROLE_SYSTEM_DROPLIST     "drop down"
+    ROLE_SYSTEM_PROGRESSBAR  "progress bar"
+    ROLE_SYSTEM_DIAL         "dial"
+    ROLE_SYSTEM_HOTKEYFIELD  "hot key field"
+    ROLE_SYSTEM_SLIDER       "slider"
+    ROLE_SYSTEM_SPINBUTTON   "spin box"
+    ROLE_SYSTEM_DIAGRAM      "diagram"
+    ROLE_SYSTEM_ANIMATION    "animation"
+    ROLE_SYSTEM_EQUATION     "equation"
+    ROLE_SYSTEM_BUTTONDROPDOWN "drop down button"
+    ROLE_SYSTEM_BUTTONMENU   "menu button"
+    ROLE_SYSTEM_BUTTONDROPDOWNGRID "grid drop down button"
+    ROLE_SYSTEM_WHITESPACE   "white space"
+    ROLE_SYSTEM_PAGETABLIST  "page tab list"
+    ROLE_SYSTEM_CLOCK        "clock"
+    ROLE_SYSTEM_SPLITBUTTON  "split button"
+    ROLE_SYSTEM_IPADDRESS    "IP address"
+    ROLE_SYSTEM_OUTLINEBUTTON "outline button"
+}
diff --git a/dlls/oleacc/tests/Makefile.in b/dlls/oleacc/tests/Makefile.in
new file mode 100644
index 0000000..6e2bc8d
--- /dev/null
+++ b/dlls/oleacc/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL   = oleacc.dll
+IMPORTS   = kernel32 oleacc
+
+CTESTS = \
+	main.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/oleacc/tests/main.c b/dlls/oleacc/tests/main.c
new file mode 100644
index 0000000..c0b6a0f
--- /dev/null
+++ b/dlls/oleacc/tests/main.c
@@ -0,0 +1,44 @@
+/*
+ * oleacc tests
+ *
+ * Copyright 2008 Nikolay Sivov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <oleacc.h>
+#include "wine/test.h"
+
+static void test_getroletext(void)
+{
+    INT ret;
+
+    /* wrong role number */
+    ret = GetRoleTextA(-1, NULL, 0);
+    ok(ret == 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret);
+
+    /* zero role number - not documented */
+    ret = GetRoleTextA(0, NULL, 0);
+    ok(ret > 0, "GetRoleTextA doesn't return length for zero role number, got %d\n", ret);
+
+    /* NULL buffer, return length */
+    ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, NULL, 0);
+    ok(ret > 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret);
+}
+
+START_TEST(main)
+{
+    test_getroletext();
+}
-- 
1.4.4.4






More information about the wine-patches mailing list