LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/toolpanel - TaskPaneShellManager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 64 0.0 %
Date: 2012-12-27 Functions: 0 11 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 "TaskPaneShellManager.hxx"
      22             : 
      23             : #include "ViewShellManager.hxx"
      24             : #include <tools/diagnose_ex.h>
      25             : #include <vcl/window.hxx>
      26             : 
      27             : #include <algorithm>
      28             : 
      29             : namespace sd { namespace toolpanel {
      30             : 
      31           0 : TaskPaneShellManager::TaskPaneShellManager (
      32             :     const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager,
      33             :     const ViewShell& rViewShell)
      34             :     : mpViewShellManager(rpViewShellManager),
      35             :       mrViewShell(rViewShell),
      36           0 :       maSubShells()
      37             : {
      38           0 : }
      39             : 
      40             : 
      41             : 
      42             : 
      43           0 : TaskPaneShellManager::~TaskPaneShellManager (void)
      44             : {
      45           0 :     while ( ! maSubShells.empty())
      46           0 :         RemoveSubShell(maSubShells.begin()->second.mpShell);
      47           0 : }
      48             : 
      49             : 
      50             : 
      51             : 
      52           0 : SfxShell* TaskPaneShellManager::CreateShell( ShellId nId, ::Window* , FrameView* )
      53             : {
      54           0 :     SubShells::const_iterator iShell (maSubShells.find(nId));
      55           0 :     if (iShell != maSubShells.end())
      56           0 :         return iShell->second.mpShell;
      57             :     else
      58           0 :         return NULL;
      59             : }
      60             : 
      61             : 
      62             : 
      63             : 
      64           0 : void TaskPaneShellManager::ReleaseShell (SfxShell* )
      65             : {
      66             :     // Nothing to do.
      67           0 : }
      68             : 
      69           0 : void TaskPaneShellManager::AddSubShell (
      70             :     ShellId nId,
      71             :     SfxShell* pShell,
      72             :     ::Window* pWindow)
      73             : {
      74           0 :     if (pShell != NULL)
      75             :     {
      76           0 :         maSubShells[nId] = ShellDescriptor(pShell,pWindow);
      77           0 :         if (pWindow != NULL)
      78             :         {
      79           0 :             pWindow->AddEventListener(LINK(this,TaskPaneShellManager,WindowCallback));
      80           0 :             if (pWindow->IsReallyVisible())
      81           0 :                 mpViewShellManager->ActivateSubShell(mrViewShell, nId);
      82             :         }
      83             :         else
      84           0 :             mpViewShellManager->ActivateSubShell(mrViewShell, nId);
      85             :     }
      86           0 : }
      87             : 
      88             : 
      89             : 
      90             : 
      91           0 : void TaskPaneShellManager::RemoveSubShell (const ShellId i_nShellId)
      92             : {
      93           0 :     SubShells::iterator pos = maSubShells.find( i_nShellId );
      94           0 :     ENSURE_OR_RETURN_VOID( pos != maSubShells.end(), "no shell for this ID" );
      95           0 :     if ( pos->second.mpWindow != NULL )
      96             :     {
      97           0 :         pos->second.mpWindow->RemoveEventListener( LINK( this, TaskPaneShellManager, WindowCallback ) );
      98             :     }
      99           0 :     mpViewShellManager->DeactivateSubShell( mrViewShell, pos->first );
     100           0 :     maSubShells.erase( pos );
     101             : }
     102             : 
     103             : 
     104             : 
     105             : 
     106           0 : void TaskPaneShellManager::RemoveSubShell (const SfxShell* pShell)
     107             : {
     108           0 :     if (pShell != NULL)
     109             :     {
     110           0 :         SubShells::iterator iShell;
     111           0 :         for (iShell=maSubShells.begin(); iShell!=maSubShells.end(); ++iShell)
     112           0 :             if (iShell->second.mpShell == pShell)
     113             :             {
     114           0 :                 if (iShell->second.mpWindow != NULL)
     115           0 :                     iShell->second.mpWindow->RemoveEventListener(
     116           0 :                         LINK(this,TaskPaneShellManager,WindowCallback));
     117           0 :                 mpViewShellManager->DeactivateSubShell(mrViewShell,iShell->first);
     118           0 :                 maSubShells.erase(iShell);
     119           0 :                 break;
     120             :             }
     121             :     }
     122           0 : }
     123             : 
     124             : 
     125             : 
     126             : 
     127           0 : void TaskPaneShellManager::MoveToTop (SfxShell* pShell)
     128             : {
     129           0 :     SubShells::const_iterator iShell;
     130           0 :     for (iShell=maSubShells.begin(); iShell!=maSubShells.end(); ++iShell)
     131           0 :         if (iShell->second.mpShell == pShell)
     132             :         {
     133           0 :             ViewShellManager::UpdateLock aLocker (mpViewShellManager);
     134           0 :             mpViewShellManager->MoveSubShellToTop(mrViewShell,iShell->first);
     135           0 :             mpViewShellManager->MoveToTop(mrViewShell);
     136           0 :             break;
     137             :         }
     138           0 : }
     139             : 
     140             : 
     141             : 
     142             : 
     143           0 : IMPL_LINK(TaskPaneShellManager, WindowCallback, VclWindowEvent*, pEvent)
     144             : {
     145           0 :     if (pEvent != NULL)
     146             :     {
     147           0 :         SubShells::const_iterator iShell;
     148           0 :         ::Window* pWindow = pEvent->GetWindow();
     149           0 :         for (iShell=maSubShells.begin(); iShell!=maSubShells.end(); ++iShell)
     150           0 :             if (iShell->second.mpWindow == pWindow)
     151           0 :                 break;
     152           0 :         if (iShell != maSubShells.end())
     153           0 :             switch (pEvent->GetId())
     154             :             {
     155             :                 case VCLEVENT_WINDOW_SHOW:
     156           0 :                     mpViewShellManager->ActivateSubShell(mrViewShell,iShell->first);
     157           0 :                     break;
     158             : 
     159             :                 case VCLEVENT_WINDOW_HIDE:
     160             :                     // Do not activate the sub shell.  This leads to
     161             :                     // problems with shapes currently being in text edit
     162             :                     // mode: Deactivating the shell leads to leaving the
     163             :                     // text editing mode.
     164             :                     // mpViewShellManager->DeactivateSubShell(mrViewShell,iShell->first);
     165           0 :                     break;
     166             :             }
     167             :     }
     168             : 
     169           0 :     return 0;
     170             : }
     171             : 
     172             : 
     173             : } } // end of namespace ::sd::toolpanel
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10