Avoid potential negative array index access to cached text.
[LibreOffice.git] / accessibility / inc / standard / accessiblemenubasecomponent.hxx
blob337ee0a80d00005df81525181e052d5dbc92bedc
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 <com/sun/star/accessibility/XAccessible.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/awt/Point.hpp>
25 #include <comphelper/accessiblecomponenthelper.hxx>
26 #include <cppuhelper/implbase.hxx>
27 #include <tools/link.hxx>
28 #include <vcl/vclptr.hxx>
30 #include <vector>
32 class Menu;
33 class VclSimpleEvent;
34 class VclMenuEvent;
36 class OAccessibleMenuItemComponent;
38 class OAccessibleMenuBaseComponent : public cppu::ImplInheritanceHelper<
39 comphelper::OAccessibleExtendedComponentHelper,
40 css::accessibility::XAccessible,
41 css::lang::XServiceInfo>
43 friend class OAccessibleMenuItemComponent;
44 friend class VCLXAccessibleMenuItem;
45 friend class VCLXAccessibleMenu;
47 protected:
48 typedef std::vector< rtl::Reference< OAccessibleMenuItemComponent > > AccessibleChildren;
50 AccessibleChildren m_aAccessibleChildren1;
51 VclPtr<Menu> m_pMenu;
53 bool m_bEnabled;
54 bool m_bFocused;
55 bool m_bVisible;
56 bool m_bSelected;
57 bool m_bChecked;
59 virtual bool IsEnabled();
60 virtual bool IsFocused();
61 virtual bool IsVisible();
62 virtual bool IsSelected();
63 virtual bool IsChecked();
65 void SetEnabled( bool bEnabled );
66 void SetFocused( bool bFocused );
67 void SetVisible( bool bVisible );
68 void SetSelected( bool bSelected );
69 void SetChecked( bool bChecked );
71 void UpdateEnabled( sal_Int32 i, bool bEnabled );
72 void UpdateFocused( sal_Int32 i, bool bFocused );
73 void UpdateVisible();
74 void UpdateSelected( sal_Int32 i, bool bSelected );
75 void UpdateChecked( sal_Int32 i, bool bChecked );
76 void UpdateAccessibleName( sal_Int32 i );
77 void UpdateItemRole(sal_Int32 i);
78 void UpdateItemText( sal_Int32 i );
80 sal_Int64 GetChildCount() const;
82 css::uno::Reference< css::accessibility::XAccessible > GetChild( sal_Int64 i );
83 css::uno::Reference< css::accessibility::XAccessible > GetChildAt( const css::awt::Point& rPoint );
85 void InsertChild( sal_Int32 i );
86 void RemoveChild( sal_Int32 i );
88 virtual bool IsHighlighted();
89 bool IsChildHighlighted();
91 virtual bool IsMenuHideDisabledEntries();
93 void SelectChild( sal_Int32 i );
94 void DeSelectAll();
95 bool IsChildSelected( sal_Int32 i );
97 virtual void Click();
98 virtual bool IsPopupMenuOpen();
100 DECL_LINK( MenuEventListener, VclMenuEvent&, void );
102 void ProcessMenuEvent( const VclMenuEvent& rVclMenuEvent );
104 virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) = 0;
106 // XComponent
107 virtual void SAL_CALL disposing() override;
109 public:
110 OAccessibleMenuBaseComponent( Menu* pMenu );
111 virtual ~OAccessibleMenuBaseComponent() override;
113 void SetStates();
115 // XServiceInfo
116 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
118 // XAccessible
119 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
121 // XAccessibleContext
122 virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */