tdf#117228: crash in SfxItemSet::GetItemState...
[LibreOffice.git] / winaccessibility / inc / AccObject.hxx
blobef83f343eaf390d5accdbaffa30663f63ddb4279
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 #ifndef INCLUDED_WINACCESSIBILITY_INC_ACCOBJECT_HXX
21 #define INCLUDED_WINACCESSIBILITY_INC_ACCOBJECT_HXX
23 #include <vector>
24 #include <map>
25 #if !defined WIN32_LEAN_AND_MEAN
26 # define WIN32_LEAN_AND_MEAN
27 #endif
28 #include <windows.h>
29 #include <oleacc.h>
31 #include <rtl/ref.hxx>
33 #include <com/sun/star/accessibility/XAccessible.hpp>
34 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
35 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
37 #include "accHelper.hxx"
39 #if defined __clang__
40 #pragma clang diagnostic push
41 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
42 #endif
43 #include <UAccCOM.h>
44 #if defined __clang__
45 #pragma clang diagnostic pop
46 #endif
48 class AccEventListener;
49 class AccObjectManagerAgent;
50 class AccObject;
52 typedef std::map<const long, AccObject*> IAccSelectionList;
53 typedef std::vector<AccObject *> IAccChildList;
56 class AccObject
58 private:
60 short m_accRole;
61 long m_resID;
62 HWND m_pParantID;
63 bool m_bShouldDestroy; //avoid access COM interface when acc object is deleted
64 IMAccessible* m_pIMAcc;
65 AccObject* m_pParentObj;
66 IAccChildList m_childrenList;
67 ::rtl::Reference<AccEventListener> m_pListener;
68 IAccSelectionList m_selectionList;
70 css::uno::Reference < css::accessibility::XAccessible > m_xAccRef;
71 css::uno::Reference < css::accessibility::XAccessibleAction > m_xAccActionRef;
72 css::uno::Reference < css::accessibility::XAccessibleContext > m_xAccContextRef;
74 void ImplInitializeCreateObj();//create COM object
76 void UpdateActionDesc();
77 void UpdateRole();
79 DWORD GetMSAAStateFromUNO(short xState);//translate state from UNO to MSAA value
80 css::accessibility::XAccessibleSelection* GetXAccessibleSelection();
81 void GetExpandedState(sal_Bool* isExpandable, sal_Bool* isExpanded);
82 ::rtl::OUString GetMAccessibleValueFromAny(css::uno::Any pAny);
84 public:
86 AccObject ( css::accessibility::XAccessible* pXAcc = nullptr,AccObjectManagerAgent* pAgent = nullptr ,AccEventListener* accListener=nullptr);
87 virtual ~AccObject();
89 bool UpdateAccessibleInfoFromUnoToMSAA( ); //implement accessible information mapping
90 void UpdateDefaultAction();
92 IMAccessible* GetIMAccessible(); //return COM interface in acc object
93 css::uno::Reference<css::accessibility::XAccessible> const& GetXAccessible();
95 void SetResID(long id);//ResID means ChildID in MSAA
96 long GetResID();
99 void SetParentHWND(HWND hWnd);//need to set top window handle when send event to AT
100 HWND GetParentHWND();
102 void SetListener(::rtl::Reference<AccEventListener> const& pListener);
103 AccEventListener* getListener();
105 void SetParentObj(AccObject* pParentAccObj);
106 AccObject* GetParentObj();
108 void InsertChild( AccObject* pChild,short pos = LAST_CHILD);
109 void DeleteChild( AccObject* pChild );
110 AccObject* NextChild();
112 void NotifyDestroy(bool ifDelete);
113 bool ifShouldDestroy();
115 void DecreaseState(short xState );//call COM interface DecreaseState method
116 void IncreaseState( short xState );//call COM interface IncreaseState method
118 void SetName( css::uno::Any newName);
119 void SetValue( css::uno::Any pAny );
120 void SetDescription( css::uno::Any newDesc );
121 void SetRole( short Role );
123 short GetRole() const;
125 void UpdateState();
126 void UpdateName();
127 void UpdateValue();
128 void UpdateAction();
129 void UpdateDescription();
130 void UpdateValidWindow();
131 void UpdateLocation();
133 void setFocus();
134 void unsetFocus();
136 void AddSelect(long index, AccObject* accObj);
137 IAccSelectionList& GetSelection();
138 void setLocalizedResourceString();
141 #endif // INCLUDED_WINACCESSIBILITY_INC_ACCOBJECT_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */