1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
)
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
;
89 aBounds
= AWTRectangle( m_pHeadBar
->GetItemRect( sal_uInt16( m_nIndexInParent
) ) );
98 IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleHeaderBarItem
, AccessibleExtendedComponentHelper_BASE
, VCLXAccessibleHeaderBarItem_BASE
)
104 IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleHeaderBarItem
, AccessibleExtendedComponentHelper_BASE
, VCLXAccessibleHeaderBarItem_BASE
)
110 void VCLXAccessibleHeaderBarItem::disposing()
112 AccessibleExtendedComponentHelper_BASE::disposing();
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";
134 Reference
< XAccessibleContext
> VCLXAccessibleHeaderBarItem::getAccessibleContext() throw (RuntimeException
, std::exception
)
136 OExternalLockGuard
aGuard( this );
142 // XAccessibleContext
145 sal_Int32
VCLXAccessibleHeaderBarItem::getAccessibleChildCount() throw (RuntimeException
, std::exception
)
147 OExternalLockGuard
aGuard( this );
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
;
173 xParent
= m_pHeadBar
->GetAccessible();
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
;
207 OUString
VCLXAccessibleHeaderBarItem::getAccessibleName() throw (RuntimeException
, std::exception
)
209 OExternalLockGuard
aGuard( this );
213 sName
= m_pHeadBar
->GetItemText( sal_uInt16( m_nIndexInParent
) );
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
;
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
);
243 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
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;
281 sal_Int32
VCLXAccessibleHeaderBarItem::getBackground() throw (RuntimeException
, std::exception
)
283 OExternalLockGuard
aGuard( this );
285 sal_Int32 nColor
= 0;
290 // XAccessibleExtendedComponent
293 Reference
< awt::XFont
> VCLXAccessibleHeaderBarItem::getFont() throw (RuntimeException
, std::exception
)
295 OExternalLockGuard
aGuard( this );
297 Reference
< awt::XFont
> xFont
;
303 OUString
VCLXAccessibleHeaderBarItem::getTitledBorderText() throw (RuntimeException
, std::exception
)
305 OExternalLockGuard
aGuard( this );
313 OUString
VCLXAccessibleHeaderBarItem::getToolTipText() throw (RuntimeException
, std::exception
)
315 OExternalLockGuard
aGuard( this );
319 sText
= m_pHeadBar
->GetQuickHelpText();
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */