diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-10-05 00:14:07 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-10-05 18:51:33 -0500 |
commit | 6d217a7c13b30ec5f32707d6022e45eb906a6cfc (patch) | |
tree | 2be0e0dd02e9c7cf76cc1334c572ef3e4c6bdbf8 | |
parent | 3ddb5807d67c12e8ea8c9e22409f639eb6d6dfa8 (diff) |
accfixes2: accessibility API implementation for the headerbar
-rw-r--r-- | svtools/Library_svt.mk | 2 | ||||
-rw-r--r-- | svtools/inc/svtools/headbar.hxx | 21 | ||||
-rwxr-xr-x | svtools/inc/svtools/vclxaccessibleheaderbar.hxx | 89 | ||||
-rwxr-xr-x | svtools/inc/svtools/vclxaccessibleheaderbaritem.hxx | 126 | ||||
-rw-r--r-- | svtools/source/control/headbar.cxx | 20 | ||||
-rwxr-xr-x | svtools/source/control/vclxaccessibleheaderbar.cxx | 172 | ||||
-rwxr-xr-x | svtools/source/control/vclxaccessibleheaderbaritem.cxx | 393 |
7 files changed, 815 insertions, 8 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 8e13dc70454f..b4776cf2051f 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -145,6 +145,8 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/control/urlcontrol \ svtools/source/control/valueacc \ svtools/source/control/valueset \ + svtools/source/control/vclxaccessibleheaderbar \ + svtools/source/control/vclxaccessibleheaderbaritem \ svtools/source/dialogs/addresstemplate \ svtools/source/dialogs/colrdlg \ svtools/source/dialogs/filedlg \ diff --git a/svtools/inc/svtools/headbar.hxx b/svtools/inc/svtools/headbar.hxx index a44bc8bbb2ca..746bc65298be 100644 --- a/svtools/inc/svtools/headbar.hxx +++ b/svtools/inc/svtools/headbar.hxx @@ -240,6 +240,8 @@ typedef sal_uInt16 HeaderBarItemBits; // - HeaderBar - // ------------- +class VCLXHeaderBar; + class SVT_DLLPUBLIC HeaderBar : public Window { private: @@ -253,20 +255,21 @@ private: long mnStartPos; long mnDragPos; long mnMouseOff; - sal_uInt16 mnCurItemId; - sal_uInt16 mnItemDragPos; - sal_Bool mbDragable; - sal_Bool mbDrag; - sal_Bool mbItemDrag; - sal_Bool mbOutDrag; - sal_Bool mbButtonStyle; - sal_Bool mbItemMode; + sal_uInt16 mnCurItemId; + sal_uInt16 mnItemDragPos; + sal_Bool mbDragable; + sal_Bool mbDrag; + sal_Bool mbItemDrag; + sal_Bool mbOutDrag; + sal_Bool mbButtonStyle; + sal_Bool mbItemMode; Link maStartDragHdl; Link maDragHdl; Link maEndDragHdl; Link maSelectHdl; Link maDoubleClickHdl; Link maCreateAccessibleHdl; + VCLXHeaderBar* m_pVCLXHeaderBar; ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > @@ -388,6 +391,8 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); void SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface( sal_Bool bCreate ); + }; #endif // _HEADBAR_HXX diff --git a/svtools/inc/svtools/vclxaccessibleheaderbar.hxx b/svtools/inc/svtools/vclxaccessibleheaderbar.hxx new file mode 100755 index 000000000000..c66c36b67f4c --- /dev/null +++ b/svtools/inc/svtools/vclxaccessibleheaderbar.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright IBM Corporation 2010. + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SVTOOLS_VCLXACCESSIBLEHEADERBAR_HXX_ +#define _SVTOOLS_VCLXACCESSIBLEHEADERBAR_HXX_ + +#include <svtools/headbar.hxx> +#include <toolkit/awt/vclxaccessiblecomponent.hxx> +#include "toolkit/awt/vclxwindow.hxx" + +class HeaderBar; + +// ---------------------------------------------------- +// class VCLXAccessibleHeaderBar +// ---------------------------------------------------- + +typedef std::vector< ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible > > ListItems; + +class VCLXAccessibleHeaderBar : public VCLXAccessibleComponent +{ + +public: + HeaderBar* m_pHeadBar; + virtual ~VCLXAccessibleHeaderBar(); + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); + virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ); + + VCLXAccessibleHeaderBar( VCLXWindow* pVCLXindow ); + + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); + + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException); + +public: + virtual void SAL_CALL disposing (void); + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateChild(sal_Int32 i); + +private: + ListItems m_aAccessibleChildren; + + +}; + +class VCLXHeaderBar : public VCLXWindow +{ +public: + VCLXHeaderBar(Window* pHeaderBar); + virtual ~VCLXHeaderBar(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > CreateAccessibleContext(); + +}; + +#endif // _SVTOOLS_VCLXACCESSIBLEHEADERBAR_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/inc/svtools/vclxaccessibleheaderbaritem.hxx b/svtools/inc/svtools/vclxaccessibleheaderbaritem.hxx new file mode 100755 index 000000000000..889eaa8c7767 --- /dev/null +++ b/svtools/inc/svtools/vclxaccessibleheaderbaritem.hxx @@ -0,0 +1,126 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright IBM Corporation 2010. + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SVTOOLS_VCLACCESSIBLEHEADBARITEM_HXX_ +#define _SVTOOLS_VCLACCESSIBLEHEADBARITEM_HXX_ + +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <comphelper/accessiblecomponenthelper.hxx> +#include <cppuhelper/implbase2.hxx> +#include <tools/link.hxx> + + +#include <vector> + +class HeaderBar; +class VCLExternalSolarLock; +class VclSimpleEvent; +class VclWindowEvent; + +namespace utl { +class AccessibleStateSetHelper; +} + + +// ---------------------------------------------------- +// class VCLXAccessibleHeaderBarItem +// ---------------------------------------------------- + +typedef ::comphelper::OAccessibleExtendedComponentHelper AccessibleExtendedComponentHelper_BASE; + +typedef ::cppu::ImplHelper2< +::com::sun::star::accessibility::XAccessible, +::com::sun::star::lang::XServiceInfo > VCLXAccessibleHeaderBarItem_BASE; + +class VCLXAccessibleHeaderBarItem : public AccessibleExtendedComponentHelper_BASE, + public VCLXAccessibleHeaderBarItem_BASE +{ +private: + VCLExternalSolarLock* m_pExternalLock; + HeaderBar* m_pHeadBar; + size_t m_nIndexInParent; + +protected: + DECL_LINK( WindowEventListener, VclSimpleEvent* ); + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); + virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ); + + // OCommonAccessibleComponent + virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL disposing(); + +public: + VCLXAccessibleHeaderBarItem( HeaderBar* pHeadBar, sal_Int32 _nIndexInParent ); + ~VCLXAccessibleHeaderBarItem(); + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException); + + // XAccessible + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException); + + // XAccessibleContext + virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); + + // XAccessibleComponent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException){}; + virtual sal_Int32 SAL_CALL getForeground() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBackground() throw (::com::sun::star::uno::RuntimeException); + + // XAccessibleExtendedComponent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTitledBorderText( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getToolTipText( ) throw (::com::sun::star::uno::RuntimeException); +}; + +#endif // _SVTOOLS_VCLACCESSIBLEHEADBARITEM_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/headbar.cxx b/svtools/source/control/headbar.cxx index 77e067961aec..892f35ea1bd7 100644 --- a/svtools/source/control/headbar.cxx +++ b/svtools/source/control/headbar.cxx @@ -37,6 +37,9 @@ #include <vcl/help.hxx> #include <vcl/image.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> + +#include <vclxaccessibleheaderbar.hxx> // ======================================================================= @@ -88,6 +91,7 @@ void HeaderBar::ImplInit( WinBits nWinStyle ) mbItemDrag = sal_False; mbOutDrag = sal_False; mbItemMode = sal_False; + m_pVCLXHeaderBar = NULL; // StyleBits auswerten if ( nWinStyle & WB_DRAG ) @@ -1595,4 +1599,20 @@ void HeaderBar::SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::sta mxAccessible = _xAccessible; } +::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > HeaderBar::GetComponentInterface( sal_Bool bCreate ) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer (Window::GetComponentInterface(false)); + if ( !xPeer.is() && bCreate ) + { + ::com::sun::star::awt::XWindowPeer* mxPeer = new VCLXHeaderBar(this); + m_pVCLXHeaderBar = (VCLXHeaderBar*)(mxPeer); + SetComponentInterface(mxPeer); + return mxPeer; + } + else + { + return xPeer; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/vclxaccessibleheaderbar.cxx b/svtools/source/control/vclxaccessibleheaderbar.cxx new file mode 100755 index 000000000000..1af2add76d6c --- /dev/null +++ b/svtools/source/control/vclxaccessibleheaderbar.cxx @@ -0,0 +1,172 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright IBM Corporation 2010. + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <comphelper/sequence.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <headbar.hxx> +#include <svtools/vclxaccessibleheaderbar.hxx> +#include <svtools/vclxaccessibleheaderbaritem.hxx> +#include <toolkit/awt/vclxwindows.hxx> +#include <unotools/accessiblestatesethelper.hxx> + +namespace css = com::sun::star; +using namespace ::comphelper; + +VCLXHeaderBar::VCLXHeaderBar(Window* pHeaderBar) +{ + SetWindow(pHeaderBar); +} + +VCLXHeaderBar::~VCLXHeaderBar() +{ +} + +::css::uno::Reference< ::css::accessibility::XAccessibleContext > VCLXHeaderBar::CreateAccessibleContext() +{ + return new VCLXAccessibleHeaderBar(this); +} + + +VCLXAccessibleHeaderBar::VCLXAccessibleHeaderBar( VCLXWindow* pVCLWindow ) + :VCLXAccessibleComponent( pVCLWindow ) + ,m_pHeadBar(NULL) +{ + m_pHeadBar = static_cast< HeaderBar* >( GetWindow() ); +} + +VCLXAccessibleHeaderBar::~VCLXAccessibleHeaderBar() +{ +} + +void VCLXAccessibleHeaderBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); +} + +void VCLXAccessibleHeaderBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) +{ + VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); +} + +// ----------------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------------- + +::rtl::OUString VCLXAccessibleHeaderBar::getImplementationName() throw ( ::css::uno::RuntimeException) +{ + return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleHeaderBar" ); +} + +// ----------------------------------------------------------------------------- + +::css::uno::Sequence< ::rtl::OUString > VCLXAccessibleHeaderBar::getSupportedServiceNames() throw (::css::uno::RuntimeException) +{ + ::css::uno::Sequence< ::rtl::OUString > aNames(1); + aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleHeaderBar" ); + return aNames; +} + +// =======XAccessibleContext======= + +sal_Int32 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChildCount( ) + throw (::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nCount = 0; + if ( m_pHeadBar ) + nCount = m_pHeadBar->GetItemCount(); + + return nCount; +} +::css::uno::Reference< ::css::accessibility::XAccessible > SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChild( sal_Int32 i ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + if ( i < 0 || i >= getAccessibleChildCount() ) + { + throw ::css::lang::IndexOutOfBoundsException(); + } + ::css::uno::Reference< ::css::accessibility::XAccessible > xChild; + // search for the child + if ( (size_t)i >= m_aAccessibleChildren.size() ) + { + xChild = CreateChild (i); + } + else + { + xChild = m_aAccessibleChildren[i]; + if ( !xChild.is() ) + { + xChild = CreateChild (i); + } + } + return xChild; +} + +sal_Int16 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleRole( ) throw (::css::uno::RuntimeException) +{ + return css::accessibility::AccessibleRole::LIST; +} + +void SAL_CALL VCLXAccessibleHeaderBar::disposing (void) +{ + ListItems().swap(m_aAccessibleChildren); + VCLXAccessibleComponent::disposing(); +} + +::css::uno::Reference< ::css::accessibility::XAccessible > VCLXAccessibleHeaderBar::CreateChild (sal_Int32 i) +{ + ::css::uno::Reference< ::css::accessibility::XAccessible> xChild; + +if ( (size_t)i >= m_aAccessibleChildren.size() ) + { + m_aAccessibleChildren.resize(i + 1); + + // insert into the container + xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i); + m_aAccessibleChildren[i] = xChild; + } + else + { + xChild = m_aAccessibleChildren[i]; + // check if position is empty and can be used else we have to adjust all entries behind this + if ( !xChild.is() ) + { + xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i); + m_aAccessibleChildren[i] = xChild; + } + } + return xChild; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/vclxaccessibleheaderbaritem.cxx b/svtools/source/control/vclxaccessibleheaderbaritem.cxx new file mode 100755 index 000000000000..9bee16c9c561 --- /dev/null +++ b/svtools/source/control/vclxaccessibleheaderbaritem.cxx @@ -0,0 +1,393 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright IBM Corporation 2010. + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//IAccessibility2 Implementation 2009----- + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include <svtools/vclxaccessibleheaderbaritem.hxx> +#include <svtools/headbar.hxx> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <unotools/accessiblestatesethelper.hxx> +#include <unotools/accessiblerelationsethelper.hxx> +#include <vcl/svapp.hxx> +#include <toolkit/awt/vclxfont.hxx> +#include <toolkit/helper/externallock.hxx> +#include <toolkit/helper/convert.hxx> + +#include <vector> + + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::accessibility; +using namespace ::comphelper; + +DBG_NAME( VCLXAccessibleHeaderBarItem ) + +// ---------------------------------------------------- +// class AccessibleTabBar +// ---------------------------------------------------- + +VCLXAccessibleHeaderBarItem::VCLXAccessibleHeaderBarItem( HeaderBar* pHeadBar, sal_Int32 _nIndexInParent ) + :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ) + ,m_pHeadBar( pHeadBar ) + ,m_nIndexInParent(_nIndexInParent + 1) + +{ + DBG_CTOR( VCLXAccessibleHeaderBarItem, NULL ); + m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() ); +} + +// ----------------------------------------------------------------------------- + +VCLXAccessibleHeaderBarItem::~VCLXAccessibleHeaderBarItem() +{ + delete m_pExternalLock; + m_pExternalLock = NULL; +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( VCLXAccessibleHeaderBarItem, WindowEventListener, VclSimpleEvent*, pEvent ) +{ + DBG_CHKTHIS( VCLXAccessibleHeaderBarItem, 0 ); + DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "VCLXAccessibleHeaderBarItem::WindowEventListener: unknown window event!" ); + + if ( pEvent && pEvent->ISA( VclWindowEvent ) ) + { + DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "VCLXAccessibleHeaderBarItem::WindowEventListener: no window!" ); + if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) ) + { + ProcessWindowEvent( *(VclWindowEvent*)pEvent ); + } + } + + return 0; +} + +// ----------------------------------------------------------------------------- + +void VCLXAccessibleHeaderBarItem::ProcessWindowEvent( const VclWindowEvent& ) +{ + Any aOldValue, aNewValue; +} + +// ----------------------------------------------------------------------------- + +void VCLXAccessibleHeaderBarItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) +{ + if ( m_pHeadBar ) + { + if ( m_pHeadBar->IsEnabled() ) + { + rStateSet.AddState( AccessibleStateType::ENABLED ); + } + if ( m_pHeadBar->IsVisible() ) + { + rStateSet.AddState( AccessibleStateType::VISIBLE ); + } + rStateSet.AddState( AccessibleStateType::SELECTABLE ); + rStateSet.AddState( AccessibleStateType::RESIZABLE ); + } +} + +// ----------------------------------------------------------------------------- +// OCommonAccessibleComponent +// ----------------------------------------------------------------------------- + +awt::Rectangle VCLXAccessibleHeaderBarItem::implGetBounds() throw (RuntimeException) +{ + awt::Rectangle aBounds; + OExternalLockGuard aGuard( this ); + + ::com::sun::star::awt::Size aSize; + + if ( m_pHeadBar ) + { + aBounds = AWTRectangle( m_pHeadBar->GetItemRect( (sal_uInt16)m_nIndexInParent ) ); + } + return aBounds; +} + +// ----------------------------------------------------------------------------- +// XInterface +// ----------------------------------------------------------------------------- + +IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE ) + +// ----------------------------------------------------------------------------- +// XTypeProvider +// ----------------------------------------------------------------------------- + +IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE ) + +// ----------------------------------------------------------------------------- +// XComponent +// ----------------------------------------------------------------------------- + +void VCLXAccessibleHeaderBarItem::disposing() +{ + AccessibleExtendedComponentHelper_BASE::disposing(); +} + +// ----------------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------------- + +::rtl::OUString VCLXAccessibleHeaderBarItem::getImplementationName() throw (RuntimeException) +{ + return ::rtl::OUString::createFromAscii( "com.sun.star.comp.svtools.AccessibleHeaderBarItem" ); +} + +// ----------------------------------------------------------------------------- + +sal_Bool VCLXAccessibleHeaderBarItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() ); + const ::rtl::OUString* pNames = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pNames + aNames.getLength(); + for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) + ; + + return pNames != pEnd; +} + +// ----------------------------------------------------------------------------- + +Sequence< ::rtl::OUString > VCLXAccessibleHeaderBarItem::getSupportedServiceNames() throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aNames(1); + aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleHeaderBarItem" ); + return aNames; +} + +// ----------------------------------------------------------------------------- +// XAccessible +// ----------------------------------------------------------------------------- + +Reference< XAccessibleContext > VCLXAccessibleHeaderBarItem::getAccessibleContext() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return this; +} + +// ----------------------------------------------------------------------------- +// XAccessibleContext +// ----------------------------------------------------------------------------- + +sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleChildCount() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return 0; +} + +// ----------------------------------------------------------------------------- + +Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + if ( i < 0 || i >= getAccessibleChildCount() ) + { + throw IndexOutOfBoundsException(); + } + return Reference< XAccessible >(); +} + +// ----------------------------------------------------------------------------- + +Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleParent() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + Reference< XAccessible > xParent; + if ( m_pHeadBar ) + { + xParent = m_pHeadBar->GetAccessible(); + } + + return xParent; +} + +// ----------------------------------------------------------------------------- + +sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleIndexInParent() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + return m_nIndexInParent - 1; +} + +// ----------------------------------------------------------------------------- + +sal_Int16 VCLXAccessibleHeaderBarItem::getAccessibleRole() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return AccessibleRole::COLUMN_HEADER; +} + +// ----------------------------------------------------------------------------- + +::rtl::OUString VCLXAccessibleHeaderBarItem::getAccessibleDescription() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + ::rtl::OUString sDescription; + return sDescription; +} + +// ----------------------------------------------------------------------------- + +::rtl::OUString VCLXAccessibleHeaderBarItem::getAccessibleName() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + ::rtl::OUString sName; + if(m_pHeadBar) + { + sName = m_pHeadBar->GetItemText( (sal_uInt16) m_nIndexInParent ); + } + return sName; +} + +// ----------------------------------------------------------------------------- + +Reference< XAccessibleRelationSet > VCLXAccessibleHeaderBarItem::getAccessibleRelationSet( ) throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; + Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; + return xSet; +} + +// ----------------------------------------------------------------------------- + +Reference< XAccessibleStateSet > VCLXAccessibleHeaderBarItem::getAccessibleStateSet( ) throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; + Reference< XAccessibleStateSet > xSet = pStateSetHelper; + + if ( !rBHelper.bDisposed && !rBHelper.bInDispose ) + { + FillAccessibleStateSet( *pStateSetHelper ); + } + else + { + pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); + } + + return xSet; +} + +// ----------------------------------------------------------------------------- + +com::sun::star::lang::Locale VCLXAccessibleHeaderBarItem::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return Application::GetSettings().GetLocale(); +} + +// ----------------------------------------------------------------------------- +// XAccessibleComponent +// ----------------------------------------------------------------------------- + +Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return Reference< XAccessible >(); +} + +// ----------------------------------------------------------------------------- + +sal_Int32 VCLXAccessibleHeaderBarItem::getForeground() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nColor = 0; + return nColor; +} + +// ----------------------------------------------------------------------------- + +sal_Int32 VCLXAccessibleHeaderBarItem::getBackground() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nColor = 0; + return nColor; +} + +// ----------------------------------------------------------------------------- +// XAccessibleExtendedComponent +// ----------------------------------------------------------------------------- + +Reference< awt::XFont > VCLXAccessibleHeaderBarItem::getFont() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + Reference< awt::XFont > xFont; + return xFont; +} + +// ----------------------------------------------------------------------------- + +::rtl::OUString VCLXAccessibleHeaderBarItem::getTitledBorderText() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + ::rtl::OUString sText; + return sText; +} + +// ----------------------------------------------------------------------------- + +::rtl::OUString VCLXAccessibleHeaderBarItem::getToolTipText() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + ::rtl::OUString sText; + if ( m_pHeadBar ) + { + sText = m_pHeadBar->GetQuickHelpText(); + } + return sText; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |