Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / accessibility / source / standard / vclxaccessibleheaderbaritem.cxx
blobd3463f5cdae7075be169c0e698008a4226fc94b0
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 <standard/vclxaccessibleheaderbaritem.hxx>
21 #include <vcl/headbar.hxx>
23 #include <com/sun/star/accessibility/AccessibleRole.hpp>
24 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
25 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 #include <comphelper/accessiblecontexthelper.hxx>
27 #include <cppuhelper/supportsservice.hxx>
29 #include <unotools/accessiblerelationsethelper.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/settings.hxx>
32 #include <toolkit/helper/convert.hxx>
33 #include <i18nlangtag/languagetag.hxx>
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::lang;
38 using namespace ::com::sun::star::accessibility;
39 using namespace ::comphelper;
44 VCLXAccessibleHeaderBarItem::VCLXAccessibleHeaderBarItem( HeaderBar* pHeadBar, sal_Int32 _nIndexInParent )
45 :m_pHeadBar( pHeadBar )
46 ,m_nIndexInParent(_nIndexInParent + 1)
51 VCLXAccessibleHeaderBarItem::~VCLXAccessibleHeaderBarItem()
55 void VCLXAccessibleHeaderBarItem::FillAccessibleStateSet( sal_Int64& rStateSet )
57 if ( m_pHeadBar )
59 if ( m_pHeadBar->IsEnabled() )
60 rStateSet |= AccessibleStateType::ENABLED;
62 if ( m_pHeadBar->IsVisible() )
64 rStateSet |= AccessibleStateType::VISIBLE;
66 rStateSet |= AccessibleStateType::SELECTABLE;
67 rStateSet |= AccessibleStateType::RESIZABLE;
71 // OCommonAccessibleComponent
72 awt::Rectangle VCLXAccessibleHeaderBarItem::implGetBounds()
74 awt::Rectangle aBounds;
75 OExternalLockGuard aGuard( this );
77 if ( m_pHeadBar )
78 aBounds = AWTRectangle( m_pHeadBar->GetItemRect( sal_uInt16( m_nIndexInParent ) ) );
80 return aBounds;
84 // XServiceInfo
85 OUString VCLXAccessibleHeaderBarItem::getImplementationName()
87 return "com.sun.star.comp.svtools.AccessibleHeaderBarItem";
90 sal_Bool VCLXAccessibleHeaderBarItem::supportsService( const OUString& rServiceName )
92 return cppu::supportsService( this, rServiceName );
95 Sequence< OUString > VCLXAccessibleHeaderBarItem::getSupportedServiceNames()
97 return { "com.sun.star.awt.AccessibleHeaderBarItem" };
100 // XAccessible
101 Reference< XAccessibleContext > VCLXAccessibleHeaderBarItem::getAccessibleContext()
103 return this;
107 // XAccessibleContext
110 sal_Int64 VCLXAccessibleHeaderBarItem::getAccessibleChildCount()
112 return 0;
116 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleChild( sal_Int64 i )
118 OExternalLockGuard aGuard( this );
120 if ( i < 0 || i >= getAccessibleChildCount() )
121 throw IndexOutOfBoundsException();
123 return Reference< XAccessible >();
127 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleParent()
129 OExternalLockGuard aGuard( this );
131 Reference< XAccessible > xParent;
132 if ( m_pHeadBar )
134 xParent = m_pHeadBar->GetAccessible();
137 return xParent;
141 sal_Int64 VCLXAccessibleHeaderBarItem::getAccessibleIndexInParent()
143 OExternalLockGuard aGuard( this );
144 return m_nIndexInParent - 1;
148 sal_Int16 VCLXAccessibleHeaderBarItem::getAccessibleRole()
150 return AccessibleRole::COLUMN_HEADER;
154 OUString VCLXAccessibleHeaderBarItem::getAccessibleDescription()
156 return OUString();
160 OUString VCLXAccessibleHeaderBarItem::getAccessibleName()
162 OExternalLockGuard aGuard( this );
164 OUString sName;
165 if(m_pHeadBar)
166 sName = m_pHeadBar->GetItemText( sal_uInt16( m_nIndexInParent ) );
167 return sName;
171 Reference< XAccessibleRelationSet > VCLXAccessibleHeaderBarItem::getAccessibleRelationSet( )
173 OExternalLockGuard aGuard( this );
175 return new utl::AccessibleRelationSetHelper;
179 sal_Int64 VCLXAccessibleHeaderBarItem::getAccessibleStateSet( )
181 OExternalLockGuard aGuard( this );
183 sal_Int64 nStateSet = 0;
185 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
187 FillAccessibleStateSet( nStateSet );
189 else
191 nStateSet |= AccessibleStateType::DEFUNC;
194 return nStateSet;
198 css::lang::Locale VCLXAccessibleHeaderBarItem::getLocale()
200 OExternalLockGuard aGuard( this );
202 return Application::GetSettings().GetLanguageTag().getLocale();
206 // XAccessibleComponent
209 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleAtPoint( const awt::Point& )
211 return Reference< XAccessible >();
215 sal_Int32 VCLXAccessibleHeaderBarItem::getForeground()
217 return 0;
221 sal_Int32 VCLXAccessibleHeaderBarItem::getBackground()
223 return 0;
227 // XAccessibleExtendedComponent
230 Reference< awt::XFont > VCLXAccessibleHeaderBarItem::getFont()
232 return Reference< awt::XFont >();
236 OUString VCLXAccessibleHeaderBarItem::getTitledBorderText()
238 return OUString();
242 OUString VCLXAccessibleHeaderBarItem::getToolTipText()
244 OExternalLockGuard aGuard( this );
246 OUString sText;
247 if ( m_pHeadBar )
248 sText = m_pHeadBar->GetQuickHelpText();
250 return sText;
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */