1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir #include "PaneChildWindows.hxx" 31*cdf0e10cSrcweir #include "PaneDockingWindow.hrc" 32*cdf0e10cSrcweir #include "PaneDockingWindow.hxx" 33*cdf0e10cSrcweir #include "ViewShellBase.hxx" 34*cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx" 35*cdf0e10cSrcweir #include "taskpane/ToolPanelViewShell.hxx" 36*cdf0e10cSrcweir #include "app.hrc" 37*cdf0e10cSrcweir #include "strings.hrc" 38*cdf0e10cSrcweir #include "sdresid.hxx" 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <sfx2/app.hxx> 44*cdf0e10cSrcweir #include <sfx2/dockwin.hxx> 45*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 46*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 47*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir namespace sd { 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 52*cdf0e10cSrcweir using ::com::sun::star::drawing::framework::XResourceId; 53*cdf0e10cSrcweir using ::com::sun::star::drawing::framework::XConfigurationController; 54*cdf0e10cSrcweir using ::com::sun::star::drawing::framework::ResourceActivationMode_ADD; 55*cdf0e10cSrcweir using ::com::sun::star::drawing::framework::ResourceActivationMode_REPLACE; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir SFX_IMPL_DOCKINGWINDOW(LeftPaneImpressChildWindow, SID_LEFT_PANE_IMPRESS) 58*cdf0e10cSrcweir SFX_IMPL_DOCKINGWINDOW(LeftPaneDrawChildWindow, SID_LEFT_PANE_DRAW) 59*cdf0e10cSrcweir SFX_IMPL_DOCKINGWINDOW( ToolPanelChildWindow, SID_TASKPANE) 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir //===== PaneChildWindow ======================================================= 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir PaneChildWindow::PaneChildWindow ( 64*cdf0e10cSrcweir ::Window* pParentWindow, 65*cdf0e10cSrcweir sal_uInt16 nId, 66*cdf0e10cSrcweir SfxBindings* pBindings, 67*cdf0e10cSrcweir SfxChildWinInfo* pInfo, 68*cdf0e10cSrcweir const sal_uInt16 nDockWinTitleResId, 69*cdf0e10cSrcweir const sal_uInt16 nTitleBarResId, 70*cdf0e10cSrcweir SfxChildAlignment eAlignment) 71*cdf0e10cSrcweir : SfxChildWindow (pParentWindow, nId) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir pWindow = new PaneDockingWindow ( 74*cdf0e10cSrcweir pBindings, 75*cdf0e10cSrcweir this, 76*cdf0e10cSrcweir pParentWindow, 77*cdf0e10cSrcweir SdResId( nDockWinTitleResId ), 78*cdf0e10cSrcweir String( SdResId( nTitleBarResId ) ) ); 79*cdf0e10cSrcweir eChildAlignment = eAlignment; 80*cdf0e10cSrcweir static_cast<SfxDockingWindow*>(pWindow)->Initialize(pInfo); 81*cdf0e10cSrcweir SetHideNotDelete(sal_True); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pBindings->GetDispatcher()->GetFrame()); 84*cdf0e10cSrcweir if (pBase != NULL) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration(); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir PaneChildWindow::~PaneChildWindow (void) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir ViewShellBase* pBase = NULL; 96*cdf0e10cSrcweir PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(pWindow); 97*cdf0e10cSrcweir if (pDockingWindow != NULL) 98*cdf0e10cSrcweir pBase = ViewShellBase::GetViewShellBase( 99*cdf0e10cSrcweir pDockingWindow->GetBindings().GetDispatcher()->GetFrame()); 100*cdf0e10cSrcweir if (pBase != NULL) 101*cdf0e10cSrcweir framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration(); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir //===== LeftPaneImpressChildWindow ============================================ 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir LeftPaneImpressChildWindow::LeftPaneImpressChildWindow ( 112*cdf0e10cSrcweir ::Window* pParentWindow, 113*cdf0e10cSrcweir sal_uInt16 nId, 114*cdf0e10cSrcweir SfxBindings* pBindings, 115*cdf0e10cSrcweir SfxChildWinInfo* pInfo) 116*cdf0e10cSrcweir : PaneChildWindow( 117*cdf0e10cSrcweir pParentWindow, 118*cdf0e10cSrcweir nId, 119*cdf0e10cSrcweir pBindings, 120*cdf0e10cSrcweir pInfo, 121*cdf0e10cSrcweir FLT_LEFT_PANE_IMPRESS_DOCKING_WINDOW, 122*cdf0e10cSrcweir STR_LEFT_PANE_IMPRESS_TITLE, 123*cdf0e10cSrcweir SFX_ALIGN_LEFT) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir //===== LeftPaneDrawChildWindow =============================================== 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir LeftPaneDrawChildWindow::LeftPaneDrawChildWindow ( 133*cdf0e10cSrcweir ::Window* pParentWindow, 134*cdf0e10cSrcweir sal_uInt16 nId, 135*cdf0e10cSrcweir SfxBindings* pBindings, 136*cdf0e10cSrcweir SfxChildWinInfo* pInfo) 137*cdf0e10cSrcweir : PaneChildWindow( 138*cdf0e10cSrcweir pParentWindow, 139*cdf0e10cSrcweir nId, 140*cdf0e10cSrcweir pBindings, 141*cdf0e10cSrcweir pInfo, 142*cdf0e10cSrcweir FLT_LEFT_PANE_DRAW_DOCKING_WINDOW, 143*cdf0e10cSrcweir STR_LEFT_PANE_DRAW_TITLE, 144*cdf0e10cSrcweir SFX_ALIGN_LEFT) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir //====================================================================================================================== 152*cdf0e10cSrcweir //= ToolPanelChildWindow 153*cdf0e10cSrcweir //====================================================================================================================== 154*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------------- 155*cdf0e10cSrcweir ToolPanelChildWindow::ToolPanelChildWindow( ::Window* i_pParentWindow, sal_uInt16 i_nId, SfxBindings* i_pBindings, 156*cdf0e10cSrcweir SfxChildWinInfo* i_pChildWindowInfo ) 157*cdf0e10cSrcweir :PaneChildWindow( i_pParentWindow, i_nId, i_pBindings, i_pChildWindowInfo, 158*cdf0e10cSrcweir FLT_TOOL_PANEL_DOCKING_WINDOW, STR_RIGHT_PANE_TITLE, SFX_ALIGN_RIGHT ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir // just in case this window has been created by SFX, instead our resource framework: Ensure that the resource framework 161*cdf0e10cSrcweir // activates the task pane, so it is really filled with content (in opposite to the other SFX applications, the 162*cdf0e10cSrcweir // child window registered for SID_TASKPANE is not responsible for its content, but here in SD, it's the ToolPanelViewShell 163*cdf0e10cSrcweir // which has this responsibility. And this view shell is created implicitly via the resource framework.) 164*cdf0e10cSrcweir // #i113788# / 2010-09-03 / frank.schoenheit@oracle.com 165*cdf0e10cSrcweir SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() ); 166*cdf0e10cSrcweir ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() ); 167*cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ToolPanelChildWindow: no view shell access!" ); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) ); 170*cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pFrameworkHelper.get(), "ToolPanelChildWindow::ToolPanelChildWindow: no framework helper for the view shell!" ); 171*cdf0e10cSrcweir Reference<XConfigurationController> xConfigController( pFrameworkHelper->GetConfigurationController() ); 172*cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( xConfigController.is(), "ToolPanelChildWindow::ToolPanelChildWindow: no config controller!" ); 173*cdf0e10cSrcweir xConfigController->requestResourceActivation( 174*cdf0e10cSrcweir framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msRightPaneURL ), 175*cdf0e10cSrcweir ResourceActivationMode_ADD ); 176*cdf0e10cSrcweir xConfigController->requestResourceActivation( 177*cdf0e10cSrcweir framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL ), 178*cdf0e10cSrcweir ResourceActivationMode_REPLACE 179*cdf0e10cSrcweir ); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------------- 183*cdf0e10cSrcweir struct DelayedToolPanelActivation 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir DelayedToolPanelActivation( ToolPanelChildWindow& i_rToolPanelWindow, const ::rtl::OUString& i_rPanelURL ) 186*cdf0e10cSrcweir :m_rToolPanelWindow( i_rToolPanelWindow ) 187*cdf0e10cSrcweir ,m_sPanelURL( i_rPanelURL ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir void operator() (bool) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir m_rToolPanelWindow.ActivateToolPanel( m_sPanelURL ); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir private: 197*cdf0e10cSrcweir ToolPanelChildWindow& m_rToolPanelWindow; 198*cdf0e10cSrcweir const ::rtl::OUString m_sPanelURL; 199*cdf0e10cSrcweir }; 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------------- 202*cdf0e10cSrcweir void ToolPanelChildWindow::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() ); 205*cdf0e10cSrcweir ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() ); 206*cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ActivateToolPanel: no view shell access!" ); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir if ( i_rPanelURL.indexOf( framework::FrameworkHelper::msTaskPanelURLPrefix ) == 0 ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir // it's one of our standard panels known to the drawing framework 213*cdf0e10cSrcweir pFrameworkHelper->RequestTaskPanel( i_rPanelURL ); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir else 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir // TODO: it would be nice if the drawing framework were able to handle non-standard panels, installed by 218*cdf0e10cSrcweir // extensions, too. As long as this is not the case, we need to take the direct way ... 219*cdf0e10cSrcweir ::boost::shared_ptr< ViewShell > pViewShell = pFrameworkHelper->GetViewShell( framework::FrameworkHelper::msRightPaneURL ); 220*cdf0e10cSrcweir toolpanel::ToolPanelViewShell* pToolPanelViewShell = dynamic_cast< toolpanel::ToolPanelViewShell* >( pViewShell.get() ); 221*cdf0e10cSrcweir if ( pToolPanelViewShell ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir pToolPanelViewShell->ActivatePanel( i_rPanelURL ); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir else 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir Reference< XResourceId > xTaskPaneResource = pFrameworkHelper->RequestView( 228*cdf0e10cSrcweir framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL ); 229*cdf0e10cSrcweir pFrameworkHelper->RunOnResourceActivation( xTaskPaneResource, DelayedToolPanelActivation( *this, i_rPanelURL ) ); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir } // end of namespace ::sd 235