Bump version to 5.0-14
[LibreOffice.git] / svtools / source / control / vclxaccessibleheaderbar.cxx
blob7c928370ff4a99262e10c334d93b8ec107d9c8dd
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 .
19 #include <vclxaccessibleheaderbar.hxx>
20 #include <vclxaccessibleheaderbaritem.hxx>
22 #include <toolkit/awt/vclxwindows.hxx>
23 #include <svtools/headbar.hxx>
24 #include <unotools/accessiblestatesethelper.hxx>
25 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
26 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
27 #include <cppuhelper/typeprovider.hxx>
28 #include <comphelper/sequence.hxx>
29 #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 #include <vcl/svapp.hxx>
32 using namespace ::com::sun::star;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::awt;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::accessibility;
38 using namespace ::comphelper;
40 VCLXHeaderBar::VCLXHeaderBar(vcl::Window* pHeaderBar)
42 SetWindow(pHeaderBar);
45 VCLXHeaderBar::~VCLXHeaderBar()
49 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXHeaderBar::CreateAccessibleContext()
51 return new VCLXAccessibleHeaderBar(this);
55 VCLXAccessibleHeaderBar::VCLXAccessibleHeaderBar( VCLXWindow* pVCLWindow )
56 :VCLXAccessibleComponent( pVCLWindow )
57 ,m_pHeadBar(NULL)
59 m_pHeadBar = GetAs< HeaderBar >();
63 VCLXAccessibleHeaderBar::~VCLXAccessibleHeaderBar()
69 void VCLXAccessibleHeaderBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
71 VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
76 void VCLXAccessibleHeaderBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
78 VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
82 // XServiceInfo
85 ::rtl::OUString VCLXAccessibleHeaderBar::getImplementationName() throw (RuntimeException, std::exception)
87 return OUString( "com.sun.star.comp.toolkit.AccessibleHeaderBar" );
92 Sequence< ::rtl::OUString > VCLXAccessibleHeaderBar::getSupportedServiceNames() throw (RuntimeException, std::exception)
94 Sequence< ::rtl::OUString > aNames(1);
95 aNames[0] = "com.sun.star.awt.AccessibleHeaderBar";
96 return aNames;
99 // =======XAccessibleContext=======
101 sal_Int32 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChildCount( )
102 throw (::com::sun::star::uno::RuntimeException, std::exception)
104 SolarMutexGuard g;
106 sal_Int32 nCount = 0;
107 if ( m_pHeadBar )
108 nCount = m_pHeadBar->GetItemCount();
110 return nCount;
112 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
113 VCLXAccessibleHeaderBar::getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
115 SolarMutexGuard g;
117 if ( i < 0 || i >= getAccessibleChildCount() )
118 throw IndexOutOfBoundsException();
120 Reference< XAccessible > xChild;
121 // search for the child
122 if ( static_cast<sal_uInt16>(i) >= m_aAccessibleChildren.size() )
123 xChild = CreateChild (i);
124 else
126 xChild = m_aAccessibleChildren[i];
127 if ( !xChild.is() )
128 xChild = CreateChild (i);
130 return xChild;
133 sal_Int16 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
135 return com::sun::star::accessibility::AccessibleRole::LIST;
138 void SAL_CALL VCLXAccessibleHeaderBar::disposing()
140 SolarMutexGuard g;
142 ListItems().swap(m_aAccessibleChildren);
143 VCLXAccessibleComponent::disposing();
146 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > VCLXAccessibleHeaderBar::CreateChild (sal_Int32 i)
148 Reference<XAccessible> xChild;
150 sal_uInt16 nPos = static_cast<sal_uInt16>(i);
151 if ( nPos >= m_aAccessibleChildren.size() )
153 m_aAccessibleChildren.resize(nPos + 1);
155 // insert into the container
156 xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i);
157 m_aAccessibleChildren[nPos] = xChild;
159 else
161 xChild = m_aAccessibleChildren[nPos];
162 // check if position is empty and can be used else we have to adjust all entries behind this
163 if ( !xChild.is() )
165 xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i);
166 m_aAccessibleChildren[nPos] = xChild;
169 return xChild;
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */