fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / winaccessibility / source / UAccCOM / MAccessible.h
blobc02013f5d1f139e551729ac7088bf8663cbdbad6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_WINACCESSIBILITY_SOURCE_UACCCOM_MACCESSIBLE_H
21 #define INCLUDED_WINACCESSIBILITY_SOURCE_UACCCOM_MACCESSIBLE_H
23 #include "resource.h" // main symbols
24 #include <map>
25 #include <com/sun/star/accessibility/XAccessible.hpp>
26 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
27 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
28 #include <AccObjectManagerAgent.hxx>
29 #include "EnumVariant.h"
30 #include "acccommon.h"
31 #include <rtl/ustring.hxx>
33 #define OBJID_WINDOW ((LONG)0x00000000)
34 #define OBJID_SYSMENU ((LONG)0xFFFFFFFF)
35 #define OBJID_TITLEBAR ((LONG)0xFFFFFFFE)
36 #define OBJID_MENU ((LONG)0xFFFFFFFD)
37 #define OBJID_CLIENT ((LONG)0xFFFFFFFC)
38 #define OBJID_VSCROLL ((LONG)0xFFFFFFFB)
39 #define OBJID_HSCROLL ((LONG)0xFFFFFFFA)
40 #define OBJID_SIZEGRIP ((LONG)0xFFFFFFF9)
41 #define OBJID_CARET ((LONG)0xFFFFFFF8)
42 #define OBJID_CURSOR ((LONG)0xFFFFFFF7)
43 #define OBJID_ALERT ((LONG)0xFFFFFFF6)
44 #define OBJID_SOUND ((LONG)0xFFFFFFF5)
45 #define OBJID_QUERYCLASSNAMEIDX ((LONG)0xFFFFFFF4)
46 #define OBJID_NATIVEOM ((LONG)0xFFFFFFF0)
48 /**
49 *This class implements IMAccessible interface, which inherits from IAccessible2, and
50 *in turn inherits from IAccessible. So its methods include the methods defined only in
51 *IAccessible, plus the methods defined only in IAccessible2, plus the methods defined
52 *only in IMAccessible.
54 class ATL_NO_VTABLE CMAccessible :
55 public CComObjectRoot,
56 public CComCoClass<CMAccessible, &CLSID_MAccessible>,
57 public IDispatchImpl<IMAccessible, &IID_IMAccessible, &LIBID_UACCCOMLib>,
58 public IServiceProvider,
59 public IAccessibleApplication
61 typedef ::std::map<const GUID, CComPtr<IUnknown>, ltComp> XGUIDToComObjHash;
63 public:
64 CMAccessible();
65 virtual ~CMAccessible();
67 DECLARE_NO_REGISTRY()
69 DECLARE_GET_CONTROLLING_UNKNOWN()
71 DECLARE_PROTECT_FINAL_CONSTRUCT()
73 BEGIN_COM_MAP(CMAccessible)
74 COM_INTERFACE_ENTRY(IMAccessible)
75 COM_INTERFACE_ENTRY(IAccessible)
76 COM_INTERFACE_ENTRY(IAccessible2)
77 COM_INTERFACE_ENTRY(IDispatch)
78 COM_INTERFACE_ENTRY(IAccessibleApplication)
79 COM_INTERFACE_ENTRY(IServiceProvider)
80 COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,_SmartQI)
81 END_COM_MAP()
83 // IMAccessible
84 STDMETHOD(put_accValue)(VARIANT varChild,BSTR szValue);
85 STDMETHOD(put_accName)(VARIANT varChild,BSTR szName);
86 STDMETHOD(accDoDefaultAction)(VARIANT varChild);
87 STDMETHOD(accHitTest)(long xLeft,long yTop,VARIANT *pvarChild);
88 STDMETHOD(accNavigate)(long navDir,VARIANT varStart,VARIANT *pvarEndUpAt);
89 STDMETHOD(accLocation)(long *pxLeft,long *pyTop,long *pcxWidth,long *pcyHeight,VARIANT varChild);
90 STDMETHOD(accSelect)(long flagsSelect,VARIANT varChild);
91 STDMETHOD(get_accDefaultAction)( VARIANT varChild,BSTR *pszDefaultAction);
92 STDMETHOD(get_accSelection)(VARIANT *pvarChildren);
93 STDMETHOD(get_accFocus)(VARIANT *pvarChild);
94 STDMETHOD(get_accKeyboardShortcut)( VARIANT varChild,BSTR *pszKeyboardShortcut);
95 STDMETHOD(get_accHelpTopic)(BSTR *pszHelpFile,VARIANT varChild,long *pidTopic);
96 STDMETHOD(get_accHelp)(VARIANT varChild,BSTR *pszHelp);
97 STDMETHOD(get_accState)(VARIANT varChild,VARIANT *pvarState);
98 STDMETHOD(get_accRole)(VARIANT varChild,VARIANT *pvarRole);
99 STDMETHOD(get_accDescription)(VARIANT varChild,BSTR *pszDescription);
100 STDMETHOD(get_accValue)( VARIANT varChild,BSTR *pszValue);
101 STDMETHOD(get_accName)(VARIANT varChild,BSTR *pszName);
102 STDMETHOD(get_accChild)(VARIANT varChild,IDispatch **ppdispChild);
103 STDMETHOD(get_accChildCount)(long *pcountChildren);
104 STDMETHOD(get_accParent)( IDispatch **ppdispParent);
106 // methods which are defined only in the IAccessible2
107 // These methods only declare here, and their implementation bodies are empty now.
108 STDMETHOD(get_nRelations)( long __RPC_FAR *nRelations) ;
109 STDMETHOD(get_relation)( long relationIndex, IAccessibleRelation __RPC_FAR *__RPC_FAR *relation) ;
110 STDMETHOD(get_relations)( long maxRelations, IAccessibleRelation __RPC_FAR *__RPC_FAR *relation, long __RPC_FAR *nRelations) ;
111 STDMETHOD(role)(long __RPC_FAR *role);
112 STDMETHOD(get_nActions)(long __RPC_FAR *nActions);
113 STDMETHOD(scrollTo)(enum IA2ScrollType scrollType);
114 STDMETHOD(scrollToPoint)(enum IA2CoordinateType coordinateType, long x, long y);
115 STDMETHOD(get_groupPosition)(long __RPC_FAR *groupLevel,long __RPC_FAR *similarItemsInGroup,long __RPC_FAR *positionInGroup);
116 STDMETHOD(get_states)( AccessibleStates __RPC_FAR *states );
117 STDMETHOD(get_extendedRole)( BSTR __RPC_FAR *extendedRole );
118 STDMETHOD(get_localizedExtendedRole)( BSTR __RPC_FAR *localizedExtendedRole );
119 STDMETHOD(get_nExtendedStates)( long __RPC_FAR *nExtendedStates);
120 STDMETHOD(get_extendedStates)( long maxExtendedStates, BSTR __RPC_FAR *__RPC_FAR *extendedStates, long __RPC_FAR *nExtendedStates);
121 STDMETHOD(get_localizedExtendedStates)(long maxLocalizedExtendedStates,BSTR __RPC_FAR *__RPC_FAR *localizedExtendedStates,long __RPC_FAR *nLocalizedExtendedStates);
122 STDMETHOD(get_uniqueID)(long __RPC_FAR *uniqueID);
123 STDMETHOD(get_windowHandle)(HWND __RPC_FAR *windowHandle);
124 STDMETHOD(get_indexInParent)( long __RPC_FAR *accParentIndex );
125 STDMETHOD(get_locale)( IA2Locale __RPC_FAR *locale );
126 STDMETHOD(get_attributes)(/*[out]*/ BSTR *pAttr);
128 //IServiceProvider.
129 STDMETHOD(QueryService)(REFGUID guidService, REFIID riid, void** ppvObject);
131 //IAccessibleApplication
132 STDMETHOD(get_appName)(BSTR __RPC_FAR *name);
133 STDMETHOD(get_appVersion)(BSTR __RPC_FAR *version);
134 STDMETHOD(get_toolkitName)(BSTR __RPC_FAR *name);
135 STDMETHOD(get_toolkitVersion)(BSTR __RPC_FAR *version);
137 // methods which are defined only in IMAccessible
138 // These methods are provided for UNO management system.
139 // The UNO management system use these methods to put Accessibility
140 // information to COM.
141 STDMETHOD(Put_XAccName)(const OLECHAR __RPC_FAR *pszName);
142 STDMETHOD(Put_XAccRole)(unsigned short pRole);
143 STDMETHOD(DecreaseState)(DWORD pXSate);
144 STDMETHOD(IncreaseState)(DWORD pXSate);
145 STDMETHOD(SetState)(DWORD pXSate);
146 STDMETHOD(Put_XAccDescription)(const OLECHAR __RPC_FAR *pszDescription);
147 STDMETHOD(Put_XAccValue)(const OLECHAR __RPC_FAR *pszAccValue);
148 STDMETHOD(Put_XAccLocation)(const Location sLocation);
149 STDMETHOD(Put_XAccFocus)(long dChildID);
150 STDMETHOD(Put_XAccParent)(IMAccessible __RPC_FAR *pIParent);
151 STDMETHOD(Put_XAccWindowHandle)(HWND hwnd);
152 STDMETHOD(Put_XAccChildID)(long dChildID);
153 STDMETHOD(Put_XAccAgent)(hyper pAgent);
154 STDMETHOD(NotifyDestroy)(BOOL isDestroy);
155 STDMETHOD(Put_ActionDescription)( const OLECHAR* szAction);
156 STDMETHOD(SetDefaultAction)(hyper pAction);
157 STDMETHOD(GetUNOInterface)(hyper*);
158 STDMETHOD(SetXAccessible)(hyper);
160 private:
161 OLECHAR* m_pszName;
162 OLECHAR* m_pszValue;
163 OLECHAR* m_pszActionDescription;
164 unsigned short m_iRole;
165 DWORD m_dState;
166 OLECHAR* m_pszDescription;
167 IMAccessible* m_pIParent;
168 Location m_sLocation;
170 // identify a COM object/Acc object uniquely
171 long m_dChildID;
172 // specify the focus child ID in object self and its direct children
174 long m_dFocusChildID;
175 // parent window handle,will be used in the future application, its value comes from UNO
177 HWND m_hwnd;
179 // the COM class which implements IEnumVARIANT interface,currently only used in
180 // the implementation of get_accSelection
181 CEnumVariant* m_pEnumVar;
183 // specify if the XAccessible is invalid
184 BOOL m_isDestroy;
186 css::uno::Reference<css::accessibility::XAccessible> m_xAccessible;
187 // initially m_xAction and m_xContext are the same object
188 // but they may be different once AccObject::UpdateAction() is called?
189 css::uno::Reference<css::accessibility::XAccessibleAction> m_xAction;
190 css::uno::Reference<css::accessibility::XAccessibleContext> m_xContext;
192 private:
194 // the helper methods in order to implement the above public methods
195 IMAccessible* GetChildInterface(long dChildIndex);//notice here the parameter is child index,not child id
196 IMAccessible* GetNavigateChildForDM(VARIANT varCur,short flags);//for descendant manage
197 HRESULT GetFirstChild(VARIANT varStart,VARIANT* pvarEndUpAt);//for accNavigate implementation
198 HRESULT GetLastChild(VARIANT varStart,VARIANT* pvarEndUpAt);//for accNavigate implementation
199 HRESULT GetNextSibling(VARIANT varStart,VARIANT* pvarEndUpAt);//for accNavigate implementation
200 HRESULT GetPreSibling(VARIANT varStart,VARIANT* pvarEndUpAt);//for accNavigate implementation
201 BOOL IsDescendantManage();//identify whether the current COM belongs to manage_descendant roles
203 // the following private methods are used to implement accSelect method
204 HRESULT SelectChild(css::accessibility::XAccessible* pItem);
205 HRESULT DeSelectChild(css::accessibility::XAccessible* pItem);
206 HRESULT SelectMutipleChidren(css::accessibility::XAccessible** pItem,
207 int size);
208 HRESULT DeSelectMutipleChildren(css::accessibility::XAccessible** pItem,
209 int size);
210 css::accessibility::XAccessibleContext* GetContextByXAcc(
211 css::accessibility::XAccessible* pXAcc);
212 css::uno::Reference<css::accessibility::XAccessibleSelection> GetSelection();
213 // end accSelect implementation methods
214 BOOL GetXInterfaceFromXAccessible(css::accessibility::XAccessible*,
215 css::uno::XInterface**, int);
216 HRESULT WINAPI SmartQI(void* pv, REFIID iid, void** ppvObject);
218 public:
219 STDMETHOD(Get_XAccChildID)(/*[out,retval]*/ long* childID);
220 // AccObjectManagerAgent is a management object in UNO, here keep its pointer for
221 // the implementation of accNavigate when descendant manage happens for List,Tree, or Table
222 // AccObjectManagerAgent and the following UNO objects XAccessble,XAccessibleSelection,
223 // XAccessibleAction are all used to operate UNO accessiblility information directly when
224 // implement some specific MSAA methods,such as accSelection,accNavigate
225 static AccObjectManagerAgent* g_pAgent;
227 static BOOL get_IAccessibleFromXAccessible(
228 css::accessibility::XAccessible * pXAcc, IAccessible** ppIA);
229 BOOL m_bRequiresSave;
230 XGUIDToComObjHash m_containedObjects;
232 static HRESULT WINAPI _SmartQI(void* pv,
233 REFIID iid, void** ppvObject, DWORD_PTR)
235 return ((CMAccessible*)pv)->SmartQI(pv,iid,ppvObject);
238 static void get_OLECHARFromAny(css::uno::Any& pAny, OLECHAR* pChar);
240 static void get_OLECHAR4Numbering(const css::uno::Any& pAny,
241 short numberingLevel, const OUString& numberingPrefix,
242 OLECHAR* pChar);
244 // Helper function for data conversion.
245 static void ConvertAnyToVariant(const css::uno::Any &rAnyVal,
246 VARIANT *pvData);
251 #endif // INCLUDED_WINACCESSIBILITY_SOURCE_UACCCOM_MACCESSIBLE_H
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */