LCOV - code coverage report
Current view: top level - libreoffice/forms/source/component - clickableimage.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 20 5.0 %
Date: 2012-12-27 Functions: 3 19 15.8 %
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 FORMS_SOURCE_CLICKABLEIMAGE_HXX
      21             : #define FORMS_SOURCE_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;      // Art des Buttons (push,submit,reset)
      62             :         ::rtl::OUString                         m_sTargetURL;       // URL fuer den URL-Button
      63             :         ::rtl::OUString                         m_sTargetFrame;     // TargetFrame zum Oeffnen
      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             :         sal_Bool                                m_bDispatchUrlInternal; // property: is not allowed to set : 1
      70             :         sal_Bool                                m_bDownloading : 1; // laeuft ein Download?
      71             :         sal_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           0 :         inline ImageProducer* GetImageProducer() { return m_pProducer; }
      80             : 
      81             :         void StartProduction();
      82             :         void SetURL(const ::rtl::OUString& rURL);
      83             :         void DataAvailable();
      84             :         void DownloadDone();
      85             : 
      86             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
      87           0 :         inline sal_Bool isDispatchUrlInternal() const { return m_bDispatchUrlInternal; }
      88           0 :         inline void     setDispatchUrlInternal(sal_Bool _bDispatch) { m_bDispatchUrlInternal = _bDispatch; }
      89             : 
      90             :     public:
      91             :         DECLARE_DEFAULT_XTOR( OClickableImageBaseModel );
      92             : 
      93             :         // UNO Anbindung
      94        2601 :         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);
      96             : 
      97             :     protected:
      98             :         // OComponentHelper
      99             :         virtual void SAL_CALL disposing();
     100             : 
     101             :         // ::com::sun::star::form::XImageProducerSupplier
     102           0 :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> SAL_CALL getImageProducer() throw (::com::sun::star::uno::RuntimeException) { return m_xProducer; }
     103             : 
     104             :         // OPropertySetHelper
     105             :         virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
     106             :         virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
     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);
     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);
     115             : 
     116             :         // XPropertyState
     117             :         virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
     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);
     121             :         virtual void SAL_CALL removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException);
     122             :         virtual void SAL_CALL startProduction(  ) throw (::com::sun::star::uno::RuntimeException);
     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);
     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);
     127             : 
     128             :         // XServiceInfo
     129             :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
     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             :     //==================================================================
     149             :     // ImageModelMethodGuard
     150             :     //==================================================================
     151           0 :     class ImageModelMethodGuard : public ::osl::MutexGuard
     152             :     {
     153             :     private:
     154             :         typedef ::osl::MutexGuard   GuardBase;
     155             : 
     156             :     public:
     157           0 :         ImageModelMethodGuard( OClickableImageBaseModel& _rModel )
     158           0 :             :GuardBase( _rModel.getMutex( OClickableImageBaseModel::GuardAccess() ) )
     159             :         {
     160           0 :             if ( NULL == _rModel.getImageProducer( OClickableImageBaseModel::GuardAccess() ) )
     161             :                 throw ::com::sun::star::lang::DisposedException(
     162             :                     ::rtl::OUString(),
     163             :                     static_cast< ::com::sun::star::form::XImageProducerSupplier* >( &_rModel )
     164           0 :                 );
     165           0 :         }
     166             :     };
     167             : 
     168             :     //==================================================================
     169             :     // OClickableImageBaseControl
     170             :     //==================================================================
     171             :     typedef ::cppu::ImplHelper3 <   ::com::sun::star::form::XApproveActionBroadcaster
     172             :                                 ,   ::com::sun::star::form::submission::XSubmission
     173             :                                 ,   ::com::sun::star::frame::XDispatchProviderInterception
     174             :                                 >   OClickableImageBaseControl_BASE;
     175             : 
     176             :     class OClickableImageBaseControl    :public OClickableImageBaseControl_BASE
     177             :                                         ,public OControl
     178             :     {
     179             :         friend class OImageProducerThread_Impl;
     180             : 
     181             :     private:
     182             :         OImageProducerThread_Impl*          m_pThread;
     183             :         ::cppu::OInterfaceContainerHelper   m_aSubmissionVetoListeners;
     184             :         ::std::auto_ptr< ControlFeatureInterception >
     185             :                                             m_pFeatureInterception;
     186             : 
     187             :     protected:
     188             :         ::cppu::OInterfaceContainerHelper m_aApproveActionListeners;
     189             :         ::cppu::OInterfaceContainerHelper m_aActionListeners;
     190             :         ::rtl::OUString m_aActionCommand;
     191             : 
     192             :         // XSubmission
     193             :         virtual void SAL_CALL submit(  ) throw (::com::sun::star::util::VetoException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     194             :         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);
     195             :         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);
     196             :         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);
     197             : 
     198             :         // XServiceInfo
     199             :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
     200             : 
     201             :         // XEventListener
     202             :         using OControl::disposing;
     203             : 
     204             :     public:
     205             :         OClickableImageBaseControl(
     206             :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory,
     207             :             const ::rtl::OUString& _aService);
     208             :         virtual ~OClickableImageBaseControl();
     209             : 
     210             :     protected:
     211             :         // UNO Anbindung
     212           0 :         DECLARE_UNO3_AGG_DEFAULTS(OClickableImageBaseControl, OControl);
     213             :         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
     214             : 
     215             :         // OComponentHelper
     216             :         virtual void SAL_CALL disposing();
     217             : 
     218             :         // ::com::sun::star::form::XApproveActionBroadcaster
     219             :         virtual void SAL_CALL addApproveActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XApproveActionListener>& _rxListener)
     220             :             throw(::com::sun::star::uno::RuntimeException);
     221             :         virtual void SAL_CALL removeApproveActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XApproveActionListener>& _rxListener)
     222             :             throw(::com::sun::star::uno::RuntimeException);
     223             : 
     224             :         // XDispatchProviderInterception
     225             :         virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
     226             :         virtual void SAL_CALL releaseDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
     227             : 
     228             :     protected:
     229             :         virtual void actionPerformed_Impl( sal_Bool bNotifyListener, const ::com::sun::star::awt::MouseEvent& rEvt );
     230             : 
     231             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > _getTypes();
     232             : 
     233             :         /** approves the action by calling the approve listeners
     234             :             @return <TRUE/> if and only if the action has <em>not</em> been cancelled by a listener
     235             :         */
     236             :         bool    approveAction( );
     237             : 
     238             :         /** retrieves (and if necessary creates) the image producer thread.
     239             : 
     240             :             Must be called with our mutex locked
     241             :         */
     242             :         OImageProducerThread_Impl* getImageProducerThread();
     243             : 
     244             :     private:
     245             :         void implSubmit(
     246             :             const ::com::sun::star::awt::MouseEvent& _rEvent,
     247             :             const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler
     248             :         ) SAL_THROW((com::sun::star::util::VetoException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException));
     249             :     };
     250             : 
     251             :     //==================================================================
     252             :     // OImageProducerThread_Impl
     253             :     //==================================================================
     254           0 :     class OImageProducerThread_Impl: public OComponentEventThread
     255             :     {
     256             :     protected:
     257             : 
     258             :         // Die folgende Methode wrrd gerufen um das Event unter Beruecksichtigung
     259             :         // seines Typs zu duplizieren
     260             :         virtual ::com::sun::star::lang::EventObject* cloneEvent( const ::com::sun::star::lang::EventObject* _pEvt ) const;
     261             : 
     262             :         // Ein Event bearbeiten. Der Mutex ist dabei nicht gelockt, pCompImpl
     263             :         // bleibt aber in jedem Fall gueltig.
     264             :         virtual void processEvent( ::cppu::OComponentHelper *pCompImpl,
     265             :                                 const ::com::sun::star::lang::EventObject*,
     266             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>&,
     267             :                                 sal_Bool );
     268             : 
     269             :     public:
     270           0 :         OImageProducerThread_Impl( OClickableImageBaseControl *pControl ) :
     271           0 :             OComponentEventThread( pControl )
     272           0 :         {}
     273             : 
     274           0 :         void addEvent() { ::com::sun::star::lang::EventObject aEvt; OComponentEventThread::addEvent( &aEvt ); }
     275             : 
     276             :     protected:
     277             :         using OComponentEventThread::addEvent;
     278             :     };
     279             : 
     280             : //.........................................................................
     281             : }   // namespace frm
     282             : //.........................................................................
     283             : 
     284             : #endif // FORMS_SOURCE_CLICKABLEIMAGE_HXX
     285             : 
     286             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10