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

Generated by: LCOV version 1.10