1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "genericpropertyhandler.hxx"
31 #include "formmetadata.hxx"
32 #include "handlerhelper.hxx"
34 /** === begin UNO includes === **/
35 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
36 #include <com/sun/star/reflection/XEnumTypeDescription.hpp>
37 #include <com/sun/star/beans/XIntrospection.hpp>
38 #include <com/sun/star/inspection/PropertyControlType.hpp>
39 #include <com/sun/star/inspection/XHyperlinkControl.hpp>
40 #include <com/sun/star/awt/XActionListener.hpp>
41 #include <com/sun/star/util/XURLTransformer.hpp>
42 #include <com/sun/star/frame/XDispatchProvider.hpp>
43 /** === end UNO includes === **/
44 #include <tools/debug.hxx>
45 #include <comphelper/extract.hxx>
49 //------------------------------------------------------------------------
50 extern "C" void SAL_CALL
createRegistryInfo_GenericPropertyHandler()
52 ::pcr::OAutoRegistration
< ::pcr::GenericPropertyHandler
> aAutoRegistration
;
55 //........................................................................
58 //........................................................................
60 using namespace ::com::sun::star::uno
;
61 using namespace ::com::sun::star::beans
;
62 using namespace ::com::sun::star::script
;
63 using namespace ::com::sun::star::frame
;
64 using namespace ::com::sun::star::lang
;
65 using namespace ::com::sun::star::util
;
66 using namespace ::com::sun::star::container
;
67 using namespace ::com::sun::star::reflection
;
68 using namespace ::com::sun::star::inspection
;
69 using ::com::sun::star::awt::XActionListener
;
70 using ::com::sun::star::awt::ActionEvent
;
72 //====================================================================
73 //= EnumRepresentation
74 //====================================================================
75 class EnumRepresentation
: public IPropertyEnumRepresentation
78 oslInterlockedCount m_refCount
;
79 Reference
< XEnumTypeDescription
> m_xTypeDescription
;
83 EnumRepresentation( const Reference
< XComponentContext
>& _rxContext
, const Type
& _rEnumType
);
85 // IPropertyEnumRepresentation implementqation
86 virtual ::std::vector
< ::rtl::OUString
>
87 SAL_CALL
getDescriptions() const;
88 virtual void SAL_CALL
getValueFromDescription( const ::rtl::OUString
& _rDescription
, ::com::sun::star::uno::Any
& _out_rValue
) const;
89 virtual ::rtl::OUString SAL_CALL
getDescriptionForValue( const ::com::sun::star::uno::Any
& _rEnumValue
) const;
91 // IReference implementqation
92 virtual oslInterlockedCount SAL_CALL
acquire();
93 virtual oslInterlockedCount SAL_CALL
release();
96 void impl_getValues( Sequence
< sal_Int32
>& _out_rValues
) const;
99 EnumRepresentation(); // never implemented
100 EnumRepresentation( const EnumRepresentation
& ); // never implemented
101 EnumRepresentation
& operator=( const EnumRepresentation
& ); // never implemented
104 //--------------------------------------------------------------------
105 EnumRepresentation::EnumRepresentation( const Reference
< XComponentContext
>& _rxContext
, const Type
& _rEnumType
)
107 ,m_aEnumType( _rEnumType
)
111 if ( _rxContext
.is() )
113 Reference
< XHierarchicalNameAccess
> xTypeDescProv(
114 _rxContext
->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ) ),
117 m_xTypeDescription
= Reference
< XEnumTypeDescription
>( xTypeDescProv
->getByHierarchicalName( m_aEnumType
.getTypeName() ), UNO_QUERY_THROW
);
120 catch( const Exception
& )
122 OSL_ENSURE( sal_False
, "EnumRepresentation::EnumRepresentation: caught an exception!" );
126 //--------------------------------------------------------------------
127 ::std::vector
< ::rtl::OUString
> EnumRepresentation::getDescriptions() const
129 Sequence
< ::rtl::OUString
> aNames
;
132 if ( m_xTypeDescription
.is() )
133 aNames
= m_xTypeDescription
->getEnumNames();
135 catch( const Exception
& )
137 OSL_ENSURE( sal_False
, "EnumRepresentation::getDescriptions: caught an exception!" );
140 return ::std::vector
< ::rtl::OUString
>( aNames
.getConstArray(), aNames
.getConstArray() + aNames
.getLength() );
143 //--------------------------------------------------------------------
144 void EnumRepresentation::impl_getValues( Sequence
< sal_Int32
>& _out_rValues
) const
146 _out_rValues
.realloc( 0 );
149 if ( m_xTypeDescription
.is() )
150 _out_rValues
= m_xTypeDescription
->getEnumValues();
152 catch( const Exception
& )
154 OSL_ENSURE( sal_False
, "EnumRepresentation::impl_getValues: caught an exception!" );
158 //--------------------------------------------------------------------
159 void EnumRepresentation::getValueFromDescription( const ::rtl::OUString
& _rDescription
, Any
& _out_rValue
) const
161 ::std::vector
< ::rtl::OUString
> aDescriptions( getDescriptions() );
163 sal_Int32 index
= ::std::find( aDescriptions
.begin(), aDescriptions
.end(),
164 _rDescription
) - aDescriptions
.begin();
166 Sequence
< sal_Int32
> aValues
;
167 impl_getValues( aValues
);
169 if ( ( index
>= 0 ) && ( index
< aValues
.getLength() ) )
170 _out_rValue
= ::cppu::int2enum( aValues
[ index
], m_aEnumType
);
173 DBG_ERROR( "EnumRepresentation::getValueFromDescription: cannot convert!" );
178 //--------------------------------------------------------------------
179 ::rtl::OUString
EnumRepresentation::getDescriptionForValue( const Any
& _rEnumValue
) const
181 ::rtl::OUString sDescription
;
183 sal_Int32 nAsInt
= 0;
184 OSL_VERIFY( ::cppu::enum2int( nAsInt
, _rEnumValue
) );
186 Sequence
< sal_Int32
> aValues
;
187 impl_getValues( aValues
);
189 sal_Int32 index
= ::std::find( aValues
.getConstArray(), aValues
.getConstArray() + aValues
.getLength(),
190 nAsInt
) - aValues
.getConstArray();
192 ::std::vector
< ::rtl::OUString
> aDescriptions( getDescriptions() );
193 if ( ( index
>= 0 ) && ( index
< (sal_Int32
)aDescriptions
.size() ) )
194 sDescription
= aDescriptions
[ index
];
197 DBG_ERROR( "EnumRepresentation::getDescriptionForValue: cannot convert!" );
202 //--------------------------------------------------------------------
203 oslInterlockedCount SAL_CALL
EnumRepresentation::acquire()
205 return osl_incrementInterlockedCount( &m_refCount
);
208 //--------------------------------------------------------------------
209 oslInterlockedCount SAL_CALL
EnumRepresentation::release()
211 if ( 0 == osl_decrementInterlockedCount( &m_refCount
) )
219 //====================================================================
221 //====================================================================
222 typedef ::cppu::WeakImplHelper1
< XActionListener
223 > UrlClickHandler_Base
;
224 class UrlClickHandler
: public UrlClickHandler_Base
226 ComponentContext m_aContext
;
228 UrlClickHandler( const ComponentContext
& _rContext
, const Reference
< XHyperlinkControl
>& _rxControl
);
234 virtual void SAL_CALL
actionPerformed( const ActionEvent
& rEvent
) throw (RuntimeException
);
237 virtual void SAL_CALL
disposing( const EventObject
& Source
) throw (RuntimeException
);
240 void impl_dispatch_throw( const ::rtl::OUString
& _rURL
);
243 //--------------------------------------------------------------------
244 DBG_NAME( UrlClickHandler
)
245 //--------------------------------------------------------------------
246 UrlClickHandler::UrlClickHandler( const ComponentContext
& _rContext
, const Reference
< XHyperlinkControl
>& _rxControl
)
247 :m_aContext( _rContext
)
249 if ( !_rxControl
.is() )
250 throw NullPointerException();
252 osl_incrementInterlockedCount( &m_refCount
);
254 _rxControl
->addActionListener( this );
256 osl_decrementInterlockedCount( &m_refCount
);
257 OSL_ENSURE( m_refCount
> 0, "UrlClickHandler::UrlClickHandler: leaking!" );
259 DBG_CTOR( UrlClickHandler
, NULL
);
262 //--------------------------------------------------------------------
263 UrlClickHandler::~UrlClickHandler()
265 DBG_DTOR( UrlClickHandler
, NULL
);
268 //--------------------------------------------------------------------
269 void SAL_CALL
UrlClickHandler::actionPerformed( const ActionEvent
& rEvent
) throw (RuntimeException
)
271 Reference
< XPropertyControl
> xControl( rEvent
.Source
, UNO_QUERY_THROW
);
272 Any
aControlValue( xControl
->getValue() );
274 ::rtl::OUString sURL
;
275 if ( aControlValue
.hasValue() && !( aControlValue
>>= sURL
) )
276 throw RuntimeException( ::rtl::OUString(), *this );
278 if ( !sURL
.getLength() )
281 impl_dispatch_throw( sURL
);
284 //--------------------------------------------------------------------
285 void SAL_CALL
UrlClickHandler::disposing( const EventObject
& /*Source*/ ) throw (RuntimeException
)
290 //--------------------------------------------------------------------
291 void UrlClickHandler::impl_dispatch_throw( const ::rtl::OUString
& _rURL
)
293 Reference
< XURLTransformer
> xTransformer( m_aContext
.createComponent( "com.sun.star.util.URLTransformer" ), UNO_QUERY_THROW
);
294 URL aURL
; aURL
.Complete
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:OpenHyperlink" ) );
295 xTransformer
->parseStrict( aURL
);
297 Reference
< XDispatchProvider
> xDispProv( m_aContext
.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW
);
298 Reference
< XDispatch
> xDispatch( xDispProv
->queryDispatch( aURL
, ::rtl::OUString(), 0 ), UNO_QUERY_THROW
);
300 Sequence
< PropertyValue
> aDispatchArgs(1);
301 aDispatchArgs
[0].Name
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
302 aDispatchArgs
[0].Value
<<= _rURL
;
304 xDispatch
->dispatch( aURL
, aDispatchArgs
);
307 //====================================================================
308 //= GenericPropertyHandler
309 //====================================================================
310 DBG_NAME( GenericPropertyHandler
)
311 //--------------------------------------------------------------------
312 GenericPropertyHandler::GenericPropertyHandler( const Reference
< XComponentContext
>& _rxContext
)
313 :GenericPropertyHandler_Base( m_aMutex
)
314 ,m_aContext( _rxContext
)
315 ,m_aPropertyListeners( m_aMutex
)
316 ,m_bPropertyMapInitialized( false )
318 DBG_CTOR( GenericPropertyHandler
, NULL
);
320 m_xTypeConverter
= Reference
< XTypeConverter
>(
321 m_aContext
.createComponent( "com.sun.star.script.Converter" ),
326 //--------------------------------------------------------------------
327 GenericPropertyHandler::~GenericPropertyHandler()
329 DBG_DTOR( GenericPropertyHandler
, NULL
);
332 //--------------------------------------------------------------------
333 ::rtl::OUString SAL_CALL
GenericPropertyHandler::getImplementationName( ) throw (RuntimeException
)
335 return getImplementationName_static();
338 //--------------------------------------------------------------------
339 ::sal_Bool SAL_CALL
GenericPropertyHandler::supportsService( const ::rtl::OUString
& ServiceName
) throw (RuntimeException
)
341 StlSyntaxSequence
< ::rtl::OUString
> aAllServices( getSupportedServiceNames() );
342 return ::std::find( aAllServices
.begin(), aAllServices
.end(), ServiceName
) != aAllServices
.end();
345 //--------------------------------------------------------------------
346 Sequence
< ::rtl::OUString
> SAL_CALL
GenericPropertyHandler::getSupportedServiceNames( ) throw (RuntimeException
)
348 return getSupportedServiceNames_static();
351 //--------------------------------------------------------------------
352 ::rtl::OUString SAL_CALL
GenericPropertyHandler::getImplementationName_static( ) throw (RuntimeException
)
354 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.GenericPropertyHandler" ) );
357 //--------------------------------------------------------------------
358 Sequence
< ::rtl::OUString
> SAL_CALL
GenericPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException
)
360 Sequence
< ::rtl::OUString
> aSupported( 1 );
361 aSupported
[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.GenericPropertyHandler" ) );
365 //--------------------------------------------------------------------
366 Reference
< XInterface
> SAL_CALL
GenericPropertyHandler::Create( const Reference
< XComponentContext
>& _rxContext
)
368 return *( new GenericPropertyHandler( _rxContext
) );
371 //--------------------------------------------------------------------
372 void SAL_CALL
GenericPropertyHandler::inspect( const Reference
< XInterface
>& _rxIntrospectee
) throw (RuntimeException
, NullPointerException
)
374 ::osl::MutexGuard
aGuard( m_aMutex
);
376 if ( !_rxIntrospectee
.is() )
377 throw NullPointerException();
379 // revoke old property change listeners
380 ::cppu::OInterfaceIteratorHelper
iterRemove( m_aPropertyListeners
);
381 ::cppu::OInterfaceIteratorHelper
iterReAdd( m_aPropertyListeners
); // this holds a copy of the container ...
382 while ( iterRemove
.hasMoreElements() )
383 m_xComponent
->removePropertyChangeListener( ::rtl::OUString(), static_cast< XPropertyChangeListener
* >( iterRemove
.next() ) );
385 m_xComponentIntrospectionAccess
.clear();
386 m_xComponent
.clear();
387 m_xPropertyState
.clear();
389 // create an introspection adapter for the component
390 Reference
< XIntrospection
> xIntrospection
;
391 if ( !m_aContext
.createComponent( "com.sun.star.beans.Introspection", xIntrospection
) )
392 throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not create an instance of the service com.sun.star.beans.Introspection." ) ), *this );
394 Reference
< XIntrospectionAccess
> xIntrospectionAccess( xIntrospection
->inspect( makeAny( _rxIntrospectee
) ) );
395 if ( !xIntrospectionAccess
.is() )
396 throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The introspection service could not handle the given component." ) ), *this );
398 m_xComponent
= Reference
< XPropertySet
>( xIntrospectionAccess
->queryAdapter( XPropertySet::static_type() ), UNO_QUERY_THROW
);
399 // now that we survived so far, remember m_xComponentIntrospectionAccess
400 m_xComponentIntrospectionAccess
= xIntrospectionAccess
;
401 m_xPropertyState
= m_xPropertyState
.query( m_xComponent
);
403 m_bPropertyMapInitialized
= false;
404 m_aProperties
.clear();
406 // re-add the property change listeners
407 while ( iterReAdd
.hasMoreElements() )
408 m_xComponent
->addPropertyChangeListener( ::rtl::OUString(), static_cast< XPropertyChangeListener
* >( iterReAdd
.next() ) );
411 //--------------------------------------------------------------------
412 Any SAL_CALL
GenericPropertyHandler::getPropertyValue( const ::rtl::OUString
& _rPropertyName
) throw (UnknownPropertyException
, RuntimeException
)
414 ::osl::MutexGuard
aGuard( m_aMutex
);
415 if ( !m_xComponent
.is() )
416 throw UnknownPropertyException();
418 return m_xComponent
->getPropertyValue( _rPropertyName
);
421 //--------------------------------------------------------------------
422 void SAL_CALL
GenericPropertyHandler::setPropertyValue( const ::rtl::OUString
& _rPropertyName
, const Any
& _rValue
) throw (UnknownPropertyException
, RuntimeException
)
424 ::osl::MutexGuard
aGuard( m_aMutex
);
425 if ( !m_xComponent
.is() )
426 throw UnknownPropertyException();
428 m_xComponent
->setPropertyValue( _rPropertyName
, _rValue
);
431 //--------------------------------------------------------------------
432 ::rtl::Reference
< IPropertyEnumRepresentation
> GenericPropertyHandler::impl_getEnumConverter( const Type
& _rEnumType
)
434 ::rtl::Reference
< IPropertyEnumRepresentation
>& rConverter
= m_aEnumConverters
[ _rEnumType
];
435 if ( !rConverter
.is() )
436 rConverter
= new EnumRepresentation( m_aContext
.getUNOContext(), _rEnumType
);
440 //--------------------------------------------------------------------
441 Any SAL_CALL
GenericPropertyHandler::convertToPropertyValue( const ::rtl::OUString
& _rPropertyName
, const Any
& _rControlValue
) throw (UnknownPropertyException
, RuntimeException
)
443 ::osl::MutexGuard
aGuard( m_aMutex
);
444 const_cast< GenericPropertyHandler
* >( this )->impl_ensurePropertyMap();
446 PropertyMap::const_iterator pos
= m_aProperties
.find( _rPropertyName
);
447 if ( pos
== m_aProperties
.end() )
448 throw UnknownPropertyException();
451 if ( !_rControlValue
.hasValue() )
452 // NULL is converted to NULL
453 return aPropertyValue
;
455 if ( pos
->second
.Type
.getTypeClass() == TypeClass_ENUM
)
457 ::rtl::OUString sControlValue
;
458 OSL_VERIFY( _rControlValue
>>= sControlValue
);
459 impl_getEnumConverter( pos
->second
.Type
)->getValueFromDescription( sControlValue
, aPropertyValue
);
462 aPropertyValue
= PropertyHandlerHelper::convertToPropertyValue( m_aContext
.getContext(),m_xTypeConverter
, pos
->second
, _rControlValue
);
464 return aPropertyValue
;
467 //--------------------------------------------------------------------
468 Any SAL_CALL
GenericPropertyHandler::convertToControlValue( const ::rtl::OUString
& _rPropertyName
, const Any
& _rPropertyValue
, const Type
& _rControlValueType
) throw (UnknownPropertyException
, RuntimeException
)
470 ::osl::MutexGuard
aGuard( m_aMutex
);
471 const_cast< GenericPropertyHandler
* >( this )->impl_ensurePropertyMap();
473 PropertyMap::const_iterator pos
= m_aProperties
.find( _rPropertyName
);
474 if ( pos
== m_aProperties
.end() )
475 throw UnknownPropertyException();
478 if ( !_rPropertyValue
.hasValue() )
479 // NULL is converted to NULL
480 return aControlValue
;
482 if ( pos
->second
.Type
.getTypeClass() == TypeClass_ENUM
)
484 aControlValue
<<= impl_getEnumConverter( pos
->second
.Type
)->getDescriptionForValue( _rPropertyValue
);
487 aControlValue
= PropertyHandlerHelper::convertToControlValue( m_aContext
.getContext(),m_xTypeConverter
, _rPropertyValue
, _rControlValueType
);
488 return aControlValue
;
491 //--------------------------------------------------------------------
492 PropertyState SAL_CALL
GenericPropertyHandler::getPropertyState( const ::rtl::OUString
& _rPropertyName
) throw (UnknownPropertyException
, RuntimeException
)
494 ::osl::MutexGuard
aGuard( m_aMutex
);
495 PropertyState eState
= PropertyState_DIRECT_VALUE
;
496 if ( m_xPropertyState
.is() )
497 eState
= m_xPropertyState
->getPropertyState( _rPropertyName
);
501 //--------------------------------------------------------------------
502 void SAL_CALL
GenericPropertyHandler::addPropertyChangeListener( const Reference
< XPropertyChangeListener
>& _rxListener
) throw (RuntimeException
)
504 if ( !_rxListener
.is() )
505 throw NullPointerException();
507 ::osl::MutexGuard
aGuard( m_aMutex
);
508 m_aPropertyListeners
.addInterface( _rxListener
);
509 if ( m_xComponent
.is() )
513 m_xComponent
->addPropertyChangeListener( ::rtl::OUString(), _rxListener
);
515 catch( const UnknownPropertyException
& )
517 OSL_ENSURE( false, "GenericPropertyHandler::addPropertyChangeListener:\nThe inspected component does not allow registering for all properties at once! This violates the interface contract!" );
522 //--------------------------------------------------------------------
523 void SAL_CALL
GenericPropertyHandler::removePropertyChangeListener( const Reference
< XPropertyChangeListener
>& _rxListener
) throw (RuntimeException
)
525 ::osl::MutexGuard
aGuard( m_aMutex
);
526 if ( m_xComponent
.is() )
530 m_xComponent
->removePropertyChangeListener( ::rtl::OUString(), _rxListener
);
532 catch( const UnknownPropertyException
& )
534 OSL_ENSURE( false, "GenericPropertyHandler::removePropertyChangeListener:\nThe inspected component does not allow de-registering for all properties at once! This violates the interface contract!" );
537 m_aPropertyListeners
.removeInterface( _rxListener
);
540 //--------------------------------------------------------------------
541 void GenericPropertyHandler::impl_ensurePropertyMap()
543 if ( !m_bPropertyMapInitialized
)
545 m_bPropertyMapInitialized
= true;
548 Reference
< XPropertySetInfo
> xPSI
;
549 if ( m_xComponent
.is() )
550 xPSI
= m_xComponent
->getPropertySetInfo();
551 Sequence
< Property
> aProperties
;
553 aProperties
= xPSI
->getProperties();
554 DBG_ASSERT( aProperties
.getLength(), "GenericPropertyHandler::getSupportedProperties: no properties!" );
556 for ( const Property
* pProperties
= aProperties
.getConstArray();
557 pProperties
!= aProperties
.getConstArray() + aProperties
.getLength();
561 switch ( pProperties
->Type
.getTypeClass() )
563 case TypeClass_BOOLEAN
:
565 case TypeClass_SHORT
:
566 case TypeClass_UNSIGNED_SHORT
:
568 case TypeClass_UNSIGNED_LONG
:
569 case TypeClass_HYPER
:
570 case TypeClass_UNSIGNED_HYPER
:
571 case TypeClass_FLOAT
:
572 case TypeClass_DOUBLE
:
574 case TypeClass_STRING
:
575 // allowed, we can handle this type
578 case TypeClass_SEQUENCE
:
580 TypeClass eElementTypeClass
= ::comphelper::getSequenceElementType( pProperties
->Type
).getTypeClass();
581 if ( ( eElementTypeClass
!= TypeClass_STRING
)
582 && ( eElementTypeClass
!= TypeClass_BYTE
)
583 && ( eElementTypeClass
!= TypeClass_SHORT
)
584 && ( eElementTypeClass
!= TypeClass_UNSIGNED_SHORT
)
585 && ( eElementTypeClass
!= TypeClass_LONG
)
586 && ( eElementTypeClass
!= TypeClass_UNSIGNED_LONG
)
588 // can only handle the above
594 // next property, we don't support this type
598 m_aProperties
.insert( PropertyMap::value_type( pProperties
->Name
, *pProperties
) );
601 catch( const Exception
& )
603 OSL_ENSURE( sal_False
, "GenericPropertyHandler::impl_ensurePropertyMap: caught an exception!" );
608 //--------------------------------------------------------------------
609 Sequence
< Property
> SAL_CALL
GenericPropertyHandler::getSupportedProperties() throw (RuntimeException
)
611 ::osl::MutexGuard
aGuard( m_aMutex
);
612 const_cast< GenericPropertyHandler
* >( this )->impl_ensurePropertyMap();
614 Sequence
< Property
> aReturn( m_aProperties
.size() );
615 ::std::transform( m_aProperties
.begin(), m_aProperties
.end(),
616 aReturn
.getArray(), ::std::select2nd
< PropertyMap::value_type
>() );
620 //--------------------------------------------------------------------
621 Sequence
< ::rtl::OUString
> SAL_CALL
GenericPropertyHandler::getSupersededProperties( ) throw (RuntimeException
)
623 // no superseded properties at all. This handler offers the very basic PropertyHandler
624 // functionality, so it's much more likely that other handlers want to supersede
625 // *our* properties ....
626 return Sequence
< ::rtl::OUString
>( );
629 //--------------------------------------------------------------------
630 Sequence
< ::rtl::OUString
> SAL_CALL
GenericPropertyHandler::getActuatingProperties( ) throw (RuntimeException
)
632 // This basic PropertyHandler implementation is too dumb^Wgeneric to know
633 // anything about property dependencies
634 return Sequence
< ::rtl::OUString
>( );
637 //--------------------------------------------------------------------
638 LineDescriptor SAL_CALL
GenericPropertyHandler::describePropertyLine( const ::rtl::OUString
& _rPropertyName
,
639 const Reference
< XPropertyControlFactory
>& _rxControlFactory
)
640 throw (UnknownPropertyException
, NullPointerException
, RuntimeException
)
642 if ( !_rxControlFactory
.is() )
643 throw NullPointerException();
645 ::osl::MutexGuard
aGuard( m_aMutex
);
646 const_cast< GenericPropertyHandler
* >( this )->impl_ensurePropertyMap();
648 PropertyMap::const_iterator pos
= m_aProperties
.find( _rPropertyName
);
649 if ( pos
== m_aProperties
.end() )
650 throw UnknownPropertyException();
652 LineDescriptor aDescriptor
;
653 aDescriptor
.DisplayName
= _rPropertyName
;
654 switch ( pos
->second
.Type
.getTypeClass() )
657 aDescriptor
.Control
= PropertyHandlerHelper::createListBoxControl( _rxControlFactory
,
658 impl_getEnumConverter( pos
->second
.Type
)->getDescriptions(),
659 PropertyHandlerHelper::requiresReadOnlyControl( pos
->second
.Attributes
),
662 case TypeClass_STRING
:
664 // some special handling for URL properties
665 bool bIsURLProperty
= ( _rPropertyName
.getLength() >= 3 ) && _rPropertyName
.matchAsciiL( "URL", 3, _rPropertyName
.getLength() - 3 );
666 if ( bIsURLProperty
)
668 aDescriptor
.Control
= _rxControlFactory
->createPropertyControl(
669 PropertyControlType::HyperlinkField
, PropertyHandlerHelper::requiresReadOnlyControl( pos
->second
.Attributes
) );
671 Reference
< XHyperlinkControl
> xControl( aDescriptor
.Control
, UNO_QUERY_THROW
);
672 Reference
< XActionListener
> xEnsureDelete( new UrlClickHandler( m_aContext
, xControl
) );
680 if ( !aDescriptor
.Control
.is() )
681 PropertyHandlerHelper::describePropertyLine( pos
->second
, aDescriptor
, _rxControlFactory
);
683 aDescriptor
.Category
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
687 //--------------------------------------------------------------------
688 ::sal_Bool SAL_CALL
GenericPropertyHandler::isComposable( const ::rtl::OUString
& /*_rPropertyName*/ ) throw (UnknownPropertyException
, RuntimeException
)
693 //--------------------------------------------------------------------
694 InteractiveSelectionResult SAL_CALL
GenericPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString
& /*_rPropertyName*/, sal_Bool
/*_bPrimary*/, Any
& /*_rData*/, const Reference
< XObjectInspectorUI
>& /*_rxInspectorUI*/ ) throw (UnknownPropertyException
, NullPointerException
, RuntimeException
)
696 DBG_ERROR( "GenericPropertyHandler::onInteractivePropertySelection: I'm too dumb to know anything about property browse buttons!" );
697 return InteractiveSelectionResult_Cancelled
;
700 //--------------------------------------------------------------------
701 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
)
703 DBG_ERROR( "GenericPropertyHandler::actuatingPropertyChanged: no no no, I did not register for any actuating properties!" );
706 //--------------------------------------------------------------------
707 sal_Bool SAL_CALL
GenericPropertyHandler::suspend( sal_Bool
/*_bSuspend*/ ) throw (RuntimeException
)
712 //--------------------------------------------------------------------
713 void SAL_CALL
GenericPropertyHandler::disposing()
715 m_aPropertyListeners
.clear();
716 // not disposeAndClear: the listeners are (virtually) listeners at our introspectee, not
717 // at this handler instance
720 //--------------------------------------------------------------------
721 IMPLEMENT_FORWARD_XCOMPONENT( GenericPropertyHandler
, GenericPropertyHandler_Base
);
723 //........................................................................
725 //........................................................................