LCOV - code coverage report
Current view: top level - sd/source/ui/framework/factories - BasicToolBarFactory.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 71 0.0 %
Date: 2014-04-14 Functions: 0 13 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             : 
      21             : #include "BasicToolBarFactory.hxx"
      22             : 
      23             : #include "ViewTabBar.hxx"
      24             : #include "framework/FrameworkHelper.hxx"
      25             : #include <unotools/mediadescriptor.hxx>
      26             : 
      27             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      28             : #include "DrawController.hxx"
      29             : 
      30             : using namespace ::com::sun::star;
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::lang;
      33             : using namespace ::com::sun::star::drawing::framework;
      34             : 
      35             : namespace sd { namespace framework {
      36             : 
      37             : 
      38           0 : Reference<XInterface> SAL_CALL BasicToolBarFactory_createInstance (
      39             :     const Reference<XComponentContext>& rxContext)
      40             : {
      41           0 :     return static_cast<XWeak*>(new BasicToolBarFactory(rxContext));
      42             : }
      43             : 
      44             : 
      45             : 
      46             : 
      47           0 : OUString BasicToolBarFactory_getImplementationName (void) throw(RuntimeException)
      48             : {
      49           0 :     return OUString("com.sun.star.comp.Draw.framework.BasicToolBarFactory");
      50             : }
      51             : 
      52             : 
      53             : 
      54             : 
      55           0 : Sequence<OUString> SAL_CALL BasicToolBarFactory_getSupportedServiceNames (void)
      56             :     throw (RuntimeException)
      57             : {
      58           0 :     const OUString sServiceName("com.sun.star.drawing.framework.BasicToolBarFactory");
      59           0 :     return Sequence<OUString>(&sServiceName, 1);
      60             : }
      61             : 
      62             : 
      63             : 
      64             : 
      65             : 
      66             : //===== BasicToolBarFactory ===================================================
      67             : 
      68           0 : BasicToolBarFactory::BasicToolBarFactory (
      69             :     const Reference<XComponentContext>& rxContext)
      70             :     : BasicToolBarFactoryInterfaceBase(m_aMutex),
      71             :       mxConfigurationController(),
      72             :       mxController(),
      73           0 :       mpViewShellBase(NULL)
      74             : {
      75             :     (void)rxContext;
      76           0 : }
      77             : 
      78             : 
      79             : 
      80             : 
      81           0 : BasicToolBarFactory::~BasicToolBarFactory (void)
      82             : {
      83           0 : }
      84             : 
      85             : 
      86             : 
      87             : 
      88           0 : void SAL_CALL BasicToolBarFactory::disposing (void)
      89             : {
      90           0 :     Shutdown();
      91           0 : }
      92             : 
      93             : 
      94             : 
      95             : 
      96           0 : void BasicToolBarFactory::Shutdown (void)
      97             : {
      98           0 :     mpViewShellBase = NULL;
      99           0 :     Reference<lang::XComponent> xComponent (mxConfigurationController, UNO_QUERY);
     100           0 :     if (xComponent.is())
     101           0 :         xComponent->removeEventListener(static_cast<lang::XEventListener*>(this));
     102           0 :     if (mxConfigurationController.is())
     103             :     {
     104           0 :         mxConfigurationController->removeResourceFactoryForReference(this);
     105           0 :         mxConfigurationController = NULL;
     106           0 :     }
     107           0 : }
     108             : 
     109             : 
     110             : 
     111             : 
     112             : //----- XInitialization -------------------------------------------------------
     113             : 
     114           0 : void SAL_CALL BasicToolBarFactory::initialize (const Sequence<Any>& aArguments)
     115             :     throw (Exception, RuntimeException, std::exception)
     116             : {
     117           0 :     if (aArguments.getLength() > 0)
     118             :     {
     119             :         try
     120             :         {
     121             :             // Get the XController from the first argument.
     122           0 :             mxController = Reference<frame::XController>(aArguments[0], UNO_QUERY_THROW);
     123             : 
     124             :             // Tunnel through the controller to obtain a ViewShellBase.
     125           0 :             Reference<lang::XUnoTunnel> xTunnel (mxController, UNO_QUERY_THROW);
     126             :             ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
     127           0 :                 xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
     128           0 :             if (pController != NULL)
     129           0 :                 mpViewShellBase = pController->GetViewShellBase();
     130             : 
     131           0 :             utl::MediaDescriptor aDescriptor (mxController->getModel()->getArgs());
     132           0 :             if ( ! aDescriptor.getUnpackedValueOrDefault(
     133           0 :                 utl::MediaDescriptor::PROP_PREVIEW(),
     134           0 :                 sal_False))
     135             :             {
     136             :                 // Register the factory for its supported tool bars.
     137           0 :                 Reference<XControllerManager> xControllerManager(mxController, UNO_QUERY_THROW);
     138           0 :                 mxConfigurationController = xControllerManager->getConfigurationController();
     139           0 :                 if (mxConfigurationController.is())
     140             :                 {
     141           0 :                     mxConfigurationController->addResourceFactory(
     142           0 :                         FrameworkHelper::msViewTabBarURL, this);
     143             :                 }
     144             : 
     145           0 :                 Reference<lang::XComponent> xComponent (mxConfigurationController, UNO_QUERY);
     146           0 :                 if (xComponent.is())
     147           0 :                     xComponent->addEventListener(static_cast<lang::XEventListener*>(this));
     148             :             }
     149             :             else
     150             :             {
     151             :                 // The view shell is in preview mode and thus does not need
     152             :                 // the view tab bar.
     153           0 :                 mxConfigurationController = NULL;
     154           0 :             }
     155             :         }
     156           0 :         catch (RuntimeException&)
     157             :         {
     158           0 :             Shutdown();
     159           0 :             throw;
     160             :         }
     161             :     }
     162           0 : }
     163             : 
     164             : 
     165             : 
     166             : 
     167             : //----- lang::XEventListener --------------------------------------------------
     168             : 
     169           0 : void SAL_CALL BasicToolBarFactory::disposing (
     170             :     const lang::EventObject& rEventObject)
     171             :     throw (RuntimeException, std::exception)
     172             : {
     173           0 :     if (rEventObject.Source == mxConfigurationController)
     174           0 :         mxConfigurationController = NULL;
     175           0 : }
     176             : 
     177             : 
     178             : 
     179             : 
     180             : //===== XPaneFactory ==========================================================
     181             : 
     182           0 : Reference<XResource> SAL_CALL BasicToolBarFactory::createResource (
     183             :     const Reference<XResourceId>& rxToolBarId)
     184             :     throw (RuntimeException, IllegalArgumentException, WrappedTargetException, std::exception)
     185             : {
     186           0 :     ThrowIfDisposed();
     187             : 
     188           0 :     Reference<XResource> xToolBar;
     189             : 
     190           0 :     if (rxToolBarId->getResourceURL().equals(FrameworkHelper::msViewTabBarURL))
     191             :     {
     192           0 :         xToolBar = new ViewTabBar(rxToolBarId, mxController);
     193             :     }
     194             :     else
     195           0 :         throw lang::IllegalArgumentException();
     196             : 
     197             : 
     198           0 :     return xToolBar;
     199             : }
     200             : 
     201             : 
     202             : 
     203             : 
     204             : 
     205           0 : void SAL_CALL BasicToolBarFactory::releaseResource (
     206             :     const Reference<XResource>& rxToolBar)
     207             :     throw (RuntimeException, std::exception)
     208             : {
     209           0 :     ThrowIfDisposed();
     210             : 
     211           0 :     Reference<XComponent> xComponent (rxToolBar, UNO_QUERY);
     212           0 :     if (xComponent.is())
     213           0 :         xComponent->dispose();
     214           0 : }
     215             : 
     216             : 
     217             : 
     218             : 
     219           0 : void BasicToolBarFactory::ThrowIfDisposed (void) const
     220             :     throw (lang::DisposedException)
     221             : {
     222           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     223             :     {
     224             :         throw lang::DisposedException ("BasicToolBarFactory object has already been disposed",
     225           0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
     226             :     }
     227           0 : }
     228             : 
     229             : 
     230             : 
     231             : 
     232             : } } // end of namespace sd::framework
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10