2002-04-16 11:08:19 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: AccessibleControlShape.cxx,v $
|
|
|
|
*
|
2002-09-20 09:50:27 +00:00
|
|
|
* $Revision: 1.12 $
|
2002-04-16 11:08:19 +00:00
|
|
|
*
|
2002-09-20 09:50:27 +00:00
|
|
|
* last change: $Author: fs $ $Date: 2002-09-20 10:50:27 $
|
2002-04-16 11:08:19 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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 for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (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.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _SVX_ACCESSIBILITY_ACCESSIBLE_CONTROL_SHAPE_HXX
|
|
|
|
#include "AccessibleControlShape.hxx"
|
|
|
|
#endif
|
2002-05-06 08:00:26 +00:00
|
|
|
#ifndef _SVX_ACCESSIBILITY_ACCESSIBLE_SHAPE_INFO_HXX
|
|
|
|
#include "AccessibleShapeInfo.hxx"
|
|
|
|
#endif
|
2002-04-16 11:08:19 +00:00
|
|
|
#ifndef _SVX_ACCESSIBILITY_DESCRIPTION_GENERATOR_HXX
|
|
|
|
#include "DescriptionGenerator.hxx"
|
|
|
|
#endif
|
2002-04-29 15:51:40 +00:00
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_
|
|
|
|
#include <com/sun/star/drawing/XControlShape.hpp>
|
|
|
|
#endif
|
2002-05-02 06:40:18 +00:00
|
|
|
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
|
2002-04-29 15:51:40 +00:00
|
|
|
#include <drafts/com/sun/star/accessibility/AccessibleEventId.hpp>
|
2002-05-02 06:40:18 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_REFLECTION_XPROXYFACTORY_HPP_
|
|
|
|
#include <com/sun/star/reflection/XProxyFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVDOUNO_HXX
|
|
|
|
#include "svdouno.hxx"
|
|
|
|
#endif
|
2002-05-06 08:00:26 +00:00
|
|
|
#ifndef _SVX_UNOAPI_HXX_
|
|
|
|
#include "unoapi.hxx"
|
|
|
|
#endif
|
2002-09-11 08:49:15 +00:00
|
|
|
#ifndef _SVX_ACCESSIBILITY_SHAPE_TYPE_HANDLER_HXX
|
2002-04-16 11:08:19 +00:00
|
|
|
#include "ShapeTypeHandler.hxx"
|
2002-09-11 08:49:15 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SVX_ACCESSIBILITY_SVX_SHAPE_TYPES_HXX
|
2002-04-16 11:08:19 +00:00
|
|
|
#include "SvxShapeTypes.hxx"
|
2002-09-11 08:49:15 +00:00
|
|
|
#endif
|
2002-05-17 10:55:01 +00:00
|
|
|
#include "svdstr.hrc"
|
2002-04-16 11:08:19 +00:00
|
|
|
|
|
|
|
using namespace accessibility;
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::drafts::com::sun::star::accessibility;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
2002-05-02 06:40:18 +00:00
|
|
|
using ::com::sun::star::reflection::XProxyFactory;
|
|
|
|
using ::com::sun::star::uno::XAggregation;
|
|
|
|
using ::com::sun::star::lang::XComponent;
|
2002-04-16 11:08:19 +00:00
|
|
|
|
|
|
|
//===== internal ============================================================
|
|
|
|
|
2002-05-06 08:00:26 +00:00
|
|
|
AccessibleControlShape::AccessibleControlShape (
|
|
|
|
const AccessibleShapeInfo& rShapeInfo,
|
|
|
|
const AccessibleShapeTreeInfo& rShapeTreeInfo)
|
|
|
|
: AccessibleShape (rShapeInfo, rShapeTreeInfo)
|
2002-04-29 15:51:40 +00:00
|
|
|
, mbListeningForName( sal_False )
|
|
|
|
, mbListeningForDesc( sal_False )
|
2002-05-02 06:40:18 +00:00
|
|
|
, mbDisposeNativeContext( sal_False )
|
2002-04-16 11:08:19 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AccessibleControlShape::~AccessibleControlShape (void)
|
|
|
|
{
|
2002-05-02 06:40:18 +00:00
|
|
|
if ( m_xControlContextProxy.is() )
|
|
|
|
m_xControlContextProxy->setDelegator( NULL );
|
|
|
|
m_xControlContextProxy.clear();
|
|
|
|
// this should remove the _one_and_only_ "real" reference (means not delegated to
|
2002-05-02 06:47:50 +00:00
|
|
|
// ourself) to this proxy, and thus delete it
|
2002-04-16 11:08:19 +00:00
|
|
|
}
|
|
|
|
|
2002-05-02 06:40:18 +00:00
|
|
|
//=============================================================================
|
|
|
|
SdrObject* AccessibleControlShape::getSdrObject() const
|
|
|
|
{
|
2002-05-06 08:00:26 +00:00
|
|
|
return GetSdrObjectFromXShape (mxShape);
|
2002-05-02 06:40:18 +00:00
|
|
|
}
|
2002-04-16 11:08:19 +00:00
|
|
|
|
2002-05-02 06:40:18 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void AccessibleControlShape::Init()
|
|
|
|
{
|
|
|
|
AccessibleShape::Init();
|
2002-04-16 11:08:19 +00:00
|
|
|
|
2002-05-02 06:40:18 +00:00
|
|
|
OSL_ENSURE( !m_xControlContextProxy.is(), "AccessibleControlShape::Init: already initialized!" );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// What we need to do here is merge the functionality of the AccessibleContext of our UNO control
|
|
|
|
// with our own AccessibleContext-related functionality.
|
|
|
|
//
|
|
|
|
// The problem is that we do not know the interfaces our "inner" context supports - this may be any
|
|
|
|
// XAccessibleXXX interface (or even any other) which makes sense for it.
|
|
|
|
//
|
|
|
|
// In theory, we could implement all possible interfaces ourself, and re-route all functionality to
|
|
|
|
// the inner context (except those we implement ourself, like XAccessibleComponent). But this is in no
|
|
|
|
// way future-proof - as soon as an inner context appears which implements an additional interface,
|
|
|
|
// we would need to adjust our implementation to support this new interface, too. Bad idea.
|
|
|
|
//
|
|
|
|
// The usual solution for such a problem is aggregation. Aggregation means using UNO's own meachnisms
|
|
|
|
// for merging an inner with an outer component, an get a component which behaves as it is exactly one.
|
|
|
|
// This is what XAggregation is for. Unfortunately, aggregation requires _exact_ control over the ref count
|
|
|
|
// of the inner object, which we do not have at all.
|
|
|
|
// Bad, too.
|
|
|
|
//
|
|
|
|
// But there is a solution: com.sun.star.reflection.ProxyFactory. This service is able to create a proxy
|
|
|
|
// for any component, which supports _exactly_ the same interfaces as the component. In addition, it can
|
|
|
|
// be aggregated, as by definition the proxy's ref count is exactly one when returned from the factory.
|
|
|
|
// Sounds better. Though this yields the problem of slightly degraded performance, it's the only solution
|
|
|
|
// I'm aware of at the moment .....
|
|
|
|
//
|
|
|
|
// 98750 - 30.04.2002 - fs@openoffice.org
|
|
|
|
//
|
|
|
|
|
|
|
|
// get the control which belongs to our model (relative to our view)
|
2002-05-17 10:55:01 +00:00
|
|
|
const Window* pViewWindow = maShapeTreeInfo.GetWindow();
|
2002-05-02 06:40:18 +00:00
|
|
|
SdrUnoObj* pUnoObjectImpl = PTR_CAST( SdrUnoObj, getSdrObject() );
|
|
|
|
OSL_ENSURE( pViewWindow && pUnoObjectImpl, "AccessibleControlShape::Init: no view, or no SdrUnoObj!" );
|
|
|
|
|
|
|
|
if ( pViewWindow && pUnoObjectImpl )
|
|
|
|
{
|
|
|
|
// get the context of the control - it will be our "inner" context
|
2002-09-11 08:49:15 +00:00
|
|
|
m_xControlModes = m_xControlModes.query( pUnoObjectImpl->GetUnoControl( pViewWindow ) );
|
|
|
|
Reference< XAccessible > xControlAccessible( m_xControlModes, uno::UNO_QUERY );
|
2002-05-02 06:40:18 +00:00
|
|
|
Reference< XAccessibleContext > xNativeControlContext;
|
|
|
|
if ( xControlAccessible.is() )
|
|
|
|
xNativeControlContext = xControlAccessible->getAccessibleContext();
|
2002-09-11 08:49:15 +00:00
|
|
|
OSL_ENSURE( xNativeControlContext.is(), "AccessibleControlShape::Init: no AccessibleContext for the control!" );
|
2002-05-02 06:40:18 +00:00
|
|
|
|
|
|
|
// get a proxy for this context
|
|
|
|
// first a factory for the proxy
|
|
|
|
Reference< XProxyFactory > xFactory;
|
|
|
|
xFactory = xFactory.query( ::comphelper::createProcessComponent(
|
|
|
|
::rtl::OUString::createFromAscii( "com.sun.star.reflection.ProxyFactory" ) ) );
|
|
|
|
OSL_ENSURE( xFactory.is(), "AccessibleControlShape::Init: could not create a proxy factory!" );
|
|
|
|
// then the proxy itself
|
|
|
|
if ( xFactory.is() && xNativeControlContext.is() )
|
|
|
|
{
|
|
|
|
m_xControlContextProxy = xFactory->createProxy( xNativeControlContext );
|
|
|
|
|
|
|
|
// aggregate the proxy
|
|
|
|
osl_incrementInterlockedCount( &m_refCount );
|
|
|
|
if ( m_xControlContextProxy.is() )
|
|
|
|
{
|
|
|
|
// At this point in time, the proxy has a ref count of exactly one - in m_xControlContextProxy.
|
|
|
|
// Remember to _not_ reset this member unles the delegator of the proxy has been reset, too!
|
|
|
|
m_xControlContextProxy->setDelegator( *this );
|
|
|
|
}
|
|
|
|
osl_decrementInterlockedCount( &m_refCount );
|
|
|
|
|
|
|
|
mbDisposeNativeContext = sal_True;
|
|
|
|
|
2002-09-11 08:49:15 +00:00
|
|
|
// Finally, we need to add ourself as mode listener to the control. In case the mode switches,
|
|
|
|
// we need to dispose ourself.
|
|
|
|
m_xControlModes->addModeChangeListener( this );
|
2002-05-02 06:40:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const uno::Exception& )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "AccessibleControlShape::Init: could not \"aggregate\" the controls XAccessibleContext!" );
|
|
|
|
}
|
|
|
|
}
|
2002-04-16 11:08:19 +00:00
|
|
|
|
|
|
|
//===== XAccessible =========================================================
|
|
|
|
|
|
|
|
Reference<XAccessibleContext> SAL_CALL
|
|
|
|
AccessibleControlShape::getAccessibleContext (void)
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return AccessibleShape::getAccessibleContext ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===== XServiceInfo ========================================================
|
|
|
|
|
|
|
|
::rtl::OUString SAL_CALL
|
|
|
|
AccessibleControlShape::getImplementationName (void)
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleControlShape"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Set this object's name if is different to the current name.
|
|
|
|
::rtl::OUString
|
|
|
|
AccessibleControlShape::CreateAccessibleBaseName (void)
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
::rtl::OUString sName;
|
|
|
|
|
|
|
|
ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
|
|
|
|
switch (nShapeType)
|
|
|
|
{
|
|
|
|
case DRAWING_CONTROL:
|
|
|
|
sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("ControlShape"));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleControlShape"));
|
|
|
|
uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
|
|
|
|
if (xDescriptor.is())
|
|
|
|
sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
|
|
|
|
+ xDescriptor->getShapeType();
|
|
|
|
}
|
|
|
|
|
|
|
|
return sName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-04-29 15:51:40 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
//................................................................
|
|
|
|
const ::rtl::OUString& lcl_getNamePropertyName( )
|
|
|
|
{
|
|
|
|
static ::rtl::OUString s_sNamePropertyName( RTL_CONSTASCII_USTRINGPARAM( "Name" ) );
|
|
|
|
return s_sNamePropertyName;
|
|
|
|
}
|
|
|
|
//................................................................
|
|
|
|
const ::rtl::OUString& lcl_getDescPropertyName( )
|
|
|
|
{
|
|
|
|
static ::rtl::OUString s_sDescPropertyDesc( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) );
|
|
|
|
return s_sDescPropertyDesc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-04-16 11:08:19 +00:00
|
|
|
::rtl::OUString
|
|
|
|
AccessibleControlShape::CreateAccessibleDescription (void)
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
DescriptionGenerator aDG (mxShape);
|
|
|
|
ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
|
|
|
|
switch (nShapeType)
|
|
|
|
{
|
|
|
|
case DRAWING_CONTROL:
|
2002-04-29 15:51:40 +00:00
|
|
|
{
|
|
|
|
// check if we can obtain the "Desc" property from the model
|
|
|
|
::rtl::OUString sDesc( getControlModelStringProperty( lcl_getDescPropertyName() ) );
|
|
|
|
if ( !sDesc.getLength() )
|
|
|
|
{ // no -> use the default
|
2002-05-17 10:55:01 +00:00
|
|
|
aDG.Initialize (STR_ObjNameSingulUno);
|
2002-04-29 15:51:40 +00:00
|
|
|
aDG.AddProperty (OUString::createFromAscii ("ControlBackground"),
|
|
|
|
DescriptionGenerator::COLOR,
|
|
|
|
OUString());
|
|
|
|
aDG.AddProperty (OUString::createFromAscii ("ControlBorder"),
|
|
|
|
DescriptionGenerator::INTEGER,
|
|
|
|
OUString());
|
|
|
|
}
|
|
|
|
// ensure that we are listening to the Name property
|
|
|
|
mbListeningForDesc = ensureListeningState( mbListeningForDesc, sal_True, lcl_getDescPropertyName() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-04-16 11:08:19 +00:00
|
|
|
default:
|
|
|
|
aDG.Initialize (::rtl::OUString::createFromAscii (
|
|
|
|
"Unknown accessible control shape"));
|
|
|
|
uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
|
|
|
|
if (xDescriptor.is())
|
|
|
|
{
|
|
|
|
aDG.AppendString (::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("service name=")));
|
|
|
|
aDG.AppendString (xDescriptor->getShapeType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aDG();
|
|
|
|
}
|
|
|
|
|
2002-04-29 15:51:40 +00:00
|
|
|
//--------------------------------------------------------------------
|
2002-09-11 08:49:15 +00:00
|
|
|
IMPLEMENT_FORWARD_REFCOUNT( AccessibleControlShape, AccessibleShape )
|
|
|
|
IMPLEMENT_GET_IMPLEMENTATION_ID( AccessibleControlShape )
|
2002-04-29 15:51:40 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL AccessibleControlShape::propertyChange( const beans::PropertyChangeEvent& _rEvent ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( maMutex );
|
|
|
|
|
|
|
|
// check if it is the name or the description
|
|
|
|
if ( _rEvent.PropertyName.equals( lcl_getNamePropertyName() ) )
|
|
|
|
{
|
2002-05-06 08:00:26 +00:00
|
|
|
SetAccessibleName (CreateAccessibleName());
|
2002-04-29 15:51:40 +00:00
|
|
|
}
|
|
|
|
else if ( _rEvent.PropertyName.equals( lcl_getDescPropertyName() ) )
|
|
|
|
{
|
2002-05-06 08:00:26 +00:00
|
|
|
SetAccessibleDescription (CreateAccessibleDescription());
|
2002-04-29 15:51:40 +00:00
|
|
|
}
|
|
|
|
#ifdef _DEBUG
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "AccessibleControlShape::propertyChange: where did this come from?" );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-09-11 08:49:15 +00:00
|
|
|
uno::Any SAL_CALL AccessibleControlShape::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
uno::Any aReturn = AccessibleShape::queryInterface( _rType );
|
|
|
|
if ( !aReturn.hasValue() )
|
|
|
|
{
|
|
|
|
aReturn = AccessibleControlShape_Base::queryInterface( _rType );
|
2002-09-20 09:50:27 +00:00
|
|
|
if ( !aReturn.hasValue() && m_xControlContextProxy.is() )
|
2002-09-11 08:49:15 +00:00
|
|
|
aReturn = m_xControlContextProxy->queryAggregation( _rType );
|
|
|
|
}
|
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
uno::Sequence< uno::Type > SAL_CALL AccessibleControlShape::getTypes() throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
uno::Sequence< uno::Type > aShapeTypes = AccessibleShape::getTypes();
|
|
|
|
uno::Sequence< uno::Type > aOwnTypes = AccessibleControlShape_Base::getTypes();
|
|
|
|
|
|
|
|
uno::Sequence< uno::Type > aAggregateTypes;
|
|
|
|
Reference< lang::XTypeProvider > xAggTypes;
|
|
|
|
if ( ::comphelper::query_aggregation( m_xControlContextProxy, xAggTypes ) )
|
|
|
|
aAggregateTypes = xAggTypes->getTypes();
|
|
|
|
|
2002-09-20 09:50:27 +00:00
|
|
|
uno::Sequence< uno::Type > aAllTypes = ::comphelper::concatSequences( aShapeTypes, aOwnTypes, aAggregateTypes );
|
|
|
|
|
|
|
|
// remove duplicates
|
|
|
|
uno::Type* pBegin = aAllTypes.getArray();
|
|
|
|
uno::Type* pEnd = pBegin + aAllTypes.getLength();
|
|
|
|
while ( pBegin != pEnd )
|
|
|
|
{
|
|
|
|
uno::Type aThisRoundType = *pBegin;
|
|
|
|
if ( ++pBegin != pEnd )
|
|
|
|
{
|
|
|
|
pEnd = ::std::remove( pBegin, pEnd, aThisRoundType );
|
|
|
|
// now all types between begin and (the old) end which equal aThisRoundType
|
|
|
|
// are moved behind the new end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aAllTypes.realloc( pEnd - aAllTypes.getArray() );
|
|
|
|
|
|
|
|
return aAllTypes;
|
2002-09-11 08:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL AccessibleControlShape::modeChanged( const util::ModeChangeEvent& _rSource ) throw (uno::RuntimeException)
|
2002-04-29 15:51:40 +00:00
|
|
|
{
|
2002-05-02 06:40:18 +00:00
|
|
|
// did it come from our inner context (the real one, not it's proxy!)?
|
2002-09-11 08:49:15 +00:00
|
|
|
OSL_TRACE ("AccessibleControlShape::modeChanged");
|
|
|
|
if ( _rSource.Source == m_xControlModes )
|
2002-05-02 06:40:18 +00:00
|
|
|
{
|
2002-05-06 08:00:26 +00:00
|
|
|
// If our "pseudo-aggregated" inner context does not live anymore,
|
|
|
|
// we don't want to live, too. This is accomplished by asking our
|
|
|
|
// parent to replace this object with a new one. Disposing this
|
|
|
|
// object and sending notifications about the replacement are the
|
|
|
|
// task of our parent.
|
2002-06-27 11:04:16 +00:00
|
|
|
AccessibleShape* pShape =
|
2002-05-06 08:00:26 +00:00
|
|
|
ShapeTypeHandler::Instance().CreateAccessibleObject (
|
2002-06-27 11:04:16 +00:00
|
|
|
AccessibleShapeInfo (
|
|
|
|
mxShape, getAccessibleParent(), mpParent, mnIndex),
|
|
|
|
maShapeTreeInfo);
|
2002-09-20 09:50:27 +00:00
|
|
|
|
|
|
|
Reference<XAccessible> xShape( pShape );
|
|
|
|
pShape->Init();
|
2002-06-27 11:04:16 +00:00
|
|
|
// Now that there is a reference to the new accessible shape we
|
|
|
|
// can safely call its Init() method. The following call transfers
|
|
|
|
// owenership to our parent so that at the end of the scope we can
|
|
|
|
// safely release the reference.
|
2002-09-20 09:50:27 +00:00
|
|
|
OSL_VERIFY( mpParent->ReplaceChild ( this, pShape ) );
|
2002-05-02 06:40:18 +00:00
|
|
|
}
|
2002-09-11 08:49:15 +00:00
|
|
|
#ifdef _DEBUG
|
2002-05-02 06:40:18 +00:00
|
|
|
else
|
2002-09-11 08:49:15 +00:00
|
|
|
OSL_ENSURE( sal_False, "AccessibleControlShape::modeChanged: where did this come from?" );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL AccessibleControlShape::disposing (const lang::EventObject& _rSource) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
AccessibleShape::disposing( _rSource );
|
2002-04-29 15:51:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
sal_Bool AccessibleControlShape::ensureListeningState(
|
|
|
|
const sal_Bool _bCurrentlyListening, const sal_Bool _bNeedNewListening,
|
|
|
|
const ::rtl::OUString& _rPropertyName )
|
|
|
|
{
|
|
|
|
if ( ( _bCurrentlyListening == _bNeedNewListening ) || !ensureControlModelAccess() )
|
|
|
|
// nothing to do
|
|
|
|
return _bCurrentlyListening;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( !mxModelPropsMeta.is() || mxModelPropsMeta->hasPropertyByName( _rPropertyName ) )
|
|
|
|
{
|
|
|
|
// add or revoke as listener
|
|
|
|
if ( _bNeedNewListening )
|
|
|
|
mxControlModel->addPropertyChangeListener( _rPropertyName, static_cast< beans::XPropertyChangeListener* >( this ) );
|
|
|
|
else
|
|
|
|
mxControlModel->removePropertyChangeListener( _rPropertyName, static_cast< beans::XPropertyChangeListener* >( this ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const uno::Exception& e )
|
|
|
|
{
|
|
|
|
e; // make compiler happy
|
|
|
|
OSL_ENSURE( sal_False, "AccessibleControlShape::ensureListeningState: could not change the listening state!" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return _bNeedNewListening;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
::rtl::OUString AccessibleControlShape::CreateAccessibleName (void) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// check if we can obtain the "Name" property from the model
|
|
|
|
::rtl::OUString sName( getControlModelStringProperty( lcl_getNamePropertyName() ) );
|
|
|
|
if ( !sName.getLength() )
|
|
|
|
{ // no -> use the default
|
|
|
|
sName = AccessibleShape::CreateAccessibleName();
|
|
|
|
}
|
|
|
|
|
|
|
|
// now that somebody first asked us for our name, ensure that we are listening to name changes on the model
|
|
|
|
mbListeningForName = ensureListeningState( mbListeningForName, sal_True, lcl_getNamePropertyName() );
|
|
|
|
|
|
|
|
return sName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL AccessibleControlShape::disposing (void)
|
|
|
|
{
|
|
|
|
// ensure we're not listening
|
|
|
|
mbListeningForName = ensureListeningState( mbListeningForName, sal_False, lcl_getNamePropertyName() );
|
|
|
|
mbListeningForDesc = ensureListeningState( mbListeningForDesc, sal_False, lcl_getDescPropertyName() );
|
|
|
|
|
|
|
|
// release the model
|
|
|
|
mxControlModel.clear();
|
|
|
|
mxModelPropsMeta.clear();
|
|
|
|
|
2002-05-02 06:40:18 +00:00
|
|
|
// forward the disposel to our inner context
|
|
|
|
if ( mbDisposeNativeContext )
|
|
|
|
{
|
2002-09-11 08:49:15 +00:00
|
|
|
// don't listen for mode changes anymore
|
|
|
|
OSL_ENSURE( m_xControlModes.is(), "AccessibleControlShape::disposing: don't have an mode broadcaster anymore!" );
|
|
|
|
if ( m_xControlModes.is() )
|
|
|
|
m_xControlModes->removeModeChangeListener( this );
|
2002-05-02 06:47:50 +00:00
|
|
|
|
2002-05-02 06:40:18 +00:00
|
|
|
Reference< XComponent > xInnerComponent;
|
|
|
|
if ( ::comphelper::query_aggregation( m_xControlContextProxy, xInnerComponent ) )
|
|
|
|
xInnerComponent->dispose();
|
2002-05-02 06:47:50 +00:00
|
|
|
// do _not_ clear m_xControlContextProxy! This has to be done in the dtor for correct ref-count handling
|
|
|
|
|
|
|
|
// no need to dispose the proxy/inner context anymore
|
2002-05-02 06:40:18 +00:00
|
|
|
mbDisposeNativeContext = sal_False;
|
|
|
|
}
|
2002-09-11 08:49:15 +00:00
|
|
|
|
|
|
|
m_xControlModes.clear();
|
2002-05-02 06:40:18 +00:00
|
|
|
|
2002-04-29 15:51:40 +00:00
|
|
|
// let the base do it's stuff
|
2002-05-02 06:40:18 +00:00
|
|
|
AccessibleShape::disposing();
|
2002-04-29 15:51:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-05-02 06:40:18 +00:00
|
|
|
sal_Bool AccessibleControlShape::ensureControlModelAccess() SAL_THROW(())
|
2002-04-29 15:51:40 +00:00
|
|
|
{
|
|
|
|
if ( mxControlModel.is() )
|
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< drawing::XControlShape > xShape( mxShape, uno::UNO_QUERY );
|
|
|
|
if ( xShape.is() )
|
2002-05-02 06:40:18 +00:00
|
|
|
mxControlModel = mxControlModel.query( xShape->getControl() );
|
2002-04-29 15:51:40 +00:00
|
|
|
|
|
|
|
if ( mxControlModel.is() )
|
2002-05-02 06:40:18 +00:00
|
|
|
mxModelPropsMeta = mxControlModel->getPropertySetInfo();
|
2002-04-29 15:51:40 +00:00
|
|
|
}
|
|
|
|
catch( const uno::Exception& e )
|
|
|
|
{
|
|
|
|
e; // make compiler happy
|
|
|
|
OSL_ENSURE( sal_False, "AccessibleControlShape::ensureControlModelAccess: caught an exception!" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return mxControlModel.is();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
::rtl::OUString AccessibleControlShape::getControlModelStringProperty( const ::rtl::OUString& _rPropertyName ) const SAL_THROW(())
|
|
|
|
{
|
|
|
|
::rtl::OUString sReturn;
|
|
|
|
try
|
|
|
|
{
|
2002-05-02 06:40:18 +00:00
|
|
|
if ( const_cast< AccessibleControlShape* >( this ) ->ensureControlModelAccess() )
|
2002-04-29 15:51:40 +00:00
|
|
|
{
|
|
|
|
if ( !mxModelPropsMeta.is() || mxModelPropsMeta->hasPropertyByName( _rPropertyName ) )
|
|
|
|
// ask only if a) the control does not have a PropertySetInfo object or b) it has, and the
|
|
|
|
// property in question is available
|
|
|
|
mxControlModel->getPropertyValue( _rPropertyName ) >>= sReturn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const uno::Exception& )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "OAccessibleControlContext::getModelStringProperty: caught an exception!" );
|
|
|
|
}
|
|
|
|
return sReturn;
|
|
|
|
}
|
2002-04-16 11:08:19 +00:00
|
|
|
|