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 67 : SFX_IMPL_DOCKINGWINDOW_WITHID(LeftPaneImpressChildWindow, SID_LEFT_PANE_IMPRESS)
48 227 : SFX_IMPL_DOCKINGWINDOW_WITHID(LeftPaneDrawChildWindow, SID_LEFT_PANE_DRAW)
49 67 : SFX_IMPL_DOCKINGWINDOW_WITHID(ToolPanelChildWindow, SID_TASKPANE)
50 :
51 : //===== PaneChildWindow =======================================================
52 :
53 78 : 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 78 : : SfxChildWindow (pParentWindow, nId)
62 : {
63 : pWindow = new PaneDockingWindow (
64 : pBindings,
65 : this,
66 : pParentWindow,
67 : SdResId( nDockWinTitleResId ),
68 78 : String( SdResId( nTitleBarResId ) ) );
69 78 : eChildAlignment = eAlignment;
70 78 : static_cast<SfxDockingWindow*>(pWindow)->Initialize(pInfo);
71 78 : SetHideNotDelete(sal_True);
72 :
73 78 : ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pBindings->GetDispatcher()->GetFrame());
74 78 : if (pBase != NULL)
75 : {
76 78 : framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
77 : }
78 78 : }
79 :
80 :
81 :
82 :
83 156 : PaneChildWindow::~PaneChildWindow (void)
84 : {
85 78 : ViewShellBase* pBase = NULL;
86 78 : PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(pWindow);
87 78 : if (pDockingWindow != NULL)
88 : pBase = ViewShellBase::GetViewShellBase(
89 78 : pDockingWindow->GetBindings().GetDispatcher()->GetFrame());
90 78 : if (pBase != NULL)
91 78 : framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
92 78 : }
93 :
94 :
95 :
96 :
97 :
98 :
99 : //===== LeftPaneImpressChildWindow ============================================
100 :
101 13 : 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 13 : SFX_ALIGN_LEFT)
114 : {
115 13 : }
116 :
117 :
118 :
119 :
120 : //===== LeftPaneDrawChildWindow ===============================================
121 :
122 52 : 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 52 : SFX_ALIGN_LEFT)
135 : {
136 52 : }
137 :
138 :
139 13 : 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 13 : FLT_TOOL_PANEL_DOCKING_WINDOW, STR_RIGHT_PANE_TITLE, SFX_ALIGN_RIGHT )
143 : {
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 13 : SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() );
150 13 : ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() );
151 13 : ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ToolPanelChildWindow: no view shell access!" );
152 :
153 13 : const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) );
154 13 : ENSURE_OR_RETURN_VOID( pFrameworkHelper.get(), "ToolPanelChildWindow::ToolPanelChildWindow: no framework helper for the view shell!" );
155 26 : Reference<XConfigurationController> xConfigController( pFrameworkHelper->GetConfigurationController() );
156 13 : ENSURE_OR_RETURN_VOID( xConfigController.is(), "ToolPanelChildWindow::ToolPanelChildWindow: no config controller!" );
157 13 : xConfigController->requestResourceActivation(
158 : framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msRightPaneURL ),
159 13 : ResourceActivationMode_ADD );
160 13 : xConfigController->requestResourceActivation(
161 : framework::FrameworkHelper::CreateResourceId( framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL ),
162 : ResourceActivationMode_REPLACE
163 26 : );
164 : }
165 :
166 : //----------------------------------------------------------------------------------------------------------------------
167 0 : struct DelayedToolPanelActivation
168 : {
169 0 : DelayedToolPanelActivation( ToolPanelChildWindow& i_rToolPanelWindow, const OUString& i_rPanelURL )
170 : :m_rToolPanelWindow( i_rToolPanelWindow )
171 0 : ,m_sPanelURL( i_rPanelURL )
172 : {
173 0 : }
174 :
175 0 : void operator() (bool)
176 : {
177 0 : m_rToolPanelWindow.ActivateToolPanel( m_sPanelURL );
178 0 : }
179 :
180 : private:
181 : ToolPanelChildWindow& m_rToolPanelWindow;
182 : const OUString m_sPanelURL;
183 : };
184 :
185 : //----------------------------------------------------------------------------------------------------------------------
186 0 : void ToolPanelChildWindow::ActivateToolPanel( const OUString& i_rPanelURL )
187 : {
188 0 : SfxDockingWindow* pDockingWindow = dynamic_cast< SfxDockingWindow* >( GetWindow() );
189 0 : ViewShellBase* pViewShellBase = ViewShellBase::GetViewShellBase( pDockingWindow->GetBindings().GetDispatcher()->GetFrame() );
190 0 : ENSURE_OR_RETURN_VOID( pViewShellBase != NULL, "ToolPanelChildWindow::ActivateToolPanel: no view shell access!" );
191 :
192 0 : const ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper( framework::FrameworkHelper::Instance( *pViewShellBase ) );
193 :
194 0 : if ( i_rPanelURL.indexOf( framework::FrameworkHelper::msTaskPanelURLPrefix ) == 0 )
195 : {
196 : // it's one of our standard panels known to the drawing framework
197 0 : pFrameworkHelper->RequestSidebarPanel( i_rPanelURL );
198 : }
199 : else
200 : {
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 0 : ::boost::shared_ptr< ViewShell > pViewShell = pFrameworkHelper->GetViewShell( framework::FrameworkHelper::msRightPaneURL );
204 0 : toolpanel::ToolPanelViewShell* pToolPanelViewShell = dynamic_cast< toolpanel::ToolPanelViewShell* >( pViewShell.get() );
205 0 : if ( pToolPanelViewShell )
206 : {
207 0 : pToolPanelViewShell->ActivatePanel( i_rPanelURL );
208 : }
209 : else
210 : {
211 : Reference< XResourceId > xTaskPaneResource = pFrameworkHelper->RequestView(
212 0 : framework::FrameworkHelper::msTaskPaneURL, framework::FrameworkHelper::msRightPaneURL );
213 0 : pFrameworkHelper->RunOnResourceActivation( xTaskPaneResource, DelayedToolPanelActivation( *this, i_rPanelURL ) );
214 0 : }
215 0 : }
216 : }
217 :
218 11 : void ToolPanelChildWindow::RegisterChildWindowIfEnabled (sal_Bool bVisible,
219 : SfxModule *pMod,
220 : sal_uInt16 nFlags)
221 : {
222 11 : if ( ! SfxViewFrame::IsSidebarEnabled() )
223 11 : RegisterChildWindow( bVisible, pMod, nFlags );
224 11 : }
225 :
226 33 : } // end of namespace ::sd
227 :
228 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|