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 <comphelper/processfactory.hxx>
21 :
22 : #include <com/sun/star/frame/UnknownModuleException.hpp>
23 : #include <com/sun/star/frame/ModuleManager.hpp>
24 : #include <com/sun/star/container/XNameAccess.hpp>
25 : #include <com/sun/star/beans/PropertyValue.hpp>
26 : #include <com/sun/star/frame/theUICommandDescription.hpp>
27 :
28 : #include "ViewShellBase.hxx"
29 : #include <algorithm>
30 : #include "EventMultiplexer.hxx"
31 : #include "cache/SlsPageCacheManager.hxx"
32 : #include "sdresid.hxx"
33 : #include "app.hrc"
34 : #include "strings.hrc"
35 : #include "glob.hrc"
36 : #include "unokywds.hxx"
37 : #include <svx/svxids.hrc>
38 : #include "DrawDocShell.hxx"
39 : #include <sfx2/app.hxx>
40 : #include "PaneChildWindows.hxx"
41 : #include "ViewShellManager.hxx"
42 : #include "DrawController.hxx"
43 : #include "FrameView.hxx"
44 : #include "ViewTabBar.hxx"
45 : #include <sfx2/event.hxx>
46 : #include "drawdoc.hxx"
47 : #include <sfx2/dispatch.hxx>
48 : #include <sfx2/request.hxx>
49 : #include <sfx2/printer.hxx>
50 : #include "DrawViewShell.hxx"
51 : #include "GraphicViewShell.hxx"
52 : #include "OutlineViewShell.hxx"
53 : #include "SlideSorterViewShell.hxx"
54 : #include "PresentationViewShell.hxx"
55 : #include "FormShellManager.hxx"
56 : #include "ToolBarManager.hxx"
57 : #include "SidebarPanelId.hxx"
58 : #include "Window.hxx"
59 : #include "framework/ConfigurationController.hxx"
60 : #include "DocumentRenderer.hxx"
61 :
62 : #include <com/sun/star/frame/XFrame.hpp>
63 : #include <com/sun/star/awt/XWindow.hpp>
64 : #include <com/sun/star/frame/XController.hpp>
65 : #include <com/sun/star/frame/XModel.hpp>
66 : #include <com/sun/star/document/XViewDataSupplier.hpp>
67 : #include <com/sun/star/container/XIndexAccess.hpp>
68 : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
69 : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
70 : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
71 : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
72 : #include <com/sun/star/drawing/framework/ResourceId.hpp>
73 : #include "framework/FrameworkHelper.hxx"
74 :
75 : #include <rtl/ref.hxx>
76 : #include <sfx2/msg.hxx>
77 : #include <sfx2/objface.hxx>
78 : #include <sfx2/viewfrm.hxx>
79 : #include <svl/whiter.hxx>
80 : #include <vcl/msgbox.hxx>
81 : #include <vcl/settings.hxx>
82 :
83 : #include <tools/diagnose_ex.h>
84 :
85 : #include "fubullet.hxx"
86 :
87 : using namespace sd;
88 : #define ViewShellBase
89 : #include "sdslots.hxx"
90 :
91 : using ::sd::framework::FrameworkHelper;
92 : using namespace com::sun::star::uno;
93 : using namespace com::sun::star::frame;
94 : using namespace com::sun::star::container;
95 : using namespace com::sun::star::lang;
96 : using namespace com::sun::star::beans;
97 :
98 : namespace {
99 :
100 : class CurrentPageSetter
101 : {
102 : public:
103 : CurrentPageSetter (ViewShellBase& rBase);
104 : void operator () (bool);
105 : private:
106 : ViewShellBase& mrBase;
107 : };
108 :
109 : } // end of anonymous namespace
110 :
111 : using namespace ::com::sun::star;
112 : using namespace ::com::sun::star::uno;
113 : using namespace ::com::sun::star::drawing::framework;
114 : using ::sd::framework::FrameworkHelper;
115 :
116 : namespace sd {
117 :
118 : class ViewShellBase::Implementation
119 : {
120 : public:
121 : /** Main controller of the view shell. During the switching from one
122 : stacked shell to another this pointer may be NULL.
123 : */
124 : ::rtl::Reference<DrawController> mpController;
125 :
126 : /** The view tab bar is the control for switching between different
127 : views in one pane.
128 : */
129 : ::rtl::Reference<ViewTabBar> mpViewTabBar;
130 :
131 : // contains the complete area of the current view relative to the frame window
132 : Rectangle maClientArea;
133 :
134 : // This is set to true when PrepareClose() is called.
135 : bool mbIsClosing;
136 :
137 : /** The view window is the parent of all UI elements that belong to the
138 : view or ViewShell. This comprises the rulers, the scroll bars, and
139 : the content window.
140 : It does not include the ViewTabBar.
141 : */
142 : ::boost::scoped_ptr< vcl::Window> mpViewWindow;
143 : ::boost::shared_ptr<ToolBarManager> mpToolBarManager;
144 : ::boost::shared_ptr<ViewShellManager> mpViewShellManager;
145 : ::boost::shared_ptr<tools::EventMultiplexer> mpEventMultiplexer;
146 : ::boost::shared_ptr<FormShellManager> mpFormShellManager;
147 :
148 : Implementation (ViewShellBase& rBase);
149 : ~Implementation (void);
150 :
151 : void LateInit (void);
152 :
153 : /** Show or hide the ViewTabBar.
154 : @param bShow
155 : When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden.
156 : */
157 : void ShowViewTabBar (bool bShow);
158 :
159 : /** Common code of ViewShellBase::OuterResizePixel() and
160 : ViewShellBase::InnerResizePixel().
161 : */
162 : void ResizePixel (
163 : const Point& rOrigin,
164 : const Size& rSize,
165 : bool bOuterResize);
166 :
167 : /** Show or hide the specified pane. The visibility state is taken
168 : fromthe given request.
169 : @param rRequest
170 : The request determines the new visibility state. The state can
171 : either be toggled or be set to a given value.
172 : @param rsPaneURL
173 : This URL specifies the pane whose visibility state to set.
174 : @param rsViewURL
175 : When the pane becomes visible then this view URL specifies which
176 : type of view to show in it.
177 : */
178 : void SetPaneVisibility (
179 : const SfxRequest& rRequest,
180 : const OUString& rsPaneURL,
181 : const OUString& rsViewURL);
182 :
183 : void GetSlotState (SfxItemSet& rSet);
184 :
185 : void ProcessRestoreEditingViewSlot (void);
186 :
187 : private:
188 : ViewShellBase& mrBase;
189 :
190 : /** Hold a reference to the page cache manager of the slide sorter in
191 : order to ensure that it stays alive while the ViewShellBase is
192 : alive.
193 : */
194 : ::boost::shared_ptr<slidesorter::cache::PageCacheManager> mpPageCacheManager;
195 : };
196 :
197 : namespace {
198 : /** The only task of this window is to forward key presses to the content
199 : window of the main view shell. With the key press it forwards the focus
200 : so that it is not called very often.
201 : */
202 : class FocusForwardingWindow : public vcl::Window
203 : {
204 : public:
205 : FocusForwardingWindow (vcl::Window& rParentWindow, ViewShellBase& rBase);
206 : virtual ~FocusForwardingWindow (void);
207 : virtual void KeyInput (const KeyEvent& rEvent) SAL_OVERRIDE;
208 : virtual void Command (const CommandEvent& rEvent) SAL_OVERRIDE;
209 :
210 : private:
211 : ViewShellBase& mrBase;
212 : };
213 : } // end of anonymous namespace
214 :
215 : //===== ViewShellBase =========================================================
216 :
217 8417 : TYPEINIT1(ViewShellBase, SfxViewShell);
218 :
219 : // We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
220 : // new ViewShellBase object has been constructed.
221 :
222 : SfxViewFactory* ViewShellBase::pFactory;
223 :
224 7324 : SFX_IMPL_INTERFACE(ViewShellBase, SfxViewShell, SdResId(0))
225 :
226 36 : void ViewShellBase::InitInterface_Impl()
227 : {
228 36 : }
229 :
230 212 : ViewShellBase::ViewShellBase (
231 : SfxViewFrame* _pFrame,
232 : SfxViewShell*)
233 : : SfxViewShell (_pFrame,
234 : SFX_VIEW_CAN_PRINT
235 : | SFX_VIEW_HAS_PRINTOPTIONS),
236 : maMutex(),
237 : mpImpl(),
238 : mpDocShell (NULL),
239 212 : mpDocument (NULL)
240 : {
241 212 : mpImpl.reset(new Implementation(*this));
242 212 : mpImpl->mpViewWindow.reset(new FocusForwardingWindow(_pFrame->GetWindow(),*this));
243 212 : mpImpl->mpViewWindow->SetBackground(Wallpaper());
244 :
245 212 : _pFrame->GetWindow().SetBackground(Application::GetSettings().GetStyleSettings().GetLightColor());
246 :
247 : // Set up the members in the correct order.
248 212 : if (GetViewFrame()->GetObjectShell()->ISA(DrawDocShell))
249 : mpDocShell = static_cast<DrawDocShell*>(
250 212 : GetViewFrame()->GetObjectShell());
251 212 : if (mpDocShell != NULL)
252 212 : mpDocument = mpDocShell->GetDoc();
253 212 : mpImpl->mpViewShellManager.reset(new ViewShellManager(*this));
254 :
255 212 : SetWindow(mpImpl->mpViewWindow.get());
256 :
257 : // Hide the window to avoid complaints from Sfx...SwitchViewShell...
258 212 : _pFrame->GetWindow().Hide();
259 212 : }
260 :
261 : /** In this destructor the order in which some of the members are destroyed
262 : (and/or being prepared to being destroyed) is important. Change it only
263 : when you know what you are doing.
264 : */
265 424 : ViewShellBase::~ViewShellBase (void)
266 : {
267 : // Tell the controller that the ViewShellBase is not available anymore.
268 212 : if (mpImpl->mpController.get() != NULL)
269 212 : mpImpl->mpController->ReleaseViewShellBase();
270 :
271 : // We have to hide the main window to prevent SFX complaining after a
272 : // reload about it being already visible.
273 212 : ViewShell* pShell = GetMainViewShell().get();
274 212 : if (pShell!=NULL
275 0 : && pShell->GetActiveWindow()!=NULL
276 212 : && pShell->GetActiveWindow()->GetParent()!=NULL)
277 : {
278 0 : pShell->GetActiveWindow()->GetParent()->Hide();
279 : }
280 :
281 212 : mpImpl->mpToolBarManager->Shutdown();
282 212 : mpImpl->mpViewShellManager->Shutdown();
283 :
284 212 : EndListening(*GetViewFrame());
285 212 : EndListening(*GetDocShell());
286 :
287 212 : SetWindow(NULL);
288 212 : }
289 :
290 212 : void ViewShellBase::LateInit (const OUString& rsDefaultView)
291 : {
292 212 : StartListening(*GetViewFrame(),true);
293 212 : StartListening(*GetDocShell(),true);
294 212 : mpImpl->LateInit();
295 212 : InitializeFramework();
296 :
297 212 : mpImpl->mpEventMultiplexer.reset(new tools::EventMultiplexer (*this));
298 :
299 212 : mpImpl->mpFormShellManager.reset(new FormShellManager(*this));
300 :
301 636 : mpImpl->mpToolBarManager = ToolBarManager::Create(
302 : *this,
303 212 : mpImpl->mpEventMultiplexer,
304 424 : mpImpl->mpViewShellManager);
305 :
306 : try
307 : {
308 212 : Reference<XControllerManager> xControllerManager (GetDrawController(), UNO_QUERY_THROW);
309 : Reference<XConfigurationController> xConfigurationController (
310 424 : xControllerManager->getConfigurationController());
311 212 : if (xConfigurationController.is())
312 : {
313 212 : OUString sView (rsDefaultView);
314 212 : if (sView.isEmpty())
315 52 : sView = GetInitialViewShellType();
316 :
317 424 : ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(*this));
318 :
319 : // Create the resource ids for the center pane and view.
320 : const Reference<drawing::framework::XResourceId> xCenterPaneId (
321 424 : FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL));
322 : const Reference<drawing::framework::XResourceId> xCenterViewId (
323 424 : FrameworkHelper::CreateResourceId(sView, xCenterPaneId));
324 :
325 : // Request center pane and view.
326 212 : xConfigurationController->requestResourceActivation(xCenterPaneId, ResourceActivationMode_ADD);
327 212 : xConfigurationController->requestResourceActivation(xCenterViewId, ResourceActivationMode_REPLACE);
328 :
329 : // Process configuration events synchronously until the center view
330 : // has been created.
331 : sd::framework::ConfigurationController* pConfigurationController
332 212 : = dynamic_cast<sd::framework::ConfigurationController*>(xConfigurationController.get());
333 212 : if (pConfigurationController != NULL)
334 : {
335 2644 : while (
336 4864 : ! pConfigurationController->getResource(xCenterViewId).is()
337 3648 : && pConfigurationController->hasPendingRequests())
338 : {
339 1004 : pConfigurationController->ProcessEvent();
340 : }
341 212 : }
342 212 : }
343 : }
344 0 : catch (const RuntimeException&)
345 : {
346 : }
347 :
348 : // AutoLayouts have to be ready.
349 212 : GetDocument()->StopWorkStartupDelay();
350 :
351 212 : UpdateBorder();
352 :
353 : // Remember the type of the current main view shell in the frame view.
354 212 : ViewShell* pViewShell = GetMainViewShell().get();
355 212 : if (pViewShell != NULL)
356 : {
357 212 : FrameView* pFrameView = pViewShell->GetFrameView();
358 212 : if (pFrameView != NULL)
359 212 : pFrameView->SetViewShellTypeOnLoad(pViewShell->GetShellType());
360 : }
361 212 : }
362 :
363 10620 : ::boost::shared_ptr<ViewShellManager> ViewShellBase::GetViewShellManager (void) const
364 : {
365 10620 : return mpImpl->mpViewShellManager;
366 : }
367 :
368 10178 : ::boost::shared_ptr<ViewShell> ViewShellBase::GetMainViewShell (void) const
369 : {
370 : ::boost::shared_ptr<ViewShell> pMainViewShell (
371 : framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))
372 10178 : ->GetViewShell(framework::FrameworkHelper::msCenterPaneURL));
373 10178 : if (pMainViewShell.get() == NULL)
374 3724 : pMainViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))
375 1862 : ->GetViewShell(framework::FrameworkHelper::msFullScreenPaneURL);
376 10178 : return pMainViewShell;
377 : }
378 :
379 671 : ViewShellBase* ViewShellBase::GetViewShellBase (SfxViewFrame* pViewFrame)
380 : {
381 671 : ViewShellBase* pBase = NULL;
382 :
383 671 : if (pViewFrame != NULL)
384 : {
385 : // Get the view shell for the frame and cast it to
386 : // sd::ViewShellBase.
387 671 : SfxViewShell* pSfxViewShell = pViewFrame->GetViewShell();
388 671 : if (pSfxViewShell!=NULL && pSfxViewShell->ISA(::sd::ViewShellBase))
389 671 : pBase = static_cast<ViewShellBase*>(pSfxViewShell);
390 : }
391 :
392 671 : return pBase;
393 : }
394 :
395 86394 : void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
396 : {
397 86394 : SfxViewShell::Notify(rBC, rHint);
398 :
399 86394 : const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
400 86394 : if (pEventHint)
401 : {
402 2306 : switch (pEventHint->GetEventId())
403 : {
404 : case SFX_EVENT_OPENDOC:
405 4 : if( GetDocument() && GetDocument()->IsStartWithPresentation() )
406 : {
407 0 : if( GetViewFrame() )
408 : {
409 : GetViewFrame()->GetDispatcher()->Execute(
410 0 : SID_PRESENTATION, SfxCallMode::ASYNCHRON );
411 : }
412 : }
413 4 : break;
414 :
415 : default:
416 2302 : break;
417 : }
418 : }
419 86394 : }
420 :
421 0 : void ViewShellBase::InitializeFramework (void)
422 : {
423 0 : }
424 :
425 0 : OUString ViewShellBase::GetSelectionText(bool bCompleteWords)
426 : {
427 0 : ::boost::shared_ptr<ViewShell> const pMainShell(GetMainViewShell());
428 : DrawViewShell *const pDrawViewShell(
429 0 : dynamic_cast<DrawViewShell*>(pMainShell.get()));
430 : return (pDrawViewShell)
431 0 : ? pDrawViewShell->GetSelectionText(bCompleteWords)
432 0 : : SfxViewShell::GetSelectionText(bCompleteWords);
433 : }
434 :
435 0 : bool ViewShellBase::HasSelection(bool bText) const
436 : {
437 0 : ::boost::shared_ptr<ViewShell> const pMainShell(GetMainViewShell());
438 : DrawViewShell *const pDrawViewShell(
439 0 : dynamic_cast<DrawViewShell*>(pMainShell.get()));
440 : return (pDrawViewShell)
441 0 : ? pDrawViewShell->HasSelection(bText)
442 0 : : SfxViewShell::HasSelection(bText);
443 : }
444 :
445 0 : void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize)
446 : {
447 0 : Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
448 0 : if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
449 : {
450 0 : SvBorder aBorder( GetBorderPixel() );
451 0 : Size aSize( rSize );
452 0 : aSize.Width() -= (aBorder.Left() + aBorder.Right());
453 0 : aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
454 0 : Size aObjSizePixel = mpImpl->mpViewWindow->LogicToPixel( aObjSize, MAP_100TH_MM );
455 : SfxViewShell::SetZoomFactor(
456 0 : Fraction( aSize.Width(), std::max( aObjSizePixel.Width(), (long int)1 ) ),
457 0 : Fraction( aSize.Height(), std::max( aObjSizePixel.Height(), (long int)1) ) );
458 : }
459 :
460 0 : mpImpl->ResizePixel(rOrigin, rSize, false);
461 0 : }
462 :
463 689 : void ViewShellBase::OuterResizePixel (const Point& rOrigin, const Size &rSize)
464 : {
465 689 : mpImpl->ResizePixel (rOrigin, rSize, true);
466 689 : }
467 :
468 0 : void ViewShellBase::Rearrange (void)
469 : {
470 : OSL_ASSERT(GetViewFrame()!=NULL);
471 :
472 : // There is a bug in the communication between embedded objects and the
473 : // framework::LayoutManager that leads to missing resize updates. The
474 : // following workaround enforces such an update by cycling the border to
475 : // zero and back to the current value.
476 0 : if (GetWindow() != NULL)
477 : {
478 0 : SetBorderPixel(SvBorder());
479 0 : UpdateBorder(true);
480 : }
481 : else
482 : {
483 : OSL_TRACE("Rearrange: window missing");
484 : }
485 :
486 0 : GetViewFrame()->Resize(true);
487 0 : }
488 :
489 0 : ErrCode ViewShellBase::DoVerb (long nVerb)
490 : {
491 0 : ErrCode aResult = ERRCODE_NONE;
492 :
493 0 : ::sd::ViewShell* pShell = GetMainViewShell().get();
494 0 : if (pShell != NULL)
495 0 : aResult = pShell->DoVerb (nVerb);
496 :
497 0 : return aResult;
498 : }
499 :
500 0 : Reference<view::XRenderable> ViewShellBase::GetRenderable (void)
501 : {
502 : // Create a new DocumentRenderer on every call. It observes the life
503 : // time of this ViewShellBase object.
504 0 : return Reference<view::XRenderable>(new DocumentRenderer(*this));
505 : }
506 :
507 760 : SfxPrinter* ViewShellBase::GetPrinter (bool bCreate)
508 : {
509 : OSL_ASSERT(mpImpl.get()!=NULL);
510 :
511 760 : return GetDocShell()->GetPrinter (bCreate);
512 : }
513 :
514 0 : sal_uInt16 ViewShellBase::SetPrinter (
515 : SfxPrinter* pNewPrinter,
516 : sal_uInt16 nDiffFlags,
517 : bool bIsAPI)
518 : {
519 : OSL_ASSERT(mpImpl.get()!=NULL);
520 :
521 0 : GetDocShell()->SetPrinter(pNewPrinter);
522 :
523 0 : if ( (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ||
524 0 : nDiffFlags & SFX_PRINTER_CHG_SIZE) && pNewPrinter )
525 : {
526 0 : MapMode aMap = pNewPrinter->GetMapMode();
527 0 : aMap.SetMapUnit(MAP_100TH_MM);
528 0 : MapMode aOldMap = pNewPrinter->GetMapMode();
529 0 : pNewPrinter->SetMapMode(aMap);
530 0 : Size aNewSize = pNewPrinter->GetOutputSize();
531 :
532 0 : bool bScaleAll = false;
533 0 : if ( bIsAPI )
534 : {
535 : WarningBox aWarnBox (
536 : GetWindow(),
537 : (WinBits)(WB_YES_NO | WB_DEF_YES),
538 0 : SD_RESSTR(STR_SCALE_OBJS_TO_PAGE));
539 0 : bScaleAll = (aWarnBox.Execute() == RET_YES);
540 : }
541 :
542 : ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
543 0 : ::boost::dynamic_pointer_cast<DrawViewShell>(GetMainViewShell()));
544 0 : if (pDrawViewShell)
545 : {
546 : SdPage* pPage = GetDocument()->GetSdPage(
547 0 : 0, PK_STANDARD );
548 0 : pDrawViewShell->SetPageSizeAndBorder (
549 : pDrawViewShell->GetPageKind(),
550 : aNewSize,
551 : -1,-1,-1,-1,
552 : bScaleAll,
553 : pNewPrinter->GetOrientation(),
554 0 : pPage->GetPaperBin(),
555 0 : pPage->IsBackgroundFullSize());
556 : }
557 :
558 0 : pNewPrinter->SetMapMode(aOldMap);
559 : }
560 :
561 0 : return 0;
562 : }
563 :
564 0 : void ViewShellBase::UIActivating( SfxInPlaceClient* pClient )
565 : {
566 0 : mpImpl->ShowViewTabBar(false);
567 :
568 0 : ViewShell* pViewShell = GetMainViewShell().get();
569 0 : if ( pViewShell )
570 0 : pViewShell->UIActivating( pClient );
571 :
572 0 : SfxViewShell::UIActivating( pClient );
573 0 : }
574 :
575 0 : void ViewShellBase::UIDeactivated( SfxInPlaceClient* pClient )
576 : {
577 0 : SfxViewShell::UIDeactivated( pClient );
578 :
579 0 : mpImpl->ShowViewTabBar(true);
580 :
581 0 : ViewShell* pViewShell = GetMainViewShell().get();
582 0 : if ( pViewShell )
583 0 : pViewShell->UIDeactivated( pClient );
584 0 : }
585 :
586 901 : SvBorder ViewShellBase::GetBorder (bool )
587 : {
588 901 : int nTop = 0;
589 901 : if (mpImpl->mpViewTabBar.is() && mpImpl->mpViewTabBar->GetTabControl()->IsVisible())
590 260 : nTop = mpImpl->mpViewTabBar->GetHeight();
591 901 : return SvBorder(0,nTop,0,0);
592 : }
593 :
594 0 : void ViewShellBase::Execute (SfxRequest& rRequest)
595 : {
596 0 : sal_uInt16 nSlotId = rRequest.GetSlot();
597 :
598 0 : switch (nSlotId)
599 : {
600 : case SID_SWITCH_SHELL:
601 : {
602 0 : Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
603 0 : if (xControllerManager.is())
604 : {
605 : Reference<XConfigurationController> xConfigurationController (
606 0 : xControllerManager->getConfigurationController());
607 0 : if (xConfigurationController.is())
608 0 : xConfigurationController->update();
609 0 : }
610 : }
611 0 : break;
612 :
613 : case SID_LEFT_PANE_DRAW:
614 : mpImpl->SetPaneVisibility(
615 : rRequest,
616 : framework::FrameworkHelper::msLeftDrawPaneURL,
617 0 : framework::FrameworkHelper::msSlideSorterURL);
618 0 : break;
619 :
620 : case SID_LEFT_PANE_IMPRESS:
621 : mpImpl->SetPaneVisibility(
622 : rRequest,
623 : framework::FrameworkHelper::msLeftImpressPaneURL,
624 0 : framework::FrameworkHelper::msSlideSorterURL);
625 0 : break;
626 :
627 : case SID_NORMAL_MULTI_PANE_GUI:
628 : case SID_SLIDE_SORTER_MULTI_PANE_GUI:
629 : case SID_DRAWINGMODE:
630 : case SID_DIAMODE:
631 : case SID_OUTLINEMODE:
632 : case SID_NOTESMODE:
633 : case SID_HANDOUTMODE:
634 0 : framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId, rRequest);
635 0 : break;
636 :
637 : case SID_WIN_FULLSCREEN:
638 : // The full screen mode is not supported. Ignore the request.
639 0 : break;
640 :
641 : case SID_RESTORE_EDITING_VIEW:
642 0 : mpImpl->ProcessRestoreEditingViewSlot();
643 0 : break;
644 :
645 : default:
646 : // Ignore any other slot.
647 0 : rRequest.Ignore ();
648 0 : break;
649 : }
650 0 : }
651 :
652 0 : void ViewShellBase::GetState (SfxItemSet& rSet)
653 : {
654 0 : mpImpl->GetSlotState(rSet);
655 :
656 0 : FuBullet::GetSlotState( rSet, 0, GetViewFrame() );
657 0 : }
658 :
659 214 : void ViewShellBase::WriteUserDataSequence (
660 : ::com::sun::star::uno::Sequence <
661 : ::com::sun::star::beans::PropertyValue >& rSequence,
662 : bool bBrowse)
663 : {
664 : // Forward call to main sub shell.
665 214 : ViewShell* pShell = GetMainViewShell().get();
666 214 : if (pShell != NULL)
667 214 : pShell->WriteUserDataSequence (rSequence, bBrowse);
668 214 : }
669 :
670 212 : void ViewShellBase::ReadUserDataSequence (
671 : const ::com::sun::star::uno::Sequence <
672 : ::com::sun::star::beans::PropertyValue >& rSequence,
673 : bool bBrowse)
674 : {
675 : // Forward call to main sub shell.
676 212 : ViewShell* pShell = GetMainViewShell().get();
677 212 : if (pShell != NULL)
678 : {
679 212 : pShell->ReadUserDataSequence (rSequence, bBrowse);
680 :
681 : // For certain shell types ReadUserDataSequence may have changed the
682 : // type to another one. Make sure that the center pane shows the
683 : // right view shell.
684 212 : switch (pShell->GetShellType())
685 : {
686 : case ViewShell::ST_IMPRESS:
687 : case ViewShell::ST_NOTES:
688 : case ViewShell::ST_HANDOUT:
689 : {
690 52 : OUString sViewURL;
691 52 : switch (PTR_CAST(DrawViewShell, pShell)->GetPageKind())
692 : {
693 : default:
694 : case PK_STANDARD:
695 52 : sViewURL = framework::FrameworkHelper::msImpressViewURL;
696 52 : break;
697 : case PK_NOTES:
698 0 : sViewURL = framework::FrameworkHelper::msNotesViewURL;
699 0 : break;
700 : case PK_HANDOUT:
701 0 : sViewURL = framework::FrameworkHelper::msHandoutViewURL;
702 0 : break;
703 : }
704 52 : if (!sViewURL.isEmpty())
705 : framework::FrameworkHelper::Instance(*this)->RequestView(
706 : sViewURL,
707 52 : framework::FrameworkHelper::msCenterPaneURL);
708 : }
709 52 : break;
710 :
711 : default:
712 160 : break;
713 : }
714 : }
715 212 : }
716 :
717 212 : void ViewShellBase::Activate (bool bIsMDIActivate)
718 : {
719 212 : SfxViewShell::Activate(bIsMDIActivate);
720 :
721 212 : Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
722 212 : if (xControllerManager.is())
723 : {
724 : Reference<XConfigurationController> xConfigurationController (
725 212 : xControllerManager->getConfigurationController());
726 212 : if (xConfigurationController.is())
727 212 : xConfigurationController->update();
728 : }
729 212 : GetToolBarManager()->RequestUpdate();
730 212 : }
731 :
732 212 : void ViewShellBase::Deactivate (bool bIsMDIActivate)
733 : {
734 212 : SfxViewShell::Deactivate(bIsMDIActivate);
735 212 : }
736 :
737 0 : void ViewShellBase::SetZoomFactor (
738 : const Fraction &rZoomX,
739 : const Fraction &rZoomY)
740 : {
741 0 : SfxViewShell::SetZoomFactor (rZoomX, rZoomY);
742 : // Forward call to main sub shell.
743 0 : ViewShell* pShell = GetMainViewShell().get();
744 0 : if (pShell != NULL)
745 0 : pShell->SetZoomFactor (rZoomX, rZoomY);
746 0 : }
747 :
748 354 : bool ViewShellBase::PrepareClose (bool bUI)
749 : {
750 354 : bool nResult = SfxViewShell::PrepareClose (bUI);
751 :
752 354 : if (nResult)
753 : {
754 354 : mpImpl->mbIsClosing = true;
755 :
756 : // Forward call to main sub shell.
757 354 : ViewShell* pShell = GetMainViewShell().get();
758 354 : if (pShell != NULL)
759 354 : nResult = pShell->PrepareClose (bUI);
760 : }
761 :
762 354 : return nResult;
763 : }
764 :
765 0 : void ViewShellBase::WriteUserData (OUString& rString, bool bBrowse)
766 : {
767 0 : SfxViewShell::WriteUserData (rString, bBrowse);
768 :
769 : // Forward call to main sub shell.
770 0 : ViewShell* pShell = GetMainViewShell().get();
771 0 : if (pShell != NULL)
772 0 : pShell->WriteUserData (rString);
773 0 : }
774 :
775 0 : void ViewShellBase::ReadUserData (const OUString& rString, bool bBrowse)
776 : {
777 0 : SfxViewShell::ReadUserData (rString, bBrowse);
778 :
779 : // Forward call to main sub shell.
780 0 : ViewShell* pShell = GetMainViewShell().get();
781 0 : if (pShell != NULL)
782 0 : pShell->ReadUserData (rString);
783 0 : }
784 :
785 874 : SdrView* ViewShellBase::GetDrawView (void) const
786 : {
787 : // Forward call to main sub shell.
788 874 : ViewShell* pShell = GetMainViewShell().get();
789 874 : if (pShell != NULL)
790 662 : return pShell->GetDrawView ();
791 : else
792 212 : return SfxViewShell::GetDrawView();
793 : }
794 :
795 0 : void ViewShellBase::AdjustPosSizePixel (const Point &rOfs, const Size &rSize)
796 : {
797 0 : SfxViewShell::AdjustPosSizePixel (rOfs, rSize);
798 0 : }
799 :
800 0 : void ViewShellBase::SetBusyState (bool bBusy)
801 : {
802 0 : if (GetDocShell() != NULL)
803 0 : GetDocShell()->SetWaitCursor (bBusy);
804 0 : }
805 :
806 212 : void ViewShellBase::UpdateBorder ( bool bForce /* = false */ )
807 : {
808 : // The following calls to SetBorderPixel() and InvalidateBorder() are
809 : // made only for the main view shell. This not only avoids unnecessary
810 : // calls for the views in side panes but prevents calling an already
811 : // dying SfxViewShell base class.
812 : // We have to check the existence of the window, too.
813 : // The SfxViewFrame accesses the window without checking it.
814 212 : ViewShell* pMainViewShell = GetMainViewShell().get();
815 212 : if (pMainViewShell != NULL && GetWindow()!=NULL)
816 : {
817 212 : SvBorder aCurrentBorder (GetBorderPixel());
818 212 : bool bOuterResize ( ! GetDocShell()->IsInPlaceActive());
819 212 : SvBorder aBorder (GetBorder(bOuterResize));
820 212 : aBorder += pMainViewShell->GetBorder(bOuterResize);
821 :
822 212 : if (bForce || (aBorder != aCurrentBorder))
823 : {
824 212 : SetBorderPixel (aBorder);
825 212 : InvalidateBorder();
826 : }
827 : }
828 212 : }
829 :
830 0 : void ViewShellBase::ShowUIControls (bool bVisible)
831 : {
832 0 : if (mpImpl->mpViewTabBar.is())
833 0 : mpImpl->mpViewTabBar->GetTabControl()->Show(bVisible);
834 :
835 0 : ViewShell* pMainViewShell = GetMainViewShell().get();
836 0 : if (pMainViewShell != NULL)
837 0 : pMainViewShell->ShowUIControls (bVisible);
838 :
839 0 : UpdateBorder();
840 0 : if (bVisible)
841 0 : Rearrange();
842 0 : }
843 :
844 52 : OUString ViewShellBase::GetInitialViewShellType (void)
845 : {
846 52 : OUString sRequestedView (FrameworkHelper::msImpressViewURL);
847 :
848 : do
849 : {
850 : Reference<document::XViewDataSupplier> xViewDataSupplier (
851 52 : GetDocShell()->GetModel(), UNO_QUERY);
852 52 : if ( ! xViewDataSupplier.is())
853 0 : break;
854 :
855 58 : Reference<container::XIndexAccess> xViewData (xViewDataSupplier->getViewData());
856 52 : if ( ! xViewData.is())
857 46 : break;
858 6 : if (xViewData->getCount() == 0)
859 0 : break;
860 :
861 6 : sal_Int32 nView = 0;
862 12 : ::com::sun::star::uno::Any aAny = xViewData->getByIndex(nView);
863 12 : Sequence<beans::PropertyValue> aProperties;
864 6 : if ( ! (aAny >>= aProperties))
865 0 : break;
866 :
867 : // Search the properties for the one that tells us what page kind to
868 : // use.
869 112 : for (sal_Int32 n=0; n<aProperties.getLength(); n++)
870 : {
871 112 : const beans::PropertyValue& rProperty (aProperties[n]);
872 112 : if (rProperty.Name == sUNO_View_PageKind)
873 : {
874 6 : sal_Int16 nPageKind = 0;
875 6 : rProperty.Value >>= nPageKind;
876 6 : switch ((PageKind)nPageKind)
877 : {
878 : case PK_STANDARD:
879 6 : sRequestedView = FrameworkHelper::msImpressViewURL;
880 6 : break;
881 :
882 : case PK_HANDOUT:
883 0 : sRequestedView = FrameworkHelper::msHandoutViewURL;
884 0 : break;
885 :
886 : case PK_NOTES:
887 0 : sRequestedView = FrameworkHelper::msNotesViewURL;
888 0 : break;
889 :
890 : default:
891 : // The page kind is invalid. This is probably an
892 : // error by the caller. We use the standard type to
893 : // keep things going.
894 : DBG_ASSERT(false, "ViewShellBase::GetInitialViewShellType: invalid page kind");
895 0 : sRequestedView = FrameworkHelper::msImpressViewURL;
896 0 : break;
897 : }
898 6 : break;
899 : }
900 6 : }
901 : }
902 : while (false);
903 :
904 52 : return sRequestedView;
905 : }
906 :
907 : /** this method starts the presentation by
908 : executing the slot SID_PRESENTATION asynchronous */
909 0 : void ViewShellBase::StartPresentation()
910 : {
911 0 : if( GetViewFrame() && GetViewFrame()->GetDispatcher() )
912 0 : GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
913 0 : }
914 :
915 1800 : ::boost::shared_ptr<tools::EventMultiplexer> ViewShellBase::GetEventMultiplexer (void)
916 : {
917 : OSL_ASSERT(mpImpl.get()!=NULL);
918 : OSL_ASSERT(mpImpl->mpEventMultiplexer.get()!=NULL);
919 :
920 1800 : return mpImpl->mpEventMultiplexer;
921 : }
922 :
923 0 : const Rectangle& ViewShellBase::getClientRectangle (void) const
924 : {
925 0 : return mpImpl->maClientArea;
926 : }
927 :
928 2134 : ::boost::shared_ptr<ToolBarManager> ViewShellBase::GetToolBarManager (void) const
929 : {
930 : OSL_ASSERT(mpImpl.get()!=NULL);
931 : OSL_ASSERT(mpImpl->mpToolBarManager.get()!=NULL);
932 :
933 2134 : return mpImpl->mpToolBarManager;
934 : }
935 :
936 2201 : ::boost::shared_ptr<FormShellManager> ViewShellBase::GetFormShellManager (void) const
937 : {
938 : OSL_ASSERT(mpImpl.get()!=NULL);
939 : OSL_ASSERT(mpImpl->mpFormShellManager.get()!=NULL);
940 :
941 2201 : return mpImpl->mpFormShellManager;
942 : }
943 :
944 5180 : DrawController& ViewShellBase::GetDrawController (void) const
945 : {
946 : OSL_ASSERT(mpImpl.get()!=NULL);
947 :
948 5180 : return *mpImpl->mpController;
949 : }
950 :
951 104 : void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar)
952 : {
953 : OSL_ASSERT(mpImpl.get()!=NULL);
954 :
955 104 : mpImpl->mpViewTabBar = rViewTabBar;
956 104 : }
957 :
958 212 : ::vcl::Window* ViewShellBase::GetViewWindow (void)
959 : {
960 : OSL_ASSERT(mpImpl.get()!=NULL);
961 :
962 212 : return mpImpl->mpViewWindow.get();
963 : }
964 :
965 0 : OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const OUString& aCmdURL )
966 : {
967 0 : OUString aLabel;
968 :
969 0 : if ( !aCmdURL.isEmpty() ) try
970 : {
971 0 : Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_QUERY_THROW );
972 :
973 0 : Reference< XModuleManager2 > xModuleManager( ModuleManager::create(xContext) );
974 :
975 0 : OUString aModuleIdentifier( xModuleManager->identify( Reference<XInterface>( xFrame, UNO_QUERY_THROW ) ) );
976 :
977 0 : if( !aModuleIdentifier.isEmpty() )
978 : {
979 : Reference< XNameAccess > const xNameAccess(
980 0 : frame::theUICommandDescription::get(xContext) );
981 0 : Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels( xNameAccess->getByName( aModuleIdentifier ), UNO_QUERY_THROW );
982 0 : Sequence< PropertyValue > aPropSeq;
983 0 : if( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
984 : {
985 0 : for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
986 : {
987 0 : if ( aPropSeq[i].Name == "Name" )
988 : {
989 0 : aPropSeq[i].Value >>= aLabel;
990 0 : break;
991 : }
992 : }
993 0 : }
994 0 : }
995 : }
996 0 : catch (const Exception&)
997 : {
998 : }
999 :
1000 0 : return aLabel;
1001 : }
1002 :
1003 0 : OUString ViewShellBase::RetrieveLabelFromCommand( const OUString& aCmdURL ) const
1004 : {
1005 0 : Reference< XFrame > xFrame( GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(), UNO_QUERY );
1006 0 : return ImplRetrieveLabelFromCommand( xFrame, aCmdURL );
1007 : }
1008 :
1009 : //===== ViewShellBase::Implementation =========================================
1010 :
1011 212 : ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
1012 : : mpController(),
1013 : mpViewTabBar(),
1014 : maClientArea(),
1015 : mbIsClosing(false),
1016 : mpViewWindow(),
1017 : mpToolBarManager(),
1018 : mpViewShellManager(),
1019 : mpEventMultiplexer(),
1020 : mpFormShellManager(),
1021 : mrBase(rBase),
1022 212 : mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance())
1023 : {
1024 212 : }
1025 :
1026 424 : ViewShellBase::Implementation::~Implementation (void)
1027 : {
1028 212 : mpController = NULL;
1029 212 : mpViewTabBar = NULL;
1030 212 : mpViewWindow.reset();
1031 212 : mpToolBarManager.reset();
1032 212 : }
1033 :
1034 212 : void ViewShellBase::Implementation::LateInit (void)
1035 : {
1036 212 : mpController = new DrawController(mrBase);
1037 212 : }
1038 :
1039 0 : void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void)
1040 : {
1041 0 : ViewShell* pViewShell = mrBase.GetMainViewShell().get();
1042 0 : if (pViewShell != NULL)
1043 : {
1044 0 : FrameView* pFrameView = pViewShell->GetFrameView();
1045 0 : if (pFrameView != NULL)
1046 : {
1047 : // Set view shell, edit mode, and page kind.
1048 : pFrameView->SetViewShEditMode(
1049 : pFrameView->GetViewShEditModeOnLoad(),
1050 0 : pFrameView->GetPageKindOnLoad());
1051 : pFrameView->SetPageKind(
1052 0 : pFrameView->GetPageKindOnLoad());
1053 0 : ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(mrBase));
1054 : pHelper->RequestView(
1055 : FrameworkHelper::GetViewURL(pFrameView->GetViewShellTypeOnLoad()),
1056 0 : FrameworkHelper::msCenterPaneURL);
1057 0 : pHelper->RunOnConfigurationEvent("ConfigurationUpdateEnd", CurrentPageSetter(mrBase));
1058 : }
1059 : }
1060 0 : }
1061 :
1062 0 : void ViewShellBase::Implementation::ShowViewTabBar (bool bShow)
1063 : {
1064 0 : if (mpViewTabBar.is()
1065 0 : && mpViewTabBar->GetTabControl()->IsVisible() != bShow)
1066 : {
1067 0 : mpViewTabBar->GetTabControl()->Show(bShow ? sal_True : sal_False);
1068 0 : mrBase.Rearrange();
1069 : }
1070 0 : }
1071 :
1072 689 : void ViewShellBase::Implementation::ResizePixel (
1073 : const Point& rOrigin,
1074 : const Size &rSize,
1075 : bool bOuterResize)
1076 : {
1077 689 : if (mbIsClosing)
1078 689 : return;
1079 :
1080 : // Forward the call to both the base class and the main stacked sub
1081 : // shell only when main sub shell exists.
1082 689 : ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
1083 :
1084 : // Set the ViewTabBar temporarily to full size so that, when asked
1085 : // later, it can return its true height.
1086 689 : mrBase.SetWindow (mpViewWindow.get());
1087 689 : if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1088 208 : mpViewTabBar->GetTabControl()->SetPosSizePixel (rOrigin, rSize);
1089 :
1090 : // Calculate and set the border before the controls are placed.
1091 689 : SvBorder aBorder;
1092 689 : if (pMainViewShell != NULL)
1093 689 : aBorder = pMainViewShell->GetBorder(bOuterResize);
1094 689 : aBorder += mrBase.GetBorder(bOuterResize);
1095 689 : if (mrBase.GetBorderPixel() != aBorder)
1096 33 : mrBase.SetBorderPixel(aBorder);
1097 :
1098 : // Place the ViewTabBar at the top. It is part of the border.
1099 689 : SvBorder aBaseBorder;
1100 689 : if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
1101 : {
1102 208 : aBaseBorder.Top() = mpViewTabBar->GetHeight();
1103 416 : mpViewTabBar->GetTabControl()->SetPosSizePixel(
1104 208 : rOrigin, Size(rSize.Width(),aBaseBorder.Top()));
1105 : }
1106 :
1107 : // The view window gets the remaining space.
1108 : Point aViewWindowPosition (
1109 689 : rOrigin.X()+aBaseBorder.Left(),
1110 1378 : rOrigin.Y()+aBaseBorder.Top());
1111 :
1112 : Size aViewWindowSize (
1113 689 : rSize.Width() - aBaseBorder.Left() - aBaseBorder.Right(),
1114 1378 : rSize.Height() - aBaseBorder.Top() - aBaseBorder.Bottom());
1115 689 : mpViewWindow->SetPosSizePixel(aViewWindowPosition, aViewWindowSize);
1116 :
1117 689 : maClientArea = Rectangle(Point(0,0), aViewWindowSize);
1118 : }
1119 :
1120 0 : void ViewShellBase::Implementation::SetPaneVisibility (
1121 : const SfxRequest& rRequest,
1122 : const OUString& rsPaneURL,
1123 : const OUString& rsViewURL)
1124 : {
1125 : try
1126 : {
1127 0 : Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1128 :
1129 : const Reference< XComponentContext > xContext(
1130 0 : ::comphelper::getProcessComponentContext() );
1131 : Reference<XResourceId> xPaneId (ResourceId::create(
1132 0 : xContext, rsPaneURL));
1133 : Reference<XResourceId> xViewId (ResourceId::createWithAnchorURL(
1134 0 : xContext, rsViewURL, rsPaneURL));
1135 :
1136 : // Determine the new visibility state.
1137 0 : const SfxItemSet* pArguments = rRequest.GetArgs();
1138 : bool bShowChildWindow;
1139 0 : sal_uInt16 nSlotId = rRequest.GetSlot();
1140 0 : if (pArguments != NULL)
1141 : bShowChildWindow = static_cast<const SfxBoolItem&>(
1142 0 : pArguments->Get(nSlotId)).GetValue();
1143 : else
1144 : {
1145 : Reference<XConfigurationController> xConfigurationController (
1146 0 : xControllerManager->getConfigurationController());
1147 0 : if ( ! xConfigurationController.is())
1148 0 : throw RuntimeException();
1149 : Reference<XConfiguration> xConfiguration (
1150 0 : xConfigurationController->getRequestedConfiguration());
1151 0 : if ( ! xConfiguration.is())
1152 0 : throw RuntimeException();
1153 :
1154 0 : bShowChildWindow = ! xConfiguration->hasResource(xPaneId);
1155 : }
1156 :
1157 : // Set the desired visibility state at the current configuration
1158 : // and update it accordingly.
1159 : Reference<XConfigurationController> xConfigurationController (
1160 0 : xControllerManager->getConfigurationController());
1161 0 : if ( ! xConfigurationController.is())
1162 0 : throw RuntimeException();
1163 0 : if (bShowChildWindow)
1164 : {
1165 0 : xConfigurationController->requestResourceActivation(
1166 : xPaneId,
1167 0 : ResourceActivationMode_ADD);
1168 0 : xConfigurationController->requestResourceActivation(
1169 : xViewId,
1170 0 : ResourceActivationMode_REPLACE);
1171 : }
1172 : else
1173 0 : xConfigurationController->requestResourceDeactivation(
1174 0 : xPaneId);
1175 : }
1176 0 : catch (const Exception&)
1177 : {
1178 : DBG_UNHANDLED_EXCEPTION();
1179 : }
1180 0 : }
1181 :
1182 0 : void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet)
1183 : {
1184 : try
1185 : {
1186 : // Get some frequently used values.
1187 0 : Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
1188 : Reference<XConfigurationController> xConfigurationController (
1189 0 : xControllerManager->getConfigurationController());
1190 0 : if ( ! xConfigurationController.is())
1191 0 : throw RuntimeException();
1192 : Reference<XConfiguration> xConfiguration (
1193 0 : xConfigurationController->getRequestedConfiguration());
1194 0 : if ( ! xConfiguration.is())
1195 0 : throw RuntimeException();
1196 :
1197 : const Reference< XComponentContext > xContext(
1198 0 : ::comphelper::getProcessComponentContext() );
1199 0 : SfxWhichIter aSetIterator (rSet);
1200 0 : sal_uInt16 nItemId (aSetIterator.FirstWhich());
1201 0 : while (nItemId > 0)
1202 : {
1203 0 : bool bState (false);
1204 0 : Reference<XResourceId> xResourceId;
1205 : try
1206 : {
1207 0 : switch (nItemId)
1208 : {
1209 : case SID_LEFT_PANE_IMPRESS:
1210 0 : xResourceId = ResourceId::create(
1211 0 : xContext, FrameworkHelper::msLeftImpressPaneURL);
1212 0 : break;
1213 :
1214 : case SID_LEFT_PANE_DRAW:
1215 0 : xResourceId = ResourceId::create(
1216 0 : xContext, FrameworkHelper::msLeftDrawPaneURL);
1217 0 : break;
1218 :
1219 : case SID_NORMAL_MULTI_PANE_GUI:
1220 0 : xResourceId = ResourceId::createWithAnchorURL(
1221 : xContext,
1222 : FrameworkHelper::msImpressViewURL,
1223 0 : FrameworkHelper::msCenterPaneURL);
1224 0 : break;
1225 :
1226 : case SID_SLIDE_SORTER_MULTI_PANE_GUI:
1227 : case SID_DIAMODE:
1228 0 : xResourceId = ResourceId::createWithAnchorURL(
1229 : xContext,
1230 : FrameworkHelper::msSlideSorterURL,
1231 0 : FrameworkHelper::msCenterPaneURL);
1232 0 : break;
1233 :
1234 : case SID_OUTLINEMODE:
1235 0 : xResourceId = ResourceId::createWithAnchorURL(
1236 : xContext,
1237 : FrameworkHelper::msOutlineViewURL,
1238 0 : FrameworkHelper::msCenterPaneURL);
1239 0 : break;
1240 :
1241 : case SID_HANDOUTMODE:
1242 : // There is only the master page mode for the handout
1243 : // view so ignore the master page flag.
1244 0 : xResourceId = ResourceId::createWithAnchorURL(
1245 : xContext,
1246 : FrameworkHelper::msHandoutViewURL,
1247 0 : FrameworkHelper::msCenterPaneURL);
1248 0 : break;
1249 :
1250 : case SID_NOTESMODE:
1251 0 : xResourceId = ResourceId::createWithAnchorURL(
1252 : xContext,
1253 : FrameworkHelper::msNotesViewURL,
1254 0 : FrameworkHelper::msCenterPaneURL);
1255 0 : break;
1256 :
1257 : default:
1258 : // Ignore all other items. They are not meant to be
1259 : // handled by us.
1260 0 : break;
1261 : }
1262 : }
1263 0 : catch (const DeploymentException&)
1264 : {
1265 : }
1266 :
1267 : // Determine the state for the resource.
1268 0 : bState = xConfiguration->hasResource(xResourceId);
1269 :
1270 : // Take the master page mode into account.
1271 0 : switch (nItemId)
1272 : {
1273 : case SID_NORMAL_MULTI_PANE_GUI:
1274 : case SID_NOTESMODE:
1275 : {
1276 : // Determine the master page mode.
1277 : ViewShell* pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell(
1278 0 : FrameworkHelper::msCenterPaneURL).get();
1279 0 : bool bMasterPageMode (false);
1280 0 : if (pCenterViewShell!=NULL && pCenterViewShell->ISA(DrawViewShell))
1281 0 : if (PTR_CAST(DrawViewShell,pCenterViewShell)->GetEditMode()
1282 : == EM_MASTERPAGE)
1283 : {
1284 0 : bMasterPageMode = true;
1285 : }
1286 :
1287 0 : bState &= !bMasterPageMode;
1288 0 : break;
1289 : }
1290 :
1291 : case SID_HANDOUTMODE:
1292 : // There is only the master page mode for the handout
1293 : // view so ignore the master page flag.
1294 0 : break;
1295 : }
1296 :
1297 : // And finally set the state.
1298 0 : rSet.Put(SfxBoolItem(nItemId, bState));
1299 :
1300 0 : nItemId = aSetIterator.NextWhich();
1301 0 : }
1302 : }
1303 0 : catch (const RuntimeException&)
1304 : {
1305 : DBG_UNHANDLED_EXCEPTION();
1306 : }
1307 :
1308 0 : }
1309 :
1310 : } // end of namespace sd
1311 :
1312 : //===== CurrentPageSetter ===========================================
1313 :
1314 : namespace {
1315 :
1316 0 : CurrentPageSetter::CurrentPageSetter (ViewShellBase& rBase)
1317 0 : : mrBase(rBase)
1318 : {
1319 0 : }
1320 :
1321 0 : void CurrentPageSetter::operator() (bool)
1322 : {
1323 0 : FrameView* pFrameView = NULL;
1324 :
1325 0 : if (mrBase.GetMainViewShell() != 0)
1326 : {
1327 0 : pFrameView = mrBase.GetMainViewShell()->GetFrameView();
1328 : }
1329 :
1330 0 : if (pFrameView!=NULL)
1331 : {
1332 : try
1333 : {
1334 : // Get the current page either from the DrawPagesSupplier or the
1335 : // MasterPagesSupplier.
1336 0 : Any aPage;
1337 0 : if (pFrameView->GetViewShEditModeOnLoad() == EM_PAGE)
1338 : {
1339 : Reference<drawing::XDrawPagesSupplier> xPagesSupplier (
1340 0 : mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1341 : Reference<container::XIndexAccess> xPages (
1342 0 : xPagesSupplier->getDrawPages(), UNO_QUERY_THROW);
1343 0 : aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1344 : }
1345 : else
1346 : {
1347 : Reference<drawing::XMasterPagesSupplier> xPagesSupplier (
1348 0 : mrBase.GetController()->getModel(), UNO_QUERY_THROW);
1349 : Reference<container::XIndexAccess> xPages (
1350 0 : xPagesSupplier->getMasterPages(), UNO_QUERY_THROW);
1351 0 : aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
1352 : }
1353 : // Switch to the page last edited by setting the CurrentPage
1354 : // property.
1355 0 : Reference<beans::XPropertySet> xSet (mrBase.GetController(), UNO_QUERY_THROW);
1356 0 : xSet->setPropertyValue ("CurrentPage", aPage);
1357 : }
1358 0 : catch (const RuntimeException&)
1359 : {
1360 : // We have not been able to set the current page at the main view.
1361 : // This is sad but still leaves us in a valid state. Therefore,
1362 : // this exception is silently ignored.
1363 : }
1364 0 : catch (const beans::UnknownPropertyException&)
1365 : {
1366 : DBG_ASSERT(false,"CurrentPage property unknown");
1367 : }
1368 : }
1369 0 : }
1370 :
1371 : } // end of anonymouse namespace
1372 :
1373 : //===== FocusForwardingWindow =================================================
1374 :
1375 : namespace sd { namespace {
1376 :
1377 212 : FocusForwardingWindow::FocusForwardingWindow (
1378 : vcl::Window& rParentWindow,
1379 : ViewShellBase& rBase)
1380 : : vcl::Window(&rParentWindow, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
1381 212 : mrBase(rBase)
1382 : {
1383 : OSL_TRACE("created FocusForwardingWindow at %x", this);
1384 212 : }
1385 :
1386 424 : FocusForwardingWindow::~FocusForwardingWindow (void)
1387 : {
1388 : OSL_TRACE("destroyed FocusForwardingWindow at %x", this);
1389 424 : }
1390 :
1391 0 : void FocusForwardingWindow::KeyInput (const KeyEvent& rKEvt)
1392 : {
1393 0 : ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1394 0 : if (pViewShell.get() != NULL)
1395 : {
1396 0 : vcl::Window* pWindow = pViewShell->GetActiveWindow();
1397 0 : if (pWindow != NULL)
1398 : {
1399 : // Forward the focus so that the window is called directly the
1400 : // next time.
1401 0 : pWindow->GrabFocus();
1402 : // Forward the key press as well.
1403 0 : pWindow->KeyInput(rKEvt);
1404 : }
1405 0 : }
1406 0 : }
1407 :
1408 0 : void FocusForwardingWindow::Command (const CommandEvent& rEvent)
1409 : {
1410 0 : ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
1411 0 : if (pViewShell.get() != NULL)
1412 : {
1413 0 : vcl::Window* pWindow = pViewShell->GetActiveWindow();
1414 0 : if (pWindow != NULL)
1415 : {
1416 0 : pWindow->Command(rEvent);
1417 : }
1418 0 : }
1419 0 : }
1420 :
1421 : } // end of anonymouse namespace
1422 :
1423 114 : } // end of namespace sd
1424 :
1425 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|