1*5fdc4257SSteve Yin /*************************************************************************
2*5fdc4257SSteve Yin  *
3*5fdc4257SSteve Yin  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*5fdc4257SSteve Yin  *
5*5fdc4257SSteve Yin  * Copyright IBM Corporation 2010.
6*5fdc4257SSteve Yin  * Copyright 2000, 2010 Oracle and/or its affiliates.
7*5fdc4257SSteve Yin  *
8*5fdc4257SSteve Yin  * OpenOffice.org - a multi-platform office productivity suite
9*5fdc4257SSteve Yin  *
10*5fdc4257SSteve Yin  * This file is part of OpenOffice.org.
11*5fdc4257SSteve Yin  *
12*5fdc4257SSteve Yin  * OpenOffice.org is free software: you can redistribute it and/or modify
13*5fdc4257SSteve Yin  * it under the terms of the GNU Lesser General Public License version 3
14*5fdc4257SSteve Yin  * only, as published by the Free Software Foundation.
15*5fdc4257SSteve Yin  *
16*5fdc4257SSteve Yin  * OpenOffice.org is distributed in the hope that it will be useful,
17*5fdc4257SSteve Yin  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18*5fdc4257SSteve Yin  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19*5fdc4257SSteve Yin  * GNU Lesser General Public License version 3 for more details
20*5fdc4257SSteve Yin  * (a copy is included in the LICENSE file that accompanied this code).
21*5fdc4257SSteve Yin  *
22*5fdc4257SSteve Yin  * You should have received a copy of the GNU Lesser General Public License
23*5fdc4257SSteve Yin  * version 3 along with OpenOffice.org.  If not, see
24*5fdc4257SSteve Yin  * <http://www.openoffice.org/license.html>
25*5fdc4257SSteve Yin  * for a copy of the LGPLv3 License.
26*5fdc4257SSteve Yin  *
27*5fdc4257SSteve Yin  ************************************************************************/
28*5fdc4257SSteve Yin 
29*5fdc4257SSteve Yin #ifndef __ACCOBJECTWINMANAGER_HXX
30*5fdc4257SSteve Yin #define __ACCOBJECTWINMANAGER_HXX
31*5fdc4257SSteve Yin 
32*5fdc4257SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_
33*5fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessible.hpp>
34*5fdc4257SSteve Yin #endif
35*5fdc4257SSteve Yin #include <map>
36*5fdc4257SSteve Yin #include <windows.h>
37*5fdc4257SSteve Yin #include <vos/mutex.hxx>
38*5fdc4257SSteve Yin #include "ResIDGenerator.hxx"
39*5fdc4257SSteve Yin #include "UAccCOM2.h"
40*5fdc4257SSteve Yin 
41*5fdc4257SSteve Yin class ResIDGenerator;
42*5fdc4257SSteve Yin class AccObjectManagerAgent;
43*5fdc4257SSteve Yin class AccEventListener;
44*5fdc4257SSteve Yin class AccObject;
45*5fdc4257SSteve Yin 
46*5fdc4257SSteve Yin /*******************************************************************
47*5fdc4257SSteve Yin AccObjectWinManager complete the functions:
48*5fdc4257SSteve Yin 1. Insert, delete,query,update Acc objects
49*5fdc4257SSteve Yin 2. Create, delete,fire AccEventLister, the lifecycle of AccEventListener is as same as
50*5fdc4257SSteve Yin    Acc Object
51*5fdc4257SSteve Yin  3.Return COM interface for AT,by the call back in salframe
52*5fdc4257SSteve Yin  4.Pass accessible information to Acc objects
53*5fdc4257SSteve Yin  *******************************************************************/
54*5fdc4257SSteve Yin class AccObjectWinManager
55*5fdc4257SSteve Yin {
56*5fdc4257SSteve Yin     friend class AccObjectManagerAgent;
57*5fdc4257SSteve Yin 
58*5fdc4257SSteve Yin private:
59*5fdc4257SSteve Yin     struct ltstr1
60*5fdc4257SSteve Yin     {
61*5fdc4257SSteve Yin         bool operator()(const void*  s1, const void*  s2) const
62*5fdc4257SSteve Yin         {
63*5fdc4257SSteve Yin             return long(s1)<long(s2);
64*5fdc4257SSteve Yin         }
65*5fdc4257SSteve Yin     };
66*5fdc4257SSteve Yin     struct ltstr2
67*5fdc4257SSteve Yin     {
68*5fdc4257SSteve Yin         bool operator()(const HWND  s1, const HWND  s2) const
69*5fdc4257SSteve Yin         {
70*5fdc4257SSteve Yin             return long(s1)<long(s2);
71*5fdc4257SSteve Yin         }
72*5fdc4257SSteve Yin     };
73*5fdc4257SSteve Yin     struct ltstr3
74*5fdc4257SSteve Yin     {
75*5fdc4257SSteve Yin         bool operator()(const long  s1, const long  s2) const
76*5fdc4257SSteve Yin         {
77*5fdc4257SSteve Yin             return long(s1)<long(s2);
78*5fdc4257SSteve Yin         }
79*5fdc4257SSteve Yin     };
80*5fdc4257SSteve Yin     typedef std::map< void*, AccObject,ltstr1 > XIdToAccObjHash;
81*5fdc4257SSteve Yin     typedef std::map< HWND,void*,ltstr2 > XHWNDToXAccHash;
82*5fdc4257SSteve Yin     typedef std::map< const long, AccObject*,ltstr3 > XResIdToAccObjHash;
83*5fdc4257SSteve Yin 
84*5fdc4257SSteve Yin     typedef std::map< const long, com::sun::star::accessibility::XAccessible*,ltstr3 > XHWNDToDocumentHash;
85*5fdc4257SSteve Yin 
86*5fdc4257SSteve Yin 
87*5fdc4257SSteve Yin     //XAccessible to AccObject
88*5fdc4257SSteve Yin     XIdToAccObjHash  XIdAccList;
89*5fdc4257SSteve Yin 
90*5fdc4257SSteve Yin     //HWND to All XAccessible pointer
91*5fdc4257SSteve Yin     XHWNDToXAccHash  HwndXAcc;
92*5fdc4257SSteve Yin 
93*5fdc4257SSteve Yin     //id_Child to AccObject
94*5fdc4257SSteve Yin     XResIdToAccObjHash XResIdAccList;
95*5fdc4257SSteve Yin 
96*5fdc4257SSteve Yin     //for file name support
97*5fdc4257SSteve Yin     XHWNDToDocumentHash XHWNDDocList;
98*5fdc4257SSteve Yin 
99*5fdc4257SSteve Yin     com::sun::star::accessibility::XAccessible* oldFocus;
100*5fdc4257SSteve Yin 
101*5fdc4257SSteve Yin     AccObjectManagerAgent*	 pAgent;
102*5fdc4257SSteve Yin     static AccObjectWinManager* me;
103*5fdc4257SSteve Yin     ResIDGenerator ResIdGen;
104*5fdc4257SSteve Yin     mutable ::vos::OMutex aDeleteMutex;
105*5fdc4257SSteve Yin     mutable ::vos::OMutex aNotifyMutex;
106*5fdc4257SSteve Yin     mutable ::vos::OMutex maATInterfaceMutex;
107*5fdc4257SSteve Yin 
108*5fdc4257SSteve Yin     AccObjectWinManager(AccObjectManagerAgent* Agent=NULL);
109*5fdc4257SSteve Yin 	bool m_bBridgeRegistered;
110*5fdc4257SSteve Yin 
111*5fdc4257SSteve Yin private:
112*5fdc4257SSteve Yin     long ImpleGenerateResID();
113*5fdc4257SSteve Yin     AccObject* GetAccObjByXAcc( com::sun::star::accessibility::XAccessible* pXAcc);
114*5fdc4257SSteve Yin 
115*5fdc4257SSteve Yin     com::sun::star::accessibility::XAccessible* GetXAccByAccObj(AccObject* pAccObj);
116*5fdc4257SSteve Yin 
117*5fdc4257SSteve Yin     AccObject* GetTopWindowAccObj(HWND hWnd);
118*5fdc4257SSteve Yin 
119*5fdc4257SSteve Yin     com::sun::star::accessibility::XAccessible* GetAccDocByHWND( long pWnd );
120*5fdc4257SSteve Yin 
121*5fdc4257SSteve Yin     void       DeleteAccListener( AccObject* pAccObj );
122*5fdc4257SSteve Yin     void       InsertAccChildNode(AccObject* pCurObj,AccObject* pParentObj,HWND pWnd);
123*5fdc4257SSteve Yin     void       DeleteAccChildNode(AccObject* pChild);
124*5fdc4257SSteve Yin     void       DeleteFromHwndXAcc(com::sun::star::accessibility::XAccessible* pXAcc );
125*5fdc4257SSteve Yin     int  UpdateAccSelection(com::sun::star::accessibility::XAccessible* pXAcc);
126*5fdc4257SSteve Yin 
127*5fdc4257SSteve Yin     AccEventListener* createAccEventListener(com::sun::star::accessibility::XAccessible* pXAcc, AccObjectManagerAgent* Agent);
128*5fdc4257SSteve Yin public:
129*5fdc4257SSteve Yin     virtual ~AccObjectWinManager();
130*5fdc4257SSteve Yin     sal_Bool InsertAccObj( com::sun::star::accessibility::XAccessible* pXAcc,com::sun::star::accessibility::XAccessible* pParentXAcc,HWND pWnd);
131*5fdc4257SSteve Yin     sal_Bool InsertChildrenAccObj( com::sun::star::accessibility::XAccessible* pXAcc,HWND pWnd=0);
132*5fdc4257SSteve Yin     void DeleteAccObj( com::sun::star::accessibility::XAccessible* pXAcc );
133*5fdc4257SSteve Yin     void DeleteChildrenAccObj(com::sun::star::accessibility::XAccessible* pAccObj);
134*5fdc4257SSteve Yin 
135*5fdc4257SSteve Yin public:
136*5fdc4257SSteve Yin     static  AccObjectWinManager* CreateAccObjectWinManagerInstance(AccObjectManagerAgent* Agent);
137*5fdc4257SSteve Yin 
138*5fdc4257SSteve Yin public:
139*5fdc4257SSteve Yin 
140*5fdc4257SSteve Yin     sal_Bool NotifyAccEvent( com::sun::star::accessibility::XAccessible* pXAcc,short state = 0 );
141*5fdc4257SSteve Yin 
142*5fdc4257SSteve Yin     long Get_ToATInterface( HWND hWnd, long lParam, long wParam);
143*5fdc4257SSteve Yin 
144*5fdc4257SSteve Yin     void  DecreaseState( com::sun::star::accessibility::XAccessible* pXAcc,unsigned short pState );
145*5fdc4257SSteve Yin     void  IncreaseState( com::sun::star::accessibility::XAccessible* pXAcc,unsigned short pState );
146*5fdc4257SSteve Yin     void  UpdateState( com::sun::star::accessibility::XAccessible* pXAcc );
147*5fdc4257SSteve Yin     void  SetLocation( com::sun::star::accessibility::XAccessible* pXAcc,
148*5fdc4257SSteve Yin                        long Top = 0,long left = 0,long width = 0,long height = 0);
149*5fdc4257SSteve Yin 
150*5fdc4257SSteve Yin     void  SetValue( com::sun::star::accessibility::XAccessible* pXAcc, com::sun::star::uno::Any pAny );
151*5fdc4257SSteve Yin     void  UpdateValue( com::sun::star::accessibility::XAccessible* pXAcc );
152*5fdc4257SSteve Yin 
153*5fdc4257SSteve Yin     void  SetAccName( com::sun::star::accessibility::XAccessible* pXAcc, com::sun::star::uno::Any newName);
154*5fdc4257SSteve Yin     void  UpdateAccName( com::sun::star::accessibility::XAccessible* pXAcc );
155*5fdc4257SSteve Yin 
156*5fdc4257SSteve Yin     void  SetDescription( com::sun::star::accessibility::XAccessible* pXAcc, com::sun::star::uno::Any newDesc );
157*5fdc4257SSteve Yin     void UpdateDescription( com::sun::star::accessibility::XAccessible* pXAcc );
158*5fdc4257SSteve Yin 
159*5fdc4257SSteve Yin     void  SetRole( com::sun::star::accessibility::XAccessible* pXAcc, long Role );
160*5fdc4257SSteve Yin 
161*5fdc4257SSteve Yin     void  UpdateAccFocus( com::sun::star::accessibility::XAccessible* newFocus );
162*5fdc4257SSteve Yin     void  UpdateAction( com::sun::star::accessibility::XAccessible* pXAcc );
163*5fdc4257SSteve Yin 
164*5fdc4257SSteve Yin     sal_Bool IsContainer( com::sun::star::accessibility::XAccessible* pAccessible );
165*5fdc4257SSteve Yin 
166*5fdc4257SSteve Yin     IMAccessible* GetIMAccByXAcc( com::sun::star::accessibility::XAccessible* pXAcc );
167*5fdc4257SSteve Yin     IMAccessible* GetIAccessibleFromResID(long resID);
168*5fdc4257SSteve Yin 
169*5fdc4257SSteve Yin     void NotifyDestroy( com::sun::star::accessibility::XAccessible* pXAcc );
170*5fdc4257SSteve Yin     com::sun::star::accessibility::XAccessible* GetParentXAccessible( com::sun::star::accessibility::XAccessible* pXAcc );
171*5fdc4257SSteve Yin     short GetParentRole( com::sun::star::accessibility::XAccessible* pXAcc );
172*5fdc4257SSteve Yin 
173*5fdc4257SSteve Yin     void SaveTopWindowHandle(HWND hWnd, com::sun::star::accessibility::XAccessible* pXAcc);
174*5fdc4257SSteve Yin 
175*5fdc4257SSteve Yin     void UpdateChildState(com::sun::star::accessibility::XAccessible* pXAcc);
176*5fdc4257SSteve Yin 
177*5fdc4257SSteve Yin     bool IsSpecialToolboItem(com::sun::star::accessibility::XAccessible* pXAcc);
178*5fdc4257SSteve Yin 
179*5fdc4257SSteve Yin     short GetRole(com::sun::star::accessibility::XAccessible* pXAcc);
180*5fdc4257SSteve Yin 
181*5fdc4257SSteve Yin     com::sun::star::accessibility::XAccessible* GetAccDocByAccTopWin( com::sun::star::accessibility::XAccessible* pXAcc );
182*5fdc4257SSteve Yin     bool IsTopWinAcc( com::sun::star::accessibility::XAccessible* pXAcc );
183*5fdc4257SSteve Yin 
184*5fdc4257SSteve Yin     bool IsStateManageDescendant(com::sun::star::accessibility::XAccessible* pAccessible);
185*5fdc4257SSteve Yin 
186*5fdc4257SSteve Yin };
187*5fdc4257SSteve Yin 
188*5fdc4257SSteve Yin #endif
189