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

Generated by: LCOV version 1.11