1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "precompiled_svtools.hxx"
25 
26 #include "toolpaneldrawerpeer.hxx"
27 #include "toolpaneldrawer.hxx"
28 
29 /** === begin UNO includes === **/
30 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
31 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
32 /** === end UNO includes === **/
33 
34 #include <tools/diagnose_ex.h>
35 #include <toolkit/awt/vclxaccessiblecomponent.hxx>
36 #include <unotools/accessiblestatesethelper.hxx>
37 #include <vcl/vclevent.hxx>
38 
39 //......................................................................................................................
40 namespace svt
41 {
42 //......................................................................................................................
43 
44 	/** === begin UNO using === **/
45 	using ::com::sun::star::uno::Reference;
46 	using ::com::sun::star::uno::XInterface;
47 	using ::com::sun::star::uno::UNO_QUERY;
48 	using ::com::sun::star::uno::UNO_QUERY_THROW;
49 	using ::com::sun::star::uno::UNO_SET_THROW;
50 	using ::com::sun::star::uno::Exception;
51 	using ::com::sun::star::uno::RuntimeException;
52 	using ::com::sun::star::uno::Any;
53 	using ::com::sun::star::uno::makeAny;
54 	using ::com::sun::star::uno::Sequence;
55 	using ::com::sun::star::uno::Type;
56     using ::com::sun::star::accessibility::XAccessibleContext;
57 	/** === end UNO using === **/
58     namespace AccessibleStateType = ::com::sun::star::accessibility::AccessibleStateType;
59     namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId;
60 
61 	//==================================================================================================================
62 	//= ToolPanelDrawerContext
63 	//==================================================================================================================
64     class ToolPanelDrawerContext : public VCLXAccessibleComponent
65     {
66     public:
ToolPanelDrawerContext(VCLXWindow & i_rWindow)67         ToolPanelDrawerContext( VCLXWindow& i_rWindow )
68             :VCLXAccessibleComponent( &i_rWindow )
69         {
70         }
71 
72         virtual void	ProcessWindowEvent( const VclWindowEvent& i_rVclWindowEvent );
73         virtual void	FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet );
74 
75     protected:
~ToolPanelDrawerContext()76         ~ToolPanelDrawerContext()
77         {
78         }
79     };
80 
81 	//------------------------------------------------------------------------------------------------------------------
ProcessWindowEvent(const VclWindowEvent & i_rVclWindowEvent)82     void ToolPanelDrawerContext::ProcessWindowEvent( const VclWindowEvent& i_rVclWindowEvent )
83     {
84         VCLXAccessibleComponent::ProcessWindowEvent( i_rVclWindowEvent );
85 
86         switch ( i_rVclWindowEvent.GetId() )
87         {
88         case VCLEVENT_ITEM_EXPANDED:
89             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), makeAny( AccessibleStateType::EXPANDED ) );
90             break;
91         case VCLEVENT_ITEM_COLLAPSED:
92             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, makeAny( AccessibleStateType::EXPANDED ), Any() );
93             break;
94         }
95     }
96 
97 	//------------------------------------------------------------------------------------------------------------------
FillAccessibleStateSet(::utl::AccessibleStateSetHelper & i_rStateSet)98     void ToolPanelDrawerContext::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet )
99     {
100         VCLXAccessibleComponent::FillAccessibleStateSet( i_rStateSet );
101         if ( !GetWindow() )
102             return;
103 
104         i_rStateSet.AddState( AccessibleStateType::EXPANDABLE );
105         i_rStateSet.AddState( AccessibleStateType::FOCUSABLE );
106 
107         const ToolPanelDrawer* pDrawer( dynamic_cast< const ToolPanelDrawer* > ( GetWindow() ) );
108         ENSURE_OR_RETURN_VOID( pDrawer, "ToolPanelDrawerContext::FillAccessibleStateSet: illegal window!" );
109         if ( pDrawer->IsExpanded() )
110             i_rStateSet.AddState( AccessibleStateType::EXPANDED );
111 
112         if ( pDrawer->HasChildPathFocus() )
113             i_rStateSet.AddState( AccessibleStateType::FOCUSED );
114     }
115 
116 	//==================================================================================================================
117 	//= ToolPanelDrawerPeer
118 	//==================================================================================================================
119 	//------------------------------------------------------------------------------------------------------------------
ToolPanelDrawerPeer()120     ToolPanelDrawerPeer::ToolPanelDrawerPeer()
121         :VCLXWindow()
122     {
123     }
124 
125 	//------------------------------------------------------------------------------------------------------------------
~ToolPanelDrawerPeer()126     ToolPanelDrawerPeer::~ToolPanelDrawerPeer()
127     {
128     }
129 
130 	//------------------------------------------------------------------------------------------------------------------
CreateAccessibleContext()131     Reference< XAccessibleContext > ToolPanelDrawerPeer::CreateAccessibleContext()
132     {
133         ::vos::OGuard aSolarGuard( GetMutex() );
134         return new ToolPanelDrawerContext( *this );
135     }
136 
137 //......................................................................................................................
138 } // namespace svt
139 //......................................................................................................................
140