diff options
-rw-r--r-- | winaccessibility/Library_uacccom.mk | 1 | ||||
-rw-r--r-- | winaccessibility/Library_winaccessibility.mk | 1 | ||||
-rw-r--r-- | winaccessibility/inc/UAccCOMdllapi.h | 24 | ||||
-rw-r--r-- | winaccessibility/inc/accHelper.hxx | 4 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccHypertext.cxx | 8 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/AccTable.cxx | 16 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/EnumVariant.cxx | 5 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/MAccessible.cxx | 73 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/UAccCOM.cxx | 9 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/acccommon.h | 6 | ||||
-rw-r--r-- | winaccessibility/source/service/AccObject.cxx | 18 |
11 files changed, 114 insertions, 51 deletions
diff --git a/winaccessibility/Library_uacccom.mk b/winaccessibility/Library_uacccom.mk index f481b404fe51..1592804125d8 100644 --- a/winaccessibility/Library_uacccom.mk +++ b/winaccessibility/Library_uacccom.mk @@ -20,6 +20,7 @@ $(eval $(call gb_Library_set_include,UAccCOM,\ )) $(eval $(call gb_Library_add_defs,UAccCOM,\ + -DUACCCOM_DLLIMPLEMENTATION \ -D_UNICODE=1 \ )) diff --git a/winaccessibility/Library_winaccessibility.mk b/winaccessibility/Library_winaccessibility.mk index 55057c39ddd6..45a86f3c917c 100644 --- a/winaccessibility/Library_winaccessibility.mk +++ b/winaccessibility/Library_winaccessibility.mk @@ -53,6 +53,7 @@ $(eval $(call gb_Library_use_externals,winaccessibility,\ )) $(eval $(call gb_Library_use_libraries,winaccessibility,\ + UAccCOM \ cppu \ cppuhelper \ vcl \ diff --git a/winaccessibility/inc/UAccCOMdllapi.h b/winaccessibility/inc/UAccCOMdllapi.h new file mode 100644 index 000000000000..aca29b6678be --- /dev/null +++ b/winaccessibility/inc/UAccCOMdllapi.h @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_UACCCOM_UACCCOMDLLAPI_H +#define INCLUDED_UACCCOM_UACCCOMDLLAPI_H + +#include <sal/types.h> + +#if defined(UACCCOM_DLLIMPLEMENTATION) +#define UACCCOM_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define UACCCOM_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define UACCCOM_DLLPRIVATE SAL_DLLPRIVATE + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/inc/accHelper.hxx b/winaccessibility/inc/accHelper.hxx index 772393a0768d..f0dd29bae440 100644 --- a/winaccessibility/inc/accHelper.hxx +++ b/winaccessibility/inc/accHelper.hxx @@ -20,6 +20,8 @@ #ifndef __ACCHELPER_HXX #define __ACCHELPER_HXX +#include <UAccCOMdllapi.h> + enum DIRECTION { FIRST_CHILD=0, @@ -30,6 +32,8 @@ enum DIRECTION #define UNO_MSAA_UNMAPPING 0x00000000 +struct IMAccessible; +UACCCOM_DLLPUBLIC IMAccessible * UAccCOMCreateInstance(); #endif diff --git a/winaccessibility/source/UAccCOM/AccHypertext.cxx b/winaccessibility/source/UAccCOM/AccHypertext.cxx index ae9e86a3afc4..4679440fbfba 100644 --- a/winaccessibility/source/UAccCOM/AccHypertext.cxx +++ b/winaccessibility/source/UAccCOM/AccHypertext.cxx @@ -20,6 +20,8 @@ #include "stdafx.h" #include "UAccCOM.h" #include "AccHypertext.h" +#include "AccHyperLink.h" +#include "acccommon.h" #include "act.hxx" @@ -325,11 +327,7 @@ STDMETHODIMP CAccHypertext::get_hyperlink(long index,IAccessibleHyperlink **hype } IAccessibleHyperlink* plink = NULL; - ActivateActContext(); - HRESULT hr = CoCreateInstance( CLSID_AccHyperLink, NULL, CLSCTX_SERVER , - IID_IAccessibleHyperlink, - (void **)&plink); - DeactivateActContext(); + HRESULT hr = createInstance<CAccHyperLink>(IID_IAccessibleHyperlink, &plink); if( SUCCEEDED(hr) ) { IUNOXWrapper* wrapper = NULL; diff --git a/winaccessibility/source/UAccCOM/AccTable.cxx b/winaccessibility/source/UAccCOM/AccTable.cxx index f3a1558e9f15..ab9b21847148 100644 --- a/winaccessibility/source/UAccCOM/AccTable.cxx +++ b/winaccessibility/source/UAccCOM/AccTable.cxx @@ -214,13 +214,7 @@ STDMETHODIMP CAccTable::get_columnHeader(IAccessibleTable __RPC_FAR *__RPC_FAR * *startingRowIndex = 0 ; IMAccessible* pIMacc = NULL; - ActivateActContext(); - HRESULT hr = CoCreateInstance( CLSID_MAccessible, NULL, CLSCTX_ALL , - IID_IMAccessible, - (void **)&pIMacc - ); - DeactivateActContext(); - + HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc); if (!SUCCEEDED(hr)) { return E_FAIL; @@ -448,13 +442,7 @@ STDMETHODIMP CAccTable::get_rowHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *acc *startingColumnIndex = 0 ; IMAccessible* pIMacc = NULL; - ActivateActContext(); - HRESULT hr = CoCreateInstance( CLSID_MAccessible, NULL, CLSCTX_ALL , - IID_IMAccessible, - (void **)&pIMacc - ); - DeactivateActContext(); - + HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc); if (!SUCCEEDED(hr)) { return E_FAIL; diff --git a/winaccessibility/source/UAccCOM/EnumVariant.cxx b/winaccessibility/source/UAccCOM/EnumVariant.cxx index f588dd2e7bb0..93ae9966310b 100644 --- a/winaccessibility/source/UAccCOM/EnumVariant.cxx +++ b/winaccessibility/source/UAccCOM/EnumVariant.cxx @@ -155,10 +155,7 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Clone(IEnumVARIANT __RPC_FAR *__RPC_FAR */ HRESULT STDMETHODCALLTYPE CEnumVariant::Create(CEnumVariant __RPC_FAR *__RPC_FAR *ppenum) { - ActivateActContext(); - HRESULT hr = CoCreateInstance(CLSID_EnumVariant,NULL, - CLSCTX_SERVER,IID_IEnumVariant,(void **)ppenum); - DeactivateActContext(); + HRESULT hr = createInstance<CEnumVariant>(IID_IEnumVariant, ppenum); if (S_OK != hr) { return E_FAIL; diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 642e77896c4b..12fe471cb9d5 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -23,6 +23,15 @@ #include <algorithm> #include "AccAction.h" +#include "AccRelation.h" +#include "AccComponent.h" +#include "AccText.h" +#include "AccEditableText.h" +#include "AccImage.h" +#include "AccTable.h" +#include "AccValue.h" +#include "AccHypertext.h" +#include "AccHyperLink.h" #include <com/sun/star/accessibility/XAccessibleText.hpp> #include <com/sun/star/accessibility/XAccessibleEditableText.hpp> @@ -1720,11 +1729,8 @@ STDMETHODIMP CMAccessible::get_relation( long relationIndex, IAccessibleRelation } IAccessibleRelation* pRelation = NULL; - ActivateActContext(); - HRESULT hr = CoCreateInstance( CLSID_AccRelation, NULL, CLSCTX_SERVER , - IID_IAccessibleRelation, - (void **)&pRelation); - DeactivateActContext(); + HRESULT hr = createInstance<CAccRelation>(IID_IAccessibleRelation, + &pRelation); if(SUCCEEDED(hr)) { IUNOXWrapper* wrapper = NULL; @@ -1784,11 +1790,8 @@ STDMETHODIMP CMAccessible::get_relations( long, IAccessibleRelation __RPC_FAR *_ for(int i=0; i<nCount ; i++) { IAccessibleRelation* pRelation = NULL; - ActivateActContext(); - HRESULT hr = CoCreateInstance( CLSID_AccRelation, NULL, CLSCTX_SERVER , - IID_IAccessibleRelation, - (void **)&pRelation); - DeactivateActContext(); + HRESULT hr = createInstance<CAccRelation>(IID_IAccessibleRelation, + &pRelation); if(SUCCEEDED(hr)) { IUNOXWrapper* wrapper = NULL; @@ -2557,7 +2560,18 @@ BOOL CMAccessible::GetXInterfaceFromXAccessible(XAccessible* pXAcc, XInterface** return FALSE; } -HRESULT WINAPI CMAccessible::SmartQI(void* pv, REFIID iid, void** ppvObject) +template<typename T> HRESULT +createAggInstance(CMAccessible &rOuter, REFIID iid, void ** ppvObject) +{ +// return CComCreator< CComAggObject<T> >::CreateInstance( +// XXX: do not use CComAggObject - the aggregation is hand-crafted! +// the SmartQI method must not call itself recursively - +// which it will do if CComAggObject redirects QueryInterface. + return CComCreator< CComObject<T> >::CreateInstance( + rOuter.GetControllingUnknown(), iid, ppvObject); +} + +HRESULT WINAPI CMAccessible::SmartQI(void* /*pv*/, REFIID iid, void** ppvObject) { ENTER_PROTECTED_BLOCK ISDESTROY() @@ -2589,9 +2603,40 @@ HRESULT WINAPI CMAccessible::SmartQI(void* pv, REFIID iid, void** ppvObject) } else { - ActivateActContext(); - HRESULT hr = pMap->pfnCreateInstance(pv, iid, ppvObject); - DeactivateActContext(); + HRESULT hr(REGDB_E_CLASSNOTREG); + switch (pMap->XIFIndex) + { + case XI_COMPONENT: + hr = createAggInstance<CAccComponent>(*this, iid, ppvObject); + break; + case XI_TEXT: + hr = createAggInstance<CAccText>(*this, iid, ppvObject); + break; + case XI_EDITABLETEXT: + hr = createAggInstance<CAccEditableText>(*this, iid, ppvObject); + break; + case XI_IMAGE: + hr = createAggInstance<CAccImage>(*this, iid, ppvObject); + break; + case XI_TABLE: + hr = createAggInstance<CAccTable>(*this, iid, ppvObject); + break; + case XI_ACTION: + hr = createAggInstance<CAccAction>(*this, iid, ppvObject); + break; + case XI_VALUE: + hr = createAggInstance<CAccValue>(*this, iid, ppvObject); + break; + case XI_HYPERTEXT: + hr = createAggInstance<CAccHypertext>(*this, iid, ppvObject); + break; + case XI_HYPERLINK: + hr = createAggInstance<CAccHyperLink>(*this, iid, ppvObject); + break; + default: + assert(false); + } + assert(hr == S_OK); if(hr == S_OK) { m_containedObjects.insert(XGUIDToComObjHash::value_type(*pMap->piid,(IUnknown*)*ppvObject)); diff --git a/winaccessibility/source/UAccCOM/UAccCOM.cxx b/winaccessibility/source/UAccCOM/UAccCOM.cxx index 851464f058f9..2570d92041ca 100644 --- a/winaccessibility/source/UAccCOM/UAccCOM.cxx +++ b/winaccessibility/source/UAccCOM/UAccCOM.cxx @@ -21,6 +21,7 @@ #include "resource.h" #include <initguid.h> #include "UAccCOM.h" +#include <accHelper.hxx> #include "UAccCOM_i.c" #include "ia2_api_all_i.c" @@ -110,4 +111,12 @@ STDAPI DllUnregisterServer(void) return _Module.UnregisterServer(TRUE); } + +IMAccessible * UAccCOMCreateInstance() +{ + IMAccessible * pIMA = 0; + HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMA); + return (S_OK == hr) ? pIMA : 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/source/UAccCOM/acccommon.h b/winaccessibility/source/UAccCOM/acccommon.h index 61c876aa7e38..22112ad97eac 100644 --- a/winaccessibility/source/UAccCOM/acccommon.h +++ b/winaccessibility/source/UAccCOM/acccommon.h @@ -85,6 +85,12 @@ inline BOOL ImplIsEqualGUID(REFGUID rguid1, REFGUID rguid2) static DWORD GetMSAAStateFromUNO(short xState); +template<typename T, typename Ifc> HRESULT +createInstance(REFIID iid, Ifc ** ppIfc) +{ + return CComCreator< CComObject<T> >::CreateInstance(0, iid, (void**)ppIfc); +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index 365779b5a792..124d29b8f4f9 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -244,21 +244,11 @@ void AccObject::UpdateValidWindow() */ sal_Bool AccObject::ImplInitializeCreateObj() { - ActivateActContext(); - HRESULT hr = CoCreateInstance( CLSID_MAccessible, NULL, CLSCTX_ALL, - IID_IMAccessible, - (void **)&m_pIMAcc); - SAL_WARN_IF( - m_pIMAcc == 0, "iacc2", - "Failed to create IAccessible2 instance: 0x" << std::hex << hr); - DeactivateActContext(); - - if ( S_OK != hr ) - { - return sal_False; - } + m_pIMAcc = UAccCOMCreateInstance(); - return sal_True; + assert(m_pIMAcc); + + return m_pIMAcc != 0; } /** |