fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / PaneChildWindows.cxx
blobdf799740122814a1e5c8f9b9e218e413e7f41311
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
30 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
31 #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
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>
39 namespace sd {
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;
47 SFX_IMPL_DOCKINGWINDOW_WITHID(LeftPaneImpressChildWindow, SID_LEFT_PANE_IMPRESS)
48 SFX_IMPL_DOCKINGWINDOW_WITHID(LeftPaneDrawChildWindow, SID_LEFT_PANE_DRAW)
49 SFX_IMPL_DOCKINGWINDOW_WITHID(ToolPanelChildWindow, SID_TASKPANE)
51 //===== PaneChildWindow =======================================================
53 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 : SfxChildWindow (pParentWindow, nId)
63 pWindow = new PaneDockingWindow (
64 pBindings,
65 this,
66 pParentWindow,
67 SdResId( nDockWinTitleResId ),
68 String( SdResId( nTitleBarResId ) ) );
69 eChildAlignment = eAlignment;
70 static_cast<SfxDockingWindow*>(pWindow)->Initialize(pInfo);
71 SetHideNotDelete(sal_True);
73 ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pBindings->GetDispatcher()->GetFrame());
74 if (pBase != NULL)
76 framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
83 PaneChildWindow::~PaneChildWindow (void)
85 ViewShellBase* pBase = NULL;
86 PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(pWindow);
87 if (pDockingWindow != NULL)
88 pBase = ViewShellBase::GetViewShellBase(
89 pDockingWindow->GetBindings().GetDispatcher()->GetFrame());
90 if (pBase != NULL)
91 framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
99 //===== LeftPaneImpressChildWindow ============================================
101 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 SFX_ALIGN_LEFT)
120 //===== LeftPaneDrawChildWindow ===============================================
122 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 SFX_ALIGN_LEFT)
139 ToolPanelChildWindow::ToolPanelChildWindow( ::Window* i_pParentWindow, sal_uInt16 i_nId, SfxBindings* i_pBindings,
140 SfxChildWinInfo* i_pChildWindowInfo )
141 :PaneChildWindow( i_pParentWindow, i_nId, i_pBindings, i_pChildWindowInfo,
142 FLT_TOOL_PANEL_DOCKING_WINDOW, STR_RIGHT_PANE_TITLE, SFX_ALIGN_RIGHT )
144 // just in case this window has been created by SFX, instead our resource framework: Ensure that the resource framework
145 // activates the task pane, so it is really filled with content (in opposite to the other SFX applications, the
146 // child window registered for SID_TASKPANE is not responsible for its content, but here in SD, it's the ToolPanelViewShell
147 // which has this responsibility. And this view shell is created implicitly via the resource framework.)
148 // #i113788#
149 SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() );
150 ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() );
151 ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ToolPanelChildWindow: no view shell access!" );
153 const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) );
154 ENSURE_OR_RETURN_VOID( pFrameworkHelper.get(), "ToolPanelChildWindow::ToolPanelChildWindow: no framework helper for the view shell!" );
155 Reference<XConfigurationController> xConfigController( pFrameworkHelper->GetConfigurationController() );
156 ENSURE_OR_RETURN_VOID( xConfigController.is(), "ToolPanelChildWindow::ToolPanelChildWindow: no config controller!" );
157 xConfigController->requestResourceActivation(
158 framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msRightPaneURL ),
159 ResourceActivationMode_ADD );
160 xConfigController->requestResourceActivation(
161 framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL ),
162 ResourceActivationMode_REPLACE
166 //----------------------------------------------------------------------------------------------------------------------
167 struct DelayedToolPanelActivation
169 DelayedToolPanelActivation( ToolPanelChildWindow& i_rToolPanelWindow, const OUString& i_rPanelURL )
170 :m_rToolPanelWindow( i_rToolPanelWindow )
171 ,m_sPanelURL( i_rPanelURL )
175 void operator() (bool)
177 m_rToolPanelWindow.ActivateToolPanel( m_sPanelURL );
180 private:
181 ToolPanelChildWindow& m_rToolPanelWindow;
182 const OUString m_sPanelURL;
185 //----------------------------------------------------------------------------------------------------------------------
186 void ToolPanelChildWindow::ActivateToolPanel( const OUString& i_rPanelURL )
188 SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() );
189 ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() );
190 ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ActivateToolPanel: no view shell access!" );
192 const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) );
194 if ( i_rPanelURL.indexOf( framework::FrameworkHelper::msTaskPanelURLPrefix ) == 0 )
196 // it's one of our standard panels known to the drawing framework
197 pFrameworkHelper->RequestSidebarPanel( i_rPanelURL );
199 else
201 // TODO: it would be nice if the drawing framework were able to handle non-standard panels, installed by
202 // extensions, too. As long as this is not the case, we need to take the direct way ...
203 ::boost::shared_ptr< ViewShell > pViewShell = pFrameworkHelper->GetViewShell( framework::FrameworkHelper::msRightPaneURL );
204 toolpanel::ToolPanelViewShell* pToolPanelViewShell = dynamic_cast< toolpanel::ToolPanelViewShell* >( pViewShell.get() );
205 if ( pToolPanelViewShell )
207 pToolPanelViewShell->ActivatePanel( i_rPanelURL );
209 else
211 Reference< XResourceId > xTaskPaneResource = pFrameworkHelper->RequestView(
212 framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL );
213 pFrameworkHelper->RunOnResourceActivation( xTaskPaneResource, DelayedToolPanelActivation( *this, i_rPanelURL ) );
218 } // end of namespace ::sd
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */