tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / accessibility / source / standard / vclxaccessibleheaderbaritem.cxx
blob7bbc2684524deb1a9fb9b04f5481470d268b95a5
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 <vcl/unohelp.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
79 = vcl::unohelper::ConvertToAWTRect(m_pHeadBar->GetItemRect(sal_uInt16(m_nIndexInParent)));
81 return aBounds;
85 // XServiceInfo
86 OUString VCLXAccessibleHeaderBarItem::getImplementationName()
88 return u"com.sun.star.comp.svtools.AccessibleHeaderBarItem"_ustr;
91 sal_Bool VCLXAccessibleHeaderBarItem::supportsService( const OUString& rServiceName )
93 return cppu::supportsService( this, rServiceName );
96 Sequence< OUString > VCLXAccessibleHeaderBarItem::getSupportedServiceNames()
98 return { u"com.sun.star.awt.AccessibleHeaderBarItem"_ustr };
101 // XAccessible
102 Reference< XAccessibleContext > VCLXAccessibleHeaderBarItem::getAccessibleContext()
104 return this;
108 // XAccessibleContext
111 sal_Int64 VCLXAccessibleHeaderBarItem::getAccessibleChildCount()
113 return 0;
117 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleChild( sal_Int64 i )
119 OExternalLockGuard aGuard( this );
121 if ( i < 0 || i >= getAccessibleChildCount() )
122 throw IndexOutOfBoundsException();
124 return Reference< XAccessible >();
128 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleParent()
130 OExternalLockGuard aGuard( this );
132 Reference< XAccessible > xParent;
133 if ( m_pHeadBar )
135 xParent = m_pHeadBar->GetAccessible();
138 return xParent;
142 sal_Int64 VCLXAccessibleHeaderBarItem::getAccessibleIndexInParent()
144 OExternalLockGuard aGuard( this );
145 return m_nIndexInParent - 1;
149 sal_Int16 VCLXAccessibleHeaderBarItem::getAccessibleRole()
151 return AccessibleRole::COLUMN_HEADER;
155 OUString VCLXAccessibleHeaderBarItem::getAccessibleDescription()
157 return OUString();
161 OUString VCLXAccessibleHeaderBarItem::getAccessibleName()
163 OExternalLockGuard aGuard( this );
165 OUString sName;
166 if(m_pHeadBar)
167 sName = m_pHeadBar->GetItemText( sal_uInt16( m_nIndexInParent ) );
168 return sName;
172 Reference< XAccessibleRelationSet > VCLXAccessibleHeaderBarItem::getAccessibleRelationSet( )
174 OExternalLockGuard aGuard( this );
176 return new utl::AccessibleRelationSetHelper;
180 sal_Int64 VCLXAccessibleHeaderBarItem::getAccessibleStateSet( )
182 OExternalLockGuard aGuard( this );
184 sal_Int64 nStateSet = 0;
186 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
188 FillAccessibleStateSet( nStateSet );
190 else
192 nStateSet |= AccessibleStateType::DEFUNC;
195 return nStateSet;
199 css::lang::Locale VCLXAccessibleHeaderBarItem::getLocale()
201 OExternalLockGuard aGuard( this );
203 return Application::GetSettings().GetLanguageTag().getLocale();
207 // XAccessibleComponent
210 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleAtPoint( const awt::Point& )
212 return Reference< XAccessible >();
216 sal_Int32 VCLXAccessibleHeaderBarItem::getForeground()
218 return 0;
222 sal_Int32 VCLXAccessibleHeaderBarItem::getBackground()
224 return 0;
228 // XAccessibleExtendedComponent
230 OUString VCLXAccessibleHeaderBarItem::getTitledBorderText()
232 return OUString();
236 OUString VCLXAccessibleHeaderBarItem::getToolTipText()
238 OExternalLockGuard aGuard( this );
240 OUString sText;
241 if ( m_pHeadBar )
242 sText = m_pHeadBar->GetQuickHelpText();
244 return sText;
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */