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