LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - eventhandler.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 9 0.0 %
Date: 2014-04-14 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          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_EVENTHANDLER_HXX
      21             : #define EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
      22             : 
      23             : #include "pcrcommontypes.hxx"
      24             : #include "pcrcommon.hxx"
      25             : 
      26             : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      27             : #include <com/sun/star/lang/XServiceInfo.hpp>
      28             : #include <com/sun/star/inspection/XPropertyHandler.hpp>
      29             : #include <com/sun/star/beans/XPropertySet.hpp>
      30             : #include <com/sun/star/frame/XFrame.hpp>
      31             : #include <com/sun/star/uno/XComponentContext.hpp>
      32             : #include <cppuhelper/compbase2.hxx>
      33             : #include <comphelper/listenernotification.hxx>
      34             : 
      35             : 
      36             : namespace pcr
      37             : {
      38             : 
      39             : 
      40             : 
      41             :     //= EventDescription
      42             : 
      43             :     typedef sal_Int32   EventId;
      44           0 :     struct EventDescription
      45             :     {
      46             :     public:
      47             :         OUString sDisplayName;
      48             :         OUString sListenerClassName;
      49             :         OUString sListenerMethodName;
      50             :         OString  sHelpId;
      51             :         OString  sUniqueBrowseId;
      52             :         EventId         nId;
      53             : 
      54           0 :         EventDescription()
      55           0 :             :nId( 0 )
      56             :             {
      57           0 :             }
      58             : 
      59             :         EventDescription(
      60             :             EventId _nId,
      61             :             const sal_Char* _pListenerNamespaceAscii,
      62             :             const sal_Char* _pListenerClassAsciiName,
      63             :             const sal_Char* _pListenerMethodAsciiName,
      64             :             sal_uInt16 _nDisplayNameResId,
      65             :             const OString& _sHelpId,
      66             :             const OString& _sUniqueBrowseId );
      67             :     };
      68             : 
      69             :     typedef ::boost::unordered_map< OUString, EventDescription, OUStringHash >   EventMap;
      70             : 
      71             : 
      72             :     //= EventHandler
      73             : 
      74             :     typedef ::cppu::WeakComponentImplHelper2    <   ::com::sun::star::inspection::XPropertyHandler
      75             :                                                 ,   ::com::sun::star::lang::XServiceInfo
      76             :                                                 >   EventHandler_Base;
      77             :     class EventHandler : public EventHandler_Base
      78             :     {
      79             :     private:
      80             :         mutable ::osl::Mutex    m_aMutex;
      81             : 
      82             :         /// the context in which the instance was created
      83             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >  m_xContext;
      84             :         /// the properties of the object we're handling
      85             :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   m_xComponent;
      86             :         /// our XPropertyChangeListener(s)
      87             :         PropertyChangeListeners                                                     m_aPropertyListeners;
      88             :         /// cache of the events we found at our introspectee
      89             :         EventMap                                                                    m_aEvents;
      90             :         /// has m_aEvents been initialized?
      91             :         bool                                                                        m_bEventsMapInitialized;
      92             :         /// is our introspectee a dialog element?
      93             :         bool                                                                        m_bIsDialogElement;
      94             :             // TODO: move different handling into different derived classes?
      95             :         /// (FormComponent) type of the grid column being inspected, or -1 if we're not inspecting a grid column
      96             :         sal_Int16                                                                   m_nGridColumnType;
      97             : 
      98             :     public:
      99             :         // XServiceInfo - static versions
     100             :         static OUString SAL_CALL getImplementationName_static(  ) throw (::com::sun::star::uno::RuntimeException);
     101             :         static ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_static(  ) throw (::com::sun::star::uno::RuntimeException);
     102             :         static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
     103             : 
     104             :     protected:
     105             :         EventHandler(
     106             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
     107             :        );
     108             : 
     109             :         virtual ~EventHandler();
     110             : 
     111             :     protected:
     112             :         // XPropertyHandler overridables
     113             :         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, std::exception) SAL_OVERRIDE;
     114             :         virtual ::com::sun::star::uno::Any                          SAL_CALL getPropertyValue( const OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             :         virtual void                                                SAL_CALL setPropertyValue( const OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     116             :         virtual ::com::sun::star::uno::Any                          SAL_CALL convertToPropertyValue( const OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     117             :         virtual ::com::sun::star::uno::Any                          SAL_CALL convertToControlValue( const 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, std::exception) SAL_OVERRIDE;
     118             :         virtual ::com::sun::star::beans::PropertyState              SAL_CALL getPropertyState( const OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :         virtual void                                                SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     120             :         virtual void                                                SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
     122             :                                                                     SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             :         virtual ::com::sun::star::uno::Sequence< OUString >  SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     124             :         virtual ::com::sun::star::uno::Sequence< OUString >  SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     125             :         virtual ::com::sun::star::inspection::LineDescriptor        SAL_CALL describePropertyLine( const 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, std::exception) SAL_OVERRIDE;
     126             :         virtual sal_Bool                                          SAL_CALL isComposable( const OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             :         virtual ::com::sun::star::inspection::InteractiveSelectionResult
     128             :                                                                     SAL_CALL onInteractivePropertySelection( const 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, std::exception) SAL_OVERRIDE;
     129             :         virtual void                                                SAL_CALL actuatingPropertyChanged( const 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, std::exception) SAL_OVERRIDE;
     130             :         virtual sal_Bool                                            SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     131             : 
     132             :         // XComponent
     133             :         DECLARE_XCOMPONENT()
     134             :         virtual void                                                SAL_CALL disposing() SAL_OVERRIDE;
     135             : 
     136             :         // XServiceInfo
     137             :         virtual OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     139             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     140             : 
     141             :     private:
     142             :         /** returns the script events associated with our introspectee
     143             :             @param  _out_rEvents
     144             :                 Takes, upon successful return, the events currently associated with the introspectee
     145             :             @precond
     146             :                 Our introspectee is a form component
     147             :         */
     148             :         void    impl_getFormComponentScriptEvents_nothrow(
     149             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
     150             :                 ) const;
     151             : 
     152             :         /** returns the script events associated with our introspectee
     153             :             @param  _out_rEvents
     154             :                 Takes, upon successful return, the events currently associated with the introspectee
     155             :             @precond
     156             :                 Our introspectee is a dialog element
     157             :         */
     158             :         void    impl_getDialogElementScriptEvents_nothrow(
     159             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
     160             :                 ) const;
     161             : 
     162             :         /** returns the script events associated with our introspectee
     163             :             @param  _out_rEvents
     164             :                 Takes, the events currently associated with the introspectee
     165             :         */
     166           0 :         inline void impl_getComponentScriptEvents_nothrow(
     167             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
     168             :                 ) const
     169             :         {
     170           0 :             if ( m_bIsDialogElement )
     171           0 :                 impl_getDialogElementScriptEvents_nothrow( _out_rEvents );
     172             :             else
     173           0 :                 impl_getFormComponentScriptEvents_nothrow( _out_rEvents );
     174           0 :         }
     175             : 
     176             :         /** returns the types of the listeners which can be registered at our introspectee
     177             :             @param  _out_rTypes
     178             :                 Takes, upon successful return, the types of possible listeners at the introspectee
     179             :         */
     180             :         void    impl_getCopmonentListenerTypes_nothrow(
     181             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >& _out_rTypes
     182             :                 ) const;
     183             : 
     184             :         /** returns a secondary component to be used for event inspection
     185             : 
     186             :             In the UI, we want to mix events for the control model with events for the control.
     187             :             Since our introspectee is a model, this method creates a control for it (if possible).
     188             : 
     189             :             @return
     190             :                 the secondary component whose events should be mixed with the introspectee's events
     191             :                 The caller takes the ownership of the component (if not <NULL/>).
     192             : 
     193             :             @throws
     194             :                 if an unexpected error occurs during creation of the secondary component.
     195             :                 A <NULL/> component to be returned is not unexpected, but allowed
     196             : 
     197             :             @precond
     198             :                 ->m_xComponent is not <NULL/>
     199             :         */
     200             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     201             :                 impl_getSecondaryComponentForEventInspection_throw( ) const;
     202             : 
     203             :         /** returns the event description for the given (programmatic) property name
     204             :             @param  _rPropertyName
     205             :                 the name whose event description should be looked up
     206             :             @return
     207             :                 the event description for the property name
     208             :             @throws ::com::sun::star::beans::UnknownPropertyException
     209             :                 if our introspectee does not have an event with the given logical name (see ->getSupportedProperties)
     210             :         */
     211             :         const EventDescription&
     212             :                 impl_getEventForName_throw( const OUString& _rPropertyName ) const;
     213             : 
     214             :         /** returns the index of our component within its parent, if this parent can be
     215             :             obtained  (XChild::getParent) and supports an ->XIndexAccess interface
     216             :         */
     217             :         sal_Int32   impl_getComponentIndexInParent_throw() const;
     218             : 
     219             :         /** sets a given script event as event handler at a form component
     220             : 
     221             :             @param  _rScriptEvent
     222             :                 the script event to set
     223             :         */
     224             :         void    impl_setFormComponentScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
     225             : 
     226             :         /** sets a given script event as event handler at a dialog component
     227             : 
     228             :             @param  _rScriptEvent
     229             :                 the script event to set
     230             :         */
     231             :         void    impl_setDialogElementScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
     232             : 
     233             :         /** returns the frame associated with our context document
     234             :         */
     235             :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
     236             :                 impl_getContextFrame_nothrow() const;
     237             : 
     238             :         /** approves or denies a certain method to be included in the UI
     239             :             @return
     240             :                 <TRUE/> if and only if the given method is allowed.
     241             :         */
     242             :         bool    impl_filterMethod_nothrow( const EventDescription& _rEvent ) const;
     243             : 
     244             :     private:
     245             :         EventHandler();                                 // never implemented
     246             :         EventHandler( const EventHandler& );            // never implemented
     247             :         EventHandler& operator=( const EventHandler& ); // never implemented
     248             :     };
     249             : 
     250             : 
     251             : } // namespace pcr
     252             : 
     253             : 
     254             : #endif // EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
     255             : 
     256             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10