LCOV - code coverage report
Current view: top level - extensions/source/plugin/base - plmodel.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 76 7.9 %
Date: 2015-06-13 12:38:46 Functions: 3 21 14.3 %
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             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      12             :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13             :  * it under the terms of the GNU Lesser General Public License version 3
      14             :  * only, as published by the Free Software Foundation.
      15             :  *
      16             :  * OpenOffice.org is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU Lesser General Public License version 3 for more details
      20             :  * (a copy is included in the LICENSE file that accompanied this code).
      21             :  *
      22             :  * You should have received a copy of the GNU Lesser General Public License
      23             :  * version 3 along with OpenOffice.org.  If not, see
      24             :  * <http://www.openoffice.org/license.html>
      25             :  * for a copy of the LGPLv3 License.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : #include <plugin/model.hxx>
      30             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      31             : #include <cppuhelper/queryinterface.hxx>
      32             : 
      33             : using namespace com::sun::star::uno;
      34             : 
      35             : 
      36           0 : Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory >  & ) throw( Exception )
      37             : {
      38           0 :     Reference< XInterface >  xService = *new PluginModel();
      39           0 :     return xService;
      40             : }
      41             : 
      42           0 : Any PluginModel::queryAggregation( const Type& type ) throw( RuntimeException, std::exception )
      43             : {
      44             :     Any aRet( ::cppu::queryInterface( type,
      45             :                                       static_cast< ::com::sun::star::lang::XComponent* >(this),
      46             :                                       static_cast< ::com::sun::star::io::XPersistObject* >(this ),
      47             :                                       static_cast< ::com::sun::star::awt::XControlModel* >(this),
      48             :                                       static_cast< ::com::sun::star::beans::XPropertySet* >(this),
      49             :                                       static_cast< ::com::sun::star::beans::XMultiPropertySet* >(this),
      50             :                                       static_cast< ::com::sun::star::beans::XFastPropertySet* >(this)
      51           0 :         ) );
      52           0 :     return aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( type );
      53             : }
      54             : 
      55             : 
      56             : // XPluginManager_Impl
      57           0 : Sequence< OUString > PluginModel::getSupportedServiceNames_Static() throw()
      58             : {
      59           0 :     Sequence< OUString > aSNS( 1 );
      60           0 :     aSNS[0] = "com.sun.star.plugin.PluginModel";
      61           0 :     return aSNS;
      62             : }
      63             : 
      64             : 
      65             : static const char* aCreationURL = "URL";
      66             : static const char* aMime = "TYPE";
      67             : 
      68           1 : static ::osl::Mutex aPropertyMutex;
      69             : 
      70           2 : static ::com::sun::star::beans::Property aProps[] =
      71             : {
      72             :     ::com::sun::star::beans::Property(
      73             :         OUString::createFromAscii( aMime ),
      74             :         1,
      75           1 :         ::cppu::UnoType<OUString>::get(),
      76             :         ::com::sun::star::beans::PropertyAttribute::BOUND ),
      77             :     ::com::sun::star::beans::Property(
      78             :         OUString::createFromAscii( aCreationURL ),
      79             :         2,
      80           1 :         ::cppu::UnoType<OUString>::get(),
      81             :         ::com::sun::star::beans::PropertyAttribute::BOUND )
      82           3 : };
      83             : 
      84           0 : PluginModel::PluginModel() :
      85             :         BroadcasterHelperHolder( aPropertyMutex ),
      86             :         OPropertySetHelper( m_aHelper ),
      87           0 :         OPropertyArrayHelper( aProps, 2 )
      88             : {
      89           0 : }
      90             : 
      91           0 : PluginModel::PluginModel(const OUString& rURL, const OUString& rMimeType ) :
      92             :         BroadcasterHelperHolder( aPropertyMutex ),
      93             :         OPropertySetHelper( m_aHelper ),
      94             :         OPropertyArrayHelper( aProps, 2 ),
      95             :         m_aCreationURL( rURL ),
      96           0 :         m_aMimeType( rMimeType )
      97             : {
      98           0 : }
      99             : 
     100           0 : PluginModel::~PluginModel()
     101             : {
     102           0 : }
     103             : 
     104           0 : Reference< ::com::sun::star::beans::XPropertySetInfo >  PluginModel::getPropertySetInfo() throw(std::exception)
     105             : {
     106             :     static Reference< ::com::sun::star::beans::XPropertySetInfo > aInfo =
     107           0 :         createPropertySetInfo( *this );
     108           0 :     return aInfo;
     109             : }
     110             : 
     111           0 : ::cppu::IPropertyArrayHelper& PluginModel::getInfoHelper()
     112             : {
     113           0 :     return *this;
     114             : }
     115             : 
     116           0 : sal_Bool PluginModel::convertFastPropertyValue( Any & rConvertedValue,
     117             :                                                 Any & rOldValue,
     118             :                                                 sal_Int32 nHandle,
     119             :                                                 const Any& rValue ) throw()
     120             : {
     121           0 :     if( nHandle == 1 || nHandle == 2 )
     122             :     {
     123           0 :         if( rValue.getValueTypeClass() == TypeClass_STRING )
     124             :         {
     125           0 :             rConvertedValue = rValue;
     126           0 :             if( nHandle == 2 )
     127           0 :                 rOldValue <<= m_aCreationURL;
     128           0 :             else if( nHandle == 1 )
     129           0 :                 rOldValue <<= m_aMimeType;
     130           0 :             return sal_True;
     131             :         }
     132             :     }
     133           0 :     return sal_False;
     134             : }
     135             : 
     136           0 : void PluginModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
     137             :                                                     const Any& rValue )
     138             :     throw(::com::sun::star::uno::Exception, std::exception)
     139             : {
     140           0 :     if( rValue.getValueTypeClass() == TypeClass_STRING ) // FIXME wrong type!
     141             : 
     142             :     {
     143           0 :         if( nHandle == 2 )
     144           0 :             rValue >>= m_aCreationURL;
     145           0 :         else if( nHandle == 1 )
     146           0 :             rValue >>= m_aMimeType;
     147             :     }
     148             :     else
     149           0 :         throw ::com::sun::star::lang::IllegalArgumentException();
     150           0 : }
     151             : 
     152           0 : void PluginModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw()
     153             : {
     154           0 :     if( nHandle == 2 )
     155           0 :         rValue <<= m_aCreationURL;
     156           0 :     else if( nHandle == 1 )
     157           0 :         rValue <<= m_aMimeType;
     158           0 : }
     159             : 
     160             : //---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
     161           0 : void PluginModel::addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) throw(std::exception)
     162             : {
     163           0 :     m_aDisposeListeners.push_back( l );
     164           0 : }
     165             : 
     166             : //---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
     167           0 : void PluginModel::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) throw(std::exception)
     168             : {
     169           0 :     m_aDisposeListeners.remove( l );
     170           0 : }
     171             : 
     172             : //---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
     173           0 : void PluginModel::dispose() throw(std::exception)
     174             : {
     175             :     // send disposing events
     176           0 :     ::com::sun::star::lang::EventObject aEvt;
     177           0 :     aEvt.Source = static_cast<cppu::OWeakObject*>(this);
     178           0 :     ::std::list< Reference< ::com::sun::star::lang::XEventListener > > aLocalListeners = m_aDisposeListeners;
     179           0 :     for( ::std::list< Reference< ::com::sun::star::lang::XEventListener > >::iterator it = aLocalListeners.begin();
     180           0 :          it != aLocalListeners.end(); ++it )
     181           0 :         (*it)->disposing( aEvt );
     182             : 
     183           0 :     m_aDisposeListeners.clear();
     184             : 
     185           0 :     disposing();
     186           0 : }
     187             : 
     188             : 
     189             : // ::com::sun::star::io::XPersistObject
     190           0 : OUString PluginModel::getServiceName() throw(std::exception)
     191             : {
     192           0 :     return OUString("com.sun.star.plugin.PluginModel");
     193             : }
     194             : 
     195           0 : void PluginModel::write(const Reference< ::com::sun::star::io::XObjectOutputStream > & OutStream) throw(std::exception)
     196             : {
     197           0 :     OutStream->writeUTF( m_aCreationURL );
     198           0 : }
     199             : 
     200           0 : void PluginModel::read(const Reference< ::com::sun::star::io::XObjectInputStream > & InStream) throw(std::exception)
     201             : {
     202           0 :     m_aCreationURL = InStream->readUTF();
     203           3 : }
     204             : 
     205             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11