[Libreoffice-commits] core.git: Branch 'feature/ia2.4' - vcl/source winaccessibility/source

Michael Meeks michael.meeks at collabora.com
Mon Nov 18 12:47:34 PST 2013


 vcl/source/app/svdata.cxx                            |   10 +
 winaccessibility/source/service/msaaservice_impl.cxx |  144 ++++++-------------
 2 files changed, 59 insertions(+), 95 deletions(-)

New commits:
commit ab9710c4a2c0e42d8e3219d21e2f7a92b1f19b76
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 18 20:46:56 2013 +0000

    uia: cleanup msa service info and implement XComponent.
    
    Change-Id: I00d19949a67147ef077bd92abc09ca8e8cf9a661

diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 521b07c..0423b68 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -321,13 +321,19 @@ bool ImplInitAccessBridge(bool bAllowCancel, bool &rCancelled)
         {
             css::uno::Reference< XComponentContext > xContext(comphelper::getProcessComponentContext());
 
-            // Windows only but safe here
-            if ( !getenv ("SAL_DISABLE_IACCESSIBLE2") )
+            bool bTryIAcc2 = ( officecfg::Office::Common::Misc::ExperimentalMode::get( xContext ) &&
+                               !getenv ("SAL_DISABLE_IACCESSIBLE2") );
+
+            if ( bTryIAcc2 ) // Windows only really
             {
                 // FIXME: convert to service ... pSVData->mxAccessBridge = css::accessibility::MSAAService::create( xContext );
                 pSVData->mxAccessBridge = Reference< XComponent >( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.accessibility.MSAAService", xContext ), UNO_QUERY );
+
+                SAL_INFO( "vcl", "IAccessible2 bridge is: " << (int)(pSVData->mxAccessBridge.is()) );
                 return pSVData->mxAccessBridge.is();
             }
+            else
+                SAL_INFO( "vcl", "IAccessible2 disabled, falling back to java" );
 
             css::uno::Reference< XExtendedToolkit > xToolkit =
                 css::uno::Reference< XExtendedToolkit >(Application::GetVCLToolkit(), UNO_QUERY);
diff --git a/winaccessibility/source/service/msaaservice_impl.cxx b/winaccessibility/source/service/msaaservice_impl.cxx
index 99b6728..b96a86d 100755
--- a/winaccessibility/source/service/msaaservice_impl.cxx
+++ b/winaccessibility/source/service/msaaservice_impl.cxx
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase4.hxx>
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/implementationentry.hxx>
 
@@ -51,78 +51,47 @@ extern void handleWindowOpened_impl( long pAcc);
 namespace my_sc_impl
 {
 
-/**
- * Method that returns the service name.
- * @param
- * @return Name sequence.
- */
 static Sequence< OUString > getSupportedServiceNames_MSAAServiceImpl()
 {
-    static Sequence < OUString > *pNames = 0;
-    if( ! pNames )
-    {
-        //      MutexGuard guard( Mutex::getGlobalMutex() );
-        if( !pNames )
-        {
-            static Sequence< OUString > seqNames(1);
-            seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.MSAAService"));
-            pNames = &seqNames;
-        }
-    }
-    return *pNames;
+    Sequence< OUString > seqNames(1);
+    seqNames.getArray()[0] = "com.sun.star.accessibility.MSAAService";
+    return seqNames;
 }
 
-/**
-   * Method that returns the service name.
-   * @param
-   * @return Name sequence.
-   */
 static OUString getImplementationName_MSAAServiceImpl()
 {
-    static OUString *pImplName = 0;
-    if( ! pImplName )
-    {
-        //      MutexGuard guard( Mutex::getGlobalMutex() );
-        if( ! pImplName )
-        {
-            static OUString implName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.my_sc_implementation.MSAAService") );
-            pImplName = &implName;
-        }
-    }
-    return *pImplName;
+    return OUString( "com.sun.star.accessibility.my_sc_implementation.MSAAService" );
 }
 
-class MSAAServiceImpl : public ::cppu::WeakImplHelper3<
-            XMSAAService, lang::XServiceInfo, lang::XInitialization >
+class MSAAServiceImpl : public ::cppu::WeakImplHelper4<
+            XMSAAService, lang::XServiceInfo,
+            lang::XInitialization, lang::XComponent >
 {
     OUString m_arg;
 public:
-    // focus on three given interfaces,
-    // no need to implement XInterface, XTypeProvider, XWeak
+    // focus on four interfaces,
+    // no need to implement XInterface, XTypeProvider, XWeak etc.
     MSAAServiceImpl ();
     virtual ~MSAAServiceImpl( void );
+
     // XInitialization will be called upon createInstanceWithArguments[AndContext]()
-    virtual void SAL_CALL initialize( Sequence< Any > const & args )
-    throw (Exception);
+    virtual void SAL_CALL initialize( Sequence< Any > const & args ) throw (Exception);
+
+    // XComponent - as used by VCL to lifecycle manage this bridge.
+    virtual void SAL_CALL dispose();
+    virtual void SAL_CALL addEventListener( const ::css::uno::Reference< ::css::lang::XEventListener >& xListener )    { /* dummy */ }
+    virtual void SAL_CALL removeEventListener( const ::css::uno::Reference< ::css::lang::XEventListener >& aListener ) { /* dummy */ }
+
     // XMSAAService
-    virtual sal_Int32 SAL_CALL getAccObjectPtr (long hWnd, long lParam, long wParam)
-    throw (RuntimeException);
-    virtual void SAL_CALL handleWindowOpened(sal_Int32)
-    throw (RuntimeException);
+    virtual sal_Int32 SAL_CALL getAccObjectPtr (long hWnd, long lParam, long wParam);
+    virtual void SAL_CALL handleWindowOpened(sal_Int32);
+
     // XServiceInfo
-    virtual OUString SAL_CALL getImplementationName()
-    throw (RuntimeException);
-    virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName )
-    throw (RuntimeException);
-    virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
-    throw (RuntimeException);
+    virtual OUString SAL_CALL getImplementationName();
+    virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName );
+    virtual Sequence< OUString > SAL_CALL getSupportedServiceNames();
 };
 
-/**
-   * Implemention of XInitialization.
-   * @param
-   * @return.
-   */
 void MSAAServiceImpl::initialize( Sequence< Any > const & args ) throw (Exception)
 {
     if (1 != args.getLength())
@@ -148,29 +117,23 @@ void MSAAServiceImpl::initialize( Sequence< Any > const & args ) throw (Exceptio
    */
 sal_Int32 MSAAServiceImpl::getAccObjectPtr ( long hWnd, long lParam, long wParam) throw (RuntimeException)
 {
-    return GetMSComPtr(hWnd, lParam, wParam);
+    return GetMSComPtr( hWnd, lParam, wParam );
 }
 
 /**
-   * Implemention of handleWindowOpened,the method will be invoked when a top window
-   * opened and AT starts up.
+   * Implemention of handleWindowOpened, the method will be invoked when a
+   * top window is opened and AT starts up.
    * @param
    * @return
    */
 void MSAAServiceImpl::handleWindowOpened( sal_Int32 pAcc)
 {
-    handleWindowOpened_impl(pAcc);
+    handleWindowOpened_impl( pAcc );
 }
 
-/**
-   * Implemention of XServiceInfo.
-   * @param
-   * @return Implementataion name.
-   */
 OUString MSAAServiceImpl::getImplementationName() throw (RuntimeException)
 {
-    // unique implementation name
-    return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.my_sc_impl.MSAAService") );
+    return OUString( "com.sun.star.accessibility.my_sc_impl.MSAAService" );
 }
 
 /**
@@ -181,7 +144,7 @@ OUString MSAAServiceImpl::getImplementationName() throw (RuntimeException)
 sal_Bool MSAAServiceImpl::supportsService( OUString const & serviceName ) throw (RuntimeException)
 {
     // this object only supports one service, so the test is simple
-    return serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.accessibility.MSAAService") );
+    return serviceName == "com.sun.star.accessibility.MSAAService";
 }
 
 /**
@@ -277,7 +240,7 @@ void AccessBridgeUpdateOldTopWindows( const Reference< XMSAAService > &xAccMgr )
     }
 }
 
-sal_Bool HasAtHook()
+static bool HasAtHook()
 {
     sal_Int32 bIsRuning=0;
     // BOOL WINAPI SystemParametersInfo(
@@ -288,39 +251,37 @@ sal_Bool HasAtHook()
     //  );
     // 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;
+    return SystemParametersInfo( SPI_GETSCREENREADER, 0,
+                                 &bIsRuning, 0) && bIsRuning;
 }
 
 /**
-   * Static method that can create an entity of our MSAA Service
-   * @param xContext No use here.
-   * @return The object interface.
-   */
+ * Static method that can create an entity of our MSAA Service
+ * @param xContext No use here.
+ * @return The object interface.
+ */
 Reference< XInterface > SAL_CALL create_MSAAServiceImpl( Reference< XComponentContext > const & /*xContext*/ ) SAL_THROW( () )
 {
+    bool bRunWithoutAt = getenv("SAL_FORCE_IACCESSIBLE2");
+
     if ( !HasAtHook() )
     {
-        SAL_INFO("iacc2", "Apparently no running AT -> not enabling IAccessible2 integration");
-        return Reference< XMSAAService >();
+        if ( !bRunWithoutAt )
+        {
+            SAL_INFO("iacc2", "Apparently no running AT -> not enabling IAccessible2 integration");
+            return Reference< XMSAAService >();
+        }
     }
 
     Reference< XMSAAService > xAccMgr( new MSAAServiceImpl() );
 
     AccessBridgeUpdateOldTopWindows( xAccMgr );
 
+    SAL_INFO("iacc2", "Created new IAccessible2 service impl.");
+
     return xAccMgr;
 }
 
-/**
-   * Constructor.
-   * @param
-   * @return
-   */
 MSAAServiceImpl::MSAAServiceImpl()
 {
     Reference< XExtendedToolkit > xToolkit =
@@ -336,14 +297,12 @@ MSAAServiceImpl::MSAAServiceImpl()
     }
 }
 
-/**
-   * Static method that can create an entity of our MSAA Service
-   * @param Destructor
-   * @return
-   */
 MSAAServiceImpl::~MSAAServiceImpl()
 {
+}
 
+MSAAServiceImpl::dispose()
+{
     // As all folders and streams contain references to their parents,
     // we must remove these references so that they will be deleted when
     // the hash_map of the root folder is cleared, releasing all subfolders
@@ -351,8 +310,6 @@ MSAAServiceImpl::~MSAAServiceImpl()
     // released when this destructor completes, the folder tree should be
     // deleted fully (and automagically).
     FreeTopWindowListener();
-
-
 }
 
 }
@@ -364,7 +321,8 @@ static struct ::cppu::ImplementationEntry s_component_entries [] =
     {
         {
             create_MSAAServiceImpl, getImplementationName_MSAAServiceImpl,
-            getSupportedServiceNames_MSAAServiceImpl, ::cppu::createSingleComponentFactory,
+            getSupportedServiceNames_MSAAServiceImpl,
+            ::cppu::createSingleComponentFactory,
             0, 0
         },
         { 0, 0, 0, 0, 0, 0 }


More information about the Libreoffice-commits mailing list