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

Generated by: LCOV version 1.10