LCOV - code coverage report
Current view: top level - sd/source/ui/framework/module - CenterViewFocusModule.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 62 0.0 %
Date: 2014-04-14 Functions: 0 7 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 "CenterViewFocusModule.hxx"
      22             : 
      23             : #include "framework/ConfigurationController.hxx"
      24             : #include "framework/FrameworkHelper.hxx"
      25             : #include "framework/ViewShellWrapper.hxx"
      26             : 
      27             : #include "DrawController.hxx"
      28             : #include "ViewShellBase.hxx"
      29             : #include "ViewShellManager.hxx"
      30             : #include "strings.hrc"
      31             : #include "sdresid.hxx"
      32             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      33             : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
      34             : 
      35             : #include <toolkit/awt/vclxdevice.hxx>
      36             : #include <sfx2/viewfrm.hxx>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::uno;
      40             : using namespace ::com::sun::star::drawing::framework;
      41             : 
      42             : using ::sd::framework::FrameworkHelper;
      43             : 
      44             : 
      45             : namespace sd { namespace framework {
      46             : 
      47             : //===== CenterViewFocusModule ====================================================
      48             : 
      49           0 : CenterViewFocusModule::CenterViewFocusModule (Reference<frame::XController>& rxController)
      50             :     : CenterViewFocusModuleInterfaceBase(MutexOwner::maMutex),
      51             :       mbValid(false),
      52             :       mxConfigurationController(),
      53             :       mpBase(NULL),
      54           0 :       mbNewViewCreated(false)
      55             : {
      56           0 :     Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
      57           0 :     if (xControllerManager.is())
      58             :     {
      59           0 :         mxConfigurationController = xControllerManager->getConfigurationController();
      60             : 
      61             :         // Tunnel through the controller to obtain a ViewShellBase.
      62           0 :         Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
      63           0 :         if (xTunnel.is())
      64             :         {
      65             :             ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
      66           0 :                 xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
      67           0 :             if (pController != NULL)
      68           0 :                 mpBase = pController->GetViewShellBase();
      69             :         }
      70             : 
      71             :         // Check, if all required objects do exist.
      72           0 :         if (mxConfigurationController.is() && mpBase!=NULL)
      73             :         {
      74           0 :             mbValid = true;
      75           0 :         }
      76             :     }
      77             : 
      78           0 :     if (mbValid)
      79             :     {
      80           0 :         mxConfigurationController->addConfigurationChangeListener(
      81             :             this,
      82             :             FrameworkHelper::msConfigurationUpdateEndEvent,
      83           0 :             Any());
      84           0 :         mxConfigurationController->addConfigurationChangeListener(
      85             :             this,
      86             :             FrameworkHelper::msResourceActivationEvent,
      87           0 :             Any());
      88           0 :     }
      89           0 : }
      90             : 
      91             : 
      92             : 
      93             : 
      94           0 : CenterViewFocusModule::~CenterViewFocusModule (void)
      95             : {
      96           0 : }
      97             : 
      98             : 
      99             : 
     100             : 
     101           0 : void SAL_CALL CenterViewFocusModule::disposing (void)
     102             : {
     103           0 :     if (mxConfigurationController.is())
     104           0 :         mxConfigurationController->removeConfigurationChangeListener(this);
     105             : 
     106           0 :     mbValid = false;
     107           0 :     mxConfigurationController = NULL;
     108           0 :     mpBase = NULL;
     109           0 : }
     110             : 
     111             : 
     112             : 
     113             : 
     114           0 : void SAL_CALL CenterViewFocusModule::notifyConfigurationChange (
     115             :     const ConfigurationChangeEvent& rEvent)
     116             :     throw (RuntimeException, std::exception)
     117             : {
     118           0 :     if (mbValid)
     119             :     {
     120           0 :         if (rEvent.Type.equals(FrameworkHelper::msConfigurationUpdateEndEvent))
     121             :         {
     122           0 :             HandleNewView(rEvent.Configuration);
     123             :         }
     124           0 :         else if (rEvent.Type.equals(FrameworkHelper::msResourceActivationEvent))
     125             :         {
     126           0 :             if (rEvent.ResourceId->getResourceURL().match(FrameworkHelper::msViewURLPrefix))
     127           0 :                 mbNewViewCreated = true;
     128             :         }
     129             :     }
     130           0 : }
     131             : 
     132             : 
     133             : 
     134             : 
     135           0 : void CenterViewFocusModule::HandleNewView (
     136             :     const Reference<XConfiguration>& rxConfiguration)
     137             : {
     138           0 :     if (mbNewViewCreated)
     139             :     {
     140           0 :         mbNewViewCreated = false;
     141             :         // Make the center pane the active one.  Tunnel through the
     142             :         // controller to obtain a ViewShell pointer.
     143             : 
     144           0 :         Sequence<Reference<XResourceId> > xViewIds (rxConfiguration->getResources(
     145             :             FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL),
     146             :             FrameworkHelper::msViewURLPrefix,
     147           0 :             AnchorBindingMode_DIRECT));
     148           0 :         Reference<XView> xView;
     149           0 :         if (xViewIds.getLength() > 0)
     150           0 :             xView = Reference<XView>(
     151           0 :                 mxConfigurationController->getResource(xViewIds[0]),UNO_QUERY);
     152           0 :         Reference<lang::XUnoTunnel> xTunnel (xView, UNO_QUERY);
     153           0 :         if (xTunnel.is() && mpBase!=NULL)
     154             :         {
     155             :             ViewShellWrapper* pViewShellWrapper = reinterpret_cast<ViewShellWrapper*>(
     156           0 :                 xTunnel->getSomething(ViewShellWrapper::getUnoTunnelId()));
     157           0 :             if (pViewShellWrapper != NULL)
     158             :             {
     159           0 :                 ::boost::shared_ptr<ViewShell> pViewShell = pViewShellWrapper->GetViewShell();
     160           0 :                 if (pViewShell.get() != NULL)
     161           0 :                     mpBase->GetViewShellManager()->MoveToTop(*pViewShell);
     162             :             }
     163           0 :         }
     164             :     }
     165           0 : }
     166             : 
     167             : 
     168             : 
     169             : 
     170           0 : void SAL_CALL CenterViewFocusModule::disposing (
     171             :     const lang::EventObject& rEvent)
     172             :     throw (RuntimeException, std::exception)
     173             : {
     174           0 :     if (mxConfigurationController.is())
     175           0 :         if (rEvent.Source == mxConfigurationController)
     176             :         {
     177           0 :             mbValid = false;
     178           0 :             mxConfigurationController = NULL;
     179           0 :             mpBase = NULL;
     180             :         }
     181           0 : }
     182             : 
     183             : 
     184             : 
     185             : } } // end of namespace sd::framework
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10