LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - PaneChildWindows.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 40 62 64.5 %
Date: 2012-08-25 Functions: 17 23 73.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 50 134 37.3 %

           Branch data     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 [ +  - ][ +  - ]:        137 : SFX_IMPL_DOCKINGWINDOW_WITHID(LeftPaneImpressChildWindow, SID_LEFT_PANE_IMPRESS)
                 [ +  - ]
      48 [ +  - ][ +  - ]:        457 : SFX_IMPL_DOCKINGWINDOW_WITHID(LeftPaneDrawChildWindow, SID_LEFT_PANE_DRAW)
                 [ +  - ]
      49 [ +  - ][ +  - ]:        137 : SFX_IMPL_DOCKINGWINDOW_WITHID( ToolPanelChildWindow, SID_TASKPANE)
                 [ +  - ]
      50                 :            : 
      51                 :            : //===== PaneChildWindow =======================================================
      52                 :            : 
      53                 :        156 : 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                 :        156 :     : SfxChildWindow (pParentWindow, nId)
      62                 :            : {
      63                 :            :     pWindow = new PaneDockingWindow (
      64                 :            :         pBindings,
      65                 :            :         this,
      66                 :            :         pParentWindow,
      67                 :            :         SdResId( nDockWinTitleResId ),
      68 [ +  - ][ +  - ]:        156 :         String( SdResId( nTitleBarResId ) ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      69                 :        156 :     eChildAlignment = eAlignment;
      70         [ +  - ]:        156 :     static_cast<SfxDockingWindow*>(pWindow)->Initialize(pInfo);
      71         [ +  - ]:        156 :     SetHideNotDelete(sal_True);
      72                 :            : 
      73 [ +  - ][ +  - ]:        156 :     ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pBindings->GetDispatcher()->GetFrame());
      74         [ +  - ]:        156 :     if (pBase != NULL)
      75                 :            :     {
      76 [ +  - ][ +  - ]:        156 :         framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
                 [ +  - ]
      77                 :            :     }
      78                 :        156 : }
      79                 :            : 
      80                 :            : 
      81                 :            : 
      82                 :            : 
      83                 :        156 : PaneChildWindow::~PaneChildWindow (void)
      84                 :            : {
      85                 :        156 :     ViewShellBase* pBase = NULL;
      86         [ -  + ]:        156 :     PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(pWindow);
      87         [ +  - ]:        156 :     if (pDockingWindow != NULL)
      88                 :            :         pBase = ViewShellBase::GetViewShellBase(
      89 [ +  - ][ +  - ]:        156 :             pDockingWindow->GetBindings().GetDispatcher()->GetFrame());
      90         [ +  - ]:        156 :     if (pBase != NULL)
      91 [ +  - ][ +  - ]:        156 :         framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
                 [ +  - ]
      92         [ -  + ]:        156 : }
      93                 :            : 
      94                 :            : 
      95                 :            : 
      96                 :            : 
      97                 :            : 
      98                 :            : 
      99                 :            : //===== LeftPaneImpressChildWindow ============================================
     100                 :            : 
     101                 :         26 : 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                 :         26 :         SFX_ALIGN_LEFT)
     114                 :            : {
     115                 :         26 : }
     116                 :            : 
     117                 :            : 
     118                 :            : 
     119                 :            : 
     120                 :            : //===== LeftPaneDrawChildWindow ===============================================
     121                 :            : 
     122                 :        104 : 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                 :        104 :         SFX_ALIGN_LEFT)
     135                 :            : {
     136                 :        104 : }
     137                 :            : 
     138                 :            : 
     139                 :            : 
     140                 :            : 
     141                 :            : //======================================================================================================================
     142                 :            : //= ToolPanelChildWindow
     143                 :            : //======================================================================================================================
     144                 :            : //----------------------------------------------------------------------------------------------------------------------
     145                 :         26 : 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                 :         26 :         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         [ -  + ]:         26 :     SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() );
     156 [ +  - ][ +  - ]:         26 :     ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() );
     157         [ +  - ]:         26 :     ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ToolPanelChildWindow: no view shell access!" );
     158                 :            : 
     159         [ +  - ]:         26 :     const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) );
     160         [ -  + ]:         26 :     ENSURE_OR_RETURN_VOID( pFrameworkHelper.get(), "ToolPanelChildWindow::ToolPanelChildWindow: no framework helper for the view shell!" );
     161         [ +  - ]:         26 :     Reference<XConfigurationController> xConfigController( pFrameworkHelper->GetConfigurationController() );
     162         [ -  + ]:         26 :     ENSURE_OR_RETURN_VOID( xConfigController.is(), "ToolPanelChildWindow::ToolPanelChildWindow: no config controller!" );
     163         [ +  - ]:         26 :     xConfigController->requestResourceActivation(
     164                 :            :         framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msRightPaneURL ),
     165 [ +  - ][ +  - ]:         26 :         ResourceActivationMode_ADD );
     166         [ +  - ]:         26 :     xConfigController->requestResourceActivation(
     167                 :            :         framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL ),
     168                 :            :         ResourceActivationMode_REPLACE
     169 [ +  - ][ +  - ]:         26 :     );
         [ -  + ][ +  - ]
                 [ +  - ]
     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