Line data Source code
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 :
21 : #include "toolpaneldrawerpeer.hxx"
22 : #include "toolpaneldrawer.hxx"
23 :
24 : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
25 : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
26 :
27 : #include <tools/diagnose_ex.h>
28 : #include <toolkit/awt/vclxaccessiblecomponent.hxx>
29 : #include <unotools/accessiblestatesethelper.hxx>
30 : #include <vcl/vclevent.hxx>
31 : #include <vcl/svapp.hxx>
32 :
33 : //......................................................................................................................
34 : namespace svt
35 : {
36 : //......................................................................................................................
37 :
38 : /** === begin UNO using === **/
39 : using ::com::sun::star::uno::Reference;
40 : using ::com::sun::star::uno::XInterface;
41 : using ::com::sun::star::uno::UNO_QUERY;
42 : using ::com::sun::star::uno::UNO_QUERY_THROW;
43 : using ::com::sun::star::uno::UNO_SET_THROW;
44 : using ::com::sun::star::uno::Exception;
45 : using ::com::sun::star::uno::RuntimeException;
46 : using ::com::sun::star::uno::Any;
47 : using ::com::sun::star::uno::makeAny;
48 : using ::com::sun::star::uno::Sequence;
49 : using ::com::sun::star::uno::Type;
50 : using ::com::sun::star::accessibility::XAccessibleContext;
51 : /** === end UNO using === **/
52 : namespace AccessibleStateType = ::com::sun::star::accessibility::AccessibleStateType;
53 : namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId;
54 :
55 : //==================================================================================================================
56 : //= ToolPanelDrawerContext
57 : //==================================================================================================================
58 : class ToolPanelDrawerContext : public VCLXAccessibleComponent
59 : {
60 : public:
61 0 : ToolPanelDrawerContext( VCLXWindow& i_rWindow )
62 0 : :VCLXAccessibleComponent( &i_rWindow )
63 : {
64 0 : }
65 :
66 : virtual void ProcessWindowEvent( const VclWindowEvent& i_rVclWindowEvent );
67 : virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet );
68 :
69 : protected:
70 0 : ~ToolPanelDrawerContext()
71 0 : {
72 0 : }
73 : };
74 :
75 : //------------------------------------------------------------------------------------------------------------------
76 0 : void ToolPanelDrawerContext::ProcessWindowEvent( const VclWindowEvent& i_rVclWindowEvent )
77 : {
78 0 : VCLXAccessibleComponent::ProcessWindowEvent( i_rVclWindowEvent );
79 :
80 0 : switch ( i_rVclWindowEvent.GetId() )
81 : {
82 : case VCLEVENT_ITEM_EXPANDED:
83 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), makeAny( AccessibleStateType::EXPANDED ) );
84 0 : break;
85 : case VCLEVENT_ITEM_COLLAPSED:
86 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, makeAny( AccessibleStateType::EXPANDED ), Any() );
87 0 : break;
88 : }
89 0 : }
90 :
91 : //------------------------------------------------------------------------------------------------------------------
92 0 : void ToolPanelDrawerContext::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet )
93 : {
94 0 : VCLXAccessibleComponent::FillAccessibleStateSet( i_rStateSet );
95 0 : if ( !GetWindow() )
96 0 : return;
97 :
98 0 : i_rStateSet.AddState( AccessibleStateType::EXPANDABLE );
99 0 : i_rStateSet.AddState( AccessibleStateType::FOCUSABLE );
100 :
101 0 : const ToolPanelDrawer* pDrawer( dynamic_cast< const ToolPanelDrawer* > ( GetWindow() ) );
102 0 : ENSURE_OR_RETURN_VOID( pDrawer, "ToolPanelDrawerContext::FillAccessibleStateSet: illegal window!" );
103 0 : if ( pDrawer->IsExpanded() )
104 0 : i_rStateSet.AddState( AccessibleStateType::EXPANDED );
105 :
106 0 : if ( pDrawer->HasChildPathFocus() )
107 0 : i_rStateSet.AddState( AccessibleStateType::FOCUSED );
108 : }
109 :
110 : //==================================================================================================================
111 : //= ToolPanelDrawerPeer
112 : //==================================================================================================================
113 : //------------------------------------------------------------------------------------------------------------------
114 0 : ToolPanelDrawerPeer::ToolPanelDrawerPeer()
115 0 : :VCLXWindow()
116 : {
117 0 : }
118 :
119 : //------------------------------------------------------------------------------------------------------------------
120 0 : ToolPanelDrawerPeer::~ToolPanelDrawerPeer()
121 : {
122 0 : }
123 :
124 : //------------------------------------------------------------------------------------------------------------------
125 0 : Reference< XAccessibleContext > ToolPanelDrawerPeer::CreateAccessibleContext()
126 : {
127 0 : SolarMutexGuard aSolarGuard;
128 0 : return new ToolPanelDrawerContext( *this );
129 : }
130 :
131 : //......................................................................................................................
132 : } // namespace svt
133 : //......................................................................................................................
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|