LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - eventhandler.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 9 0.0 %
Date: 2012-08-25 Functions: 0 5 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                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
      30                 :            : #define EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
      31                 :            : 
      32                 :            : #include "pcrcomponentcontext.hxx"
      33                 :            : #include "pcrcommontypes.hxx"
      34                 :            : #include "pcrcommon.hxx"
      35                 :            : 
      36                 :            : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      37                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      38                 :            : #include <com/sun/star/inspection/XPropertyHandler.hpp>
      39                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      40                 :            : #include <com/sun/star/frame/XFrame.hpp>
      41                 :            : #include <cppuhelper/compbase2.hxx>
      42                 :            : #include <comphelper/listenernotification.hxx>
      43                 :            : 
      44                 :            : //........................................................................
      45                 :            : namespace pcr
      46                 :            : {
      47                 :            : //........................................................................
      48                 :            : 
      49                 :            :     //====================================================================
      50                 :            :     //= EventDescription
      51                 :            :     //====================================================================
      52                 :            :     typedef sal_Int32   EventId;
      53                 :          0 :     struct EventDescription
      54                 :            :     {
      55                 :            :     public:
      56                 :            :         ::rtl::OUString sDisplayName;
      57                 :            :         ::rtl::OUString sListenerClassName;
      58                 :            :         ::rtl::OUString sListenerMethodName;
      59                 :            :         ::rtl::OString  sHelpId;
      60                 :            :         ::rtl::OString  sUniqueBrowseId;
      61                 :            :         EventId         nId;
      62                 :            : 
      63                 :          0 :         EventDescription()
      64                 :          0 :             :nId( 0 )
      65                 :            :             {
      66                 :          0 :             }
      67                 :            : 
      68                 :            :         EventDescription(
      69                 :            :             EventId _nId,
      70                 :            :             const sal_Char* _pListenerNamespaceAscii,
      71                 :            :             const sal_Char* _pListenerClassAsciiName,
      72                 :            :             const sal_Char* _pListenerMethodAsciiName,
      73                 :            :             sal_uInt16 _nDisplayNameResId,
      74                 :            :             const rtl::OString& _sHelpId,
      75                 :            :             const rtl::OString& _sUniqueBrowseId );
      76                 :            :     };
      77                 :            : 
      78                 :            :     typedef ::boost::unordered_map< ::rtl::OUString, EventDescription, ::rtl::OUStringHash >   EventMap;
      79                 :            : 
      80                 :            :     //====================================================================
      81                 :            :     //= EventHandler
      82                 :            :     //====================================================================
      83                 :            :     typedef ::cppu::WeakComponentImplHelper2    <   ::com::sun::star::inspection::XPropertyHandler
      84                 :            :                                                 ,   ::com::sun::star::lang::XServiceInfo
      85                 :            :                                                 >   EventHandler_Base;
      86                 :            :     class EventHandler : public EventHandler_Base
      87                 :            :     {
      88                 :            :     private:
      89                 :            :         mutable ::osl::Mutex    m_aMutex;
      90                 :            : 
      91                 :            :         /// the context in which the instance was created
      92                 :            :         ComponentContext                                                            m_aContext;
      93                 :            :         /// the properties of the object we're handling
      94                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   m_xComponent;
      95                 :            :         /// our XPropertyChangeListener(s)
      96                 :            :         PropertyChangeListeners                                                     m_aPropertyListeners;
      97                 :            :         /// cache of the events we found at our introspectee
      98                 :            :         EventMap                                                                    m_aEvents;
      99                 :            :         /// has m_aEvents been initialized?
     100                 :            :         bool                                                                        m_bEventsMapInitialized;
     101                 :            :         /// is our introspectee a dialog element?
     102                 :            :         bool                                                                        m_bIsDialogElement;
     103                 :            :             // TODO: move different handling into different derived classes?
     104                 :            :         /// (FormComponent) type of the grid column being inspected, or -1 if we're not inspecting a grid column
     105                 :            :         sal_Int16                                                                   m_nGridColumnType;
     106                 :            : 
     107                 :            :     public:
     108                 :            :         // XServiceInfo - static versions
     109                 :            :         static ::rtl::OUString SAL_CALL getImplementationName_static(  ) throw (::com::sun::star::uno::RuntimeException);
     110                 :            :         static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static(  ) throw (::com::sun::star::uno::RuntimeException);
     111                 :            :         static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
     112                 :            : 
     113                 :            :     protected:
     114                 :            :         EventHandler(
     115                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
     116                 :            :        );
     117                 :            : 
     118                 :            :         ~EventHandler();
     119                 :            : 
     120                 :            :     protected:
     121                 :            :         // XPropertyHandler overridables
     122                 :            :         virtual void                                                SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
     123                 :            :         virtual ::com::sun::star::uno::Any                          SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
     124                 :            :         virtual void                                                SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
     125                 :            :         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);
     126                 :            :         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);
     127                 :            :         virtual ::com::sun::star::beans::PropertyState              SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
     128                 :            :         virtual void                                                SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
     129                 :            :         virtual void                                                SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
     130                 :            :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
     131                 :            :                                                                     SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
     132                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >  SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
     133                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >  SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
     134                 :            :         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);
     135                 :            :         virtual ::sal_Bool                                          SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
     136                 :            :         virtual ::com::sun::star::inspection::InteractiveSelectionResult
     137                 :            :                                                                     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);
     138                 :            :         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);
     139                 :            :         virtual sal_Bool                                            SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
     140                 :            : 
     141                 :            :         // XComponent
     142                 :            :         DECLARE_XCOMPONENT()
     143                 :            :         virtual void                                                SAL_CALL disposing();
     144                 :            : 
     145                 :            :         // XServiceInfo
     146                 :            :         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
     147                 :            :         virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
     148                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
     149                 :            : 
     150                 :            :     private:
     151                 :            :         /** returns the script events associated with our introspectee
     152                 :            :             @param  _out_rEvents
     153                 :            :                 Takes, upon successfull return, the events currently associated with the introspectee
     154                 :            :             @precond
     155                 :            :                 Our introspectee is a form component
     156                 :            :         */
     157                 :            :         void    impl_getFormComponentScriptEvents_nothrow(
     158                 :            :                     ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
     159                 :            :                 ) const;
     160                 :            : 
     161                 :            :         /** returns the script events associated with our introspectee
     162                 :            :             @param  _out_rEvents
     163                 :            :                 Takes, upon successfull return, the events currently associated with the introspectee
     164                 :            :             @precond
     165                 :            :                 Our introspectee is a dialog element
     166                 :            :         */
     167                 :            :         void    impl_getDialogElementScriptEvents_nothrow(
     168                 :            :                     ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
     169                 :            :                 ) const;
     170                 :            : 
     171                 :            :         /** returns the script events associated with our introspectee
     172                 :            :             @param  _out_rEvents
     173                 :            :                 Takes, the events currently associated with the introspectee
     174                 :            :         */
     175                 :          0 :         inline void impl_getComponentScriptEvents_nothrow(
     176                 :            :                     ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
     177                 :            :                 ) const
     178                 :            :         {
     179                 :          0 :             if ( m_bIsDialogElement )
     180                 :          0 :                 impl_getDialogElementScriptEvents_nothrow( _out_rEvents );
     181                 :            :             else
     182                 :          0 :                 impl_getFormComponentScriptEvents_nothrow( _out_rEvents );
     183                 :          0 :         }
     184                 :            : 
     185                 :            :         /** returns the types of the listeners which can be registered at our introspectee
     186                 :            :             @param  _out_rTypes
     187                 :            :                 Takes, upon successfull return, the types of possible listeners at the introspectee
     188                 :            :         */
     189                 :            :         void    impl_getCopmonentListenerTypes_nothrow(
     190                 :            :                     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >& _out_rTypes
     191                 :            :                 ) const;
     192                 :            : 
     193                 :            :         /** returns a secondary component to be used for event inspection
     194                 :            : 
     195                 :            :             In the UI, we want to mix events for the control model with events for the control.
     196                 :            :             Since our introspectee is a model, this method creates a control for it (if possible).
     197                 :            : 
     198                 :            :             @return
     199                 :            :                 the secondary component whose events should be mixed with the introspectee's events
     200                 :            :                 The caller takes the ownership of the component (if not <NULL/>).
     201                 :            : 
     202                 :            :             @throws
     203                 :            :                 if an unexpected error occurs during creation of the secondary component.
     204                 :            :                 A <NULL/> component to be returned is not unexpected, but allowed
     205                 :            : 
     206                 :            :             @precond
     207                 :            :                 ->m_xComponent is not <NULL/>
     208                 :            :         */
     209                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     210                 :            :                 impl_getSecondaryComponentForEventInspection_throw( ) const;
     211                 :            : 
     212                 :            :         /** returns the event description for the given (programmatic) property name
     213                 :            :             @param  _rPropertyName
     214                 :            :                 the name whose event description should be looked up
     215                 :            :             @return
     216                 :            :                 the event description for the property name
     217                 :            :             @throws ::com::sun::star::beans::UnknownPropertyException
     218                 :            :                 if our introspectee does not have an event with the given logical name (see ->getSupportedProperties)
     219                 :            :         */
     220                 :            :         const EventDescription&
     221                 :            :                 impl_getEventForName_throw( const ::rtl::OUString& _rPropertyName ) const;
     222                 :            : 
     223                 :            :         /** returns the index of our component within its parent, if this parent can be
     224                 :            :             obtained  (XChild::getParent) and supports an ->XIndexAccess interface
     225                 :            :         */
     226                 :            :         sal_Int32   impl_getComponentIndexInParent_throw() const;
     227                 :            : 
     228                 :            :         /** sets a given script event as event handler at a form component
     229                 :            : 
     230                 :            :             @param  _rScriptEvent
     231                 :            :                 the script event to set
     232                 :            :         */
     233                 :            :         void    impl_setFormComponentScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
     234                 :            : 
     235                 :            :         /** sets a given script event as event handler at a dialog component
     236                 :            : 
     237                 :            :             @param  _rScriptEvent
     238                 :            :                 the script event to set
     239                 :            :         */
     240                 :            :         void    impl_setDialogElementScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
     241                 :            : 
     242                 :            :         /** returns the frame associated with our context document
     243                 :            :         */
     244                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
     245                 :            :                 impl_getContextFrame_nothrow() const;
     246                 :            : 
     247                 :            :         /** approves or denies a certain method to be included in the UI
     248                 :            :             @return
     249                 :            :                 <TRUE/> if and only if the given method is allowed.
     250                 :            :         */
     251                 :            :         bool    impl_filterMethod_nothrow( const EventDescription& _rEvent ) const;
     252                 :            : 
     253                 :            :     private:
     254                 :            :         EventHandler();                                 // never implemented
     255                 :            :         EventHandler( const EventHandler& );            // never implemented
     256                 :            :         EventHandler& operator=( const EventHandler& ); // never implemented
     257                 :            :     };
     258                 :            : 
     259                 :            : //........................................................................
     260                 :            : } // namespace pcr
     261                 :            : //........................................................................
     262                 :            : 
     263                 :            : #endif // EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
     264                 :            : 
     265                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10