LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - propertyhandler.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 42 0.0 %
Date: 2012-08-25 Functions: 0 68 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
      21                 :            : #define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
      22                 :            : 
      23                 :            : #include "pcrcomponentcontext.hxx"
      24                 :            : #include "pcrcommon.hxx"
      25                 :            : #include "modulepcr.hxx"
      26                 :            : 
      27                 :            : #include <com/sun/star/uno/XComponentContext.hpp>
      28                 :            : #include <com/sun/star/beans/PropertyState.hpp>
      29                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      30                 :            : #include <com/sun/star/beans/Property.hpp>
      31                 :            : #include <com/sun/star/script/XTypeConverter.hpp>
      32                 :            : #include <com/sun/star/frame/XModel.hpp>
      33                 :            : #include <com/sun/star/uno/Sequence.hxx>
      34                 :            : #include <com/sun/star/uno/Any.hxx>
      35                 :            : #include <com/sun/star/util/Date.hpp>
      36                 :            : #include <com/sun/star/util/Time.hpp>
      37                 :            : #include <com/sun/star/util/DateTime.hpp>
      38                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      39                 :            : #include <com/sun/star/inspection/XPropertyHandler.hpp>
      40                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      41                 :            : #include <osl/interlck.h>
      42                 :            : #include <cppuhelper/compbase1.hxx>
      43                 :            : #include <cppuhelper/implbase1.hxx>
      44                 :            : #include <comphelper/uno3.hxx>
      45                 :            : 
      46                 :            : #include <memory>
      47                 :            : #include <vector>
      48                 :            : 
      49                 :            : namespace com { namespace sun { namespace star {
      50                 :            :     namespace inspection {
      51                 :            :         struct LineDescriptor;
      52                 :            :         class XPropertyControlFactory;
      53                 :            :     }
      54                 :            : } } }
      55                 :            : 
      56                 :            : class Window;
      57                 :            : //........................................................................
      58                 :            : namespace pcr
      59                 :            : {
      60                 :            : //........................................................................
      61                 :            : 
      62                 :            :     typedef sal_Int32   PropertyId;
      63                 :            : 
      64                 :            :     //====================================================================
      65                 :            :     //= PropertyHandler
      66                 :            :     //====================================================================
      67                 :            :     class OPropertyInfoService;
      68                 :            :     typedef ::cppu::WeakComponentImplHelper1    <   ::com::sun::star::inspection::XPropertyHandler
      69                 :            :                                                 >   PropertyHandler_Base;
      70                 :            :     /** the base class for property handlers
      71                 :            :     */
      72                 :            :     class PropertyHandler : public PropertyHandler_Base
      73                 :            :     {
      74                 :            :     private:
      75                 :            :         /// cache for getSupportedProperties
      76                 :            :         mutable StlSyntaxSequence< ::com::sun::star::beans::Property >
      77                 :            :                                     m_aSupportedProperties;
      78                 :            :         mutable bool                m_bSupportedPropertiesAreKnown;
      79                 :            : 
      80                 :            :         /// helper which ensures that we can access resources as long as the instance lives
      81                 :            :         PcrClient       m_aEnsureResAccess;
      82                 :            : 
      83                 :            :     private:
      84                 :            :         /// the property listener which has been registered
      85                 :            :         PropertyChangeListeners                                                         m_aPropertyListeners;
      86                 :            : 
      87                 :            :     protected:
      88                 :            :         mutable ::osl::Mutex                                                            m_aMutex;
      89                 :            :         /// the context in which the instance was created
      90                 :            :         ComponentContext                                                                m_aContext;
      91                 :            :         /// the component we're inspecting
      92                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >       m_xComponent;
      93                 :            :         /// info about our component's properties
      94                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >   m_xComponentPropertyInfo;
      95                 :            :         /// type converter, needed on various occasions
      96                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >    m_xTypeConverter;
      97                 :            :         /// access to property meta data
      98                 :            :         ::std::auto_ptr< OPropertyInfoService >                                         m_pInfoService;
      99                 :            : 
     100                 :            :     protected:
     101                 :            :         PropertyHandler(
     102                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
     103                 :            :         );
     104                 :            :         ~PropertyHandler();
     105                 :            : 
     106                 :            :         // default implementations for XPropertyHandler
     107                 :            :         virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
     108                 :            :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
     109                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
     110                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
     111                 :            :         virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
     112                 :            :         virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
     113                 :            :         virtual ::com::sun::star::beans::PropertyState  SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
     114                 :            :         virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
     115                 :            :         virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
     116                 :            :         virtual ::com::sun::star::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
     117                 :            :         virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
     118                 :            :         virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
     119                 :            :         virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
     120                 :            :         virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
     121                 :            : 
     122                 :            :         // XComponent
     123                 :            :         DECLARE_XCOMPONENT()
     124                 :            :         virtual void SAL_CALL disposing();
     125                 :            : 
     126                 :            :         // own overridables
     127                 :            :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
     128                 :            :                     SAL_CALL doDescribeSupportedProperties() const = 0;
     129                 :            : 
     130                 :            :         /// called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect
     131                 :            :         virtual void onNewComponent();
     132                 :            : 
     133                 :            :     protected:
     134                 :            :         /** fires the change in a property value to our listener (if any)
     135                 :            :             @see addPropertyChangeListener
     136                 :            :         */
     137                 :            :         void    firePropertyChange( const ::rtl::OUString& _rPropName, PropertyId _nPropId,
     138                 :            :                     const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Any& _rNewValue ) SAL_THROW(());
     139                 :            : 
     140                 :            :         /** retrieves a window which can be used as parent for dialogs
     141                 :            :         */
     142                 :            :         Window* impl_getDefaultDialogParent_nothrow() const;
     143                 :            : 
     144                 :            :         /** retrieves the property id for a given property name
     145                 :            :             @throw com::sun::star::beans::UnknownPropertyException
     146                 :            :                 if the property name is not known to our ->m_pInfoService
     147                 :            :         */
     148                 :            :         PropertyId impl_getPropertyId_throw( const ::rtl::OUString& _rPropertyName ) const;
     149                 :            : 
     150                 :            :         //-------------------------------------------------------------------------------
     151                 :            :         // helper for implementing doDescribeSupportedProperties
     152                 :            :         /** adds a description for the given string property to the given property vector
     153                 :            :             Most probably to be called from within getSupportedProperties
     154                 :            :         */
     155                 :            :         inline void addStringPropertyDescription(
     156                 :            :                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
     157                 :            :                     const ::rtl::OUString& _rPropertyName,
     158                 :            :                     sal_Int16 _nAttribs = 0
     159                 :            :                 ) const;
     160                 :            : 
     161                 :            :         /** adds a description for the given int32 property to the given property vector
     162                 :            :         */
     163                 :            :         inline void addInt32PropertyDescription(
     164                 :            :                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
     165                 :            :                     const ::rtl::OUString& _rPropertyName,
     166                 :            :                     sal_Int16 _nAttribs = 0
     167                 :            :                 ) const;
     168                 :            : 
     169                 :            :         /** adds a description for the given int16 property to the given property vector
     170                 :            :         */
     171                 :            :         inline void addInt16PropertyDescription(
     172                 :            :                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
     173                 :            :                     const ::rtl::OUString& _rPropertyName,
     174                 :            :                     sal_Int16 _nAttribs = 0
     175                 :            :                 ) const;
     176                 :            : 
     177                 :            :         /** adds a description for the given double property to the given property vector
     178                 :            :         */
     179                 :            :         inline void addDoublePropertyDescription(
     180                 :            :                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
     181                 :            :                     const ::rtl::OUString& _rPropertyName,
     182                 :            :                     sal_Int16 _nAttribs = 0
     183                 :            :                 ) const;
     184                 :            : 
     185                 :            :         /** adds a description for the given date property to the given property vector
     186                 :            :         */
     187                 :            :         inline void addDatePropertyDescription(
     188                 :            :                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
     189                 :            :                     const ::rtl::OUString& _rPropertyName,
     190                 :            :                     sal_Int16 _nAttribs = 0
     191                 :            :                 ) const;
     192                 :            : 
     193                 :            :         /** adds a description for the given time property to the given property vector
     194                 :            :         */
     195                 :            :         inline void addTimePropertyDescription(
     196                 :            :                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
     197                 :            :                     const ::rtl::OUString& _rPropertyName,
     198                 :            :                     sal_Int16 _nAttribs = 0
     199                 :            :                 ) const;
     200                 :            : 
     201                 :            :         /** adds a description for the given DateTime property to the given property vector
     202                 :            :         */
     203                 :            :         inline void addDateTimePropertyDescription(
     204                 :            :                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
     205                 :            :                     const ::rtl::OUString& _rPropertyName,
     206                 :            :                     sal_Int16 _nAttribs = 0
     207                 :            :                 ) const;
     208                 :            : 
     209                 :            :         /// adds a Property, given by name only, to a given vector of Properties
     210                 :            :         void implAddPropertyDescription(
     211                 :            :                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
     212                 :            :                     const ::rtl::OUString& _rPropertyName,
     213                 :            :                     const ::com::sun::star::uno::Type& _rType,
     214                 :            :                     sal_Int16 _nAttribs = 0
     215                 :            :                 ) const;
     216                 :            : 
     217                 :            :         //-------------------------------------------------------------------------------
     218                 :            :         // helper for accessing and maintaining meta data about our supported properties
     219                 :            : 
     220                 :            :         /** retrieves a property given by handle
     221                 :            : 
     222                 :            :             @return
     223                 :            :                 a pointer to the descriptor for the given properties, if it is one of our
     224                 :            :                 supported properties, <NULL/> else.
     225                 :            : 
     226                 :            :             @see doDescribeSupportedProperties
     227                 :            :             @see impl_getPropertyFromId_throw
     228                 :            :         */
     229                 :            :         const ::com::sun::star::beans::Property*
     230                 :            :                     impl_getPropertyFromId_nothrow( PropertyId _nPropId ) const;
     231                 :            : 
     232                 :            :         /** retrieves a property given by handle
     233                 :            : 
     234                 :            :             @throws UnknownPropertyException
     235                 :            :                 if the handler does not support a property with the given handle
     236                 :            : 
     237                 :            :             @seealso doDescribeSupportedProperties
     238                 :            :             @see impl_getPropertyFromId_nothrow
     239                 :            :         */
     240                 :            :         const ::com::sun::star::beans::Property&
     241                 :            :                     impl_getPropertyFromId_throw( PropertyId _nPropId ) const;
     242                 :            : 
     243                 :            :         /** determines whether a given property id is part of our supported properties
     244                 :            :             @see getSupportedProperties
     245                 :            :             @see doDescribeSupportedProperties
     246                 :            :         */
     247                 :          0 :         inline bool impl_isSupportedProperty_nothrow( PropertyId _nPropId ) const
     248                 :            :         {
     249                 :          0 :             return impl_getPropertyFromId_nothrow( _nPropId ) != NULL;
     250                 :            :         }
     251                 :            : 
     252                 :            :         /** retrieves a property given by name
     253                 :            : 
     254                 :            :             @throws UnknownPropertyException
     255                 :            :                 if the handler does not support a property with the given name
     256                 :            : 
     257                 :            :             @seealso doDescribeSupportedProperties
     258                 :            :         */
     259                 :            :         const ::com::sun::star::beans::Property&
     260                 :            :                     impl_getPropertyFromName_throw( const ::rtl::OUString& _rPropertyName ) const;
     261                 :            : 
     262                 :            :         /** get the name of a property given by handle
     263                 :            :         */
     264                 :            :         inline ::rtl::OUString
     265                 :            :                     impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const;
     266                 :            : 
     267                 :            :         /** returns the value of the ContextDocument property in the ComponentContext which was used to create
     268                 :            :             this handler.
     269                 :            :         */
     270                 :            :         inline ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
     271                 :          0 :                     impl_getContextDocument_nothrow() const
     272                 :            :         {
     273                 :            :             return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >(
     274                 :          0 :                 m_aContext.getContextValueByAsciiName( "ContextDocument" ), ::com::sun::star::uno::UNO_QUERY );
     275                 :            :         }
     276                 :            : 
     277                 :            :         /** marks the context document as modified
     278                 :            : 
     279                 :            :             @see impl_getContextDocument_nothrow
     280                 :            :         */
     281                 :            :         void impl_setContextDocumentModified_nothrow() const;
     282                 :            : 
     283                 :            :         /// determines whether our component has a given property
     284                 :            :         bool impl_componentHasProperty_throw( const ::rtl::OUString& _rPropName ) const;
     285                 :            : 
     286                 :            :         /** determines the default measure unit for the document in which our component lives
     287                 :            :         */
     288                 :            :         sal_Int16 impl_getDocumentMeasurementUnit_throw() const;
     289                 :            : 
     290                 :            :     private:
     291                 :            :         PropertyHandler();                                    // never implemented
     292                 :            :         PropertyHandler( const PropertyHandler& );            // never implemented
     293                 :            :         PropertyHandler& operator=( const PropertyHandler& ); // never implemented
     294                 :            :     };
     295                 :            : 
     296                 :            :     //--------------------------------------------------------------------
     297                 :          0 :     inline void PropertyHandler::addStringPropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
     298                 :            :     {
     299                 :          0 :         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), _nAttribs );
     300                 :          0 :     }
     301                 :            : 
     302                 :          0 :     inline void PropertyHandler::addInt32PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
     303                 :            :     {
     304                 :          0 :         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int32* >( NULL ) ), _nAttribs );
     305                 :          0 :     }
     306                 :            : 
     307                 :          0 :     inline void PropertyHandler::addInt16PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
     308                 :            :     {
     309                 :          0 :         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int16* >( NULL ) ), _nAttribs );
     310                 :          0 :     }
     311                 :            : 
     312                 :          0 :     inline void PropertyHandler::addDoublePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
     313                 :            :     {
     314                 :          0 :         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< double* >( NULL ) ), _nAttribs );
     315                 :          0 :     }
     316                 :            : 
     317                 :          0 :     inline void PropertyHandler::addDatePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
     318                 :            :     {
     319                 :          0 :         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Date* >( NULL ) ), _nAttribs );
     320                 :          0 :     }
     321                 :            : 
     322                 :          0 :     inline void PropertyHandler::addTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
     323                 :            :     {
     324                 :          0 :         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Time* >( NULL ) ), _nAttribs );
     325                 :          0 :     }
     326                 :            : 
     327                 :          0 :     inline void PropertyHandler::addDateTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
     328                 :            :     {
     329                 :          0 :         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::DateTime* >( NULL ) ), _nAttribs );
     330                 :          0 :     }
     331                 :            : 
     332                 :          0 :     inline ::rtl::OUString PropertyHandler::impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const
     333                 :            :     {
     334                 :          0 :         const ::com::sun::star::beans::Property* pProp = impl_getPropertyFromId_nothrow( _nPropId );
     335                 :          0 :         return pProp ? pProp->Name : ::rtl::OUString();
     336                 :            :     }
     337                 :            : 
     338                 :            :     //====================================================================
     339                 :            :     //= PropertyHandlerComponent
     340                 :            :     //====================================================================
     341                 :            :     typedef ::cppu::ImplHelper1 <   ::com::sun::star::lang::XServiceInfo
     342                 :            :                                 >   PropertyHandlerComponent_Base;
     343                 :            :     /** PropertyHandler implementation which additionally supports XServiceInfo
     344                 :            :     */
     345                 :          0 :     class PropertyHandlerComponent  :public PropertyHandler
     346                 :            :                                     ,public PropertyHandlerComponent_Base
     347                 :            :     {
     348                 :            :     protected:
     349                 :            :         PropertyHandlerComponent(
     350                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
     351                 :            :         );
     352                 :            : 
     353                 :            :         DECLARE_XINTERFACE()
     354                 :            :         DECLARE_XTYPEPROVIDER()
     355                 :            : 
     356                 :            :         // XServiceInfo
     357                 :            :         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
     358                 :            :         virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
     359                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
     360                 :            :     };
     361                 :            : 
     362                 :            :     //====================================================================
     363                 :            :     //= HandlerComponentBase
     364                 :            :     //====================================================================
     365                 :            :     /** a PropertyHandlerComponent implementation which routes XServiceInfo::getImplementationName and
     366                 :            :         XServiceInfo::getSupportedServiceNames to static versions of those methods, which are part of
     367                 :            :         the derived class.
     368                 :            : 
     369                 :            :         Additionally, a method <member>Create</member> is provided which takes a component context, and returns a new
     370                 :            :         instance of the derived class. This <member>Create</member> is used to register the implementation
     371                 :            :         of the derived class at the <type>PcrModule</type>.
     372                 :            : 
     373                 :            :         Well, every time we're talking about derived class, we in fact mean the template argument of
     374                 :            :         <type>HandlerComponentBase</type>. But usually this equals your derived class:
     375                 :            :         <pre>
     376                 :            :         class MyHandler;
     377                 :            :         typedef HandlerComponentBase< MyHandler > MyHandler_Base;
     378                 :            :         class MyHandler : MyHandler_Base
     379                 :            :         {
     380                 :            :             ...
     381                 :            :         public:
     382                 :            :             static ::rtl::OUString SAL_CALL getImplementationName_static(  ) throw (::com::sun::star::uno::RuntimeException);
     383                 :            :             static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static(  ) throw (::com::sun::star::uno::RuntimeException);
     384                 :            :         };
     385                 :            :         </pre>
     386                 :            :     */
     387                 :            :     template < class HANDLER >
     388                 :          0 :     class HandlerComponentBase : public PropertyHandlerComponent
     389                 :            :     {
     390                 :            :     protected:
     391                 :          0 :         HandlerComponentBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
     392                 :          0 :             :PropertyHandlerComponent( _rxContext )
     393                 :            :         {
     394                 :          0 :         }
     395                 :            : 
     396                 :            :     protected:
     397                 :            :         // XServiceInfo
     398                 :            :         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
     399                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
     400                 :            :         static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
     401                 :            : 
     402                 :            :     public:
     403                 :            :         /** registers the implementation of HANDLER at the <type>PcrModule</type>
     404                 :            :         */
     405                 :            :         static void registerImplementation();
     406                 :            :     };
     407                 :            : 
     408                 :            :     //--------------------------------------------------------------------
     409                 :            :     template < class HANDLER >
     410                 :          0 :     ::rtl::OUString SAL_CALL HandlerComponentBase< HANDLER >::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)
     411                 :            :     {
     412                 :          0 :         return HANDLER::getImplementationName_static();
     413                 :            :     }
     414                 :            : 
     415                 :            :     //--------------------------------------------------------------------
     416                 :            :     template < class HANDLER >
     417                 :          0 :     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL HandlerComponentBase< HANDLER >::getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException)
     418                 :            :     {
     419                 :          0 :         return HANDLER::getSupportedServiceNames_static();
     420                 :            :     }
     421                 :            : 
     422                 :            :     //--------------------------------------------------------------------
     423                 :            :     template < class HANDLER >
     424                 :          0 :     void HandlerComponentBase< HANDLER >::registerImplementation()
     425                 :            :     {
     426                 :          0 :         PcrModule::getInstance().registerImplementation(
     427                 :            :             HANDLER::getImplementationName_static(),
     428                 :            :             HANDLER::getSupportedServiceNames_static(),
     429                 :            :             HANDLER::Create
     430                 :            :         );
     431                 :          0 :     }
     432                 :            : 
     433                 :            :     //--------------------------------------------------------------------
     434                 :            :     template < class HANDLER >
     435                 :          0 :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL HandlerComponentBase< HANDLER >::Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
     436                 :            :     {
     437                 :          0 :         return *( new HANDLER( _rxContext ) );
     438                 :            :     }
     439                 :            : 
     440                 :            : //........................................................................
     441                 :            : } // namespace pcr
     442                 :            : //........................................................................
     443                 :            : 
     444                 :            : #endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
     445                 :            : 
     446                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10