1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright IBM Corporation 2010.
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org.  If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #ifndef __ACCOBJECT_HXX
30 #define __ACCOBJECT_HXX
31 
32 #include <vector>
33 #include <map>
34 #include <oleacc.h>
35 #include <windows.h>
36 
37 #include <com/sun/star/accessibility/XAccessible.hpp>
38 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
39 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
40 
41 #include "accHelper.hxx"
42 #include  "UAccCOM.h"
43 
44 class AccEventListener;
45 class AccObjectManagerAgent;
46 class AccObject;
47 
48 typedef std::map< const long, AccObject*,ltstr4 > IAccSelectionList;
49 typedef std::vector<AccObject *> IAccChildList;
50 
51 
52 class AccObject
53 {
54 private:
55 
56     short				m_accRole;
57     long				m_resID;
58     HWND				m_pParantID;
59     sal_Bool				m_bShouldDestroy; //avoid access COM interface when acc object is deleted
60     IMAccessible*		m_pIMAcc;
61     AccObject*			m_pParentObj;
62     IAccChildList		m_childrenList;
63     AccEventListener*	m_accListener;
64     IAccSelectionList	m_selectionList;
65 
66     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > m_xAccRef;
67     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessibleAction > m_xAccActionRef;
68     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessibleContext > m_xAccContextRef;
69 
70     sal_Bool ImplInitilizeCreateObj();//create COM object
71 
72     void UpdateActionDesc();
73     void UpdateRole();
74 
75     DWORD GetMSAAStateFromUNO(short xState);//translate state from UNO to MSAA value
76     ::com::sun::star::accessibility::XAccessibleSelection* GetXAccessibleSelection();
77     void GetExpandedState(sal_Bool* isExpandable, sal_Bool* isExpanded);
78     ::rtl::OUString GetMAccessibleValueFromAny(::com::sun::star::uno::Any pAny);
79 
80 public:
81 
82     AccObject ( ::com::sun::star::accessibility::XAccessible* pXAcc = NULL,AccObjectManagerAgent* pAgent = NULL ,AccEventListener* accListener=NULL);
83     virtual ~AccObject();
84 
85     sal_Bool UpdateAccessibleInfoFromUnoToMSAA(  ); //implement accessible information mapping
86     void UpdateDefaultAction();
87 
88     IMAccessible*  GetIMAccessible();	//return COM interface in acc object
89     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > GetXAccessible();
90 
91     void SetResID(long id);//ResID means ChildID in MSAA
92     long GetResID();
93 
94 
95     void SetParentHWND(HWND hWnd);//need to set top window handle when send event to AT
96     HWND GetParentHWND();
97 
98     void SetListener( AccEventListener* Listener );
99     AccEventListener* getListener();
100 
101     void SetParentObj(AccObject* pParentAccObj);
102     AccObject* GetParentObj();
103 
104     void InsertChild( AccObject* pChild,short pos = LAST_CHILD);
105     void DeleteChild( AccObject* pChild );
106     AccObject* NextChild();
107 
108     void NotifyDestroy(sal_Bool ifDelete);
109     sal_Bool  ifShouldDestroy();
110 
111     void  DecreaseState(short xState );//call COM interface DecreaseState method
112     void  IncreaseState( short xState );//call COM interface IncreaseState method
113 
114     void  SetName( com::sun::star::uno::Any newName);
115     void  SetValue( com::sun::star::uno::Any pAny );
116     void  SetDescription( com::sun::star::uno::Any newDesc );
117     void  SetRole( short Role );
118 
119     short GetRole() const;
120 
121     void  UpdateState();
122     void  UpdateName();
123     void  UpdateValue();
124     void  UpdateAction();
125     void  UpdateDescription();
126     void  UpdateValidWindow();
127     void  UpdateLocation();
128 
129     void  setFocus();
130     void  unsetFocus();
131 
132     void  AddSelect(long index, AccObject* accObj);
133     IAccSelectionList& GetSelection();
134     void  setLocalizedResourceString();
135 };
136 
137 #endif
138