LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/view - ViewShellBase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 565 0.4 %
Date: 2012-12-27 Functions: 3 75 4.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10