LCOV - code coverage report
Current view: top level - framework/source/fwe/classes - rootactiontriggercontainer.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 121 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 26 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 <classes/rootactiontriggercontainer.hxx>
      21             : #include <classes/actiontriggercontainer.hxx>
      22             : #include <classes/actiontriggerpropertyset.hxx>
      23             : #include <classes/actiontriggerseparatorpropertyset.hxx>
      24             : #include <cppuhelper/supportsservice.hxx>
      25             : #include <cppuhelper/queryinterface.hxx>
      26             : #include <cppuhelper/typeprovider.hxx>
      27             : #include <framework/actiontriggerhelper.hxx>
      28             : #include <osl/mutex.hxx>
      29             : #include <vcl/svapp.hxx>
      30             : 
      31             : using namespace cppu;
      32             : using namespace com::sun::star::uno;
      33             : using namespace com::sun::star::lang;
      34             : using namespace com::sun::star::container;
      35             : using namespace com::sun::star::beans;
      36             : 
      37             : namespace framework
      38             : {
      39             : 
      40           0 : static Sequence< sal_Int8 > impl_getStaticIdentifier()
      41             : {
      42             :     static const sal_uInt8 pGUID[16] = { 0x17, 0x0F, 0xA2, 0xC9, 0xCA, 0x50, 0x4A, 0xD3, 0xA6, 0x3B, 0x39, 0x99, 0xC5, 0x96, 0x43, 0x27 };
      43           0 :     static ::com::sun::star::uno::Sequence< sal_Int8 > seqID(reinterpret_cast<const sal_Int8*>(pGUID), 16);
      44           0 :     return seqID;
      45             : }
      46             : 
      47           0 : RootActionTriggerContainer::RootActionTriggerContainer( const Menu* pMenu, const OUString* pMenuIdentifier ) :
      48             :     PropertySetContainer()
      49             :     ,   m_bContainerCreated( false )
      50             :     ,   m_bContainerChanged( false )
      51             :     ,   m_bInContainerCreation( false )
      52             :     ,   m_pMenu( pMenu )
      53           0 :     ,   m_pMenuIdentifier( pMenuIdentifier )
      54             : {
      55           0 : }
      56             : 
      57           0 : RootActionTriggerContainer::~RootActionTriggerContainer()
      58             : {
      59           0 : }
      60             : 
      61             : // XInterface
      62           0 : Any SAL_CALL RootActionTriggerContainer::queryInterface( const Type& aType )
      63             : throw ( RuntimeException, std::exception )
      64             : {
      65             :     Any a = ::cppu::queryInterface(
      66             :                 aType ,
      67             :                 (static_cast< XMultiServiceFactory*   >(this)),
      68             :                 (static_cast< XServiceInfo*           >(this)),
      69             :                 (static_cast< XUnoTunnel*             >(this)),
      70             :                 (static_cast< XTypeProvider*          >(this)),
      71           0 :                 (static_cast< XNamed*                 >(this)));
      72             : 
      73           0 :     if( a.hasValue() )
      74             :     {
      75           0 :         return a;
      76             :     }
      77             : 
      78           0 :     return PropertySetContainer::queryInterface( aType );
      79             : }
      80             : 
      81           0 : void SAL_CALL RootActionTriggerContainer::acquire() throw ()
      82             : {
      83           0 :     PropertySetContainer::acquire();
      84           0 : }
      85             : 
      86           0 : void SAL_CALL RootActionTriggerContainer::release() throw ()
      87             : {
      88           0 :     PropertySetContainer::release();
      89           0 : }
      90             : 
      91             : // XMultiServiceFactory
      92           0 : Reference< XInterface > SAL_CALL RootActionTriggerContainer::createInstance( const OUString& aServiceSpecifier )
      93             : throw ( Exception,  RuntimeException, std::exception )
      94             : {
      95           0 :     if ( aServiceSpecifier == SERVICENAME_ACTIONTRIGGER )
      96           0 :         return static_cast<OWeakObject *>( new ActionTriggerPropertySet());
      97           0 :     else if ( aServiceSpecifier == SERVICENAME_ACTIONTRIGGERCONTAINER )
      98           0 :         return static_cast<OWeakObject *>( new ActionTriggerContainer());
      99           0 :     else if ( aServiceSpecifier == SERVICENAME_ACTIONTRIGGERSEPARATOR )
     100           0 :         return static_cast<OWeakObject *>( new ActionTriggerSeparatorPropertySet());
     101             :     else
     102           0 :         throw com::sun::star::uno::RuntimeException("Unknown service specifier!", static_cast<OWeakObject *>(this) );
     103             : }
     104             : 
     105           0 : Reference< XInterface > SAL_CALL RootActionTriggerContainer::createInstanceWithArguments( const OUString& ServiceSpecifier, const Sequence< Any >& /*Arguments*/ )
     106             : throw ( Exception, RuntimeException, std::exception )
     107             : {
     108           0 :     return createInstance( ServiceSpecifier );
     109             : }
     110             : 
     111           0 : Sequence< OUString > SAL_CALL RootActionTriggerContainer::getAvailableServiceNames()
     112             : throw ( RuntimeException, std::exception )
     113             : {
     114           0 :     Sequence< OUString > aSeq( 3 );
     115             : 
     116           0 :     aSeq[0] = SERVICENAME_ACTIONTRIGGER;
     117           0 :     aSeq[1] = SERVICENAME_ACTIONTRIGGERCONTAINER;
     118           0 :     aSeq[2] = SERVICENAME_ACTIONTRIGGERSEPARATOR;
     119             : 
     120           0 :     return aSeq;
     121             : }
     122             : 
     123             : // XIndexContainer
     124           0 : void SAL_CALL RootActionTriggerContainer::insertByIndex( sal_Int32 Index, const Any& Element )
     125             : throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
     126             : {
     127           0 :     SolarMutexGuard g;
     128             : 
     129           0 :     if ( !m_bContainerCreated )
     130           0 :         FillContainer();
     131             : 
     132           0 :     if ( !m_bInContainerCreation )
     133           0 :         m_bContainerChanged = true;
     134           0 :     PropertySetContainer::insertByIndex( Index, Element );
     135           0 : }
     136             : 
     137           0 : void SAL_CALL RootActionTriggerContainer::removeByIndex( sal_Int32 Index )
     138             : throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
     139             : {
     140           0 :     SolarMutexGuard g;
     141             : 
     142           0 :     if ( !m_bContainerCreated )
     143           0 :         FillContainer();
     144             : 
     145           0 :     if ( !m_bInContainerCreation )
     146           0 :         m_bContainerChanged = true;
     147           0 :     PropertySetContainer::removeByIndex( Index );
     148           0 : }
     149             : 
     150             : // XIndexReplace
     151           0 : void SAL_CALL RootActionTriggerContainer::replaceByIndex( sal_Int32 Index, const Any& Element )
     152             : throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
     153             : {
     154           0 :     SolarMutexGuard g;
     155             : 
     156           0 :     if ( !m_bContainerCreated )
     157           0 :         FillContainer();
     158             : 
     159           0 :     if ( !m_bInContainerCreation )
     160           0 :         m_bContainerChanged = true;
     161           0 :     PropertySetContainer::replaceByIndex( Index, Element );
     162           0 : }
     163             : 
     164             : // XIndexAccess
     165           0 : sal_Int32 SAL_CALL RootActionTriggerContainer::getCount()
     166             : throw ( RuntimeException, std::exception )
     167             : {
     168           0 :     SolarMutexGuard g;
     169             : 
     170           0 :     if ( !m_bContainerCreated )
     171             :     {
     172           0 :         if ( m_pMenu )
     173             :         {
     174           0 :             SolarMutexGuard aSolarMutexGuard;
     175           0 :             return m_pMenu->GetItemCount();
     176             :         }
     177             :         else
     178           0 :             return 0;
     179             :     }
     180             :     else
     181             :     {
     182           0 :         return PropertySetContainer::getCount();
     183           0 :     }
     184             : }
     185             : 
     186           0 : Any SAL_CALL RootActionTriggerContainer::getByIndex( sal_Int32 Index )
     187             : throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
     188             : {
     189           0 :     SolarMutexGuard g;
     190             : 
     191           0 :     if ( !m_bContainerCreated )
     192           0 :         FillContainer();
     193             : 
     194           0 :     return PropertySetContainer::getByIndex( Index );
     195             : }
     196             : 
     197             : // XElementAccess
     198           0 : Type SAL_CALL RootActionTriggerContainer::getElementType()
     199             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     200             : {
     201           0 :     return cppu::UnoType<XPropertySet>::get();
     202             : }
     203             : 
     204           0 : sal_Bool SAL_CALL RootActionTriggerContainer::hasElements()
     205             : throw (::com::sun::star::uno::RuntimeException, std::exception)
     206             : {
     207           0 :     if ( m_pMenu )
     208             :     {
     209           0 :         SolarMutexGuard aSolarMutexGuard;
     210           0 :         return ( m_pMenu->GetItemCount() > 0 );
     211             :     }
     212             : 
     213           0 :     return sal_False;
     214             : }
     215             : 
     216             : // XServiceInfo
     217           0 : OUString SAL_CALL RootActionTriggerContainer::getImplementationName()
     218             : throw ( RuntimeException, std::exception )
     219             : {
     220           0 :     return OUString( IMPLEMENTATIONNAME_ROOTACTIONTRIGGERCONTAINER );
     221             : }
     222             : 
     223           0 : sal_Bool SAL_CALL RootActionTriggerContainer::supportsService( const OUString& ServiceName )
     224             : throw ( RuntimeException, std::exception )
     225             : {
     226           0 :     return cppu::supportsService(this, ServiceName);
     227             : }
     228             : 
     229           0 : Sequence< OUString > SAL_CALL RootActionTriggerContainer::getSupportedServiceNames()
     230             : throw ( RuntimeException, std::exception )
     231             : {
     232           0 :     Sequence< OUString > seqServiceNames( 1 );
     233             : 
     234           0 :     seqServiceNames[0] = SERVICENAME_ACTIONTRIGGERCONTAINER;
     235           0 :     return seqServiceNames;
     236             : }
     237             : 
     238             : // XUnoTunnel
     239           0 : sal_Int64 SAL_CALL RootActionTriggerContainer::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw ( RuntimeException, std::exception )
     240             : {
     241           0 :     if ( aIdentifier == impl_getStaticIdentifier() )
     242           0 :         return reinterpret_cast< sal_Int64 >( this );
     243             :     else
     244           0 :         return 0;
     245             : }
     246             : 
     247             : // XTypeProvider
     248           0 : Sequence< Type > SAL_CALL RootActionTriggerContainer::getTypes() throw ( RuntimeException, std::exception )
     249             : {
     250             :     // Optimize this method !
     251             :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     252             :     // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
     253             :     static ::cppu::OTypeCollection* pTypeCollection = NULL;
     254             : 
     255           0 :     if ( pTypeCollection == NULL )
     256             :     {
     257             :         // Ready for multithreading; get global mutex for first call of this method only! see before
     258           0 :         osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() );
     259             : 
     260             :         // Control these pointer again ... it can be, that another instance will be faster then these!
     261           0 :         if ( pTypeCollection == NULL )
     262             :         {
     263             :             // Create a static typecollection ...
     264             :             static ::cppu::OTypeCollection aTypeCollection(
     265           0 :                         cppu::UnoType<XMultiServiceFactory>::get(),
     266           0 :                         cppu::UnoType<XIndexContainer>::get(),
     267           0 :                         cppu::UnoType<XServiceInfo>::get(),
     268           0 :                         cppu::UnoType<XTypeProvider>::get(),
     269           0 :                         cppu::UnoType<XUnoTunnel>::get(),
     270           0 :                         cppu::UnoType<XNamed>::get());
     271             : 
     272             :             // ... and set his address to static pointer!
     273           0 :             pTypeCollection = &aTypeCollection;
     274           0 :         }
     275             :     }
     276             : 
     277           0 :     return pTypeCollection->getTypes();
     278             : }
     279             : 
     280           0 : Sequence< sal_Int8 > SAL_CALL RootActionTriggerContainer::getImplementationId() throw ( RuntimeException, std::exception )
     281             : {
     282           0 :     return css::uno::Sequence<sal_Int8>();
     283             : }
     284             : 
     285             : // private implementation helper
     286           0 : void RootActionTriggerContainer::FillContainer()
     287             : {
     288           0 :     m_bContainerCreated = true;
     289           0 :     m_bInContainerCreation = true;
     290           0 :     Reference<XIndexContainer> xXIndexContainer( static_cast<OWeakObject *>(this), UNO_QUERY );
     291             :     ActionTriggerHelper::FillActionTriggerContainerFromMenu(
     292             :         xXIndexContainer,
     293           0 :         m_pMenu );
     294           0 :     m_bInContainerCreation = false;
     295           0 : }
     296           0 : OUString RootActionTriggerContainer::getName() throw ( RuntimeException, std::exception )
     297             : {
     298           0 :     OUString sRet;
     299           0 :     if( m_pMenuIdentifier )
     300           0 :         sRet = *m_pMenuIdentifier;
     301           0 :     return sRet;
     302             : }
     303             : 
     304           0 : void RootActionTriggerContainer::setName( const OUString& ) throw ( RuntimeException, std::exception)
     305             : {
     306           0 :     throw RuntimeException();
     307             : }
     308             : }
     309             : 
     310             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11