summaryrefslogtreecommitdiff
path: root/accessibility/source/standard
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility/source/standard')
-rw-r--r--accessibility/source/standard/accessiblemenubasecomponent.cxx786
-rw-r--r--accessibility/source/standard/accessiblemenucomponent.cxx474
-rw-r--r--accessibility/source/standard/accessiblemenuitemcomponent.cxx506
-rw-r--r--accessibility/source/standard/floatingwindowaccessible.cxx74
-rw-r--r--accessibility/source/standard/makefile.mk82
-rw-r--r--accessibility/source/standard/vclxaccessiblebox.cxx377
-rw-r--r--accessibility/source/standard/vclxaccessiblebutton.cxx329
-rw-r--r--accessibility/source/standard/vclxaccessiblecheckbox.cxx364
-rw-r--r--accessibility/source/standard/vclxaccessiblecombobox.cxx99
-rw-r--r--accessibility/source/standard/vclxaccessibledropdowncombobox.cxx145
-rw-r--r--accessibility/source/standard/vclxaccessibledropdownlistbox.cxx113
-rw-r--r--accessibility/source/standard/vclxaccessibleedit.cxx633
-rw-r--r--accessibility/source/standard/vclxaccessiblefixedhyperlink.cxx88
-rw-r--r--accessibility/source/standard/vclxaccessiblefixedtext.cxx99
-rw-r--r--accessibility/source/standard/vclxaccessiblelist.cxx857
-rw-r--r--accessibility/source/standard/vclxaccessiblelistbox.cxx111
-rw-r--r--accessibility/source/standard/vclxaccessiblelistboxlist.cxx338
-rw-r--r--accessibility/source/standard/vclxaccessiblelistitem.cxx677
-rw-r--r--accessibility/source/standard/vclxaccessiblemenu.cxx258
-rw-r--r--accessibility/source/standard/vclxaccessiblemenubar.cxx214
-rw-r--r--accessibility/source/standard/vclxaccessiblemenuitem.cxx610
-rw-r--r--accessibility/source/standard/vclxaccessiblemenuseparator.cxx88
-rw-r--r--accessibility/source/standard/vclxaccessiblepopupmenu.cxx114
-rw-r--r--accessibility/source/standard/vclxaccessibleradiobutton.cxx317
-rw-r--r--accessibility/source/standard/vclxaccessiblescrollbar.cxx283
-rw-r--r--accessibility/source/standard/vclxaccessiblestatusbar.cxx369
-rw-r--r--accessibility/source/standard/vclxaccessiblestatusbaritem.cxx632
-rw-r--r--accessibility/source/standard/vclxaccessibletabcontrol.cxx518
-rw-r--r--accessibility/source/standard/vclxaccessibletabpage.cxx705
-rw-r--r--accessibility/source/standard/vclxaccessibletabpagewindow.cxx144
-rw-r--r--accessibility/source/standard/vclxaccessibletextcomponent.cxx365
-rw-r--r--accessibility/source/standard/vclxaccessibletextfield.cxx157
-rw-r--r--accessibility/source/standard/vclxaccessibletoolbox.cxx858
-rw-r--r--accessibility/source/standard/vclxaccessibletoolboxitem.cxx721
34 files changed, 12505 insertions, 0 deletions
diff --git a/accessibility/source/standard/accessiblemenubasecomponent.cxx b/accessibility/source/standard/accessiblemenubasecomponent.cxx
new file mode 100644
index 000000000000..defde95ce4b3
--- /dev/null
+++ b/accessibility/source/standard/accessiblemenubasecomponent.cxx
@@ -0,0 +1,786 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: accessiblemenubasecomponent.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/accessiblemenubasecomponent.hxx>
+#include <accessibility/standard/vclxaccessiblemenu.hxx>
+#include <accessibility/standard/vclxaccessiblemenuitem.hxx>
+#include <accessibility/standard/vclxaccessiblemenuseparator.hxx>
+#include <toolkit/helper/externallock.hxx>
+#include <toolkit/helper/convert.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 <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/menu.hxx>
+#include <tools/debug.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// OAccessibleMenuBaseComponent
+// -----------------------------------------------------------------------------
+
+OAccessibleMenuBaseComponent::OAccessibleMenuBaseComponent( Menu* pMenu )
+ :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
+ ,m_pMenu( pMenu )
+ ,m_bEnabled( sal_False )
+ ,m_bFocused( sal_False )
+ ,m_bVisible( sal_False )
+ ,m_bSelected( sal_False )
+ ,m_bChecked( sal_False )
+{
+ m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
+
+ if ( m_pMenu )
+ {
+ m_aAccessibleChildren.assign( m_pMenu->GetItemCount(), Reference< XAccessible >() );
+ m_pMenu->AddEventListener( LINK( this, OAccessibleMenuBaseComponent, MenuEventListener ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+OAccessibleMenuBaseComponent::~OAccessibleMenuBaseComponent()
+{
+ if ( m_pMenu )
+ m_pMenu->RemoveEventListener( LINK( this, OAccessibleMenuBaseComponent, MenuEventListener ) );
+
+ delete m_pExternalLock;
+ m_pExternalLock = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsEnabled()
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsFocused()
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsVisible()
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsSelected()
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsChecked()
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::SetStates()
+{
+ m_bEnabled = IsEnabled();
+ m_bFocused = IsFocused();
+ m_bVisible = IsVisible();
+ m_bSelected = IsSelected();
+ m_bChecked = IsChecked();
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::SetEnabled( sal_Bool bEnabled )
+{
+ if ( m_bEnabled != bEnabled )
+ {
+ Any aOldValue[2], aNewValue[2];
+ if ( m_bEnabled )
+ {
+ aOldValue[0] <<= AccessibleStateType::SENSITIVE;
+ aOldValue[1] <<= AccessibleStateType::ENABLED;
+ }
+ else
+ {
+ aNewValue[0] <<= AccessibleStateType::ENABLED;
+ aNewValue[1] <<= AccessibleStateType::SENSITIVE;
+ }
+ m_bEnabled = bEnabled;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] );
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::SetFocused( sal_Bool bFocused )
+{
+ if ( m_bFocused != bFocused )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bFocused )
+ aOldValue <<= AccessibleStateType::FOCUSED;
+ else
+ aNewValue <<= AccessibleStateType::FOCUSED;
+ m_bFocused = bFocused;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::SetVisible( sal_Bool bVisible )
+{
+ if ( m_bVisible != bVisible )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bVisible )
+ aOldValue <<= AccessibleStateType::VISIBLE;
+ else
+ aNewValue <<= AccessibleStateType::VISIBLE;
+ m_bVisible = bVisible;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::SetSelected( sal_Bool bSelected )
+{
+ if ( m_bSelected != bSelected )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bSelected )
+ aOldValue <<= AccessibleStateType::SELECTED;
+ else
+ aNewValue <<= AccessibleStateType::SELECTED;
+ m_bSelected = bSelected;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::SetChecked( sal_Bool bChecked )
+{
+ if ( m_bChecked != bChecked )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bChecked )
+ aOldValue <<= AccessibleStateType::CHECKED;
+ else
+ aNewValue <<= AccessibleStateType::CHECKED;
+ m_bChecked = bChecked;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::UpdateEnabled( sal_Int32 i, sal_Bool bEnabled )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xChild.get() );
+ if ( pComp )
+ pComp->SetEnabled( bEnabled );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::UpdateFocused( sal_Int32 i, sal_Bool bFocused )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xChild.get() );
+ if ( pComp )
+ pComp->SetFocused( bFocused );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::UpdateVisible()
+{
+ SetVisible( IsVisible() );
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xChild.get() );
+ if ( pComp )
+ pComp->SetVisible( pComp->IsVisible() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::UpdateSelected( sal_Int32 i, sal_Bool bSelected )
+{
+ NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
+
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xChild.get() );
+ if ( pComp )
+ pComp->SetSelected( bSelected );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::UpdateChecked( sal_Int32 i, sal_Bool bChecked )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xChild.get() );
+ if ( pComp )
+ pComp->SetChecked( bChecked );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::UpdateAccessibleName( sal_Int32 i )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ OAccessibleMenuItemComponent* pComp = static_cast< OAccessibleMenuItemComponent* >( xChild.get() );
+ if ( pComp )
+ pComp->SetAccessibleName( pComp->GetAccessibleName() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::UpdateItemText( sal_Int32 i )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ OAccessibleMenuItemComponent* pComp = static_cast< OAccessibleMenuItemComponent* >( xChild.get() );
+ if ( pComp )
+ pComp->SetItemText( pComp->GetItemText() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuBaseComponent::GetChildCount()
+{
+ return m_aAccessibleChildren.size();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuBaseComponent::GetChild( sal_Int32 i )
+{
+ Reference< XAccessible > xChild = m_aAccessibleChildren[i];
+ if ( !xChild.is() )
+ {
+ if ( m_pMenu )
+ {
+ // create a new child
+ OAccessibleMenuBaseComponent* pChild;
+
+ if ( m_pMenu->GetItemType( (USHORT)i ) == MENUITEM_SEPARATOR )
+ {
+ pChild = new VCLXAccessibleMenuSeparator( m_pMenu, (sal_uInt16)i );
+ }
+ else
+ {
+ PopupMenu* pPopupMenu = m_pMenu->GetPopupMenu( m_pMenu->GetItemId( (USHORT)i ) );
+ if ( pPopupMenu )
+ {
+ pChild = new VCLXAccessibleMenu( m_pMenu, (sal_uInt16)i, pPopupMenu );
+ pPopupMenu->SetAccessible( pChild );
+ }
+ else
+ {
+ pChild = new VCLXAccessibleMenuItem( m_pMenu, (sal_uInt16)i );
+ }
+ }
+
+ // set states
+ pChild->SetStates();
+
+ xChild = pChild;
+
+ // insert into menu item list
+ m_aAccessibleChildren[i] = xChild;
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuBaseComponent::GetChildAt( const awt::Point& rPoint )
+{
+ Reference< XAccessible > xChild;
+ for ( sal_uInt32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
+ {
+ Reference< XAccessible > xAcc = getAccessibleChild( i );
+ if ( xAcc.is() )
+ {
+ Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
+ if ( xComp.is() )
+ {
+ Rectangle aRect = VCLRectangle( xComp->getBounds() );
+ Point aPos = VCLPoint( rPoint );
+ if ( aRect.IsInside( aPos ) )
+ {
+ xChild = xAcc;
+ break;
+ }
+ }
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::InsertChild( sal_Int32 i )
+{
+ if ( i > (sal_Int32)m_aAccessibleChildren.size() )
+ i = m_aAccessibleChildren.size();
+
+ if ( i >= 0 )
+ {
+ // insert entry in child list
+ m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() );
+
+ // update item position of accessible children
+ for ( sal_uInt32 j = i, nCount = m_aAccessibleChildren.size(); j < nCount; ++j )
+ {
+ Reference< XAccessible > xAcc( m_aAccessibleChildren[j] );
+ if ( xAcc.is() )
+ {
+ OAccessibleMenuItemComponent* pComp = static_cast< OAccessibleMenuItemComponent* >( xAcc.get() );
+ if ( pComp )
+ pComp->SetItemPos( (sal_uInt16)j );
+ }
+ }
+
+ // send accessible child event
+ Reference< XAccessible > xChild( GetChild( i ) );
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aNewValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::RemoveChild( sal_Int32 i )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ // keep the accessible of the removed item
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+
+ // remove entry in child list
+ m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
+
+ // update item position of accessible children
+ for ( sal_uInt32 j = i, nCount = m_aAccessibleChildren.size(); j < nCount; ++j )
+ {
+ Reference< XAccessible > xAcc( m_aAccessibleChildren[j] );
+ if ( xAcc.is() )
+ {
+ OAccessibleMenuItemComponent* pComp = static_cast< OAccessibleMenuItemComponent* >( xAcc.get() );
+ if ( pComp )
+ pComp->SetItemPos( (sal_uInt16)j );
+ }
+ }
+
+ // send accessible child event
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+
+ Reference< XComponent > xComponent( xChild, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsHighlighted()
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsChildHighlighted()
+{
+ sal_Bool bChildHighlighted = sal_False;
+
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xChild.get() );
+ if ( pComp && pComp->IsHighlighted() )
+ {
+ bChildHighlighted = sal_True;
+ break;
+ }
+ }
+ }
+
+ return bChildHighlighted;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::SelectChild( sal_Int32 i )
+{
+ // open the menu
+ if ( getAccessibleRole() == AccessibleRole::MENU && !IsPopupMenuOpen() )
+ Click();
+
+ // highlight the child
+ if ( m_pMenu )
+ m_pMenu->HighlightItem( (USHORT)i );
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::DeSelectAll()
+{
+ if ( m_pMenu )
+ m_pMenu->DeHighlight();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsChildSelected( sal_Int32 i )
+{
+ sal_Bool bSelected = sal_False;
+
+ if ( m_pMenu && m_pMenu->IsHighlighted( (USHORT)i ) )
+ bSelected = sal_True;
+
+ return bSelected;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::Select()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::DeSelect()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::Click()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::IsPopupMenuOpen()
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( OAccessibleMenuBaseComponent, MenuEventListener, VclSimpleEvent*, pEvent )
+{
+ DBG_ASSERT( pEvent && pEvent->ISA( VclMenuEvent ), "OAccessibleMenuBaseComponent - Unknown MenuEvent!" );
+ if ( pEvent && pEvent->ISA( VclMenuEvent ) )
+ {
+ DBG_ASSERT( ((VclMenuEvent*)pEvent)->GetMenu(), "OAccessibleMenuBaseComponent - Menu?" );
+ ProcessMenuEvent( *(VclMenuEvent*)pEvent );
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::ProcessMenuEvent( const VclMenuEvent& rVclMenuEvent )
+{
+ sal_uInt16 nItemPos = rVclMenuEvent.GetItemPos();
+
+ switch ( rVclMenuEvent.GetId() )
+ {
+ case VCLEVENT_MENU_SHOW:
+ case VCLEVENT_MENU_HIDE:
+ {
+ UpdateVisible();
+ }
+ break;
+ case VCLEVENT_MENU_HIGHLIGHT:
+ {
+ SetFocused( sal_False );
+ UpdateFocused( nItemPos, sal_True );
+ UpdateSelected( nItemPos, sal_True );
+ }
+ break;
+ case VCLEVENT_MENU_DEHIGHLIGHT:
+ {
+ UpdateFocused( nItemPos, sal_False );
+ UpdateSelected( nItemPos, sal_False );
+ }
+ break;
+ case VCLEVENT_MENU_SUBMENUACTIVATE:
+ {
+ }
+ break;
+ case VCLEVENT_MENU_SUBMENUDEACTIVATE:
+ {
+ UpdateFocused( nItemPos, sal_True );
+ }
+ break;
+ case VCLEVENT_MENU_ENABLE:
+ {
+ UpdateEnabled( nItemPos, sal_True );
+ }
+ break;
+ case VCLEVENT_MENU_DISABLE:
+ {
+ UpdateEnabled( nItemPos, sal_False );
+ }
+ break;
+ case VCLEVENT_MENU_SUBMENUCHANGED:
+ {
+ RemoveChild( nItemPos );
+ InsertChild( nItemPos );
+ }
+ break;
+ case VCLEVENT_MENU_INSERTITEM:
+ {
+ InsertChild( nItemPos );
+ }
+ break;
+ case VCLEVENT_MENU_REMOVEITEM:
+ {
+ RemoveChild( nItemPos );
+ }
+ break;
+ case VCLEVENT_MENU_ACCESSIBLENAMECHANGED:
+ {
+ UpdateAccessibleName( nItemPos );
+ }
+ break;
+ case VCLEVENT_MENU_ITEMTEXTCHANGED:
+ {
+ UpdateAccessibleName( nItemPos );
+ UpdateItemText( nItemPos );
+ }
+ break;
+ case VCLEVENT_MENU_ITEMCHECKED:
+ {
+ UpdateChecked( nItemPos, sal_True );
+ }
+ break;
+ case VCLEVENT_MENU_ITEMUNCHECKED:
+ {
+ UpdateChecked( nItemPos, sal_False );
+ }
+ break;
+ case VCLEVENT_OBJECT_DYING:
+ {
+ if ( m_pMenu )
+ {
+ m_pMenu->RemoveEventListener( LINK( this, OAccessibleMenuBaseComponent, MenuEventListener ) );
+
+ m_pMenu = NULL;
+
+ // dispose all menu items
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ m_aAccessibleChildren.clear();
+ }
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleMenuBaseComponent, AccessibleExtendedComponentHelper_BASE, OAccessibleMenuBaseComponent_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleMenuBaseComponent, AccessibleExtendedComponentHelper_BASE, OAccessibleMenuBaseComponent_BASE )
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuBaseComponent::disposing()
+{
+ AccessibleExtendedComponentHelper_BASE::disposing();
+
+ if ( m_pMenu )
+ {
+ m_pMenu->RemoveEventListener( LINK( this, OAccessibleMenuBaseComponent, MenuEventListener ) );
+
+ m_pMenu = NULL;
+
+ // dispose all menu items
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ m_aAccessibleChildren.clear();
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuBaseComponent::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;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessible
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleContext > OAccessibleMenuBaseComponent::getAccessibleContext( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleStateSet > OAccessibleMenuBaseComponent::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;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/accessiblemenucomponent.cxx b/accessibility/source/standard/accessiblemenucomponent.cxx
new file mode 100644
index 000000000000..cd08b1da09ee
--- /dev/null
+++ b/accessibility/source/standard/accessiblemenucomponent.cxx
@@ -0,0 +1,474 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: accessiblemenucomponent.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/accessiblemenucomponent.hxx>
+
+#include <toolkit/awt/vclxfont.hxx>
+#include <toolkit/helper/convert.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 <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/unohelp2.hxx>
+
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class OAccessibleMenuComponent
+// -----------------------------------------------------------------------------
+
+OAccessibleMenuComponent::OAccessibleMenuComponent( Menu* pMenu )
+ :OAccessibleMenuBaseComponent( pMenu )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+OAccessibleMenuComponent::~OAccessibleMenuComponent()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuComponent::IsEnabled()
+{
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuComponent::IsVisible()
+{
+ sal_Bool bVisible = sal_False;
+
+ if ( m_pMenu )
+ bVisible = m_pMenu->IsMenuVisible();
+
+ return bVisible;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ if ( IsEnabled() )
+ {
+ rStateSet.AddState( AccessibleStateType::ENABLED );
+ rStateSet.AddState( AccessibleStateType::SENSITIVE );
+ }
+
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+
+ if ( IsFocused() )
+ rStateSet.AddState( AccessibleStateType::FOCUSED );
+
+ if ( IsVisible() )
+ {
+ rStateSet.AddState( AccessibleStateType::VISIBLE );
+ rStateSet.AddState( AccessibleStateType::SHOWING );
+ }
+
+ rStateSet.AddState( AccessibleStateType::OPAQUE );
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleComponent
+// -----------------------------------------------------------------------------
+
+awt::Rectangle OAccessibleMenuComponent::implGetBounds() throw (RuntimeException)
+{
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+
+ if ( m_pMenu )
+ {
+ Window* pWindow = m_pMenu->GetWindow();
+ if ( pWindow )
+ {
+ // get bounding rectangle of the window in screen coordinates
+ Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL );
+ aBounds = AWTRectangle( aRect );
+
+ // get position of the accessible parent in screen coordinates
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComponent.is() )
+ {
+ awt::Point aParentScreenLoc = xParentComponent->getLocationOnScreen();
+
+ // calculate position of the window relative to the accessible parent
+ aBounds.X -= aParentScreenLoc.X;
+ aBounds.Y -= aParentScreenLoc.Y;
+ }
+ }
+ }
+ }
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleMenuComponent, OAccessibleMenuBaseComponent, OAccessibleMenuComponent_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleMenuComponent, OAccessibleMenuBaseComponent, OAccessibleMenuComponent_BASE )
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuComponent::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetChildCount();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuComponent::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= GetChildCount() )
+ throw IndexOutOfBoundsException();
+
+ return GetChild( i );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuComponent::getAccessibleParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xParent;
+
+ if ( m_pMenu )
+ {
+ Window* pWindow = m_pMenu->GetWindow();
+ if ( pWindow )
+ {
+ Window* pParent = pWindow->GetAccessibleParentWindow();
+ if ( pParent )
+ xParent = pParent->GetAccessible();
+ }
+ }
+
+ return xParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 OAccessibleMenuComponent::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::UNKNOWN;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuComponent::getAccessibleDescription( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sDescription;
+ if ( m_pMenu )
+ {
+ Window* pWindow = m_pMenu->GetWindow();
+ if ( pWindow )
+ sDescription = pWindow->GetAccessibleDescription();
+ }
+
+ return sDescription;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuComponent::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleRelationSet > OAccessibleMenuComponent::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
+}
+
+// -----------------------------------------------------------------------------
+
+Locale OAccessibleMenuComponent::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuComponent::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetChildAt( rPoint );
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Point OAccessibleMenuComponent::getLocationOnScreen( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ awt::Point aPos;
+
+ if ( m_pMenu )
+ {
+ Window* pWindow = m_pMenu->GetWindow();
+ if ( pWindow )
+ {
+ Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL );
+ aPos = AWTPoint( aRect.TopLeft() );
+ }
+ }
+
+ return aPos;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuComponent::grabFocus( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( m_pMenu )
+ {
+ Window* pWindow = m_pMenu->GetWindow();
+ if ( pWindow )
+ pWindow->GrabFocus();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuComponent::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ sal_Int32 nColor = rStyleSettings.GetMenuTextColor().GetColor();
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuComponent::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+
+Reference< awt::XFont > OAccessibleMenuComponent::getFont( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< awt::XFont > xFont;
+
+ if ( m_pMenu )
+ {
+ Window* pWindow = m_pMenu->GetWindow();
+ if ( pWindow )
+ {
+ Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), UNO_QUERY );
+ if ( xDev.is() )
+ {
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ VCLXFont* pVCLXFont = new VCLXFont;
+ pVCLXFont->Init( *xDev.get(), rStyleSettings.GetMenuFont() );
+ xFont = pVCLXFont;
+ }
+ }
+ }
+
+ return xFont;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuComponent::getTitledBorderText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuComponent::getToolTipText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleSelection
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuComponent::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
+ throw IndexOutOfBoundsException();
+
+ SelectChild( nChildIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuComponent::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
+ throw IndexOutOfBoundsException();
+
+ return IsChildSelected( nChildIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuComponent::clearAccessibleSelection( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ DeSelectAll();
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuComponent::selectAllAccessibleChildren( ) throw (RuntimeException)
+{
+ // This method makes no sense in a menu, and so does nothing.
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuComponent::getSelectedAccessibleChildCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nRet = 0;
+
+ for ( sal_Int32 i = 0, nCount = GetChildCount(); i < nCount; i++ )
+ {
+ if ( IsChildSelected( i ) )
+ ++nRet;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuComponent::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild;
+
+ for ( sal_Int32 i = 0, j = 0, nCount = GetChildCount(); i < nCount; i++ )
+ {
+ if ( IsChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
+ {
+ xChild = GetChild( i );
+ break;
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuComponent::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
+ throw IndexOutOfBoundsException();
+
+ DeSelectAll();
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/accessiblemenuitemcomponent.cxx b/accessibility/source/standard/accessiblemenuitemcomponent.cxx
new file mode 100644
index 000000000000..eac5b8fe43ec
--- /dev/null
+++ b/accessibility/source/standard/accessiblemenuitemcomponent.cxx
@@ -0,0 +1,506 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: accessiblemenuitemcomponent.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/accessiblemenuitemcomponent.hxx>
+
+
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+#include <toolkit/awt/vclxwindows.hxx>
+#include <toolkit/helper/externallock.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/accessibletexthelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/unohelp2.hxx>
+
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class OAccessibleMenuItemComponent
+// -----------------------------------------------------------------------------
+
+OAccessibleMenuItemComponent::OAccessibleMenuItemComponent( Menu* pParent, sal_uInt16 nItemPos, Menu* pMenu )
+ :OAccessibleMenuBaseComponent( pMenu )
+ ,m_pParent( pParent )
+ ,m_nItemPos( nItemPos )
+{
+ m_sAccessibleName = GetAccessibleName();
+ m_sItemText = GetItemText();
+}
+
+// -----------------------------------------------------------------------------
+
+OAccessibleMenuItemComponent::~OAccessibleMenuItemComponent()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuItemComponent::IsEnabled()
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bEnabled = sal_False;
+ if ( m_pParent )
+ bEnabled = m_pParent->IsItemEnabled( m_pParent->GetItemId( m_nItemPos ) );
+
+ return bEnabled;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OAccessibleMenuItemComponent::IsVisible()
+{
+ sal_Bool bVisible = sal_False;
+
+ if ( m_pParent )
+ bVisible = m_pParent->IsItemPosVisible( m_nItemPos );
+
+ return bVisible;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuItemComponent::Select()
+{
+ // open the parent menu
+ Reference< XAccessible > xParent( getAccessibleParent() );
+ if ( xParent.is() )
+ {
+ OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xParent.get() );
+ if ( pComp && pComp->getAccessibleRole() == AccessibleRole::MENU && !pComp->IsPopupMenuOpen() )
+ pComp->Click();
+ }
+
+ // highlight the menu item
+ if ( m_pParent )
+ m_pParent->HighlightItem( m_nItemPos );
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuItemComponent::DeSelect()
+{
+ if ( m_pParent && IsSelected() )
+ m_pParent->DeHighlight();
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuItemComponent::Click()
+{
+ // open the parent menu
+ Reference< XAccessible > xParent( getAccessibleParent() );
+ if ( xParent.is() )
+ {
+ OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xParent.get() );
+ if ( pComp && pComp->getAccessibleRole() == AccessibleRole::MENU && !pComp->IsPopupMenuOpen() )
+ pComp->Click();
+ }
+
+ // click the menu item
+ if ( m_pParent )
+ {
+ Window* pWindow = m_pParent->GetWindow();
+ if ( pWindow )
+ {
+ // #102438# Menu items are not selectable
+ // Popup menus are executed asynchronously, triggered by a timer.
+ // As Menu::SelectItem only works, if the corresponding menu window is
+ // already created, we have to set the menu delay to 0, so
+ // that the popup menus are executed synchronously.
+ AllSettings aSettings = pWindow->GetSettings();
+ MouseSettings aMouseSettings = aSettings.GetMouseSettings();
+ ULONG nDelay = aMouseSettings.GetMenuDelay();
+ aMouseSettings.SetMenuDelay( 0 );
+ aSettings.SetMouseSettings( aMouseSettings );
+ pWindow->SetSettings( aSettings );
+
+ m_pParent->SelectItem( m_pParent->GetItemId( m_nItemPos ) );
+
+ // meanwhile the window pointer may be invalid
+ pWindow = m_pParent->GetWindow();
+ if ( pWindow )
+ {
+ // set the menu delay back to the old value
+ aSettings = pWindow->GetSettings();
+ aMouseSettings = aSettings.GetMouseSettings();
+ aMouseSettings.SetMenuDelay( nDelay );
+ aSettings.SetMouseSettings( aMouseSettings );
+ pWindow->SetSettings( aSettings );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuItemComponent::SetItemPos( sal_uInt16 nItemPos )
+{
+ m_nItemPos = nItemPos;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuItemComponent::SetAccessibleName( const ::rtl::OUString& sAccessibleName )
+{
+ if ( !m_sAccessibleName.equals( sAccessibleName ) )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= m_sAccessibleName;
+ aNewValue <<= sAccessibleName;
+ m_sAccessibleName = sAccessibleName;
+ NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuItemComponent::GetAccessibleName()
+{
+ ::rtl::OUString sName;
+ if ( m_pParent )
+ {
+ sal_uInt16 nItemId = m_pParent->GetItemId( m_nItemPos );
+ sName = m_pParent->GetAccessibleName( nItemId );
+ if ( sName.getLength() == 0 )
+ sName = m_pParent->GetItemText( nItemId );
+ sName = OutputDevice::GetNonMnemonicString( sName );
+ }
+
+ return sName;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuItemComponent::SetItemText( const ::rtl::OUString& sItemText )
+{
+ Any aOldValue, aNewValue;
+ if ( OCommonAccessibleText::implInitTextChangedEvent( m_sItemText, sItemText, aOldValue, aNewValue ) )
+ {
+ m_sItemText = sItemText;
+ NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuItemComponent::GetItemText()
+{
+ ::rtl::OUString sText;
+ if ( m_pParent )
+ sText = OutputDevice::GetNonMnemonicString( m_pParent->GetItemText( m_pParent->GetItemId( m_nItemPos ) ) );
+
+ return sText;
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuItemComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ if ( IsEnabled() )
+ {
+ rStateSet.AddState( AccessibleStateType::ENABLED );
+ rStateSet.AddState( AccessibleStateType::SENSITIVE );
+ }
+
+ if ( IsVisible() )
+ {
+ rStateSet.AddState( AccessibleStateType::VISIBLE );
+ rStateSet.AddState( AccessibleStateType::SHOWING );
+ }
+
+ rStateSet.AddState( AccessibleStateType::OPAQUE );
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleComponent
+// -----------------------------------------------------------------------------
+
+awt::Rectangle OAccessibleMenuItemComponent::implGetBounds() throw (RuntimeException)
+{
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+
+ if ( m_pParent )
+ {
+ // get bounding rectangle of the item relative to the containing window
+ aBounds = AWTRectangle( m_pParent->GetBoundingRectangle( m_nItemPos ) );
+
+ // get position of containing window in screen coordinates
+ Window* pWindow = m_pParent->GetWindow();
+ if ( pWindow )
+ {
+ Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL );
+ awt::Point aWindowScreenLoc = AWTPoint( aRect.TopLeft() );
+
+ // get position of accessible parent in screen coordinates
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComponent.is() )
+ {
+ awt::Point aParentScreenLoc = xParentComponent->getLocationOnScreen();
+
+ // calculate bounding rectangle of the item relative to the accessible parent
+ aBounds.X += aWindowScreenLoc.X - aParentScreenLoc.X;
+ aBounds.Y += aWindowScreenLoc.Y - aParentScreenLoc.Y;
+ }
+ }
+ }
+ }
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OAccessibleMenuItemComponent::disposing()
+{
+ OAccessibleMenuBaseComponent::disposing();
+
+ m_pParent = NULL;
+ m_sAccessibleName = ::rtl::OUString();
+ m_sItemText = ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuItemComponent::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuItemComponent::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ return Reference< XAccessible >();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuItemComponent::getAccessibleParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return m_pParent->GetAccessible();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuItemComponent::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return m_nItemPos;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 OAccessibleMenuItemComponent::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::UNKNOWN;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuItemComponent::getAccessibleDescription( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sDescription;
+ if ( m_pParent )
+ sDescription = m_pParent->GetHelpText( m_pParent->GetItemId( m_nItemPos ) );
+
+ return sDescription;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuItemComponent::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return m_sAccessibleName;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleRelationSet > OAccessibleMenuItemComponent::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
+}
+
+// -----------------------------------------------------------------------------
+
+Locale OAccessibleMenuItemComponent::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > OAccessibleMenuItemComponent::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Reference< XAccessible >();
+}
+
+// -----------------------------------------------------------------------------
+
+void OAccessibleMenuItemComponent::grabFocus( ) throw (RuntimeException)
+{
+ // no focus for items
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuItemComponent::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ nColor = xParentComp->getForeground();
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 OAccessibleMenuItemComponent::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ nColor = xParentComp->getBackground();
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+
+Reference< awt::XFont > OAccessibleMenuItemComponent::getFont( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< awt::XFont > xFont;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ xFont = xParentComp->getFont();
+ }
+
+ return xFont;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuItemComponent::getTitledBorderText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OAccessibleMenuItemComponent::getToolTipText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sRet;
+ if ( m_pParent )
+ sRet = m_pParent->GetTipHelpText( m_pParent->GetItemId( m_nItemPos ) );
+
+ return sRet;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/floatingwindowaccessible.cxx b/accessibility/source/standard/floatingwindowaccessible.cxx
new file mode 100644
index 000000000000..aa886c7a0bce
--- /dev/null
+++ b/accessibility/source/standard/floatingwindowaccessible.cxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: floatingwindowaccessible.cxx,v $
+ *
+ * $Revision: 1.5 $
+ *
+ * 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_accessibility.hxx"
+
+#include <floatingwindowaccessible.hxx>
+
+
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <vcl/window.hxx>
+
+namespace uno = ::com::sun::star::uno;
+
+using ::com::sun::star::accessibility::AccessibleRelation;
+namespace AccessibleRelationType = ::com::sun::star::accessibility::AccessibleRelationType;
+
+//-------------------------------------------------------------------
+
+FloatingWindowAccessible::FloatingWindowAccessible(VCLXWindow* pWindow) :
+ VCLXAccessibleComponent(pWindow)
+{
+}
+
+//-------------------------------------------------------------------
+
+FloatingWindowAccessible::~FloatingWindowAccessible()
+{
+}
+
+//-------------------------------------------------------------------
+
+void FloatingWindowAccessible::FillAccessibleRelationSet(utl::AccessibleRelationSetHelper& rRelationSet)
+{
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ {
+ Window* pParentWindow = pWindow->GetParent();
+ if( pParentWindow )
+ {
+ uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
+ aSequence[0] = pParentWindow->GetAccessible();
+ rRelationSet.AddRelation( AccessibleRelation( AccessibleRelationType::SUB_WINDOW_OF, aSequence ) );
+ }
+ }
+}
diff --git a/accessibility/source/standard/makefile.mk b/accessibility/source/standard/makefile.mk
new file mode 100644
index 000000000000..f98d8a3e766a
--- /dev/null
+++ b/accessibility/source/standard/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.5 $
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=accessibility
+TARGET=standard
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/accessiblemenubasecomponent.obj \
+ $(SLO)$/accessiblemenucomponent.obj \
+ $(SLO)$/accessiblemenuitemcomponent.obj \
+ $(SLO)$/floatingwindowaccessible.obj \
+ $(SLO)$/vclxaccessiblebox.obj \
+ $(SLO)$/vclxaccessiblebutton.obj \
+ $(SLO)$/vclxaccessiblecheckbox.obj \
+ $(SLO)$/vclxaccessiblecombobox.obj \
+ $(SLO)$/vclxaccessibledropdowncombobox.obj \
+ $(SLO)$/vclxaccessibledropdownlistbox.obj \
+ $(SLO)$/vclxaccessibleedit.obj \
+ $(SLO)$/vclxaccessiblefixedhyperlink.obj \
+ $(SLO)$/vclxaccessiblefixedtext.obj \
+ $(SLO)$/vclxaccessiblelist.obj \
+ $(SLO)$/vclxaccessiblelistbox.obj \
+ $(SLO)$/vclxaccessiblelistitem.obj \
+ $(SLO)$/vclxaccessiblemenu.obj \
+ $(SLO)$/vclxaccessiblemenubar.obj \
+ $(SLO)$/vclxaccessiblemenuitem.obj \
+ $(SLO)$/vclxaccessiblemenuseparator.obj \
+ $(SLO)$/vclxaccessiblepopupmenu.obj \
+ $(SLO)$/vclxaccessibleradiobutton.obj \
+ $(SLO)$/vclxaccessiblescrollbar.obj \
+ $(SLO)$/vclxaccessiblestatusbar.obj \
+ $(SLO)$/vclxaccessiblestatusbaritem.obj \
+ $(SLO)$/vclxaccessibletabcontrol.obj \
+ $(SLO)$/vclxaccessibletabpage.obj \
+ $(SLO)$/vclxaccessibletabpagewindow.obj \
+ $(SLO)$/vclxaccessibletextcomponent.obj \
+ $(SLO)$/vclxaccessibletextfield.obj \
+ $(SLO)$/vclxaccessibletoolbox.obj \
+ $(SLO)$/vclxaccessibletoolboxitem.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/accessibility/source/standard/vclxaccessiblebox.cxx b/accessibility/source/standard/vclxaccessiblebox.cxx
new file mode 100644
index 000000000000..ad1f4ab2e01b
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblebox.cxx
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblebox.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblebox.hxx>
+#include <accessibility/standard/vclxaccessibletextfield.hxx>
+#include <accessibility/standard/vclxaccessibleedit.hxx>
+#include <accessibility/standard/vclxaccessiblelist.hxx>
+#include <accessibility/standard/vclxaccessiblelistboxlist.hxx>
+#include <accessibility/helper/listboxhelper.hxx>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <vcl/svapp.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/lstbox.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+
+VCLXAccessibleBox::VCLXAccessibleBox (VCLXWindow* pVCLWindow, BoxType aType, bool bIsDropDownBox)
+ : VCLXAccessibleComponent (pVCLWindow),
+ m_aBoxType (aType),
+ m_bIsDropDownBox (bIsDropDownBox),
+ m_nIndexInParent (DEFAULT_INDEX_IN_PARENT)
+{
+ // Set up the flags that indicate which children this object has.
+ m_bHasListChild = true;
+
+ // A text field is not present for non drop down list boxes.
+ if ((m_aBoxType==LISTBOX) && ! m_bIsDropDownBox)
+ m_bHasTextChild = false;
+ else
+ m_bHasTextChild = true;
+}
+
+VCLXAccessibleBox::~VCLXAccessibleBox (void)
+{
+}
+
+void VCLXAccessibleBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ uno::Any aOldValue, aNewValue;
+ uno::Reference<XAccessible> xAcc;
+
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_WINDOW_SHOW:
+ case VCLEVENT_WINDOW_HIDE:
+ {
+ Window* pChildWindow = (Window *) rVclWindowEvent.GetData();
+ // Just compare to the combo box text field. All other children
+ // are identical to this object in which case this object will
+ // be removed in a short time.
+ if (m_aBoxType==COMBOBOX)
+ {
+ ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
+ if ( ( pComboBox != NULL ) && ( pChildWindow != NULL ) )
+ if (pChildWindow == pComboBox->GetSubEdit())
+ {
+ if (rVclWindowEvent.GetId() == VCLEVENT_WINDOW_SHOW)
+ {
+ // Instantiate text field.
+ getAccessibleChild (0);
+ aNewValue <<= m_xText;
+ }
+ else
+ {
+ // Release text field.
+ aOldValue <<= m_xText;
+ m_xText = NULL;
+ }
+ // Tell the listeners about the new/removed child.
+ NotifyAccessibleEvent (
+ AccessibleEventId::CHILD,
+ aOldValue, aNewValue);
+ }
+
+ }
+ }
+ break;
+
+ default:
+ VCLXAccessibleComponent::ProcessWindowChildEvent (rVclWindowEvent);
+ }
+}
+
+void VCLXAccessibleBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent)
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_DROPDOWN_OPEN:
+ case VCLEVENT_DROPDOWN_CLOSE:
+ case VCLEVENT_LISTBOX_DOUBLECLICK:
+ case VCLEVENT_LISTBOX_SCROLLED:
+ case VCLEVENT_LISTBOX_SELECT:
+ case VCLEVENT_LISTBOX_ITEMADDED:
+ case VCLEVENT_LISTBOX_ITEMREMOVED:
+ case VCLEVENT_COMBOBOX_ITEMADDED:
+ case VCLEVENT_COMBOBOX_ITEMREMOVED:
+ case VCLEVENT_COMBOBOX_SCROLLED:
+ {
+ // Forward the call to the list child.
+ VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get());
+ if ( pList == NULL )
+ {
+ getAccessibleChild ( m_bHasTextChild ? 1 : 0 );
+ pList = static_cast<VCLXAccessibleList*>(m_xList.get());
+ }
+ if ( pList != NULL )
+ pList->ProcessWindowEvent (rVclWindowEvent);
+ break;
+ }
+
+ case VCLEVENT_COMBOBOX_SELECT:
+ case VCLEVENT_COMBOBOX_DESELECT:
+ {
+ // Selection is handled by VCLXAccessibleList which operates on
+ // the same VCL object as this box does. In case of the
+ // combobox, however, we have to help the list with providing
+ // the text of the currently selected item.
+ VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get());
+ if (pList != NULL && m_xText.is())
+ {
+ Reference<XAccessibleText> xText (m_xText->getAccessibleContext(), UNO_QUERY);
+ if ( xText.is() )
+ {
+ ::rtl::OUString sText = xText->getSelectedText();
+ if ( !sText.getLength() )
+ sText = xText->getText();
+ pList->UpdateSelection (sText);
+ }
+ }
+ break;
+ }
+
+ case VCLEVENT_EDIT_MODIFY:
+ case VCLEVENT_EDIT_SELECTIONCHANGED:
+ // Modify/Selection events are handled by the combo box instead of
+ // directly by the edit field (Why?). Therefore, delegate this
+ // call to the edit field.
+ if (m_aBoxType==COMBOBOX)
+ {
+ if (m_xText.is())
+ {
+ Reference<XAccessibleContext> xContext = m_xText->getAccessibleContext();
+ VCLXAccessibleEdit* pEdit = static_cast<VCLXAccessibleEdit*>(xContext.get());
+ if (pEdit != NULL)
+ pEdit->ProcessWindowEvent (rVclWindowEvent);
+ }
+ }
+ break;
+
+ default:
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleBox, VCLXAccessibleComponent, VCLXAccessibleBox_BASE)
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleBox, VCLXAccessibleComponent, VCLXAccessibleBox_BASE)
+
+//===== XAccessible =========================================================
+
+Reference< XAccessibleContext > SAL_CALL VCLXAccessibleBox::getAccessibleContext( )
+ throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ return this;
+}
+
+//===== XAccessibleContext ==================================================
+
+sal_Int32 SAL_CALL VCLXAccessibleBox::getAccessibleChildCount (void)
+ throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ // Usually a box has a text field and a list of items as its children.
+ // Non drop down list boxes have no text field. Additionally check
+ // whether the object is valid.
+ sal_Int32 nCount = 0;
+ if (IsValid())
+ nCount += (m_bHasTextChild?1:0) + (m_bHasListChild?1:0);
+ else
+ {
+ // Object not valid anymore. Release references to children.
+ m_bHasTextChild = false;
+ m_xText = NULL;
+ m_bHasListChild = false;
+ m_xList = NULL;
+ }
+
+ return nCount;
+}
+
+Reference<XAccessible> SAL_CALL VCLXAccessibleBox::getAccessibleChild (sal_Int32 i)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ if (i<0 || i>=getAccessibleChildCount())
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild;
+ if (IsValid())
+ {
+ if (i==1 || ! m_bHasTextChild)
+ {
+ // List.
+ if ( ! m_xList.is())
+ {
+ VCLXAccessibleList* pList = new VCLXAccessibleList ( GetVCLXWindow(),
+ (m_aBoxType == LISTBOX ? VCLXAccessibleList::LISTBOX : VCLXAccessibleList::COMBOBOX),
+ this);
+ pList->SetIndexInParent (i);
+ m_xList = pList;
+ }
+ xChild = m_xList;
+ }
+ else
+ {
+ // Text Field.
+ if ( ! m_xText.is())
+ {
+ if (m_aBoxType==COMBOBOX)
+ {
+ ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
+ if (pComboBox!=NULL && pComboBox->GetSubEdit()!=NULL)
+ m_xText = pComboBox->GetSubEdit()->GetAccessible();
+ }
+ else if (m_bIsDropDownBox)
+ m_xText = new VCLXAccessibleTextField (GetVCLXWindow(),this);
+ }
+ xChild = m_xText;
+ }
+ }
+
+ return xChild;
+}
+
+sal_Int16 SAL_CALL VCLXAccessibleBox::getAccessibleRole (void) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ // Return the role <const>COMBO_BOX</const> for both VCL combo boxes and
+ // VCL list boxes in DropDown-Mode else <const>PANEL</const>.
+ // This way the Java bridge has not to handle both independently.
+ return m_bIsDropDownBox ? AccessibleRole::COMBO_BOX : AccessibleRole::PANEL;
+}
+
+sal_Int32 SAL_CALL VCLXAccessibleBox::getAccessibleIndexInParent (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ if (m_nIndexInParent != DEFAULT_INDEX_IN_PARENT)
+ return m_nIndexInParent;
+ else
+ return VCLXAccessibleComponent::getAccessibleIndexInParent();
+}
+
+//===== XAccessibleAction ===================================================
+
+sal_Int32 SAL_CALL VCLXAccessibleBox::getAccessibleActionCount (void)
+ throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex> aGuard (GetMutex());
+
+ // There is one action for drop down boxes (toggle popup) and none for
+ // the other boxes.
+ return m_bIsDropDownBox ? 1 : 0;
+}
+
+sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ if (nIndex<0 || nIndex>=getAccessibleActionCount())
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+
+ if (m_aBoxType == COMBOBOX)
+ {
+ ComboBox* pComboBox = static_cast< ComboBox* >( GetWindow() );
+ if (pComboBox != NULL)
+ {
+ pComboBox->ToggleDropDown();
+ bNotify = sal_True;
+ }
+ }
+ else if (m_aBoxType == LISTBOX)
+ {
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if (pListBox != NULL)
+ {
+ pListBox->ToggleDropDown();
+ bNotify = sal_True;
+ }
+ }
+ }
+
+ if (bNotify)
+ NotifyAccessibleEvent (AccessibleEventId::ACTION_CHANGED, Any(), Any());
+
+ return bNotify;
+}
+
+::rtl::OUString SAL_CALL VCLXAccessibleBox::getAccessibleActionDescription (sal_Int32 nIndex)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+ if (nIndex<0 || nIndex>=getAccessibleActionCount())
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+ return TK_RES_STRING( RID_STR_ACC_ACTION_TOGGLEPOPUP);
+}
+
+Reference< XAccessibleKeyBinding > VCLXAccessibleBox::getAccessibleActionKeyBinding( sal_Int32 nIndex )
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ Reference< XAccessibleKeyBinding > xRet;
+
+ if (nIndex<0 || nIndex>=getAccessibleActionCount())
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+
+ // ... which key?
+ return xRet;
+}
+
+//===== XComponent ==========================================================
+
+void SAL_CALL VCLXAccessibleBox::disposing (void)
+{
+ VCLXAccessibleComponent::disposing();
+}
+
diff --git a/accessibility/source/standard/vclxaccessiblebutton.cxx b/accessibility/source/standard/vclxaccessiblebutton.cxx
new file mode 100644
index 000000000000..41f8c686bdde
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblebutton.cxx
@@ -0,0 +1,329 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblebutton.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessiblebutton.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <comphelper/accessiblekeybindinghelper.hxx>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+
+#include <vcl/button.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleButton
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleButton::VCLXAccessibleButton( VCLXWindow* pVCLWindow )
+ :VCLXAccessibleTextComponent( pVCLWindow )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleButton::~VCLXAccessibleButton()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_PUSHBUTTON_TOGGLE:
+ {
+ Any aOldValue;
+ Any aNewValue;
+
+ PushButton* pButton = (PushButton*) GetWindow();
+ if ( pButton && pButton->GetState() == STATE_CHECK )
+ aNewValue <<= AccessibleStateType::CHECKED;
+ else
+ aOldValue <<= AccessibleStateType::CHECKED;
+
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ default:
+ VCLXAccessibleTextComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleButton::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
+
+ PushButton* pButton = (PushButton*) GetWindow();
+ if ( pButton )
+ {
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+
+ if ( pButton->GetState() == STATE_CHECK )
+ rStateSet.AddState( AccessibleStateType::CHECKED );
+
+ if ( pButton->IsPressed() )
+ rStateSet.AddState( AccessibleStateType::PRESSED );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleButton, VCLXAccessibleTextComponent, VCLXAccessibleButton_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleButton, VCLXAccessibleTextComponent, VCLXAccessibleButton_BASE )
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleButton::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleButton" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleButton::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleButton" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleButton::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString aName( VCLXAccessibleTextComponent::getAccessibleName() );
+ sal_Int32 nLength = aName.getLength();
+
+ if ( nLength >= 3 && aName.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("..."), nLength - 3 ) )
+ {
+ if ( nLength == 3 )
+ {
+ // it's a browse button
+ aName = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_NAME_BROWSEBUTTON ) );
+ }
+ else
+ {
+ // remove the three trailing dots
+ aName = aName.copy( 0, nLength - 3 );
+ }
+ }
+ else if ( nLength >= 3 && aName.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("<< "), 0 ) )
+ {
+ // remove the leading symbols
+ aName = aName.copy( 3, nLength - 3 );
+ }
+ else if ( nLength >= 3 && aName.matchAsciiL( RTL_CONSTASCII_STRINGPARAM(" >>"), nLength - 3 ) )
+ {
+ // remove the trailing symbols
+ aName = aName.copy( 0, nLength - 3 );
+ }
+
+ return aName;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleAction
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleButton::getAccessibleActionCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleButton::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ PushButton* pButton = (PushButton*) GetWindow();
+ if ( pButton )
+ pButton->Click();
+
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleButton::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleKeyBinding > VCLXAccessibleButton::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper();
+ Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper;
+
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ {
+ KeyEvent aKeyEvent = pWindow->GetActivationKey();
+ KeyCode aKeyCode = aKeyEvent.GetKeyCode();
+ if ( aKeyCode.GetCode() != 0 )
+ {
+ awt::KeyStroke aKeyStroke;
+ aKeyStroke.Modifiers = 0;
+ if ( aKeyCode.IsShift() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::SHIFT;
+ if ( aKeyCode.IsMod1() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD1;
+ if ( aKeyCode.IsMod2() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD2;
+ if ( aKeyCode.IsMod3() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD3;
+ aKeyStroke.KeyCode = aKeyCode.GetCode();
+ aKeyStroke.KeyChar = aKeyEvent.GetCharCode();
+ aKeyStroke.KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() );
+ pKeyBindingHelper->AddKeyBinding( aKeyStroke );
+ }
+ }
+
+ return xKeyBinding;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleValue
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleButton::getCurrentValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+
+ PushButton* pButton = (PushButton*) GetWindow();
+ if ( pButton )
+ aValue <<= (sal_Int32) pButton->IsPressed();
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleButton::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ PushButton* pButton = (PushButton*) GetWindow();
+ if ( pButton )
+ {
+ sal_Int32 nValue = 0;
+ OSL_VERIFY( aNumber >>= nValue );
+
+ if ( nValue < 0 )
+ nValue = 0;
+ else if ( nValue > 1 )
+ nValue = 1;
+
+ pButton->SetPressed( (BOOL) nValue );
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleButton::getMaximumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ aValue <<= (sal_Int32) 1;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleButton::getMinimumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ aValue <<= (sal_Int32) 0;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblecheckbox.cxx b/accessibility/source/standard/vclxaccessiblecheckbox.cxx
new file mode 100644
index 000000000000..c6ea1603d647
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblecheckbox.cxx
@@ -0,0 +1,364 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblecheckbox.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessiblecheckbox.hxx>
+
+#include <toolkit/awt/vclxwindows.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <comphelper/accessiblekeybindinghelper.hxx>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+
+#include <vcl/button.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleCheckBox
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleCheckBox::VCLXAccessibleCheckBox( VCLXWindow* pVCLWindow )
+ :VCLXAccessibleTextComponent( pVCLWindow )
+{
+ m_bChecked = IsChecked();
+ m_bIndeterminate = IsIndeterminate();
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleCheckBox::~VCLXAccessibleCheckBox()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+bool VCLXAccessibleCheckBox::IsChecked()
+{
+ bool bChecked = false;
+
+ VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( GetVCLXWindow() );
+ if ( pVCLXCheckBox && pVCLXCheckBox->getState() == (sal_Int16) 1 )
+ bChecked = true;
+
+ return bChecked;
+}
+
+// -----------------------------------------------------------------------------
+
+bool VCLXAccessibleCheckBox::IsIndeterminate()
+{
+ bool bIndeterminate = false;
+
+ VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( GetVCLXWindow() );
+ if ( pVCLXCheckBox && pVCLXCheckBox->getState() == (sal_Int16) 2 )
+ bIndeterminate = true;
+
+ return bIndeterminate;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleCheckBox::SetChecked( bool bChecked )
+{
+ if ( m_bChecked != bChecked )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bChecked )
+ aOldValue <<= AccessibleStateType::CHECKED;
+ else
+ aNewValue <<= AccessibleStateType::CHECKED;
+ m_bChecked = bChecked;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleCheckBox::SetIndeterminate( bool bIndeterminate )
+{
+ if ( m_bIndeterminate != bIndeterminate )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bIndeterminate )
+ aOldValue <<= AccessibleStateType::INDETERMINATE;
+ else
+ aNewValue <<= AccessibleStateType::INDETERMINATE;
+ m_bIndeterminate = bIndeterminate;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_CHECKBOX_TOGGLE:
+ {
+ SetChecked( IsChecked() );
+ SetIndeterminate( IsIndeterminate() );
+ }
+ break;
+ default:
+ VCLXAccessibleTextComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleCheckBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
+
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+
+ if ( IsChecked() )
+ rStateSet.AddState( AccessibleStateType::CHECKED );
+
+ if ( IsIndeterminate() )
+ rStateSet.AddState( AccessibleStateType::INDETERMINATE );
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleCheckBox, VCLXAccessibleTextComponent, VCLXAccessibleCheckBox_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleCheckBox, VCLXAccessibleTextComponent, VCLXAccessibleCheckBox_BASE )
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleCheckBox::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleCheckBox" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleCheckBox::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleCheckBox" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleAction
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleCheckBox::getAccessibleActionCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleCheckBox::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ CheckBox* pCheckBox = (CheckBox*) GetWindow();
+ VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( GetVCLXWindow() );
+ if ( pCheckBox && pVCLXCheckBox )
+ {
+ sal_Int32 nValueMin = (sal_Int32) 0;
+ sal_Int32 nValueMax = (sal_Int32) 1;
+
+ if ( pCheckBox->IsTriStateEnabled() )
+ nValueMax = (sal_Int32) 2;
+
+ sal_Int32 nValue = (sal_Int32) pVCLXCheckBox->getState();
+
+ ++nValue;
+
+ if ( nValue > nValueMax )
+ nValue = nValueMin;
+
+ pVCLXCheckBox->setState( (sal_Int16) nValue );
+ }
+
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleCheckBox::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleKeyBinding > VCLXAccessibleCheckBox::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper();
+ Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper;
+
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ {
+ KeyEvent aKeyEvent = pWindow->GetActivationKey();
+ KeyCode aKeyCode = aKeyEvent.GetKeyCode();
+ if ( aKeyCode.GetCode() != 0 )
+ {
+ awt::KeyStroke aKeyStroke;
+ aKeyStroke.Modifiers = 0;
+ if ( aKeyCode.IsShift() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::SHIFT;
+ if ( aKeyCode.IsMod1() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD1;
+ if ( aKeyCode.IsMod2() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD2;
+ if ( aKeyCode.IsMod3() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD3;
+ aKeyStroke.KeyCode = aKeyCode.GetCode();
+ aKeyStroke.KeyChar = aKeyEvent.GetCharCode();
+ aKeyStroke.KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() );
+ pKeyBindingHelper->AddKeyBinding( aKeyStroke );
+ }
+ }
+
+ return xKeyBinding;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleValue
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleCheckBox::getCurrentValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+
+ VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( GetVCLXWindow() );
+ if ( pVCLXCheckBox )
+ aValue <<= (sal_Int32) pVCLXCheckBox->getState();
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleCheckBox::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( GetVCLXWindow() );
+ if ( pVCLXCheckBox )
+ {
+ sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0;
+ OSL_VERIFY( aNumber >>= nValue );
+ OSL_VERIFY( getMinimumValue() >>= nValueMin );
+ OSL_VERIFY( getMaximumValue() >>= nValueMax );
+
+ if ( nValue < nValueMin )
+ nValue = nValueMin;
+ else if ( nValue > nValueMax )
+ nValue = nValueMax;
+
+ pVCLXCheckBox->setState( (sal_Int16) nValue );
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleCheckBox::getMaximumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+
+ CheckBox* pCheckBox = (CheckBox*) GetWindow();
+ if ( pCheckBox && pCheckBox->IsTriStateEnabled() )
+ aValue <<= (sal_Int32) 2;
+ else
+ aValue <<= (sal_Int32) 1;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleCheckBox::getMinimumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ aValue <<= (sal_Int32) 0;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblecombobox.cxx b/accessibility/source/standard/vclxaccessiblecombobox.cxx
new file mode 100644
index 000000000000..69f87a085588
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblecombobox.cxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblecombobox.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblecombobox.hxx>
+#include <accessibility/standard/vclxaccessiblelist.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <vcl/svapp.hxx>
+#include <vcl/combobox.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+
+
+VCLXAccessibleComboBox::VCLXAccessibleComboBox (VCLXWindow* pVCLWindow)
+ : VCLXAccessibleBox (pVCLWindow, VCLXAccessibleBox::COMBOBOX, false)
+{
+}
+
+
+
+
+VCLXAccessibleComboBox::~VCLXAccessibleComboBox (void)
+{
+}
+
+
+
+
+bool VCLXAccessibleComboBox::IsValid (void) const
+{
+ return static_cast<ComboBox*>(GetWindow()) != NULL;
+
+}
+
+
+
+
+void VCLXAccessibleComboBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent)
+{
+ VCLXAccessibleBox::ProcessWindowEvent( rVclWindowEvent );
+}
+
+
+
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString VCLXAccessibleComboBox::getImplementationName (void)
+ throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii ("com.sun.star.comp.toolkit.AccessibleComboBox");
+}
+
+
+
+
+Sequence< ::rtl::OUString > VCLXAccessibleComboBox::getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames = VCLXAccessibleBox::getSupportedServiceNames();
+ sal_Int32 nLength = aNames.getLength();
+ aNames.realloc( nLength + 1 );
+ aNames[nLength] = ::rtl::OUString::createFromAscii(
+ "com.sun.star.accessibility.AccessibleComboBox" );
+ return aNames;
+}
diff --git a/accessibility/source/standard/vclxaccessibledropdowncombobox.cxx b/accessibility/source/standard/vclxaccessibledropdowncombobox.cxx
new file mode 100644
index 000000000000..24fa4367d884
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibledropdowncombobox.cxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibledropdowncombobox.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessibledropdowncombobox.hxx>
+#include <accessibility/standard/vclxaccessiblecombobox.hxx>
+#include <accessibility/standard/vclxaccessibletextfield.hxx>
+#include <accessibility/standard/vclxaccessiblelist.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/unohelp.hxx>
+
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+
+
+VCLXAccessibleDropDownComboBox::VCLXAccessibleDropDownComboBox (VCLXWindow* pVCLWindow)
+ : VCLXAccessibleBox (pVCLWindow, VCLXAccessibleBox::COMBOBOX, true)
+{
+}
+
+
+
+
+VCLXAccessibleDropDownComboBox::~VCLXAccessibleDropDownComboBox (void)
+{
+}
+
+
+
+bool VCLXAccessibleDropDownComboBox::IsValid (void) const
+{
+ return static_cast<ComboBox*>(GetWindow()) != NULL;
+
+}
+
+
+
+
+void VCLXAccessibleDropDownComboBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent)
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_DROPDOWN_OPEN:
+ case VCLEVENT_DROPDOWN_CLOSE:
+ {
+ /* // child count changed
+ Any aOldValue, aNewValue;
+ // get the listbox child
+ Reference< XAccessible > xChild;
+ if ( !xChild.is() )
+ {
+ try
+ {
+ // the listbox is the second child
+ xChild = getAccessibleChild(1);
+ }
+ catch ( IndexOutOfBoundsException& ) {}
+ catch ( RuntimeException& ) {}
+ }
+ if ( rVclWindowEvent.GetId() == VCLEVENT_DROPDOWN_OPEN )
+ aNewValue <<= xChild;
+ else
+ aOldValue <<= xChild;
+ NotifyAccessibleEvent(
+ AccessibleEventId::CHILD, aOldValue, aNewValue
+ );
+ */
+ break;
+ }
+
+ default:
+ VCLXAccessibleBox::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+
+
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString VCLXAccessibleDropDownComboBox::getImplementationName()
+ throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.toolkit.AccessibleDropDownComboBox");
+}
+
+
+
+
+Sequence< ::rtl::OUString > VCLXAccessibleDropDownComboBox::getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames = VCLXAccessibleBox::getSupportedServiceNames();
+ sal_Int32 nLength = aNames.getLength();
+ aNames.realloc( nLength + 1 );
+ aNames[nLength] = ::rtl::OUString::createFromAscii(
+ "com.sun.star.accessibility.AccessibleDropDownComboBox" );
+ return aNames;
+}
diff --git a/accessibility/source/standard/vclxaccessibledropdownlistbox.cxx b/accessibility/source/standard/vclxaccessibledropdownlistbox.cxx
new file mode 100644
index 000000000000..1245fbb1df3d
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibledropdownlistbox.cxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibledropdownlistbox.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+
+#include <accessibility/standard/vclxaccessibledropdownlistbox.hxx>
+#include <accessibility/standard/vclxaccessiblelistbox.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/unohelp.hxx>
+
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+
+
+VCLXAccessibleDropDownListBox::VCLXAccessibleDropDownListBox (VCLXWindow* pVCLWindow)
+ : VCLXAccessibleBox (pVCLWindow, VCLXAccessibleBox::LISTBOX, true)
+{
+}
+
+
+
+
+VCLXAccessibleDropDownListBox::~VCLXAccessibleDropDownListBox()
+{
+}
+
+
+
+
+bool VCLXAccessibleDropDownListBox::IsValid (void) const
+{
+ return static_cast<ListBox*>(GetWindow()) != NULL;
+
+}
+
+
+
+
+void VCLXAccessibleDropDownListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ VCLXAccessibleBox::ProcessWindowEvent (rVclWindowEvent);
+}
+
+
+
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString VCLXAccessibleDropDownListBox::getImplementationName()
+ throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.toolkit.AccessibleDropDownListBox");
+}
+
+
+
+
+Sequence< ::rtl::OUString > VCLXAccessibleDropDownListBox::getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames = VCLXAccessibleBox::getSupportedServiceNames();
+ sal_Int32 nLength = aNames.getLength();
+ aNames.realloc( nLength + 1 );
+ aNames[nLength] = ::rtl::OUString::createFromAscii(
+ "com.sun.star.accessibility.AccessibleDropDownListBox" );
+ return aNames;
+}
diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx
new file mode 100644
index 000000000000..06dd0e1e094c
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibleedit.cxx
@@ -0,0 +1,633 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibleedit.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessibleedit.hxx>
+
+#include <toolkit/awt/vclxwindows.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/edit.hxx>
+#include <sot/exchange.hxx>
+#include <sot/formats.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleEdit
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleEdit::VCLXAccessibleEdit( VCLXWindow* pVCLWindow )
+ :VCLXAccessibleTextComponent( pVCLWindow )
+{
+ m_nCaretPosition = getCaretPosition();
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleEdit::~VCLXAccessibleEdit()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleEdit::UpdateCaretPosition()
+{
+ sal_Int32 nCaretPosition = getCaretPosition();
+
+ if ( m_nCaretPosition != nCaretPosition )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= (sal_Int32) m_nCaretPosition;
+ aNewValue <<= (sal_Int32) nCaretPosition;
+ m_nCaretPosition = nCaretPosition;
+ NotifyAccessibleEvent( AccessibleEventId::CARET_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_EDIT_MODIFY:
+ {
+ SetText( implGetText() );
+ }
+ break;
+ case VCLEVENT_EDIT_SELECTIONCHANGED:
+ {
+ Window* pWindow = GetWindow();
+ if ( pWindow && pWindow->HasChildPathFocus() )
+ {
+ NotifyAccessibleEvent( AccessibleEventId::TEXT_SELECTION_CHANGED, Any(), Any() );
+ UpdateCaretPosition();
+ }
+ }
+ break;
+ default:
+ VCLXAccessibleTextComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleEdit::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
+
+ VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
+ if ( pVCLXEdit )
+ {
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+ rStateSet.AddState( AccessibleStateType::SINGLE_LINE );
+ if ( pVCLXEdit->isEditable() )
+ rStateSet.AddState( AccessibleStateType::EDITABLE );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleText
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleEdit::implGetText()
+{
+ ::rtl::OUString aText;
+
+ Edit* pEdit = static_cast< Edit* >( GetWindow() );
+ if ( pEdit )
+ {
+ aText = OutputDevice::GetNonMnemonicString( pEdit->GetText() );
+
+ if ( getAccessibleRole() == AccessibleRole::PASSWORD_TEXT )
+ {
+ xub_Unicode cEchoChar = pEdit->GetEchoChar();
+ if ( !cEchoChar )
+ cEchoChar = '*';
+ XubString sTmp;
+ aText = sTmp.Fill( (USHORT)aText.getLength(), cEchoChar );
+ }
+ }
+
+ return aText;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleEdit::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
+{
+ awt::Selection aSelection;
+ VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
+ if ( pVCLXEdit )
+ aSelection = pVCLXEdit->getSelection();
+
+ nStartIndex = aSelection.Min;
+ nEndIndex = aSelection.Max;
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleEdit, VCLXAccessibleTextComponent, VCLXAccessibleEdit_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleEdit, VCLXAccessibleTextComponent, VCLXAccessibleEdit_BASE )
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleEdit::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleEdit" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleEdit::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleEdit" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleEdit::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleEdit::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ return Reference< XAccessible >();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessibleEdit::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int16 nRole;
+ Edit* pEdit = static_cast< Edit* >( GetWindow() );
+ if ( pEdit && ( ( pEdit->GetStyle() & WB_PASSWORD ) || pEdit->GetEchoChar() ) )
+ nRole = AccessibleRole::PASSWORD_TEXT;
+ else
+ nRole = AccessibleRole::TEXT;
+
+ return nRole;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleAction
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleEdit::getAccessibleActionCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ // There is one action: activate
+ return 1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ sal_Bool bDoAction = sal_False;
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ {
+ pWindow->GrabFocus();
+ bDoAction = sal_True;
+ }
+
+ return bDoAction;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleEdit::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ static const ::rtl::OUString sAction( RTL_CONSTASCII_USTRINGPARAM( "activate" ) );
+ return sAction;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleKeyBinding > VCLXAccessibleEdit::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ return Reference< XAccessibleKeyBinding >();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleText
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleEdit::getCaretPosition( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ awt::Selection aSelection;
+ VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
+ if ( pVCLXEdit )
+ aSelection = pVCLXEdit->getSelection();
+
+ return aSelection.Max;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return setSelection( nIndex, nIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Unicode VCLXAccessibleEdit::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getCharacter( nIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< PropertyValue > VCLXAccessibleEdit::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getCharacterAttributes( nIndex, aRequestedAttributes );
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Rectangle VCLXAccessibleEdit::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+ sal_Int32 nLength = implGetText().getLength();
+
+ if ( !implIsValidRange( nIndex, nIndex, nLength ) )
+ throw IndexOutOfBoundsException();
+
+ Control* pControl = static_cast< Control* >( GetWindow() );
+ if ( pControl )
+ {
+ if ( nIndex == nLength )
+ {
+ // #108914# calculate virtual bounding rectangle
+ for ( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ Rectangle aRect = pControl->GetCharacterBounds( i );
+ sal_Int32 nHeight = aRect.GetHeight();
+ if ( aBounds.Height < nHeight )
+ {
+ aBounds.Y = aRect.Top();
+ aBounds.Height = nHeight;
+ }
+ if ( i == nLength - 1 )
+ {
+ aBounds.X = aRect.Right() + 1;
+ aBounds.Width = 1;
+ }
+ }
+ }
+ else
+ {
+ aBounds = AWTRectangle( pControl->GetCharacterBounds( nIndex ) );
+ }
+ }
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleEdit::getCharacterCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getCharacterCount();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleEdit::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getIndexAtPoint( aPoint );
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleEdit::getSelectedText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getSelectedText();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleEdit::getSelectionStart( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getSelectionStart();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleEdit::getSelectionEnd( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getSelectionEnd();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+ ::rtl::OUString sText( implGetText() );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
+ Edit* pEdit = static_cast< Edit* >( GetWindow() );
+ if ( pVCLXEdit && pEdit && pEdit->IsEnabled() )
+ {
+ pVCLXEdit->setSelection( awt::Selection( nStartIndex, nEndIndex ) );
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleEdit::getText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getText();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleEdit::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getTextRange( nStartIndex, nEndIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleEdit::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getTextAtIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleEdit::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getTextBeforeIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleEdit::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::getTextBehindIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return VCLXAccessibleTextComponent::copyText( nStartIndex, nEndIndex );
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleEditableText
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return copyText( nStartIndex, nEndIndex ) && deleteText( nStartIndex, nEndIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::pasteText( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ if ( GetWindow() )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ Reference< datatransfer::XTransferable > xDataObj = xClipboard->getContents();
+ Application::AcquireSolarMutex( nRef );
+ if ( xDataObj.is() )
+ {
+ datatransfer::DataFlavor aFlavor;
+ SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
+ if ( xDataObj->isDataFlavorSupported( aFlavor ) )
+ {
+ Any aData = xDataObj->getTransferData( aFlavor );
+ ::rtl::OUString sText;
+ aData >>= sText;
+ bReturn = replaceText( nIndex, nIndex, sText );
+ }
+ }
+ }
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return replaceText( nStartIndex, nEndIndex, ::rtl::OUString() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::insertText( const ::rtl::OUString& sText, sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return replaceText( nIndex, nIndex, sText );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const ::rtl::OUString& sReplacement ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+ ::rtl::OUString sText( implGetText() );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ sal_Int32 nMinIndex = ::std::min( nStartIndex, nEndIndex );
+ sal_Int32 nMaxIndex = ::std::max( nStartIndex, nEndIndex );
+
+ VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() );
+ if ( pVCLXEdit && pVCLXEdit->isEditable() )
+ {
+ pVCLXEdit->setText( sText.replaceAt( nMinIndex, nMaxIndex - nMinIndex, sReplacement ) );
+ sal_Int32 nIndex = nMinIndex + sReplacement.getLength();
+ setSelection( nIndex, nIndex );
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const Sequence<PropertyValue>& ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False; // attributes cannot be set for an edit
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleEdit::setText( const ::rtl::OUString& sText ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ bSuccess = replaceText( 0, implGetText().getLength(), sText );
+ }
+ catch( const IndexOutOfBoundsException& )
+ {
+ OSL_ENSURE( sal_False, "VCLXAccessibleText::setText: caught an exception!" );
+ }
+ return bSuccess;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblefixedhyperlink.cxx b/accessibility/source/standard/vclxaccessiblefixedhyperlink.cxx
new file mode 100644
index 000000000000..29c71b260e34
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblefixedhyperlink.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblefixedhyperlink.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessiblefixedhyperlink.hxx>
+
+using namespace ::com::sun::star;
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleFixedHyperlink
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleFixedHyperlink::VCLXAccessibleFixedHyperlink( VCLXWindow* pVCLWindow )
+ :VCLXAccessibleTextComponent( pVCLWindow )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleFixedHyperlink::~VCLXAccessibleFixedHyperlink()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleFixedHyperlink::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleFixedHyperlink::implGetLineBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
+{
+ // TODO
+ OCommonAccessibleText::implGetLineBoundary( rBoundary, nIndex );
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleFixedHyperlink::getImplementationName() throw (uno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleFixedHyperlink" );
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > VCLXAccessibleFixedHyperlink::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleFixedHyperlink" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+
diff --git a/accessibility/source/standard/vclxaccessiblefixedtext.cxx b/accessibility/source/standard/vclxaccessiblefixedtext.cxx
new file mode 100644
index 000000000000..11a9fe527367
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblefixedtext.cxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblefixedtext.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessiblefixedtext.hxx>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <vcl/fixed.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleFixedText
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleFixedText::VCLXAccessibleFixedText( VCLXWindow* pVCLWindow )
+ :VCLXAccessibleTextComponent( pVCLWindow )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleFixedText::~VCLXAccessibleFixedText()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleFixedText::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
+
+ if ( GetWindow() && GetWindow()->GetStyle() & WB_WORDBREAK )
+ rStateSet.AddState( AccessibleStateType::MULTI_LINE );
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleFixedText::implGetLineBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
+{
+ // TODO
+ OCommonAccessibleText::implGetLineBoundary( rBoundary, nIndex );
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleFixedText::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleFixedText" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleFixedText::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleFixedText" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx
new file mode 100644
index 000000000000..4651903820be
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblelist.cxx
@@ -0,0 +1,857 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblelist.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblelist.hxx>
+#include <accessibility/standard/vclxaccessiblelistitem.hxx>
+#include <accessibility/helper/listboxhelper.hxx>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <vcl/svapp.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/lstbox.hxx>
+#include <toolkit/helper/convert.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+using namespace ::accessibility;
+
+namespace
+{
+ void checkSelection_Impl( sal_Int32 _nIndex, const IComboListBoxHelper& _rListBox, sal_Bool bSelected )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException)
+ {
+ sal_Int32 nCount = bSelected ? (sal_Int32)_rListBox.GetSelectEntryCount()
+ : (sal_Int32)_rListBox.GetEntryCount();
+ if ( _nIndex < 0 || _nIndex >= nCount )
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+ }
+}
+
+VCLXAccessibleList::VCLXAccessibleList (VCLXWindow* pVCLWindow, BoxType aBoxType,
+ const Reference< XAccessible >& _xParent)
+ : VCLXAccessibleComponent (pVCLWindow),
+ m_aBoxType (aBoxType),
+ m_nVisibleLineCount (0),
+ m_nIndexInParent (DEFAULT_INDEX_IN_PARENT),
+ m_nLastTopEntry ( 0 ),
+ m_nLastSelectedPos ( LISTBOX_ENTRY_NOTFOUND ),
+ m_bDisableProcessEvent ( false ),
+ m_bVisible ( true ),
+ m_xParent ( _xParent )
+{
+ // Because combo boxes and list boxes have the no common interface for
+ // methods with identical signature we have to write down twice the
+ // same code.
+ switch (m_aBoxType)
+ {
+ case COMBOBOX:
+ {
+ ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
+ if ( pBox != NULL )
+ m_pListBoxHelper = new VCLListBoxHelper<ComboBox> (*pBox);
+ break;
+ }
+
+ case LISTBOX:
+ {
+ ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ if ( pBox != NULL )
+ m_pListBoxHelper = new VCLListBoxHelper<ListBox> (*pBox);
+ break;
+ }
+ }
+ UpdateVisibleLineCount();
+
+ USHORT nCount = static_cast<USHORT>(getAccessibleChildCount());
+ m_aAccessibleChildren.reserve(nCount);
+}
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleList::~VCLXAccessibleList (void)
+{
+ delete m_pListBoxHelper;
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleList::SetIndexInParent (sal_Int32 nIndex)
+{
+ m_nIndexInParent = nIndex;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL VCLXAccessibleList::disposing (void)
+{
+ VCLXAccessibleComponent::disposing();
+
+ // Dispose all items in the list.
+ clearItems();
+
+ delete m_pListBoxHelper;
+ m_pListBoxHelper = NULL;
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleList::clearItems()
+{
+// ListItems::iterator aEnd = m_aAccessibleChildren.end();
+// for (ListItems::iterator aIter = m_aAccessibleChildren.begin(); aIter != aEnd; ++aIter)
+// ::comphelper::disposeComponent(*aIter);
+
+ // Clear the list itself and delete all the rest.
+ ListItems().swap(m_aAccessibleChildren); // clear and minimize
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleList::FillAccessibleStateSet (utl::AccessibleStateSetHelper& rStateSet)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+
+ VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
+ // check if our list should be visible
+ if ( m_pListBoxHelper
+ && (m_pListBoxHelper->GetStyle() & WB_DROPDOWN ) == WB_DROPDOWN
+ && !m_pListBoxHelper->IsInDropDown() )
+ {
+ rStateSet.RemoveState (AccessibleStateType::VISIBLE);
+ rStateSet.RemoveState (AccessibleStateType::SHOWING);
+ m_bVisible = false;
+ }
+
+ // Both the combo box and list box are handled identical in the
+ // following but for some reason they don't have a common interface for
+ // the methods used.
+ if ( m_pListBoxHelper )
+ {
+ if ( m_pListBoxHelper->IsMultiSelectionEnabled() )
+ rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE);
+ rStateSet.AddState (AccessibleStateType::FOCUSABLE);
+ // All children are transient.
+ rStateSet.AddState (AccessibleStateType::MANAGES_DESCENDANTS);
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleList::notifyVisibleStates(sal_Bool _bSetNew )
+{
+ m_bVisible = _bSetNew ? true : false;
+ Any aOldValue, aNewValue;
+ (_bSetNew ? aNewValue : aOldValue ) <<= AccessibleStateType::VISIBLE;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ (_bSetNew ? aNewValue : aOldValue ) <<= AccessibleStateType::SHOWING;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+
+ ListItems::iterator aIter = m_aAccessibleChildren.begin();
+ ListItems::iterator aEnd = m_aAccessibleChildren.end();
+ UpdateVisibleLineCount();
+ // adjust the index inside the VCLXAccessibleListItem
+ for (;aIter != aEnd ; ++aIter)
+ {
+ Reference< XAccessible > xHold = *aIter;
+ VCLXAccessibleListItem* pItem = static_cast<VCLXAccessibleListItem*>(xHold.get());
+ if ( pItem )
+ {
+ USHORT nTopEntry = 0;
+ if ( m_pListBoxHelper )
+ nTopEntry = m_pListBoxHelper->GetTopEntry();
+ USHORT nPos = (USHORT)(aIter - m_aAccessibleChildren.begin());
+ sal_Bool bVisible = ( nPos>=nTopEntry && nPos<( nTopEntry + m_nVisibleLineCount ) );
+ pItem->SetVisible( m_bVisible && bVisible );
+ }
+
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleList::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent)
+{
+ // Create a reference to this object to prevent an early release of the
+ // listbox (VCLEVENT_OBJECT_DYING).
+ Reference< XAccessible > xTemp = this;
+
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_DROPDOWN_OPEN:
+ notifyVisibleStates(sal_True);
+ break;
+ case VCLEVENT_DROPDOWN_CLOSE:
+ notifyVisibleStates(sal_False);
+ break;
+ case VCLEVENT_LISTBOX_SCROLLED:
+ case VCLEVENT_COMBOBOX_SCROLLED:
+ UpdateEntryRange_Impl();
+ break;
+
+ case VCLEVENT_LISTBOX_SELECT:
+ if ( !m_bDisableProcessEvent )
+ UpdateSelection_Impl();
+ break;
+ // The selection events VCLEVENT_COMBOBOX_SELECT and
+ // VCLEVENT_COMBOBOX_DESELECT are not handled here because here we
+ // have no access to the edit field. Its text is necessary to
+ // identify the currently selected item.
+
+ case VCLEVENT_OBJECT_DYING:
+ {
+ dispose();
+
+ VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent);
+ break;
+ }
+
+ case VCLEVENT_LISTBOX_ITEMREMOVED:
+ case VCLEVENT_COMBOBOX_ITEMREMOVED:
+ HandleChangedItemList (false, reinterpret_cast<sal_IntPtr>(
+ rVclWindowEvent.GetData()));
+ break;
+
+ case VCLEVENT_LISTBOX_ITEMADDED:
+ case VCLEVENT_COMBOBOX_ITEMADDED:
+ HandleChangedItemList (true, reinterpret_cast<sal_IntPtr>(
+ rVclWindowEvent.GetData()));
+ break;
+ case VCLEVENT_CONTROL_GETFOCUS:
+ VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent);
+ if ( m_pListBoxHelper )
+ {
+ uno::Any aOldValue,
+ aNewValue;
+ USHORT nPos = m_pListBoxHelper->GetSelectEntryPos();
+ if ( nPos == LISTBOX_ENTRY_NOTFOUND )
+ nPos = m_pListBoxHelper->GetTopEntry();
+ if ( nPos != LISTBOX_ENTRY_NOTFOUND )
+ aNewValue <<= CreateChild(nPos);
+
+ NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED,
+ aOldValue,
+ aNewValue );
+ }
+ break;
+
+ default:
+ VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent);
+ }
+}
+// -----------------------------------------------------------------------------
+
+/** To find out which item is currently selected and to update the SELECTED
+ state of the associated accessibility objects accordingly we exploit the
+ fact that the
+*/
+void VCLXAccessibleList::UpdateSelection (::rtl::OUString sTextOfSelectedItem)
+{
+ if ( m_aBoxType == COMBOBOX )
+ {
+ ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
+ if ( pBox != NULL )
+ {
+ // Find the index of the selected item inside the VCL control...
+ USHORT nIndex = pBox->GetEntryPos (XubString(sTextOfSelectedItem));
+ // ...and then find the associated accessibility object.
+ if ( nIndex == LISTBOX_ENTRY_NOTFOUND )
+ nIndex = 0;
+ UpdateSelection_Impl(nIndex);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleList::adjustEntriesIndexInParent(ListItems::iterator& _aBegin,::std::mem_fun_t<bool,VCLXAccessibleListItem>& _rMemFun)
+{
+ ListItems::iterator aIter = _aBegin;
+ ListItems::iterator aEnd = m_aAccessibleChildren.end();
+ // adjust the index inside the VCLXAccessibleListItem
+ for (;aIter != aEnd ; ++aIter)
+ {
+ Reference< XAccessible > xHold = *aIter;
+ VCLXAccessibleListItem* pItem = static_cast<VCLXAccessibleListItem*>(xHold.get());
+ if ( pItem )
+ _rMemFun(pItem);
+ }
+}
+// -----------------------------------------------------------------------------
+
+Reference<XAccessible> VCLXAccessibleList::CreateChild (sal_Int32 i)
+{
+ Reference<XAccessible> xChild;
+
+ USHORT nPos = static_cast<USHORT>(i);
+ if ( nPos >= m_aAccessibleChildren.size() )
+ {
+ m_aAccessibleChildren.resize(nPos + 1);
+
+ // insert into the container
+ xChild = new VCLXAccessibleListItem(m_pListBoxHelper, i, this);
+ m_aAccessibleChildren[nPos] = xChild;
+ }
+ else
+ {
+ xChild = m_aAccessibleChildren[nPos];
+ // check if position is empty and can be used else we have to adjust all entries behind this
+ if ( xChild.is() )
+ {
+ ListItems::iterator aIter = m_aAccessibleChildren.begin() + nPos;
+ ::std::mem_fun_t<bool, VCLXAccessibleListItem> aTemp(&VCLXAccessibleListItem::IncrementIndexInParent);
+ adjustEntriesIndexInParent( aIter, aTemp);
+ }
+ else
+ {
+ xChild = new VCLXAccessibleListItem(m_pListBoxHelper, i, this);
+ m_aAccessibleChildren[nPos] = xChild;
+ }
+ }
+
+ if ( xChild.is() )
+ {
+ // Just add the SELECTED state.
+ BOOL bNowSelected = FALSE;
+ if ( m_pListBoxHelper )
+ bNowSelected = m_pListBoxHelper->IsEntryPosSelected ((USHORT)i);
+ VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >(xChild.get());
+ pItem->SetSelected( bNowSelected );
+
+ // Set the child's VISIBLE state.
+ UpdateVisibleLineCount();
+ USHORT nTopEntry = 0;
+ if ( m_pListBoxHelper )
+ nTopEntry = m_pListBoxHelper->GetTopEntry();
+ sal_Bool bVisible = ( nPos>=nTopEntry && nPos<( nTopEntry + m_nVisibleLineCount ) );
+ pItem->SetVisible( m_bVisible && bVisible );
+ }
+
+ return xChild;
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleList::HandleChangedItemList (bool bItemInserted, sal_Int32 nIndex)
+{
+ if ( !bItemInserted )
+ {
+ if ( nIndex == -1 ) // special handling here
+ {
+ clearItems();
+ }
+ else
+ {
+ if ( nIndex >= 0 && static_cast<USHORT>(nIndex) < m_aAccessibleChildren.size() )
+ {
+ ListItems::iterator aIter = m_aAccessibleChildren.erase(m_aAccessibleChildren.begin()+nIndex);
+ ::std::mem_fun_t<bool, VCLXAccessibleListItem> aTemp(&VCLXAccessibleListItem::DecrementIndexInParent);
+ adjustEntriesIndexInParent( aIter, aTemp );
+ }
+ }
+ }
+ else
+ getAccessibleChild(nIndex);
+
+ NotifyAccessibleEvent (
+ AccessibleEventId::INVALIDATE_ALL_CHILDREN,
+ Any(), Any());
+}
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleList, VCLXAccessibleComponent, VCLXAccessibleList_BASE)
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleList, VCLXAccessibleComponent, VCLXAccessibleList_BASE)
+
+//===== XAccessible =========================================================
+
+Reference<XAccessibleContext> SAL_CALL
+ VCLXAccessibleList::getAccessibleContext (void)
+ throw (RuntimeException)
+{
+ return this;
+}
+// -----------------------------------------------------------------------------
+
+//===== XAccessibleContext ==================================================
+
+sal_Int32 SAL_CALL VCLXAccessibleList::getAccessibleChildCount (void)
+ throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ sal_Int32 nCount = 0;
+ if ( m_pListBoxHelper )
+ nCount = m_pListBoxHelper->GetEntryCount();
+
+ return nCount;
+}
+// -----------------------------------------------------------------------------
+
+Reference<XAccessible> SAL_CALL VCLXAccessibleList::getAccessibleChild (sal_Int32 i)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild;
+ // search for the child
+ if ( static_cast<USHORT>(i) >= m_aAccessibleChildren.size() )
+ xChild = CreateChild (i);
+ else
+ {
+ xChild = m_aAccessibleChildren[i];
+ if ( !xChild.is() )
+ xChild = CreateChild (i);
+ }
+ OSL_ENSURE( xChild.is(), "VCLXAccessibleList::getAccessibleChild: returning empty child!" );
+ return xChild;
+}
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL VCLXAccessibleList::getAccessibleParent( )
+ throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ return m_xParent;
+}
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL VCLXAccessibleList::getAccessibleIndexInParent (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ if (m_nIndexInParent != DEFAULT_INDEX_IN_PARENT)
+ return m_nIndexInParent;
+ else
+ return VCLXAccessibleComponent::getAccessibleIndexInParent();
+}
+// -----------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL VCLXAccessibleList::getAccessibleRole (void)
+ throw (RuntimeException)
+{
+ return AccessibleRole::LIST;
+}
+// -----------------------------------------------------------------------------
+
+//===== XAccessibleComponent ================================================
+
+sal_Bool SAL_CALL VCLXAccessibleList::contains( const awt::Point& rPoint ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ sal_Bool bInside = sal_False;
+
+ Window* pListBox = GetWindow();
+ if ( pListBox )
+ {
+ Rectangle aRect( Point(0,0), pListBox->GetSizePixel() );
+ bInside = aRect.IsInside( VCLPoint( rPoint ) );
+ }
+
+ return bInside;
+}
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL VCLXAccessibleList::getAccessibleAt( const awt::Point& rPoint )
+ throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ Reference< XAccessible > xChild;
+ if ( m_pListBoxHelper )
+ {
+ UpdateVisibleLineCount();
+ if ( contains( rPoint ) && m_nVisibleLineCount > 0 )
+ {
+ Point aPos = VCLPoint( rPoint );
+ USHORT nEndPos = m_pListBoxHelper->GetTopEntry() + (USHORT)m_nVisibleLineCount;
+ for ( USHORT i = m_pListBoxHelper->GetTopEntry(); i < nEndPos; ++i )
+ {
+ if ( m_pListBoxHelper->GetBoundingRectangle(i).IsInside( aPos ) )
+ {
+ xChild = getAccessibleChild(i);
+ break;
+ }
+ }
+ }
+ }
+
+ return xChild;
+}
+// -----------------------------------------------------------------------------
+
+//===== XServiceInfo ==========================================================
+
+::rtl::OUString VCLXAccessibleList::getImplementationName (void)
+ throw (RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.toolkit.AccessibleList"));
+}
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleList::getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames = VCLXAccessibleComponent::getSupportedServiceNames();
+ sal_Int32 nLength = aNames.getLength();
+ aNames.realloc( nLength + 1 );
+ aNames[nLength] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleList"));
+ return aNames;
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleList::UpdateVisibleLineCount()
+{
+ if ( m_pListBoxHelper )
+ {
+ if ( (m_pListBoxHelper->GetStyle() & WB_DROPDOWN ) == WB_DROPDOWN )
+ m_nVisibleLineCount = m_pListBoxHelper->GetDisplayLineCount();
+ else
+ {
+ USHORT nCols = 0,
+ nLines = 0;
+ m_pListBoxHelper->GetMaxVisColumnsAndLines (nCols, nLines);
+ m_nVisibleLineCount = nLines;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void VCLXAccessibleList::UpdateEntryRange_Impl()
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ sal_Int32 nTop = m_nLastTopEntry;
+
+ if ( m_pListBoxHelper )
+ nTop = m_pListBoxHelper->GetTopEntry();
+ if ( nTop != m_nLastTopEntry )
+ {
+ UpdateVisibleLineCount();
+ sal_Int32 nBegin = Min( m_nLastTopEntry, nTop );
+ sal_Int32 nEnd = Max( m_nLastTopEntry + m_nVisibleLineCount, nTop + m_nVisibleLineCount );
+ for (USHORT i = static_cast<USHORT>(nBegin); (i <= static_cast<USHORT>(nEnd)); ++i)
+ {
+ sal_Bool bVisible = ( i >= nTop && i < ( nTop + m_nVisibleLineCount ) );
+ Reference< XAccessible > xHold;
+ if ( i < m_aAccessibleChildren.size() )
+ xHold = m_aAccessibleChildren[i];
+ else if ( bVisible )
+ xHold = CreateChild(i);
+
+ if ( xHold.is() )
+ static_cast< VCLXAccessibleListItem* >( xHold.get() )->SetVisible( m_bVisible && bVisible );
+ }
+ }
+
+ m_nLastTopEntry = nTop;
+}
+// -----------------------------------------------------------------------------
+BOOL VCLXAccessibleList::checkEntrySelected(USHORT _nPos,Any& _rNewValue,Reference< XAccessible >& _rxNewAcc)
+{
+ OSL_ENSURE(m_pListBoxHelper,"Helper is not valid!");
+ BOOL bNowSelected = FALSE;
+ if ( m_pListBoxHelper )
+ {
+ bNowSelected = m_pListBoxHelper->IsEntryPosSelected (_nPos);
+ if ( bNowSelected )
+ {
+ _rxNewAcc = CreateChild(_nPos);
+ _rNewValue <<= _rxNewAcc;
+ }
+ }
+ return bNowSelected;
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleList::UpdateSelection_Impl(USHORT)
+{
+ uno::Any aOldValue, aNewValue;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+ Reference< XAccessible > xNewAcc;
+
+ if ( m_pListBoxHelper )
+ {
+ USHORT i=0;
+ for ( ListItems::iterator aIter = m_aAccessibleChildren.begin();
+ aIter != m_aAccessibleChildren.end(); ++aIter,++i)
+ {
+ Reference< XAccessible > xHold = *aIter;
+ if ( xHold.is() )
+ {
+ VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >( xHold.get() );
+ // Retrieve the item's index from the list entry.
+ BOOL bNowSelected = m_pListBoxHelper->IsEntryPosSelected (i);
+
+ if ( bNowSelected && !pItem->IsSelected() )
+ {
+ xNewAcc = *aIter;
+ aNewValue <<= xNewAcc;
+ }
+ else if ( pItem->IsSelected() )
+ m_nLastSelectedPos = i;
+
+ pItem->SetSelected( bNowSelected );
+ }
+ else
+ { // it could happen that a child was not created before
+ checkEntrySelected(i,aNewValue,xNewAcc);
+ }
+ }
+ USHORT nCount = m_pListBoxHelper->GetEntryCount();
+ if ( i < nCount ) // here we have to check the if any other listbox entry is selected
+ {
+ for (; i < nCount && !checkEntrySelected(i,aNewValue,xNewAcc) ;++i )
+ ;
+ }
+ if ( xNewAcc.is() && GetWindow()->HasFocus() )
+ {
+ if ( m_nLastSelectedPos != LISTBOX_ENTRY_NOTFOUND )
+ aOldValue <<= getAccessibleChild( (sal_Int32)m_nLastSelectedPos );
+ aNewValue <<= xNewAcc;
+ }
+ }
+ }
+
+ if ( aNewValue.hasValue() || aOldValue.hasValue() )
+ NotifyAccessibleEvent(
+ AccessibleEventId::ACTIVE_DESCENDANT_CHANGED,
+ aOldValue,
+ aNewValue );
+
+ NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleSelection
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleList::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ if ( m_pListBoxHelper )
+ {
+ checkSelection_Impl(nChildIndex,*m_pListBoxHelper,sal_False);
+
+ m_pListBoxHelper->SelectEntryPos( (USHORT)nChildIndex, TRUE );
+ // call the select handler, don't handle events in this time
+ m_bDisableProcessEvent = true;
+ m_pListBoxHelper->Select();
+ m_bDisableProcessEvent = false;
+ bNotify = sal_True;
+ }
+ }
+
+ if ( bNotify )
+ UpdateSelection_Impl();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleList::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ sal_Bool bRet = sal_False;
+ if ( m_pListBoxHelper )
+ {
+ checkSelection_Impl(nChildIndex,*m_pListBoxHelper,sal_False);
+
+ bRet = m_pListBoxHelper->IsEntryPosSelected( (USHORT)nChildIndex );
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleList::clearAccessibleSelection( ) throw (RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ if ( m_pListBoxHelper )
+ {
+ m_pListBoxHelper->SetNoSelection();
+ bNotify = sal_True;
+ }
+ }
+
+ if ( bNotify )
+ UpdateSelection_Impl();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleList::selectAllAccessibleChildren( ) throw (RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ if ( m_pListBoxHelper )
+ {
+ USHORT nCount = m_pListBoxHelper->GetEntryCount();
+ for ( USHORT i = 0; i < nCount; ++i )
+ m_pListBoxHelper->SelectEntryPos( i, TRUE );
+ // call the select handler, don't handle events in this time
+ m_bDisableProcessEvent = true;
+ m_pListBoxHelper->Select();
+ m_bDisableProcessEvent = false;
+ bNotify = sal_True;
+ }
+ }
+
+ if ( bNotify )
+ UpdateSelection_Impl();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleList::getSelectedAccessibleChildCount( ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ sal_Int32 nCount = 0;
+ if ( m_pListBoxHelper )
+ nCount = m_pListBoxHelper->GetSelectEntryCount();
+ return nCount;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleList::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ if ( m_pListBoxHelper )
+ {
+ checkSelection_Impl(nSelectedChildIndex,*m_pListBoxHelper,sal_True);
+ return getAccessibleChild( (sal_Int32)m_pListBoxHelper->GetSelectEntryPos( (USHORT)nSelectedChildIndex ) );
+ }
+
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleList::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ if ( m_pListBoxHelper )
+ {
+ checkSelection_Impl(nSelectedChildIndex,*m_pListBoxHelper,sal_False);
+
+ m_pListBoxHelper->SelectEntryPos( (USHORT)nSelectedChildIndex, FALSE );
+ // call the select handler, don't handle events in this time
+ m_bDisableProcessEvent = true;
+ m_pListBoxHelper->Select();
+ m_bDisableProcessEvent = false;
+ bNotify = sal_True;
+ }
+ }
+
+ if ( bNotify )
+ UpdateSelection_Impl();
+}
+// -----------------------------------------------------------------------------
+// accessibility::XAccessibleComponent
+awt::Rectangle VCLXAccessibleList::implGetBounds() throw (uno::RuntimeException)
+{
+ awt::Rectangle aBounds ( 0, 0, 0, 0 );
+ if ( m_pListBoxHelper
+ && (m_pListBoxHelper->GetStyle() & WB_DROPDOWN ) == WB_DROPDOWN )
+ {
+ if ( m_pListBoxHelper->IsInDropDown() )
+ aBounds = AWTRectangle(m_pListBoxHelper->GetDropDownPosSizePixel());
+ }
+ else
+ {
+ // a list has the same bounds as his parent but starts at (0,0)
+ aBounds = VCLXAccessibleComponent::implGetBounds();
+ aBounds.X = 0;
+ aBounds.Y = 0;
+ if ( m_aBoxType == COMBOBOX )
+ {
+ ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
+ if ( pBox )
+ {
+ Size aSize = pBox->GetSubEdit()->GetSizePixel();
+ aBounds.X += aSize.Height();
+ aBounds.Y += aSize.Width();
+ aBounds.Height -= aSize.Height();
+ aBounds.Width -= aSize.Width();
+ }
+ }
+ }
+ return aBounds;
+}
+// -----------------------------------------------------------------------------
+
+awt::Point VCLXAccessibleList::getLocationOnScreen( ) throw (uno::RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ awt::Point aPos;
+ if ( m_pListBoxHelper
+ && (m_pListBoxHelper->GetStyle() & WB_DROPDOWN ) == WB_DROPDOWN )
+ {
+ if ( m_pListBoxHelper->IsInDropDown() )
+ aPos = AWTPoint(m_pListBoxHelper->GetDropDownPosSizePixel().TopLeft());
+ }
+ else
+ {
+ aPos = VCLXAccessibleComponent::getLocationOnScreen();
+ if ( m_aBoxType == COMBOBOX )
+ {
+ ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
+ if ( pBox )
+ {
+ aPos.X += pBox->GetSubEdit()->GetSizePixel().Height();
+ aPos.Y += pBox->GetSubEdit()->GetSizePixel().Width();
+ }
+ }
+ }
+ return aPos;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/accessibility/source/standard/vclxaccessiblelistbox.cxx b/accessibility/source/standard/vclxaccessiblelistbox.cxx
new file mode 100644
index 000000000000..96b91a91161c
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblelistbox.cxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblelistbox.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblelistbox.hxx>
+#include <accessibility/standard/vclxaccessiblelistitem.hxx>
+#include <accessibility/helper/listboxhelper.hxx>
+
+#include <algorithm>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/unohelp.hxx>
+
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+
+VCLXAccessibleListBox::VCLXAccessibleListBox (VCLXWindow* pVCLWindow)
+ : VCLXAccessibleBox (pVCLWindow, VCLXAccessibleBox::LISTBOX, false)
+{
+}
+
+
+
+
+VCLXAccessibleListBox::~VCLXAccessibleListBox (void)
+{
+}
+
+
+
+
+bool VCLXAccessibleListBox::IsValid (void) const
+{
+ return static_cast<ListBox*>(GetWindow()) != NULL;
+
+}
+
+
+
+
+void VCLXAccessibleListBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent)
+{
+ VCLXAccessibleBox::ProcessWindowEvent( rVclWindowEvent );
+}
+
+
+
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString VCLXAccessibleListBox::getImplementationName (void)
+ throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.toolkit.AccessibleListBox");
+}
+
+
+
+
+Sequence< ::rtl::OUString > VCLXAccessibleListBox::getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames = VCLXAccessibleBox::getSupportedServiceNames();
+ sal_Int32 nLength = aNames.getLength();
+ aNames.realloc( nLength + 1 );
+ aNames[nLength] = ::rtl::OUString::createFromAscii(
+ "com.sun.star.accessibility.AccessibleListBox" );
+ return aNames;
+}
diff --git a/accessibility/source/standard/vclxaccessiblelistboxlist.cxx b/accessibility/source/standard/vclxaccessiblelistboxlist.cxx
new file mode 100644
index 000000000000..9ceacb80392f
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblelistboxlist.cxx
@@ -0,0 +1,338 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblelistboxlist.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblelistboxlist.hxx>
+#include <accessibility/standard/vclxaccessiblelistitem.hxx>
+#include <accessibility/helper/listboxhelper.hxx>
+
+#include <algorithm>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/unohelp.hxx>
+
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+
+
+namespace
+{
+ void checkSelection_Impl( sal_Int32 _nIndex, const ListBox& _rListBox, sal_Bool bSelected )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException)
+ {
+ sal_Int32 nCount = bSelected ? (sal_Int32)_rListBox.GetSelectEntryCount()
+ : (sal_Int32)_rListBox.GetEntryCount();
+ if ( _nIndex < 0 || _nIndex >= nCount )
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+ }
+}
+
+
+VCLXAccessibleListBoxList::VCLXAccessibleListBoxList (VCLXWindow* pVCLWindow,
+ BoxType aBoxType,const Reference< XAccessible >& _xParent)
+ : VCLXAccessibleList (pVCLWindow, aBoxType, _xParent)
+{
+}
+
+
+
+
+VCLXAccessibleListBoxList::~VCLXAccessibleListBoxList (void)
+{
+}
+
+
+
+
+void VCLXAccessibleListBoxList::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent)
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_LISTBOX_SCROLLED:
+ UpdateEntryRange_Impl();
+ break;
+
+ case VCLEVENT_LISTBOX_SELECT:
+ if ( !m_bDisableProcessEvent )
+ UpdateSelection_Impl();
+ break;
+
+ default:
+ VCLXAccessibleList::ProcessWindowEvent (rVclWindowEvent);
+ }
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleListBoxList, VCLXAccessibleList, VCLXAccessibleListBoxList_BASE)
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleListBoxList, VCLXAccessibleList, VCLXAccessibleListBoxList_BASE)
+
+
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString VCLXAccessibleListBoxList::getImplementationName (void)
+ throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.toolkit.AccessibleListBoxList");
+}
+
+
+
+
+Sequence< ::rtl::OUString > VCLXAccessibleListBoxList::getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames = VCLXAccessibleList::getSupportedServiceNames();
+ sal_Int32 nLength = aNames.getLength();
+ aNames.realloc( nLength + 1 );
+ aNames[nLength] = ::rtl::OUString::createFromAscii(
+ "com.sun.star.accessibility.AccessibleListBoxList");
+ return aNames;
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleListBoxList::UpdateSelection_Impl()
+{
+ uno::Any aOldValue, aNewValue;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+ Reference< XAccessible > xNewAcc;
+
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if ( pListBox )
+ {
+ USHORT nPos = 0;
+ ListItems::iterator aEnd = m_aAccessibleChildren.end();
+ for ( ListItems::iterator aIter = m_aAccessibleChildren.begin();
+ aIter != aEnd; ++aIter,++nPos)
+ {
+ if ( aIter->is() )
+ {
+ VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >( aIter->get() );
+ // Retrieve the item's index from the list entry.
+ BOOL bNowSelected = pListBox->IsEntryPosSelected (nPos);
+
+ if ( bNowSelected && !pItem->IsSelected() )
+ {
+ xNewAcc = *aIter;
+ aNewValue <<= xNewAcc;
+ m_nLastSelectedPos = nPos;
+ }
+
+ pItem->SetSelected( bNowSelected );
+ }
+ else
+ { // it could happen that a child was not created before
+ checkEntrySelected(pListBox,nPos,aNewValue,xNewAcc);
+ }
+ }
+
+ USHORT nCount = pListBox->GetEntryCount();
+ if ( nPos < nCount ) // here we have to check the if any other listbox entry is selected
+ {
+ for (; nPos < nCount && !checkEntrySelected(pListBox,nPos,aNewValue,xNewAcc) ;++nPos )
+ ;
+ }
+ }
+
+ if ( xNewAcc.is() && pListBox->HasFocus() )
+ {
+ if ( m_nLastSelectedPos != LISTBOX_ENTRY_NOTFOUND )
+ aOldValue <<= getAccessibleChild( (sal_Int32)m_nLastSelectedPos );
+ aNewValue <<= xNewAcc;
+ }
+ }
+
+ if ( aNewValue.hasValue() || aOldValue.hasValue() )
+ NotifyAccessibleEvent(
+ AccessibleEventId::ACTIVE_DESCENDANT_CHANGED,
+ aOldValue,
+ aNewValue );
+
+ NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleSelection
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListBoxList::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if ( pListBox )
+ {
+ checkSelection_Impl( nChildIndex, *pListBox, sal_False );
+ pListBox->SelectEntryPos( (USHORT)nChildIndex, TRUE );
+ // call the select handler, don't handle events in this time
+ m_bDisableProcessEvent = true;
+ pListBox->Select();
+ m_bDisableProcessEvent = false;
+ bNotify = sal_True;
+ }
+ }
+
+ if ( bNotify )
+ UpdateSelection_Impl();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleListBoxList::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ sal_Bool bRet = sal_False;
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if ( pListBox )
+ {
+ checkSelection_Impl( nChildIndex, *pListBox, sal_False );
+ bRet = pListBox->IsEntryPosSelected( (USHORT)nChildIndex );
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListBoxList::clearAccessibleSelection( ) throw (RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if ( pListBox )
+ {
+ pListBox->SetNoSelection();
+ bNotify = sal_True;
+ }
+ }
+
+ if ( bNotify )
+ UpdateSelection_Impl();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListBoxList::selectAllAccessibleChildren( ) throw (RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if ( pListBox )
+ {
+ USHORT nCount = pListBox->GetEntryCount();
+ for ( USHORT i = 0; i < nCount; ++i )
+ pListBox->SelectEntryPos( i, TRUE );
+ // call the select handler, don't handle events in this time
+ m_bDisableProcessEvent = true;
+ pListBox->Select();
+ m_bDisableProcessEvent = false;
+ bNotify = sal_True;
+ }
+ }
+
+ if ( bNotify )
+ UpdateSelection_Impl();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleListBoxList::getSelectedAccessibleChildCount( ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ sal_Int32 nCount = 0;
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if ( pListBox )
+ nCount = pListBox->GetSelectEntryCount();
+ return nCount;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleListBoxList::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if ( pListBox )
+ {
+ checkSelection_Impl( nSelectedChildIndex, *pListBox, sal_True );
+ return getAccessibleChild( (sal_Int32)pListBox->GetSelectEntryPos( (USHORT)nSelectedChildIndex ) );
+ }
+
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListBoxList::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ sal_Bool bNotify = sal_False;
+
+ {
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ ListBox* pListBox = static_cast< ListBox* >( GetWindow() );
+ if ( pListBox )
+ {
+ checkSelection_Impl( nSelectedChildIndex, *pListBox, sal_False );
+ pListBox->SelectEntryPos( (USHORT)nSelectedChildIndex, FALSE );
+ // call the select handler, don't handle events in this time
+ m_bDisableProcessEvent = true;
+ pListBox->Select();
+ m_bDisableProcessEvent = false;
+ bNotify = sal_True;
+ }
+ }
+
+ if ( bNotify )
+ UpdateSelection_Impl();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/accessibility/source/standard/vclxaccessiblelistitem.cxx b/accessibility/source/standard/vclxaccessiblelistitem.cxx
new file mode 100644
index 000000000000..8100e67330c3
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblelistitem.cxx
@@ -0,0 +1,677 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblelistitem.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblelistitem.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <accessibility/helper/listboxhelper.hxx>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/Size.hpp>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/controllayout.hxx>
+#include <vcl/unohelp2.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/accessibleeventnotifier.hxx>
+
+namespace
+{
+ void checkIndex_Impl( sal_Int32 _nIndex, const ::rtl::OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
+ {
+ if ( _nIndex < 0 || _nIndex > _sText.getLength() )
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+ }
+}
+
+// class VCLXAccessibleListItem ------------------------------------------
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star;
+
+DBG_NAME(VCLXAccessibleListItem)
+
+// -----------------------------------------------------------------------------
+// Ctor() and Dtor()
+// -----------------------------------------------------------------------------
+VCLXAccessibleListItem::VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, sal_Int32 _nIndexInParent, const Reference< XAccessible >& _xParent ) :
+
+ VCLXAccessibleListItem_BASE ( m_aMutex ),
+
+ m_nIndexInParent( _nIndexInParent ),
+ m_bSelected ( sal_False ),
+ m_bVisible ( sal_False ),
+ m_nClientId ( 0 ),
+ m_pListBoxHelper( _pListBoxHelper ),
+ m_xParent ( _xParent )
+
+{
+ DBG_CTOR( VCLXAccessibleListItem, NULL );
+
+ if ( m_xParent.is() )
+ m_xParentContext = m_xParent->getAccessibleContext();
+
+ if ( m_pListBoxHelper )
+ m_sEntryText = m_pListBoxHelper->GetEntry( (USHORT)_nIndexInParent );
+}
+// -----------------------------------------------------------------------------
+VCLXAccessibleListItem::~VCLXAccessibleListItem()
+{
+ DBG_DTOR( VCLXAccessibleListItem, NULL );
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleListItem::SetSelected( sal_Bool _bSelected )
+{
+ if ( m_bSelected != _bSelected )
+ {
+ Any aOldValue;
+ Any aNewValue;
+ if ( m_bSelected )
+ aOldValue <<= AccessibleStateType::SELECTED;
+ else
+ aNewValue <<= AccessibleStateType::SELECTED;
+ m_bSelected = _bSelected;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleListItem::SetVisible( sal_Bool _bVisible )
+{
+ if ( m_bVisible != _bVisible )
+ {
+ Any aOldValue, aNewValue;
+ m_bVisible = _bVisible;
+ (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::VISIBLE;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::SHOWING;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleListItem::NotifyAccessibleEvent( sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _aOldValue,
+ const ::com::sun::star::uno::Any& _aNewValue )
+{
+ AccessibleEventObject aEvt;
+ aEvt.Source = *this;
+ aEvt.EventId = _nEventId;
+ aEvt.OldValue = _aOldValue;
+ aEvt.NewValue = _aNewValue;
+
+ if (m_nClientId)
+ comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEvt );
+}
+// -----------------------------------------------------------------------------
+// OCommonAccessibleText
+// -----------------------------------------------------------------------------
+::rtl::OUString VCLXAccessibleListItem::implGetText()
+{
+ return m_sEntryText;
+}
+// -----------------------------------------------------------------------------
+Locale VCLXAccessibleListItem::implGetLocale()
+{
+ return Application::GetSettings().GetLocale();
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleListItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
+{
+ nStartIndex = 0;
+ nEndIndex = 0;
+}
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+Any SAL_CALL VCLXAccessibleListItem::queryInterface( Type const & rType ) throw (RuntimeException)
+{
+ return VCLXAccessibleListItem_BASE::queryInterface( rType );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListItem::acquire() throw ()
+{
+ VCLXAccessibleListItem_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListItem::release() throw ()
+{
+ VCLXAccessibleListItem_BASE::release();
+}
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+Sequence< Type > SAL_CALL VCLXAccessibleListItem::getTypes( ) throw (RuntimeException)
+{
+ return VCLXAccessibleListItem_BASE::getTypes();
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > VCLXAccessibleListItem::getImplementationId() throw (RuntimeException)
+{
+ static ::cppu::OImplementationId* pId = NULL;
+
+ if ( !pId )
+ {
+ ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+
+ if ( !pId )
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListItem::disposing()
+{
+ comphelper::AccessibleEventNotifier::TClientId nId( 0 );
+ Reference< XInterface > xEventSource;
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ VCLXAccessibleListItem_BASE::disposing();
+ m_sEntryText = ::rtl::OUString();
+ m_pListBoxHelper = NULL;
+ m_xParent = NULL;
+ m_xParentContext = NULL;
+
+ nId = m_nClientId;
+ m_nClientId = 0;
+ if ( nId )
+ xEventSource = *this;
+ }
+
+ // Send a disposing to all listeners.
+ if ( nId )
+ comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
+}
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+::rtl::OUString VCLXAccessibleListItem::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleListItem" );
+}
+// -----------------------------------------------------------------------------
+sal_Bool VCLXAccessibleListItem::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 > VCLXAccessibleListItem::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(3);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleContext" );
+ aNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleComponent" );
+ aNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleListItem" );
+ return aNames;
+}
+// -----------------------------------------------------------------------------
+// XAccessible
+// -----------------------------------------------------------------------------
+Reference< XAccessibleContext > SAL_CALL VCLXAccessibleListItem::getAccessibleContext( ) throw (RuntimeException)
+{
+ return this;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleChildCount( ) throw (RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleChild( sal_Int32 ) throw (RuntimeException)
+{
+ return Reference< XAccessible >();
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleParent( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return m_xParent;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_nIndexInParent;
+}
+// -----------------------------------------------------------------------------
+sal_Int16 SAL_CALL VCLXAccessibleListItem::getAccessibleRole( ) throw (RuntimeException)
+{
+ return AccessibleRole::LIST_ITEM;
+ // return AccessibleRole::LABEL;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleListItem::getAccessibleDescription( ) throw (RuntimeException)
+{
+ // no description for every item
+ return ::rtl::OUString();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleListItem::getAccessibleName( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // entry text == accessible name
+ return implGetText();
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleListItem::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleListItem::getAccessibleStateSet( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+ Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
+
+ if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
+ {
+ pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
+ pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
+ pStateSetHelper->AddState( AccessibleStateType::ENABLED );
+ pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
+ if ( m_bSelected )
+ pStateSetHelper->AddState( AccessibleStateType::SELECTED );
+ if ( m_bVisible )
+ {
+ pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
+ pStateSetHelper->AddState( AccessibleStateType::SHOWING );
+ }
+ }
+ else
+ pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+
+ return xStateSet;
+}
+// -----------------------------------------------------------------------------
+Locale SAL_CALL VCLXAccessibleListItem::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return implGetLocale();
+}
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleListItem::containsPoint( const awt::Point& _aPoint ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Bool bInside = sal_False;
+ if ( m_pListBoxHelper )
+ {
+ Rectangle aRect( m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent ) );
+ aRect.Move(-aRect.TopLeft().X(),-aRect.TopLeft().Y());
+ bInside = aRect.IsInside( VCLPoint( _aPoint ) );
+ }
+ return bInside;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
+{
+ return Reference< XAccessible >();
+}
+// -----------------------------------------------------------------------------
+awt::Rectangle SAL_CALL VCLXAccessibleListItem::getBounds( ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ awt::Rectangle aRect;
+ if ( m_pListBoxHelper )
+ aRect = AWTRectangle( m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent ) );
+
+ return aRect;
+}
+// -----------------------------------------------------------------------------
+awt::Point SAL_CALL VCLXAccessibleListItem::getLocation( ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Point aPoint(0,0);
+ if ( m_pListBoxHelper )
+ {
+ Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent );
+ aPoint = aRect.TopLeft();
+ }
+ return AWTPoint( aPoint );
+}
+// -----------------------------------------------------------------------------
+awt::Point SAL_CALL VCLXAccessibleListItem::getLocationOnScreen( ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Point aPoint(0,0);
+ if ( m_pListBoxHelper )
+ {
+ Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent );
+ aPoint = aRect.TopLeft();
+ aPoint += m_pListBoxHelper->GetWindowExtentsRelative( NULL ).TopLeft();
+ }
+ return AWTPoint( aPoint );
+}
+// -----------------------------------------------------------------------------
+awt::Size SAL_CALL VCLXAccessibleListItem::getSize( ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Size aSize;
+ if ( m_pListBoxHelper )
+ aSize = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent ).GetSize();
+
+ return AWTSize( aSize );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListItem::grabFocus( ) throw (RuntimeException)
+{
+ // no focus for each item
+}
+// -----------------------------------------------------------------------------
+// XAccessibleText
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getCaretPosition() throw (RuntimeException)
+{
+ return -1;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleListItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Unicode SAL_CALL VCLXAccessibleListItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getCharacter( nIndex );
+}
+// -----------------------------------------------------------------------------
+Sequence< PropertyValue > SAL_CALL VCLXAccessibleListItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OUString sText( implGetText() );
+ if ( !implIsValidIndex( nIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return Sequence< PropertyValue >();
+}
+// -----------------------------------------------------------------------------
+awt::Rectangle SAL_CALL VCLXAccessibleListItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OUString sText( implGetText() );
+ if ( !implIsValidIndex( nIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+ if ( m_pListBoxHelper )
+ {
+ Rectangle aCharRect = m_pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex );
+ Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent );
+ aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
+ aBounds = AWTRectangle( aCharRect );
+ }
+
+ return aBounds;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getCharacterCount() throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getCharacterCount();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Int32 nIndex = -1;
+ if ( m_pListBoxHelper )
+ {
+ USHORT nPos = LISTBOX_ENTRY_NOTFOUND;
+ Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent );
+ Point aPnt( VCLPoint( aPoint ) );
+ aPnt += aItemRect.TopLeft();
+ sal_Int32 nI = m_pListBoxHelper->GetIndexForPoint( aPnt, nPos );
+ if ( nI != -1 && (USHORT)m_nIndexInParent == nPos )
+ nIndex = nI;
+ }
+ return nIndex;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleListItem::getSelectedText() throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getSelectedText();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionStart() throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getSelectionStart();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionEnd() throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getSelectionEnd();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleListItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleListItem::getText() throw (RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getText();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleListItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ checkIndex_Impl( nStartIndex, m_sEntryText );
+ checkIndex_Impl( nEndIndex, m_sEntryText );
+
+ sal_Bool bRet = sal_False;
+ if ( m_pListBoxHelper )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pListBoxHelper->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
+ ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
+
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pDataObj, NULL );
+ Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+ Application::AcquireSolarMutex( nRef );
+
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleEventBroadcaster
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListItem::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
+{
+ if (xListener.is())
+ {
+ if (!m_nClientId)
+ m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
+ comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleListItem::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
+{
+ if ( xListener.is() && m_nClientId )
+ {
+ sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
+ if ( !nListenerCount )
+ {
+ // no listeners anymore
+ // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+ // and at least to us not firing any events anymore, in case somebody calls
+ // NotifyAccessibleEvent, again
+ if ( m_nClientId )
+ {
+ comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId );
+ m_nClientId = 0;
+ comphelper::AccessibleEventNotifier::revokeClient( nId );
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
+// AF (Oct. 29 2002): Return black as constant foreground color. This is an
+// initial implementation and has to be substituted by code that determines
+// the color that is actually used.
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getForeground (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return COL_BLACK;
+}
+
+// AF (Oct. 29 2002): Return white as constant background color. This is an
+// initial implementation and has to be substituted by code that determines
+// the color that is actually used.
+sal_Int32 SAL_CALL VCLXAccessibleListItem::getBackground (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return COL_WHITE;
+}
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblemenu.cxx b/accessibility/source/standard/vclxaccessiblemenu.cxx
new file mode 100644
index 000000000000..5dfa96d0a52c
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblemenu.cxx
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblemenu.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessiblemenu.hxx>
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <vcl/menu.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleMenu
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleMenu::VCLXAccessibleMenu( Menu* pParent, sal_uInt16 nItemPos, Menu* pMenu )
+ :VCLXAccessibleMenuItem( pParent, nItemPos, pMenu )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleMenu::~VCLXAccessibleMenu()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenu::IsFocused()
+{
+ sal_Bool bFocused = sal_False;
+
+ if ( IsHighlighted() && !IsChildHighlighted() )
+ bFocused = sal_True;
+
+ return bFocused;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenu::IsPopupMenuOpen()
+{
+ sal_Bool bPopupMenuOpen = sal_False;
+
+ if ( m_pParent )
+ {
+ PopupMenu* pPopupMenu = m_pParent->GetPopupMenu( m_pParent->GetItemId( m_nItemPos ) );
+ if ( pPopupMenu && pPopupMenu->IsMenuVisible() )
+ bPopupMenuOpen = sal_True;
+ }
+
+ return bPopupMenuOpen;
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleMenu, VCLXAccessibleMenuItem, VCLXAccessibleMenu_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleMenu, VCLXAccessibleMenuItem, VCLXAccessibleMenu_BASE )
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenu::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleMenu" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleMenu::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleMenu" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenu::getAccessibleChildCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetChildCount();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleMenu::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= GetChildCount() )
+ throw IndexOutOfBoundsException();
+
+ return GetChild( i );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessibleMenu::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::MENU;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleMenu::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetChildAt( rPoint );
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleSelection
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleMenu::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
+ throw IndexOutOfBoundsException();
+
+ SelectChild( nChildIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenu::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
+ throw IndexOutOfBoundsException();
+
+ return IsChildSelected( nChildIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleMenu::clearAccessibleSelection( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ DeSelectAll();
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleMenu::selectAllAccessibleChildren( ) throw (RuntimeException)
+{
+ // This method makes no sense in a menu, and so does nothing.
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenu::getSelectedAccessibleChildCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nRet = 0;
+
+ for ( sal_Int32 i = 0, nCount = GetChildCount(); i < nCount; i++ )
+ {
+ if ( IsChildSelected( i ) )
+ ++nRet;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleMenu::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild;
+
+ for ( sal_Int32 i = 0, j = 0, nCount = GetChildCount(); i < nCount; i++ )
+ {
+ if ( IsChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
+ {
+ xChild = GetChild( i );
+ break;
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleMenu::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
+ throw IndexOutOfBoundsException();
+
+ DeSelectAll();
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblemenubar.cxx b/accessibility/source/standard/vclxaccessiblemenubar.cxx
new file mode 100644
index 000000000000..8c50d80a9c6f
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblemenubar.cxx
@@ -0,0 +1,214 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblemenubar.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblemenubar.hxx>
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/menu.hxx>
+
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class VCLXAccessibleMenuBar
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleMenuBar::VCLXAccessibleMenuBar( Menu* pMenu )
+ :OAccessibleMenuComponent( pMenu )
+{
+ if ( pMenu )
+ {
+ m_pWindow = pMenu->GetWindow();
+
+ if ( m_pWindow )
+ m_pWindow->AddEventListener( LINK( this, VCLXAccessibleMenuBar, WindowEventListener ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleMenuBar::~VCLXAccessibleMenuBar()
+{
+ if ( m_pWindow )
+ m_pWindow->RemoveEventListener( LINK( this, VCLXAccessibleMenuBar, WindowEventListener ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuBar::IsFocused()
+{
+ sal_Bool bFocused = sal_False;
+
+ if ( m_pWindow && m_pWindow->HasFocus() && !IsChildHighlighted() )
+ bFocused = sal_True;
+
+ return bFocused;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( VCLXAccessibleMenuBar, WindowEventListener, VclSimpleEvent*, pEvent )
+{
+ DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "VCLXAccessibleMenuBar::WindowEventListener: unknown window event!" );
+ if ( pEvent && pEvent->ISA( VclWindowEvent ) )
+ {
+ DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "VCLXAccessibleMenuBar::WindowEventListener: no window!" );
+ if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
+ {
+ ProcessWindowEvent( *(VclWindowEvent*)pEvent );
+ }
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleMenuBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_WINDOW_GETFOCUS:
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ {
+ SetFocused( rVclWindowEvent.GetId() == VCLEVENT_WINDOW_GETFOCUS );
+ }
+ break;
+ case VCLEVENT_OBJECT_DYING:
+ {
+ if ( m_pWindow )
+ {
+ m_pWindow->RemoveEventListener( LINK( this, VCLXAccessibleMenuBar, WindowEventListener ) );
+ m_pWindow = NULL;
+ }
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleMenuBar::disposing()
+{
+ OAccessibleMenuComponent::disposing();
+
+ if ( m_pWindow )
+ {
+ m_pWindow->RemoveEventListener( LINK( this, VCLXAccessibleMenuBar, WindowEventListener ) );
+ m_pWindow = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenuBar::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleMenuBar" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleMenuBar::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleMenuBar" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenuBar::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndexInParent = -1;
+
+ if ( m_pMenu )
+ {
+ Window* pWindow = m_pMenu->GetWindow();
+ if ( pWindow )
+ {
+ Window* pParent = pWindow->GetAccessibleParentWindow();
+ if ( pParent )
+ {
+ for ( USHORT n = pParent->GetAccessibleChildWindowCount(); n; )
+ {
+ Window* pChild = pParent->GetAccessibleChildWindow( --n );
+ if ( pChild == pWindow )
+ {
+ nIndexInParent = n;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return nIndexInParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessibleMenuBar::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::MENU_BAR;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenuBar::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Application::GetSettings().GetStyleSettings().GetMenuBarColor().GetColor();
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblemenuitem.cxx b/accessibility/source/standard/vclxaccessiblemenuitem.cxx
new file mode 100644
index 000000000000..2548ad0a7dbb
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblemenuitem.cxx
@@ -0,0 +1,610 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblemenuitem.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblemenuitem.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+#include <toolkit/helper/convert.hxx>
+#include <accessibility/helper/characterattributeshelper.hxx>
+#include <comphelper/accessiblekeybindinghelper.hxx>
+#include <com/sun/star/awt/KeyModifier.hpp>
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <comphelper/sequence.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/unohelp2.hxx>
+
+#include <memory>
+
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class VCLXAccessibleMenuItem
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleMenuItem::VCLXAccessibleMenuItem( Menu* pParent, sal_uInt16 nItemPos, Menu* pMenu )
+ :OAccessibleMenuItemComponent( pParent, nItemPos, pMenu )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleMenuItem::~VCLXAccessibleMenuItem()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::IsFocused()
+{
+ return IsHighlighted();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::IsSelected()
+{
+ return IsHighlighted();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::IsChecked()
+{
+ sal_Bool bChecked = sal_False;
+
+ if ( m_pParent )
+ {
+ sal_uInt16 nItemId = m_pParent->GetItemId( m_nItemPos );
+ if ( m_pParent->IsItemChecked( nItemId ) )
+ bChecked = sal_True;
+ }
+
+ return bChecked;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::IsHighlighted()
+{
+ sal_Bool bHighlighted = sal_False;
+
+ if ( m_pParent && m_pParent->IsHighlighted( m_nItemPos ) )
+ bHighlighted = sal_True;
+
+ return bHighlighted;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleMenuItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ OAccessibleMenuItemComponent::FillAccessibleStateSet( rStateSet );
+
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+
+ if ( IsFocused() )
+ rStateSet.AddState( AccessibleStateType::FOCUSED );
+
+ rStateSet.AddState( AccessibleStateType::SELECTABLE );
+
+ if ( IsSelected() )
+ rStateSet.AddState( AccessibleStateType::SELECTED );
+
+ if ( IsChecked() )
+ rStateSet.AddState( AccessibleStateType::CHECKED );
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleText
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenuItem::implGetText()
+{
+ return m_sItemText;
+}
+
+// -----------------------------------------------------------------------------
+
+Locale VCLXAccessibleMenuItem::implGetLocale()
+{
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleMenuItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
+{
+ nStartIndex = 0;
+ nEndIndex = 0;
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleMenuItem, OAccessibleMenuItemComponent, VCLXAccessibleMenuItem_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleMenuItem, OAccessibleMenuItemComponent, VCLXAccessibleMenuItem_BASE )
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenuItem::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleMenuItem" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleMenuItem::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleMenuItem" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessibleMenuItem::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::MENU_ITEM;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleText
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenuItem::getCaretPosition() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return -1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Unicode VCLXAccessibleMenuItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getCharacter( nIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< PropertyValue > VCLXAccessibleMenuItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Sequence< PropertyValue > aValues;
+ ::rtl::OUString sText( implGetText() );
+
+ if ( !implIsValidIndex( nIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ Font aFont = Application::GetSettings().GetStyleSettings().GetMenuFont();
+ sal_Int32 nBackColor = getBackground();
+ sal_Int32 nColor = getForeground();
+ ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) );
+ aValues = pHelper->GetCharacterAttributes( aRequestedAttributes );
+
+ return aValues;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Rectangle VCLXAccessibleMenuItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+ if ( m_pParent )
+ {
+ sal_uInt16 nItemId = m_pParent->GetItemId( m_nItemPos );
+ Rectangle aItemRect = m_pParent->GetBoundingRectangle( m_nItemPos );
+ Rectangle aCharRect = m_pParent->GetCharacterBounds( nItemId, nIndex );
+ aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
+ aBounds = AWTRectangle( aCharRect );
+ }
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenuItem::getCharacterCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getCharacterCount();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenuItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndex = -1;
+ if ( m_pParent )
+ {
+ sal_uInt16 nItemId = 0;
+ Rectangle aItemRect = m_pParent->GetBoundingRectangle( m_nItemPos );
+ Point aPnt( VCLPoint( aPoint ) );
+ aPnt += aItemRect.TopLeft();
+ sal_Int32 nI = m_pParent->GetIndexForPoint( aPnt, nItemId );
+ if ( nI != -1 && m_pParent->GetItemId( m_nItemPos ) == nItemId )
+ nIndex = nI;
+ }
+
+ return nIndex;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenuItem::getSelectedText() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getSelectedText();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenuItem::getSelectionStart() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getSelectionStart();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenuItem::getSelectionEnd() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getSelectionEnd();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenuItem::getText() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getText();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenuItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleMenuItem::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleMenuItem::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleMenuItem::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ if ( m_pParent )
+ {
+ Window* pWindow = m_pParent->GetWindow();
+ if ( pWindow )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = pWindow->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
+
+ ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pDataObj, NULL );
+
+ Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+
+ Application::AcquireSolarMutex( nRef );
+
+ bReturn = sal_True;
+ }
+ }
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleAction
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleMenuItem::getAccessibleActionCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ Click();
+
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenuItem::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleKeyBinding > VCLXAccessibleMenuItem::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper();
+ Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper;
+
+ if ( m_pParent )
+ {
+ // create auto mnemonics
+ if ( Application::GetSettings().GetStyleSettings().GetAutoMnemonic() && !( m_pParent->GetMenuFlags() & MENU_FLAG_NOAUTOMNEMONICS ) )
+ m_pParent->CreateAutoMnemonics();
+
+ // activation key
+ KeyEvent aKeyEvent = m_pParent->GetActivationKey( m_pParent->GetItemId( m_nItemPos ) );
+ KeyCode aKeyCode = aKeyEvent.GetKeyCode();
+ Sequence< awt::KeyStroke > aSeq1(1);
+ aSeq1[0].Modifiers = 0;
+ Reference< XAccessible > xParent( getAccessibleParent() );
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
+ if ( xParentContext.is() && xParentContext->getAccessibleRole() == AccessibleRole::MENU_BAR )
+ aSeq1[0].Modifiers |= awt::KeyModifier::MOD2;
+ }
+ aSeq1[0].KeyCode = aKeyCode.GetCode();
+ aSeq1[0].KeyChar = aKeyEvent.GetCharCode();
+ aSeq1[0].KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() );
+ pKeyBindingHelper->AddKeyBinding( aSeq1 );
+
+ // complete menu activation key sequence
+ Sequence< awt::KeyStroke > aSeq;
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
+ if ( xParentContext.is() && xParentContext->getAccessibleRole() == AccessibleRole::MENU )
+ {
+ Reference< XAccessibleAction > xAction( xParentContext, UNO_QUERY );
+ if ( xAction.is() && xAction->getAccessibleActionCount() > 0 )
+ {
+ Reference< XAccessibleKeyBinding > xKeyB( xAction->getAccessibleActionKeyBinding( 0 ) );
+ if ( xKeyB.is() && xKeyB->getAccessibleKeyBindingCount() > 1 )
+ aSeq = xKeyB->getAccessibleKeyBinding( 1 );
+ }
+ }
+ }
+ Sequence< awt::KeyStroke > aSeq2 = ::comphelper::concatSequences( aSeq, aSeq1 );
+ pKeyBindingHelper->AddKeyBinding( aSeq2 );
+
+ // accelerator key
+ KeyCode aAccelKeyCode = m_pParent->GetAccelKey( m_pParent->GetItemId( m_nItemPos ) );
+ if ( aAccelKeyCode.GetCode() != 0 )
+ {
+ Sequence< awt::KeyStroke > aSeq3(1);
+ aSeq3[0].Modifiers = 0;
+ if ( aAccelKeyCode.IsShift() )
+ aSeq3[0].Modifiers |= awt::KeyModifier::SHIFT;
+ if ( aAccelKeyCode.IsMod1() )
+ aSeq3[0].Modifiers |= awt::KeyModifier::MOD1;
+ if ( aAccelKeyCode.IsMod2() )
+ aSeq3[0].Modifiers |= awt::KeyModifier::MOD2;
+ if ( aAccelKeyCode.IsMod3() )
+ aSeq3[0].Modifiers |= awt::KeyModifier::MOD3;
+ aSeq3[0].KeyCode = aAccelKeyCode.GetCode();
+ aSeq3[0].KeyFunc = static_cast< sal_Int16 >( aAccelKeyCode.GetFunction() );
+ pKeyBindingHelper->AddKeyBinding( aSeq3 );
+ }
+ }
+
+ return xKeyBinding;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleValue
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleMenuItem::getCurrentValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ if ( IsSelected() )
+ aValue <<= (sal_Int32) 1;
+ else
+ aValue <<= (sal_Int32) 0;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleMenuItem::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+ sal_Int32 nValue = 0;
+ OSL_VERIFY( aNumber >>= nValue );
+
+ if ( nValue <= 0 )
+ {
+ DeSelect();
+ bReturn = sal_True;
+ }
+ else if ( nValue >= 1 )
+ {
+ Select();
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleMenuItem::getMaximumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ aValue <<= (sal_Int32) 1;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleMenuItem::getMinimumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ aValue <<= (sal_Int32) 0;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblemenuseparator.cxx b/accessibility/source/standard/vclxaccessiblemenuseparator.cxx
new file mode 100644
index 000000000000..5c2dc3a004b1
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblemenuseparator.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblemenuseparator.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblemenuseparator.hxx>
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class VCLXAccessibleMenuSeparator
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleMenuSeparator::VCLXAccessibleMenuSeparator( Menu* pParent, sal_uInt16 nItemPos, Menu* pMenu )
+ :OAccessibleMenuItemComponent( pParent, nItemPos, pMenu )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleMenuSeparator::~VCLXAccessibleMenuSeparator()
+{
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleMenuSeparator::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleMenuSeparator" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleMenuSeparator::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleMenuSeparator" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessibleMenuSeparator::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::SEPARATOR;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblepopupmenu.cxx b/accessibility/source/standard/vclxaccessiblepopupmenu.cxx
new file mode 100644
index 000000000000..438708362f5e
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblepopupmenu.cxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblepopupmenu.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblepopupmenu.hxx>
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class VCLXAccessiblePopupMenu
+// -----------------------------------------------------------------------------
+
+VCLXAccessiblePopupMenu::VCLXAccessiblePopupMenu( Menu* pMenu )
+ :OAccessibleMenuComponent( pMenu )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessiblePopupMenu::~VCLXAccessiblePopupMenu()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessiblePopupMenu::IsFocused()
+{
+ return !IsChildHighlighted();
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessiblePopupMenu::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessiblePopupMenu" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessiblePopupMenu::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessiblePopupMenu" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessiblePopupMenu::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessiblePopupMenu::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::POPUP_MENU;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessiblePopupMenu::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor();
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibleradiobutton.cxx b/accessibility/source/standard/vclxaccessibleradiobutton.cxx
new file mode 100644
index 000000000000..f797ff2d70ae
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibleradiobutton.cxx
@@ -0,0 +1,317 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibleradiobutton.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessibleradiobutton.hxx>
+
+#include <toolkit/awt/vclxwindows.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <comphelper/accessiblekeybindinghelper.hxx>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <vcl/window.hxx>
+#include <vcl/button.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleRadioButton
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleRadioButton::VCLXAccessibleRadioButton( VCLXWindow* pVCLWindow )
+ :VCLXAccessibleTextComponent( pVCLWindow )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleRadioButton::~VCLXAccessibleRadioButton()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_RADIOBUTTON_TOGGLE:
+ {
+ Any aOldValue;
+ Any aNewValue;
+
+ VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
+ if ( pVCLXRadioButton && pVCLXRadioButton->getState() )
+ aNewValue <<= AccessibleStateType::CHECKED;
+ else
+ aOldValue <<= AccessibleStateType::CHECKED;
+
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ default:
+ VCLXAccessibleTextComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet )
+{
+ VCLXAccessibleTextComponent::FillAccessibleRelationSet( rRelationSet );
+
+ RadioButton* pRadioButton = dynamic_cast< RadioButton* >( GetWindow() );
+ if ( pRadioButton )
+ {
+ ::std::vector< RadioButton* > aGroup;
+ pRadioButton->GetRadioButtonGroup( aGroup, true );
+ if ( !aGroup.empty() )
+ {
+ sal_Int32 i = 0;
+ Sequence< Reference< XInterface > > aSequence( static_cast< sal_Int32 >( aGroup.size() ) );
+ ::std::vector< RadioButton* >::const_iterator aEndItr = aGroup.end();
+ for ( ::std::vector< RadioButton* >::const_iterator aItr = aGroup.begin(); aItr < aEndItr; ++aItr )
+ {
+ aSequence[i++] = (*aItr)->GetAccessible();
+ }
+ rRelationSet.AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleRadioButton::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
+
+ VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
+ if ( pVCLXRadioButton )
+ {
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+ if ( pVCLXRadioButton->getState() )
+ rStateSet.AddState( AccessibleStateType::CHECKED );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleRadioButton, VCLXAccessibleTextComponent, VCLXAccessibleRadioButton_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleRadioButton, VCLXAccessibleTextComponent, VCLXAccessibleRadioButton_BASE )
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleRadioButton::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleRadioButton" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleRadioButton::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleRadioButton" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleAction
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleRadioButton::getAccessibleActionCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleRadioButton::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
+ if ( pVCLXRadioButton && !pVCLXRadioButton->getState() )
+ pVCLXRadioButton->setState( sal_True );
+
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleRadioButton::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleKeyBinding > VCLXAccessibleRadioButton::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper();
+ Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper;
+
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ {
+ KeyEvent aKeyEvent = pWindow->GetActivationKey();
+ KeyCode aKeyCode = aKeyEvent.GetKeyCode();
+ if ( aKeyCode.GetCode() != 0 )
+ {
+ awt::KeyStroke aKeyStroke;
+ aKeyStroke.Modifiers = 0;
+ if ( aKeyCode.IsShift() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::SHIFT;
+ if ( aKeyCode.IsMod1() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD1;
+ if ( aKeyCode.IsMod2() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD2;
+ if ( aKeyCode.IsMod3() )
+ aKeyStroke.Modifiers |= awt::KeyModifier::MOD3;
+ aKeyStroke.KeyCode = aKeyCode.GetCode();
+ aKeyStroke.KeyChar = aKeyEvent.GetCharCode();
+ aKeyStroke.KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() );
+ pKeyBindingHelper->AddKeyBinding( aKeyStroke );
+ }
+ }
+
+ return xKeyBinding;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleValue
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleRadioButton::getCurrentValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+
+ VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
+ if ( pVCLXRadioButton )
+ aValue <<= (sal_Int32) pVCLXRadioButton->getState();
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleRadioButton::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
+ if ( pVCLXRadioButton )
+ {
+ sal_Int32 nValue = 0;
+ OSL_VERIFY( aNumber >>= nValue );
+
+ if ( nValue < 0 )
+ nValue = 0;
+ else if ( nValue > 1 )
+ nValue = 1;
+
+ pVCLXRadioButton->setState( (sal_Bool) nValue );
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleRadioButton::getMaximumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ aValue <<= (sal_Int32) 1;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleRadioButton::getMinimumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ aValue <<= (sal_Int32) 0;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblescrollbar.cxx b/accessibility/source/standard/vclxaccessiblescrollbar.cxx
new file mode 100644
index 000000000000..ed561c6fdc20
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblescrollbar.cxx
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblescrollbar.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessiblescrollbar.hxx>
+
+#include <toolkit/awt/vclxwindows.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/awt/ScrollBarOrientation.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <vcl/scrbar.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleScrollBar
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleScrollBar::VCLXAccessibleScrollBar( VCLXWindow* pVCLWindow )
+ :VCLXAccessibleComponent( pVCLWindow )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleScrollBar::~VCLXAccessibleScrollBar()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_SCROLLBAR_SCROLL:
+ {
+ NotifyAccessibleEvent( AccessibleEventId::VALUE_CHANGED, Any(), Any() );
+ }
+ break;
+ default:
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleScrollBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
+
+ VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
+ if ( pVCLXScrollBar )
+ {
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+ if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::HORIZONTAL )
+ rStateSet.AddState( AccessibleStateType::HORIZONTAL );
+ else if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::VERTICAL )
+ rStateSet.AddState( AccessibleStateType::VERTICAL );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleScrollBar, VCLXAccessibleComponent, VCLXAccessibleScrollBar_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleScrollBar, VCLXAccessibleComponent, VCLXAccessibleScrollBar_BASE )
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleScrollBar::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleScrollBar" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleScrollBar::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleScrollBar" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleAction
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleScrollBar::getAccessibleActionCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 4;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleScrollBar::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ sal_Bool bReturn = sal_False;
+ ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
+ if ( pScrollBar )
+ {
+ ScrollType eScrollType;
+ switch ( nIndex )
+ {
+ case 0: eScrollType = SCROLL_LINEUP; break;
+ case 1: eScrollType = SCROLL_LINEDOWN; break;
+ case 2: eScrollType = SCROLL_PAGEUP; break;
+ case 3: eScrollType = SCROLL_PAGEDOWN; break;
+ default: eScrollType = SCROLL_DONTKNOW; break;
+ }
+ if ( pScrollBar->DoScrollAction( eScrollType ) )
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleScrollBar::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ ::rtl::OUString sDescription;
+
+ switch ( nIndex )
+ {
+ case 0: sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_DECLINE ) ); break;
+ case 1: sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_INCLINE ) ); break;
+ case 2: sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_DECBLOCK ) ); break;
+ case 3: sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_INCBLOCK ) ); break;
+ default: break;
+ }
+
+ return sDescription;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleKeyBinding > VCLXAccessibleScrollBar::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ return Reference< XAccessibleKeyBinding >();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleValue
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleScrollBar::getCurrentValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+
+ VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
+ if ( pVCLXScrollBar )
+ aValue <<= (sal_Int32) pVCLXScrollBar->getValue();
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleScrollBar::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
+ if ( pVCLXScrollBar )
+ {
+ sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0;
+ OSL_VERIFY( aNumber >>= nValue );
+ OSL_VERIFY( getMinimumValue() >>= nValueMin );
+ OSL_VERIFY( getMaximumValue() >>= nValueMax );
+
+ if ( nValue < nValueMin )
+ nValue = nValueMin;
+ else if ( nValue > nValueMax )
+ nValue = nValueMax;
+
+ pVCLXScrollBar->setValue( nValue );
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleScrollBar::getMaximumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+
+ VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
+ if ( pVCLXScrollBar )
+ aValue <<= (sal_Int32) pVCLXScrollBar->getMaximum();
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
+
+Any VCLXAccessibleScrollBar::getMinimumValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ aValue <<= (sal_Int32) 0;
+
+ return aValue;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblestatusbar.cxx b/accessibility/source/standard/vclxaccessiblestatusbar.cxx
new file mode 100644
index 000000000000..cc3c6d3aa666
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblestatusbar.cxx
@@ -0,0 +1,369 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblestatusbar.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblestatusbar.hxx>
+#include <accessibility/standard/vclxaccessiblestatusbaritem.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <vcl/status.hxx>
+
+
+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;
+
+
+// ----------------------------------------------------
+// class VCLXAccessibleStatusBar
+// ----------------------------------------------------
+
+VCLXAccessibleStatusBar::VCLXAccessibleStatusBar( VCLXWindow* pVCLXWindow )
+ :VCLXAccessibleComponent( pVCLXWindow )
+{
+ m_pStatusBar = static_cast< StatusBar* >( GetWindow() );
+
+ if ( m_pStatusBar )
+ m_aAccessibleChildren.assign( m_pStatusBar->GetItemCount(), Reference< XAccessible >() );
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleStatusBar::~VCLXAccessibleStatusBar()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBar::UpdateShowing( sal_Int32 i, sal_Bool bShowing )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleStatusBarItem* pVCLXAccessibleStatusBarItem = static_cast< VCLXAccessibleStatusBarItem* >( xChild.get() );
+ if ( pVCLXAccessibleStatusBarItem )
+ pVCLXAccessibleStatusBarItem->SetShowing( bShowing );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBar::UpdateItemName( sal_Int32 i )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleStatusBarItem* pVCLXAccessibleStatusBarItem = static_cast< VCLXAccessibleStatusBarItem* >( xChild.get() );
+ if ( pVCLXAccessibleStatusBarItem )
+ {
+ ::rtl::OUString sItemName = pVCLXAccessibleStatusBarItem->GetItemName();
+ pVCLXAccessibleStatusBarItem->SetItemName( sItemName );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBar::UpdateItemText( sal_Int32 i )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleStatusBarItem* pVCLXAccessibleStatusBarItem = static_cast< VCLXAccessibleStatusBarItem* >( xChild.get() );
+ if ( pVCLXAccessibleStatusBarItem )
+ {
+ ::rtl::OUString sItemText = pVCLXAccessibleStatusBarItem->GetItemText();
+ pVCLXAccessibleStatusBarItem->SetItemText( sItemText );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBar::InsertChild( sal_Int32 i )
+{
+ if ( i >= 0 && i <= (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ // insert entry in child list
+ m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() );
+
+ // send accessible child event
+ Reference< XAccessible > xChild( getAccessibleChild( i ) );
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aNewValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBar::RemoveChild( sal_Int32 i )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ // get the accessible of the removed page
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+
+ // remove entry in child list
+ m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
+
+ // send accessible child event
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+
+ Reference< XComponent > xComponent( xChild, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_STATUSBAR_ITEMADDED:
+ {
+ if ( m_pStatusBar )
+ {
+ sal_uInt16 nItemId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ sal_uInt16 nItemPos = m_pStatusBar->GetItemPos( nItemId );
+ InsertChild( nItemPos );
+ }
+ }
+ break;
+ case VCLEVENT_STATUSBAR_ITEMREMOVED:
+ {
+ if ( m_pStatusBar )
+ {
+ sal_uInt16 nItemId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
+ {
+ Reference< XAccessible > xChild( getAccessibleChild( i ) );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleStatusBarItem* pVCLXAccessibleStatusBarItem = static_cast< VCLXAccessibleStatusBarItem* >( xChild.get() );
+ if ( pVCLXAccessibleStatusBarItem && pVCLXAccessibleStatusBarItem->GetItemId() == nItemId )
+ {
+ RemoveChild( i );
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ case VCLEVENT_STATUSBAR_ALLITEMSREMOVED:
+ {
+ for ( sal_Int32 i = m_aAccessibleChildren.size() - 1; i >= 0; --i )
+ RemoveChild( i );
+ }
+ break;
+ case VCLEVENT_STATUSBAR_SHOWITEM:
+ case VCLEVENT_STATUSBAR_HIDEITEM:
+ {
+ if ( m_pStatusBar )
+ {
+ sal_uInt16 nItemId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ sal_uInt16 nItemPos = m_pStatusBar->GetItemPos( nItemId );
+ UpdateShowing( nItemPos, rVclWindowEvent.GetId() == VCLEVENT_STATUSBAR_SHOWITEM );
+ }
+ }
+ break;
+ case VCLEVENT_STATUSBAR_SHOWALLITEMS:
+ case VCLEVENT_STATUSBAR_HIDEALLITEMS:
+ {
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ UpdateShowing( i, rVclWindowEvent.GetId() == VCLEVENT_STATUSBAR_SHOWALLITEMS );
+ }
+ break;
+ case VCLEVENT_STATUSBAR_NAMECHANGED:
+ {
+ if ( m_pStatusBar )
+ {
+ sal_uInt16 nItemId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ sal_uInt16 nItemPos = m_pStatusBar->GetItemPos( nItemId );
+ UpdateItemName( nItemPos );
+ }
+ }
+ break;
+ case VCLEVENT_STATUSBAR_DRAWITEM:
+ {
+ if ( m_pStatusBar )
+ {
+ sal_uInt16 nItemId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ sal_uInt16 nItemPos = m_pStatusBar->GetItemPos( nItemId );
+ UpdateItemText( nItemPos );
+ }
+ }
+ break;
+ case VCLEVENT_OBJECT_DYING:
+ {
+ if ( m_pStatusBar )
+ {
+ m_pStatusBar = NULL;
+
+ // dispose all children
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ m_aAccessibleChildren.clear();
+ }
+
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+ break;
+ default:
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBar::disposing()
+{
+ VCLXAccessibleComponent::disposing();
+
+ if ( m_pStatusBar )
+ {
+ m_pStatusBar = NULL;
+
+ // dispose all children
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ m_aAccessibleChildren.clear();
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBar::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleStatusBar" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleStatusBar::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleStatusBar" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleStatusBar::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return m_aAccessibleChildren.size();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleStatusBar::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild = m_aAccessibleChildren[i];
+ if ( !xChild.is() )
+ {
+ if ( m_pStatusBar )
+ {
+ sal_uInt16 nItemId = m_pStatusBar->GetItemId( (USHORT)i );
+
+ xChild = new VCLXAccessibleStatusBarItem( m_pStatusBar, nItemId );
+
+ // insert into status bar item list
+ m_aAccessibleChildren[i] = xChild;
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleStatusBar::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xChild;
+ if ( m_pStatusBar )
+ {
+ sal_uInt16 nItemId = m_pStatusBar->GetItemId( VCLPoint( rPoint ) );
+ sal_Int32 nItemPos = m_pStatusBar->GetItemPos( nItemId );
+ if ( nItemPos >= 0 && nItemPos < (sal_Int32)m_aAccessibleChildren.size() )
+ xChild = getAccessibleChild( nItemPos );
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx b/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx
new file mode 100644
index 000000000000..e5f4f974d4ea
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx
@@ -0,0 +1,632 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessiblestatusbaritem.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessiblestatusbaritem.hxx>
+#include <toolkit/helper/externallock.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <accessibility/helper/characterattributeshelper.hxx>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/unohelp2.hxx>
+#include <vcl/status.hxx>
+#include <vcl/controllayout.hxx>
+
+#include <memory>
+
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class VCLXAccessibleStatusBarItem
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleStatusBarItem::VCLXAccessibleStatusBarItem( StatusBar* pStatusBar, sal_uInt16 nItemId )
+ :AccessibleTextHelper_BASE( new VCLExternalSolarLock() )
+ ,m_pStatusBar( pStatusBar )
+ ,m_nItemId( nItemId )
+{
+ m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
+
+ m_sItemName = GetItemName();
+ m_sItemText = GetItemText();
+ m_bShowing = IsShowing();
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleStatusBarItem::~VCLXAccessibleStatusBarItem()
+{
+ delete m_pExternalLock;
+ m_pExternalLock = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleStatusBarItem::IsShowing()
+{
+ sal_Bool bShowing = sal_False;
+
+ if ( m_pStatusBar )
+ bShowing = m_pStatusBar->IsItemVisible( m_nItemId );
+
+ return bShowing;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBarItem::SetShowing( sal_Bool bShowing )
+{
+ if ( m_bShowing != bShowing )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bShowing )
+ aOldValue <<= AccessibleStateType::SHOWING;
+ else
+ aNewValue <<= AccessibleStateType::SHOWING;
+ m_bShowing = bShowing;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBarItem::SetItemName( const ::rtl::OUString& sItemName )
+{
+ if ( !m_sItemName.equals( sItemName ) )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= m_sItemName;
+ aNewValue <<= sItemName;
+ m_sItemName = sItemName;
+ NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBarItem::GetItemName()
+{
+ ::rtl::OUString sName;
+ if ( m_pStatusBar )
+ sName = m_pStatusBar->GetAccessibleName( m_nItemId );
+
+ return sName;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBarItem::SetItemText( const ::rtl::OUString& sItemText )
+{
+ Any aOldValue, aNewValue;
+ if ( implInitTextChangedEvent( m_sItemText, sItemText, aOldValue, aNewValue ) )
+ {
+ m_sItemText = sItemText;
+ NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBarItem::GetItemText()
+{
+ ::rtl::OUString sText;
+ ::vcl::ControlLayoutData aLayoutData;
+ if ( m_pStatusBar )
+ {
+ Rectangle aItemRect = m_pStatusBar->GetItemRect( m_nItemId );
+ m_pStatusBar->RecordLayoutData( &aLayoutData, aItemRect );
+ sText = aLayoutData.m_aDisplayText;
+ }
+
+ return sText;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBarItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ rStateSet.AddState( AccessibleStateType::ENABLED );
+ rStateSet.AddState( AccessibleStateType::SENSITIVE );
+
+ rStateSet.AddState( AccessibleStateType::VISIBLE );
+
+ if ( IsShowing() )
+ rStateSet.AddState( AccessibleStateType::SHOWING );
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleComponent
+// -----------------------------------------------------------------------------
+
+awt::Rectangle VCLXAccessibleStatusBarItem::implGetBounds() throw (RuntimeException)
+{
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+
+ if ( m_pStatusBar )
+ aBounds = AWTRectangle( m_pStatusBar->GetItemRect( m_nItemId ) );
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleText
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBarItem::implGetText()
+{
+ return GetItemText();
+}
+
+// -----------------------------------------------------------------------------
+
+lang::Locale VCLXAccessibleStatusBarItem::implGetLocale()
+{
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBarItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
+{
+ nStartIndex = 0;
+ nEndIndex = 0;
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleStatusBarItem, AccessibleTextHelper_BASE, VCLXAccessibleStatusBarItem_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleStatusBarItem, AccessibleTextHelper_BASE, VCLXAccessibleStatusBarItem_BASE )
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBarItem::disposing()
+{
+ AccessibleTextHelper_BASE::disposing();
+
+ m_pStatusBar = NULL;
+ m_sItemName = ::rtl::OUString();
+ m_sItemText = ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBarItem::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleStatusBarItem" );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleStatusBarItem::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 > VCLXAccessibleStatusBarItem::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleStatusBarItem" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessible
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleContext > VCLXAccessibleStatusBarItem::getAccessibleContext( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleStatusBarItem::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleStatusBarItem::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ return Reference< XAccessible >();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleStatusBarItem::getAccessibleParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xParent;
+ if ( m_pStatusBar )
+ xParent = m_pStatusBar->GetAccessible();
+
+ return xParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleStatusBarItem::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndexInParent = -1;
+ if ( m_pStatusBar )
+ nIndexInParent = m_pStatusBar->GetItemPos( m_nItemId );
+
+ return nIndexInParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessibleStatusBarItem::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::LABEL;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBarItem::getAccessibleDescription( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sDescription;
+ if ( m_pStatusBar )
+ sDescription = m_pStatusBar->GetHelpText( m_nItemId );
+
+ return sDescription;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBarItem::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetItemName();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleRelationSet > VCLXAccessibleStatusBarItem::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleStateSet > VCLXAccessibleStatusBarItem::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;
+}
+
+// -----------------------------------------------------------------------------
+
+Locale VCLXAccessibleStatusBarItem::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleStatusBarItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Reference< XAccessible >();
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleStatusBarItem::grabFocus( ) throw (RuntimeException)
+{
+ // no focus for status bar items
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleStatusBarItem::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ nColor = xParentComp->getForeground();
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleStatusBarItem::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ nColor = xParentComp->getBackground();
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+
+Reference< awt::XFont > VCLXAccessibleStatusBarItem::getFont( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< awt::XFont > xFont;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ xFont = xParentComp->getFont();
+ }
+
+ return xFont;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBarItem::getTitledBorderText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetItemText();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleStatusBarItem::getToolTipText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleText
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleStatusBarItem::getCaretPosition() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return -1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleStatusBarItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< PropertyValue > VCLXAccessibleStatusBarItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Sequence< PropertyValue > aValues;
+ ::rtl::OUString sText( implGetText() );
+
+ if ( !implIsValidIndex( nIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ if ( m_pStatusBar )
+ {
+ Font aFont = m_pStatusBar->GetFont();
+ sal_Int32 nBackColor = getBackground();
+ sal_Int32 nColor = getForeground();
+ ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) );
+ aValues = pHelper->GetCharacterAttributes( aRequestedAttributes );
+ }
+
+ return aValues;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Rectangle VCLXAccessibleStatusBarItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+ if ( m_pStatusBar )
+ {
+ ::vcl::ControlLayoutData aLayoutData;
+ Rectangle aItemRect = m_pStatusBar->GetItemRect( m_nItemId );
+ m_pStatusBar->RecordLayoutData( &aLayoutData, aItemRect );
+ Rectangle aCharRect = aLayoutData.GetCharacterBounds( nIndex );
+ aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
+ aBounds = AWTRectangle( aCharRect );
+ }
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleStatusBarItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndex = -1;
+ if ( m_pStatusBar )
+ {
+ ::vcl::ControlLayoutData aLayoutData;
+ Rectangle aItemRect = m_pStatusBar->GetItemRect( m_nItemId );
+ m_pStatusBar->RecordLayoutData( &aLayoutData, aItemRect );
+ Point aPnt( VCLPoint( aPoint ) );
+ aPnt += aItemRect.TopLeft();
+ nIndex = aLayoutData.GetIndexForPoint( aPnt );
+ }
+
+ return nIndex;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleStatusBarItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleStatusBarItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ if ( m_pStatusBar )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pStatusBar->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
+
+ ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pDataObj, NULL );
+
+ Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+
+ Application::AcquireSolarMutex( nRef );
+
+ bReturn = sal_True;
+ }
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibletabcontrol.cxx b/accessibility/source/standard/vclxaccessibletabcontrol.cxx
new file mode 100644
index 000000000000..e2b77802e771
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibletabcontrol.cxx
@@ -0,0 +1,518 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibletabcontrol.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessibletabcontrol.hxx>
+#include <accessibility/standard/vclxaccessibletabpage.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 <vcl/tabctrl.hxx>
+#include <vcl/tabpage.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;
+
+
+// ----------------------------------------------------
+// class VCLXAccessibleTabControl
+// ----------------------------------------------------
+
+VCLXAccessibleTabControl::VCLXAccessibleTabControl( VCLXWindow* pVCLXWindow )
+ :VCLXAccessibleComponent( pVCLXWindow )
+{
+ m_pTabControl = static_cast< TabControl* >( GetWindow() );
+
+ if ( m_pTabControl )
+ m_aAccessibleChildren.assign( m_pTabControl->GetPageCount(), Reference< XAccessible >() );
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleTabControl::~VCLXAccessibleTabControl()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::UpdateFocused()
+{
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() );
+ if ( pVCLXAccessibleTabPage )
+ pVCLXAccessibleTabPage->SetFocused( pVCLXAccessibleTabPage->IsFocused() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::UpdateSelected( sal_Int32 i, bool bSelected )
+{
+ NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
+
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() );
+ if ( pVCLXAccessibleTabPage )
+ pVCLXAccessibleTabPage->SetSelected( bSelected );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::UpdatePageText( sal_Int32 i )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() );
+ if ( pVCLXAccessibleTabPage )
+ pVCLXAccessibleTabPage->SetPageText( pVCLXAccessibleTabPage->GetPageText() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::UpdateTabPage( sal_Int32 i, bool bNew )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() );
+ if ( pVCLXAccessibleTabPage )
+ pVCLXAccessibleTabPage->Update( bNew );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::InsertChild( sal_Int32 i )
+{
+ if ( i >= 0 && i <= (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ // insert entry in child list
+ m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() );
+
+ // send accessible child event
+ Reference< XAccessible > xChild( getAccessibleChild( i ) );
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aNewValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::RemoveChild( sal_Int32 i )
+{
+ if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
+ {
+ // get the accessible of the removed page
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
+
+ // remove entry in child list
+ m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
+
+ // send accessible child event
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+
+ Reference< XComponent > xComponent( xChild, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_TABPAGE_ACTIVATE:
+ case VCLEVENT_TABPAGE_DEACTIVATE:
+ {
+ if ( m_pTabControl )
+ {
+ sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ sal_uInt16 nPagePos = m_pTabControl->GetPagePos( nPageId );
+ UpdateFocused();
+ UpdateSelected( nPagePos, rVclWindowEvent.GetId() == VCLEVENT_TABPAGE_ACTIVATE );
+ }
+ }
+ break;
+ case VCLEVENT_TABPAGE_PAGETEXTCHANGED:
+ {
+ if ( m_pTabControl )
+ {
+ sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ sal_uInt16 nPagePos = m_pTabControl->GetPagePos( nPageId );
+ UpdatePageText( nPagePos );
+ }
+ }
+ break;
+ case VCLEVENT_TABPAGE_INSERTED:
+ {
+ if ( m_pTabControl )
+ {
+ sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ sal_uInt16 nPagePos = m_pTabControl->GetPagePos( nPageId );
+ InsertChild( nPagePos );
+ }
+ }
+ break;
+ case VCLEVENT_TABPAGE_REMOVED:
+ {
+ if ( m_pTabControl )
+ {
+ sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
+ for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
+ {
+ Reference< XAccessible > xChild( getAccessibleChild( i ) );
+ if ( xChild.is() )
+ {
+ VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() );
+ if ( pVCLXAccessibleTabPage && pVCLXAccessibleTabPage->GetPageId() == nPageId )
+ {
+ RemoveChild( i );
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ case VCLEVENT_TABPAGE_REMOVEDALL:
+ {
+ for ( sal_Int32 i = m_aAccessibleChildren.size() - 1; i >= 0; --i )
+ RemoveChild( i );
+ }
+ break;
+ case VCLEVENT_WINDOW_GETFOCUS:
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ {
+ UpdateFocused();
+ }
+ break;
+ case VCLEVENT_OBJECT_DYING:
+ {
+ if ( m_pTabControl )
+ {
+ m_pTabControl = NULL;
+
+ // dispose all tab pages
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ m_aAccessibleChildren.clear();
+ }
+
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+ break;
+ default:
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_WINDOW_SHOW:
+ case VCLEVENT_WINDOW_HIDE:
+ {
+ if ( m_pTabControl )
+ {
+ Window* pChild = static_cast< Window* >( rVclWindowEvent.GetData() );
+ if ( pChild && pChild->GetType() == WINDOW_TABPAGE )
+ {
+ for ( sal_Int32 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
+ {
+ sal_uInt16 nPageId = m_pTabControl->GetPageId( (USHORT)i );
+ TabPage* pTabPage = m_pTabControl->GetTabPage( nPageId );
+ if ( pTabPage == (TabPage*) pChild )
+ UpdateTabPage( i, rVclWindowEvent.GetId() == VCLEVENT_WINDOW_SHOW );
+ }
+ }
+ }
+ }
+ break;
+ default:
+ VCLXAccessibleComponent::ProcessWindowChildEvent( rVclWindowEvent );
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
+
+ if ( m_pTabControl )
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleTabControl, VCLXAccessibleComponent, VCLXAccessibleTabControl_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleTabControl, VCLXAccessibleComponent, VCLXAccessibleTabControl_BASE )
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::disposing()
+{
+ VCLXAccessibleComponent::disposing();
+
+ if ( m_pTabControl )
+ {
+ m_pTabControl = NULL;
+
+ // dispose all tab pages
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ m_aAccessibleChildren.clear();
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabControl::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleTabControl" );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > VCLXAccessibleTabControl::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleTabControl" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabControl::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return m_aAccessibleChildren.size();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleTabControl::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild = m_aAccessibleChildren[i];
+ if ( !xChild.is() )
+ {
+ if ( m_pTabControl )
+ {
+ sal_uInt16 nPageId = m_pTabControl->GetPageId( (USHORT)i );
+
+ xChild = new VCLXAccessibleTabPage( m_pTabControl, nPageId );
+
+ // insert into tab page list
+ m_aAccessibleChildren[i] = xChild;
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessibleTabControl::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::PAGE_TAB_LIST;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabControl::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleSelection
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ if ( m_pTabControl )
+ m_pTabControl->SelectTabPage( m_pTabControl->GetPageId( (USHORT)nChildIndex ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleTabControl::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ sal_Bool bSelected = sal_False;
+ if ( m_pTabControl && m_pTabControl->GetCurPageId() == m_pTabControl->GetPageId( (USHORT)nChildIndex ) )
+ bSelected = sal_True;
+
+ return bSelected;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::clearAccessibleSelection( ) throw (RuntimeException)
+{
+ // This method makes no sense in a tab control, and so does nothing.
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::selectAllAccessibleChildren( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ selectAccessibleChild( 0 );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabControl::getSelectedAccessibleChildCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 1;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleTabControl::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild;
+
+ for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ )
+ {
+ if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
+ {
+ xChild = getAccessibleChild( i );
+ break;
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabControl::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ // This method makes no sense in a tab control, and so does nothing.
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibletabpage.cxx b/accessibility/source/standard/vclxaccessibletabpage.cxx
new file mode 100644
index 000000000000..8cc85a022188
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibletabpage.cxx
@@ -0,0 +1,705 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibletabpage.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessibletabpage.hxx>
+#include <toolkit/helper/externallock.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <accessibility/helper/characterattributeshelper.hxx>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/unohelp2.hxx>
+#include <vcl/tabctrl.hxx>
+#include <vcl/tabpage.hxx>
+
+#include <memory>
+
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class VCLXAccessibleTabPage
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleTabPage::VCLXAccessibleTabPage( TabControl* pTabControl, sal_uInt16 nPageId )
+ :AccessibleTextHelper_BASE( new VCLExternalSolarLock() )
+ ,m_pTabControl( pTabControl )
+ ,m_nPageId( nPageId )
+{
+ m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
+ m_bFocused = IsFocused();
+ m_bSelected = IsSelected();
+ m_sPageText = GetPageText();
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleTabPage::~VCLXAccessibleTabPage()
+{
+ delete m_pExternalLock;
+ m_pExternalLock = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+bool VCLXAccessibleTabPage::IsFocused()
+{
+ bool bFocused = false;
+
+ if ( m_pTabControl && m_pTabControl->HasFocus() && m_pTabControl->GetCurPageId() == m_nPageId )
+ bFocused = true;
+
+ return bFocused;
+}
+
+// -----------------------------------------------------------------------------
+
+bool VCLXAccessibleTabPage::IsSelected()
+{
+ bool bSelected = false;
+
+ if ( m_pTabControl && m_pTabControl->GetCurPageId() == m_nPageId )
+ bSelected = true;
+
+ return bSelected;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPage::SetFocused( bool bFocused )
+{
+ if ( m_bFocused != bFocused )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bFocused )
+ aOldValue <<= AccessibleStateType::FOCUSED;
+ else
+ aNewValue <<= AccessibleStateType::FOCUSED;
+ m_bFocused = bFocused;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPage::SetSelected( bool bSelected )
+{
+ if ( m_bSelected != bSelected )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bSelected )
+ aOldValue <<= AccessibleStateType::SELECTED;
+ else
+ aNewValue <<= AccessibleStateType::SELECTED;
+ m_bSelected = bSelected;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPage::SetPageText( const ::rtl::OUString& sPageText )
+{
+ Any aOldValue, aNewValue;
+ if ( OCommonAccessibleText::implInitTextChangedEvent( m_sPageText, sPageText, aOldValue, aNewValue ) )
+ {
+ Any aOldName, aNewName;
+ aOldName <<= m_sPageText;
+ aNewName <<= sPageText;
+ m_sPageText = sPageText;
+ NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldName, aNewName );
+ NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabPage::GetPageText()
+{
+ ::rtl::OUString sText;
+ if ( m_pTabControl )
+ sText = OutputDevice::GetNonMnemonicString( m_pTabControl->GetPageText( m_nPageId ) );
+
+ return sText;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPage::Update( bool bNew )
+{
+ if ( m_pTabControl )
+ {
+ TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId );
+ if ( pTabPage )
+ {
+ Reference< XAccessible > xChild( pTabPage->GetAccessible( bNew ) );
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ if ( bNew )
+ aNewValue <<= xChild;
+ else
+ aOldValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPage::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ rStateSet.AddState( AccessibleStateType::ENABLED );
+ rStateSet.AddState( AccessibleStateType::SENSITIVE );
+
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+
+ if ( IsFocused() )
+ rStateSet.AddState( AccessibleStateType::FOCUSED );
+
+ rStateSet.AddState( AccessibleStateType::VISIBLE );
+
+ rStateSet.AddState( AccessibleStateType::SHOWING );
+
+ rStateSet.AddState( AccessibleStateType::SELECTABLE );
+
+ if ( IsSelected() )
+ rStateSet.AddState( AccessibleStateType::SELECTED );
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleComponent
+// -----------------------------------------------------------------------------
+
+awt::Rectangle VCLXAccessibleTabPage::implGetBounds() throw (RuntimeException)
+{
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+
+ if ( m_pTabControl )
+ aBounds = AWTRectangle( m_pTabControl->GetTabBounds( m_nPageId ) );
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleText
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabPage::implGetText()
+{
+ return GetPageText();
+}
+
+// -----------------------------------------------------------------------------
+
+lang::Locale VCLXAccessibleTabPage::implGetLocale()
+{
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPage::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
+{
+ nStartIndex = 0;
+ nEndIndex = 0;
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleTabPage, AccessibleTextHelper_BASE, VCLXAccessibleTabPage_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleTabPage, AccessibleTextHelper_BASE, VCLXAccessibleTabPage_BASE )
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPage::disposing()
+{
+ AccessibleTextHelper_BASE::disposing();
+
+ m_pTabControl = NULL;
+ m_sPageText = ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabPage::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleTabPage" );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleTabPage::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 > VCLXAccessibleTabPage::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleTabPage" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessible
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleContext > VCLXAccessibleTabPage::getAccessibleContext( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabPage::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nCount = 0;
+ if ( m_pTabControl )
+ {
+ TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId );
+ if ( pTabPage && pTabPage->IsVisible() )
+ nCount = 1;
+ }
+
+ return nCount;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild;
+ if ( m_pTabControl )
+ {
+ TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId );
+ if ( pTabPage && pTabPage->IsVisible() )
+ xChild = pTabPage->GetAccessible();
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xParent;
+ if ( m_pTabControl )
+ xParent = m_pTabControl->GetAccessible();
+
+ return xParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabPage::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndexInParent = -1;
+ if ( m_pTabControl )
+ nIndexInParent = m_pTabControl->GetPagePos( m_nPageId );
+
+ return nIndexInParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 VCLXAccessibleTabPage::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::PAGE_TAB;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabPage::getAccessibleDescription( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sDescription;
+ if ( m_pTabControl )
+ sDescription = m_pTabControl->GetHelpText( m_nPageId );
+
+ return sDescription;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabPage::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetPageText();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleRelationSet > VCLXAccessibleTabPage::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleStateSet > VCLXAccessibleTabPage::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;
+}
+
+// -----------------------------------------------------------------------------
+
+Locale VCLXAccessibleTabPage::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xChild;
+ for ( sal_uInt32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
+ {
+ Reference< XAccessible > xAcc = getAccessibleChild( i );
+ if ( xAcc.is() )
+ {
+ Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
+ if ( xComp.is() )
+ {
+ Rectangle aRect = VCLRectangle( xComp->getBounds() );
+ Point aPos = VCLPoint( rPoint );
+ if ( aRect.IsInside( aPos ) )
+ {
+ xChild = xAcc;
+ break;
+ }
+ }
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPage::grabFocus( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( m_pTabControl )
+ {
+ m_pTabControl->SelectTabPage( m_nPageId );
+ m_pTabControl->GrabFocus();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabPage::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ nColor = xParentComp->getForeground();
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabPage::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ nColor = xParentComp->getBackground();
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+
+Reference< awt::XFont > VCLXAccessibleTabPage::getFont( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< awt::XFont > xFont;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
+ if ( xParentComp.is() )
+ xFont = xParentComp->getFont();
+ }
+
+ return xFont;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabPage::getTitledBorderText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTabPage::getToolTipText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleText
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabPage::getCaretPosition() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return -1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleTabPage::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< PropertyValue > VCLXAccessibleTabPage::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Sequence< PropertyValue > aValues;
+ ::rtl::OUString sText( implGetText() );
+
+ if ( !implIsValidIndex( nIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ if ( m_pTabControl )
+ {
+ Font aFont = m_pTabControl->GetFont();
+ sal_Int32 nBackColor = getBackground();
+ sal_Int32 nColor = getForeground();
+ ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) );
+ aValues = pHelper->GetCharacterAttributes( aRequestedAttributes );
+ }
+
+ return aValues;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Rectangle VCLXAccessibleTabPage::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+ if ( m_pTabControl )
+ {
+ Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
+ Rectangle aCharRect = m_pTabControl->GetCharacterBounds( m_nPageId, nIndex );
+ aCharRect.Move( -aPageRect.Left(), -aPageRect.Top() );
+ aBounds = AWTRectangle( aCharRect );
+ }
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabPage::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndex = -1;
+ if ( m_pTabControl )
+ {
+ sal_uInt16 nPageId = 0;
+ Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
+ Point aPnt( VCLPoint( aPoint ) );
+ aPnt += aPageRect.TopLeft();
+ sal_Int32 nI = m_pTabControl->GetIndexForPoint( aPnt, nPageId );
+ if ( nI != -1 && m_nPageId == nPageId )
+ nIndex = nI;
+ }
+
+ return nIndex;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleTabPage::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleTabPage::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ if ( m_pTabControl )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pTabControl->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
+
+ ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pDataObj, NULL );
+
+ Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+
+ Application::AcquireSolarMutex( nRef );
+
+ bReturn = sal_True;
+ }
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibletabpagewindow.cxx b/accessibility/source/standard/vclxaccessibletabpagewindow.cxx
new file mode 100644
index 000000000000..1624e194afd4
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibletabpagewindow.cxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibletabpagewindow.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessibletabpagewindow.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <vcl/tabctrl.hxx>
+#include <vcl/tabpage.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// ----------------------------------------------------
+// class VCLXAccessibleTabPageWindow
+// ----------------------------------------------------
+
+VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindow )
+ :VCLXAccessibleComponent( pVCLXWindow )
+{
+ m_pTabPage = static_cast< TabPage* >( GetWindow() );
+ if ( m_pTabPage )
+ {
+ Window* pParent = m_pTabPage->GetAccessibleParentWindow();
+ if ( pParent && pParent->GetType() == WINDOW_TABCONTROL )
+ {
+ m_pTabControl = static_cast< TabControl* >( pParent );
+ if ( m_pTabControl )
+ {
+ for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
+ {
+ sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
+ if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage )
+ m_nPageId = nPageId;
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleTabPageWindow::~VCLXAccessibleTabPageWindow()
+{
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleComponent
+// -----------------------------------------------------------------------------
+
+awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds() throw (RuntimeException)
+{
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+
+ if ( m_pTabControl )
+ {
+ Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
+ if ( m_pTabPage )
+ {
+ Rectangle aRect = Rectangle( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
+ aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
+ aBounds = AWTRectangle( aRect );
+ }
+ }
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTabPageWindow::disposing()
+{
+ VCLXAccessibleComponent::disposing();
+
+ m_pTabControl = NULL;
+ m_pTabPage = NULL;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xParent;
+ if ( m_pTabControl )
+ {
+ Reference< XAccessible > xAcc( m_pTabControl->GetAccessible() );
+ if ( xAcc.is() )
+ {
+ Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() );
+ if ( xCont.is() )
+ xParent = xCont->getAccessibleChild( m_pTabControl->GetPagePos( m_nPageId ) );
+ }
+ }
+
+ return xParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibletextcomponent.cxx b/accessibility/source/standard/vclxaccessibletextcomponent.cxx
new file mode 100644
index 000000000000..87b25ffda078
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibletextcomponent.cxx
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibletextcomponent.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessibletextcomponent.hxx>
+#include <toolkit/helper/macros.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <accessibility/helper/characterattributeshelper.hxx>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/unohelp2.hxx>
+#include <vcl/ctrl.hxx>
+
+#include <memory>
+#include <vector>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// ----------------------------------------------------
+// class VCLXAccessibleTextComponent
+// ----------------------------------------------------
+
+VCLXAccessibleTextComponent::VCLXAccessibleTextComponent( VCLXWindow* pVCLXWindow )
+ :VCLXAccessibleComponent( pVCLXWindow )
+{
+ if ( GetWindow() )
+ m_sText = OutputDevice::GetNonMnemonicString( GetWindow()->GetText() );
+}
+
+// -----------------------------------------------------------------------------
+
+VCLXAccessibleTextComponent::~VCLXAccessibleTextComponent()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTextComponent::SetText( const ::rtl::OUString& sText )
+{
+ Any aOldValue, aNewValue;
+ if ( implInitTextChangedEvent( m_sText, sText, aOldValue, aNewValue ) )
+ {
+ m_sText = sText;
+ NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTextComponent::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_WINDOW_FRAMETITLECHANGED:
+ {
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ SetText( implGetText() );
+ }
+ break;
+ default:
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleText
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTextComponent::implGetText()
+{
+ ::rtl::OUString aText;
+ if ( GetWindow() )
+ aText = OutputDevice::GetNonMnemonicString( GetWindow()->GetText() );
+
+ return aText;
+}
+
+// -----------------------------------------------------------------------------
+
+lang::Locale VCLXAccessibleTextComponent::implGetLocale()
+{
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTextComponent::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
+{
+ nStartIndex = 0;
+ nEndIndex = 0;
+}
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleTextComponent::disposing()
+{
+ VCLXAccessibleComponent::disposing();
+
+ m_sText = ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleTextComponent, VCLXAccessibleComponent, VCLXAccessibleTextComponent_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleTextComponent, VCLXAccessibleComponent, VCLXAccessibleTextComponent_BASE )
+
+// -----------------------------------------------------------------------------
+// XAccessibleText
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTextComponent::getCaretPosition() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return -1;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleTextComponent::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return setSelection( nIndex, nIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Unicode VCLXAccessibleTextComponent::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getCharacter( nIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< PropertyValue > VCLXAccessibleTextComponent::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Sequence< PropertyValue > aValues;
+ ::rtl::OUString sText( implGetText() );
+
+ if ( !implIsValidIndex( nIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ if ( GetWindow() )
+ {
+ Font aFont = GetWindow()->GetControlFont();
+ sal_Int32 nBackColor = GetWindow()->GetControlBackground().GetColor();
+ sal_Int32 nColor = GetWindow()->GetControlForeground().GetColor();
+ ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) );
+ aValues = pHelper->GetCharacterAttributes( aRequestedAttributes );
+ }
+
+ return aValues;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Rectangle VCLXAccessibleTextComponent::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ awt::Rectangle aRect;
+ Control* pControl = static_cast< Control* >( GetWindow() );
+ if ( pControl )
+ aRect = AWTRectangle( pControl->GetCharacterBounds( nIndex ) );
+
+ return aRect;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTextComponent::getCharacterCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getCharacterCount();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTextComponent::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndex = -1;
+ Control* pControl = static_cast< Control* >( GetWindow() );
+ if ( pControl )
+ nIndex = pControl->GetIndexForPoint( VCLPoint( aPoint ) );
+
+ return nIndex;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTextComponent::getSelectedText() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getSelectedText();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTextComponent::getSelectionStart() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getSelectionStart();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 VCLXAccessibleTextComponent::getSelectionEnd() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getSelectionEnd();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleTextComponent::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTextComponent::getText() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getText();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString VCLXAccessibleTextComponent::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleTextComponent::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleTextComponent::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::accessibility::TextSegment VCLXAccessibleTextComponent::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool VCLXAccessibleTextComponent::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ if ( GetWindow() )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
+
+ ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pDataObj, NULL );
+
+ Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+
+ Application::AcquireSolarMutex( nRef );
+
+ bReturn = sal_True;
+ }
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibletextfield.cxx b/accessibility/source/standard/vclxaccessibletextfield.cxx
new file mode 100644
index 000000000000..1d1dadd0e907
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibletextfield.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibletextfield.cxx,v $
+ * $Revision: 1.3 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessibletextfield.hxx>
+#include <vcl/lstbox.hxx>
+#include <accessibility/helper/listboxhelper.hxx>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <vcl/svapp.hxx>
+#include <vcl/combobox.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+
+
+
+
+VCLXAccessibleTextField::VCLXAccessibleTextField (VCLXWindow* pVCLWindow, const Reference< XAccessible >& _xParent) :
+
+ VCLXAccessibleTextComponent (pVCLWindow),
+
+ m_xParent( _xParent )
+
+{
+}
+
+
+
+
+VCLXAccessibleTextField::~VCLXAccessibleTextField (void)
+{
+}
+
+
+
+
+::rtl::OUString VCLXAccessibleTextField::implGetText (void)
+{
+ ::rtl::OUString aText;
+ ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ if (pListBox!=NULL && !pListBox->IsInDropDown())
+ aText = pListBox->GetSelectEntry();
+
+ return aText;
+}
+
+
+
+
+IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE)
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE)
+
+
+//===== XAccessible =========================================================
+
+Reference<XAccessibleContext> SAL_CALL
+ VCLXAccessibleTextField::getAccessibleContext (void)
+ throw (RuntimeException)
+{
+ return this;
+}
+
+
+//===== XAccessibleContext ==================================================
+
+sal_Int32 SAL_CALL VCLXAccessibleTextField::getAccessibleChildCount (void)
+ throw (RuntimeException)
+{
+ return 0;
+}
+
+
+
+
+Reference<XAccessible> SAL_CALL VCLXAccessibleTextField::getAccessibleChild (sal_Int32)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ throw IndexOutOfBoundsException();
+}
+
+
+
+
+sal_Int16 SAL_CALL VCLXAccessibleTextField::getAccessibleRole (void)
+ throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ return AccessibleRole::TEXT;
+}
+
+Reference< XAccessible > SAL_CALL VCLXAccessibleTextField::getAccessibleParent( )
+ throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ return m_xParent;
+}
+
+
+
+//===== XServiceInfo ==========================================================
+
+::rtl::OUString VCLXAccessibleTextField::getImplementationName (void)
+ throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii ("com.sun.star.comp.toolkit.AccessibleTextField");
+}
+
+
+
+
+Sequence< ::rtl::OUString > VCLXAccessibleTextField::getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames = VCLXAccessibleTextComponent::getSupportedServiceNames();
+ sal_Int32 nLength = aNames.getLength();
+ aNames.realloc( nLength + 1 );
+ aNames[nLength] = ::rtl::OUString::createFromAscii(
+ "com.sun.star.accessibility.AccessibleTextField");
+ return aNames;
+}
diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx
new file mode 100644
index 000000000000..3e4ecd843d7d
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx
@@ -0,0 +1,858 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibletoolbox.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * 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_accessibility.hxx"
+
+// includes --------------------------------------------------------------
+#include <accessibility/standard/vclxaccessibletoolbox.hxx>
+#include <accessibility/standard/vclxaccessibletoolboxitem.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <tools/debug.hxx>
+#include <vcl/toolbox.hxx>
+#include <comphelper/accessiblewrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+using namespace ::comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::accessibility;
+
+namespace
+{
+ // =========================================================================
+ // = OToolBoxWindowItemContext
+ // =========================================================================
+ /** XAccessibleContext implementation for a toolbox item which is represented by a VCL Window
+ */
+ class OToolBoxWindowItemContext : public OAccessibleContextWrapper
+ {
+ sal_Int32 m_nIndexInParent;
+ public:
+ OToolBoxWindowItemContext(sal_Int32 _nIndexInParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxOwningAccessible,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParentAccessible
+ ) : OAccessibleContextWrapper(
+ _rxORB,
+ _rxInnerAccessibleContext,
+ _rxOwningAccessible,
+ _rxParentAccessible )
+ ,m_nIndexInParent(_nIndexInParent)
+ {
+ }
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ // -------------------------------------------------------------------------
+ sal_Int32 SAL_CALL OToolBoxWindowItemContext::getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_nIndexInParent;
+ }
+
+ // =========================================================================
+ // = OToolBoxWindowItem
+ // =========================================================================
+ typedef ::cppu::ImplHelper1 < XUnoTunnel
+ > OToolBoxWindowItem_Base;
+
+ /** XAccessible implementation for a toolbox item which is represented by a VCL Window
+ */
+ class OToolBoxWindowItem
+ :public OAccessibleWrapper
+ ,public OToolBoxWindowItem_Base
+ {
+ private:
+ sal_Int32 m_nIndexInParent;
+
+ public:
+ inline sal_Int32 getIndexInParent() const { return m_nIndexInParent; }
+ inline void setIndexInParent( sal_Int32 _nNewIndex ) { m_nIndexInParent = _nNewIndex; }
+
+ static sal_Bool isWindowItem( const Reference< XAccessible >& _rxAcc, OToolBoxWindowItem** /* [out] */ _ppImplementation = NULL );
+
+ public:
+ OToolBoxWindowItem(sal_Int32 _nIndexInParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxInnerAccessible,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParentAccessible
+ ) : OAccessibleWrapper(
+ _rxORB,
+ _rxInnerAccessible,
+ _rxParentAccessible)
+ ,m_nIndexInParent(_nIndexInParent)
+ {
+ }
+
+ protected:
+ // XInterface
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ // OAccessibleWrapper
+ virtual OAccessibleContextWrapper* createAccessibleContext(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxInnerContext
+ );
+
+ // XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw (RuntimeException);
+ static Sequence< sal_Int8 > getUnoTunnelImplementationId();
+ };
+
+ // -------------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( OToolBoxWindowItem, OAccessibleWrapper, OToolBoxWindowItem_Base )
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( OToolBoxWindowItem, OAccessibleWrapper, OToolBoxWindowItem_Base )
+
+ // -------------------------------------------------------------------------
+ OAccessibleContextWrapper* OToolBoxWindowItem::createAccessibleContext(
+ const Reference< XAccessibleContext >& _rxInnerContext )
+ {
+ return new OToolBoxWindowItemContext( m_nIndexInParent,getORB(), _rxInnerContext, this, getParent() );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OToolBoxWindowItem::isWindowItem( const Reference< XAccessible >& _rxAcc, OToolBoxWindowItem** /* [out] */ _ppImplementation )
+ {
+ OToolBoxWindowItem* pImplementation = NULL;
+
+ Reference< XUnoTunnel > xTunnel( _rxAcc, UNO_QUERY );
+ if ( xTunnel.is() )
+ pImplementation = reinterpret_cast< OToolBoxWindowItem* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
+
+ if ( _ppImplementation )
+ *_ppImplementation = pImplementation;
+
+ return NULL != pImplementation;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< sal_Int8 > OToolBoxWindowItem::getUnoTunnelImplementationId()
+ {
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int64 SAL_CALL OToolBoxWindowItem::getSomething( const Sequence< sal_Int8 >& _rId ) throw (RuntimeException)
+ {
+ if ( ( 16 == _rId.getLength() )
+ && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), _rId.getConstArray(), 16 ) )
+ )
+ return reinterpret_cast< sal_Int64>( this );
+
+ return 0;
+ }
+}
+
+DBG_NAME(VCLXAccessibleToolBox)
+
+// -----------------------------------------------------------------------------
+// VCLXAccessibleToolBox
+// -----------------------------------------------------------------------------
+VCLXAccessibleToolBox::VCLXAccessibleToolBox( VCLXWindow* pVCLXWindow ) :
+
+ VCLXAccessibleComponent( pVCLXWindow )
+
+{
+ DBG_CTOR(VCLXAccessibleToolBox,NULL);
+}
+// -----------------------------------------------------------------------------
+VCLXAccessibleToolBox::~VCLXAccessibleToolBox()
+{
+ DBG_DTOR(VCLXAccessibleToolBox,NULL);
+}
+// -----------------------------------------------------------------------------
+VCLXAccessibleToolBoxItem* VCLXAccessibleToolBox::GetItem_Impl( sal_Int32 _nPos, bool _bMustHaveFocus )
+{
+ VCLXAccessibleToolBoxItem* pItem = NULL;
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox && ( !_bMustHaveFocus || pToolBox->HasFocus() ) )
+ {
+ ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
+ // returns only toolbox buttons, not windows
+ if ( aIter != m_aAccessibleChildren.end() && !aIter->second.is())
+ pItem = static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
+ }
+
+ return pItem;
+}
+// -----------------------------------------------------------------------------
+
+void VCLXAccessibleToolBox::UpdateFocus_Impl()
+{
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if( !pToolBox )
+ return;
+
+ // submit events only if toolbox has the focus to avoid sending events due to mouse move
+ BOOL bHasFocus = FALSE;
+ if ( pToolBox->HasFocus() )
+ bHasFocus = TRUE;
+ else
+ {
+ // check for subtoolbar, i.e. check if our parent is a toolbar
+ ToolBox* pToolBoxParent = dynamic_cast< ToolBox* >( pToolBox->GetParent() );
+ // subtoolbars never get the focus as key input is just forwarded, so check if the parent toolbar has it
+ if ( pToolBoxParent && pToolBoxParent->HasFocus() )
+ bHasFocus = TRUE;
+ }
+
+ if ( bHasFocus )
+ {
+ USHORT nHighlightItemId = pToolBox->GetHighlightItemId();
+ USHORT nFocusCount = 0;
+ for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
+ aIter != m_aAccessibleChildren.end(); ++aIter )
+ {
+ USHORT nItemId = pToolBox->GetItemId( (USHORT)aIter->first );
+
+ if ( aIter->second.is() )
+ {
+ VCLXAccessibleToolBoxItem* pItem =
+ static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
+ if ( pItem->HasFocus() && nItemId != nHighlightItemId )
+ {
+ // reset the old focused item
+ pItem->SetFocus( sal_False );
+ nFocusCount++;
+ }
+ if ( nItemId == nHighlightItemId )
+ {
+ // set the new focused item
+ pItem->SetFocus( sal_True );
+ nFocusCount++;
+ }
+ }
+ // both items changed?
+ if ( nFocusCount > 1 )
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::ReleaseFocus_Impl( sal_Int32 _nPos )
+{
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox ) // #107124#, do not check for focus because this message is also handled in losefocus
+ {
+ ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
+ if ( aIter != m_aAccessibleChildren.end() && aIter->second.is() )
+ {
+ VCLXAccessibleToolBoxItem* pItem =
+ static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
+ if ( pItem->HasFocus() )
+ pItem->SetFocus( sal_False );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::UpdateChecked_Impl( sal_Int32 )
+{
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ {
+ for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
+ aIter != m_aAccessibleChildren.end(); ++aIter )
+ {
+ USHORT nItemId = pToolBox->GetItemId( (USHORT)aIter->first );
+
+ VCLXAccessibleToolBoxItem* pItem =
+ static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
+ pItem->SetChecked( pToolBox->IsItemChecked( nItemId ) );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::UpdateIndeterminate_Impl( sal_Int32 _nPos )
+{
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ {
+ USHORT nItemId = pToolBox->GetItemId( (USHORT)_nPos );
+
+ ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
+ if ( aIter != m_aAccessibleChildren.end() && aIter->second.is() )
+ {
+ VCLXAccessibleToolBoxItem* pItem =
+ static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
+ if ( pItem )
+ pItem->SetIndeterminate( pToolBox->GetItemState( nItemId ) == STATE_DONTKNOW );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::implReleaseToolboxItem( ToolBoxItemsMap::iterator& _rMapPos,
+ bool _bNotifyRemoval, bool _bDispose )
+{
+ Reference< XAccessible > xItemAcc( _rMapPos->second );
+ if ( !xItemAcc.is() )
+ return;
+
+ if ( _bNotifyRemoval )
+ {
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, makeAny( xItemAcc ), Any() );
+ }
+
+ OToolBoxWindowItem* pWindowItem = NULL;
+ if ( !OToolBoxWindowItem::isWindowItem( xItemAcc, &pWindowItem ) )
+ {
+ static_cast< VCLXAccessibleToolBoxItem* >( xItemAcc.get() )->ReleaseToolBox();
+ if ( _bDispose )
+ ::comphelper::disposeComponent( xItemAcc );
+ }
+ else
+ {
+ if ( _bDispose )
+ {
+ if ( pWindowItem )
+ {
+ Reference< XAccessibleContext > xContext( pWindowItem->getContextNoCreate() );
+ ::comphelper::disposeComponent( xContext );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::UpdateItem_Impl( sal_Int32 _nPos, sal_Bool _bItemAdded )
+{
+ if ( _nPos < sal_Int32( m_aAccessibleChildren.size() ) )
+ {
+ UpdateAllItems_Impl();
+ return;
+ }
+
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ {
+ if ( !_bItemAdded )
+ { // the item was removed
+ // -> destroy the old item
+ ToolBoxItemsMap::iterator aItemPos = m_aAccessibleChildren.find( _nPos );
+ if ( m_aAccessibleChildren.end() != aItemPos )
+ {
+ implReleaseToolboxItem( aItemPos, true, true );
+ m_aAccessibleChildren.erase( aItemPos );
+ }
+ }
+
+ // adjust the "index-in-parent"s
+ ToolBoxItemsMap::iterator aIndexAdjust = m_aAccessibleChildren.upper_bound( _nPos );
+ while ( m_aAccessibleChildren.end() != aIndexAdjust )
+ {
+ Reference< XAccessible > xItemAcc( aIndexAdjust->second );
+
+ OToolBoxWindowItem* pWindowItem = NULL;
+ if ( !OToolBoxWindowItem::isWindowItem( xItemAcc, &pWindowItem ) )
+ {
+ VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xItemAcc.get() );
+ if ( pItem )
+ {
+ sal_Int32 nIndex = pItem->getIndexInParent( );
+ nIndex += _bItemAdded ? +1 : -1;
+ pItem->setIndexInParent( nIndex );
+ }
+ }
+ else
+ {
+ if ( pWindowItem )
+ {
+ sal_Int32 nIndex = pWindowItem->getIndexInParent( );
+ nIndex += _bItemAdded ? +1 : -1;
+ pWindowItem->setIndexInParent( nIndex );
+ }
+ }
+
+ ++aIndexAdjust;
+ }
+
+ if ( _bItemAdded )
+ {
+ // TODO: we should make this dependent on the existence of event listeners
+ // with the current implementation, we always create accessible object
+ Any aNewChild = makeAny( getAccessibleChild( (sal_Int32)_nPos ) );
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewChild );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::UpdateAllItems_Impl()
+{
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ {
+ // deregister the old items
+ for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
+ aIter != m_aAccessibleChildren.end(); ++aIter )
+ {
+ implReleaseToolboxItem( aIter, true, true );
+ }
+ m_aAccessibleChildren.clear();
+
+ // register the new items
+ USHORT i, nCount = pToolBox->GetItemCount();
+ for ( i = 0; i < nCount; ++i )
+ {
+ Any aNewValue;
+ aNewValue <<= getAccessibleChild( (sal_Int32)i );;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::UpdateItemName_Impl( sal_Int32 _nPos )
+{
+ VCLXAccessibleToolBoxItem* pItem = GetItem_Impl( _nPos, false );
+ if ( pItem )
+ pItem->NameChanged();
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::UpdateItemEnabled_Impl( sal_Int32 _nPos )
+{
+ VCLXAccessibleToolBoxItem* pItem = GetItem_Impl( _nPos, false );
+ if ( pItem )
+ pItem->ToggleEnableState();
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent, bool _bShow )
+{
+ Window* pChildWindow = (Window *) rVclWindowEvent.GetData();
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pChildWindow
+ && pToolBox
+ && pToolBox == pChildWindow->GetParent()
+ && pChildWindow->GetType() == WINDOW_TOOLBOX )
+ {
+ sal_Int32 nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
+ Reference< XAccessible > xItem = getAccessibleChild( nIndex );
+ if ( xItem.is() )
+ {
+ Reference< XAccessible > xChild = pChildWindow->GetAccessible();
+ VCLXAccessibleToolBoxItem* pItem =
+ static_cast< VCLXAccessibleToolBoxItem* >( xItem.get() );
+ pItem->SetChild( xChild );
+ pItem->NotifyChildEvent( xChild, _bShow );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::ReleaseSubToolBox( ToolBox* _pSubToolBox )
+{
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ {
+ sal_Int32 nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
+ Reference< XAccessible > xItem = getAccessibleChild( nIndex );
+ if ( xItem.is() )
+ {
+ Reference< XAccessible > xChild = _pSubToolBox->GetAccessible();
+ VCLXAccessibleToolBoxItem* pItem =
+ static_cast< VCLXAccessibleToolBoxItem* >( xItem.get() );
+ if ( pItem->GetChild() == xChild )
+ {
+ pItem->SetChild( Reference< XAccessible >() );
+ pItem->NotifyChildEvent( xChild, false );
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
+
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ {
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+ if ( pToolBox->IsHorizontal() )
+ rStateSet.AddState( AccessibleStateType::HORIZONTAL );
+ else
+ rStateSet.AddState( AccessibleStateType::VERTICAL );
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ // to prevent an early release of the toolbox (VCLEVENT_OBJECT_DYING)
+ Reference< XAccessibleContext > xTemp = this;
+
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_TOOLBOX_CLICK:
+ {
+ if ( rVclWindowEvent.GetData() )
+ {
+ UpdateChecked_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
+ UpdateIndeterminate_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
+ }
+ break;
+ }
+ case VCLEVENT_TOOLBOX_DOUBLECLICK:
+ case VCLEVENT_TOOLBOX_ACTIVATE:
+ case VCLEVENT_TOOLBOX_DEACTIVATE:
+ case VCLEVENT_TOOLBOX_SELECT:
+ break;
+
+ case VCLEVENT_TOOLBOX_HIGHLIGHT:
+ UpdateFocus_Impl();
+ break;
+
+ case VCLEVENT_TOOLBOX_HIGHLIGHTOFF:
+ ReleaseFocus_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
+ break;
+
+ case VCLEVENT_TOOLBOX_ITEMADDED :
+// UpdateItem_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData(), VCLEVENT_TOOLBOX_ITEMADDED == rVclWindowEvent.GetId() );
+ UpdateItem_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData(), sal_True );
+ break;
+
+ case VCLEVENT_TOOLBOX_ITEMREMOVED :
+ case VCLEVENT_TOOLBOX_ALLITEMSCHANGED :
+ {
+ UpdateAllItems_Impl();
+ break;
+ }
+
+ case VCLEVENT_TOOLBOX_ITEMWINDOWCHANGED:
+ {
+ sal_Int32 nPos = (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData();
+ ToolBoxItemsMap::iterator aAccessiblePos( m_aAccessibleChildren.find( nPos ) );
+ if ( m_aAccessibleChildren.end() != aAccessiblePos )
+ {
+ implReleaseToolboxItem( aAccessiblePos, false, true );
+ m_aAccessibleChildren.erase (aAccessiblePos);
+ }
+
+ Any aNewValue;
+ aNewValue <<= getAccessibleChild(nPos);
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue );
+ break;
+ }
+ case VCLEVENT_TOOLBOX_ITEMTEXTCHANGED :
+ UpdateItemName_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
+ break;
+
+ case VCLEVENT_TOOLBOX_ITEMENABLED :
+ case VCLEVENT_TOOLBOX_ITEMDISABLED :
+ {
+ UpdateItemEnabled_Impl( (sal_Int32)(sal_IntPtr)rVclWindowEvent.GetData() );
+ break;
+ }
+
+ case VCLEVENT_OBJECT_DYING :
+ {
+ // if this toolbox is a subtoolbox, we have to relese it from its parent
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox && pToolBox->GetParent() &&
+ pToolBox->GetParent()->GetType() == WINDOW_TOOLBOX )
+ {
+ VCLXAccessibleToolBox* pParent = static_cast< VCLXAccessibleToolBox* >(
+ pToolBox->GetParent()->GetAccessible()->getAccessibleContext().get() );
+ if ( pParent )
+ pParent->ReleaseSubToolBox( pToolBox );
+ }
+
+ // dispose all items
+ for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
+ aIter != m_aAccessibleChildren.end(); ++aIter )
+ {
+ implReleaseToolboxItem( aIter, false, true );
+ }
+ m_aAccessibleChildren.clear();
+
+ //!!! no break to call base class
+ }
+
+ default:
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_WINDOW_SHOW: // send create on show for direct accessible children
+ {
+ Reference< XAccessible > xReturn = GetItemWindowAccessible(rVclWindowEvent);
+ if ( xReturn.is() )
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), makeAny(xReturn) );
+ else
+ HandleSubToolBarEvent( rVclWindowEvent, true );
+ }
+ break;
+
+ default:
+ VCLXAccessibleComponent::ProcessWindowChildEvent( rVclWindowEvent );
+
+ }
+}
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleToolBox, VCLXAccessibleComponent, VCLXAccessibleToolBox_BASE )
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleToolBox, VCLXAccessibleComponent, VCLXAccessibleToolBox_BASE )
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleToolBox::disposing()
+{
+ VCLXAccessibleComponent::disposing();
+
+ // release the items
+ for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
+ aIter != m_aAccessibleChildren.end(); ++aIter )
+ {
+ implReleaseToolboxItem( aIter, false, true );
+ }
+ m_aAccessibleChildren.clear();
+}
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+::rtl::OUString VCLXAccessibleToolBox::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleToolBox" );
+}
+// -----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > VCLXAccessibleToolBox::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames = VCLXAccessibleComponent::getSupportedServiceNames();
+ sal_Int32 nLength = aNames.getLength();
+ aNames.realloc( nLength + 1 );
+ aNames[nLength] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleToolBox" );
+ return aNames;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleToolBox::getAccessibleChildCount( ) throw (RuntimeException)
+{
+ comphelper::OExternalLockGuard aGuard( this );
+
+ sal_Int32 nCount = 0;
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ nCount = pToolBox->GetItemCount();
+
+ return nCount;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ comphelper::OExternalLockGuard aGuard( this );
+
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ {
+ Reference< XAccessible > xChild;
+ // search for the child
+ ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find(i);
+ if ( m_aAccessibleChildren.end() == aIter )
+ {
+ USHORT nItemId = pToolBox->GetItemId( (USHORT)i );
+ USHORT nHighlightItemId = pToolBox->GetHighlightItemId();
+ Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
+ // not found -> create a new child
+ VCLXAccessibleToolBoxItem* pChild = new VCLXAccessibleToolBoxItem( pToolBox, i );
+ Reference< XAccessible> xParent = pChild;
+ if ( pItemWindow )
+ {
+ xChild = new OToolBoxWindowItem(0,::comphelper::getProcessServiceFactory(),pItemWindow->GetAccessible(),xParent);
+ pItemWindow->SetAccessible(xChild);
+ pChild->SetChild( xChild );
+ }
+ xChild = pChild;
+ if ( nHighlightItemId > 0 && nItemId == nHighlightItemId )
+ pChild->SetFocus( sal_True );
+ if ( pToolBox->IsItemChecked( nItemId ) )
+ pChild->SetChecked( sal_True );
+ if ( pToolBox->GetItemState( nItemId ) == STATE_DONTKNOW )
+ pChild->SetIndeterminate( true );
+ m_aAccessibleChildren.insert( ToolBoxItemsMap::value_type( i, xChild ) );
+ }
+ else
+ {
+ // found it
+ xChild = aIter->second;
+ }
+ return xChild;
+ }
+
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleAtPoint( const awt::Point& _rPoint ) throw (RuntimeException)
+{
+ comphelper::OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xAccessible;
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pToolBox )
+ {
+ USHORT nItemPos = pToolBox->GetItemPos( VCLPoint( _rPoint ) );
+ if ( nItemPos != TOOLBOX_ITEM_NOTFOUND )
+ xAccessible = getAccessibleChild( nItemPos );
+ }
+
+ return xAccessible;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > VCLXAccessibleToolBox::GetItemWindowAccessible( const VclWindowEvent& rVclWindowEvent )
+{
+ Reference< XAccessible > xReturn;
+ Window* pChildWindow = (Window *) rVclWindowEvent.GetData();
+ ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() );
+ if ( pChildWindow && pToolBox )
+ {
+ USHORT nCount = pToolBox->GetItemCount();
+ for (USHORT i = 0 ; i < nCount && !xReturn.is() ; ++i)
+ {
+ USHORT nItemId = pToolBox->GetItemId( i );
+ Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
+ if ( pItemWindow == pChildWindow )
+ xReturn = getAccessibleChild(i);
+ }
+ }
+ return xReturn;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > VCLXAccessibleToolBox::GetChildAccessible( const VclWindowEvent& rVclWindowEvent )
+{
+ Reference< XAccessible > xReturn = GetItemWindowAccessible(rVclWindowEvent);
+
+ if ( !xReturn.is() )
+ xReturn = VCLXAccessibleComponent::GetChildAccessible(rVclWindowEvent);
+ return xReturn;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleSelection
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+ ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() );
+ USHORT nPos = static_cast < USHORT > (nChildIndex);
+ pToolBox->ChangeHighlight( nPos );
+}
+// -----------------------------------------------------------------------------
+sal_Bool VCLXAccessibleToolBox::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+ ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() );
+ USHORT nPos = static_cast < USHORT > (nChildIndex);
+ if ( pToolBox != NULL && pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nPos ) )
+ return sal_True;
+ else
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::clearAccessibleSelection( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() );
+ pToolBox -> LoseFocus();
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::selectAllAccessibleChildren( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ // intentionally empty. makes no sense for a toolbox
+}
+// -----------------------------------------------------------------------------
+sal_Int32 VCLXAccessibleToolBox::getSelectedAccessibleChildCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ sal_Int32 nRet = 0;
+ for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; i++ )
+ {
+ if ( isAccessibleChildSelected( i ) )
+ {
+ nRet = 1;
+ break; // a toolbox can only have (n)one selected child
+ }
+ }
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > VCLXAccessibleToolBox::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+ Reference< XAccessible > xChild;
+ for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ )
+ {
+ if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
+ {
+ xChild = getAccessibleChild( i );
+ break;
+ }
+ }
+ return xChild;
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBox::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+ clearAccessibleSelection(); // a toolbox can only have (n)one selected child
+}
+// -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
new file mode 100644
index 000000000000..76507d22e3cf
--- /dev/null
+++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
@@ -0,0 +1,721 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclxaccessibletoolboxitem.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * 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_accessibility.hxx"
+#include <accessibility/standard/vclxaccessibletoolboxitem.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <accessibility/helper/accresmgr.hxx>
+#include <accessibility/helper/accessiblestrings.hrc>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/Size.hpp>
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/unohelp2.hxx>
+#include <vcl/help.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/externallock.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+
+#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
+
+// class VCLXAccessibleToolBoxItem ------------------------------------------
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+
+DBG_NAME(VCLXAccessibleToolBoxItem)
+
+// -----------------------------------------------------------------------------
+// Ctor() and Dtor()
+// -----------------------------------------------------------------------------
+VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_Int32 _nPos ) :
+
+ AccessibleTextHelper_BASE( new VCLExternalSolarLock() ),
+
+ m_pToolBox ( _pToolBox ),
+ m_nIndexInParent( _nPos ),
+ m_nRole ( AccessibleRole::PUSH_BUTTON ),
+ m_nItemId ( 0 ),
+ m_bHasFocus ( sal_False ),
+ m_bIsChecked ( sal_False ),
+ m_bIndeterminate( false )
+
+{
+ DBG_CTOR( VCLXAccessibleToolBoxItem, NULL );
+
+ m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock( ) );
+
+ DBG_ASSERT( m_pToolBox, "invalid toolbox" );
+ m_nItemId = m_pToolBox->GetItemId( (USHORT)m_nIndexInParent );
+ m_sOldName = GetText( true );
+ m_bIsChecked = m_pToolBox->IsItemChecked( m_nItemId );
+ m_bIndeterminate = ( m_pToolBox->GetItemState( m_nItemId ) == STATE_DONTKNOW );
+ ToolBoxItemType eType = m_pToolBox->GetItemType( (USHORT)m_nIndexInParent );
+ switch ( eType )
+ {
+ case TOOLBOXITEM_BUTTON :
+ {
+ ToolBoxItemBits nBits = m_pToolBox->GetItemBits( m_nItemId );
+ if (( nBits & TIB_DROPDOWN ) == TIB_DROPDOWN)
+ m_nRole = AccessibleRole::BUTTON_DROPDOWN;
+ else if (( ( nBits & TIB_CHECKABLE ) == TIB_CHECKABLE ) ||
+ ( ( nBits & TIB_AUTOCHECK ) == TIB_AUTOCHECK ) )
+ m_nRole = AccessibleRole::TOGGLE_BUTTON;
+ else if ( m_pToolBox->GetItemWindow( m_nItemId ) )
+ m_nRole = AccessibleRole::PANEL;
+ break;
+ }
+
+ case TOOLBOXITEM_SPACE :
+ m_nRole = AccessibleRole::FILLER;
+ break;
+
+ case TOOLBOXITEM_SEPARATOR :
+ case TOOLBOXITEM_BREAK :
+ m_nRole = AccessibleRole::SEPARATOR;
+ break;
+
+ default:
+ {
+ DBG_ERRORFILE( "unsupported toolbox itemtype" );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+VCLXAccessibleToolBoxItem::~VCLXAccessibleToolBoxItem()
+{
+ DBG_DTOR( VCLXAccessibleToolBoxItem, NULL );
+
+ delete m_pExternalLock;
+ m_pExternalLock = NULL;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString VCLXAccessibleToolBoxItem::GetText( bool _bAsName )
+{
+ ::rtl::OUString sRet;
+ // no text for separators and spaces
+ if ( m_pToolBox && m_nItemId > 0 && ( _bAsName || m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) )
+ {
+ sRet = m_pToolBox->GetItemText( m_nItemId );
+//OJ #108243# we only read the name of the toolboxitem
+//
+// Window* pItemWindow = m_pToolBox->GetItemWindow( m_nItemId );
+// if ( pItemWindow && pItemWindow->GetAccessible().is() &&
+// pItemWindow->GetAccessible()->getAccessibleContext().is() )
+// {
+// ::rtl::OUString sWinText = pItemWindow->GetAccessible()->getAccessibleContext()->getAccessibleName();
+// if ( ( sRet.getLength() > 0 ) && ( sWinText.getLength() > 0 ) )
+// sRet += String( RTL_CONSTASCII_USTRINGPARAM( " " ) );
+// sRet += sWinText;
+// }
+ }
+ return sRet;
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBoxItem::SetFocus( sal_Bool _bFocus )
+{
+ if ( m_bHasFocus != _bFocus )
+ {
+ Any aOldValue;
+ Any aNewValue;
+ if ( m_bHasFocus )
+ aOldValue <<= AccessibleStateType::FOCUSED;
+ else
+ aNewValue <<= AccessibleStateType::FOCUSED;
+ m_bHasFocus = _bFocus;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBoxItem::SetChecked( sal_Bool _bCheck )
+{
+ if ( m_bIsChecked != _bCheck )
+ {
+ Any aOldValue;
+ Any aNewValue;
+ if ( m_bIsChecked )
+ aOldValue <<= AccessibleStateType::CHECKED;
+ else
+ aNewValue <<= AccessibleStateType::CHECKED;
+ m_bIsChecked = _bCheck;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBoxItem::SetIndeterminate( bool _bIndeterminate )
+{
+ if ( m_bIndeterminate != _bIndeterminate )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bIndeterminate )
+ aOldValue <<= AccessibleStateType::INDETERMINATE;
+ else
+ aNewValue <<= AccessibleStateType::INDETERMINATE;
+ m_bIndeterminate = _bIndeterminate;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBoxItem::NameChanged()
+{
+ ::rtl::OUString sNewName = implGetText();
+ if ( sNewName != m_sOldName )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= m_sOldName;
+ // save new name as old name for next change
+ m_sOldName = sNewName;
+ aNewValue <<= m_sOldName;
+ NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
+ }
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBoxItem::SetChild( const Reference< XAccessible >& _xChild )
+{
+ m_xChild = _xChild;
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBoxItem::NotifyChildEvent( const Reference< XAccessible >& _xChild, bool _bShow )
+{
+ Any aOld = _bShow ? Any() : makeAny( _xChild );
+ Any aNew = _bShow ? makeAny( _xChild ) : Any();
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOld, aNew );
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBoxItem::ToggleEnableState()
+{
+ Any aOldValue[2], aNewValue[2];
+ if ( m_pToolBox->IsItemEnabled( m_nItemId ) )
+ {
+ aNewValue[0] <<= AccessibleStateType::SENSITIVE;
+ aNewValue[1] <<= AccessibleStateType::ENABLED;
+ }
+ else
+ {
+ aOldValue[0] <<= AccessibleStateType::ENABLED;
+ aOldValue[1] <<= AccessibleStateType::SENSITIVE;
+ }
+
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] );
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] );
+}
+// -----------------------------------------------------------------------------
+awt::Rectangle SAL_CALL VCLXAccessibleToolBoxItem::implGetBounds( ) throw (RuntimeException)
+{
+ awt::Rectangle aRect;
+ if ( m_pToolBox )
+ aRect = AWTRectangle( m_pToolBox->GetItemPosRect( (USHORT)m_nIndexInParent ) );
+
+ return aRect;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString VCLXAccessibleToolBoxItem::implGetText()
+{
+ return GetText (true);
+}
+// -----------------------------------------------------------------------------
+Locale VCLXAccessibleToolBoxItem::implGetLocale()
+{
+ return Application::GetSettings().GetUILocale();
+}
+// -----------------------------------------------------------------------------
+void VCLXAccessibleToolBoxItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
+{
+ nStartIndex = 0;
+ nEndIndex = 0;
+}
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_REFCOUNT( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE )
+Any SAL_CALL VCLXAccessibleToolBoxItem::queryInterface( const Type& _rType ) throw (RuntimeException)
+{
+ // --> PB 2004-09-03 #i33611# - toolbox buttons without text don't support XAccessibleText
+ if ( _rType == ::getCppuType( ( const Reference< XAccessibleText >* ) 0 )
+ && ( !m_pToolBox || m_pToolBox->GetButtonType() == BUTTON_SYMBOL ) )
+ return Any();
+ // <--
+
+ ::com::sun::star::uno::Any aReturn = AccessibleTextHelper_BASE::queryInterface( _rType );
+ if ( !aReturn.hasValue() )
+ aReturn = VCLXAccessibleToolBoxItem_BASE::queryInterface( _rType );
+ return aReturn;
+}
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE, VCLXAccessibleToolBoxItem_BASE )
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleToolBoxItem::disposing()
+{
+ AccessibleTextHelper_BASE::disposing();
+ m_pToolBox = NULL;
+}
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+::rtl::OUString VCLXAccessibleToolBoxItem::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleToolBoxItem" );
+}
+// -----------------------------------------------------------------------------
+sal_Bool VCLXAccessibleToolBoxItem::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 > VCLXAccessibleToolBoxItem::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(4);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleContext" );
+ aNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleComponent" );
+ aNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleExtendedComponent" );
+ aNames[3] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleToolBoxItem" );
+ return aNames;
+}
+// -----------------------------------------------------------------------------
+// XAccessible
+// -----------------------------------------------------------------------------
+Reference< XAccessibleContext > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleContext( ) throw (RuntimeException)
+{
+ return this;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChildCount( ) throw (RuntimeException)
+{
+ OContextEntryGuard aGuard( this );
+
+ return m_xChild.is() ? 1 : 0;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChild( sal_Int32 i ) throw (RuntimeException, com::sun::star::lang::IndexOutOfBoundsException)
+{
+ OContextEntryGuard aGuard( this );
+
+ // no child -> so index is out of bounds
+ if ( !m_xChild.is() || i != 0 )
+ throw IndexOutOfBoundsException();
+
+ return m_xChild;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleParent( ) throw (RuntimeException)
+{
+ OContextEntryGuard aGuard( this );
+
+ return m_pToolBox->GetAccessible();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OContextEntryGuard aGuard( this );
+
+ return m_nIndexInParent;
+}
+// -----------------------------------------------------------------------------
+sal_Int16 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRole( ) throw (RuntimeException)
+{
+ OContextEntryGuard aGuard( this );
+
+ return m_nRole;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleDescription( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sDescription;
+ if ( m_pToolBox )
+ sDescription = m_pToolBox->GetHelpText( m_nItemId );
+
+ return sDescription;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ // entry text == accessible name
+ return GetText( true );
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ OContextEntryGuard aGuard( this );
+
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleStateSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+ Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
+
+ if ( m_pToolBox && !rBHelper.bDisposed && !rBHelper.bInDispose )
+ {
+ pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
+ if ( m_bIsChecked )
+ pStateSetHelper->AddState( AccessibleStateType::CHECKED );
+ if ( m_bIndeterminate )
+ pStateSetHelper->AddState( AccessibleStateType::INDETERMINATE );
+ if ( m_pToolBox->IsItemEnabled( m_nItemId ) )
+ {
+ pStateSetHelper->AddState( AccessibleStateType::ENABLED );
+ pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
+ }
+ if ( m_pToolBox->IsItemVisible( m_nItemId ) )
+ pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
+ if ( m_pToolBox->IsItemReallyVisible( m_nItemId ) )
+ pStateSetHelper->AddState( AccessibleStateType::SHOWING );
+ if ( m_bHasFocus )
+ pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
+ }
+ else
+ pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+
+ return xStateSet;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleText
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getCaretPosition() throw (RuntimeException)
+{
+ return -1;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+Sequence< PropertyValue > SAL_CALL VCLXAccessibleToolBoxItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sText( implGetText() );
+
+ if ( !implIsValidIndex( nIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return Sequence< PropertyValue >();
+}
+// -----------------------------------------------------------------------------
+awt::Rectangle SAL_CALL VCLXAccessibleToolBoxItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sText( implGetText() );
+
+ if ( !implIsValidIndex( nIndex, sText.getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+ if ( m_pToolBox && m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) // symbol buttons have no character bounds
+ {
+ Rectangle aCharRect = m_pToolBox->GetCharacterBounds( m_nItemId, nIndex );
+ Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId );
+ aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
+ aBounds = AWTRectangle( aCharRect );
+ }
+
+ return aBounds;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndex = -1;
+ if ( m_pToolBox && m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) // symbol buttons have no character bounds
+ {
+ sal_uInt16 nItemId = 0;
+ Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId );
+ Point aPnt( VCLPoint( aPoint ) );
+ aPnt += aItemRect.TopLeft();
+ sal_Int32 nIdx = m_pToolBox->GetIndexForPoint( aPnt, nItemId );
+ if ( nIdx != -1 && nItemId == m_nItemId )
+ nIndex = nIdx;
+ }
+
+ return nIndex;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
+ throw IndexOutOfBoundsException();
+
+ sal_Bool bReturn = sal_False;
+
+ if ( m_pToolBox )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pToolBox->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
+
+ ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pDataObj, NULL );
+
+ Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+
+ Application::AcquireSolarMutex( nRef );
+
+ bReturn = sal_True;
+ }
+ }
+
+ return bReturn;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
+{
+ return Reference< XAccessible >();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL VCLXAccessibleToolBoxItem::grabFocus( ) throw (RuntimeException)
+{
+ Reference< XAccessible > xParent(getAccessibleParent());
+
+ if( xParent.is() )
+ {
+ Reference< XAccessibleSelection > rxAccessibleSelection(xParent->getAccessibleContext(), UNO_QUERY);
+
+ if ( rxAccessibleSelection.is() )
+ {
+ rxAccessibleSelection -> selectAccessibleChild ( getAccessibleIndexInParent() );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ if ( m_pToolBox )
+ nColor = m_pToolBox->GetControlForeground().GetColor();
+
+ return nColor;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ if ( m_pToolBox )
+ nColor = m_pToolBox->GetControlBackground().GetColor();
+
+ return nColor;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+Reference< awt::XFont > SAL_CALL VCLXAccessibleToolBoxItem::getFont( ) throw (RuntimeException)
+{
+ return uno::Reference< awt::XFont >();
+}
+// -----------------------------------------------------------------------------
+awt::FontDescriptor SAL_CALL VCLXAccessibleToolBoxItem::getFontMetrics( const Reference< awt::XFont >& xFont ) throw (RuntimeException)
+{
+ return xFont->getFontDescriptor();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getTitledBorderText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sRet;
+ if ( m_pToolBox )
+ sRet = m_pToolBox->GetItemText( m_nItemId );
+
+ return sRet;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getToolTipText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sRet;
+ if ( m_pToolBox )
+ {
+ if ( Help::IsExtHelpEnabled() )
+ sRet = m_pToolBox->GetHelpText( m_nItemId );
+ else
+ sRet = m_pToolBox->GetQuickHelpText( m_nItemId );
+ if ( !sRet.getLength() )
+ // no help text set, so use item text
+ sRet = m_pToolBox->GetItemText( m_nItemId );
+ }
+ return sRet;
+}
+// -----------------------------------------------------------------------------
+// XAccessibleAction
+// -----------------------------------------------------------------------------
+sal_Int32 VCLXAccessibleToolBoxItem::getAccessibleActionCount( ) throw (RuntimeException)
+{
+ // only one action -> "Click"
+ return 1;
+}
+// -----------------------------------------------------------------------------
+sal_Bool VCLXAccessibleToolBoxItem::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ if ( m_pToolBox )
+ m_pToolBox->TriggerItem( m_nItemId );
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString VCLXAccessibleToolBoxItem::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) );
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleKeyBinding > VCLXAccessibleToolBoxItem::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OContextEntryGuard aGuard( this );
+
+ if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
+ throw IndexOutOfBoundsException();
+
+ return Reference< XAccessibleKeyBinding >();
+}
+// -----------------------------------------------------------------------------
+// XAccessibleValue
+// -----------------------------------------------------------------------------
+Any VCLXAccessibleToolBoxItem::getCurrentValue( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Any aValue;
+ if ( m_pToolBox )
+ aValue <<= (sal_Int32)m_pToolBox->IsItemChecked( m_nItemId );
+
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+sal_Bool VCLXAccessibleToolBoxItem::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Bool bReturn = sal_False;
+
+ if ( m_pToolBox )
+ {
+ sal_Int32 nValue = 0;
+ OSL_VERIFY( aNumber >>= nValue );
+
+ if ( nValue < 0 )
+ nValue = 0;
+ else if ( nValue > 1 )
+ nValue = 1;
+
+ m_pToolBox->CheckItem( m_nItemId, (BOOL) nValue );
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+// -----------------------------------------------------------------------------
+Any VCLXAccessibleToolBoxItem::getMaximumValue( ) throw (RuntimeException)
+{
+ return makeAny((sal_Int32)1);
+}
+// -----------------------------------------------------------------------------
+Any VCLXAccessibleToolBoxItem::getMinimumValue( ) throw (RuntimeException)
+{
+ return makeAny((sal_Int32)0);
+}
+// -----------------------------------------------------------------------------
+
+