LCOV - code coverage report
Current view: top level - forms/source/component - clickableimage.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 4 20 20.0 %
Date: 2014-11-03 Functions: 8 19 42.1 %
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 INCLUDED_FORMS_SOURCE_COMPONENT_CLICKABLEIMAGE_HXX
      21             : #define INCLUDED_FORMS_SOURCE_COMPONENT_CLICKABLEIMAGE_HXX
      22             : 
      23             : #include "FormComponent.hxx"
      24             : #include "EventThread.hxx"
      25             : #include "imgprod.hxx"
      26             : #include <tools/link.hxx>
      27             : #include <comphelper/propmultiplex.hxx>
      28             : #include <com/sun/star/form/XImageProducerSupplier.hpp>
      29             : #include <com/sun/star/form/FormButtonType.hpp>
      30             : #include <com/sun/star/form/XApproveActionListener.hpp>
      31             : #include <com/sun/star/form/XApproveActionBroadcaster.hpp>
      32             : #include <com/sun/star/form/submission/XSubmissionSupplier.hpp>
      33             : #include <com/sun/star/form/submission/XSubmission.hpp>
      34             : #include <com/sun/star/frame/XModel.hpp>
      35             : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      36             : #include <cppuhelper/implbase3.hxx>
      37             : 
      38             : 
      39             : class SfxMedium;
      40             : 
      41             : 
      42             : namespace frm
      43             : {
      44             : 
      45             : 
      46             :     class OImageProducerThread_Impl;
      47             :     class ControlFeatureInterception;
      48             : 
      49             :     // OClickableImageBaseModel
      50             : 
      51             :     typedef ::cppu::ImplHelper3 <   ::com::sun::star::form::XImageProducerSupplier
      52             :                                 ,   ::com::sun::star::awt::XImageProducer
      53             :                                 ,   ::com::sun::star::form::submission::XSubmissionSupplier
      54             :                                 >   OClickableImageBaseModel_Base;
      55             : 
      56             :     class OClickableImageBaseModel  :public OClickableImageBaseModel_Base
      57             :                                     ,public OControlModel
      58             :                                     ,public OPropertyChangeListener
      59             :     {
      60             :     protected:
      61             :         ::com::sun::star::form::FormButtonType  m_eButtonType; // Type of the button (push, submit, reset)
      62             :         OUString                         m_sTargetURL;         // URL for the URL button
      63             :         OUString                         m_sTargetFrame;       // TargetFrame to open
      64             : 
      65             :         // ImageProducer stuff
      66             :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer>    m_xProducer;
      67             :         SfxMedium*                              m_pMedium;     // Download medium
      68             :         ImageProducer*                          m_pProducer;
      69             :         bool                                m_bDispatchUrlInternal; // property: is not allowed to set : 1
      70             :         bool                                m_bDownloading : 1;     // Is a download in progress?
      71             :         bool                                m_bProdStarted : 1;
      72             : 
      73             :         // XSubmission stuff
      74             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmission >
      75             :                                                 m_xSubmissionDelegate;
      76             : 
      77             :         DECL_STATIC_LINK( OClickableImageBaseModel, DownloadDoneLink, void* );
      78             : 
      79           2 :         inline ImageProducer* GetImageProducer() { return m_pProducer; }
      80             : 
      81             :         void StartProduction();
      82             :         void SetURL(const OUString& rURL);
      83             :         void DataAvailable();
      84             :         void DownloadDone();
      85             : 
      86             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
      87           0 :         inline bool isDispatchUrlInternal() const { return m_bDispatchUrlInternal; }
      88           0 :         inline void     setDispatchUrlInternal(bool _bDispatch) { m_bDispatchUrlInternal = _bDispatch; }
      89             : 
      90             :     public:
      91             :         DECLARE_DEFAULT_XTOR( OClickableImageBaseModel );
      92             : 
      93             :         // UNO Binding
      94      457432 :         DECLARE_UNO3_AGG_DEFAULTS(OClickableImageBaseModel, OControlModel)
      95             :         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      96             : 
      97             :     protected:
      98             :         // OComponentHelper
      99             :         virtual void SAL_CALL disposing() SAL_OVERRIDE;
     100             : 
     101             :         // ::com::sun::star::form::XImageProducerSupplier
     102           2 :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> SAL_CALL getImageProducer() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE { return m_xProducer; }
     103             : 
     104             :         // OPropertySetHelper
     105             :         virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
     106             :         virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     107             : 
     108             :         virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue, sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
     109             :             throw(::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
     110             : 
     111             :         using ::cppu::OPropertySetHelper::getFastPropertyValue;
     112             : 
     113             :         // OPropertyChangeListener
     114             :         virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent&) throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
     115             : 
     116             :         // XPropertyState
     117             :         virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const SAL_OVERRIDE;
     118             : 
     119             :         // XImageProducer
     120             :         virtual void SAL_CALL addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             :         virtual void SAL_CALL removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     122             :         virtual void SAL_CALL startProduction(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             : 
     124             :         // XSubmissionSupplier
     125             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmission > SAL_CALL getSubmission() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     126             :         virtual void SAL_CALL setSubmission( const ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmission >& _submission ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             : 
     128             :         // XServiceInfo
     129             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             : 
     131             :         // XEventListener
     132             :         using OControlModel::disposing;
     133             : 
     134             :     public:
     135           0 :         struct GuardAccess { friend class ImageModelMethodGuard; private: GuardAccess() { } };
     136           0 :         ::osl::Mutex&   getMutex( GuardAccess ) { return m_aMutex; }
     137           0 :         ImageProducer*  getImageProducer( GuardAccess ) { return m_pProducer; }
     138             : 
     139             :     protected:
     140             :         using OControlModel::getMutex;
     141             : 
     142             :         void implConstruct();
     143             : 
     144             :         // to be called from within the cloning-ctor of your derived class
     145             :         void implInitializeImageURL( );
     146             :     };
     147             : 
     148           0 :     class ImageModelMethodGuard : public ::osl::MutexGuard
     149             :     {
     150             :     private:
     151             :         typedef ::osl::MutexGuard   GuardBase;
     152             : 
     153             :     public:
     154           0 :         ImageModelMethodGuard( OClickableImageBaseModel& _rModel )
     155           0 :             :GuardBase( _rModel.getMutex( OClickableImageBaseModel::GuardAccess() ) )
     156             :         {
     157           0 :             if ( NULL == _rModel.getImageProducer( OClickableImageBaseModel::GuardAccess() ) )
     158             :                 throw ::com::sun::star::lang::DisposedException(
     159             :                     OUString(),
     160             :                     static_cast< ::com::sun::star::form::XImageProducerSupplier* >( &_rModel )
     161           0 :                 );
     162           0 :         }
     163             :     };
     164             : 
     165             : 
     166             :     // OClickableImageBaseControl
     167             : 
     168             :     typedef ::cppu::ImplHelper3 <   ::com::sun::star::form::XApproveActionBroadcaster
     169             :                                 ,   ::com::sun::star::form::submission::XSubmission
     170             :                                 ,   ::com::sun::star::frame::XDispatchProviderInterception
     171             :                                 >   OClickableImageBaseControl_BASE;
     172             : 
     173             :     class OClickableImageBaseControl    :public OClickableImageBaseControl_BASE
     174             :                                         ,public OControl
     175             :     {
     176             :         friend class OImageProducerThread_Impl;
     177             : 
     178             :     private:
     179             :         OImageProducerThread_Impl*          m_pThread;
     180             :         ::cppu::OInterfaceContainerHelper   m_aSubmissionVetoListeners;
     181             :         ::std::unique_ptr< ControlFeatureInterception >
     182             :                                             m_pFeatureInterception;
     183             : 
     184             :     protected:
     185             :         ::cppu::OInterfaceContainerHelper m_aApproveActionListeners;
     186             :         ::cppu::OInterfaceContainerHelper m_aActionListeners;
     187             :         OUString m_aActionCommand;
     188             : 
     189             :         // XSubmission
     190             :         virtual void SAL_CALL submit(  ) throw (::com::sun::star::util::VetoException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     191             :         virtual void SAL_CALL submitWithInteraction( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler ) throw (::com::sun::star::util::VetoException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     192             :         virtual void SAL_CALL addSubmissionVetoListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmissionVetoListener >& listener ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     193             :         virtual void SAL_CALL removeSubmissionVetoListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::submission::XSubmissionVetoListener >& listener ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     194             : 
     195             :         // XServiceInfo
     196             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     197             : 
     198             :         // XEventListener
     199             :         using OControl::disposing;
     200             : 
     201             :     public:
     202             :         OClickableImageBaseControl(
     203             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory,
     204             :             const OUString& _aService);
     205             :         virtual ~OClickableImageBaseControl();
     206             : 
     207             :     protected:
     208             :         // UNO Binding
     209      213053 :         DECLARE_UNO3_AGG_DEFAULTS(OClickableImageBaseControl, OControl)
     210             :         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     211             : 
     212             :         // OComponentHelper
     213             :         virtual void SAL_CALL disposing() SAL_OVERRIDE;
     214             : 
     215             :         // ::com::sun::star::form::XApproveActionBroadcaster
     216             :         virtual void SAL_CALL addApproveActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XApproveActionListener>& _rxListener)
     217             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     218             :         virtual void SAL_CALL removeApproveActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XApproveActionListener>& _rxListener)
     219             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     220             : 
     221             :         // XDispatchProviderInterception
     222             :         virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     223             :         virtual void SAL_CALL releaseDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     224             : 
     225             :     protected:
     226             :         virtual void actionPerformed_Impl( bool bNotifyListener, const ::com::sun::star::awt::MouseEvent& rEvt );
     227             : 
     228             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > _getTypes() SAL_OVERRIDE;
     229             : 
     230             :         /** approves the action by calling the approve listeners
     231             :             @return <TRUE/> if and only if the action has <em>not</em> been cancelled by a listener
     232             :         */
     233             :         bool    approveAction( );
     234             : 
     235             :         /** retrieves (and if necessary creates) the image producer thread.
     236             : 
     237             :             Must be called with our mutex locked
     238             :         */
     239             :         OImageProducerThread_Impl* getImageProducerThread();
     240             : 
     241             :     private:
     242             :         void implSubmit(
     243             :             const ::com::sun::star::awt::MouseEvent& _rEvent,
     244             :             const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler
     245             :         );
     246             :     };
     247             : 
     248           0 :     class OImageProducerThread_Impl: public OComponentEventThread
     249             :     {
     250             :     protected:
     251             : 
     252             :         // This method was called to duplicate the Event by taking its type into account
     253             :         virtual ::com::sun::star::lang::EventObject* cloneEvent( const ::com::sun::star::lang::EventObject* _pEvt ) const SAL_OVERRIDE;
     254             : 
     255             :         // Process an Event.
     256             :         // The mutex is not locked, pCompImpl stays valid in any case
     257             :         virtual void processEvent( ::cppu::OComponentHelper *pCompImpl,
     258             :                                 const ::com::sun::star::lang::EventObject*,
     259             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>&,
     260             :                                 bool ) SAL_OVERRIDE;
     261             : 
     262             :     public:
     263           0 :         OImageProducerThread_Impl( OClickableImageBaseControl *pControl ) :
     264           0 :             OComponentEventThread( pControl )
     265           0 :         {}
     266             : 
     267           0 :         void addEvent() { ::com::sun::star::lang::EventObject aEvt; OComponentEventThread::addEvent( &aEvt ); }
     268             : 
     269             :     protected:
     270             :         using OComponentEventThread::addEvent;
     271             :     };
     272             : 
     273             : 
     274             : }   // namespace frm
     275             : 
     276             : 
     277             : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_CLICKABLEIMAGE_HXX
     278             : 
     279             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10