LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/framework/factories - PresentationFactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 68 5.9 %
Date: 2012-12-27 Functions: 3 24 12.5 %
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             : 
      21             : #include "framework/PresentationFactory.hxx"
      22             : 
      23             : #include "framework/FrameworkHelper.hxx"
      24             : #include "DrawController.hxx"
      25             : #include "ViewShellBase.hxx"
      26             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      27             : #include <cppuhelper/compbase1.hxx>
      28             : #include <tools/diagnose_ex.h>
      29             : #include "slideshow.hxx"
      30             : 
      31             : using namespace ::com::sun::star;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::lang;
      34             : using namespace ::com::sun::star::drawing::framework;
      35             : 
      36             : using ::rtl::OUString;
      37             : using ::sd::framework::FrameworkHelper;
      38             : 
      39             : 
      40             : namespace sd { namespace framework {
      41             : 
      42             : namespace {
      43             : 
      44             : typedef ::cppu::WeakComponentImplHelper1 <lang::XInitialization> PresentationFactoryProviderInterfaceBase;
      45             : 
      46             : class PresentationFactoryProvider
      47             :     : protected MutexOwner,
      48             :       public PresentationFactoryProviderInterfaceBase
      49             : {
      50             : public:
      51             :     PresentationFactoryProvider (const Reference<XComponentContext>& rxContext);
      52             :     virtual ~PresentationFactoryProvider (void);
      53             : 
      54             :     virtual void SAL_CALL disposing (void);
      55             : 
      56             :     // XInitialization
      57             : 
      58             :     virtual void SAL_CALL initialize(
      59             :         const ::com::sun::star::uno::Sequence<com::sun::star::uno::Any>& aArguments)
      60             :         throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
      61             : };
      62             : 
      63             : 
      64             : 
      65             : 
      66             : typedef ::cppu::WeakComponentImplHelper1 <XView> PresentationViewInterfaceBase;
      67             : 
      68             : /** The PresentationView is not an actual view, it is a marker whose
      69             :     existence in a configuration indicates that a slideshow is running
      70             :     (in another application window).
      71             : */
      72             : class PresentationView
      73             :     : protected MutexOwner,
      74             :       public PresentationViewInterfaceBase
      75             : {
      76             : public:
      77           0 :     PresentationView (const Reference<XResourceId>& rxViewId)
      78           0 :         : PresentationViewInterfaceBase(maMutex),mxResourceId(rxViewId) {};
      79           0 :     virtual ~PresentationView (void) {};
      80             : 
      81             :     // XView
      82             : 
      83           0 :     virtual Reference<XResourceId> SAL_CALL getResourceId (void) throw (RuntimeException)
      84           0 :     { return mxResourceId; };
      85             : 
      86           0 :     virtual sal_Bool SAL_CALL isAnchorOnly (void) throw (RuntimeException)
      87           0 :     { return false; }
      88             : 
      89             : 
      90             : private:
      91             :     Reference<XResourceId> mxResourceId;
      92             : };
      93             : 
      94             : } // end of anonymous namespace.
      95             : 
      96             : 
      97             : 
      98             : 
      99             : //===== PresentationFactoryProvider service ===================================
     100             : 
     101           0 : Reference<XInterface> SAL_CALL PresentationFactoryProvider_createInstance (
     102             :     const Reference<XComponentContext>& rxContext)
     103             : {
     104           0 :     return Reference<XInterface>(static_cast<XWeak*>(new PresentationFactoryProvider(rxContext)));
     105             : }
     106             : 
     107             : 
     108             : 
     109             : 
     110           2 : ::rtl::OUString PresentationFactoryProvider_getImplementationName (void) throw(RuntimeException)
     111             : {
     112           2 :     return ::rtl::OUString("com.sun.star.comp.Draw.framework.PresentationFactoryProvider");
     113             : }
     114             : 
     115             : 
     116             : 
     117             : 
     118           0 : Sequence<rtl::OUString> SAL_CALL PresentationFactoryProvider_getSupportedServiceNames (void)
     119             :     throw (RuntimeException)
     120             : {
     121           0 :     static const ::rtl::OUString sServiceName("com.sun.star.drawing.framework.PresentationFactoryProvider");
     122           0 :     return Sequence<rtl::OUString>(&sServiceName, 1);
     123             : }
     124             : 
     125             : 
     126             : 
     127             : 
     128             : //===== PresentationFactory ===================================================
     129             : 
     130           3 : const ::rtl::OUString PresentationFactory::msPresentationViewURL("private:resource/view/Presentation");
     131             : 
     132             : 
     133           0 : PresentationFactory::PresentationFactory (
     134             :     const Reference<frame::XController>& rxController)
     135             :     : PresentationFactoryInterfaceBase(MutexOwner::maMutex),
     136             :       mxConfigurationController(),
     137           0 :       mxController(rxController)
     138             : {
     139             :     try
     140             :     {
     141             :         // Get the XController from the first argument.
     142           0 :         Reference<XControllerManager> xControllerManager(rxController, UNO_QUERY_THROW);
     143           0 :         mxConfigurationController = xControllerManager->getConfigurationController();
     144             :     }
     145           0 :     catch (RuntimeException&)
     146             :     {
     147             :         DBG_UNHANDLED_EXCEPTION();
     148             :     }
     149           0 : }
     150             : 
     151             : 
     152             : 
     153             : 
     154             : 
     155           0 : PresentationFactory::~PresentationFactory (void)
     156             : {
     157           0 : }
     158             : 
     159             : 
     160             : 
     161             : 
     162           0 : void SAL_CALL PresentationFactory::disposing (void)
     163             : {
     164           0 : }
     165             : 
     166             : 
     167             : 
     168             : 
     169             : //----- XViewFactory ----------------------------------------------------------
     170             : 
     171           0 : Reference<XResource> SAL_CALL PresentationFactory::createResource (
     172             :     const Reference<XResourceId>& rxViewId)
     173             :     throw (RuntimeException, IllegalArgumentException, WrappedTargetException)
     174             : {
     175           0 :     ThrowIfDisposed();
     176             : 
     177           0 :     if (rxViewId.is())
     178           0 :         if ( ! rxViewId->hasAnchor() && rxViewId->getResourceURL().equals(msPresentationViewURL))
     179           0 :             return new PresentationView(rxViewId);
     180             : 
     181           0 :     return Reference<XResource>();
     182             : }
     183             : 
     184             : 
     185             : 
     186             : 
     187           0 : void SAL_CALL PresentationFactory::releaseResource (
     188             :     const Reference<XResource>& rxView)
     189             :     throw (RuntimeException)
     190             : {
     191           0 :     ThrowIfDisposed();
     192             :     (void)rxView;
     193             : 
     194           0 :     Reference<lang::XUnoTunnel> xTunnel (mxController, UNO_QUERY);
     195           0 :     if (xTunnel.is())
     196             :     {
     197             :         ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
     198           0 :             xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
     199           0 :         if (pController != NULL)
     200             :         {
     201           0 :             ViewShellBase* pBase = pController->GetViewShellBase();
     202           0 :             if (pBase != NULL)
     203           0 :                 SlideShow::Stop( *pBase );
     204             :         }
     205           0 :     }
     206           0 : }
     207             : 
     208             : 
     209             : 
     210             : 
     211             : //===== XConfigurationChangeListener ==========================================
     212             : 
     213           0 : void SAL_CALL PresentationFactory::notifyConfigurationChange (
     214             :     const ConfigurationChangeEvent& rEvent)
     215             :     throw (RuntimeException)
     216             : {
     217             :     (void)rEvent;
     218           0 : }
     219             : 
     220             : 
     221             : 
     222             : 
     223             : //===== lang::XEventListener ==================================================
     224             : 
     225           0 : void SAL_CALL PresentationFactory::disposing (
     226             :     const lang::EventObject& rEventObject)
     227             :     throw (RuntimeException)
     228             : {
     229             :     (void)rEventObject;
     230           0 : }
     231             : 
     232             : 
     233             : 
     234             : 
     235             : 
     236             : //-----------------------------------------------------------------------------
     237             : 
     238           0 : void PresentationFactory::ThrowIfDisposed (void) const
     239             :     throw (lang::DisposedException)
     240             : {
     241           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     242             :     {
     243             :         throw lang::DisposedException ("PresentationFactory object has already been disposed",
     244           0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
     245             :     }
     246           0 : }
     247             : 
     248             : 
     249             : 
     250             : namespace {
     251             : 
     252             : //===== PresentationFactoryProvider ===========================================
     253             : 
     254           0 : PresentationFactoryProvider::PresentationFactoryProvider (
     255             :     const Reference<XComponentContext>& rxContext)
     256           0 :     : PresentationFactoryProviderInterfaceBase(maMutex)
     257             : {
     258             :     (void)rxContext;
     259           0 : }
     260             : 
     261             : 
     262             : 
     263             : 
     264           0 : PresentationFactoryProvider::~PresentationFactoryProvider (void)
     265             : {
     266           0 : }
     267             : 
     268             : 
     269             : 
     270             : 
     271           0 : void PresentationFactoryProvider::disposing (void)
     272             : {
     273           0 : }
     274             : 
     275             : 
     276             : 
     277             : 
     278             : // XInitialization
     279             : 
     280           0 : void SAL_CALL PresentationFactoryProvider::initialize(
     281             :     const Sequence<Any>& aArguments)
     282             :     throw (Exception, RuntimeException)
     283             : {
     284           0 :     if (aArguments.getLength() > 0)
     285             :     {
     286             :         try
     287             :         {
     288             :             // Get the XController from the first argument.
     289           0 :             Reference<frame::XController> xController (aArguments[0], UNO_QUERY_THROW);
     290           0 :             Reference<XControllerManager> xCM (xController, UNO_QUERY_THROW);
     291           0 :             Reference<XConfigurationController> xCC (xCM->getConfigurationController());
     292           0 :             if (xCC.is())
     293           0 :                 xCC->addResourceFactory(
     294             :                     PresentationFactory::msPresentationViewURL,
     295           0 :                     new PresentationFactory(xController));
     296             :         }
     297           0 :         catch (RuntimeException&)
     298             :         {
     299             :             DBG_UNHANDLED_EXCEPTION();
     300             :         }
     301             :     }
     302           0 : }
     303             : 
     304             : 
     305             : 
     306             : } // end of anonymous namespace.
     307             : 
     308             : 
     309           9 : } } // end of namespace sd::framework
     310             : 
     311             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10