LCOV - code coverage report
Current view: top level - libreoffice/forms/source/component - ImageButton.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 101 0.0 %
Date: 2012-12-27 Functions: 0 20 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             : #include "ImageButton.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include <tools/urlobj.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <osl/mutex.hxx>
      25             : #include <comphelper/basicio.hxx>
      26             : #include <com/sun/star/awt/MouseButton.hpp>
      27             : 
      28             : //.........................................................................
      29             : namespace frm
      30             : {
      31             : //.........................................................................
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::sdb;
      35             : using namespace ::com::sun::star::sdbc;
      36             : using namespace ::com::sun::star::sdbcx;
      37             : using namespace ::com::sun::star::beans;
      38             : using namespace ::com::sun::star::container;
      39             : using namespace ::com::sun::star::form;
      40             : using namespace ::com::sun::star::io;
      41             : using namespace ::com::sun::star::lang;
      42             : using namespace ::com::sun::star::util;
      43             : 
      44             : //==================================================================
      45             : //= OImageButtonModel
      46             : //==================================================================
      47             : DBG_NAME(OImageButtonModel)
      48             : //------------------------------------------------------------------
      49           0 : InterfaceRef SAL_CALL OImageButtonModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      50             : {
      51           0 :      return *(new OImageButtonModel(_rxFactory));
      52             : }
      53             : 
      54             : //------------------------------------------------------------------
      55           0 : OImageButtonModel::OImageButtonModel(const Reference<XMultiServiceFactory>& _rxFactory)
      56           0 :                     :OClickableImageBaseModel( _rxFactory, VCL_CONTROLMODEL_IMAGEBUTTON, FRM_SUN_CONTROL_IMAGEBUTTON )
      57             :                                     // use the old control name for compytibility reasons
      58             : {
      59             :     DBG_CTOR(OImageButtonModel, NULL);
      60           0 :     m_nClassId = FormComponentType::IMAGEBUTTON;
      61           0 : }
      62             : 
      63             : //------------------------------------------------------------------
      64           0 : OImageButtonModel::OImageButtonModel( const OImageButtonModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory)
      65           0 :     :OClickableImageBaseModel( _pOriginal, _rxFactory )
      66             : {
      67             :     DBG_CTOR(OImageButtonModel, NULL);
      68           0 :     implInitializeImageURL();
      69           0 : }
      70             : 
      71             : //------------------------------------------------------------------------------
      72           0 : IMPLEMENT_DEFAULT_CLONING( OImageButtonModel )
      73             : 
      74             : //------------------------------------------------------------------------------
      75           0 : OImageButtonModel::~OImageButtonModel()
      76             : {
      77             :     DBG_DTOR(OImageButtonModel, NULL);
      78           0 : }
      79             : 
      80             : // XServiceInfo
      81             : //------------------------------------------------------------------------------
      82           0 : StringSequence  OImageButtonModel::getSupportedServiceNames() throw()
      83             : {
      84           0 :     StringSequence aSupported = OClickableImageBaseModel::getSupportedServiceNames();
      85           0 :     aSupported.realloc(aSupported.getLength() + 1);
      86             : 
      87           0 :     ::rtl::OUString*pArray = aSupported.getArray();
      88           0 :     pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_IMAGEBUTTON;
      89           0 :     return aSupported;
      90             : }
      91             : 
      92             : //------------------------------------------------------------------------------
      93           0 : void OImageButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const
      94             : {
      95           0 :     BEGIN_DESCRIBE_PROPERTIES( 5, OClickableImageBaseModel )
      96           0 :         DECL_PROP1(BUTTONTYPE,          FormButtonType,     BOUND);
      97           0 :         DECL_PROP1(DISPATCHURLINTERNAL, sal_Bool,           BOUND);
      98           0 :         DECL_PROP1(TARGET_URL,          ::rtl::OUString,    BOUND);
      99           0 :         DECL_PROP1(TARGET_FRAME,        ::rtl::OUString,    BOUND);
     100           0 :         DECL_PROP1(TABINDEX,            sal_Int16,          BOUND);
     101             :     END_DESCRIBE_PROPERTIES();
     102           0 : }
     103             : 
     104             : //------------------------------------------------------------------------------
     105           0 : ::rtl::OUString OImageButtonModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
     106             : {
     107           0 :     return FRM_COMPONENT_IMAGEBUTTON;   // old (non-sun) name for compatibility !
     108             : }
     109             : 
     110             : //------------------------------------------------------------------------------
     111           0 : void OImageButtonModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
     112             : {
     113           0 :     OControlModel::write(_rxOutStream);
     114             : 
     115             :     // Version
     116           0 :     _rxOutStream->writeShort(0x0003);
     117           0 :     _rxOutStream->writeShort((sal_uInt16)m_eButtonType);
     118             : 
     119           0 :     ::rtl::OUString sTmp(INetURLObject::decode( m_sTargetURL, '%', INetURLObject::DECODE_UNAMBIGUOUS));
     120           0 :     _rxOutStream << sTmp;
     121           0 :     _rxOutStream << m_sTargetFrame;
     122           0 :     writeHelpTextCompatibly(_rxOutStream);
     123           0 : }
     124             : 
     125             : //------------------------------------------------------------------------------
     126           0 : void OImageButtonModel::read(const Reference<XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
     127             : {
     128           0 :     OControlModel::read(_rxInStream);
     129             : 
     130             :     // Version
     131           0 :     sal_uInt16 nVersion = _rxInStream->readShort();
     132             : 
     133           0 :     switch (nVersion)
     134             :     {
     135             :         case 0x0001:
     136             :         {
     137           0 :             m_eButtonType = (FormButtonType)_rxInStream->readShort();
     138             :         }
     139           0 :         break;
     140             :         case 0x0002:
     141             :         {
     142           0 :             m_eButtonType = (FormButtonType)_rxInStream->readShort();
     143           0 :             _rxInStream >> m_sTargetURL;
     144           0 :             _rxInStream >> m_sTargetFrame;
     145             :         }
     146           0 :         break;
     147             :         case 0x0003:
     148             :         {
     149           0 :             m_eButtonType = (FormButtonType)_rxInStream->readShort();
     150           0 :             _rxInStream >> m_sTargetURL;
     151           0 :             _rxInStream >> m_sTargetFrame;
     152           0 :             readHelpTextCompatibly(_rxInStream);
     153             :         }
     154           0 :         break;
     155             : 
     156             :         default :
     157             :             OSL_FAIL("OImageButtonModel::read : unknown version !");
     158           0 :             m_eButtonType = FormButtonType_PUSH;
     159           0 :             m_sTargetURL = ::rtl::OUString();
     160           0 :             m_sTargetFrame = ::rtl::OUString();
     161           0 :             break;
     162             :     }
     163           0 : }
     164             : 
     165             : //==================================================================
     166             : // OImageButtonControl
     167             : //==================================================================
     168             : //------------------------------------------------------------------
     169           0 : InterfaceRef SAL_CALL OImageButtonControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
     170             : {
     171           0 :     return *(new OImageButtonControl(_rxFactory));
     172             : }
     173             : 
     174             : //------------------------------------------------------------------------------
     175           0 : Sequence<Type> OImageButtonControl::_getTypes()
     176             : {
     177           0 :     static Sequence<Type> aTypes;
     178           0 :     if (!aTypes.getLength())
     179           0 :         aTypes = concatSequences(OClickableImageBaseControl::_getTypes(), OImageButtonControl_BASE::getTypes());
     180           0 :     return aTypes;
     181             : }
     182             : 
     183             : //------------------------------------------------------------------------------
     184           0 : StringSequence  OImageButtonControl::getSupportedServiceNames() throw()
     185             : {
     186           0 :     StringSequence aSupported = OClickableImageBaseControl::getSupportedServiceNames();
     187           0 :     aSupported.realloc(aSupported.getLength() + 1);
     188             : 
     189           0 :     ::rtl::OUString*pArray = aSupported.getArray();
     190           0 :     pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_IMAGEBUTTON;
     191           0 :     return aSupported;
     192             : }
     193             : 
     194             : //------------------------------------------------------------------------------
     195           0 : OImageButtonControl::OImageButtonControl(const Reference<XMultiServiceFactory>& _rxFactory)
     196           0 :             :OClickableImageBaseControl(_rxFactory, VCL_CONTROL_IMAGEBUTTON)
     197             : {
     198           0 :     increment(m_refCount);
     199             :     {
     200             :         // als MouseListener anmelden
     201           0 :         Reference< awt::XWindow >  xComp;
     202           0 :         query_aggregation( m_xAggregate, xComp);
     203           0 :         if (xComp.is())
     204           0 :             xComp->addMouseListener( static_cast< awt::XMouseListener* >( this ) );
     205             :     }
     206           0 :     decrement(m_refCount);
     207           0 : }
     208             : 
     209             : // UNO Anbindung
     210             : //------------------------------------------------------------------------------
     211           0 : Any SAL_CALL OImageButtonControl::queryAggregation(const Type& _rType) throw (RuntimeException)
     212             : {
     213           0 :     Any aReturn = OClickableImageBaseControl::queryAggregation(_rType);
     214           0 :     if (!aReturn.hasValue())
     215           0 :         aReturn = OImageButtonControl_BASE::queryInterface(_rType);
     216             : 
     217           0 :     return aReturn;
     218             : }
     219             : 
     220             : //------------------------------------------------------------------------------
     221           0 : void OImageButtonControl::mousePressed(const awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException)
     222             : {
     223           0 :     SolarMutexGuard aSolarGuard;
     224             : 
     225           0 :     if (e.Buttons != awt::MouseButton::LEFT)
     226           0 :         return;
     227             : 
     228           0 :     ::osl::ClearableMutexGuard aGuard( m_aMutex );
     229           0 :     if( m_aApproveActionListeners.getLength() )
     230             :     {
     231             :         // if there are listeners, start the action in an own thread, to not allow
     232             :         // them to block us here (we're in the application's main thread)
     233           0 :         getImageProducerThread()->OComponentEventThread::addEvent( &e );
     234             :     }
     235             :     else
     236             :     {
     237             :         // Sonst nicht. Dann darf man aber auf keinen Fal die Listener
     238             :         // benachrichtigen, auch dann nicht, wenn er spaeter hinzukommt.
     239           0 :         aGuard.clear();
     240           0 :         actionPerformed_Impl( sal_False, e );
     241           0 :     }
     242             : }
     243             : 
     244             : //------------------------------------------------------------------------------
     245           0 : void SAL_CALL OImageButtonControl::mouseReleased(const awt::MouseEvent& /*e*/) throw ( RuntimeException)
     246             : {
     247           0 : }
     248             : 
     249             : //------------------------------------------------------------------------------
     250           0 : void SAL_CALL OImageButtonControl::mouseEntered(const awt::MouseEvent& /*e*/) throw ( RuntimeException)
     251             : {
     252           0 : }
     253             : 
     254             : //------------------------------------------------------------------------------
     255           0 : void SAL_CALL OImageButtonControl::mouseExited(const awt::MouseEvent& /*e*/) throw ( RuntimeException)
     256             : {
     257           0 : }
     258             : 
     259             : 
     260             : //.........................................................................
     261             : }   // namespace frm
     262             : //.........................................................................
     263             : 
     264             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10