1*c82f2877SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c82f2877SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c82f2877SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c82f2877SAndrew Rist * distributed with this work for additional information 6*c82f2877SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c82f2877SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c82f2877SAndrew Rist * "License"); you may not use this file except in compliance 9*c82f2877SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*c82f2877SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*c82f2877SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c82f2877SAndrew Rist * software distributed under the License is distributed on an 15*c82f2877SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c82f2877SAndrew Rist * KIND, either express or implied. See the License for the 17*c82f2877SAndrew Rist * specific language governing permissions and limitations 18*c82f2877SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*c82f2877SAndrew Rist *************************************************************/ 21*c82f2877SAndrew Rist 22*c82f2877SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_accessibility.hxx" 26cdf0e10cSrcweir #include <accessibility/standard/vclxaccessibletoolboxitem.hxx> 27cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 28cdf0e10cSrcweir #include <accessibility/helper/accresmgr.hxx> 29cdf0e10cSrcweir #include <accessibility/helper/accessiblestrings.hrc> 30cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp> 31cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 32cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 35cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 37cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> 38cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp> 39cdf0e10cSrcweir #include <tools/debug.hxx> 40cdf0e10cSrcweir #include <vcl/svapp.hxx> 41cdf0e10cSrcweir #include <vcl/toolbox.hxx> 42cdf0e10cSrcweir #include <vcl/unohelp2.hxx> 43cdf0e10cSrcweir #include <vcl/help.hxx> 44cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx> 45cdf0e10cSrcweir #include <toolkit/helper/externallock.hxx> 46cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 47cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx> 48cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 49cdf0e10cSrcweir #include <comphelper/sequence.hxx> 50cdf0e10cSrcweir 51cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 52cdf0e10cSrcweir 53cdf0e10cSrcweir // class VCLXAccessibleToolBoxItem ------------------------------------------ 54cdf0e10cSrcweir 55cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 56cdf0e10cSrcweir using namespace ::com::sun::star::uno; 57cdf0e10cSrcweir using namespace ::com::sun::star::beans; 58cdf0e10cSrcweir using namespace ::com::sun::star::lang; 59cdf0e10cSrcweir using namespace ::com::sun::star; 60cdf0e10cSrcweir using namespace ::comphelper; 61cdf0e10cSrcweir 62cdf0e10cSrcweir DBG_NAME(VCLXAccessibleToolBoxItem) 63cdf0e10cSrcweir 64cdf0e10cSrcweir // ----------------------------------------------------------------------------- 65cdf0e10cSrcweir // Ctor() and Dtor() 66cdf0e10cSrcweir // ----------------------------------------------------------------------------- 67cdf0e10cSrcweir VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_Int32 _nPos ) : 68cdf0e10cSrcweir 69cdf0e10cSrcweir AccessibleTextHelper_BASE( new VCLExternalSolarLock() ), 70cdf0e10cSrcweir 71cdf0e10cSrcweir m_pToolBox ( _pToolBox ), 72cdf0e10cSrcweir m_nIndexInParent( _nPos ), 73cdf0e10cSrcweir m_nRole ( AccessibleRole::PUSH_BUTTON ), 74cdf0e10cSrcweir m_nItemId ( 0 ), 75cdf0e10cSrcweir m_bHasFocus ( sal_False ), 76cdf0e10cSrcweir m_bIsChecked ( sal_False ), 77cdf0e10cSrcweir m_bIndeterminate( false ) 78cdf0e10cSrcweir 79cdf0e10cSrcweir { 80cdf0e10cSrcweir DBG_CTOR( VCLXAccessibleToolBoxItem, NULL ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock( ) ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir DBG_ASSERT( m_pToolBox, "invalid toolbox" ); 85cdf0e10cSrcweir m_nItemId = m_pToolBox->GetItemId( (sal_uInt16)m_nIndexInParent ); 86cdf0e10cSrcweir m_sOldName = GetText( true ); 87cdf0e10cSrcweir m_bIsChecked = m_pToolBox->IsItemChecked( m_nItemId ); 88cdf0e10cSrcweir m_bIndeterminate = ( m_pToolBox->GetItemState( m_nItemId ) == STATE_DONTKNOW ); 89cdf0e10cSrcweir ToolBoxItemType eType = m_pToolBox->GetItemType( (sal_uInt16)m_nIndexInParent ); 90cdf0e10cSrcweir switch ( eType ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir case TOOLBOXITEM_BUTTON : 93cdf0e10cSrcweir { 94cdf0e10cSrcweir ToolBoxItemBits nBits = m_pToolBox->GetItemBits( m_nItemId ); 95cdf0e10cSrcweir if (( nBits & TIB_DROPDOWN ) == TIB_DROPDOWN) 96cdf0e10cSrcweir m_nRole = AccessibleRole::BUTTON_DROPDOWN; 97cdf0e10cSrcweir else if (( ( nBits & TIB_CHECKABLE ) == TIB_CHECKABLE ) || 98cdf0e10cSrcweir ( ( nBits & TIB_AUTOCHECK ) == TIB_AUTOCHECK ) ) 99cdf0e10cSrcweir m_nRole = AccessibleRole::TOGGLE_BUTTON; 100cdf0e10cSrcweir else if ( m_pToolBox->GetItemWindow( m_nItemId ) ) 101cdf0e10cSrcweir m_nRole = AccessibleRole::PANEL; 102cdf0e10cSrcweir break; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir case TOOLBOXITEM_SPACE : 106cdf0e10cSrcweir m_nRole = AccessibleRole::FILLER; 107cdf0e10cSrcweir break; 108cdf0e10cSrcweir 109cdf0e10cSrcweir case TOOLBOXITEM_SEPARATOR : 110cdf0e10cSrcweir case TOOLBOXITEM_BREAK : 111cdf0e10cSrcweir m_nRole = AccessibleRole::SEPARATOR; 112cdf0e10cSrcweir break; 113cdf0e10cSrcweir 114cdf0e10cSrcweir default: 115cdf0e10cSrcweir { 116cdf0e10cSrcweir DBG_ERRORFILE( "unsupported toolbox itemtype" ); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir } 119cdf0e10cSrcweir } 120cdf0e10cSrcweir // ----------------------------------------------------------------------------- 121cdf0e10cSrcweir VCLXAccessibleToolBoxItem::~VCLXAccessibleToolBoxItem() 122cdf0e10cSrcweir { 123cdf0e10cSrcweir DBG_DTOR( VCLXAccessibleToolBoxItem, NULL ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir delete m_pExternalLock; 126cdf0e10cSrcweir m_pExternalLock = NULL; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir // ----------------------------------------------------------------------------- 129cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleToolBoxItem::GetText( bool _bAsName ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir ::rtl::OUString sRet; 132cdf0e10cSrcweir // no text for separators and spaces 133cdf0e10cSrcweir if ( m_pToolBox && m_nItemId > 0 && ( _bAsName || m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir sRet = m_pToolBox->GetItemText( m_nItemId ); 136cdf0e10cSrcweir //OJ #108243# we only read the name of the toolboxitem 137cdf0e10cSrcweir // 138cdf0e10cSrcweir // Window* pItemWindow = m_pToolBox->GetItemWindow( m_nItemId ); 139cdf0e10cSrcweir // if ( pItemWindow && pItemWindow->GetAccessible().is() && 140cdf0e10cSrcweir // pItemWindow->GetAccessible()->getAccessibleContext().is() ) 141cdf0e10cSrcweir // { 142cdf0e10cSrcweir // ::rtl::OUString sWinText = pItemWindow->GetAccessible()->getAccessibleContext()->getAccessibleName(); 143cdf0e10cSrcweir // if ( ( sRet.getLength() > 0 ) && ( sWinText.getLength() > 0 ) ) 144cdf0e10cSrcweir // sRet += String( RTL_CONSTASCII_USTRINGPARAM( " " ) ); 145cdf0e10cSrcweir // sRet += sWinText; 146cdf0e10cSrcweir // } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir return sRet; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir // ----------------------------------------------------------------------------- 151cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::SetFocus( sal_Bool _bFocus ) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir if ( m_bHasFocus != _bFocus ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir Any aOldValue; 156cdf0e10cSrcweir Any aNewValue; 157cdf0e10cSrcweir if ( m_bHasFocus ) 158cdf0e10cSrcweir aOldValue <<= AccessibleStateType::FOCUSED; 159cdf0e10cSrcweir else 160cdf0e10cSrcweir aNewValue <<= AccessibleStateType::FOCUSED; 161cdf0e10cSrcweir m_bHasFocus = _bFocus; 162cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir } 165cdf0e10cSrcweir // ----------------------------------------------------------------------------- 166cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::SetChecked( sal_Bool _bCheck ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir if ( m_bIsChecked != _bCheck ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir Any aOldValue; 171cdf0e10cSrcweir Any aNewValue; 172cdf0e10cSrcweir if ( m_bIsChecked ) 173cdf0e10cSrcweir aOldValue <<= AccessibleStateType::CHECKED; 174cdf0e10cSrcweir else 175cdf0e10cSrcweir aNewValue <<= AccessibleStateType::CHECKED; 176cdf0e10cSrcweir m_bIsChecked = _bCheck; 177cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir } 180cdf0e10cSrcweir // ----------------------------------------------------------------------------- 181cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::SetIndeterminate( bool _bIndeterminate ) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir if ( m_bIndeterminate != _bIndeterminate ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir Any aOldValue, aNewValue; 186cdf0e10cSrcweir if ( m_bIndeterminate ) 187cdf0e10cSrcweir aOldValue <<= AccessibleStateType::INDETERMINATE; 188cdf0e10cSrcweir else 189cdf0e10cSrcweir aNewValue <<= AccessibleStateType::INDETERMINATE; 190cdf0e10cSrcweir m_bIndeterminate = _bIndeterminate; 191cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir } 194cdf0e10cSrcweir // ----------------------------------------------------------------------------- 195cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::NameChanged() 196cdf0e10cSrcweir { 197cdf0e10cSrcweir ::rtl::OUString sNewName = implGetText(); 198cdf0e10cSrcweir if ( sNewName != m_sOldName ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir Any aOldValue, aNewValue; 201cdf0e10cSrcweir aOldValue <<= m_sOldName; 202cdf0e10cSrcweir // save new name as old name for next change 203cdf0e10cSrcweir m_sOldName = sNewName; 204cdf0e10cSrcweir aNewValue <<= m_sOldName; 205cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue ); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir } 208cdf0e10cSrcweir // ----------------------------------------------------------------------------- 209cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::SetChild( const Reference< XAccessible >& _xChild ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir m_xChild = _xChild; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir // ----------------------------------------------------------------------------- 214cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::NotifyChildEvent( const Reference< XAccessible >& _xChild, bool _bShow ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir Any aOld = _bShow ? Any() : makeAny( _xChild ); 217cdf0e10cSrcweir Any aNew = _bShow ? makeAny( _xChild ) : Any(); 218cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::CHILD, aOld, aNew ); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir // ----------------------------------------------------------------------------- 221cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::ToggleEnableState() 222cdf0e10cSrcweir { 223cdf0e10cSrcweir Any aOldValue[2], aNewValue[2]; 224cdf0e10cSrcweir if ( m_pToolBox->IsItemEnabled( m_nItemId ) ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir aNewValue[0] <<= AccessibleStateType::SENSITIVE; 227cdf0e10cSrcweir aNewValue[1] <<= AccessibleStateType::ENABLED; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir else 230cdf0e10cSrcweir { 231cdf0e10cSrcweir aOldValue[0] <<= AccessibleStateType::ENABLED; 232cdf0e10cSrcweir aOldValue[1] <<= AccessibleStateType::SENSITIVE; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] ); 236cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] ); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir // ----------------------------------------------------------------------------- 239cdf0e10cSrcweir awt::Rectangle SAL_CALL VCLXAccessibleToolBoxItem::implGetBounds( ) throw (RuntimeException) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir awt::Rectangle aRect; 242cdf0e10cSrcweir if ( m_pToolBox ) 243cdf0e10cSrcweir aRect = AWTRectangle( m_pToolBox->GetItemPosRect( (sal_uInt16)m_nIndexInParent ) ); 244cdf0e10cSrcweir 245cdf0e10cSrcweir return aRect; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir // ----------------------------------------------------------------------------- 248cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleToolBoxItem::implGetText() 249cdf0e10cSrcweir { 250cdf0e10cSrcweir return GetText (true); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir // ----------------------------------------------------------------------------- 253cdf0e10cSrcweir Locale VCLXAccessibleToolBoxItem::implGetLocale() 254cdf0e10cSrcweir { 255cdf0e10cSrcweir return Application::GetSettings().GetUILocale(); 256cdf0e10cSrcweir } 257cdf0e10cSrcweir // ----------------------------------------------------------------------------- 258cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir nStartIndex = 0; 261cdf0e10cSrcweir nEndIndex = 0; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir // ----------------------------------------------------------------------------- 264cdf0e10cSrcweir // XInterface 265cdf0e10cSrcweir // ----------------------------------------------------------------------------- 266cdf0e10cSrcweir IMPLEMENT_FORWARD_REFCOUNT( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE ) 267cdf0e10cSrcweir Any SAL_CALL VCLXAccessibleToolBoxItem::queryInterface( const Type& _rType ) throw (RuntimeException) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir // --> PB 2004-09-03 #i33611# - toolbox buttons without text don't support XAccessibleText 270cdf0e10cSrcweir if ( _rType == ::getCppuType( ( const Reference< XAccessibleText >* ) 0 ) 271cdf0e10cSrcweir && ( !m_pToolBox || m_pToolBox->GetButtonType() == BUTTON_SYMBOL ) ) 272cdf0e10cSrcweir return Any(); 273cdf0e10cSrcweir // <-- 274cdf0e10cSrcweir 275cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn = AccessibleTextHelper_BASE::queryInterface( _rType ); 276cdf0e10cSrcweir if ( !aReturn.hasValue() ) 277cdf0e10cSrcweir aReturn = VCLXAccessibleToolBoxItem_BASE::queryInterface( _rType ); 278cdf0e10cSrcweir return aReturn; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir // ----------------------------------------------------------------------------- 281cdf0e10cSrcweir // XTypeProvider 282cdf0e10cSrcweir // ----------------------------------------------------------------------------- 283cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE, VCLXAccessibleToolBoxItem_BASE ) 284cdf0e10cSrcweir // ----------------------------------------------------------------------------- 285cdf0e10cSrcweir // XComponent 286cdf0e10cSrcweir // ----------------------------------------------------------------------------- 287cdf0e10cSrcweir void SAL_CALL VCLXAccessibleToolBoxItem::disposing() 288cdf0e10cSrcweir { 289cdf0e10cSrcweir AccessibleTextHelper_BASE::disposing(); 290cdf0e10cSrcweir m_pToolBox = NULL; 291cdf0e10cSrcweir } 292cdf0e10cSrcweir // ----------------------------------------------------------------------------- 293cdf0e10cSrcweir // XServiceInfo 294cdf0e10cSrcweir // ----------------------------------------------------------------------------- 295cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleToolBoxItem::getImplementationName() throw (RuntimeException) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleToolBoxItem" ); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir // ----------------------------------------------------------------------------- 300cdf0e10cSrcweir sal_Bool VCLXAccessibleToolBoxItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() ); 303cdf0e10cSrcweir const ::rtl::OUString* pNames = aNames.getConstArray(); 304cdf0e10cSrcweir const ::rtl::OUString* pEnd = pNames + aNames.getLength(); 305cdf0e10cSrcweir for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) 306cdf0e10cSrcweir ; 307cdf0e10cSrcweir 308cdf0e10cSrcweir return pNames != pEnd; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir // ----------------------------------------------------------------------------- 311cdf0e10cSrcweir Sequence< ::rtl::OUString > VCLXAccessibleToolBoxItem::getSupportedServiceNames() throw (RuntimeException) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames(4); 314cdf0e10cSrcweir aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleContext" ); 315cdf0e10cSrcweir aNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleComponent" ); 316cdf0e10cSrcweir aNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleExtendedComponent" ); 317cdf0e10cSrcweir aNames[3] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleToolBoxItem" ); 318cdf0e10cSrcweir return aNames; 319cdf0e10cSrcweir } 320cdf0e10cSrcweir // ----------------------------------------------------------------------------- 321cdf0e10cSrcweir // XAccessible 322cdf0e10cSrcweir // ----------------------------------------------------------------------------- 323cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleContext( ) throw (RuntimeException) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir return this; 326cdf0e10cSrcweir } 327cdf0e10cSrcweir // ----------------------------------------------------------------------------- 328cdf0e10cSrcweir // XAccessibleContext 329cdf0e10cSrcweir // ----------------------------------------------------------------------------- 330cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChildCount( ) throw (RuntimeException) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir OContextEntryGuard aGuard( this ); 333cdf0e10cSrcweir 334cdf0e10cSrcweir return m_xChild.is() ? 1 : 0; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir // ----------------------------------------------------------------------------- 337cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChild( sal_Int32 i ) throw (RuntimeException, com::sun::star::lang::IndexOutOfBoundsException) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir OContextEntryGuard aGuard( this ); 340cdf0e10cSrcweir 341cdf0e10cSrcweir // no child -> so index is out of bounds 342cdf0e10cSrcweir if ( !m_xChild.is() || i != 0 ) 343cdf0e10cSrcweir throw IndexOutOfBoundsException(); 344cdf0e10cSrcweir 345cdf0e10cSrcweir return m_xChild; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir // ----------------------------------------------------------------------------- 348cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleParent( ) throw (RuntimeException) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir OContextEntryGuard aGuard( this ); 351cdf0e10cSrcweir 352cdf0e10cSrcweir return m_pToolBox->GetAccessible(); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir // ----------------------------------------------------------------------------- 355cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleIndexInParent( ) throw (RuntimeException) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir OContextEntryGuard aGuard( this ); 358cdf0e10cSrcweir 359cdf0e10cSrcweir return m_nIndexInParent; 360cdf0e10cSrcweir } 361cdf0e10cSrcweir // ----------------------------------------------------------------------------- 362cdf0e10cSrcweir sal_Int16 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRole( ) throw (RuntimeException) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir OContextEntryGuard aGuard( this ); 365cdf0e10cSrcweir 366cdf0e10cSrcweir return m_nRole; 367cdf0e10cSrcweir } 368cdf0e10cSrcweir // ----------------------------------------------------------------------------- 369cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleDescription( ) throw (RuntimeException) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 372cdf0e10cSrcweir 373cdf0e10cSrcweir ::rtl::OUString sDescription; 374cdf0e10cSrcweir if ( m_pToolBox ) 375cdf0e10cSrcweir sDescription = m_pToolBox->GetHelpText( m_nItemId ); 376cdf0e10cSrcweir 377cdf0e10cSrcweir return sDescription; 378cdf0e10cSrcweir } 379cdf0e10cSrcweir // ----------------------------------------------------------------------------- 380cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleName( ) throw (RuntimeException) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 383cdf0e10cSrcweir 384cdf0e10cSrcweir // entry text == accessible name 385cdf0e10cSrcweir return GetText( true ); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir // ----------------------------------------------------------------------------- 388cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRelationSet( ) throw (RuntimeException) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir OContextEntryGuard aGuard( this ); 391cdf0e10cSrcweir 392cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 393cdf0e10cSrcweir Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; 394cdf0e10cSrcweir return xSet; 395cdf0e10cSrcweir } 396cdf0e10cSrcweir // ----------------------------------------------------------------------------- 397cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleStateSet( ) throw (RuntimeException) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 400cdf0e10cSrcweir 401cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 402cdf0e10cSrcweir Reference< XAccessibleStateSet > xStateSet = pStateSetHelper; 403cdf0e10cSrcweir 404cdf0e10cSrcweir if ( m_pToolBox && !rBHelper.bDisposed && !rBHelper.bInDispose ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); 407cdf0e10cSrcweir if ( m_bIsChecked ) 408cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::CHECKED ); 409cdf0e10cSrcweir if ( m_bIndeterminate ) 410cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::INDETERMINATE ); 411cdf0e10cSrcweir if ( m_pToolBox->IsItemEnabled( m_nItemId ) ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 414cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SENSITIVE ); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir if ( m_pToolBox->IsItemVisible( m_nItemId ) ) 417cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 418cdf0e10cSrcweir if ( m_pToolBox->IsItemReallyVisible( m_nItemId ) ) 419cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 420cdf0e10cSrcweir if ( m_bHasFocus ) 421cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::FOCUSED ); 422cdf0e10cSrcweir } 423cdf0e10cSrcweir else 424cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 425cdf0e10cSrcweir 426cdf0e10cSrcweir return xStateSet; 427cdf0e10cSrcweir } 428cdf0e10cSrcweir // ----------------------------------------------------------------------------- 429cdf0e10cSrcweir // XAccessibleText 430cdf0e10cSrcweir // ----------------------------------------------------------------------------- 431cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getCaretPosition() throw (RuntimeException) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir return -1; 434cdf0e10cSrcweir } 435cdf0e10cSrcweir // ----------------------------------------------------------------------------- 436cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 439cdf0e10cSrcweir 440cdf0e10cSrcweir if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) ) 441cdf0e10cSrcweir throw IndexOutOfBoundsException(); 442cdf0e10cSrcweir 443cdf0e10cSrcweir return sal_False; 444cdf0e10cSrcweir } 445cdf0e10cSrcweir // ----------------------------------------------------------------------------- 446cdf0e10cSrcweir Sequence< PropertyValue > SAL_CALL VCLXAccessibleToolBoxItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& ) throw (IndexOutOfBoundsException, RuntimeException) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 449cdf0e10cSrcweir 450cdf0e10cSrcweir ::rtl::OUString sText( implGetText() ); 451cdf0e10cSrcweir 452cdf0e10cSrcweir if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 453cdf0e10cSrcweir throw IndexOutOfBoundsException(); 454cdf0e10cSrcweir 455cdf0e10cSrcweir return Sequence< PropertyValue >(); 456cdf0e10cSrcweir } 457cdf0e10cSrcweir // ----------------------------------------------------------------------------- 458cdf0e10cSrcweir awt::Rectangle SAL_CALL VCLXAccessibleToolBoxItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 461cdf0e10cSrcweir 462cdf0e10cSrcweir ::rtl::OUString sText( implGetText() ); 463cdf0e10cSrcweir 464cdf0e10cSrcweir if ( !implIsValidIndex( nIndex, sText.getLength() ) ) 465cdf0e10cSrcweir throw IndexOutOfBoundsException(); 466cdf0e10cSrcweir 467cdf0e10cSrcweir awt::Rectangle aBounds( 0, 0, 0, 0 ); 468cdf0e10cSrcweir if ( m_pToolBox && m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) // symbol buttons have no character bounds 469cdf0e10cSrcweir { 470cdf0e10cSrcweir Rectangle aCharRect = m_pToolBox->GetCharacterBounds( m_nItemId, nIndex ); 471cdf0e10cSrcweir Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId ); 472cdf0e10cSrcweir aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() ); 473cdf0e10cSrcweir aBounds = AWTRectangle( aCharRect ); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir return aBounds; 477cdf0e10cSrcweir } 478cdf0e10cSrcweir // ----------------------------------------------------------------------------- 479cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 482cdf0e10cSrcweir 483cdf0e10cSrcweir sal_Int32 nIndex = -1; 484cdf0e10cSrcweir if ( m_pToolBox && m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) // symbol buttons have no character bounds 485cdf0e10cSrcweir { 486cdf0e10cSrcweir sal_uInt16 nItemId = 0; 487cdf0e10cSrcweir Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId ); 488cdf0e10cSrcweir Point aPnt( VCLPoint( aPoint ) ); 489cdf0e10cSrcweir aPnt += aItemRect.TopLeft(); 490cdf0e10cSrcweir sal_Int32 nIdx = m_pToolBox->GetIndexForPoint( aPnt, nItemId ); 491cdf0e10cSrcweir if ( nIdx != -1 && nItemId == m_nItemId ) 492cdf0e10cSrcweir nIndex = nIdx; 493cdf0e10cSrcweir } 494cdf0e10cSrcweir 495cdf0e10cSrcweir return nIndex; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir // ----------------------------------------------------------------------------- 498cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 501cdf0e10cSrcweir 502cdf0e10cSrcweir if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) 503cdf0e10cSrcweir throw IndexOutOfBoundsException(); 504cdf0e10cSrcweir 505cdf0e10cSrcweir return sal_False; 506cdf0e10cSrcweir } 507cdf0e10cSrcweir // ----------------------------------------------------------------------------- 508cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException) 509cdf0e10cSrcweir { 510cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 511cdf0e10cSrcweir 512cdf0e10cSrcweir if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) ) 513cdf0e10cSrcweir throw IndexOutOfBoundsException(); 514cdf0e10cSrcweir 515cdf0e10cSrcweir sal_Bool bReturn = sal_False; 516cdf0e10cSrcweir 517cdf0e10cSrcweir if ( m_pToolBox ) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pToolBox->GetClipboard(); 520cdf0e10cSrcweir if ( xClipboard.is() ) 521cdf0e10cSrcweir { 522cdf0e10cSrcweir ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) ); 523cdf0e10cSrcweir 524cdf0e10cSrcweir ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText ); 525cdf0e10cSrcweir const sal_uInt32 nRef = Application::ReleaseSolarMutex(); 526cdf0e10cSrcweir xClipboard->setContents( pDataObj, NULL ); 527cdf0e10cSrcweir 528cdf0e10cSrcweir Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY ); 529cdf0e10cSrcweir if( xFlushableClipboard.is() ) 530cdf0e10cSrcweir xFlushableClipboard->flushClipboard(); 531cdf0e10cSrcweir 532cdf0e10cSrcweir Application::AcquireSolarMutex( nRef ); 533cdf0e10cSrcweir 534cdf0e10cSrcweir bReturn = sal_True; 535cdf0e10cSrcweir } 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir return bReturn; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir // ----------------------------------------------------------------------------- 541cdf0e10cSrcweir // XAccessibleComponent 542cdf0e10cSrcweir // ----------------------------------------------------------------------------- 543cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir return Reference< XAccessible >(); 546cdf0e10cSrcweir } 547cdf0e10cSrcweir // ----------------------------------------------------------------------------- 548cdf0e10cSrcweir void SAL_CALL VCLXAccessibleToolBoxItem::grabFocus( ) throw (RuntimeException) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir Reference< XAccessible > xParent(getAccessibleParent()); 551cdf0e10cSrcweir 552cdf0e10cSrcweir if( xParent.is() ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir Reference< XAccessibleSelection > rxAccessibleSelection(xParent->getAccessibleContext(), UNO_QUERY); 555cdf0e10cSrcweir 556cdf0e10cSrcweir if ( rxAccessibleSelection.is() ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir rxAccessibleSelection -> selectAccessibleChild ( getAccessibleIndexInParent() ); 559cdf0e10cSrcweir } 560cdf0e10cSrcweir } 561cdf0e10cSrcweir } 562cdf0e10cSrcweir // ----------------------------------------------------------------------------- 563cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getForeground( ) throw (RuntimeException) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 566cdf0e10cSrcweir 567cdf0e10cSrcweir sal_Int32 nColor = 0; 568cdf0e10cSrcweir if ( m_pToolBox ) 569cdf0e10cSrcweir nColor = m_pToolBox->GetControlForeground().GetColor(); 570cdf0e10cSrcweir 571cdf0e10cSrcweir return nColor; 572cdf0e10cSrcweir } 573cdf0e10cSrcweir // ----------------------------------------------------------------------------- 574cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getBackground( ) throw (RuntimeException) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 577cdf0e10cSrcweir 578cdf0e10cSrcweir sal_Int32 nColor = 0; 579cdf0e10cSrcweir if ( m_pToolBox ) 580cdf0e10cSrcweir nColor = m_pToolBox->GetControlBackground().GetColor(); 581cdf0e10cSrcweir 582cdf0e10cSrcweir return nColor; 583cdf0e10cSrcweir } 584cdf0e10cSrcweir // ----------------------------------------------------------------------------- 585cdf0e10cSrcweir // XAccessibleExtendedComponent 586cdf0e10cSrcweir // ----------------------------------------------------------------------------- 587cdf0e10cSrcweir Reference< awt::XFont > SAL_CALL VCLXAccessibleToolBoxItem::getFont( ) throw (RuntimeException) 588cdf0e10cSrcweir { 589cdf0e10cSrcweir return uno::Reference< awt::XFont >(); 590cdf0e10cSrcweir } 591cdf0e10cSrcweir // ----------------------------------------------------------------------------- 592cdf0e10cSrcweir awt::FontDescriptor SAL_CALL VCLXAccessibleToolBoxItem::getFontMetrics( const Reference< awt::XFont >& xFont ) throw (RuntimeException) 593cdf0e10cSrcweir { 594cdf0e10cSrcweir return xFont->getFontDescriptor(); 595cdf0e10cSrcweir } 596cdf0e10cSrcweir // ----------------------------------------------------------------------------- 597cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getTitledBorderText( ) throw (RuntimeException) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 600cdf0e10cSrcweir 601cdf0e10cSrcweir ::rtl::OUString sRet; 602cdf0e10cSrcweir if ( m_pToolBox ) 603cdf0e10cSrcweir sRet = m_pToolBox->GetItemText( m_nItemId ); 604cdf0e10cSrcweir 605cdf0e10cSrcweir return sRet; 606cdf0e10cSrcweir } 607cdf0e10cSrcweir // ----------------------------------------------------------------------------- 608cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getToolTipText( ) throw (RuntimeException) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 611cdf0e10cSrcweir 612cdf0e10cSrcweir ::rtl::OUString sRet; 613cdf0e10cSrcweir if ( m_pToolBox ) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir if ( Help::IsExtHelpEnabled() ) 616cdf0e10cSrcweir sRet = m_pToolBox->GetHelpText( m_nItemId ); 617cdf0e10cSrcweir else 618cdf0e10cSrcweir sRet = m_pToolBox->GetQuickHelpText( m_nItemId ); 619cdf0e10cSrcweir if ( !sRet.getLength() ) 620cdf0e10cSrcweir // no help text set, so use item text 621cdf0e10cSrcweir sRet = m_pToolBox->GetItemText( m_nItemId ); 622cdf0e10cSrcweir } 623cdf0e10cSrcweir return sRet; 624cdf0e10cSrcweir } 625cdf0e10cSrcweir // ----------------------------------------------------------------------------- 626cdf0e10cSrcweir // XAccessibleAction 627cdf0e10cSrcweir // ----------------------------------------------------------------------------- 628cdf0e10cSrcweir sal_Int32 VCLXAccessibleToolBoxItem::getAccessibleActionCount( ) throw (RuntimeException) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir // only one action -> "Click" 631cdf0e10cSrcweir return 1; 632cdf0e10cSrcweir } 633cdf0e10cSrcweir // ----------------------------------------------------------------------------- 634cdf0e10cSrcweir sal_Bool VCLXAccessibleToolBoxItem::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 637cdf0e10cSrcweir 638cdf0e10cSrcweir if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 639cdf0e10cSrcweir throw IndexOutOfBoundsException(); 640cdf0e10cSrcweir 641cdf0e10cSrcweir if ( m_pToolBox ) 642cdf0e10cSrcweir m_pToolBox->TriggerItem( m_nItemId ); 643cdf0e10cSrcweir 644cdf0e10cSrcweir return sal_True; 645cdf0e10cSrcweir } 646cdf0e10cSrcweir // ----------------------------------------------------------------------------- 647cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleToolBoxItem::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 650cdf0e10cSrcweir 651cdf0e10cSrcweir if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 652cdf0e10cSrcweir throw IndexOutOfBoundsException(); 653cdf0e10cSrcweir 654cdf0e10cSrcweir return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) ); 655cdf0e10cSrcweir } 656cdf0e10cSrcweir // ----------------------------------------------------------------------------- 657cdf0e10cSrcweir Reference< XAccessibleKeyBinding > VCLXAccessibleToolBoxItem::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir OContextEntryGuard aGuard( this ); 660cdf0e10cSrcweir 661cdf0e10cSrcweir if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 662cdf0e10cSrcweir throw IndexOutOfBoundsException(); 663cdf0e10cSrcweir 664cdf0e10cSrcweir return Reference< XAccessibleKeyBinding >(); 665cdf0e10cSrcweir } 666cdf0e10cSrcweir // ----------------------------------------------------------------------------- 667cdf0e10cSrcweir // XAccessibleValue 668cdf0e10cSrcweir // ----------------------------------------------------------------------------- 669cdf0e10cSrcweir Any VCLXAccessibleToolBoxItem::getCurrentValue( ) throw (RuntimeException) 670cdf0e10cSrcweir { 671cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 672cdf0e10cSrcweir 673cdf0e10cSrcweir Any aValue; 674cdf0e10cSrcweir if ( m_pToolBox ) 675cdf0e10cSrcweir aValue <<= (sal_Int32)m_pToolBox->IsItemChecked( m_nItemId ); 676cdf0e10cSrcweir 677cdf0e10cSrcweir return aValue; 678cdf0e10cSrcweir } 679cdf0e10cSrcweir // ----------------------------------------------------------------------------- 680cdf0e10cSrcweir sal_Bool VCLXAccessibleToolBoxItem::setCurrentValue( const Any& aNumber ) throw (RuntimeException) 681cdf0e10cSrcweir { 682cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 683cdf0e10cSrcweir 684cdf0e10cSrcweir sal_Bool bReturn = sal_False; 685cdf0e10cSrcweir 686cdf0e10cSrcweir if ( m_pToolBox ) 687cdf0e10cSrcweir { 688cdf0e10cSrcweir sal_Int32 nValue = 0; 689cdf0e10cSrcweir OSL_VERIFY( aNumber >>= nValue ); 690cdf0e10cSrcweir 691cdf0e10cSrcweir if ( nValue < 0 ) 692cdf0e10cSrcweir nValue = 0; 693cdf0e10cSrcweir else if ( nValue > 1 ) 694cdf0e10cSrcweir nValue = 1; 695cdf0e10cSrcweir 696cdf0e10cSrcweir m_pToolBox->CheckItem( m_nItemId, (sal_Bool) nValue ); 697cdf0e10cSrcweir bReturn = sal_True; 698cdf0e10cSrcweir } 699cdf0e10cSrcweir 700cdf0e10cSrcweir return bReturn; 701cdf0e10cSrcweir } 702cdf0e10cSrcweir // ----------------------------------------------------------------------------- 703cdf0e10cSrcweir Any VCLXAccessibleToolBoxItem::getMaximumValue( ) throw (RuntimeException) 704cdf0e10cSrcweir { 705cdf0e10cSrcweir return makeAny((sal_Int32)1); 706cdf0e10cSrcweir } 707cdf0e10cSrcweir // ----------------------------------------------------------------------------- 708cdf0e10cSrcweir Any VCLXAccessibleToolBoxItem::getMinimumValue( ) throw (RuntimeException) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir return makeAny((sal_Int32)0); 711cdf0e10cSrcweir } 712cdf0e10cSrcweir // ----------------------------------------------------------------------------- 713cdf0e10cSrcweir 714cdf0e10cSrcweir 715