Anonymous avatar Anonymous committed 94124ee

accstuff: merged remaining changes from CWS oo31ia2, stuff that will go into the ia2bridge cws

Comments (0)

Files changed (10)

scp2/source/ooo/file_library_ooo.scp

  ************************************************************************/
 #include "macros.inc"
 
+#if defined(WNT) && !defined(DISABLE_ATL)
+File gid_File_Lib_Winaccessibility
+	TXT_FILE_BODY;
+	Styles	= (PACKED,UNO_COMPONENT);
+	RegistryID      = gid_Starregistry_Services_Rdb;
+	Dir	= gid_Dir_Program;
+	Name	= "winaccessibility.dll";
+End
+File gid_File_Lib_UAccCOM
+	BIN_FILE_BODY;
+	Styles	= (PACKED);
+	Dir	= gid_Dir_Program;
+	Name	= "UAccCOM.dll";
+End
+#endif
 #ifdef WNT
 File gid_File_Lib_Accessbridge
     BIN_FILE_BODY;

scp2/source/ooo/module_hidden_ooo.scp

 	gid_File_Lib_Stdc_3,
 	gid_File_Lib_Stdc_5,
 	gid_File_Lib_Accessbridge,
+	gid_File_Lib_Winaccessibility,
+	gid_File_Lib_UAccCOM,
 	gid_File_Lib_Ado,
 	gid_File_Lib_Dl,
 	gid_File_Lib_Dnd,

vcl/inc/vcl/svapp.hxx

     
     static void                 ShowNativeErrorBox(const String& sTitle  ,
                                                    const String& sMessage);
+//IAccessibility2 Implementation 2009-----
+	static bool					EnableAccessInterface(bool bEnable);
+	static bool					IsEnableAccessInterface();
+//-----IAccessibility2 Implementation 2009
 
     // IME Status Window Control:
 
     PostUserEvent( Link() );
 }
 
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+// VCL_DLLPUBLIC sal_Bool HasAtHook();
+VCL_DLLPUBLIC bool IsWNTInitAccessBridge();
+bool WNTEnableAccessInterface(bool bEnable);
+VCL_DLLPUBLIC bool TestBridgeRegistered();
+VCL_DLLPUBLIC bool IsBridgeRegistered();
+#endif
+//-----IAccessibility2 Implementation 2009
 #endif // _APP_HXX

vcl/inc/vcl/svdata.hxx

      */
     ImeStatusWindowMode meShowImeStatusWindow;
 
+//IAccessibility2 Implementation 2009-----
+	long m_bEnableAccessInterface;
+	long m_mbIsBridgeRegistered;
+//-----IAccessibility2 Implementation 2009
                             DECL_STATIC_LINK( ImplSVAppData, ImplQuitMsg, void* );
                            
 };
 ..\inc\vcl\ppdparser.hxx %_DEST%\inc%_EXT%\vcl\ppdparser.hxx
 ..\inc\vcl\helper.hxx %_DEST%\inc%_EXT%\vcl\helper.hxx
 ..\inc\vcl\strhelper.hxx %_DEST%\inc%_EXT%\vcl\strhelper.hxx
+#IAccessibility2 implementation 2009. ------
+#MT: This shouldn't be done. Probably only used in ia2 bridge, wich should move to vcl anyway...
+..\inc\vcl\svdata.hxx %_DEST%\inc%_EXT%\vcl\svdata.hxx
+..\inc\vcl\usermsg.hxx %_DEST%\inc%_EXT%\vcl\usermsg.hxx
+#------ IAccessibility2 implementation 2009.
 ..\inc\vcl\lazydelete.hxx %_DEST%\inc%_EXT%\vcl\lazydelete.hxx
 ..\inc\vcl\arrange.hxx %_DEST%\inc%_EXT%\vcl\arrange.hxx
 ..\inc\vcl\wpropset.hxx %_DEST%\inc%_EXT%\vcl\wpropset.hxx

vcl/source/app/svapp.cxx

 
 sal_Bool Application::IsAccessibilityEnabled()
 {
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+	return IsWNTInitAccessBridge();
+#else 
     return sal_False;
+#endif 
+//-----IAccessibility2 Implementation 2009
 }
 
 sal_Bool InitAccessBridge( sal_Bool bShowCancel, sal_Bool &rCancelled )
 {
     sal_Bool bRet = true;
+    rCancelled = FALSE;
 
 // Disable Java bridge on UNIX
 #if defined UNX
     (void) bShowCancel; // unsued
-    (void) rCancelled; // unused
 #else
-    bRet = ImplInitAccessBridge( bShowCancel, rCancelled );
-    
-    if( !bRet && bShowCancel && !rCancelled )
-    {
-        // disable accessibility if the user chooses to continue
-        AllSettings aSettings = Application::GetSettings();
-        MiscSettings aMisc = aSettings.GetMiscSettings();
-        aMisc.SetEnableATToolSupport( sal_False );
-        aSettings.SetMiscSettings( aMisc );
-        Application::SetSettings( aSettings );
-    }
-#endif // !UNX
+
+	// Checking TestBridgeRegistered() && HasAtHook() was introduced with IBM's IA2 CWS.
+	if(TestBridgeRegistered() /* && HasAtHook() */ )
+	{
+	    bRet = ImplInitAccessBridge( bShowCancel, rCancelled );
+	    
+	    if( !bRet && bShowCancel && !rCancelled )
+	    {
+	        // disable accessibility if the user chooses to continue
+	        AllSettings aSettings = Application::GetSettings();
+	        MiscSettings aMisc = aSettings.GetMiscSettings();
+	        aMisc.SetEnableATToolSupport( sal_False );
+	        aSettings.SetMiscSettings( aMisc );
+	        Application::SetSettings( aSettings );
+	    }
+	}
+	else
+	{
+		bRet = FALSE;
+	}
+#endif
 
     return bRet;
 }
 
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+sal_Bool HasAtHook()
+{
+	// Added by Steve Yin
+	sal_Int32 bIsRuning=FALSE;
+	// BOOL WINAPI SystemParametersInfo(
+	//	  __in     UINT uiAction,
+	//	  __in     UINT uiParam,
+	//	  __inout  PVOID pvParam,
+	//	  __in     UINT fWinIni
+	//	);
+	// pvParam must be BOOL (defined in MFC as int)
+	// End
+	if(SystemParametersInfo(SPI_GETSCREENREADER,0,&bIsRuning,0))
+	{
+		if( bIsRuning )
+			return sal_True;
+	}
+	return sal_False;
+}
+#endif
+//-----IAccessibility2 Implementation 2009
 // MT: AppProperty, AppEvent was in oldsv.cxx, but is still needed...
 // ------------------------------------------------------------------------
 
         delete pHandler;
     pHandler = p;
 }
+//IAccessibility2 Implementation 2009-----
+bool Application::EnableAccessInterface(bool bEnable)
+{
+#ifdef WNT
+	return WNTEnableAccessInterface(bEnable);
+#else 
+    bEnable = TRUE; // avoid compiler warning
+    return TRUE;
+#endif 
+}
+bool Application::IsEnableAccessInterface()
+{
+	return ImplGetSVData()->maAppData.m_bEnableAccessInterface;
+}
+//-----IAccessibility2 Implementation 2009
 
 
 
 void Application::AppEvent( const ApplicationEvent& /*rAppEvent*/ )
 {
 }
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+bool TestBridgeRegistered()
+{
+	const CLSID CLSID_MAccessible = {0xCF8DF8BA,0x44FE,0x4B10,{0xBD,0x2E,0x8C,0x8C,0xB3,0x22,0x48,0x5F}};
+
+	LPCOLESTR lpMAcc=L"UAccCOM.MAccessible";
+
+	CLSID mid;	
+	bool bReg = false;
+	if(S_OK  == CLSIDFromProgID(lpMAcc,&mid))
+	{
+		if( IsEqualCLSID(mid,CLSID_MAccessible))
+			bReg = true;
+		else
+			bReg = false;
+	}
+
+	ImplGetSVData()->maAppData.m_mbIsBridgeRegistered =bReg;
+	return bReg;
+}
+
+bool IsBridgeRegistered()
+{
+	return ImplGetSVData()->maAppData.m_mbIsBridgeRegistered;;
+}
+
+#endif
+//-----IAccessibility2 Implementation 2009

vcl/source/app/svdata.cxx

 #include "tools/debug.hxx"
 #include "tools/resary.hxx"
 
+#include <com/sun/star/lang/XComponent.hpp>
+
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#endif
+#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#endif
+#endif
+//-----IAccessibility2 Implementation 2009
+
 #include "vcl/salinst.hxx"
 #include "vcl/salframe.hxx"
 #include "vcl/configsettings.hxx"
 #include "com/sun/star/java/JavaDisabledException.hpp"
 
 #include <stdio.h>
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/accessibility/XMSAAService.hpp>
+#include <g_msaasvc.h>
+#endif
+//-----IAccessibility2 Implementation 2009
 
 namespace {
 
 
 }
 
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::awt;
-using namespace rtl;
-
 // =======================================================================
 
 namespace
             break;
         }
     }
+//IAccessibility2 Implementation 2009-----
+	//Default enable the acc bridge interface
+	pImplSVData->maAppData.m_bEnableAccessInterface =TRUE;
+//-----IAccessibility2 Implementation 2009
     
     // mark default layout border as unitialized
     pImplSVData->maAppData.mnDefaultLayoutBorder = -1;
     }
     return ret;
 }
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+void AccessBridgehandleExistingWindow(Window * pWindow, bool bShow)
+{
+    if ( pWindow )
+    {
+        css::uno::Reference< css::accessibility::XAccessible > xAccessible;
+    
+        // Test for combo box - drop down floating windows first
+        Window * pParentWindow = pWindow->GetParent();
 
+        if ( pParentWindow )
+        {
+            try 
+            {
+                // The parent window of a combo box floating window should have the role COMBO_BOX
+                css::uno::Reference< css::accessibility::XAccessible > xParentAccessible(pParentWindow->GetAccessible());
+                if ( xParentAccessible.is() )
+                {
+                    css::uno::Reference< css::accessibility::XAccessibleContext > xParentAC( xParentAccessible->getAccessibleContext() );
+                    if ( xParentAC.is() && (css::accessibility::AccessibleRole::COMBO_BOX == xParentAC->getAccessibleRole()) )
+                    {
+                        // O.k. - this is a combo box floating window corresponding to the child of role LIST of the parent.
+                        // Let's not rely on a specific child order, just search for the child with the role LIST
+                        sal_Int32 nCount = xParentAC->getAccessibleChildCount();
+                        for ( sal_Int32 n = 0; (n < nCount) && !xAccessible.is(); n++)
+                        {
+                            css::uno::Reference< css::accessibility::XAccessible > xChild = xParentAC->getAccessibleChild(n);
+                            if ( xChild.is() )
+                            {
+                                css::uno::Reference< css::accessibility::XAccessibleContext > xChildAC = xChild->getAccessibleContext();
+                                if ( xChildAC.is() && (css::accessibility::AccessibleRole::LIST == xChildAC->getAccessibleRole()) )
+                                {
+                                    xAccessible = xChild;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            catch (::com::sun::star::uno::RuntimeException e)
+            {
+                // Ignore show events that throw DisposedExceptions in getAccessibleContext(),
+                // but keep revoking these windows in hide(s).
+                if (bShow)
+                    return;
+            }
+        }
+
+        // We have to rely on the fact that Window::GetAccessible()->getAccessibleContext() returns a valid XAccessibleContext
+        // also for other menus than menubar or toplevel popup window. Otherwise we had to traverse the hierarchy to find the 
+        // context object to this menu floater. This makes the call to Window->IsMenuFloatingWindow() obsolete.
+        if ( ! xAccessible.is() )
+            xAccessible = pWindow->GetAccessible();
+
+		if ( xAccessible.is() && g_acc_manager1 )
+        {
+			g_acc_manager1->handleWindowOpened( (long)(xAccessible.get()));
+        }
+    }
+}
+
+void AccessBridgeupdateOldTopWindows()
+{
+	USHORT nTopWindowCount = (USHORT)Application::GetTopWindowCount();
+	for (USHORT i = 0; i < nTopWindowCount; i++)
+	{
+		Window* pTopWindow = Application::GetTopWindow( i );
+        css::uno::Reference< css::accessibility::XAccessible > xAccessible = pTopWindow->GetAccessible();
+        if ( xAccessible.is() )
+        {
+			css::uno::Reference< css::accessibility::XAccessibleContext > xAC(xAccessible->getAccessibleContext());
+            if ( xAC.is())
+            {
+            	short role = xAC->getAccessibleRole();
+            	if(xAC->getAccessibleName().getLength() > 0)
+					AccessBridgehandleExistingWindow(pTopWindow, true);
+            }
+        }
+	}
+}
+#endif
+//-----IAccessibility2 Implementation 2009
 
 bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
 {
         ImplSVData* pSVData = ImplGetSVData();
         if( ! pSVData->mxAccessBridge.is() )
         {
-            css::uno::Reference< XMultiServiceFactory > xFactory(vcl::unohelper::GetMultiServiceFactory());
+            css::uno::Reference< css::lang::XMultiServiceFactory > xFactory(vcl::unohelper::GetMultiServiceFactory());
 
             if( xFactory.is() )
             {
-                css::uno::Reference< XExtendedToolkit > xToolkit = 
-                    css::uno::Reference< XExtendedToolkit >(Application::GetVCLToolkit(), UNO_QUERY);
+//IAccessibility2 Implementation 2009-----
+                #ifdef WNT
+                pSVData->mxAccessBridge = xFactory->createInstance(
+			               OUString::createFromAscii( "com.sun.star.accessibility.MSAAService" ) ); 
+			    if( pSVData->mxAccessBridge.is() )
+			    {
+			    	css::uno::Reference< css::uno::XInterface > pRManager= pSVData->mxAccessBridge;
+			    	g_acc_manager1 = (css::accessibility::XMSAAService*)(pRManager.get());
+					AccessBridgeupdateOldTopWindows();
+			    }
+			    
+			    if( !pSVData->mxAccessBridge.is() )
+                    bSuccess = false;
+                return bSuccess;
+			    #endif
+//-----IAccessibility2 Implementation 2009
+                css::uno::Reference< css::awt::XExtendedToolkit > xToolkit = 
+                    css::uno::Reference< css::awt::XExtendedToolkit >(Application::GetVCLToolkit(), css::uno::UNO_QUERY);
 
-                Sequence< Any > arguments(1);
+                css::uno::Sequence< css::uno::Any > arguments(1);
                 arguments[0] = makeAny(xToolkit);
 
 	            // Disable default java error messages on startup, because they were probably unreadable

vcl/source/app/svmain.cxx

 #include <process.h>    // for _beginthreadex
 #include <ole2.h>   // for _beginthreadex
 #include <tools/postwin.h>
+//IAccessibility2 Implementation 2009-----
+#include <com/sun/star/accessibility/XMSAAService.hpp>
+#include <g_msaasvc.h>
+using namespace com::sun::star::accessibility;
+//-----IAccessibility2 Implementation 2009
 #endif
 
 // [ed 5/14/02 Add in explicit check for quartz graphics.  OS X will define
 	}
 
     DeInitVCL();
+//IAccessibility2 Implementation 2009-----
+	#ifdef WNT
+		if( g_acc_manager1 )
+			g_acc_manager1->release();
+	#endif 
+//-----IAccessibility2 Implementation 2009
     return bInit;
 }
 

vcl/win/inc/salframe.h

     sal_Bool                    mbAtCursorIME;          // TRUE: Wir behandeln nur einige IME-Messages
     sal_Bool                    mbCandidateMode;        // TRUE: Wir befinden uns im Candidate-Modus
     static sal_Bool             mbInReparent;           // TRUE: ignore focus lost and gain due to reparenting
+//IAccessibility2 Implementation 2009-----
+	HWND					mhOnSetTitleWnd;
     
     RGNDATA*                mpClipRgnData;
     RECT*                   mpNextClipRect;

vcl/win/source/window/salframe.cxx

 using ::std::max;
 #endif
 
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+#include <oleacc.h>
+#include <com/sun/star/accessibility/XMSAAService.hpp>
+#ifndef _WIN32_WCE
+#define WM_GETOBJECT                    0x003D
+#endif
+#define     OBJID_WINDOW        ((LONG)0x00000000)
+#define     OBJID_SYSMENU       ((LONG)0xFFFFFFFF)
+#define     OBJID_TITLEBAR      ((LONG)0xFFFFFFFE)
+#define     OBJID_MENU          ((LONG)0xFFFFFFFD)
+#define     OBJID_CLIENT        ((LONG)0xFFFFFFFC)
+#define     OBJID_VSCROLL       ((LONG)0xFFFFFFFB)
+#define     OBJID_HSCROLL       ((LONG)0xFFFFFFFA)
+#define     OBJID_SIZEGRIP      ((LONG)0xFFFFFFF9)
+#define     OBJID_CARET         ((LONG)0xFFFFFFF8)
+#define     OBJID_CURSOR        ((LONG)0xFFFFFFF7)
+#define     OBJID_ALERT         ((LONG)0xFFFFFFF6)
+#define     OBJID_SOUND         ((LONG)0xFFFFFFF5)
+#define     OBJID_QUERYCLASSNAMEIDX ((LONG)0xFFFFFFF4)
+#define     OBJID_NATIVEOM      ((LONG)0xFFFFFFF0)
+#include <g_msaasvc.h>
+#endif
+//-----IAccessibility2 Implementation 2009
 #include <com/sun/star/uno/Exception.hdl>
 
 #include <time.h>
 #define Uni_SupplementaryPlanesStart    0x10000
 
 // =======================================================================
-
+//IAccessibility2 Implementation 2009-----
+#ifdef WNT
+using namespace ::com::sun::star::accessibility;
+XMSAAService* g_acc_manager1 = NULL;
+#endif
+//-----IAccessibility2 Implementation 2009
 static void UpdateFrameGeometry( HWND hWnd, WinSalFrame* pFrame );
 static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame, RECT* pParentRect = NULL );
 
     // insert frame in framelist
     mpNextFrame = pSalData->mpFirstFrame;
     pSalData->mpFirstFrame = this;
+// IAccessible2 implementation, 2009
+    mhOnSetTitleWnd=NULL;
 }
 
 // -----------------------------------------------------------------------
         case WM_IME_NOTIFY:
             ImplHandleIMENotify( hWnd, wParam );
             break;
+
+//IAccessibility2 implementation 2009-----
+#ifdef WNT
+		case WM_GETOBJECT:
+			{
+				if (!Application::IsEnableAccessInterface())
+				{
+					break;
+				}
+				else
+				{
+					//Sym2_2770, Make sure to launch Accessibiliity only the following criterias are satisfied to avoid RFT interrupts regular acc processing
+					if (g_acc_manager1 == NULL && 
+						Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() &&
+						IsBridgeRegistered() /* && HasAtHook() */ )
+					{
+						sal_Bool bCancelled;
+						InitAccessBridge(sal_False,bCancelled);
+						if( bCancelled )
+							break;
+					}
+					if (g_acc_manager1 != NULL)
+					{
+						BOOL bSkipSetTitleClient =FALSE;
+						SalFrame* pFrame = GetWindowPtr( hWnd );
+						if(pFrame)
+						{
+							bSkipSetTitleClient = (lParam == OBJID_CLIENT && hWnd == ((WinSalFrame*)pFrame)->mhOnSetTitleWnd);
+						}
+						
+						if ( (lParam == OBJID_CLIENT ) && !bSkipSetTitleClient )
+						{
+							long RetResult = g_acc_manager1->getAccObjectPtr((long)hWnd, lParam, wParam);
+							if(RetResult != 0)
+							{
+								rDef = FALSE;					
+								return (HRESULT)RetResult;
+							}
+						}
+					}
+				}
+				break;
+			}
+#endif			
+//-----IAccessibility2 implementation 2009
+
         case WM_APPCOMMAND:
             if( ImplHandleAppCommand( hWnd, lParam ) )
             {                
 
 // -----------------------------------------------------------------------
 
+//IAccessibility2 implementation 2009-----
+#ifdef WNT
+bool IsWNTInitAccessBridge()
+{
+	return NULL != g_acc_manager1;
+}
+#endif
+#ifdef WNT
+bool WNTEnableAccessInterface(bool bEnable)
+{
+    ImplSVData* pSVData = ImplGetSVData();
+
+	BOOL bPreVal = pSVData->maAppData.m_bEnableAccessInterface; 
+	long nEnable= bEnable;
+	::InterlockedExchange(
+		(LPLONG)&(pSVData->maAppData.m_bEnableAccessInterface),
+		nEnable);
+	
+	return bPreVal;
+}
+#endif
+//-----IAccessibility2 implementation 2009
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.