Avoid potential negative array index access to cached text.
[LibreOffice.git] / winaccessibility / inc / AccObject.hxx
blob65c8f5777331a885018db73e3e8f66ca26afa1b2
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 <vector>
23 #include <map>
24 #if !defined WIN32_LEAN_AND_MEAN
25 # define WIN32_LEAN_AND_MEAN
26 #endif
27 #include <windows.h>
28 #include <oleacc.h>
30 #include <rtl/ref.hxx>
32 #include <com/sun/star/accessibility/XAccessible.hpp>
33 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
34 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
36 #include "accHelper.hxx"
37 #include <UAccCOM.h>
39 class AccEventListener;
40 class AccObjectWinManager;
41 class AccObject;
43 typedef std::vector<AccObject *> IAccChildList;
46 class AccObject
48 private:
50 short m_accRole;
51 long m_resID;
52 HWND m_pParantID;
53 IMAccessible* const m_pIMAcc; // AccObjectManager::GetTopWindowIMAccessible relies on this being const
54 AccObject* m_pParentObj;
55 IAccChildList m_childrenList;
56 ::rtl::Reference<AccEventListener> m_pListener;
58 css::uno::Reference < css::accessibility::XAccessible > m_xAccRef;
59 css::uno::Reference < css::accessibility::XAccessibleAction > m_xAccActionRef;
60 css::uno::Reference < css::accessibility::XAccessibleContext > m_xAccContextRef;
62 void ImplInitializeCreateObj();//create COM object
64 void UpdateActionDesc();
65 void UpdateRole();
67 DWORD GetMSAAStateFromUNO(sal_Int64 xState);//translate state from UNO to MSAA value
68 css::accessibility::XAccessibleSelection* GetXAccessibleSelection();
69 void GetExpandedState(sal_Bool* isExpandable, sal_Bool* isExpanded);
70 OUString GetMAccessibleValueFromAny(css::uno::Any pAny);
72 public:
74 AccObject(css::accessibility::XAccessible* pXAcc = nullptr, AccObjectWinManager* pManager = nullptr,
75 AccEventListener* accListener=nullptr);
76 virtual ~AccObject();
78 bool UpdateAccessibleInfoFromUnoToMSAA( ); //implement accessible information mapping
79 void UpdateDefaultAction();
81 IMAccessible* GetIMAccessible(); //return COM interface in acc object
82 css::uno::Reference<css::accessibility::XAccessible> const& GetXAccessible();
84 void SetResID(long id);//ResID means ChildID in MSAA
85 long GetResID();
88 void SetParentHWND(HWND hWnd);//need to set top window handle when send event to AT
89 HWND GetParentHWND();
91 ::rtl::Reference<AccEventListener> SetListener(::rtl::Reference<AccEventListener> const& pListener);
92 AccEventListener* getListener();
94 void SetParentObj(AccObject* pParentAccObj);
95 AccObject* GetParentObj();
97 void InsertChild( AccObject* pChild,short pos = LAST_CHILD);
98 void DeleteChild( AccObject* pChild );
99 AccObject* NextChild();
101 void NotifyDestroy();
103 void DecreaseState( sal_Int64 xState );//call COM interface DecreaseState method
104 void IncreaseState( sal_Int64 xState );//call COM interface IncreaseState method
106 void SetName( css::uno::Any newName);
107 void SetValue( css::uno::Any pAny );
109 short GetRole() const;
111 void UpdateState();
112 void UpdateName();
113 void UpdateValue();
114 void UpdateAction();
115 void UpdateValidWindow();
117 void setFocus();
118 void unsetFocus();
120 void setLocalizedResourceString();
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */