1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_extensions.hxx" 30*cdf0e10cSrcweir #include "genericpropertyhandler.hxx" 31*cdf0e10cSrcweir #include "formmetadata.hxx" 32*cdf0e10cSrcweir #include "handlerhelper.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir /** === begin UNO includes === **/ 35*cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/reflection/XEnumTypeDescription.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/beans/XIntrospection.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyControlType.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/inspection/XHyperlinkControl.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/awt/XActionListener.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 43*cdf0e10cSrcweir /** === end UNO includes === **/ 44*cdf0e10cSrcweir #include <tools/debug.hxx> 45*cdf0e10cSrcweir #include <comphelper/extract.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include <algorithm> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir //------------------------------------------------------------------------ 50*cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_GenericPropertyHandler() 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir ::pcr::OAutoRegistration< ::pcr::GenericPropertyHandler > aAutoRegistration; 53*cdf0e10cSrcweir } 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir //........................................................................ 56*cdf0e10cSrcweir namespace pcr 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir //........................................................................ 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 61*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 62*cdf0e10cSrcweir using namespace ::com::sun::star::script; 63*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 64*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 65*cdf0e10cSrcweir using namespace ::com::sun::star::util; 66*cdf0e10cSrcweir using namespace ::com::sun::star::container; 67*cdf0e10cSrcweir using namespace ::com::sun::star::reflection; 68*cdf0e10cSrcweir using namespace ::com::sun::star::inspection; 69*cdf0e10cSrcweir using ::com::sun::star::awt::XActionListener; 70*cdf0e10cSrcweir using ::com::sun::star::awt::ActionEvent; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir //==================================================================== 73*cdf0e10cSrcweir //= EnumRepresentation 74*cdf0e10cSrcweir //==================================================================== 75*cdf0e10cSrcweir class EnumRepresentation : public IPropertyEnumRepresentation 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir private: 78*cdf0e10cSrcweir oslInterlockedCount m_refCount; 79*cdf0e10cSrcweir Reference< XEnumTypeDescription > m_xTypeDescription; 80*cdf0e10cSrcweir Type m_aEnumType; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir public: 83*cdf0e10cSrcweir EnumRepresentation( const Reference< XComponentContext >& _rxContext, const Type& _rEnumType ); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir // IPropertyEnumRepresentation implementqation 86*cdf0e10cSrcweir virtual ::std::vector< ::rtl::OUString > 87*cdf0e10cSrcweir SAL_CALL getDescriptions() const; 88*cdf0e10cSrcweir virtual void SAL_CALL getValueFromDescription( const ::rtl::OUString& _rDescription, ::com::sun::star::uno::Any& _out_rValue ) const; 89*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getDescriptionForValue( const ::com::sun::star::uno::Any& _rEnumValue ) const; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // IReference implementqation 92*cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL acquire(); 93*cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL release(); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir private: 96*cdf0e10cSrcweir void impl_getValues( Sequence< sal_Int32 >& _out_rValues ) const; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir private: 99*cdf0e10cSrcweir EnumRepresentation(); // never implemented 100*cdf0e10cSrcweir EnumRepresentation( const EnumRepresentation& ); // never implemented 101*cdf0e10cSrcweir EnumRepresentation& operator=( const EnumRepresentation& ); // never implemented 102*cdf0e10cSrcweir }; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir //-------------------------------------------------------------------- 105*cdf0e10cSrcweir EnumRepresentation::EnumRepresentation( const Reference< XComponentContext >& _rxContext, const Type& _rEnumType ) 106*cdf0e10cSrcweir :m_refCount( 0 ) 107*cdf0e10cSrcweir ,m_aEnumType( _rEnumType ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir try 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir if ( _rxContext.is() ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xTypeDescProv( 114*cdf0e10cSrcweir _rxContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ) ), 115*cdf0e10cSrcweir UNO_QUERY_THROW ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir m_xTypeDescription = Reference< XEnumTypeDescription >( xTypeDescProv->getByHierarchicalName( m_aEnumType.getTypeName() ), UNO_QUERY_THROW ); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir catch( const Exception& ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir OSL_ENSURE( sal_False, "EnumRepresentation::EnumRepresentation: caught an exception!" ); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir //-------------------------------------------------------------------- 127*cdf0e10cSrcweir ::std::vector< ::rtl::OUString > EnumRepresentation::getDescriptions() const 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames; 130*cdf0e10cSrcweir try 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir if ( m_xTypeDescription.is() ) 133*cdf0e10cSrcweir aNames = m_xTypeDescription->getEnumNames(); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir catch( const Exception& ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir OSL_ENSURE( sal_False, "EnumRepresentation::getDescriptions: caught an exception!" ); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir return ::std::vector< ::rtl::OUString >( aNames.getConstArray(), aNames.getConstArray() + aNames.getLength() ); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir //-------------------------------------------------------------------- 144*cdf0e10cSrcweir void EnumRepresentation::impl_getValues( Sequence< sal_Int32 >& _out_rValues ) const 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir _out_rValues.realloc( 0 ); 147*cdf0e10cSrcweir try 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir if ( m_xTypeDescription.is() ) 150*cdf0e10cSrcweir _out_rValues = m_xTypeDescription->getEnumValues(); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir catch( const Exception& ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir OSL_ENSURE( sal_False, "EnumRepresentation::impl_getValues: caught an exception!" ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir //-------------------------------------------------------------------- 159*cdf0e10cSrcweir void EnumRepresentation::getValueFromDescription( const ::rtl::OUString& _rDescription, Any& _out_rValue ) const 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aDescriptions( getDescriptions() ); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir sal_Int32 index = ::std::find( aDescriptions.begin(), aDescriptions.end(), 164*cdf0e10cSrcweir _rDescription ) - aDescriptions.begin(); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir Sequence< sal_Int32 > aValues; 167*cdf0e10cSrcweir impl_getValues( aValues ); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir if ( ( index >= 0 ) && ( index < aValues.getLength() ) ) 170*cdf0e10cSrcweir _out_rValue = ::cppu::int2enum( aValues[ index ], m_aEnumType ); 171*cdf0e10cSrcweir else 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir DBG_ERROR( "EnumRepresentation::getValueFromDescription: cannot convert!" ); 174*cdf0e10cSrcweir _out_rValue.clear(); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir //-------------------------------------------------------------------- 179*cdf0e10cSrcweir ::rtl::OUString EnumRepresentation::getDescriptionForValue( const Any& _rEnumValue ) const 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir ::rtl::OUString sDescription; 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir sal_Int32 nAsInt = 0; 184*cdf0e10cSrcweir OSL_VERIFY( ::cppu::enum2int( nAsInt, _rEnumValue ) ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir Sequence< sal_Int32 > aValues; 187*cdf0e10cSrcweir impl_getValues( aValues ); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir sal_Int32 index = ::std::find( aValues.getConstArray(), aValues.getConstArray() + aValues.getLength(), 190*cdf0e10cSrcweir nAsInt ) - aValues.getConstArray(); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aDescriptions( getDescriptions() ); 193*cdf0e10cSrcweir if ( ( index >= 0 ) && ( index < (sal_Int32)aDescriptions.size() ) ) 194*cdf0e10cSrcweir sDescription = aDescriptions[ index ]; 195*cdf0e10cSrcweir else 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir DBG_ERROR( "EnumRepresentation::getDescriptionForValue: cannot convert!" ); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir return sDescription; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //-------------------------------------------------------------------- 203*cdf0e10cSrcweir oslInterlockedCount SAL_CALL EnumRepresentation::acquire() 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir return osl_incrementInterlockedCount( &m_refCount ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir //-------------------------------------------------------------------- 209*cdf0e10cSrcweir oslInterlockedCount SAL_CALL EnumRepresentation::release() 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir if ( 0 == osl_decrementInterlockedCount( &m_refCount ) ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir delete this; 214*cdf0e10cSrcweir return 0; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir return m_refCount; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir //==================================================================== 220*cdf0e10cSrcweir //= UrlClickHandler 221*cdf0e10cSrcweir //==================================================================== 222*cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1 < XActionListener 223*cdf0e10cSrcweir > UrlClickHandler_Base; 224*cdf0e10cSrcweir class UrlClickHandler : public UrlClickHandler_Base 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir ComponentContext m_aContext; 227*cdf0e10cSrcweir public: 228*cdf0e10cSrcweir UrlClickHandler( const ComponentContext& _rContext, const Reference< XHyperlinkControl >& _rxControl ); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir protected: 231*cdf0e10cSrcweir ~UrlClickHandler(); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir // XActionListener 234*cdf0e10cSrcweir virtual void SAL_CALL actionPerformed( const ActionEvent& rEvent ) throw (RuntimeException); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir // XEventListener 237*cdf0e10cSrcweir virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir protected: 240*cdf0e10cSrcweir void impl_dispatch_throw( const ::rtl::OUString& _rURL ); 241*cdf0e10cSrcweir }; 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir //-------------------------------------------------------------------- 244*cdf0e10cSrcweir DBG_NAME( UrlClickHandler ) 245*cdf0e10cSrcweir //-------------------------------------------------------------------- 246*cdf0e10cSrcweir UrlClickHandler::UrlClickHandler( const ComponentContext& _rContext, const Reference< XHyperlinkControl >& _rxControl ) 247*cdf0e10cSrcweir :m_aContext( _rContext ) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir if ( !_rxControl.is() ) 250*cdf0e10cSrcweir throw NullPointerException(); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir _rxControl->addActionListener( this ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 257*cdf0e10cSrcweir OSL_ENSURE( m_refCount > 0, "UrlClickHandler::UrlClickHandler: leaking!" ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir DBG_CTOR( UrlClickHandler, NULL ); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir //-------------------------------------------------------------------- 263*cdf0e10cSrcweir UrlClickHandler::~UrlClickHandler() 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir DBG_DTOR( UrlClickHandler, NULL ); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir //-------------------------------------------------------------------- 269*cdf0e10cSrcweir void SAL_CALL UrlClickHandler::actionPerformed( const ActionEvent& rEvent ) throw (RuntimeException) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir Reference< XPropertyControl > xControl( rEvent.Source, UNO_QUERY_THROW ); 272*cdf0e10cSrcweir Any aControlValue( xControl->getValue() ); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir ::rtl::OUString sURL; 275*cdf0e10cSrcweir if ( aControlValue.hasValue() && !( aControlValue >>= sURL ) ) 276*cdf0e10cSrcweir throw RuntimeException( ::rtl::OUString(), *this ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir if ( !sURL.getLength() ) 279*cdf0e10cSrcweir return; 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir impl_dispatch_throw( sURL ); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir //-------------------------------------------------------------------- 285*cdf0e10cSrcweir void SAL_CALL UrlClickHandler::disposing( const EventObject& /*Source*/ ) throw (RuntimeException) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir // not interested in 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir //-------------------------------------------------------------------- 291*cdf0e10cSrcweir void UrlClickHandler::impl_dispatch_throw( const ::rtl::OUString& _rURL ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir Reference< XURLTransformer > xTransformer( m_aContext.createComponent( "com.sun.star.util.URLTransformer" ), UNO_QUERY_THROW ); 294*cdf0e10cSrcweir URL aURL; aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:OpenHyperlink" ) ); 295*cdf0e10cSrcweir xTransformer->parseStrict( aURL ); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir Reference< XDispatchProvider > xDispProv( m_aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); 298*cdf0e10cSrcweir Reference< XDispatch > xDispatch( xDispProv->queryDispatch( aURL, ::rtl::OUString(), 0 ), UNO_QUERY_THROW ); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir Sequence< PropertyValue > aDispatchArgs(1); 301*cdf0e10cSrcweir aDispatchArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL")); 302*cdf0e10cSrcweir aDispatchArgs[0].Value <<= _rURL; 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir xDispatch->dispatch( aURL, aDispatchArgs ); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir //==================================================================== 308*cdf0e10cSrcweir //= GenericPropertyHandler 309*cdf0e10cSrcweir //==================================================================== 310*cdf0e10cSrcweir DBG_NAME( GenericPropertyHandler ) 311*cdf0e10cSrcweir //-------------------------------------------------------------------- 312*cdf0e10cSrcweir GenericPropertyHandler::GenericPropertyHandler( const Reference< XComponentContext >& _rxContext ) 313*cdf0e10cSrcweir :GenericPropertyHandler_Base( m_aMutex ) 314*cdf0e10cSrcweir ,m_aContext( _rxContext ) 315*cdf0e10cSrcweir ,m_aPropertyListeners( m_aMutex ) 316*cdf0e10cSrcweir ,m_bPropertyMapInitialized( false ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir DBG_CTOR( GenericPropertyHandler, NULL ); 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir m_xTypeConverter = Reference< XTypeConverter >( 321*cdf0e10cSrcweir m_aContext.createComponent( "com.sun.star.script.Converter" ), 322*cdf0e10cSrcweir UNO_QUERY_THROW 323*cdf0e10cSrcweir ); 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir //-------------------------------------------------------------------- 327*cdf0e10cSrcweir GenericPropertyHandler::~GenericPropertyHandler() 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir DBG_DTOR( GenericPropertyHandler, NULL ); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir //-------------------------------------------------------------------- 333*cdf0e10cSrcweir ::rtl::OUString SAL_CALL GenericPropertyHandler::getImplementationName( ) throw (RuntimeException) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir return getImplementationName_static(); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir //-------------------------------------------------------------------- 339*cdf0e10cSrcweir ::sal_Bool SAL_CALL GenericPropertyHandler::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir StlSyntaxSequence< ::rtl::OUString > aAllServices( getSupportedServiceNames() ); 342*cdf0e10cSrcweir return ::std::find( aAllServices.begin(), aAllServices.end(), ServiceName ) != aAllServices.end(); 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir //-------------------------------------------------------------------- 346*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupportedServiceNames( ) throw (RuntimeException) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir return getSupportedServiceNames_static(); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir //-------------------------------------------------------------------- 352*cdf0e10cSrcweir ::rtl::OUString SAL_CALL GenericPropertyHandler::getImplementationName_static( ) throw (RuntimeException) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.GenericPropertyHandler" ) ); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir //-------------------------------------------------------------------- 358*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported( 1 ); 361*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.GenericPropertyHandler" ) ); 362*cdf0e10cSrcweir return aSupported; 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir //-------------------------------------------------------------------- 366*cdf0e10cSrcweir Reference< XInterface > SAL_CALL GenericPropertyHandler::Create( const Reference< XComponentContext >& _rxContext ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir return *( new GenericPropertyHandler( _rxContext ) ); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir //-------------------------------------------------------------------- 372*cdf0e10cSrcweir void SAL_CALL GenericPropertyHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir if ( !_rxIntrospectee.is() ) 377*cdf0e10cSrcweir throw NullPointerException(); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir // revoke old property change listeners 380*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper iterRemove( m_aPropertyListeners ); 381*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper iterReAdd( m_aPropertyListeners ); // this holds a copy of the container ... 382*cdf0e10cSrcweir while ( iterRemove.hasMoreElements() ) 383*cdf0e10cSrcweir m_xComponent->removePropertyChangeListener( ::rtl::OUString(), static_cast< XPropertyChangeListener* >( iterRemove.next() ) ); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir m_xComponentIntrospectionAccess.clear(); 386*cdf0e10cSrcweir m_xComponent.clear(); 387*cdf0e10cSrcweir m_xPropertyState.clear(); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir // create an introspection adapter for the component 390*cdf0e10cSrcweir Reference< XIntrospection > xIntrospection; 391*cdf0e10cSrcweir if ( !m_aContext.createComponent( "com.sun.star.beans.Introspection", xIntrospection ) ) 392*cdf0e10cSrcweir throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not create an instance of the service com.sun.star.beans.Introspection." ) ), *this ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir Reference< XIntrospectionAccess > xIntrospectionAccess( xIntrospection->inspect( makeAny( _rxIntrospectee ) ) ); 395*cdf0e10cSrcweir if ( !xIntrospectionAccess.is() ) 396*cdf0e10cSrcweir throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The introspection service could not handle the given component." ) ), *this ); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir m_xComponent = Reference< XPropertySet >( xIntrospectionAccess->queryAdapter( XPropertySet::static_type() ), UNO_QUERY_THROW ); 399*cdf0e10cSrcweir // now that we survived so far, remember m_xComponentIntrospectionAccess 400*cdf0e10cSrcweir m_xComponentIntrospectionAccess = xIntrospectionAccess; 401*cdf0e10cSrcweir m_xPropertyState = m_xPropertyState.query( m_xComponent ); 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir m_bPropertyMapInitialized = false; 404*cdf0e10cSrcweir m_aProperties.clear(); 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir // re-add the property change listeners 407*cdf0e10cSrcweir while ( iterReAdd.hasMoreElements() ) 408*cdf0e10cSrcweir m_xComponent->addPropertyChangeListener( ::rtl::OUString(), static_cast< XPropertyChangeListener* >( iterReAdd.next() ) ); 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir //-------------------------------------------------------------------- 412*cdf0e10cSrcweir Any SAL_CALL GenericPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 415*cdf0e10cSrcweir if ( !m_xComponent.is() ) 416*cdf0e10cSrcweir throw UnknownPropertyException(); 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir return m_xComponent->getPropertyValue( _rPropertyName ); 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir //-------------------------------------------------------------------- 422*cdf0e10cSrcweir void SAL_CALL GenericPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 425*cdf0e10cSrcweir if ( !m_xComponent.is() ) 426*cdf0e10cSrcweir throw UnknownPropertyException(); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir m_xComponent->setPropertyValue( _rPropertyName, _rValue ); 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir //-------------------------------------------------------------------- 432*cdf0e10cSrcweir ::rtl::Reference< IPropertyEnumRepresentation > GenericPropertyHandler::impl_getEnumConverter( const Type& _rEnumType ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir ::rtl::Reference< IPropertyEnumRepresentation >& rConverter = m_aEnumConverters[ _rEnumType ]; 435*cdf0e10cSrcweir if ( !rConverter.is() ) 436*cdf0e10cSrcweir rConverter = new EnumRepresentation( m_aContext.getUNOContext(), _rEnumType ); 437*cdf0e10cSrcweir return rConverter; 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir //-------------------------------------------------------------------- 441*cdf0e10cSrcweir Any SAL_CALL GenericPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 444*cdf0e10cSrcweir const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap(); 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName ); 447*cdf0e10cSrcweir if ( pos == m_aProperties.end() ) 448*cdf0e10cSrcweir throw UnknownPropertyException(); 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir Any aPropertyValue; 451*cdf0e10cSrcweir if ( !_rControlValue.hasValue() ) 452*cdf0e10cSrcweir // NULL is converted to NULL 453*cdf0e10cSrcweir return aPropertyValue; 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir if ( pos->second.Type.getTypeClass() == TypeClass_ENUM ) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir ::rtl::OUString sControlValue; 458*cdf0e10cSrcweir OSL_VERIFY( _rControlValue >>= sControlValue ); 459*cdf0e10cSrcweir impl_getEnumConverter( pos->second.Type )->getValueFromDescription( sControlValue, aPropertyValue ); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir else 462*cdf0e10cSrcweir aPropertyValue = PropertyHandlerHelper::convertToPropertyValue( m_aContext.getContext(),m_xTypeConverter, pos->second, _rControlValue ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir return aPropertyValue; 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir //-------------------------------------------------------------------- 468*cdf0e10cSrcweir Any SAL_CALL GenericPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 471*cdf0e10cSrcweir const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap(); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName ); 474*cdf0e10cSrcweir if ( pos == m_aProperties.end() ) 475*cdf0e10cSrcweir throw UnknownPropertyException(); 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir Any aControlValue; 478*cdf0e10cSrcweir if ( !_rPropertyValue.hasValue() ) 479*cdf0e10cSrcweir // NULL is converted to NULL 480*cdf0e10cSrcweir return aControlValue; 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir if ( pos->second.Type.getTypeClass() == TypeClass_ENUM ) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir aControlValue <<= impl_getEnumConverter( pos->second.Type )->getDescriptionForValue( _rPropertyValue ); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir else 487*cdf0e10cSrcweir aControlValue = PropertyHandlerHelper::convertToControlValue( m_aContext.getContext(),m_xTypeConverter, _rPropertyValue, _rControlValueType ); 488*cdf0e10cSrcweir return aControlValue; 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir //-------------------------------------------------------------------- 492*cdf0e10cSrcweir PropertyState SAL_CALL GenericPropertyHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 495*cdf0e10cSrcweir PropertyState eState = PropertyState_DIRECT_VALUE; 496*cdf0e10cSrcweir if ( m_xPropertyState.is() ) 497*cdf0e10cSrcweir eState = m_xPropertyState->getPropertyState( _rPropertyName ); 498*cdf0e10cSrcweir return eState; 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir //-------------------------------------------------------------------- 502*cdf0e10cSrcweir void SAL_CALL GenericPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir if ( !_rxListener.is() ) 505*cdf0e10cSrcweir throw NullPointerException(); 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 508*cdf0e10cSrcweir m_aPropertyListeners.addInterface( _rxListener ); 509*cdf0e10cSrcweir if ( m_xComponent.is() ) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir try 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir m_xComponent->addPropertyChangeListener( ::rtl::OUString(), _rxListener ); 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir catch( const UnknownPropertyException& ) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir OSL_ENSURE( false, "GenericPropertyHandler::addPropertyChangeListener:\nThe inspected component does not allow registering for all properties at once! This violates the interface contract!" ); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir //-------------------------------------------------------------------- 523*cdf0e10cSrcweir void SAL_CALL GenericPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 526*cdf0e10cSrcweir if ( m_xComponent.is() ) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir try 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir m_xComponent->removePropertyChangeListener( ::rtl::OUString(), _rxListener ); 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir catch( const UnknownPropertyException& ) 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir OSL_ENSURE( false, "GenericPropertyHandler::removePropertyChangeListener:\nThe inspected component does not allow de-registering for all properties at once! This violates the interface contract!" ); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir m_aPropertyListeners.removeInterface( _rxListener ); 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir //-------------------------------------------------------------------- 541*cdf0e10cSrcweir void GenericPropertyHandler::impl_ensurePropertyMap() 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir if ( !m_bPropertyMapInitialized ) 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir m_bPropertyMapInitialized = true; 546*cdf0e10cSrcweir try 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir Reference< XPropertySetInfo > xPSI; 549*cdf0e10cSrcweir if ( m_xComponent.is() ) 550*cdf0e10cSrcweir xPSI = m_xComponent->getPropertySetInfo(); 551*cdf0e10cSrcweir Sequence< Property > aProperties; 552*cdf0e10cSrcweir if ( xPSI.is() ) 553*cdf0e10cSrcweir aProperties = xPSI->getProperties(); 554*cdf0e10cSrcweir DBG_ASSERT( aProperties.getLength(), "GenericPropertyHandler::getSupportedProperties: no properties!" ); 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir for ( const Property* pProperties = aProperties.getConstArray(); 557*cdf0e10cSrcweir pProperties != aProperties.getConstArray() + aProperties.getLength(); 558*cdf0e10cSrcweir ++pProperties 559*cdf0e10cSrcweir ) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir switch ( pProperties->Type.getTypeClass() ) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir case TypeClass_BOOLEAN: 564*cdf0e10cSrcweir case TypeClass_BYTE: 565*cdf0e10cSrcweir case TypeClass_SHORT: 566*cdf0e10cSrcweir case TypeClass_UNSIGNED_SHORT: 567*cdf0e10cSrcweir case TypeClass_LONG: 568*cdf0e10cSrcweir case TypeClass_UNSIGNED_LONG: 569*cdf0e10cSrcweir case TypeClass_HYPER: 570*cdf0e10cSrcweir case TypeClass_UNSIGNED_HYPER: 571*cdf0e10cSrcweir case TypeClass_FLOAT: 572*cdf0e10cSrcweir case TypeClass_DOUBLE: 573*cdf0e10cSrcweir case TypeClass_ENUM: 574*cdf0e10cSrcweir case TypeClass_STRING: 575*cdf0e10cSrcweir // allowed, we can handle this type 576*cdf0e10cSrcweir break; 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir case TypeClass_SEQUENCE: 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir TypeClass eElementTypeClass = ::comphelper::getSequenceElementType( pProperties->Type ).getTypeClass(); 581*cdf0e10cSrcweir if ( ( eElementTypeClass != TypeClass_STRING ) 582*cdf0e10cSrcweir && ( eElementTypeClass != TypeClass_BYTE ) 583*cdf0e10cSrcweir && ( eElementTypeClass != TypeClass_SHORT ) 584*cdf0e10cSrcweir && ( eElementTypeClass != TypeClass_UNSIGNED_SHORT ) 585*cdf0e10cSrcweir && ( eElementTypeClass != TypeClass_LONG ) 586*cdf0e10cSrcweir && ( eElementTypeClass != TypeClass_UNSIGNED_LONG ) 587*cdf0e10cSrcweir ) 588*cdf0e10cSrcweir // can only handle the above 589*cdf0e10cSrcweir continue; 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir break; 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir default: 594*cdf0e10cSrcweir // next property, we don't support this type 595*cdf0e10cSrcweir continue; 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir m_aProperties.insert( PropertyMap::value_type( pProperties->Name, *pProperties ) ); 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir } 601*cdf0e10cSrcweir catch( const Exception& ) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir OSL_ENSURE( sal_False, "GenericPropertyHandler::impl_ensurePropertyMap: caught an exception!" ); 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir //-------------------------------------------------------------------- 609*cdf0e10cSrcweir Sequence< Property > SAL_CALL GenericPropertyHandler::getSupportedProperties() throw (RuntimeException) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 612*cdf0e10cSrcweir const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap(); 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir Sequence< Property > aReturn( m_aProperties.size() ); 615*cdf0e10cSrcweir ::std::transform( m_aProperties.begin(), m_aProperties.end(), 616*cdf0e10cSrcweir aReturn.getArray(), ::std::select2nd< PropertyMap::value_type >() ); 617*cdf0e10cSrcweir return aReturn; 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir //-------------------------------------------------------------------- 621*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupersededProperties( ) throw (RuntimeException) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir // no superseded properties at all. This handler offers the very basic PropertyHandler 624*cdf0e10cSrcweir // functionality, so it's much more likely that other handlers want to supersede 625*cdf0e10cSrcweir // *our* properties .... 626*cdf0e10cSrcweir return Sequence< ::rtl::OUString >( ); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir //-------------------------------------------------------------------- 630*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getActuatingProperties( ) throw (RuntimeException) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir // This basic PropertyHandler implementation is too dumb^Wgeneric to know 633*cdf0e10cSrcweir // anything about property dependencies 634*cdf0e10cSrcweir return Sequence< ::rtl::OUString >( ); 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir //-------------------------------------------------------------------- 638*cdf0e10cSrcweir LineDescriptor SAL_CALL GenericPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName, 639*cdf0e10cSrcweir const Reference< XPropertyControlFactory >& _rxControlFactory ) 640*cdf0e10cSrcweir throw (UnknownPropertyException, NullPointerException, RuntimeException) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir if ( !_rxControlFactory.is() ) 643*cdf0e10cSrcweir throw NullPointerException(); 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 646*cdf0e10cSrcweir const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap(); 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName ); 649*cdf0e10cSrcweir if ( pos == m_aProperties.end() ) 650*cdf0e10cSrcweir throw UnknownPropertyException(); 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir LineDescriptor aDescriptor; 653*cdf0e10cSrcweir aDescriptor.DisplayName = _rPropertyName; 654*cdf0e10cSrcweir switch ( pos->second.Type.getTypeClass() ) 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir case TypeClass_ENUM: 657*cdf0e10cSrcweir aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, 658*cdf0e10cSrcweir impl_getEnumConverter( pos->second.Type )->getDescriptions(), 659*cdf0e10cSrcweir PropertyHandlerHelper::requiresReadOnlyControl( pos->second.Attributes ), 660*cdf0e10cSrcweir sal_False ); 661*cdf0e10cSrcweir break; 662*cdf0e10cSrcweir case TypeClass_STRING: 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir // some special handling for URL properties 665*cdf0e10cSrcweir bool bIsURLProperty = ( _rPropertyName.getLength() >= 3 ) && _rPropertyName.matchAsciiL( "URL", 3, _rPropertyName.getLength() - 3 ); 666*cdf0e10cSrcweir if ( bIsURLProperty ) 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir aDescriptor.Control = _rxControlFactory->createPropertyControl( 669*cdf0e10cSrcweir PropertyControlType::HyperlinkField, PropertyHandlerHelper::requiresReadOnlyControl( pos->second.Attributes ) ); 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir Reference< XHyperlinkControl > xControl( aDescriptor.Control, UNO_QUERY_THROW ); 672*cdf0e10cSrcweir Reference< XActionListener > xEnsureDelete( new UrlClickHandler( m_aContext, xControl ) ); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir break; 676*cdf0e10cSrcweir default: 677*cdf0e10cSrcweir break; 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir // fallback 680*cdf0e10cSrcweir if ( !aDescriptor.Control.is() ) 681*cdf0e10cSrcweir PropertyHandlerHelper::describePropertyLine( pos->second, aDescriptor, _rxControlFactory ); 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) ); 684*cdf0e10cSrcweir return aDescriptor; 685*cdf0e10cSrcweir } 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir //-------------------------------------------------------------------- 688*cdf0e10cSrcweir ::sal_Bool SAL_CALL GenericPropertyHandler::isComposable( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException) 689*cdf0e10cSrcweir { 690*cdf0e10cSrcweir return sal_False; 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir //-------------------------------------------------------------------- 694*cdf0e10cSrcweir InteractiveSelectionResult SAL_CALL GenericPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& /*_rPropertyName*/, sal_Bool /*_bPrimary*/, Any& /*_rData*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/ ) throw (UnknownPropertyException, NullPointerException, RuntimeException) 695*cdf0e10cSrcweir { 696*cdf0e10cSrcweir DBG_ERROR( "GenericPropertyHandler::onInteractivePropertySelection: I'm too dumb to know anything about property browse buttons!" ); 697*cdf0e10cSrcweir return InteractiveSelectionResult_Cancelled; 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir //-------------------------------------------------------------------- 701*cdf0e10cSrcweir void SAL_CALL GenericPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& /*_rActuatingPropertyName*/, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException) 702*cdf0e10cSrcweir { 703*cdf0e10cSrcweir DBG_ERROR( "GenericPropertyHandler::actuatingPropertyChanged: no no no, I did not register for any actuating properties!" ); 704*cdf0e10cSrcweir } 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir //-------------------------------------------------------------------- 707*cdf0e10cSrcweir sal_Bool SAL_CALL GenericPropertyHandler::suspend( sal_Bool /*_bSuspend*/ ) throw (RuntimeException) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir return sal_True; 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir //-------------------------------------------------------------------- 713*cdf0e10cSrcweir void SAL_CALL GenericPropertyHandler::disposing() 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir m_aPropertyListeners.clear(); 716*cdf0e10cSrcweir // not disposeAndClear: the listeners are (virtually) listeners at our introspectee, not 717*cdf0e10cSrcweir // at this handler instance 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir //-------------------------------------------------------------------- 721*cdf0e10cSrcweir IMPLEMENT_FORWARD_XCOMPONENT( GenericPropertyHandler, GenericPropertyHandler_Base ); 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir //........................................................................ 724*cdf0e10cSrcweir } // namespace pcr 725*cdf0e10cSrcweir //........................................................................ 726*cdf0e10cSrcweir 727