LCOV - code coverage report
Current view: top level - forms/source/component - ImageControl.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 5 6 83.3 %
Date: 2014-11-03 Functions: 10 11 90.9 %
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_IMAGECONTROL_HXX
      21             : #define INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX
      22             : 
      23             : #include "FormComponent.hxx"
      24             : #include "imgprod.hxx"
      25             : #include <com/sun/star/form/XImageProducerSupplier.hpp>
      26             : #include <com/sun/star/awt/XMouseListener.hpp>
      27             : #include <com/sun/star/util/XModifyBroadcaster.hpp>
      28             : #include <com/sun/star/graphic/XGraphicObject.hpp>
      29             : #include <comphelper/propmultiplex.hxx>
      30             : #include <cppuhelper/implbase2.hxx>
      31             : 
      32             : using namespace comphelper;
      33             : 
      34             : 
      35             : namespace frm
      36             : {
      37             : 
      38             : 
      39             : 
      40             : // OImageControlModel
      41             : 
      42             : typedef ::cppu::ImplHelper2 <   ::com::sun::star::form::XImageProducerSupplier
      43             :                             ,   ::com::sun::star::awt::XImageProducer
      44             :                             >   OImageControlModel_Base;
      45             : 
      46             : class OImageControlModel
      47             :                 :public OImageControlModel_Base
      48             :                 ,public OBoundControlModel
      49             : {
      50             :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer>    m_xImageProducer;
      51             :     ImageProducer*                                  m_pImageProducer;
      52             :     bool                                            m_bExternalGraphic;
      53             :     bool                                        m_bReadOnly;
      54             :     OUString                                 m_sImageURL;
      55             :     ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject >
      56             :                                                     m_xGraphicObject;
      57             :     OUString                                 m_sDocumentURL;
      58             : 
      59             : protected:
      60             :     // UNO Anbindung
      61             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
      62             : 
      63          24 :     inline ImageProducer* GetImageProducer() { return m_pImageProducer; }
      64             : 
      65             : public:
      66             :     DECLARE_DEFAULT_LEAF_XTOR( OImageControlModel );
      67             : 
      68             :     virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
      69             :     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;
      70             : 
      71             :     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 )
      72             :         throw(::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
      73             : 
      74             :     // UNO Anbindung
      75       43598 :     DECLARE_UNO3_AGG_DEFAULTS(OImageControlModel, OBoundControlModel)
      76             :     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;
      77             : 
      78             :     // XServiceInfo
      79          14 :     IMPLEMENTATION_NAME(OImageControlModel);
      80             :     virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
      81             : 
      82             :     // OComponentHelper
      83             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
      84             : 
      85             :     // XPersistObject
      86             :     virtual OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      87             :     virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      88             :     virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      89             : 
      90             :     // XImageProducerSupplier
      91             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> SAL_CALL getImageProducer() throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      92             : 
      93             :     // XImageProducer
      94             :     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;
      95             :     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;
      96             :     virtual void SAL_CALL startProduction(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      97             : 
      98             :     // OControlModel's property handling
      99             :     virtual void describeAggregateProperties(
     100             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
     101             :     ) const SAL_OVERRIDE;
     102             :     virtual void describeFixedProperties(
     103             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
     104             :     ) const SAL_OVERRIDE;
     105             : 
     106             :     // prevent method hiding
     107             :     using OBoundControlModel::disposing;
     108             :     using OBoundControlModel::getFastPropertyValue;
     109             : 
     110             : protected:
     111             :     // OBoundControlModel overridables
     112             :     virtual void            onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ) SAL_OVERRIDE;
     113             :     virtual void            onDisconnectedDbColumn() SAL_OVERRIDE;
     114             :     virtual ::com::sun::star::uno::Any
     115             :                             translateDbColumnToControlValue( ) SAL_OVERRIDE;
     116             :     virtual bool            commitControlValueToDbColumn( bool _bPostReset ) SAL_OVERRIDE;
     117             : 
     118             :     virtual ::com::sun::star::uno::Any
     119             :                             getControlValue( ) const SAL_OVERRIDE;
     120             :     virtual void            doSetControlValue( const ::com::sun::star::uno::Any& _rValue ) SAL_OVERRIDE;
     121             : 
     122             :     virtual bool            approveDbColumnType(sal_Int32 _nColumnType) SAL_OVERRIDE;
     123             : 
     124             :     virtual void            resetNoBroadcast() SAL_OVERRIDE;
     125             : 
     126             : protected:
     127             :     virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     128             : 
     129             :     void implConstruct();
     130             : 
     131             :     /** displays the image described by the given URL
     132             :         @precond
     133             :             our own mutex is locked
     134             :     */
     135             :     bool    impl_handleNewImageURL_lck( ValueChangeInstigator _eInstigator );
     136             : 
     137             :     /** updates the binary stream, created from loading the file which the given URL points to, into our
     138             :         bound field, or the control itself if there is no bound field
     139             :     */
     140             :     bool    impl_updateStreamForURL_lck( const OUString& _rURL, ValueChangeInstigator _eInstigator );
     141             : 
     142             :     DECL_LINK( OnImageImportDone, ::Graphic* );
     143             : };
     144             : 
     145             : typedef ::cppu::ImplHelper2 <   ::com::sun::star::awt::XMouseListener
     146             :                             ,   ::com::sun::star::util::XModifyBroadcaster
     147             :                             >   OImageControlControl_Base;
     148           4 : class OImageControlControl  : public OBoundControl
     149             :                             , public OImageControlControl_Base
     150             : {
     151             : private:
     152             :     ::cppu::OInterfaceContainerHelper   m_aModifyListeners;
     153             : 
     154             :     // XTypeProvider
     155             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
     156             : 
     157             : public:
     158             :     OImageControlControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
     159             : 
     160             :     // UNO
     161        2146 :     DECLARE_UNO3_AGG_DEFAULTS( OImageControlControl, OBoundControl )
     162             :     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;
     163             : 
     164             :     // XEventListener
     165             :     virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             : 
     167             :     // XServiceInfo
     168           0 :     IMPLEMENTATION_NAME(OImageControlControl);
     169             :     virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
     170             : 
     171             :     // XMouseListener
     172             :     virtual void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     173             :     virtual void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     174             :     virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     175             :     virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     176             : 
     177             :     // XModifyBroadcaster
     178             :     virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     179             :     virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     180             : 
     181             :     // OComponentHelper
     182             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     183             : 
     184             : private:
     185             :     void    implClearGraphics( bool _bForce );
     186             :     bool    implInsertGraphics();
     187             : 
     188             :     /** determines whether the control does currently have an empty grahic set
     189             :     */
     190             :     bool    impl_isEmptyGraphics_nothrow() const;
     191             : };
     192             : 
     193             : 
     194             : }   // namespace frm
     195             : 
     196             : 
     197             : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX
     198             : 
     199             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10