/src/libreoffice/sd/source/ui/view/ViewShellBase.cxx
Line | Count | Source |
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 <comphelper/processfactory.hxx> |
21 | | |
22 | | #include <boost/property_tree/json_parser.hpp> |
23 | | |
24 | | #include <ViewShellBase.hxx> |
25 | | #include <algorithm> |
26 | | #include <EventMultiplexer.hxx> |
27 | | #include <cache/SlsPageCacheManager.hxx> |
28 | | #include <app.hrc> |
29 | | #include <slideshow.hxx> |
30 | | #include <unokywds.hxx> |
31 | | #include <svx/svxids.hrc> |
32 | | #include <DrawDocShell.hxx> |
33 | | #include <ViewShellManager.hxx> |
34 | | #include <DrawController.hxx> |
35 | | #include <FrameView.hxx> |
36 | | #include <ViewTabBar.hxx> |
37 | | #include <ResourceId.hxx> |
38 | | #include <sfx2/event.hxx> |
39 | | #include <drawdoc.hxx> |
40 | | #include <sdpage.hxx> |
41 | | #include <sfx2/dispatch.hxx> |
42 | | #include <sfx2/request.hxx> |
43 | | #include <sfx2/printer.hxx> |
44 | | #include <DrawViewShell.hxx> |
45 | | #include <OutlineViewShell.hxx> |
46 | | #include <FormShellManager.hxx> |
47 | | #include <ToolBarManager.hxx> |
48 | | #include <Window.hxx> |
49 | | #include <framework/ConfigurationController.hxx> |
50 | | #include <framework/ConfigurationChangeEvent.hxx> |
51 | | #include <DocumentRenderer.hxx> |
52 | | #include <optsitem.hxx> |
53 | | #include <sdmod.hxx> |
54 | | |
55 | | #include <com/sun/star/document/XViewDataSupplier.hpp> |
56 | | #include <com/sun/star/container/XIndexAccess.hpp> |
57 | | #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> |
58 | | #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> |
59 | | #include <com/sun/star/uno/DeploymentException.hpp> |
60 | | #include <framework/FrameworkHelper.hxx> |
61 | | |
62 | | #include <sal/log.hxx> |
63 | | #include <rtl/ref.hxx> |
64 | | #include <sfx2/msg.hxx> |
65 | | #include <sfx2/objface.hxx> |
66 | | #include <sfx2/viewfrm.hxx> |
67 | | #include <svl/intitem.hxx> |
68 | | #include <svl/whiter.hxx> |
69 | | #include <svx/theme/ThemeColorChangerCommon.hxx> |
70 | | #include <vcl/commandinfoprovider.hxx> |
71 | | #include <vcl/settings.hxx> |
72 | | #include <vcl/svapp.hxx> |
73 | | |
74 | | #include <sfx2/notebookbar/SfxNotebookBar.hxx> |
75 | | |
76 | | #include <comphelper/diagnose_ex.hxx> |
77 | | #include <comphelper/lok.hxx> |
78 | | #include <sfx2/lokhelper.hxx> |
79 | | #include <LibreOfficeKit/LibreOfficeKitEnums.h> |
80 | | #include <editeng/editview.hxx> |
81 | | #include <tools/svborder.hxx> |
82 | | #include <o3tl/unreachable.hxx> |
83 | | |
84 | | #include <fubullet.hxx> |
85 | | #include <drawview.hxx> |
86 | | |
87 | | using namespace sd; |
88 | | #define ShellClass_ViewShellBase |
89 | | #include <sdslots.hxx> |
90 | | |
91 | | using ::sd::framework::FrameworkHelper; |
92 | | |
93 | | using namespace com::sun::star; |
94 | | using namespace com::sun::star::beans; |
95 | | using namespace com::sun::star::container; |
96 | | using namespace com::sun::star::drawing::framework; |
97 | | using namespace com::sun::star::lang; |
98 | | using namespace com::sun::star::uno; |
99 | | |
100 | | namespace { |
101 | | |
102 | | class CurrentPageSetter |
103 | | { |
104 | | public: |
105 | | explicit CurrentPageSetter (ViewShellBase& rBase); |
106 | | void operator () (bool); |
107 | | private: |
108 | | ViewShellBase& mrBase; |
109 | | }; |
110 | | |
111 | | } // end of anonymous namespace |
112 | | |
113 | | namespace sd { |
114 | | |
115 | | class ViewShellBase::Implementation |
116 | | { |
117 | | public: |
118 | | SdViewOptions maViewOptions; |
119 | | |
120 | | /** Main controller of the view shell. During the switching from one |
121 | | stacked shell to another this pointer may be NULL. |
122 | | */ |
123 | | ::rtl::Reference<DrawController> mpController; |
124 | | |
125 | | /** The view tab bar is the control for switching between different |
126 | | views in one pane. |
127 | | */ |
128 | | ::rtl::Reference<ViewTabBar> mpViewTabBar; |
129 | | |
130 | | // contains the complete area of the current view relative to the frame window |
131 | | ::tools::Rectangle maClientArea; |
132 | | |
133 | | // This is set to true when PrepareClose() is called. |
134 | | bool mbIsClosing; |
135 | | |
136 | | /** The view window is the parent of all UI elements that belong to the |
137 | | view or ViewShell. This comprises the rulers, the scroll bars, and |
138 | | the content window. |
139 | | It does not include the ViewTabBar. |
140 | | */ |
141 | | VclPtr<vcl::Window> mpViewWindow; |
142 | | std::shared_ptr<ToolBarManager> mpToolBarManager; |
143 | | std::shared_ptr<ViewShellManager> mpViewShellManager; |
144 | | std::shared_ptr<sdtools::EventMultiplexer> mpEventMultiplexer; |
145 | | std::unique_ptr<FormShellManager> mpFormShellManager; |
146 | | |
147 | | explicit Implementation (ViewShellBase& rBase); |
148 | | ~Implementation(); |
149 | | |
150 | | void LateInit(); |
151 | | |
152 | | /** Show or hide the ViewTabBar. |
153 | | @param bShow |
154 | | When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden. |
155 | | */ |
156 | | void ShowViewTabBar (bool bShow); |
157 | | |
158 | | void SetUserWantsTabBar(bool inValue); |
159 | 0 | bool GetUserWantsTabBar() const { return mbUserWantsTabBar; } |
160 | | |
161 | | /** Common code of ViewShellBase::OuterResizePixel() and |
162 | | ViewShellBase::InnerResizePixel(). |
163 | | */ |
164 | | void ResizePixel ( |
165 | | const Point& rOrigin, |
166 | | const Size& rSize, |
167 | | bool bOuterResize); |
168 | | |
169 | | /** Show or hide the specified pane. The visibility state is taken |
170 | | from the given request. |
171 | | @param rRequest |
172 | | The request determines the new visibility state. The state can |
173 | | either be toggled or be set to a given value. |
174 | | @param rsPaneURL |
175 | | This URL specifies the pane whose visibility state to set. |
176 | | @param rsViewURL |
177 | | When the pane becomes visible then this view URL specifies which |
178 | | type of view to show in it. |
179 | | */ |
180 | | void SetPaneVisibility ( |
181 | | const SfxRequest& rRequest, |
182 | | const OUString& rsPaneURL, |
183 | | const OUString& rsViewURL); |
184 | | |
185 | | void GetSlotState (SfxItemSet& rSet); |
186 | | |
187 | | void ProcessRestoreEditingViewSlot(); |
188 | | |
189 | | private: |
190 | | ViewShellBase& mrBase; |
191 | | bool mbUserWantsTabBar; |
192 | | bool mbTabBarShouldBeVisible; |
193 | | /** Hold a reference to the page cache manager of the slide sorter in |
194 | | order to ensure that it stays alive while the ViewShellBase is |
195 | | alive. |
196 | | */ |
197 | | std::shared_ptr<slidesorter::cache::PageCacheManager> mpPageCacheManager; |
198 | | }; |
199 | | |
200 | | namespace { |
201 | | /** The only task of this window is to forward key presses to the content |
202 | | window of the main view shell. With the key press it forwards the focus |
203 | | so that it is not called very often. |
204 | | */ |
205 | | class FocusForwardingWindow : public vcl::Window |
206 | | { |
207 | | public: |
208 | | FocusForwardingWindow (vcl::Window& rParentWindow, ViewShellBase& rBase); |
209 | | virtual ~FocusForwardingWindow() override; |
210 | | virtual void dispose() override; |
211 | | virtual void KeyInput (const KeyEvent& rEvent) override; |
212 | | virtual void Command (const CommandEvent& rEvent) override; |
213 | | |
214 | | private: |
215 | | ViewShellBase& mrBase; |
216 | | }; |
217 | | } // end of anonymous namespace |
218 | | |
219 | | //===== ViewShellBase ========================================================= |
220 | | |
221 | | |
222 | | // We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a |
223 | | // new ViewShellBase object has been constructed. |
224 | | |
225 | | SFX_IMPL_SUPERCLASS_INTERFACE(ViewShellBase, SfxViewShell) |
226 | | |
227 | | void ViewShellBase::InitInterface_Impl() |
228 | 6 | { |
229 | 6 | } |
230 | | |
231 | | ViewShellBase::ViewShellBase ( |
232 | | SfxViewFrame& _rFrame, |
233 | | SfxViewShell*) |
234 | 0 | : SfxViewShell(_rFrame, SfxViewShellFlags::HAS_PRINTOPTIONS), |
235 | 0 | mpDocShell (nullptr), |
236 | 0 | mpDocument (nullptr) |
237 | 0 | { |
238 | 0 | mpImpl.reset(new Implementation(*this)); |
239 | 0 | mpImpl->mpViewWindow = VclPtr<FocusForwardingWindow>::Create(_rFrame.GetWindow(),*this); |
240 | 0 | mpImpl->mpViewWindow->SetBackground(Wallpaper()); |
241 | |
|
242 | 0 | _rFrame.GetWindow().SetBackground(Application::GetSettings().GetStyleSettings().GetLightColor()); |
243 | | |
244 | | // Set up the members in the correct order. |
245 | 0 | if (auto pDrawDocShell = dynamic_cast< DrawDocShell *>( GetViewFrame().GetObjectShell() )) |
246 | 0 | mpDocShell = pDrawDocShell; |
247 | 0 | if (mpDocShell != nullptr) |
248 | 0 | mpDocument = mpDocShell->GetDoc(); |
249 | 0 | mpImpl->mpViewShellManager = std::make_shared<ViewShellManager>(*this); |
250 | |
|
251 | 0 | SetWindow(mpImpl->mpViewWindow.get()); |
252 | | |
253 | | // Hide the window to avoid complaints from Sfx...SwitchViewShell... |
254 | 0 | _rFrame.GetWindow().Hide(); |
255 | 0 | } |
256 | | |
257 | | /** In this destructor the order in which some of the members are destroyed |
258 | | (and/or being prepared to being destroyed) is important. Change it only |
259 | | when you know what you are doing. |
260 | | */ |
261 | | ViewShellBase::~ViewShellBase() |
262 | 0 | { |
263 | | // Notify other LOK views that we are going away. |
264 | 0 | SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", "false"_ostr); |
265 | 0 | SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", ""_ostr); |
266 | 0 | SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY"_ostr); |
267 | |
|
268 | 0 | sfx2::SfxNotebookBar::CloseMethod(GetFrame()->GetBindings()); |
269 | |
|
270 | 0 | rtl::Reference<SlideShow> xSlideShow(SlideShow::GetSlideShow(*this)); |
271 | 0 | if (xSlideShow.is() && xSlideShow->dependsOn(this)) |
272 | 0 | SlideShow::Stop(*this); |
273 | 0 | xSlideShow.clear(); |
274 | | |
275 | | // Tell the controller that the ViewShellBase is not available anymore. |
276 | 0 | if (mpImpl->mpController) |
277 | 0 | mpImpl->mpController->ReleaseViewShellBase(); |
278 | | |
279 | | // We have to hide the main window to prevent SFX complaining after a |
280 | | // reload about it being already visible. |
281 | 0 | ViewShell* pShell = GetMainViewShell().get(); |
282 | 0 | if (pShell!=nullptr |
283 | 0 | && pShell->GetActiveWindow()!=nullptr |
284 | 0 | && pShell->GetActiveWindow()->GetParent()!=nullptr) |
285 | 0 | { |
286 | 0 | pShell->GetActiveWindow()->GetParent()->Hide(); |
287 | 0 | } |
288 | |
|
289 | 0 | mpImpl->mpToolBarManager->Shutdown(); |
290 | 0 | mpImpl->mpViewShellManager->Shutdown(); |
291 | |
|
292 | 0 | EndListening(GetViewFrame()); |
293 | 0 | EndListening(*GetDocShell()); |
294 | |
|
295 | 0 | SetWindow(nullptr); |
296 | |
|
297 | 0 | mpImpl->mpFormShellManager.reset(); |
298 | 0 | } |
299 | | |
300 | | void ViewShellBase::LateInit (const OUString& rsDefaultView) |
301 | 0 | { |
302 | 0 | StartListening(GetViewFrame(), DuplicateHandling::Prevent); |
303 | 0 | StartListening(*GetDocShell(), DuplicateHandling::Prevent); |
304 | 0 | mpImpl->LateInit(); |
305 | 0 | InitializeFramework(); |
306 | |
|
307 | 0 | mpImpl->mpEventMultiplexer = std::make_shared<sdtools::EventMultiplexer>(*this); |
308 | |
|
309 | 0 | mpImpl->mpFormShellManager = std::make_unique<FormShellManager>(*this); |
310 | |
|
311 | 0 | mpImpl->mpToolBarManager = ToolBarManager::Create( |
312 | 0 | *this, |
313 | 0 | mpImpl->mpEventMultiplexer, |
314 | 0 | mpImpl->mpViewShellManager); |
315 | |
|
316 | 0 | try |
317 | 0 | { |
318 | 0 | rtl::Reference<::sd::DrawController> xControllerManager (GetDrawController()); |
319 | 0 | rtl::Reference<::sd::framework::ConfigurationController> xConfigurationController; |
320 | 0 | if (xControllerManager) |
321 | 0 | xConfigurationController = xControllerManager->getConfigurationController(); |
322 | 0 | if (xConfigurationController.is()) |
323 | 0 | { |
324 | 0 | OUString sView (rsDefaultView); |
325 | 0 | if (sView.isEmpty()) |
326 | 0 | sView = GetInitialViewShellType(); |
327 | |
|
328 | 0 | FrameworkHelper::Instance(*this); |
329 | | |
330 | | // Create the resource ids for the center pane and view. |
331 | 0 | const rtl::Reference<framework::ResourceId> xCenterPaneId ( |
332 | 0 | new ::sd::framework::ResourceId(FrameworkHelper::msCenterPaneURL)); |
333 | 0 | const rtl::Reference<framework::ResourceId> xCenterViewId ( |
334 | 0 | new ::sd::framework::ResourceId(sView, xCenterPaneId)); |
335 | | |
336 | | // Request center pane and view. |
337 | 0 | xConfigurationController->requestResourceActivation(xCenterPaneId, framework::ResourceActivationMode::ADD); |
338 | 0 | xConfigurationController->requestResourceActivation(xCenterViewId, framework::ResourceActivationMode::REPLACE); |
339 | | |
340 | | // Process configuration events synchronously until the center view |
341 | | // has been created. |
342 | 0 | while ( !xConfigurationController->getResource(xCenterViewId).is() |
343 | 0 | && xConfigurationController->hasPendingRequests()) |
344 | 0 | { |
345 | 0 | xConfigurationController->ProcessEvent(); |
346 | 0 | } |
347 | 0 | } |
348 | 0 | } |
349 | 0 | catch (const RuntimeException&) |
350 | 0 | { |
351 | 0 | } |
352 | | |
353 | | // AutoLayouts have to be ready. |
354 | 0 | GetDocument()->StopWorkStartupDelay(); |
355 | |
|
356 | 0 | UpdateBorder(); |
357 | | |
358 | | // Remember the type of the current main view shell in the frame view. |
359 | 0 | ViewShell* pViewShell = GetMainViewShell().get(); |
360 | 0 | if (pViewShell != nullptr) |
361 | 0 | { |
362 | 0 | FrameView* pFrameView = pViewShell->GetFrameView(); |
363 | 0 | if (pFrameView != nullptr) |
364 | 0 | pFrameView->SetViewShellTypeOnLoad(pViewShell->GetShellType()); |
365 | 0 | } |
366 | | // Show/Hide the TabBar |
367 | 0 | SdOptions* pOptions = SdModule::get()->GetSdOptions(GetDocument()->GetDocumentType()); |
368 | 0 | bool bIsTabBarVisible = pOptions->IsTabBarVisible(); |
369 | 0 | mpImpl->SetUserWantsTabBar( bIsTabBarVisible ); |
370 | 0 | } |
371 | | |
372 | | std::shared_ptr<ViewShellManager> const & ViewShellBase::GetViewShellManager() const |
373 | 0 | { |
374 | 0 | return mpImpl->mpViewShellManager; |
375 | 0 | } |
376 | | |
377 | | std::shared_ptr<ViewShell> ViewShellBase::GetMainViewShell() const |
378 | 0 | { |
379 | 0 | std::shared_ptr<ViewShell> pMainViewShell ( |
380 | 0 | framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this)) |
381 | 0 | ->GetViewShell(framework::FrameworkHelper::msCenterPaneURL)); |
382 | 0 | if (pMainViewShell == nullptr) |
383 | 0 | pMainViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this)) |
384 | 0 | ->GetViewShell(framework::FrameworkHelper::msFullScreenPaneURL); |
385 | 0 | return pMainViewShell; |
386 | 0 | } |
387 | | |
388 | | ViewShellBase* ViewShellBase::GetViewShellBase (SfxViewFrame const * pViewFrame) |
389 | 0 | { |
390 | 0 | ViewShellBase* pBase = nullptr; |
391 | |
|
392 | 0 | if (pViewFrame != nullptr) |
393 | 0 | { |
394 | | // Get the view shell for the frame and cast it to |
395 | | // sd::ViewShellBase. |
396 | 0 | SfxViewShell* pSfxViewShell = pViewFrame->GetViewShell(); |
397 | 0 | pBase = dynamic_cast< ::sd::ViewShellBase *>( pSfxViewShell ); |
398 | 0 | } |
399 | |
|
400 | 0 | return pBase; |
401 | 0 | } |
402 | | |
403 | | void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) |
404 | 0 | { |
405 | 0 | SfxViewShell::Notify(rBC, rHint); |
406 | |
|
407 | 0 | const SfxHintId nHintId = rHint.GetId(); |
408 | |
|
409 | 0 | if (nHintId == SfxHintId::ThisIsAnSfxEventHint) |
410 | 0 | { |
411 | 0 | switch (static_cast<const SfxEventHint&>(rHint).GetEventId()) |
412 | 0 | { |
413 | 0 | case SfxEventHintId::OpenDoc: |
414 | 0 | { |
415 | 0 | const sal_uInt16 nStartingSlide |
416 | 0 | = GetDocument() ? GetDocument()->GetStartWithPresentation() : 0; |
417 | 0 | if (nStartingSlide) |
418 | 0 | { |
419 | 0 | SfxUInt16Item aItem(FN_PARAM_1, nStartingSlide); |
420 | 0 | GetViewFrame().GetDispatcher()->ExecuteList( |
421 | 0 | SID_PRESENTATION, SfxCallMode::ASYNCHRON, { &aItem }); |
422 | 0 | } |
423 | 0 | break; |
424 | 0 | } |
425 | 0 | default: |
426 | 0 | break; |
427 | 0 | } |
428 | 0 | } |
429 | 0 | else |
430 | 0 | { |
431 | 0 | switch (nHintId) |
432 | 0 | { |
433 | 0 | case SfxHintId::LanguageChanged: |
434 | 0 | { |
435 | 0 | GetViewFrame().GetBindings().Invalidate(SID_LANGUAGE_STATUS); |
436 | 0 | } |
437 | 0 | break; |
438 | | |
439 | 0 | default: |
440 | 0 | break; |
441 | 0 | } |
442 | 0 | } |
443 | 0 | } |
444 | | |
445 | | void ViewShellBase::InitializeFramework() |
446 | 0 | { |
447 | 0 | } |
448 | | |
449 | | OUString ViewShellBase::GetSelectionText(bool bCompleteWords, bool /*bOnlyASample*/) |
450 | 0 | { |
451 | 0 | std::shared_ptr<ViewShell> const pMainShell(GetMainViewShell()); |
452 | 0 | DrawViewShell *const pDrawViewShell( |
453 | 0 | dynamic_cast<DrawViewShell*>(pMainShell.get())); |
454 | 0 | return pDrawViewShell |
455 | 0 | ? pDrawViewShell->GetSelectionText(bCompleteWords) |
456 | 0 | : SfxViewShell::GetSelectionText(bCompleteWords); |
457 | 0 | } |
458 | | |
459 | | bool ViewShellBase::HasSelection(bool bText) const |
460 | 0 | { |
461 | 0 | std::shared_ptr<ViewShell> const pMainShell(GetMainViewShell()); |
462 | 0 | DrawViewShell *const pDrawViewShell( |
463 | 0 | dynamic_cast<DrawViewShell*>(pMainShell.get())); |
464 | 0 | return pDrawViewShell |
465 | 0 | ? pDrawViewShell->HasSelection(bText) |
466 | 0 | : SfxViewShell::HasSelection(bText); |
467 | 0 | } |
468 | | |
469 | | void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize, bool) |
470 | 0 | { |
471 | 0 | Size aObjSize = GetObjectShell()->GetVisArea().GetSize(); |
472 | 0 | if ( !aObjSize.IsEmpty() ) |
473 | 0 | { |
474 | 0 | SvBorder aBorder( GetBorderPixel() ); |
475 | 0 | Size aSize( rSize ); |
476 | 0 | aSize.AdjustWidth( -(aBorder.Left() + aBorder.Right()) ); |
477 | 0 | aSize.AdjustHeight( -(aBorder.Top() + aBorder.Bottom()) ); |
478 | 0 | Size aObjSizePixel = mpImpl->mpViewWindow->LogicToPixel(aObjSize, MapMode(MapUnit::Map100thMM)); |
479 | 0 | SfxViewShell::SetZoomFactor( |
480 | 0 | Fraction( aSize.Width(), std::max( aObjSizePixel.Width(), static_cast<::tools::Long>(1) ) ), |
481 | 0 | Fraction( aSize.Height(), std::max( aObjSizePixel.Height(), static_cast<::tools::Long>(1)) ) ); |
482 | 0 | } |
483 | |
|
484 | 0 | mpImpl->ResizePixel(rOrigin, rSize, false); |
485 | 0 | } |
486 | | |
487 | | void ViewShellBase::OuterResizePixel (const Point& rOrigin, const Size &rSize) |
488 | 0 | { |
489 | 0 | mpImpl->ResizePixel (rOrigin, rSize, true); |
490 | 0 | } |
491 | | |
492 | | void ViewShellBase::Rearrange() |
493 | 0 | { |
494 | | // There is a bug in the communication between embedded objects and the |
495 | | // framework::LayoutManager that leads to missing resize updates. The |
496 | | // following workaround enforces such an update by cycling the border to |
497 | | // zero and back to the current value. |
498 | 0 | if (GetWindow() != nullptr) |
499 | 0 | { |
500 | 0 | SetBorderPixel(SvBorder()); |
501 | 0 | UpdateBorder(true); |
502 | 0 | } |
503 | 0 | else |
504 | 0 | { |
505 | 0 | SAL_WARN("sd.view", "Rearrange: window missing"); |
506 | 0 | } |
507 | | |
508 | 0 | GetViewFrame().Resize(true); |
509 | 0 | } |
510 | | |
511 | | ErrCode ViewShellBase::DoVerb(sal_Int32 nVerb) |
512 | 0 | { |
513 | 0 | ErrCode aResult = ERRCODE_NONE; |
514 | |
|
515 | 0 | ::sd::ViewShell* pShell = GetMainViewShell().get(); |
516 | 0 | if (pShell != nullptr) |
517 | 0 | aResult = pShell->DoVerb(nVerb); |
518 | |
|
519 | 0 | return aResult; |
520 | 0 | } |
521 | | |
522 | | Reference<view::XRenderable> ViewShellBase::GetRenderable() |
523 | 0 | { |
524 | | // Create a new DocumentRenderer on every call. It observes the life |
525 | | // time of this ViewShellBase object. |
526 | 0 | return Reference<view::XRenderable>(new DocumentRenderer(*this)); |
527 | 0 | } |
528 | | |
529 | | SfxPrinter* ViewShellBase::GetPrinter (bool bCreate) |
530 | 0 | { |
531 | 0 | OSL_ASSERT(mpImpl != nullptr); |
532 | |
|
533 | 0 | return GetDocShell()->GetPrinter (bCreate); |
534 | 0 | } |
535 | | |
536 | | sal_uInt16 ViewShellBase::SetPrinter ( |
537 | | SfxPrinter* pNewPrinter, |
538 | | SfxPrinterChangeFlags nDiffFlags) |
539 | 0 | { |
540 | 0 | OSL_ASSERT(mpImpl != nullptr); |
541 | |
|
542 | 0 | GetDocShell()->SetPrinter(pNewPrinter); |
543 | |
|
544 | 0 | if ( (nDiffFlags & SfxPrinterChangeFlags::CHG_ORIENTATION || |
545 | 0 | nDiffFlags & SfxPrinterChangeFlags::CHG_SIZE) && pNewPrinter ) |
546 | 0 | { |
547 | 0 | MapMode aMap = pNewPrinter->GetMapMode(); |
548 | 0 | aMap.SetMapUnit(MapUnit::Map100thMM); |
549 | 0 | MapMode aOldMap = pNewPrinter->GetMapMode(); |
550 | 0 | pNewPrinter->SetMapMode(aMap); |
551 | 0 | Size aNewSize = pNewPrinter->GetOutputSize(); |
552 | |
|
553 | 0 | std::shared_ptr<DrawViewShell> pDrawViewShell ( |
554 | 0 | std::dynamic_pointer_cast<DrawViewShell>(GetMainViewShell())); |
555 | 0 | if (pDrawViewShell) |
556 | 0 | { |
557 | 0 | SdPage* pPage = GetDocument()->GetSdPage( |
558 | 0 | 0, PageKind::Standard ); |
559 | 0 | pDrawViewShell->SetPageSizeAndBorder ( |
560 | 0 | pDrawViewShell->GetPageKind(), |
561 | 0 | aNewSize, |
562 | 0 | -1,-1,-1,-1, |
563 | 0 | false/*bScaleAll*/, |
564 | 0 | pNewPrinter->GetOrientation(), |
565 | 0 | pPage->GetPaperBin(), |
566 | 0 | pPage->IsBackgroundFullSize()); |
567 | 0 | } |
568 | |
|
569 | 0 | pNewPrinter->SetMapMode(aOldMap); |
570 | 0 | } |
571 | |
|
572 | 0 | return 0; |
573 | 0 | } |
574 | | |
575 | | void ViewShellBase::UIActivating( SfxInPlaceClient* pClient ) |
576 | 0 | { |
577 | 0 | mpImpl->ShowViewTabBar(false); |
578 | |
|
579 | 0 | ViewShell* pViewShell = GetMainViewShell().get(); |
580 | 0 | if ( pViewShell ) |
581 | 0 | pViewShell->UIActivating( pClient ); |
582 | |
|
583 | 0 | SfxViewShell::UIActivating( pClient ); |
584 | 0 | } |
585 | | |
586 | | void ViewShellBase::UIDeactivated( SfxInPlaceClient* pClient ) |
587 | 0 | { |
588 | 0 | SfxViewShell::UIDeactivated( pClient ); |
589 | |
|
590 | 0 | mpImpl->ShowViewTabBar(true); |
591 | |
|
592 | 0 | ViewShell* pViewShell = GetMainViewShell().get(); |
593 | 0 | if ( pViewShell ) |
594 | 0 | pViewShell->UIDeactivated( pClient ); |
595 | 0 | } |
596 | | |
597 | | SvBorder ViewShellBase::GetBorder (bool ) |
598 | 0 | { |
599 | 0 | int nTop = 0; |
600 | 0 | if (mpImpl->mpViewTabBar.is() && mpImpl->mpViewTabBar->GetTabControl()->IsVisible()) |
601 | 0 | nTop = mpImpl->mpViewTabBar->GetHeight(); |
602 | 0 | return SvBorder(0,nTop,0,0); |
603 | 0 | } |
604 | | |
605 | | void ViewShellBase::Execute (SfxRequest& rRequest) |
606 | 0 | { |
607 | 0 | sal_uInt16 nSlotId = rRequest.GetSlot(); |
608 | |
|
609 | 0 | switch (nSlotId) |
610 | 0 | { |
611 | 0 | case SID_SWITCH_SHELL: |
612 | 0 | { |
613 | 0 | DrawController* pDrawController(GetDrawController()); |
614 | 0 | if (pDrawController) |
615 | 0 | { |
616 | 0 | rtl::Reference<framework::ConfigurationController> xConfigurationController ( |
617 | 0 | pDrawController->getConfigurationController()); |
618 | 0 | if (xConfigurationController.is()) |
619 | 0 | xConfigurationController->update(); |
620 | 0 | } |
621 | 0 | } |
622 | 0 | break; |
623 | | |
624 | 0 | case SID_LEFT_PANE_DRAW: |
625 | 0 | mpImpl->SetPaneVisibility( |
626 | 0 | rRequest, |
627 | 0 | framework::FrameworkHelper::msLeftDrawPaneURL, |
628 | 0 | framework::FrameworkHelper::msSlideSorterURL); |
629 | 0 | break; |
630 | | |
631 | 0 | case SID_LEFT_PANE_IMPRESS: |
632 | 0 | mpImpl->SetPaneVisibility( |
633 | 0 | rRequest, |
634 | 0 | framework::FrameworkHelper::msLeftImpressPaneURL, |
635 | 0 | framework::FrameworkHelper::msSlideSorterURL); |
636 | 0 | break; |
637 | | |
638 | 0 | case SID_BOTTOM_PANE_IMPRESS: |
639 | 0 | mpImpl->SetPaneVisibility( |
640 | 0 | rRequest, |
641 | 0 | framework::FrameworkHelper::msBottomImpressPaneURL, |
642 | 0 | framework::FrameworkHelper::msNotesPanelViewURL); |
643 | 0 | break; |
644 | | |
645 | 0 | case SID_TOGGLE_TABBAR_VISIBILITY: |
646 | 0 | { |
647 | 0 | SdOptions* pOptions = SdModule::get()->GetSdOptions(GetDocument()->GetDocumentType()); |
648 | 0 | bool bIsTabBarVisible = pOptions->IsTabBarVisible(); |
649 | 0 | pOptions->SetTabBarVisible( !bIsTabBarVisible ); |
650 | 0 | mpImpl->SetUserWantsTabBar( !bIsTabBarVisible ); |
651 | 0 | rRequest.Done(); |
652 | 0 | } |
653 | 0 | break; |
654 | | |
655 | | // draw |
656 | 0 | case SID_DRAWINGMODE: |
657 | | // impress normal |
658 | 0 | case SID_NORMAL_MULTI_PANE_GUI: |
659 | 0 | case SID_NOTES_MODE: |
660 | 0 | case SID_OUTLINE_MODE: |
661 | 0 | case SID_SLIDE_SORTER_MULTI_PANE_GUI: |
662 | 0 | case SID_SLIDE_SORTER_MODE: |
663 | | // impress master |
664 | 0 | case SID_SLIDE_MASTER_MODE: |
665 | 0 | case SID_NOTES_MASTER_MODE: |
666 | 0 | case SID_HANDOUT_MASTER_MODE: |
667 | 0 | framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId, rRequest); |
668 | 0 | break; |
669 | | |
670 | 0 | case SID_WIN_FULLSCREEN: |
671 | | // The full screen mode is not supported. Ignore the request. |
672 | 0 | break; |
673 | | |
674 | 0 | case SID_RESTORE_EDITING_VIEW: |
675 | 0 | mpImpl->ProcessRestoreEditingViewSlot(); |
676 | 0 | break; |
677 | | |
678 | 0 | case SID_PROTECTPOS: |
679 | 0 | case SID_PROTECTSIZE: |
680 | 0 | { |
681 | 0 | ::sd::DrawDocShell* pDocSh = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() ); |
682 | 0 | if (!pDocSh) |
683 | 0 | break; |
684 | 0 | ::sd::View* pView = pDocSh->GetViewShell()->GetView(); |
685 | |
|
686 | 0 | const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); |
687 | 0 | assert ( rMarkList.GetMarkCount() == 1 ); |
688 | |
|
689 | 0 | SdrObject* pGraphicObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); |
690 | 0 | if (nSlotId == SID_PROTECTSIZE) |
691 | 0 | pGraphicObj->SetResizeProtect(!pGraphicObj->IsResizeProtect()); |
692 | 0 | else |
693 | 0 | pGraphicObj->SetMoveProtect(!pGraphicObj->IsMoveProtect()); |
694 | |
|
695 | 0 | } |
696 | 0 | break; |
697 | | |
698 | 0 | default: |
699 | | // Ignore any other slot. |
700 | 0 | rRequest.Ignore (); |
701 | 0 | break; |
702 | 0 | } |
703 | 0 | } |
704 | | |
705 | | void ViewShellBase::GetState (SfxItemSet& rSet) |
706 | 0 | { |
707 | 0 | mpImpl->GetSlotState(rSet); |
708 | |
|
709 | 0 | FuBullet::GetSlotState( rSet, nullptr, &GetViewFrame() ); |
710 | 0 | } |
711 | | |
712 | | void ViewShellBase::WriteUserDataSequence ( |
713 | | css::uno::Sequence< css::beans::PropertyValue >& rSequence) |
714 | 0 | { |
715 | | // Forward call to main sub shell. |
716 | 0 | ViewShell* pShell = GetMainViewShell().get(); |
717 | 0 | if (pShell != nullptr) |
718 | 0 | pShell->WriteUserDataSequence (rSequence); |
719 | 0 | } |
720 | | |
721 | | void ViewShellBase::ReadUserDataSequence ( |
722 | | const css::uno::Sequence< css::beans::PropertyValue >& rSequence) |
723 | 0 | { |
724 | | // Forward call to main sub shell. |
725 | 0 | ViewShell* pShell = GetMainViewShell().get(); |
726 | 0 | if (pShell == nullptr) |
727 | 0 | return; |
728 | | |
729 | 0 | pShell->ReadUserDataSequence (rSequence); |
730 | | |
731 | | // For certain shell types ReadUserDataSequence may have changed the |
732 | | // type to another one. Make sure that the center pane shows the |
733 | | // right view shell. |
734 | 0 | switch (pShell->GetShellType()) |
735 | 0 | { |
736 | 0 | case ViewShell::ST_IMPRESS: |
737 | 0 | case ViewShell::ST_NOTES: |
738 | 0 | case ViewShell::ST_HANDOUT: |
739 | 0 | { |
740 | 0 | OUString sViewURL; |
741 | 0 | switch (dynamic_cast<DrawViewShell&>(*pShell).GetPageKind()) |
742 | 0 | { |
743 | 0 | default: |
744 | 0 | case PageKind::Standard: |
745 | 0 | sViewURL = framework::FrameworkHelper::msImpressViewURL; |
746 | 0 | break; |
747 | 0 | case PageKind::Notes: |
748 | 0 | sViewURL = framework::FrameworkHelper::msNotesViewURL; |
749 | 0 | break; |
750 | 0 | case PageKind::Handout: |
751 | 0 | sViewURL = framework::FrameworkHelper::msHandoutViewURL; |
752 | 0 | break; |
753 | 0 | } |
754 | 0 | if (!sViewURL.isEmpty()) |
755 | 0 | framework::FrameworkHelper::Instance(*this)->RequestView( |
756 | 0 | sViewURL, |
757 | 0 | framework::FrameworkHelper::msCenterPaneURL); |
758 | 0 | } |
759 | 0 | break; |
760 | | |
761 | 0 | default: |
762 | 0 | break; |
763 | 0 | } |
764 | 0 | } |
765 | | |
766 | | void ViewShellBase::Activate (bool bIsMDIActivate) |
767 | 0 | { |
768 | 0 | SfxViewShell::Activate(bIsMDIActivate); |
769 | |
|
770 | 0 | DrawController* pDrawController(GetDrawController()); |
771 | 0 | if (pDrawController) |
772 | 0 | { |
773 | 0 | rtl::Reference<framework::ConfigurationController> xConfigurationController ( |
774 | 0 | pDrawController->getConfigurationController()); |
775 | 0 | if (xConfigurationController.is()) |
776 | 0 | xConfigurationController->update(); |
777 | 0 | } |
778 | 0 | GetToolBarManager()->RequestUpdate(); |
779 | 0 | } |
780 | | |
781 | | void ViewShellBase::SetZoomFactor ( |
782 | | const Fraction &rZoomX, |
783 | | const Fraction &rZoomY) |
784 | 0 | { |
785 | 0 | SfxViewShell::SetZoomFactor (rZoomX, rZoomY); |
786 | | // Forward call to main sub shell. |
787 | 0 | ViewShell* pShell = GetMainViewShell().get(); |
788 | 0 | if (pShell != nullptr) |
789 | 0 | pShell->SetZoomFactor (rZoomX, rZoomY); |
790 | 0 | } |
791 | | |
792 | | bool ViewShellBase::PrepareClose (bool bUI) |
793 | 0 | { |
794 | 0 | bool bResult = SfxViewShell::PrepareClose (bUI); |
795 | |
|
796 | 0 | if (bResult) |
797 | 0 | { |
798 | 0 | mpImpl->mbIsClosing = true; |
799 | | |
800 | | // Forward call to main sub shell. |
801 | 0 | ViewShell* pShell = GetMainViewShell().get(); |
802 | 0 | if (pShell != nullptr) |
803 | 0 | bResult = pShell->PrepareClose (bUI); |
804 | 0 | } |
805 | |
|
806 | 0 | return bResult; |
807 | 0 | } |
808 | | |
809 | | void ViewShellBase::WriteUserData (OUString& rString, bool bBrowse) |
810 | 0 | { |
811 | 0 | SfxViewShell::WriteUserData (rString, bBrowse); |
812 | | |
813 | | // Forward call to main sub shell. |
814 | 0 | ViewShell* pShell = GetMainViewShell().get(); |
815 | 0 | if (pShell != nullptr) |
816 | 0 | pShell->WriteUserData(); |
817 | 0 | } |
818 | | |
819 | | void ViewShellBase::ReadUserData (const OUString& rString, bool bBrowse) |
820 | 0 | { |
821 | 0 | SfxViewShell::ReadUserData (rString, bBrowse); |
822 | | |
823 | | // Forward call to main sub shell. |
824 | 0 | ViewShell* pShell = GetMainViewShell().get(); |
825 | 0 | if (pShell != nullptr) |
826 | 0 | pShell->ReadUserData(); |
827 | 0 | } |
828 | | |
829 | | SdrView* ViewShellBase::GetDrawView() const |
830 | 0 | { |
831 | | // Forward call to main sub shell. |
832 | 0 | ViewShell* pShell = GetMainViewShell().get(); |
833 | 0 | if (pShell != nullptr) |
834 | 0 | return pShell->GetDrawView (); |
835 | | |
836 | 0 | return nullptr; |
837 | 0 | } |
838 | | |
839 | | void ViewShellBase::SetBusyState (bool bBusy) |
840 | 0 | { |
841 | 0 | if (GetDocShell() != nullptr) |
842 | 0 | GetDocShell()->SetWaitCursor (bBusy); |
843 | 0 | } |
844 | | |
845 | | void ViewShellBase::UpdateBorder ( bool bForce /* = false */ ) |
846 | 0 | { |
847 | | // The following calls to SetBorderPixel() and InvalidateBorder() are |
848 | | // made only for the main view shell. This not only avoids unnecessary |
849 | | // calls for the views in side panes but prevents calling an already |
850 | | // dying SfxViewShell base class. |
851 | | // We have to check the existence of the window, too. |
852 | | // The SfxViewFrame accesses the window without checking it. |
853 | 0 | ViewShell* pMainViewShell = GetMainViewShell().get(); |
854 | 0 | if (pMainViewShell == nullptr || GetWindow()==nullptr) |
855 | 0 | return; |
856 | | |
857 | 0 | SvBorder aCurrentBorder (GetBorderPixel()); |
858 | 0 | bool bOuterResize ( ! GetDocShell()->IsInPlaceActive()); |
859 | 0 | SvBorder aBorder (GetBorder(bOuterResize)); |
860 | 0 | aBorder += pMainViewShell->GetBorder(); |
861 | |
|
862 | 0 | if (bForce || (aBorder != aCurrentBorder)) |
863 | 0 | { |
864 | 0 | SetBorderPixel (aBorder); |
865 | 0 | InvalidateBorder(); |
866 | 0 | } |
867 | 0 | } |
868 | | |
869 | | void ViewShellBase::ShowUIControls (bool bVisible) |
870 | 0 | { |
871 | 0 | mpImpl->ShowViewTabBar(bVisible); |
872 | |
|
873 | 0 | ViewShell* pMainViewShell = GetMainViewShell().get(); |
874 | 0 | if (pMainViewShell != nullptr) |
875 | 0 | pMainViewShell->ShowUIControls (bVisible); |
876 | |
|
877 | 0 | UpdateBorder(); |
878 | 0 | if (bVisible) |
879 | 0 | Rearrange(); |
880 | 0 | } |
881 | | |
882 | | OUString ViewShellBase::GetInitialViewShellType() const |
883 | 0 | { |
884 | 0 | OUString sRequestedView (FrameworkHelper::msImpressViewURL); |
885 | |
|
886 | 0 | do |
887 | 0 | { |
888 | 0 | Reference<document::XViewDataSupplier> xViewDataSupplier ( |
889 | 0 | GetDocShell()->GetModel(), UNO_QUERY); |
890 | 0 | if ( ! xViewDataSupplier.is()) |
891 | 0 | break; |
892 | | |
893 | 0 | Reference<container::XIndexAccess> xViewData (xViewDataSupplier->getViewData()); |
894 | 0 | if ( ! xViewData.is()) |
895 | 0 | break; |
896 | 0 | if (xViewData->getCount() == 0) |
897 | 0 | break; |
898 | | |
899 | 0 | css::uno::Any aAny = xViewData->getByIndex(0); |
900 | 0 | Sequence<beans::PropertyValue> aProperties; |
901 | 0 | if ( ! (aAny >>= aProperties)) |
902 | 0 | break; |
903 | | |
904 | | // Search the properties for the one that tells us what page kind to |
905 | | // use. |
906 | 0 | auto pProperty = std::find_if(std::cbegin(aProperties), std::cend(aProperties), |
907 | 0 | [](const beans::PropertyValue& rProperty) { return rProperty.Name == sUNO_View_PageKind; }); |
908 | 0 | if (pProperty != std::cend(aProperties)) |
909 | 0 | { |
910 | 0 | sal_Int16 nPageKind = 0; |
911 | 0 | pProperty->Value >>= nPageKind; |
912 | 0 | switch (static_cast<PageKind>(nPageKind)) |
913 | 0 | { |
914 | 0 | case PageKind::Standard: |
915 | 0 | sRequestedView = FrameworkHelper::msImpressViewURL; |
916 | 0 | break; |
917 | | |
918 | 0 | case PageKind::Handout: |
919 | 0 | sRequestedView = FrameworkHelper::msHandoutViewURL; |
920 | 0 | break; |
921 | | |
922 | 0 | case PageKind::Notes: |
923 | 0 | sRequestedView = FrameworkHelper::msNotesViewURL; |
924 | 0 | break; |
925 | | |
926 | 0 | default: |
927 | | // The page kind is invalid. This is probably an |
928 | | // error by the caller. We use the standard type to |
929 | | // keep things going. |
930 | 0 | SAL_WARN( "sd.view", "ViewShellBase::GetInitialViewShellType: invalid page kind"); |
931 | 0 | sRequestedView = FrameworkHelper::msImpressViewURL; |
932 | 0 | break; |
933 | 0 | } |
934 | 0 | } |
935 | 0 | } |
936 | 0 | while (false); |
937 | | |
938 | 0 | return sRequestedView; |
939 | 0 | } |
940 | | |
941 | | const SdViewOptions& ViewShellBase::GetViewOptions() const |
942 | 0 | { |
943 | 0 | return mpImpl->maViewOptions; |
944 | 0 | } |
945 | | |
946 | | void ViewShellBase::SetViewOptions(const SdViewOptions& rOptions) const |
947 | 0 | { |
948 | 0 | mpImpl->maViewOptions = rOptions; |
949 | 0 | } |
950 | | |
951 | | std::shared_ptr<sdtools::EventMultiplexer> const & ViewShellBase::GetEventMultiplexer() const |
952 | 0 | { |
953 | 0 | OSL_ASSERT(mpImpl != nullptr); |
954 | 0 | OSL_ASSERT(mpImpl->mpEventMultiplexer != nullptr); |
955 | |
|
956 | 0 | return mpImpl->mpEventMultiplexer; |
957 | 0 | } |
958 | | |
959 | | const ::tools::Rectangle& ViewShellBase::getClientRectangle() const |
960 | 0 | { |
961 | 0 | return mpImpl->maClientArea; |
962 | 0 | } |
963 | | |
964 | | std::shared_ptr<ToolBarManager> const & ViewShellBase::GetToolBarManager() const |
965 | 0 | { |
966 | 0 | OSL_ASSERT(mpImpl != nullptr); |
967 | 0 | OSL_ASSERT(mpImpl->mpToolBarManager != nullptr); |
968 | |
|
969 | 0 | return mpImpl->mpToolBarManager; |
970 | 0 | } |
971 | | |
972 | | FormShellManager* ViewShellBase::GetFormShellManager() const |
973 | 0 | { |
974 | 0 | OSL_ASSERT(mpImpl != nullptr); |
975 | 0 | OSL_ASSERT(mpImpl->mpFormShellManager != nullptr); |
976 | |
|
977 | 0 | return mpImpl->mpFormShellManager.get(); |
978 | 0 | } |
979 | | |
980 | | DrawController* ViewShellBase::GetDrawController() const |
981 | 0 | { |
982 | 0 | OSL_ASSERT(mpImpl != nullptr); |
983 | |
|
984 | 0 | return mpImpl->mpController.get(); |
985 | 0 | } |
986 | | |
987 | | void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar) |
988 | 0 | { |
989 | 0 | OSL_ASSERT(mpImpl != nullptr); |
990 | |
|
991 | 0 | mpImpl->mpViewTabBar = rViewTabBar; |
992 | 0 | } |
993 | | |
994 | | vcl::Window* ViewShellBase::GetViewWindow() |
995 | 0 | { |
996 | 0 | OSL_ASSERT(mpImpl != nullptr); |
997 | |
|
998 | 0 | return mpImpl->mpViewWindow.get(); |
999 | 0 | } |
1000 | | |
1001 | | OUString ViewShellBase::RetrieveLabelFromCommand( const OUString& aCmdURL ) const |
1002 | 0 | { |
1003 | 0 | OUString aModuleName; |
1004 | 0 | if (SfxViewFrame* pViewFrame = GetMainViewShell()->GetViewFrame()) |
1005 | 0 | aModuleName = vcl::CommandInfoProvider::GetModuleIdentifier(pViewFrame->GetFrame().GetFrameInterface()); |
1006 | 0 | auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCmdURL, aModuleName); |
1007 | 0 | return vcl::CommandInfoProvider::GetLabelForCommand(aProperties); |
1008 | 0 | } |
1009 | | |
1010 | | int ViewShellBase::getPart() const |
1011 | 0 | { |
1012 | 0 | ViewShell* pViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get(); |
1013 | |
|
1014 | 0 | if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pViewShell)) |
1015 | 0 | { |
1016 | 0 | return pDrawViewShell->GetCurPagePos(); |
1017 | 0 | } |
1018 | | |
1019 | 0 | return 0; |
1020 | 0 | } |
1021 | | |
1022 | | int ViewShellBase::getEditMode() const |
1023 | 0 | { |
1024 | 0 | ViewShell* pViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get(); |
1025 | |
|
1026 | 0 | if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pViewShell)) |
1027 | 0 | { |
1028 | 0 | switch ( pDrawViewShell->GetEditMode() ) |
1029 | 0 | { |
1030 | 0 | case EditMode::Page: |
1031 | 0 | switch (pDrawViewShell->GetPageKind()) |
1032 | 0 | { |
1033 | 0 | case PageKind::Standard: |
1034 | 0 | return 0; |
1035 | 0 | case PageKind::Notes: |
1036 | 0 | return 2; |
1037 | 0 | default: |
1038 | 0 | assert(!"Unhandled page kind"); |
1039 | 0 | return 0; |
1040 | 0 | } |
1041 | 0 | case EditMode::MasterPage: |
1042 | 0 | switch (pDrawViewShell->GetPageKind()) |
1043 | 0 | { |
1044 | 0 | case PageKind::Standard: |
1045 | 0 | return 1; |
1046 | 0 | default: |
1047 | 0 | assert(!"Unhandled page kind"); |
1048 | 0 | return 1; |
1049 | 0 | } |
1050 | 0 | } |
1051 | 0 | } |
1052 | | |
1053 | 0 | return 0; |
1054 | 0 | } |
1055 | | |
1056 | | void ViewShellBase::setEditMode(int nMode) |
1057 | 0 | { |
1058 | 0 | ViewShell* pViewShell = framework::FrameworkHelper::Instance(*this)->GetViewShell(FrameworkHelper::msCenterPaneURL).get(); |
1059 | |
|
1060 | 0 | if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pViewShell)) |
1061 | 0 | { |
1062 | 0 | EditMode eOrigEditMode = pDrawViewShell->GetEditMode(); |
1063 | 0 | PageKind eOrigPageKind = pDrawViewShell->GetPageKind(); |
1064 | 0 | sal_uInt16 nSelectedPage = pDrawViewShell->GetCurPagePos(); |
1065 | |
|
1066 | 0 | switch ( nMode ) |
1067 | 0 | { |
1068 | 0 | case 0: |
1069 | 0 | pDrawViewShell->SetPageKind(PageKind::Standard); |
1070 | 0 | pDrawViewShell->ChangeEditMode(EditMode::Page, false); |
1071 | 0 | break; |
1072 | 0 | case 1: |
1073 | 0 | pDrawViewShell->SetPageKind(PageKind::Standard); |
1074 | 0 | pDrawViewShell->ChangeEditMode(EditMode::MasterPage, false); |
1075 | 0 | break; |
1076 | 0 | case 2: |
1077 | 0 | pDrawViewShell->SetPageKind(PageKind::Notes); |
1078 | 0 | pDrawViewShell->ChangeEditMode(EditMode::Page, false); |
1079 | 0 | break; |
1080 | 0 | } |
1081 | | |
1082 | | /* |
1083 | | If the EditMode is unchanged, then ChangeEditMode was typically a |
1084 | | no-op, and an additional explicit SwitchPage is required to reselect |
1085 | | the equivalent page from the other mode, otherwise a switch from |
1086 | | e.g. Notes to Standard will still render the still selected Note |
1087 | | page. |
1088 | | */ |
1089 | 0 | if (eOrigEditMode == pDrawViewShell->GetEditMode() && |
1090 | 0 | eOrigPageKind != pDrawViewShell->GetPageKind()) |
1091 | 0 | { |
1092 | 0 | pDrawViewShell->SwitchPage(nSelectedPage); |
1093 | 0 | } |
1094 | 0 | } |
1095 | 0 | } |
1096 | | |
1097 | | void ViewShellBase::afterCallbackRegistered() |
1098 | 0 | { |
1099 | | // common tasks |
1100 | 0 | SfxViewShell::afterCallbackRegistered(); |
1101 | |
|
1102 | 0 | SfxObjectShell* pDocShell = GetObjectShell(); |
1103 | 0 | if (pDocShell) |
1104 | 0 | { |
1105 | 0 | std::shared_ptr<model::ColorSet> pThemeColors = pDocShell->GetThemeColors(); |
1106 | 0 | std::set<Color> aDocumentColors = pDocShell->GetDocColors(); |
1107 | 0 | svx::theme::notifyLOK(pThemeColors, aDocumentColors); |
1108 | 0 | } |
1109 | |
|
1110 | 0 | if (comphelper::LibreOfficeKit::isActive() && mpDocument && mpDocument->GetStartWithPresentation()) |
1111 | 0 | { |
1112 | | // Be consistent with SidebarController, emit JSON. |
1113 | 0 | boost::property_tree::ptree aTree; |
1114 | 0 | aTree.put("commandName", ".uno:StartWithPresentation"); |
1115 | 0 | aTree.put("state", "true"); |
1116 | 0 | std::stringstream aStream; |
1117 | 0 | boost::property_tree::write_json(aStream, aTree); |
1118 | 0 | libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, OString(aStream.str())); |
1119 | 0 | } |
1120 | 0 | } |
1121 | | |
1122 | | void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const |
1123 | 0 | { |
1124 | 0 | ViewShell* pThisShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get(); |
1125 | |
|
1126 | 0 | DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pThisShell); |
1127 | 0 | if (!pDrawViewShell) |
1128 | 0 | return; |
1129 | | |
1130 | 0 | if (this == pOtherShell) |
1131 | 0 | return; |
1132 | | |
1133 | 0 | DrawView* pDrawView = pDrawViewShell->GetDrawView(); |
1134 | 0 | if (!pDrawView) |
1135 | 0 | return; |
1136 | | |
1137 | 0 | if (pDrawView->GetTextEditObject()) |
1138 | 0 | { |
1139 | | // Blinking cursor. |
1140 | 0 | EditView& rEditView = pDrawView->GetTextEditOutlinerView()->GetEditView(); |
1141 | 0 | rEditView.RegisterOtherShell(pOtherShell); |
1142 | 0 | rEditView.ShowCursor(); |
1143 | 0 | rEditView.RegisterOtherShell(nullptr); |
1144 | | // Text selection, if any. |
1145 | 0 | rEditView.DrawSelectionXOR(pOtherShell); |
1146 | | |
1147 | | // Shape text lock. |
1148 | 0 | if (OutlinerView* pOutlinerView = pDrawView->GetTextEditOutlinerView()) |
1149 | 0 | { |
1150 | 0 | ::tools::Rectangle aRectangle = pOutlinerView->GetOutputArea(); |
1151 | 0 | vcl::Window* pWin = pThisShell->GetActiveWindow(); |
1152 | 0 | if (pWin && pWin->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) |
1153 | 0 | aRectangle = o3tl::toTwips(aRectangle, o3tl::Length::mm100); |
1154 | 0 | OString sRectangle = aRectangle.toString(); |
1155 | 0 | SfxLokHelper::notifyOtherView(pDrawViewShell->GetViewShellBase(), pOtherShell, LOK_CALLBACK_VIEW_LOCK, "rectangle", sRectangle); |
1156 | 0 | } |
1157 | 0 | } |
1158 | 0 | else |
1159 | 0 | { |
1160 | | // Graphic selection. |
1161 | 0 | pDrawView->AdjustMarkHdl(pOtherShell); |
1162 | 0 | } |
1163 | 0 | } |
1164 | | |
1165 | | ::Color ViewShellBase::GetColorConfigColor(svtools::ColorConfigEntry nColorType) const |
1166 | 0 | { |
1167 | 0 | Color aColor; |
1168 | |
|
1169 | 0 | const SdViewOptions& rViewOptions = GetViewOptions(); |
1170 | 0 | switch (nColorType) |
1171 | 0 | { |
1172 | 0 | case svtools::ColorConfigEntry::DOCCOLOR: |
1173 | 0 | { |
1174 | 0 | aColor = rViewOptions.mnDocBackgroundColor; |
1175 | 0 | break; |
1176 | 0 | } |
1177 | | // Should never be called for an unimplemented color type |
1178 | 0 | default: |
1179 | 0 | { |
1180 | 0 | O3TL_UNREACHABLE; |
1181 | 0 | } |
1182 | 0 | } |
1183 | | |
1184 | 0 | return aColor; |
1185 | 0 | } |
1186 | | |
1187 | | //===== ViewShellBase::Implementation ========================================= |
1188 | | |
1189 | | ViewShellBase::Implementation::Implementation (ViewShellBase& rBase) |
1190 | 0 | : mbIsClosing(false), |
1191 | 0 | mrBase(rBase), |
1192 | 0 | mbUserWantsTabBar(false), |
1193 | 0 | mbTabBarShouldBeVisible(true), |
1194 | 0 | mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance()) |
1195 | 0 | { |
1196 | 0 | } |
1197 | | |
1198 | | ViewShellBase::Implementation::~Implementation() |
1199 | 0 | { |
1200 | 0 | mpController = nullptr; |
1201 | 0 | mpViewTabBar = nullptr; |
1202 | 0 | mpViewWindow.disposeAndClear(); |
1203 | 0 | mpToolBarManager.reset(); |
1204 | 0 | } |
1205 | | |
1206 | | void ViewShellBase::Implementation::LateInit() |
1207 | 0 | { |
1208 | 0 | mpController = new DrawController(mrBase); |
1209 | 0 | } |
1210 | | |
1211 | | void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot() |
1212 | 0 | { |
1213 | 0 | ViewShell* pViewShell = mrBase.GetMainViewShell().get(); |
1214 | 0 | if (pViewShell == nullptr) |
1215 | 0 | return; |
1216 | | |
1217 | 0 | FrameView* pFrameView = pViewShell->GetFrameView(); |
1218 | 0 | if (pFrameView == nullptr) |
1219 | 0 | return; |
1220 | | |
1221 | | // Set view shell, edit mode, and page kind. |
1222 | | // pFrameView->SetViewShEditMode( |
1223 | | // pFrameView->GetViewShEditModeOnLoad(), |
1224 | | // pFrameView->GetPageKindOnLoad()); |
1225 | 0 | pFrameView->SetViewShEditMode( |
1226 | 0 | pFrameView->GetViewShEditModeOnLoad() ); |
1227 | 0 | pFrameView->SetPageKind( |
1228 | 0 | pFrameView->GetPageKindOnLoad()); |
1229 | 0 | std::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(mrBase)); |
1230 | 0 | pHelper->RequestView( |
1231 | 0 | FrameworkHelper::GetViewURL(pFrameView->GetViewShellTypeOnLoad()), |
1232 | 0 | FrameworkHelper::msCenterPaneURL); |
1233 | 0 | pHelper->RunOnConfigurationEvent(framework::ConfigurationChangeEventType::ConfigurationUpdateEnd, CurrentPageSetter(mrBase)); |
1234 | 0 | } |
1235 | | |
1236 | | void ViewShellBase::Implementation::SetUserWantsTabBar(bool inValue) |
1237 | 0 | { |
1238 | 0 | mbUserWantsTabBar = inValue; |
1239 | | // Call ShowViewTabBar to refresh the TabBar visibility |
1240 | 0 | ShowViewTabBar(mbTabBarShouldBeVisible); |
1241 | 0 | } |
1242 | | |
1243 | | void ViewShellBase::Implementation::ShowViewTabBar (bool bShow) |
1244 | 0 | { |
1245 | 0 | mbTabBarShouldBeVisible = bShow; |
1246 | 0 | bShow = bShow && mbUserWantsTabBar; |
1247 | |
|
1248 | 0 | if (mpViewTabBar.is() |
1249 | 0 | && mpViewTabBar->GetTabControl()->IsVisible() != bShow) |
1250 | 0 | { |
1251 | 0 | mpViewTabBar->GetTabControl()->Show(bShow); |
1252 | 0 | mrBase.Rearrange(); |
1253 | 0 | } |
1254 | 0 | } |
1255 | | |
1256 | | void ViewShellBase::Implementation::ResizePixel ( |
1257 | | const Point& rOrigin, |
1258 | | const Size &rSize, |
1259 | | bool bOuterResize) |
1260 | 0 | { |
1261 | 0 | if (mbIsClosing) |
1262 | 0 | return; |
1263 | | |
1264 | | // Forward the call to both the base class and the main stacked sub |
1265 | | // shell only when main sub shell exists. |
1266 | 0 | ViewShell* pMainViewShell = mrBase.GetMainViewShell().get(); |
1267 | | |
1268 | | // Set the ViewTabBar temporarily to full size so that, when asked |
1269 | | // later, it can return its true height. |
1270 | 0 | mrBase.SetWindow (mpViewWindow.get()); |
1271 | 0 | if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible()) |
1272 | 0 | mpViewTabBar->GetTabControl()->SetPosSizePixel (rOrigin, rSize); |
1273 | | |
1274 | | // Calculate and set the border before the controls are placed. |
1275 | 0 | SvBorder aBorder; |
1276 | 0 | if (pMainViewShell != nullptr) |
1277 | 0 | aBorder = pMainViewShell->GetBorder(); |
1278 | 0 | aBorder += mrBase.GetBorder(bOuterResize); |
1279 | 0 | if (mrBase.GetBorderPixel() != aBorder) |
1280 | 0 | mrBase.SetBorderPixel(aBorder); |
1281 | | |
1282 | | // Place the ViewTabBar at the top. It is part of the border. |
1283 | 0 | SvBorder aBaseBorder; |
1284 | 0 | if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible()) |
1285 | 0 | { |
1286 | 0 | aBaseBorder.Top() = mpViewTabBar->GetHeight(); |
1287 | 0 | mpViewTabBar->GetTabControl()->SetPosSizePixel( |
1288 | 0 | rOrigin, Size(rSize.Width(),aBaseBorder.Top())); |
1289 | 0 | } |
1290 | | |
1291 | | // The view window gets the remaining space. |
1292 | 0 | Point aViewWindowPosition ( |
1293 | 0 | rOrigin.X()+aBaseBorder.Left(), |
1294 | 0 | rOrigin.Y()+aBaseBorder.Top()); |
1295 | |
|
1296 | 0 | Size aViewWindowSize ( |
1297 | 0 | rSize.Width() - aBaseBorder.Left() - aBaseBorder.Right(), |
1298 | 0 | rSize.Height() - aBaseBorder.Top() - aBaseBorder.Bottom()); |
1299 | 0 | mpViewWindow->SetPosSizePixel(aViewWindowPosition, aViewWindowSize); |
1300 | |
|
1301 | 0 | maClientArea = ::tools::Rectangle(Point(0,0), aViewWindowSize); |
1302 | 0 | } |
1303 | | |
1304 | | void ViewShellBase::Implementation::SetPaneVisibility ( |
1305 | | const SfxRequest& rRequest, |
1306 | | const OUString& rsPaneURL, |
1307 | | const OUString& rsViewURL) |
1308 | 0 | { |
1309 | 0 | try |
1310 | 0 | { |
1311 | 0 | DrawController* pDrawController(mrBase.GetDrawController()); |
1312 | 0 | if (!pDrawController) |
1313 | 0 | return; |
1314 | | |
1315 | 0 | rtl::Reference<framework::ResourceId> xPaneId (new sd::framework::ResourceId( |
1316 | 0 | rsPaneURL)); |
1317 | 0 | rtl::Reference<framework::ResourceId> xViewId (new sd::framework::ResourceId( |
1318 | 0 | rsViewURL, rsPaneURL)); |
1319 | | |
1320 | | // Determine the new visibility state. |
1321 | 0 | const SfxItemSet* pArguments = rRequest.GetArgs(); |
1322 | 0 | bool bShowChildWindow; |
1323 | 0 | sal_uInt16 nSlotId = rRequest.GetSlot(); |
1324 | 0 | if (pArguments != nullptr) |
1325 | 0 | bShowChildWindow = static_cast<const SfxBoolItem&>( |
1326 | 0 | pArguments->Get(nSlotId)).GetValue(); |
1327 | 0 | else |
1328 | 0 | { |
1329 | 0 | rtl::Reference<sd::framework::ConfigurationController> xConfigurationController ( |
1330 | 0 | pDrawController->getConfigurationController()); |
1331 | 0 | if ( ! xConfigurationController.is()) |
1332 | 0 | throw RuntimeException(); |
1333 | 0 | rtl::Reference<framework::Configuration> xConfiguration ( |
1334 | 0 | xConfigurationController->getRequestedConfiguration()); |
1335 | 0 | if ( ! xConfiguration.is()) |
1336 | 0 | throw RuntimeException(); |
1337 | | |
1338 | 0 | bShowChildWindow = ! xConfiguration->hasResource(xPaneId); |
1339 | 0 | } |
1340 | | |
1341 | | // Set the desired visibility state at the current configuration |
1342 | | // and update it accordingly. |
1343 | 0 | rtl::Reference<sd::framework::ConfigurationController> xConfigurationController ( |
1344 | 0 | pDrawController->getConfigurationController()); |
1345 | 0 | if ( ! xConfigurationController.is()) |
1346 | 0 | throw RuntimeException(); |
1347 | 0 | if (bShowChildWindow) |
1348 | 0 | { |
1349 | 0 | xConfigurationController->requestResourceActivation( |
1350 | 0 | xPaneId, |
1351 | 0 | framework::ResourceActivationMode::ADD); |
1352 | 0 | xConfigurationController->requestResourceActivation( |
1353 | 0 | xViewId, |
1354 | 0 | framework::ResourceActivationMode::REPLACE); |
1355 | 0 | } |
1356 | 0 | else |
1357 | 0 | xConfigurationController->requestResourceDeactivation( |
1358 | 0 | xPaneId); |
1359 | 0 | } |
1360 | 0 | catch (const Exception&) |
1361 | 0 | { |
1362 | 0 | DBG_UNHANDLED_EXCEPTION("sd.view"); |
1363 | 0 | } |
1364 | 0 | } |
1365 | | |
1366 | | void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet) |
1367 | 0 | { |
1368 | 0 | try |
1369 | 0 | { |
1370 | | // Get some frequently used values. |
1371 | 0 | DrawController* pDrawController(mrBase.GetDrawController()); |
1372 | 0 | if (!pDrawController) |
1373 | 0 | return; |
1374 | 0 | rtl::Reference<sd::framework::ConfigurationController> xConfigurationController ( |
1375 | 0 | pDrawController->getConfigurationController()); |
1376 | 0 | if ( ! xConfigurationController.is()) |
1377 | 0 | throw RuntimeException(); |
1378 | 0 | rtl::Reference<sd::framework::Configuration> xConfiguration ( |
1379 | 0 | xConfigurationController->getRequestedConfiguration()); |
1380 | 0 | if ( ! xConfiguration.is()) |
1381 | 0 | throw RuntimeException(); |
1382 | | |
1383 | 0 | SfxWhichIter aSetIterator (rSet); |
1384 | 0 | sal_uInt16 nItemId (aSetIterator.FirstWhich()); |
1385 | |
|
1386 | 0 | while (nItemId > 0) |
1387 | 0 | { |
1388 | 0 | bool bState (false); |
1389 | 0 | bool bEnabled; |
1390 | 0 | rtl::Reference<framework::ResourceId> xResourceId; |
1391 | 0 | try |
1392 | 0 | { |
1393 | 0 | bEnabled = true; |
1394 | | // Check if the right view is active |
1395 | 0 | switch (nItemId) |
1396 | 0 | { |
1397 | 0 | case SID_LEFT_PANE_IMPRESS: |
1398 | 0 | xResourceId = new sd::framework::ResourceId( |
1399 | 0 | FrameworkHelper::msLeftImpressPaneURL); |
1400 | 0 | bState = xConfiguration->hasResource(xResourceId); |
1401 | 0 | break; |
1402 | | |
1403 | 0 | case SID_LEFT_PANE_DRAW: |
1404 | 0 | xResourceId = new sd::framework::ResourceId( |
1405 | 0 | FrameworkHelper::msLeftDrawPaneURL); |
1406 | 0 | bState = xConfiguration->hasResource(xResourceId); |
1407 | 0 | break; |
1408 | | |
1409 | 0 | case SID_BOTTOM_PANE_IMPRESS: |
1410 | 0 | xResourceId = new sd::framework::ResourceId( |
1411 | 0 | FrameworkHelper::msBottomImpressPaneURL); |
1412 | 0 | bState = xConfiguration->hasResource(xResourceId); |
1413 | 0 | break; |
1414 | | |
1415 | 0 | case SID_DRAWINGMODE: |
1416 | 0 | case SID_NORMAL_MULTI_PANE_GUI: |
1417 | 0 | case SID_SLIDE_MASTER_MODE: |
1418 | 0 | xResourceId = new sd::framework::ResourceId( |
1419 | 0 | FrameworkHelper::msImpressViewURL, |
1420 | 0 | FrameworkHelper::msCenterPaneURL); |
1421 | 0 | bState = xConfiguration->hasResource(xResourceId); |
1422 | 0 | break; |
1423 | | |
1424 | 0 | case SID_SLIDE_SORTER_MULTI_PANE_GUI: |
1425 | 0 | case SID_SLIDE_SORTER_MODE: |
1426 | 0 | xResourceId = new sd::framework::ResourceId( |
1427 | 0 | FrameworkHelper::msSlideSorterURL, |
1428 | 0 | FrameworkHelper::msCenterPaneURL); |
1429 | 0 | bState = xConfiguration->hasResource(xResourceId); |
1430 | 0 | break; |
1431 | | |
1432 | 0 | case SID_OUTLINE_MODE: |
1433 | 0 | xResourceId = new sd::framework::ResourceId( |
1434 | 0 | FrameworkHelper::msOutlineViewURL, |
1435 | 0 | FrameworkHelper::msCenterPaneURL); |
1436 | 0 | bState = xConfiguration->hasResource(xResourceId); |
1437 | 0 | break; |
1438 | | |
1439 | 0 | case SID_HANDOUT_MASTER_MODE: |
1440 | 0 | xResourceId = new sd::framework::ResourceId( |
1441 | 0 | FrameworkHelper::msHandoutViewURL, |
1442 | 0 | FrameworkHelper::msCenterPaneURL); |
1443 | 0 | bState = xConfiguration->hasResource(xResourceId); |
1444 | 0 | break; |
1445 | | |
1446 | 0 | case SID_NOTES_MODE: |
1447 | 0 | case SID_NOTES_MASTER_MODE: |
1448 | 0 | xResourceId = new sd::framework::ResourceId( |
1449 | 0 | FrameworkHelper::msNotesViewURL, |
1450 | 0 | FrameworkHelper::msCenterPaneURL); |
1451 | 0 | bState = xConfiguration->hasResource(xResourceId); |
1452 | 0 | break; |
1453 | | |
1454 | 0 | case SID_TOGGLE_TABBAR_VISIBILITY: |
1455 | 0 | bState = GetUserWantsTabBar(); |
1456 | 0 | break; |
1457 | 0 | case SID_PROTECTPOS: |
1458 | 0 | case SID_PROTECTSIZE: |
1459 | 0 | { |
1460 | 0 | ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>(SfxObjectShell::Current()); |
1461 | 0 | if (pDocSh) |
1462 | 0 | { |
1463 | 0 | ::sd::View* pView = pDocSh->GetViewShell()->GetView(); |
1464 | 0 | const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); |
1465 | 0 | if ( rMarkList.GetMarkCount() == 1 ) // graphic menu only effective on single item |
1466 | 0 | { |
1467 | 0 | const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); |
1468 | 0 | const SdrObjKind nSdrObjKind = pObj->GetObjIdentifier(); |
1469 | |
|
1470 | 0 | if ( nSdrObjKind == SdrObjKind::Graphic ) |
1471 | 0 | { |
1472 | 0 | if ( nItemId == SID_PROTECTSIZE ) |
1473 | 0 | { |
1474 | 0 | bState = pObj->IsResizeProtect(); |
1475 | 0 | if ( pObj->IsMoveProtect() ) |
1476 | 0 | bEnabled = false; |
1477 | 0 | } |
1478 | 0 | else |
1479 | 0 | bState = pObj->IsMoveProtect(); |
1480 | |
|
1481 | 0 | break; |
1482 | 0 | } |
1483 | 0 | } |
1484 | 0 | } |
1485 | 0 | bEnabled = false; |
1486 | 0 | } |
1487 | 0 | break; |
1488 | | |
1489 | 0 | default: |
1490 | | // Ignore all other items. They are not meant to be |
1491 | | // handled by us. |
1492 | 0 | break; |
1493 | 0 | } |
1494 | 0 | } |
1495 | 0 | catch (const DeploymentException&) |
1496 | 0 | { |
1497 | 0 | } |
1498 | | |
1499 | | // Check if edit mode fits too |
1500 | 0 | if (bState && bEnabled) |
1501 | 0 | { |
1502 | 0 | ViewShell* const pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell( |
1503 | 0 | FrameworkHelper::msCenterPaneURL).get(); |
1504 | 0 | DrawViewShell* const pShell = dynamic_cast<DrawViewShell*>(pCenterViewShell); |
1505 | 0 | if (pShell) |
1506 | 0 | { |
1507 | 0 | switch (nItemId) |
1508 | 0 | { |
1509 | 0 | case SID_DRAWINGMODE: |
1510 | 0 | case SID_NORMAL_MULTI_PANE_GUI: |
1511 | 0 | case SID_NOTES_MODE: |
1512 | 0 | bState = pShell->GetEditMode() == EditMode::Page; |
1513 | 0 | break; |
1514 | 0 | case SID_SLIDE_MASTER_MODE: |
1515 | 0 | case SID_NOTES_MASTER_MODE: |
1516 | 0 | bState = pShell->GetEditMode() == EditMode::MasterPage; |
1517 | 0 | break; |
1518 | 0 | } |
1519 | 0 | } |
1520 | 0 | } |
1521 | | |
1522 | | // And finally set the state. |
1523 | 0 | rSet.Put(SfxBoolItem(nItemId, bState)); |
1524 | 0 | if (!bEnabled) |
1525 | 0 | rSet.DisableItem( nItemId ); |
1526 | |
|
1527 | 0 | nItemId = aSetIterator.NextWhich(); |
1528 | 0 | } |
1529 | 0 | } |
1530 | 0 | catch (const RuntimeException&) |
1531 | 0 | { |
1532 | 0 | DBG_UNHANDLED_EXCEPTION("sd.view"); |
1533 | 0 | } |
1534 | |
|
1535 | 0 | } |
1536 | | |
1537 | | } // end of namespace sd |
1538 | | |
1539 | | //===== CurrentPageSetter =========================================== |
1540 | | |
1541 | | namespace { |
1542 | | |
1543 | | CurrentPageSetter::CurrentPageSetter (ViewShellBase& rBase) |
1544 | 0 | : mrBase(rBase) |
1545 | 0 | { |
1546 | 0 | } |
1547 | | |
1548 | | void CurrentPageSetter::operator() (bool) |
1549 | 0 | { |
1550 | 0 | FrameView* pFrameView = nullptr; |
1551 | |
|
1552 | 0 | if (auto pViewShell = mrBase.GetMainViewShell().get()) |
1553 | 0 | { |
1554 | 0 | pFrameView = pViewShell->GetFrameView(); |
1555 | 0 | } |
1556 | |
|
1557 | 0 | if (pFrameView==nullptr) |
1558 | 0 | return; |
1559 | | |
1560 | 0 | try |
1561 | 0 | { |
1562 | | // Get the current page either from the DrawPagesSupplier or the |
1563 | | // MasterPagesSupplier. |
1564 | 0 | Any aPage; |
1565 | 0 | if (pFrameView->GetViewShEditModeOnLoad() == EditMode::Page) |
1566 | 0 | { |
1567 | 0 | Reference<drawing::XDrawPagesSupplier> xPagesSupplier ( |
1568 | 0 | mrBase.GetController()->getModel(), UNO_QUERY_THROW); |
1569 | 0 | Reference<container::XIndexAccess> xPages ( |
1570 | 0 | xPagesSupplier->getDrawPages(), UNO_QUERY_THROW); |
1571 | 0 | aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad()); |
1572 | 0 | } |
1573 | 0 | else |
1574 | 0 | { |
1575 | 0 | Reference<drawing::XMasterPagesSupplier> xPagesSupplier ( |
1576 | 0 | mrBase.GetController()->getModel(), UNO_QUERY_THROW); |
1577 | 0 | Reference<container::XIndexAccess> xPages ( |
1578 | 0 | xPagesSupplier->getMasterPages(), UNO_QUERY_THROW); |
1579 | 0 | aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad()); |
1580 | 0 | } |
1581 | | // Switch to the page last edited by setting the CurrentPage |
1582 | | // property. |
1583 | 0 | DrawController* pDrawController = mrBase.GetDrawController(); |
1584 | 0 | pDrawController->setPropertyValue (u"CurrentPage"_ustr, aPage); |
1585 | 0 | } |
1586 | 0 | catch (const RuntimeException&) |
1587 | 0 | { |
1588 | | // We have not been able to set the current page at the main view. |
1589 | | // This is sad but still leaves us in a valid state. Therefore, |
1590 | | // this exception is silently ignored. |
1591 | 0 | } |
1592 | 0 | catch (const beans::UnknownPropertyException&) |
1593 | 0 | { |
1594 | 0 | SAL_WARN("sd.view", "CurrentPage property unknown"); |
1595 | 0 | } |
1596 | 0 | } |
1597 | | |
1598 | | } // end of anonymous namespace |
1599 | | |
1600 | | SdViewOptions::SdViewOptions() |
1601 | 0 | : msColorSchemeName(u"Default"_ustr) |
1602 | 0 | { |
1603 | 0 | const svtools::ColorConfig& rColorConfig = SdModule::get()->GetColorConfig(); |
1604 | 0 | mnAppBackgroundColor = rColorConfig.GetColorValue(svtools::APPBACKGROUND).nColor; |
1605 | 0 | mnDocBackgroundColor = rColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; |
1606 | 0 | } |
1607 | | |
1608 | | //===== FocusForwardingWindow ================================================= |
1609 | | |
1610 | | namespace sd { |
1611 | | namespace { |
1612 | | |
1613 | | FocusForwardingWindow::FocusForwardingWindow ( |
1614 | | vcl::Window& rParentWindow, |
1615 | | ViewShellBase& rBase) |
1616 | 0 | : vcl::Window(&rParentWindow, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)), |
1617 | 0 | mrBase(rBase) |
1618 | 0 | { |
1619 | 0 | SAL_INFO("sd.view", "created FocusForwardingWindow at " << this); |
1620 | 0 | } |
1621 | | |
1622 | | FocusForwardingWindow::~FocusForwardingWindow() |
1623 | 0 | { |
1624 | 0 | disposeOnce(); |
1625 | 0 | } |
1626 | | |
1627 | | void FocusForwardingWindow::dispose() |
1628 | 0 | { |
1629 | 0 | SAL_INFO("sd.view", "destroyed FocusForwardingWindow at " << this); |
1630 | 0 | vcl::Window::dispose(); |
1631 | 0 | } |
1632 | | |
1633 | | void FocusForwardingWindow::KeyInput (const KeyEvent& rKEvt) |
1634 | 0 | { |
1635 | 0 | std::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell(); |
1636 | 0 | if (pViewShell != nullptr) |
1637 | 0 | { |
1638 | 0 | vcl::Window* pWindow = pViewShell->GetActiveWindow(); |
1639 | 0 | if (pWindow != nullptr) |
1640 | 0 | { |
1641 | | // Forward the focus so that the window is called directly the |
1642 | | // next time. |
1643 | 0 | pWindow->GrabFocus(); |
1644 | | // Forward the key press as well. |
1645 | 0 | pWindow->KeyInput(rKEvt); |
1646 | 0 | } |
1647 | 0 | } |
1648 | 0 | } |
1649 | | |
1650 | | void FocusForwardingWindow::Command (const CommandEvent& rEvent) |
1651 | 0 | { |
1652 | 0 | std::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell(); |
1653 | 0 | if (pViewShell != nullptr) |
1654 | 0 | { |
1655 | 0 | vcl::Window* pWindow = pViewShell->GetActiveWindow(); |
1656 | 0 | if (pWindow != nullptr) |
1657 | 0 | { |
1658 | 0 | pWindow->Command(rEvent); |
1659 | 0 | } |
1660 | 0 | } |
1661 | 0 | } |
1662 | | |
1663 | | } // end of anonymous namespace |
1664 | | |
1665 | | } // end of namespace sd |
1666 | | |
1667 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |