diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-04-07 22:36:25 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-04-07 22:36:25 +0200 |
commit | e27f829f0371ad8484de9402fb1cd1d6a5610673 (patch) | |
tree | 4e8a442f7a072592300d9ab36fa8ddd562ad1669 /svtools/source/toolpanel | |
parent | 6f5988cdd0eb19dc1c4316db9f3a38787fbad2e5 (diff) |
slidecopy: A11Y implementation for single ToolPanelDrawer instances
Diffstat (limited to 'svtools/source/toolpanel')
-rw-r--r-- | svtools/source/toolpanel/drawerlayouter.cxx | 3 | ||||
-rwxr-xr-x | svtools/source/toolpanel/makefile.mk | 1 | ||||
-rw-r--r-- | svtools/source/toolpanel/toolpaneldrawer.cxx | 31 | ||||
-rw-r--r-- | svtools/source/toolpanel/toolpaneldrawer.hxx | 21 | ||||
-rw-r--r-- | svtools/source/toolpanel/toolpaneldrawerpeer.cxx | 138 | ||||
-rw-r--r-- | svtools/source/toolpanel/toolpaneldrawerpeer.hxx | 56 |
6 files changed, 232 insertions, 18 deletions
diff --git a/svtools/source/toolpanel/drawerlayouter.cxx b/svtools/source/toolpanel/drawerlayouter.cxx index d9aa80369827..2d73a5d1c0b9 100644 --- a/svtools/source/toolpanel/drawerlayouter.cxx +++ b/svtools/source/toolpanel/drawerlayouter.cxx @@ -164,8 +164,7 @@ namespace svt { OSL_PRECOND( i_nPosition <= m_aDrawers.size(), "DrawerDeckLayouter::PanelInserted: inconsistency!" ); - PToolPanelDrawer pDrawer( new ToolPanelDrawer( m_rParentWindow ) ); - pDrawer->SetText( i_pPanel->GetDisplayName() ); + PToolPanelDrawer pDrawer( new ToolPanelDrawer( m_rParentWindow, i_pPanel->GetDisplayName() ) ); pDrawer->Show(); pDrawer->AddEventListener( LINK( this, DrawerDeckLayouter, OnWindowEvent ) ); m_aDrawers.insert( m_aDrawers.begin() + i_nPosition, pDrawer ); diff --git a/svtools/source/toolpanel/makefile.mk b/svtools/source/toolpanel/makefile.mk index d36b377f3dfe..58282056f529 100755 --- a/svtools/source/toolpanel/makefile.mk +++ b/svtools/source/toolpanel/makefile.mk @@ -59,6 +59,7 @@ SLOFILES=\ $(SLO)$/toolpanel.obj \ $(SLO)$/toolpanelcollection.obj \ $(SLO)$/toolpaneldrawer.obj \ + $(SLO)$/toolpaneldrawerpeer.obj \ $(SLO)$/toolpaneldeck.obj \ $(SLO)$/toolpaneldeckpeer.obj \ diff --git a/svtools/source/toolpanel/toolpaneldrawer.cxx b/svtools/source/toolpanel/toolpaneldrawer.cxx index 3beb209672ec..1ee8273a95b4 100644 --- a/svtools/source/toolpanel/toolpaneldrawer.cxx +++ b/svtools/source/toolpanel/toolpaneldrawer.cxx @@ -27,6 +27,7 @@ #include "precompiled_svtools.hxx" #include "toolpaneldrawer.hxx" +#include "toolpaneldrawerpeer.hxx" #include "svtools/svtdata.hxx" #include <com/sun/star/accessibility/AccessibleRole.hpp> @@ -35,12 +36,15 @@ #include <vcl/lineinfo.hxx> #include <vcl/image.hxx> #include <vcl/svapp.hxx> +#include <vcl/vclevent.hxx> //...................................................................................................................... namespace svt { //...................................................................................................................... + using ::com::sun::star::uno::Reference; + using ::com::sun::star::awt::XWindowPeer; namespace AccessibleRole = ::com::sun::star::accessibility::AccessibleRole; static const int s_nIndentationWidth = 16; @@ -49,7 +53,7 @@ namespace svt //= ToolPanelDrawer //================================================================================================================== //------------------------------------------------------------------------------------------------------------------ - ToolPanelDrawer::ToolPanelDrawer( Window& i_rParent ) + ToolPanelDrawer::ToolPanelDrawer( Window& i_rParent, const ::rtl::OUString& i_rTitle ) :Window( &i_rParent, 0 ) ,m_pPaintDevice( new VirtualDevice( *this ) ) ,m_bFocused( false ) @@ -60,6 +64,10 @@ namespace svt SetPointer( POINTER_REFHAND ); SetAccessibleRole( AccessibleRole::LABEL ); + + SetText( i_rTitle ); + SetAccessibleName( i_rTitle ); + SetAccessibleDescription( i_rTitle ); } //------------------------------------------------------------------------------------------------------------------ @@ -68,7 +76,7 @@ namespace svt } //------------------------------------------------------------------------------------------------------------------ - long ToolPanelDrawer::GetPreferredHeightPixel() + long ToolPanelDrawer::GetPreferredHeightPixel() const { Rectangle aTitleBarBox( impl_calcTitleBarBox( impl_calcTextBoundingBox() ) ); return aTitleBarBox.GetHeight(); @@ -143,7 +151,7 @@ namespace svt } //------------------------------------------------------------------------------------------------------------------ - USHORT ToolPanelDrawer::impl_getTextStyle() + USHORT ToolPanelDrawer::impl_getTextStyle() const { const USHORT nBasicStyle = TEXT_DRAW_LEFT | TEXT_DRAW_TOP @@ -257,15 +265,19 @@ namespace svt } //------------------------------------------------------------------------------------------------------------------ - void ToolPanelDrawer::SetText( const String& i_rText ) + Reference< XWindowPeer > ToolPanelDrawer::GetComponentInterface( BOOL i_bCreate ) { - Window::SetText( i_rText ); - SetAccessibleName( i_rText ); - SetAccessibleDescription( i_rText ); + Reference< XWindowPeer > xWindowPeer( Window::GetComponentInterface( FALSE ) ); + if ( !xWindowPeer.is() && i_bCreate ) + { + xWindowPeer.set( new ToolPanelDrawerPeer() ); + SetComponentInterface( xWindowPeer ); + } + return xWindowPeer; } //------------------------------------------------------------------------------------------------------------------ - Rectangle ToolPanelDrawer::impl_calcTextBoundingBox() + Rectangle ToolPanelDrawer::impl_calcTextBoundingBox() const { Font aFont( GetFont() ); if ( m_bExpanded ) @@ -290,7 +302,7 @@ namespace svt } //------------------------------------------------------------------------------------------------------------------ - Rectangle ToolPanelDrawer::impl_calcTitleBarBox( const Rectangle& i_rTextBox ) + Rectangle ToolPanelDrawer::impl_calcTitleBarBox( const Rectangle& i_rTextBox ) const { Rectangle aTitleBarBox( i_rTextBox ); aTitleBarBox.Bottom() += aTitleBarBox.Top(); @@ -310,6 +322,7 @@ namespace svt if ( m_bExpanded != i_bExpanded ) { m_bExpanded = i_bExpanded; + CallEventListeners( m_bExpanded ? VCLEVENT_LISTBOX_ENTRY_EXPANDED : VCLEVENT_LISTBOX_ENTRY_COLLAPSED ); Invalidate(); } } diff --git a/svtools/source/toolpanel/toolpaneldrawer.hxx b/svtools/source/toolpanel/toolpaneldrawer.hxx index e4f00badb78f..992c15d67d6d 100644 --- a/svtools/source/toolpanel/toolpaneldrawer.hxx +++ b/svtools/source/toolpanel/toolpaneldrawer.hxx @@ -41,28 +41,35 @@ namespace svt class ToolPanelDrawer : public Window { public: - ToolPanelDrawer( Window& i_rParent ); + ToolPanelDrawer( Window& i_rParent, const ::rtl::OUString& i_rTitle ); ~ToolPanelDrawer(); - long GetPreferredHeightPixel(); - + long GetPreferredHeightPixel() const; void SetExpanded( const bool i_bExpanded ); + bool IsExpanded() const { return m_bExpanded; } + protected: + // Window overridables virtual void Paint( const Rectangle& i_rBoundingBox ); virtual void GetFocus(); virtual void LoseFocus(); virtual void DataChanged( const DataChangedEvent& i_rEvent ); - virtual void SetText( const String& i_rText ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > + GetComponentInterface( BOOL i_bCreate ); private: - Rectangle impl_calcTextBoundingBox(); - Rectangle impl_calcTitleBarBox( const Rectangle& i_rTextBox ); + Rectangle impl_calcTextBoundingBox() const; + Rectangle impl_calcTitleBarBox( const Rectangle& i_rTextBox ) const; void impl_paintBackground( const Rectangle& i_rTitleBarBox ); - USHORT impl_getTextStyle(); + USHORT impl_getTextStyle() const; void impl_paintFocusIndicator( const Rectangle& i_rTextBox ); Rectangle impl_paintExpansionIndicator( const Rectangle& i_rTextBox ); Image impl_getExpansionIndicator() const; + // don't expose SetText. Our text is used as AccessibleName/Desc, and those are not expected to change. + using Window::SetText; + private: ::std::auto_ptr< VirtualDevice > m_pPaintDevice; bool m_bFocused; diff --git a/svtools/source/toolpanel/toolpaneldrawerpeer.cxx b/svtools/source/toolpanel/toolpaneldrawerpeer.cxx new file mode 100644 index 000000000000..e535678af23e --- /dev/null +++ b/svtools/source/toolpanel/toolpaneldrawerpeer.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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. + * + ************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "toolpaneldrawerpeer.hxx" +#include "toolpaneldrawer.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> +#include <toolkit/awt/vclxaccessiblecomponent.hxx> +#include <unotools/accessiblestatesethelper.hxx> +#include <vcl/vclevent.hxx> + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::accessibility::XAccessibleContext; + /** === end UNO using === **/ + namespace AccessibleStateType = ::com::sun::star::accessibility::AccessibleStateType; + namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; + + //================================================================================================================== + //= ToolPanelDrawerContext + //================================================================================================================== + class ToolPanelDrawerContext : public VCLXAccessibleComponent + { + public: + ToolPanelDrawerContext( VCLXWindow& i_rWindow ) + :VCLXAccessibleComponent( &i_rWindow ) + { + } + + virtual void ProcessWindowEvent( const VclWindowEvent& i_rVclWindowEvent ); + virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet ); + + protected: + ~ToolPanelDrawerContext() + { + } + }; + + //------------------------------------------------------------------------------------------------------------------ + void ToolPanelDrawerContext::ProcessWindowEvent( const VclWindowEvent& i_rVclWindowEvent ) + { + VCLXAccessibleComponent::ProcessWindowEvent( i_rVclWindowEvent ); + + switch ( i_rVclWindowEvent.GetId() ) + { + case VCLEVENT_LISTBOX_ENTRY_EXPANDED: + NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), makeAny( AccessibleStateType::EXPANDED ) ); + break; + case VCLEVENT_LISTBOX_ENTRY_COLLAPSED: + NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, makeAny( AccessibleStateType::EXPANDED ), Any() ); + break; + } + } + + //------------------------------------------------------------------------------------------------------------------ + void ToolPanelDrawerContext::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& i_rStateSet ) + { + VCLXAccessibleComponent::FillAccessibleStateSet( i_rStateSet ); + if ( !GetWindow() ) + return; + + i_rStateSet.AddState( AccessibleStateType::EXPANDABLE ); + + const ToolPanelDrawer* pDrawer( dynamic_cast< const ToolPanelDrawer* > ( GetWindow() ) ); + ENSURE_OR_RETURN_VOID( pDrawer, "ToolPanelDrawerContext::FillAccessibleStateSet: illegal window!" ); + if ( pDrawer->IsExpanded() ) + i_rStateSet.AddState( AccessibleStateType::EXPANDED ); + } + + //================================================================================================================== + //= ToolPanelDrawerPeer + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + ToolPanelDrawerPeer::ToolPanelDrawerPeer() + :VCLXWindow() + { + } + + //------------------------------------------------------------------------------------------------------------------ + ToolPanelDrawerPeer::~ToolPanelDrawerPeer() + { + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessibleContext > ToolPanelDrawerPeer::CreateAccessibleContext() + { + ::vos::OGuard aSolarGuard( GetMutex() ); + return new ToolPanelDrawerContext( *this ); + } + +//...................................................................................................................... +} // namespace svt +//...................................................................................................................... diff --git a/svtools/source/toolpanel/toolpaneldrawerpeer.hxx b/svtools/source/toolpanel/toolpaneldrawerpeer.hxx new file mode 100644 index 000000000000..5fcf0ac0ae7c --- /dev/null +++ b/svtools/source/toolpanel/toolpaneldrawerpeer.hxx @@ -0,0 +1,56 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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 SVT_TOOLPANELDRAWERPEER_HXX +#define SVT_TOOLPANELDRAWERPEER_HXX + +#include <toolkit/awt/vclxwindow.hxx> + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + //================================================================================================================== + //= ToolPanelDrawerPeer + //================================================================================================================== + class ToolPanelDrawerPeer : public VCLXWindow + { + public: + ToolPanelDrawerPeer(); + + protected: + ~ToolPanelDrawerPeer(); + + // VCLXWindow overridables + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > CreateAccessibleContext(); + }; + +//...................................................................................................................... +} // namespace svt +//...................................................................................................................... + +#endif // SVT_TOOLPANELDRAWERPEER_HXX |