1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef __ACCOBJECT_HXX
23 #define __ACCOBJECT_HXX
24 
25 #include <vector>
26 #include <map>
27 #include <oleacc.h>
28 #include <windows.h>
29 
30 #include <com/sun/star/accessibility/XAccessible.hpp>
31 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
32 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
33 
34 #include "accHelper.hxx"
35 #include  "UAccCOM.h"
36 
37 class AccEventListener;
38 class AccObjectManagerAgent;
39 class AccObject;
40 
41 typedef std::map< const long, AccObject*,ltstr4 > IAccSelectionList;
42 typedef std::vector<AccObject *> IAccChildList;
43 
44 
45 class AccObject
46 {
47 private:
48 
49     short				m_accRole;
50     long				m_resID;
51     HWND				m_pParantID;
52     sal_Bool				m_bShouldDestroy; //avoid access COM interface when acc object is deleted
53     IMAccessible*		m_pIMAcc;
54     AccObject*			m_pParentObj;
55     IAccChildList		m_childrenList;
56     AccEventListener*	m_accListener;
57     IAccSelectionList	m_selectionList;
58 
59     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > m_xAccRef;
60     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessibleAction > m_xAccActionRef;
61     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessibleContext > m_xAccContextRef;
62 
63     sal_Bool ImplInitilizeCreateObj();//create COM object
64 
65     void UpdateActionDesc();
66     void UpdateRole();
67 
68     DWORD GetMSAAStateFromUNO(short xState);//translate state from UNO to MSAA value
69     ::com::sun::star::accessibility::XAccessibleSelection* GetXAccessibleSelection();
70     void GetExpandedState(sal_Bool* isExpandable, sal_Bool* isExpanded);
71     ::rtl::OUString GetMAccessibleValueFromAny(::com::sun::star::uno::Any pAny);
72 
73 public:
74 
75     AccObject ( ::com::sun::star::accessibility::XAccessible* pXAcc = NULL,AccObjectManagerAgent* pAgent = NULL ,AccEventListener* accListener=NULL);
76     virtual ~AccObject();
77 
78     sal_Bool UpdateAccessibleInfoFromUnoToMSAA(  ); //implement accessible information mapping
79     void UpdateDefaultAction();
80 
81     IMAccessible*  GetIMAccessible();	//return COM interface in acc object
82     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > GetXAccessible();
83 
84     void SetResID(long id);//ResID means ChildID in MSAA
85     long GetResID();
86 
87 
88     void SetParentHWND(HWND hWnd);//need to set top window handle when send event to AT
89     HWND GetParentHWND();
90 
91     void SetListener( AccEventListener* Listener );
92     AccEventListener* getListener();
93 
94     void SetParentObj(AccObject* pParentAccObj);
95     AccObject* GetParentObj();
96 
97     void InsertChild( AccObject* pChild,short pos = LAST_CHILD);
98     void DeleteChild( AccObject* pChild );
99     AccObject* NextChild();
100 
101     void NotifyDestroy(sal_Bool ifDelete);
102     sal_Bool  ifShouldDestroy();
103 
104     void  DecreaseState(short xState );//call COM interface DecreaseState method
105     void  IncreaseState( short xState );//call COM interface IncreaseState method
106 
107     void  SetName( com::sun::star::uno::Any newName);
108     void  SetValue( com::sun::star::uno::Any pAny );
109     void  SetDescription( com::sun::star::uno::Any newDesc );
110     void  SetRole( short Role );
111 
112     short GetRole() const;
113 
114     void  UpdateState();
115     void  UpdateName();
116     void  UpdateValue();
117     void  UpdateAction();
118     void  UpdateDescription();
119     void  UpdateValidWindow();
120     void  UpdateLocation();
121 
122     void  setFocus();
123     void  unsetFocus();
124 
125     void  AddSelect(long index, AccObject* accObj);
126     IAccSelectionList& GetSelection();
127     void  setLocalizedResourceString();
128 };
129 
130 #endif
131