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