LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - PaneChildWindows.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 62 4.8 %
Date: 2012-12-17 Functions: 3 23 13.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 "PaneChildWindows.hxx"
      21             : #include "PaneDockingWindow.hrc"
      22             : #include "PaneDockingWindow.hxx"
      23             : #include "ViewShellBase.hxx"
      24             : #include "framework/FrameworkHelper.hxx"
      25             : #include "taskpane/ToolPanelViewShell.hxx"
      26             : #include "app.hrc"
      27             : #include "strings.hrc"
      28             : #include "sdresid.hxx"
      29             : 
      30             : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
      31             : #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
      32             : 
      33             : #include <sfx2/app.hxx>
      34             : #include <sfx2/dockwin.hxx>
      35             : #include <sfx2/bindings.hxx>
      36             : #include <sfx2/dispatch.hxx>
      37             : #include <tools/diagnose_ex.h>
      38             : 
      39             : namespace sd {
      40             : 
      41             : using ::com::sun::star::uno::Reference;
      42             : using ::com::sun::star::drawing::framework::XResourceId;
      43             : using ::com::sun::star::drawing::framework::XConfigurationController;
      44             : using ::com::sun::star::drawing::framework::ResourceActivationMode_ADD;
      45             : using ::com::sun::star::drawing::framework::ResourceActivationMode_REPLACE;
      46             : 
      47           6 : SFX_IMPL_DOCKINGWINDOW_WITHID(LeftPaneImpressChildWindow, SID_LEFT_PANE_IMPRESS)
      48           6 : SFX_IMPL_DOCKINGWINDOW_WITHID(LeftPaneDrawChildWindow, SID_LEFT_PANE_DRAW)
      49           6 : SFX_IMPL_DOCKINGWINDOW_WITHID( ToolPanelChildWindow, SID_TASKPANE)
      50             : 
      51             : //===== PaneChildWindow =======================================================
      52             : 
      53           0 : PaneChildWindow::PaneChildWindow (
      54             :     ::Window* pParentWindow,
      55             :     sal_uInt16 nId,
      56             :     SfxBindings* pBindings,
      57             :     SfxChildWinInfo* pInfo,
      58             :     const sal_uInt16 nDockWinTitleResId,
      59             :     const sal_uInt16 nTitleBarResId,
      60             :     SfxChildAlignment eAlignment)
      61           0 :     : SfxChildWindow (pParentWindow, nId)
      62             : {
      63             :     pWindow = new PaneDockingWindow (
      64             :         pBindings,
      65             :         this,
      66             :         pParentWindow,
      67             :         SdResId( nDockWinTitleResId ),
      68           0 :         String( SdResId( nTitleBarResId ) ) );
      69           0 :     eChildAlignment = eAlignment;
      70           0 :     static_cast<SfxDockingWindow*>(pWindow)->Initialize(pInfo);
      71           0 :     SetHideNotDelete(sal_True);
      72             : 
      73           0 :     ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pBindings->GetDispatcher()->GetFrame());
      74           0 :     if (pBase != NULL)
      75             :     {
      76           0 :         framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
      77             :     }
      78           0 : }
      79             : 
      80             : 
      81             : 
      82             : 
      83           0 : PaneChildWindow::~PaneChildWindow (void)
      84             : {
      85           0 :     ViewShellBase* pBase = NULL;
      86           0 :     PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(pWindow);
      87           0 :     if (pDockingWindow != NULL)
      88             :         pBase = ViewShellBase::GetViewShellBase(
      89           0 :             pDockingWindow->GetBindings().GetDispatcher()->GetFrame());
      90           0 :     if (pBase != NULL)
      91           0 :         framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
      92           0 : }
      93             : 
      94             : 
      95             : 
      96             : 
      97             : 
      98             : 
      99             : //===== LeftPaneImpressChildWindow ============================================
     100             : 
     101           0 : LeftPaneImpressChildWindow::LeftPaneImpressChildWindow (
     102             :     ::Window* pParentWindow,
     103             :     sal_uInt16 nId,
     104             :     SfxBindings* pBindings,
     105             :     SfxChildWinInfo* pInfo)
     106             :     : PaneChildWindow(
     107             :         pParentWindow,
     108             :         nId,
     109             :         pBindings,
     110             :         pInfo,
     111             :         FLT_LEFT_PANE_IMPRESS_DOCKING_WINDOW,
     112             :         STR_LEFT_PANE_IMPRESS_TITLE,
     113           0 :         SFX_ALIGN_LEFT)
     114             : {
     115           0 : }
     116             : 
     117             : 
     118             : 
     119             : 
     120             : //===== LeftPaneDrawChildWindow ===============================================
     121             : 
     122           0 : LeftPaneDrawChildWindow::LeftPaneDrawChildWindow (
     123             :     ::Window* pParentWindow,
     124             :     sal_uInt16 nId,
     125             :     SfxBindings* pBindings,
     126             :     SfxChildWinInfo* pInfo)
     127             :     : PaneChildWindow(
     128             :         pParentWindow,
     129             :         nId,
     130             :         pBindings,
     131             :         pInfo,
     132             :         FLT_LEFT_PANE_DRAW_DOCKING_WINDOW,
     133             :         STR_LEFT_PANE_DRAW_TITLE,
     134           0 :         SFX_ALIGN_LEFT)
     135             : {
     136           0 : }
     137             : 
     138             : 
     139             : 
     140             : 
     141             : //======================================================================================================================
     142             : //= ToolPanelChildWindow
     143             : //======================================================================================================================
     144             : //----------------------------------------------------------------------------------------------------------------------
     145           0 : ToolPanelChildWindow::ToolPanelChildWindow( ::Window* i_pParentWindow, sal_uInt16 i_nId, SfxBindings* i_pBindings,
     146             :         SfxChildWinInfo* i_pChildWindowInfo )
     147             :     :PaneChildWindow( i_pParentWindow, i_nId, i_pBindings, i_pChildWindowInfo,
     148           0 :         FLT_TOOL_PANEL_DOCKING_WINDOW, STR_RIGHT_PANE_TITLE, SFX_ALIGN_RIGHT )
     149             : {
     150             :     // just in case this window has been created by SFX, instead our resource framework: Ensure that the resource framework
     151             :     // activates the task pane, so it is really filled with content (in opposite to the other SFX applications, the
     152             :     // child window registered for SID_TASKPANE is not responsible for its content, but here in SD, it's the ToolPanelViewShell
     153             :     // which has this responsibility. And this view shell is created implicitly via the resource framework.)
     154             :     // #i113788#
     155           0 :     SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() );
     156           0 :     ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() );
     157           0 :     ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ToolPanelChildWindow: no view shell access!" );
     158             : 
     159           0 :     const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) );
     160           0 :     ENSURE_OR_RETURN_VOID( pFrameworkHelper.get(), "ToolPanelChildWindow::ToolPanelChildWindow: no framework helper for the view shell!" );
     161           0 :     Reference<XConfigurationController> xConfigController( pFrameworkHelper->GetConfigurationController() );
     162           0 :     ENSURE_OR_RETURN_VOID( xConfigController.is(), "ToolPanelChildWindow::ToolPanelChildWindow: no config controller!" );
     163           0 :     xConfigController->requestResourceActivation(
     164             :         framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msRightPaneURL ),
     165           0 :         ResourceActivationMode_ADD );
     166           0 :     xConfigController->requestResourceActivation(
     167             :         framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL ),
     168             :         ResourceActivationMode_REPLACE
     169           0 :     );
     170             : }
     171             : 
     172             : //----------------------------------------------------------------------------------------------------------------------
     173           0 : struct DelayedToolPanelActivation
     174             : {
     175           0 :     DelayedToolPanelActivation( ToolPanelChildWindow& i_rToolPanelWindow, const ::rtl::OUString& i_rPanelURL )
     176             :         :m_rToolPanelWindow( i_rToolPanelWindow )
     177           0 :         ,m_sPanelURL( i_rPanelURL )
     178             :     {
     179           0 :     }
     180             : 
     181           0 :     void operator() (bool)
     182             :     {
     183           0 :         m_rToolPanelWindow.ActivateToolPanel( m_sPanelURL );
     184           0 :     }
     185             : 
     186             : private:
     187             :     ToolPanelChildWindow&   m_rToolPanelWindow;
     188             :     const ::rtl::OUString   m_sPanelURL;
     189             : };
     190             : 
     191             : //----------------------------------------------------------------------------------------------------------------------
     192           0 : void ToolPanelChildWindow::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
     193             : {
     194           0 :     SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() );
     195           0 :     ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() );
     196           0 :     ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ActivateToolPanel: no view shell access!" );
     197             : 
     198           0 :     const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) );
     199             : 
     200           0 :     if ( i_rPanelURL.indexOf( framework::FrameworkHelper::msTaskPanelURLPrefix ) == 0 )
     201             :     {
     202             :         // it's one of our standard panels known to the drawing framework
     203           0 :         pFrameworkHelper->RequestTaskPanel( i_rPanelURL );
     204             :     }
     205             :     else
     206             :     {
     207             :         // TODO: it would be nice if the drawing framework were able to handle non-standard panels, installed by
     208             :         // extensions, too. As long as this is not the case, we need to take the direct way ...
     209           0 :         ::boost::shared_ptr< ViewShell > pViewShell = pFrameworkHelper->GetViewShell( framework::FrameworkHelper::msRightPaneURL );
     210           0 :         toolpanel::ToolPanelViewShell* pToolPanelViewShell = dynamic_cast< toolpanel::ToolPanelViewShell* >( pViewShell.get() );
     211           0 :         if ( pToolPanelViewShell )
     212             :         {
     213           0 :             pToolPanelViewShell->ActivatePanel( i_rPanelURL );
     214             :         }
     215             :         else
     216             :         {
     217             :             Reference< XResourceId > xTaskPaneResource = pFrameworkHelper->RequestView(
     218           0 :                 framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL );
     219           0 :             pFrameworkHelper->RunOnResourceActivation( xTaskPaneResource, DelayedToolPanelActivation( *this, i_rPanelURL ) );
     220           0 :         }
     221           0 :     }
     222             : }
     223             : 
     224             : } // end of namespace ::sd
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10