Files
libreoffice/svtools/source/control/valueacc.cxx

1240 lines
38 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
2012-11-15 17:28:16 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2002-02-25 09:52:14 +00:00
#include <unotools/accessiblestatesethelper.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <svtools/valueset.hxx>
2002-02-25 09:52:14 +00:00
#include "valueimp.hxx"
2011-06-01 10:02:08 +01:00
#include <comphelper/servicehelper.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/accessibility/AccessibleRelationType.hpp>
#include <unotools/accessiblerelationsethelper.hxx>
2002-02-25 09:52:14 +00:00
using namespace ::com::sun::star;
// ----------------
// - ValueSetItem -
// ----------------
2010-12-02 11:38:00 +00:00
ValueSetItem::ValueSetItem( ValueSet& rParent )
: mrParent(rParent)
, mnId(0)
, meType(VALUESETITEM_NONE)
, mbVisible(true)
2010-12-02 11:38:00 +00:00
, mpData(NULL)
, mbSelected(false)
2010-12-02 11:38:00 +00:00
, mpxAcc(NULL)
2002-02-25 09:52:14 +00:00
{
}
// -----------------------------------------------------------------------
ValueSetItem::~ValueSetItem()
{
if( mpxAcc )
{
static_cast< ValueItemAcc* >( mpxAcc->get() )->ParentDestroyed();
delete mpxAcc;
}
}
// -----------------------------------------------------------------------
uno::Reference< accessibility::XAccessible > ValueSetItem::GetAccessible( bool bIsTransientChildrenDisabled )
2002-02-25 09:52:14 +00:00
{
if( !mpxAcc )
mpxAcc = new uno::Reference< accessibility::XAccessible >( new ValueItemAcc( this, bIsTransientChildrenDisabled ) );
2002-02-25 09:52:14 +00:00
return *mpxAcc;
}
2002-02-25 15:39:54 +00:00
// ---------------
// - ValueSetAcc -
// ---------------
2002-02-25 09:52:14 +00:00
ValueSetAcc::ValueSetAcc( ValueSet* pParent, bool bIsTransientChildrenDisabled ) :
ValueSetAccComponentBase (m_aMutex),
mpParent( pParent ),
mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled ),
mbIsFocused(false)
2002-02-25 09:52:14 +00:00
{
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
ValueSetAcc::~ValueSetAcc()
{
}
// -----------------------------------------------------------------------
void ValueSetAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
{
if( nEventId )
{
::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners );
2002-02-25 15:39:54 +00:00
accessibility::AccessibleEventObject aEvtObject;
aEvtObject.EventId = nEventId;
aEvtObject.Source = static_cast<uno::XWeak*>(this);
2002-02-25 15:39:54 +00:00
aEvtObject.NewValue = rNewValue;
aEvtObject.OldValue = rOldValue;
for (::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter( aTmpListeners.begin() );
aIter != aTmpListeners.end() ; ++aIter)
2002-03-05 14:28:18 +00:00
{
try
{
(*aIter)->notifyEvent( aEvtObject );
}
2011-06-13 23:40:41 +01:00
catch(const uno::Exception&)
{
}
2002-03-05 14:28:18 +00:00
}
2002-02-25 15:39:54 +00:00
}
}
2011-06-01 10:02:08 +01:00
namespace
{
class theValueSetAccUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theValueSetAccUnoTunnelId > {};
}
2002-02-25 15:39:54 +00:00
const uno::Sequence< sal_Int8 >& ValueSetAcc::getUnoTunnelId()
{
2011-06-01 10:02:08 +01:00
return theValueSetAccUnoTunnelId::get().getSeq();
2002-02-25 15:39:54 +00:00
}
// -----------------------------------------------------------------------------
ValueSetAcc* ValueSetAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
throw()
{
try
{
uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
return( xUnoTunnel.is() ? reinterpret_cast<ValueSetAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( ValueSetAcc::getUnoTunnelId() ))) : NULL );
2002-02-25 15:39:54 +00:00
}
2011-06-13 23:40:41 +01:00
catch(const ::com::sun::star::uno::Exception&)
2002-02-25 15:39:54 +00:00
{
return NULL;
}
}
// -----------------------------------------------------------------------------
void ValueSetAcc::GetFocus (void)
{
mbIsFocused = true;
// Broadcast the state change.
::com::sun::star::uno::Any aOldState, aNewState;
aNewState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
FireAccessibleEvent(
::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED,
aOldState, aNewState);
}
// -----------------------------------------------------------------------------
void ValueSetAcc::LoseFocus (void)
{
mbIsFocused = false;
// Broadcast the state change.
::com::sun::star::uno::Any aOldState, aNewState;
aOldState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
FireAccessibleEvent(
::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED,
aOldState, aNewState);
}
2002-02-25 15:39:54 +00:00
// -----------------------------------------------------------------------------
uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueSetAcc::getAccessibleContext()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
2002-02-25 09:52:14 +00:00
return this;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
sal_Int32 SAL_CALL ValueSetAcc::getAccessibleChildCount()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
ThrowIfDisposed();
sal_Int32 nCount = mpParent->ImplGetVisibleItemCount();
if (HasNoneField())
nCount += 1;
return nCount;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleChild( sal_Int32 i )
2002-02-25 09:52:14 +00:00
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 09:52:14 +00:00
uno::Reference< accessibility::XAccessible > xRet;
ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(i));
2002-02-25 09:52:14 +00:00
if( pItem )
xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
2002-02-25 09:52:14 +00:00
else
throw lang::IndexOutOfBoundsException();
return xRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleParent()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 15:39:54 +00:00
Window* pParent = mpParent->GetParent();
2002-02-25 09:52:14 +00:00
uno::Reference< accessibility::XAccessible > xRet;
if( pParent )
xRet = pParent->GetAccessible();
return xRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
sal_Int32 SAL_CALL ValueSetAcc::getAccessibleIndexInParent()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 15:39:54 +00:00
Window* pParent = mpParent->GetParent();
2002-02-25 09:52:14 +00:00
sal_Int32 nRet = 0;
if( pParent )
{
sal_Bool bFound = sal_False;
for( sal_uInt16 i = 0, nCount = pParent->GetChildCount(); ( i < nCount ) && !bFound; i++ )
2002-02-25 09:52:14 +00:00
{
2002-02-25 15:39:54 +00:00
if( pParent->GetChild( i ) == mpParent )
2002-02-25 09:52:14 +00:00
{
nRet = i;
bFound = sal_True;
}
}
}
return nRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
sal_Int16 SAL_CALL ValueSetAcc::getAccessibleRole()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
// #i73746# As the Java Access Bridge (v 2.0.1) uses "managesDescendants"
// always if the role is LIST, we need a different role in this case
return (mbIsTransientChildrenDisabled
? accessibility::AccessibleRole::PANEL
: accessibility::AccessibleRole::LIST );
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
OUString SAL_CALL ValueSetAcc::getAccessibleDescription()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
OUString aRet( "ValueSet" );
return aRet;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
OUString SAL_CALL ValueSetAcc::getAccessibleName()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
OUString aRet;
if (mpParent)
{
aRet = mpParent->GetAccessibleName();
if ( aRet.isEmpty() )
{
Window* pLabel = mpParent->GetAccessibleRelationLabeledBy();
if ( pLabel && pLabel != mpParent )
aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
if (aRet.isEmpty())
aRet = mpParent->GetQuickHelpText();
}
}
return aRet;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueSetAcc::getAccessibleRelationSet()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
SolarMutexGuard g;
uno::Reference< accessibility::XAccessibleRelationSet > xRelSet;
Window* pWindow = (Window*)mpParent;
if ( pWindow )
{
utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper;
xRelSet = pRelationSet;
Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy();
if ( pLabeledBy && pLabeledBy != pWindow )
{
uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
aSequence[0] = pLabeledBy->GetAccessible();
pRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) );
}
Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf();
if ( pMemberOf && pMemberOf != pWindow )
{
uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
aSequence[0] = pMemberOf->GetAccessible();
pRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) );
}
}
return xRelSet;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueSetAcc::getAccessibleStateSet()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
// Set some states.
pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
if ( !mbIsTransientChildrenDisabled )
pStateSet->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS);
pStateSet->AddState (accessibility::AccessibleStateType::FOCUSABLE);
if (mbIsFocused)
pStateSet->AddState (accessibility::AccessibleStateType::FOCUSED);
return pStateSet;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
lang::Locale SAL_CALL ValueSetAcc::getLocale()
2002-02-25 09:52:14 +00:00
throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
const OUString aEmptyStr;
2002-02-25 09:52:14 +00:00
uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
lang::Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
if( xParent.is() )
{
uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
if( xParentContext.is() )
aRet = xParentContext->getLocale ();
}
return aRet;
}
// -----------------------------------------------------------------------------
void SAL_CALL ValueSetAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
::osl::MutexGuard aGuard (m_aMutex);
2002-02-25 09:52:14 +00:00
if( rxListener.is() )
{
::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
sal_Bool bFound = sal_False;
while( !bFound && ( aIter != mxEventListeners.end() ) )
{
2002-03-05 14:28:18 +00:00
if( *aIter == rxListener )
2002-02-25 09:52:14 +00:00
bFound = sal_True;
2002-03-05 14:28:18 +00:00
else
2011-08-13 15:12:01 +02:00
++aIter;
2002-02-25 09:52:14 +00:00
}
if (!bFound)
mxEventListeners.push_back( rxListener );
}
}
// -----------------------------------------------------------------------------
void SAL_CALL ValueSetAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
::osl::MutexGuard aGuard (m_aMutex);
2002-02-25 09:52:14 +00:00
if( rxListener.is() )
{
::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
2002-02-25 09:52:14 +00:00
if (aIter != mxEventListeners.end())
mxEventListeners.erase(aIter);
2002-02-25 09:52:14 +00:00
}
}
// -----------------------------------------------------------------------------
sal_Bool SAL_CALL ValueSetAcc::containsPoint( const awt::Point& aPoint )
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const awt::Rectangle aRect( getBounds() );
const Point aSize( aRect.Width, aRect.Height );
const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
2002-02-25 09:52:14 +00:00
return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
const sal_uInt16 nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
2002-02-25 09:52:14 +00:00
uno::Reference< accessibility::XAccessible > xRet;
if ( nItemId )
2002-02-25 09:52:14 +00:00
{
const size_t nItemPos = mpParent->GetItemPos( nItemId );
2002-02-25 09:52:14 +00:00
if( VALUESET_ITEM_NONEITEM != nItemPos )
{
ValueSetItem *const pItem = mpParent->mItemList[nItemPos];
2012-02-19 23:17:51 +01:00
xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
2002-02-25 09:52:14 +00:00
}
}
return xRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
awt::Rectangle SAL_CALL ValueSetAcc::getBounds()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 15:39:54 +00:00
const Point aOutPos( mpParent->GetPosPixel() );
const Size aOutSize( mpParent->GetOutputSizePixel() );
2002-02-25 09:52:14 +00:00
awt::Rectangle aRet;
aRet.X = aOutPos.X();
aRet.Y = aOutPos.Y();
aRet.Width = aOutSize.Width();
aRet.Height = aOutSize.Height();
return aRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
awt::Point SAL_CALL ValueSetAcc::getLocation()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const awt::Rectangle aRect( getBounds() );
awt::Point aRet;
2002-02-25 09:52:14 +00:00
aRet.X = aRect.X;
aRet.Y = aRect.Y;
2002-02-25 09:52:14 +00:00
return aRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
awt::Point SAL_CALL ValueSetAcc::getLocationOnScreen()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 15:39:54 +00:00
const Point aScreenPos( mpParent->OutputToAbsoluteScreenPixel( Point() ) );
2002-02-25 09:52:14 +00:00
awt::Point aRet;
aRet.X = aScreenPos.X();
aRet.Y = aScreenPos.Y();
return aRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
awt::Size SAL_CALL ValueSetAcc::getSize()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const awt::Rectangle aRect( getBounds() );
awt::Size aRet;
2002-02-25 09:52:14 +00:00
aRet.Width = aRect.Width;
aRet.Height = aRect.Height;
2002-02-25 09:52:14 +00:00
return aRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
void SAL_CALL ValueSetAcc::grabFocus()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 15:39:54 +00:00
mpParent->GrabFocus();
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
uno::Any SAL_CALL ValueSetAcc::getAccessibleKeyBinding()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
2002-02-25 09:52:14 +00:00
return uno::Any();
}
// -----------------------------------------------------------------------------
sal_Int32 SAL_CALL ValueSetAcc::getForeground( )
throw (uno::RuntimeException)
{
ThrowIfDisposed();
sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
return static_cast<sal_Int32>(nColor);
}
// -----------------------------------------------------------------------------
sal_Int32 SAL_CALL ValueSetAcc::getBackground( )
throw (uno::RuntimeException)
{
ThrowIfDisposed();
sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
return static_cast<sal_Int32>(nColor);
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
void SAL_CALL ValueSetAcc::selectAccessibleChild( sal_Int32 nChildIndex )
2002-02-25 09:52:14 +00:00
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
2002-02-25 09:52:14 +00:00
if(pItem != NULL)
{
2002-02-25 15:39:54 +00:00
mpParent->SelectItem( pItem->mnId );
mpParent->Select ();
}
2002-02-25 09:52:14 +00:00
else
throw lang::IndexOutOfBoundsException();
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
sal_Bool SAL_CALL ValueSetAcc::isAccessibleChildSelected( sal_Int32 nChildIndex )
2002-02-25 09:52:14 +00:00
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
2002-02-25 09:52:14 +00:00
sal_Bool bRet = sal_False;
if (pItem != NULL)
2002-02-25 15:39:54 +00:00
bRet = mpParent->IsItemSelected( pItem->mnId );
2002-02-25 09:52:14 +00:00
else
throw lang::IndexOutOfBoundsException();
return bRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
void SAL_CALL ValueSetAcc::clearAccessibleSelection()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 15:39:54 +00:00
mpParent->SetNoSelection();
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
void SAL_CALL ValueSetAcc::selectAllAccessibleChildren()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
2002-02-25 09:52:14 +00:00
// unsupported due to single selection only
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
sal_Int32 SAL_CALL ValueSetAcc::getSelectedAccessibleChildCount()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 09:52:14 +00:00
sal_Int32 nRet = 0;
for( sal_uInt16 i = 0, nCount = getItemCount(); i < nCount; i++ )
2002-02-25 09:52:14 +00:00
{
ValueSetItem* pItem = getItem (i);
2002-02-25 09:52:14 +00:00
2002-02-25 15:39:54 +00:00
if( pItem && mpParent->IsItemSelected( pItem->mnId ) )
2002-02-25 09:52:14 +00:00
++nRet;
}
return nRet;
}
// -----------------------------------------------------------------------------
2002-02-25 15:39:54 +00:00
uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
2002-02-25 09:52:14 +00:00
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
2002-02-25 09:52:14 +00:00
uno::Reference< accessibility::XAccessible > xRet;
for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) && !xRet.is(); i++ )
2002-02-25 09:52:14 +00:00
{
ValueSetItem* pItem = getItem(i);
2002-02-25 09:52:14 +00:00
2002-02-25 15:39:54 +00:00
if( pItem && mpParent->IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int32 >( nSel++ ) ) )
xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
2002-02-25 09:52:14 +00:00
}
return xRet;
}
// -----------------------------------------------------------------------------
void SAL_CALL ValueSetAcc::deselectAccessibleChild( sal_Int32 nChildIndex )
2002-02-25 09:52:14 +00:00
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
// Because of the single selection we can reset the whole selection when
// the specified child is currently selected.
if (isAccessibleChildSelected(nChildIndex))
mpParent->SetNoSelection();
2002-02-25 09:52:14 +00:00
}
2002-02-25 15:39:54 +00:00
// -----------------------------------------------------------------------------
sal_Int64 SAL_CALL ValueSetAcc::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw( uno::RuntimeException )
{
sal_Int64 nRet;
if( ( rId.getLength() == 16 ) && ( 0 == memcmp( ValueSetAcc::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
2002-02-25 15:39:54 +00:00
nRet = reinterpret_cast< sal_Int64 >( this );
else
nRet = 0;
return nRet;
}
void SAL_CALL ValueSetAcc::disposing (void)
{
::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy;
{
// Make a copy of the list and clear the original.
const SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard (m_aMutex);
aListenerListCopy = mxEventListeners;
mxEventListeners.clear();
// Reset the pointer to the parent. It has to be the one who has
// disposed us because he is dying.
mpParent = NULL;
}
// Inform all listeners that this objects is disposing.
::std::vector<uno::Reference<accessibility::XAccessibleEventListener> >::const_iterator
aListenerIterator (aListenerListCopy.begin());
lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this));
while (aListenerIterator != aListenerListCopy.end())
{
try
{
(*aListenerIterator)->disposing (aEvent);
}
2011-06-13 23:40:41 +01:00
catch(const uno::Exception&)
{
// Ignore exceptions.
}
++aListenerIterator;
}
}
sal_uInt16 ValueSetAcc::getItemCount (void) const
{
sal_uInt16 nCount = mpParent->ImplGetVisibleItemCount();
// When the None-Item is visible then increase the number of items by
// one.
if (HasNoneField())
nCount += 1;
return nCount;
}
ValueSetItem* ValueSetAcc::getItem (sal_uInt16 nIndex) const
{
ValueSetItem* pItem = NULL;
if (HasNoneField())
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
{
if (nIndex == 0)
// When present the first item is the then always visible none field.
pItem = mpParent->ImplGetItem (VALUESET_ITEM_NONEITEM);
else
// Shift down the index to compensate for the none field.
nIndex -= 1;
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
}
if (pItem == NULL)
pItem = mpParent->ImplGetItem (static_cast<sal_uInt16>(nIndex));
return pItem;
}
void ValueSetAcc::ThrowIfDisposed (void)
throw (::com::sun::star::lang::DisposedException)
{
if (rBHelper.bDisposed || rBHelper.bInDispose)
{
OSL_TRACE ("Calling disposed object. Throwing exception:");
throw lang::DisposedException (
OUString("object has been already disposed"),
static_cast<uno::XWeak*>(this));
}
else
2008-10-28 15:03:16 +00:00
{
DBG_ASSERT (mpParent!=NULL, "ValueSetAcc not disposed but mpParent == NULL");
2008-10-28 15:03:16 +00:00
}
}
bool ValueSetAcc::HasNoneField (void) const
{
DBG_ASSERT (mpParent!=NULL, "ValueSetAcc::HasNoneField called with mpParent==NULL");
return ((mpParent->GetStyle() & WB_NONEFIELD) != 0);
}
2002-02-25 09:52:14 +00:00
// ----------------
// - ValueItemAcc -
// ----------------
ValueItemAcc::ValueItemAcc( ValueSetItem* pParent, bool bIsTransientChildrenDisabled ) :
mpParent( pParent ),
mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
2002-02-25 09:52:14 +00:00
{
}
// -----------------------------------------------------------------------------
ValueItemAcc::~ValueItemAcc()
{
}
// -----------------------------------------------------------------------
void ValueItemAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
{
if( nEventId )
{
::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners );
accessibility::AccessibleEventObject aEvtObject;
aEvtObject.EventId = nEventId;
aEvtObject.Source = static_cast<uno::XWeak*>(this);
aEvtObject.NewValue = rNewValue;
aEvtObject.OldValue = rOldValue;
for (::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter( aTmpListeners.begin() );
aIter != aTmpListeners.end() ; ++aIter)
{
(*aIter)->notifyEvent( aEvtObject );
}
}
}
2002-02-25 09:52:14 +00:00
// -----------------------------------------------------------------------------
void ValueItemAcc::ParentDestroyed()
{
const ::osl::MutexGuard aGuard( maMutex );
2002-02-25 09:52:14 +00:00
mpParent = NULL;
}
2011-06-01 10:02:08 +01:00
namespace
{
class theValueItemAccUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theValueItemAccUnoTunnelId > {};
}
2002-02-25 09:52:14 +00:00
const uno::Sequence< sal_Int8 >& ValueItemAcc::getUnoTunnelId()
{
2011-06-01 10:02:08 +01:00
return theValueItemAccUnoTunnelId::get().getSeq();
}
// -----------------------------------------------------------------------------
ValueItemAcc* ValueItemAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
throw()
{
try
{
uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
return( xUnoTunnel.is() ? reinterpret_cast<ValueItemAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( ValueItemAcc::getUnoTunnelId() ))) : NULL );
}
2011-06-13 23:40:41 +01:00
catch(const ::com::sun::star::uno::Exception&)
{
return NULL;
}
}
// -----------------------------------------------------------------------------
2002-02-25 09:52:14 +00:00
uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueItemAcc::getAccessibleContext()
throw (uno::RuntimeException)
{
return this;
}
// -----------------------------------------------------------------------------
sal_Int32 SAL_CALL ValueItemAcc::getAccessibleChildCount()
throw (uno::RuntimeException)
{
return 0;
}
// -----------------------------------------------------------------------------
uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleChild( sal_Int32 )
2002-02-25 09:52:14 +00:00
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
throw lang::IndexOutOfBoundsException();
}
// -----------------------------------------------------------------------------
uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleParent()
throw (uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
2002-02-25 09:52:14 +00:00
uno::Reference< accessibility::XAccessible > xRet;
if( mpParent )
xRet = mpParent->mrParent.GetAccessible();
return xRet;
}
// -----------------------------------------------------------------------------
sal_Int32 SAL_CALL ValueItemAcc::getAccessibleIndexInParent()
throw (uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
// The index defaults to -1 to indicate the child does not belong to its
// parent.
sal_Int32 nIndexInParent = -1;
2002-02-25 09:52:14 +00:00
if( mpParent )
{
bool bDone = false;
2002-02-25 09:52:14 +00:00
sal_uInt16 nCount = mpParent->mrParent.ImplGetVisibleItemCount();
ValueSetItem* pItem;
for (sal_uInt16 i=0; i<nCount && !bDone; i++)
2002-02-25 09:52:14 +00:00
{
// Guard the retrieval of the i-th child with a try/catch block
// just in case the number of children changes in the mean time.
try
2002-02-25 09:52:14 +00:00
{
pItem = mpParent->mrParent.ImplGetItem(i);
2002-02-25 09:52:14 +00:00
}
2011-06-13 23:40:41 +01:00
catch (const lang::IndexOutOfBoundsException&)
{
pItem = NULL;
}
// Do not create an accessible object for the test.
if (pItem != NULL && pItem->mpxAcc != NULL)
if (pItem->GetAccessible( mbIsTransientChildrenDisabled ).get() == this )
{
nIndexInParent = i;
bDone = true;
}
2002-02-25 09:52:14 +00:00
}
}
//if this valueset contain a none field(common value is default), then we should increase the real index and set the noitem index value equal 0.
if ( mpParent && ( (mpParent->mrParent.GetStyle() & WB_NONEFIELD) != 0 ) )
{
ValueSetItem* pFirstItem = mpParent->mrParent.ImplGetItem (VALUESET_ITEM_NONEITEM);
if( pFirstItem && pFirstItem ->GetAccessible(mbIsTransientChildrenDisabled).get() == this )
nIndexInParent = 0;
else
nIndexInParent++;
}
return nIndexInParent;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
sal_Int16 SAL_CALL ValueItemAcc::getAccessibleRole()
throw (uno::RuntimeException)
{
return accessibility::AccessibleRole::LIST_ITEM;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
OUString SAL_CALL ValueItemAcc::getAccessibleDescription()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
return OUString();
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
OUString SAL_CALL ValueItemAcc::getAccessibleName()
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
OUString aRet;
if( mpParent )
{
aRet = mpParent->maText;
if( aRet.isEmpty() )
{
OUStringBuffer aBuffer("Item ");
aBuffer.append(static_cast<sal_Int32>(mpParent->mnId));
aRet = aBuffer.makeStringAndClear();
}
}
return aRet;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueItemAcc::getAccessibleRelationSet()
throw (uno::RuntimeException)
{
return uno::Reference< accessibility::XAccessibleRelationSet >();
}
// -----------------------------------------------------------------------------
uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueItemAcc::getAccessibleStateSet()
throw (uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
if( mpParent )
{
pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
if ( !mbIsTransientChildrenDisabled )
pStateSet->AddState (accessibility::AccessibleStateType::TRANSIENT);
// SELECTABLE
pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
// pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
// SELECTED
if( mpParent->mrParent.GetSelectItemId() == mpParent->mnId )
{
pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
// pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
}
}
return pStateSet;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
lang::Locale SAL_CALL ValueItemAcc::getLocale()
throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
const OUString aEmptyStr;
2002-02-25 09:52:14 +00:00
uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
lang::Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
if( xParent.is() )
{
uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
if( xParentContext.is() )
aRet = xParentContext->getLocale();
}
return aRet;
}
// -----------------------------------------------------------------------------
void SAL_CALL ValueItemAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
const ::osl::MutexGuard aGuard( maMutex );
2002-02-25 09:52:14 +00:00
if( rxListener.is() )
{
::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
sal_Bool bFound = sal_False;
while( !bFound && ( aIter != mxEventListeners.end() ) )
{
2002-03-05 14:28:18 +00:00
if( *aIter == rxListener )
2002-02-25 09:52:14 +00:00
bFound = sal_True;
2002-03-05 14:28:18 +00:00
else
2011-08-13 15:12:01 +02:00
++aIter;
2002-02-25 09:52:14 +00:00
}
if (!bFound)
mxEventListeners.push_back( rxListener );
}
}
// -----------------------------------------------------------------------------
void SAL_CALL ValueItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
const ::osl::MutexGuard aGuard( maMutex );
2002-02-25 09:52:14 +00:00
if( rxListener.is() )
{
::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
2002-02-25 09:52:14 +00:00
if (aIter != mxEventListeners.end())
mxEventListeners.erase(aIter);
2002-02-25 09:52:14 +00:00
}
}
// -----------------------------------------------------------------------------
sal_Bool SAL_CALL ValueItemAcc::containsPoint( const awt::Point& aPoint )
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
const awt::Rectangle aRect( getBounds() );
const Point aSize( aRect.Width, aRect.Height );
const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
2002-02-25 09:52:14 +00:00
return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleAtPoint( const awt::Point& )
2002-02-25 09:52:14 +00:00
throw (uno::RuntimeException)
{
2002-03-05 14:32:10 +00:00
uno::Reference< accessibility::XAccessible > xRet;
return xRet;
2002-02-25 09:52:14 +00:00
}
// -----------------------------------------------------------------------------
awt::Rectangle SAL_CALL ValueItemAcc::getBounds()
throw (uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
2002-02-25 09:52:14 +00:00
awt::Rectangle aRet;
if( mpParent )
{
Rectangle aRect( mpParent->mrParent.GetItemRect(mpParent->mnId) );
Point aOrigin;
Rectangle aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() );
aRect.Intersection( aParentRect );
aRet.X = aRect.Left();
aRet.Y = aRect.Top();
aRet.Width = aRect.GetWidth();
aRet.Height = aRect.GetHeight();
2002-02-25 09:52:14 +00:00
}
return aRet;
}
// -----------------------------------------------------------------------------
awt::Point SAL_CALL ValueItemAcc::getLocation()
throw (uno::RuntimeException)
{
const awt::Rectangle aRect( getBounds() );
awt::Point aRet;
2002-02-25 09:52:14 +00:00
aRet.X = aRect.X;
aRet.Y = aRect.Y;
2002-02-25 09:52:14 +00:00
return aRet;
}
// -----------------------------------------------------------------------------
awt::Point SAL_CALL ValueItemAcc::getLocationOnScreen()
throw (uno::RuntimeException)
{
const SolarMutexGuard aSolarGuard;
2002-02-25 09:52:14 +00:00
awt::Point aRet;
if( mpParent )
{
const Point aPos = mpParent->mrParent.GetItemRect(mpParent->mnId).TopLeft();
const Point aScreenPos( mpParent->mrParent.OutputToAbsoluteScreenPixel( aPos ) );
2002-02-25 09:52:14 +00:00
aRet.X = aScreenPos.X();
aRet.Y = aScreenPos.Y();
}
return aRet;
}
// -----------------------------------------------------------------------------
awt::Size SAL_CALL ValueItemAcc::getSize()
throw (uno::RuntimeException)
{
const awt::Rectangle aRect( getBounds() );
awt::Size aRet;
2002-02-25 09:52:14 +00:00
aRet.Width = aRect.Width;
aRet.Height = aRect.Height;
2002-02-25 09:52:14 +00:00
return aRet;
}
// -----------------------------------------------------------------------------
void SAL_CALL ValueItemAcc::grabFocus()
throw (uno::RuntimeException)
{
// nothing to do
}
// -----------------------------------------------------------------------------
uno::Any SAL_CALL ValueItemAcc::getAccessibleKeyBinding()
throw (uno::RuntimeException)
{
return uno::Any();
}
// -----------------------------------------------------------------------------
sal_Int32 SAL_CALL ValueItemAcc::getForeground( )
throw (uno::RuntimeException)
{
sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
return static_cast<sal_Int32>(nColor);
}
// -----------------------------------------------------------------------------
sal_Int32 SAL_CALL ValueItemAcc::getBackground( )
throw (uno::RuntimeException)
{
sal_uInt32 nColor;
if (mpParent && mpParent->meType == VALUESETITEM_COLOR)
nColor = mpParent->maColor.GetColor();
else
nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
return static_cast<sal_Int32>(nColor);
}
// -----------------------------------------------------------------------------
sal_Int64 SAL_CALL ValueItemAcc::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw( uno::RuntimeException )
{
sal_Int64 nRet;
if( ( rId.getLength() == 16 ) && ( 0 == memcmp( ValueItemAcc::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
nRet = reinterpret_cast< sal_Int64 >( this );
else
nRet = 0;
return nRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */