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