Avoid potential negative array index access to cached text.
[LibreOffice.git] / winaccessibility / inc / AccObjectWinManager.hxx
blob024a58fc8655685799029976a96867cb8229adff
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 #pragma once
22 #include <map>
23 #include <mutex>
25 #if !defined WIN32_LEAN_AND_MEAN
26 # define WIN32_LEAN_AND_MEAN
27 #endif
28 #include <prewin.h>
29 #include <windows.h>
30 #include <postwin.h>
31 #include <rtl/ref.hxx>
32 #include "ResIDGenerator.hxx"
33 #include <UAccCOM.h>
35 namespace com::sun::star::accessibility {
36 class XAccessible;
38 class ResIDGenerator;
39 class AccEventListener;
40 class AccObject;
41 enum class UnoMSAAEvent;
43 /*******************************************************************
44 AccObjectWinManager complete the functions:
45 1. Insert, delete,query,update Acc objects
46 2. Create, delete,fire AccEventLister, the lifecycle of AccEventListener is as same as
47 Acc Object
48 3.Return COM interface for AT,by the call back in salframe
49 4.Pass accessible information to Acc objects
50 *******************************************************************/
51 class AccObjectWinManager
53 private:
54 typedef std::map<com::sun::star::accessibility::XAccessible*, AccObject> XIdToAccObjHash;
55 typedef std::map<HWND, com::sun::star::accessibility::XAccessible*> XHWNDToXAccHash;
56 typedef std::map<const long, AccObject*> XResIdToAccObjHash;
58 typedef std::map<const HWND, css::accessibility::XAccessible* >
59 XHWNDToDocumentHash;
61 // guard any access to XIdAccList and HwndXAcc
62 std::recursive_mutex m_Mutex;
64 //XAccessible to AccObject
65 XIdToAccObjHash XIdAccList;
67 //HWND to All XAccessible pointer
68 XHWNDToXAccHash HwndXAcc;
70 //id_Child to AccObject
71 XResIdToAccObjHash XResIdAccList;
73 //for file name support
74 XHWNDToDocumentHash XHWNDDocList;
76 css::accessibility::XAccessible* oldFocus;
78 ResIDGenerator ResIdGen;
80 private:
81 long ImpleGenerateResID();
82 AccObject* GetAccObjByXAcc( css::accessibility::XAccessible* pXAcc);
84 IMAccessible* GetTopWindowIMAccessible(HWND hWnd);
86 css::accessibility::XAccessible* GetAccDocByHWND(HWND hWnd);
88 static rtl::Reference<AccEventListener> DeleteAccListener(AccObject* pAccObj);
89 static void InsertAccChildNode(AccObject* pCurObj,AccObject* pParentObj,HWND pWnd);
90 static void DeleteAccChildNode(AccObject* pChild);
91 void DeleteFromHwndXAcc(css::accessibility::XAccessible const * pXAcc );
93 ::rtl::Reference<AccEventListener> CreateAccEventListener(
94 css::accessibility::XAccessible* pXAcc);
95 public:
96 AccObjectWinManager();
97 virtual ~AccObjectWinManager();
98 virtual bool InsertAccObj(css::accessibility::XAccessible* pXAcc,
99 css::accessibility::XAccessible* pParentXAcc,
100 HWND pWnd = nullptr);
101 bool InsertChildrenAccObj( css::accessibility::XAccessible* pXAcc,HWND pWnd=nullptr);
102 void DeleteAccObj( css::accessibility::XAccessible* pXAcc );
103 void DeleteChildrenAccObj(css::accessibility::XAccessible* pAccObj);
105 bool NotifyAccEvent(css::accessibility::XAccessible* pXAcc, UnoMSAAEvent eEvent);
107 sal_Int64 Get_ToATInterface(sal_Int64 nHWnd, long lParam, WPARAM wParam);
109 void DecreaseState(css::accessibility::XAccessible* pXAcc, sal_Int64 nState);
110 void IncreaseState(css::accessibility::XAccessible* pXAcc, sal_Int64 nState);
111 void UpdateState( css::accessibility::XAccessible* pXAcc );
113 void SetValue( css::accessibility::XAccessible* pXAcc, css::uno::Any pAny );
114 void UpdateValue( css::accessibility::XAccessible* pXAcc );
116 void SetAccName( css::accessibility::XAccessible* pXAcc, css::uno::Any newName);
117 void UpdateAccName( css::accessibility::XAccessible* pXAcc );
119 void UpdateAccFocus( css::accessibility::XAccessible* newFocus );
120 void UpdateAction( css::accessibility::XAccessible* pXAcc );
122 static bool IsContainer( css::accessibility::XAccessible* pAccessible );
124 virtual IMAccessible* GetIAccessibleFromXAccessible(css::accessibility::XAccessible* pXAcc);
125 virtual IMAccessible* GetIAccessibleFromResID(long resID);
127 void NotifyDestroy( css::accessibility::XAccessible* pXAcc );
128 css::accessibility::XAccessible* GetParentXAccessible( css::accessibility::XAccessible* pXAcc );
129 short GetParentRole( css::accessibility::XAccessible* pXAcc );
131 void SaveTopWindowHandle(HWND hWnd, css::accessibility::XAccessible* pXAcc);
133 void UpdateChildState(css::accessibility::XAccessible* pXAcc);
135 bool IsSpecialToolbarItem(css::accessibility::XAccessible* pXAcc);
137 static short GetRole(css::accessibility::XAccessible* pXAcc);
139 css::accessibility::XAccessible* GetAccDocByAccTopWin( css::accessibility::XAccessible* pXAcc );
140 bool IsTopWinAcc( css::accessibility::XAccessible* pXAcc );
142 static bool IsStateManageDescendant(css::accessibility::XAccessible* pAccessible);
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */