Bump version to 5.0-14
[LibreOffice.git] / svtools / source / control / vclxaccessibleheaderbaritem.cxx
blobdd504066c4c6e86063582b70aa7d5865ac9b2df5
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 <vclxaccessibleheaderbaritem.hxx>
21 #include <svtools/headbar.hxx>
23 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
24 #include <com/sun/star/accessibility/AccessibleRole.hpp>
25 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
26 #include <cppuhelper/supportsservice.hxx>
28 #include <unotools/accessiblestatesethelper.hxx>
29 #include <unotools/accessiblerelationsethelper.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/settings.hxx>
32 #include <toolkit/awt/vclxfont.hxx>
33 #include <toolkit/helper/externallock.hxx>
34 #include <toolkit/helper/convert.hxx>
36 #include <vector>
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::accessibility;
42 using namespace ::comphelper;
46 // class AccessibleTabBar
49 VCLXAccessibleHeaderBarItem::VCLXAccessibleHeaderBarItem( HeaderBar* pHeadBar, sal_Int32 _nIndexInParent )
50 :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
51 ,m_pHeadBar( pHeadBar )
52 ,m_nIndexInParent(_nIndexInParent + 1)
55 m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
58 VCLXAccessibleHeaderBarItem::~VCLXAccessibleHeaderBarItem()
60 delete m_pExternalLock;
61 m_pExternalLock = NULL;
64 void VCLXAccessibleHeaderBarItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
66 if ( m_pHeadBar )
68 if ( m_pHeadBar->IsEnabled() )
69 rStateSet.AddState( AccessibleStateType::ENABLED );
71 if ( m_pHeadBar->IsVisible() )
73 rStateSet.AddState( AccessibleStateType::VISIBLE );
75 rStateSet.AddState( AccessibleStateType::SELECTABLE );
76 rStateSet.AddState( AccessibleStateType::RESIZABLE );
80 // OCommonAccessibleComponent
81 awt::Rectangle VCLXAccessibleHeaderBarItem::implGetBounds() throw (RuntimeException)
83 awt::Rectangle aBounds;
84 OExternalLockGuard aGuard( this );
86 ::com::sun::star::awt::Size aSize;
88 if ( m_pHeadBar )
89 aBounds = AWTRectangle( m_pHeadBar->GetItemRect( sal_uInt16( m_nIndexInParent ) ) );
91 return aBounds;
95 // XInterface
98 IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE )
101 // XTypeProvider
104 IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE )
107 // XComponent
110 void VCLXAccessibleHeaderBarItem::disposing()
112 AccessibleExtendedComponentHelper_BASE::disposing();
115 // XServiceInfo
116 OUString VCLXAccessibleHeaderBarItem::getImplementationName() throw (RuntimeException, std::exception)
118 return OUString("com.sun.star.comp.svtools.AccessibleHeaderBarItem");
121 sal_Bool VCLXAccessibleHeaderBarItem::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
123 return cppu::supportsService( this, rServiceName );
126 Sequence< OUString > VCLXAccessibleHeaderBarItem::getSupportedServiceNames() throw (RuntimeException, std::exception)
128 Sequence< OUString > aNames(1);
129 aNames[0] = "com.sun.star.awt.AccessibleHeaderBarItem";
130 return aNames;
133 // XAccessible
134 Reference< XAccessibleContext > VCLXAccessibleHeaderBarItem::getAccessibleContext() throw (RuntimeException, std::exception)
136 OExternalLockGuard aGuard( this );
138 return this;
142 // XAccessibleContext
145 sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleChildCount() throw (RuntimeException, std::exception)
147 OExternalLockGuard aGuard( this );
149 return 0;
154 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
156 OExternalLockGuard aGuard( this );
158 if ( i < 0 || i >= getAccessibleChildCount() )
159 throw IndexOutOfBoundsException();
161 return Reference< XAccessible >();
166 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleParent() throw (RuntimeException, std::exception)
168 OExternalLockGuard aGuard( this );
170 Reference< XAccessible > xParent;
171 if ( m_pHeadBar )
173 xParent = m_pHeadBar->GetAccessible();
176 return xParent;
181 sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleIndexInParent() throw (RuntimeException, std::exception)
183 OExternalLockGuard aGuard( this );
184 return m_nIndexInParent - 1;
189 sal_Int16 VCLXAccessibleHeaderBarItem::getAccessibleRole() throw (RuntimeException, std::exception)
191 OExternalLockGuard aGuard( this );
193 return AccessibleRole::COLUMN_HEADER;
198 OUString VCLXAccessibleHeaderBarItem::getAccessibleDescription() throw (RuntimeException, std::exception)
200 OExternalLockGuard aGuard( this );
201 OUString sDescription;
202 return sDescription;
207 OUString VCLXAccessibleHeaderBarItem::getAccessibleName() throw (RuntimeException, std::exception)
209 OExternalLockGuard aGuard( this );
211 OUString sName;
212 if(m_pHeadBar)
213 sName = m_pHeadBar->GetItemText( sal_uInt16( m_nIndexInParent ) );
214 return sName;
219 Reference< XAccessibleRelationSet > VCLXAccessibleHeaderBarItem::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
221 OExternalLockGuard aGuard( this );
223 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
224 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
225 return xSet;
230 Reference< XAccessibleStateSet > VCLXAccessibleHeaderBarItem::getAccessibleStateSet( ) throw (RuntimeException, std::exception)
232 OExternalLockGuard aGuard( this );
234 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
235 Reference< XAccessibleStateSet > xSet = pStateSetHelper;
237 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
239 FillAccessibleStateSet( *pStateSetHelper );
241 else
243 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
246 return xSet;
251 com::sun::star::lang::Locale VCLXAccessibleHeaderBarItem::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
253 OExternalLockGuard aGuard( this );
255 return Application::GetSettings().GetLanguageTag().getLocale();
259 // XAccessibleComponent
262 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException, std::exception)
264 OExternalLockGuard aGuard( this );
266 return Reference< XAccessible >();
271 sal_Int32 VCLXAccessibleHeaderBarItem::getForeground() throw (RuntimeException, std::exception)
273 OExternalLockGuard aGuard( this );
275 sal_Int32 nColor = 0;
276 return nColor;
281 sal_Int32 VCLXAccessibleHeaderBarItem::getBackground() throw (RuntimeException, std::exception)
283 OExternalLockGuard aGuard( this );
285 sal_Int32 nColor = 0;
286 return nColor;
290 // XAccessibleExtendedComponent
293 Reference< awt::XFont > VCLXAccessibleHeaderBarItem::getFont() throw (RuntimeException, std::exception)
295 OExternalLockGuard aGuard( this );
297 Reference< awt::XFont > xFont;
298 return xFont;
303 OUString VCLXAccessibleHeaderBarItem::getTitledBorderText() throw (RuntimeException, std::exception)
305 OExternalLockGuard aGuard( this );
307 OUString sText;
308 return sText;
313 OUString VCLXAccessibleHeaderBarItem::getToolTipText() throw (RuntimeException, std::exception)
315 OExternalLockGuard aGuard( this );
317 OUString sText;
318 if ( m_pHeadBar )
319 sText = m_pHeadBar->GetQuickHelpText();
321 return sText;
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */