1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
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/implbase2.hxx>
27 #include <tools/link.hxx>
28 #include <vcl/vclptr.hxx>
29 
30 #include <vector>
31 
32 class Menu;
33 class VclSimpleEvent;
34 class VclMenuEvent;
35 
36 namespace utl {
37 class AccessibleStateSetHelper;
38 }
39 
40 
41 
42 typedef ::cppu::ImplHelper2<
43     css::accessibility::XAccessible,
44     css::lang::XServiceInfo > OAccessibleMenuBaseComponent_BASE;
45 
46 class OAccessibleMenuBaseComponent : public comphelper::OAccessibleExtendedComponentHelper,
47                                      public OAccessibleMenuBaseComponent_BASE
48 {
49     friend class OAccessibleMenuItemComponent;
50     friend class VCLXAccessibleMenuItem;
51     friend class VCLXAccessibleMenu;
52 
53 protected:
54     typedef std::vector< css::uno::Reference< css::accessibility::XAccessible > > AccessibleChildren;
55 
56     AccessibleChildren      m_aAccessibleChildren;
57     VclPtr<Menu>            m_pMenu;
58 
59     bool                    m_bEnabled;
60     bool                    m_bFocused;
61     bool                    m_bVisible;
62     bool                    m_bSelected;
63     bool                    m_bChecked;
64 
65     virtual bool            IsEnabled();
66     virtual bool            IsFocused();
67     virtual bool            IsVisible();
68     virtual bool            IsSelected();
69     virtual bool            IsChecked();
70 
71     void                    SetEnabled( bool bEnabled );
72     void                    SetFocused( bool bFocused );
73     void                    SetVisible( bool bVisible );
74     void                    SetSelected( bool bSelected );
75     void                    SetChecked( bool bChecked );
76 
77     void                    UpdateEnabled( sal_Int32 i, bool bEnabled );
78     void                    UpdateFocused( sal_Int32 i, bool bFocused );
79     void                    UpdateVisible();
80     void                    UpdateSelected( sal_Int32 i, bool bSelected );
81     void                    UpdateChecked( sal_Int32 i, bool bChecked );
82     void                    UpdateAccessibleName( sal_Int32 i );
83     void                    UpdateItemText( sal_Int32 i );
84 
85     sal_Int32               GetChildCount() const;
86 
87     css::uno::Reference< css::accessibility::XAccessible > GetChild( sal_Int32 i );
88     css::uno::Reference< css::accessibility::XAccessible > GetChildAt( const css::awt::Point& rPoint );
89 
90     void                    InsertChild( sal_Int32 i );
91     void                    RemoveChild( sal_Int32 i );
92 
93     virtual bool        IsHighlighted();
94     bool                IsChildHighlighted();
95 
96     virtual bool        IsMenuHideDisabledEntries();
97 
98     void                    SelectChild( sal_Int32 i );
99     void                    DeSelectAll();
100     bool                IsChildSelected( sal_Int32 i );
101 
102     virtual void            Click();
103     virtual bool            IsPopupMenuOpen();
104 
105     DECL_LINK( MenuEventListener, VclMenuEvent&, void );
106 
107     void                    ProcessMenuEvent( const VclMenuEvent& rVclMenuEvent );
108 
109     virtual void            FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) = 0;
110 
111     // XComponent
112     virtual void SAL_CALL   disposing() override;
113 
114 public:
115     OAccessibleMenuBaseComponent( Menu* pMenu );
116     virtual ~OAccessibleMenuBaseComponent() override;
117 
118     void                    SetStates();
119 
120     // XInterface
121     DECLARE_XINTERFACE()
122 
123     // XTypeProvider
124     DECLARE_XTYPEPROVIDER()
125 
126     // XServiceInfo
127     virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
128 
129     // XAccessible
130     virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) override;
131 
132     // XAccessibleContext
133     virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) override;
134 };
135 
136 
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
138