Bump version to 5.0-14
[LibreOffice.git] / svtools / source / toolpanel / toolpaneldrawerpeer.cxx
blob8e83866a6b9af64bfe135477abbbf7a8aba38636
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 .
21 #include "toolpaneldrawerpeer.hxx"
22 #include "toolpaneldrawer.hxx"
24 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
25 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
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>
34 namespace svt
38 using ::com::sun::star::uno::Reference;
39 using ::com::sun::star::uno::XInterface;
40 using ::com::sun::star::uno::UNO_QUERY;
41 using ::com::sun::star::uno::UNO_QUERY_THROW;
42 using ::com::sun::star::uno::UNO_SET_THROW;
43 using ::com::sun::star::uno::Exception;
44 using ::com::sun::star::uno::RuntimeException;
45 using ::com::sun::star::uno::Any;
46 using ::com::sun::star::uno::makeAny;
47 using ::com::sun::star::uno::Sequence;
48 using ::com::sun::star::uno::Type;
49 using ::com::sun::star::accessibility::XAccessibleContext;
51 namespace AccessibleStateType = ::com::sun::star::accessibility::AccessibleStateType;
52 namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId;
55 //= ToolPanelDrawerContext
57 class ToolPanelDrawerContext : public VCLXAccessibleComponent
59 public:
60 ToolPanelDrawerContext( VCLXWindow& i_rWindow )
61 :VCLXAccessibleComponent( &i_rWindow )
65 virtual void ProcessWindowEvent( const VclWindowEvent& i_rVclWindowEvent ) SAL_OVERRIDE;
66 virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet ) SAL_OVERRIDE;
68 protected:
69 virtual ~ToolPanelDrawerContext()
75 void ToolPanelDrawerContext::ProcessWindowEvent( const VclWindowEvent& i_rVclWindowEvent )
77 VCLXAccessibleComponent::ProcessWindowEvent( i_rVclWindowEvent );
79 switch ( i_rVclWindowEvent.GetId() )
81 case VCLEVENT_ITEM_EXPANDED:
82 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), makeAny( AccessibleStateType::EXPANDED ) );
83 break;
84 case VCLEVENT_ITEM_COLLAPSED:
85 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, makeAny( AccessibleStateType::EXPANDED ), Any() );
86 break;
91 void ToolPanelDrawerContext::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet )
93 VCLXAccessibleComponent::FillAccessibleStateSet( i_rStateSet );
94 if ( !GetWindow() )
95 return;
97 i_rStateSet.AddState( AccessibleStateType::EXPANDABLE );
98 i_rStateSet.AddState( AccessibleStateType::FOCUSABLE );
100 VclPtr< ToolPanelDrawer > pDrawer = GetAsDynamic< ToolPanelDrawer > ();
101 ENSURE_OR_RETURN_VOID( pDrawer, "ToolPanelDrawerContext::FillAccessibleStateSet: illegal window!" );
102 if ( pDrawer->IsExpanded() )
103 i_rStateSet.AddState( AccessibleStateType::EXPANDED );
105 if ( pDrawer->HasChildPathFocus() )
106 i_rStateSet.AddState( AccessibleStateType::FOCUSED );
110 //= ToolPanelDrawerPeer
113 ToolPanelDrawerPeer::ToolPanelDrawerPeer()
114 :VCLXWindow()
119 ToolPanelDrawerPeer::~ToolPanelDrawerPeer()
124 Reference< XAccessibleContext > ToolPanelDrawerPeer::CreateAccessibleContext()
126 SolarMutexGuard aSolarGuard;
127 return new ToolPanelDrawerContext( *this );
131 } // namespace svt
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */