LCOV - code coverage report
Current view: top level - sd/source/ui/view - ViewShellImplementation.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 150 0.0 %
Date: 2014-04-14 Functions: 0 15 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             : 
      21             : #include "ViewShellImplementation.hxx"
      22             : 
      23             : #include "sdpage.hxx"
      24             : #include "drawdoc.hxx"
      25             : #include "sdresid.hxx"
      26             : #include "glob.hrc"
      27             : #include "app.hrc"
      28             : #include "strings.hrc"
      29             : #include "helpids.h"
      30             : #include "sdattr.hxx"
      31             : #include "sdabstdlg.hxx"
      32             : #include "unmodpg.hxx"
      33             : #include "Window.hxx"
      34             : #include "optsitem.hxx"
      35             : #include "DrawDocShell.hxx"
      36             : #include "DrawController.hxx"
      37             : #include "FactoryIds.hxx"
      38             : #include "slideshow.hxx"
      39             : #include "ViewShellBase.hxx"
      40             : #include "FrameView.hxx"
      41             : #include "DrawViewShell.hxx"
      42             : #include "ViewShellHint.hxx"
      43             : #include "SidebarPanelId.hxx"
      44             : #include "framework/FrameworkHelper.hxx"
      45             : 
      46             : #include <sfx2/bindings.hxx>
      47             : #include <sfx2/dispatch.hxx>
      48             : #include <sfx2/request.hxx>
      49             : #include <sfx2/sidebar/Sidebar.hxx>
      50             : #include <svl/aeitem.hxx>
      51             : #include <svx/imapdlg.hxx>
      52             : #include <vcl/msgbox.hxx>
      53             : #include <basic/sbstar.hxx>
      54             : #include "undo/undoobjects.hxx"
      55             : 
      56             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      57             : 
      58             : using namespace ::com::sun::star::uno;
      59             : using namespace ::com::sun::star::drawing::framework;
      60             : using ::sd::framework::FrameworkHelper;
      61             : 
      62             : namespace sd {
      63             : 
      64           0 : ViewShell::Implementation::Implementation (ViewShell& rViewShell)
      65             :     : mbIsShowingUIControls(false),
      66             :       mbIsMainViewShell(false),
      67             :       mbIsInitialized(false),
      68             :       mbArrangeActive(false),
      69             :       mpSubShellFactory(),
      70             :       mpUpdateLockForMouse(),
      71           0 :       mrViewShell(rViewShell)
      72             : {
      73           0 : }
      74             : 
      75             : 
      76             : 
      77             : 
      78           0 : ViewShell::Implementation::~Implementation (void)
      79             : {
      80           0 :     if ( ! mpUpdateLockForMouse.expired())
      81             :     {
      82           0 :         ::boost::shared_ptr<ToolBarManagerLock> pLock(mpUpdateLockForMouse);
      83           0 :         if (pLock.get() != NULL)
      84             :         {
      85             :             // Force the ToolBarManagerLock to be released even when the
      86             :             // IsUICaptured() returns <TRUE/>.
      87           0 :             pLock->Release(true);
      88           0 :         }
      89             :     }
      90           0 : }
      91             : 
      92             : 
      93             : 
      94             : 
      95           0 : void ViewShell::Implementation::ProcessModifyPageSlot (
      96             :     SfxRequest& rRequest,
      97             :     SdPage* pCurrentPage,
      98             :     PageKind ePageKind)
      99             : {
     100           0 :     SdDrawDocument* pDocument = mrViewShell.GetDoc();
     101           0 :     SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
     102           0 :     sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false);
     103           0 :     sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false);
     104           0 :     SetOfByte aVisibleLayers;
     105           0 :     sal_Bool bHandoutMode = sal_False;
     106           0 :     SdPage* pHandoutMPage = NULL;
     107           0 :     OUString aNewName;
     108             : 
     109             :     AutoLayout aNewAutoLayout;
     110             : 
     111             :     sal_Bool bBVisible;
     112             :     sal_Bool bBObjsVisible;
     113           0 :     const SfxItemSet* pArgs = rRequest.GetArgs();
     114             : 
     115           0 :     if (pCurrentPage != NULL && pCurrentPage->TRG_HasMasterPage())
     116           0 :         aVisibleLayers = pCurrentPage->TRG_GetMasterPageVisibleLayers();
     117             :     else
     118           0 :         aVisibleLayers.SetAll();
     119             : 
     120             :     do
     121             :     {
     122           0 :         if (pCurrentPage == NULL)
     123           0 :             break;
     124             : 
     125           0 :         if (!pArgs || pArgs->Count() == 1 || pArgs->Count() == 2 )
     126             :         {
     127             : 
     128             :             // Make the layout menu visible in the tool pane.
     129             :             sfx2::sidebar::Sidebar::ShowPanel(
     130             :                 OUString("ImpressLayoutsPanel"),
     131           0 :                 mrViewShell.GetViewFrame()->GetFrame().GetFrameInterface());
     132           0 :             break;
     133             :         }
     134           0 :         else if (pArgs->Count() == 4)
     135             :         {
     136           0 :             SFX_REQUEST_ARG (rRequest, pNewName, SfxStringItem, ID_VAL_PAGENAME, false);
     137           0 :             SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, false);
     138           0 :             SFX_REQUEST_ARG (rRequest, pBVisible, SfxBoolItem, ID_VAL_ISPAGEBACK, false);
     139           0 :             SFX_REQUEST_ARG (rRequest, pBObjsVisible, SfxBoolItem, ID_VAL_ISPAGEOBJ, false);
     140           0 :             AutoLayout aLayout ((AutoLayout)pNewAutoLayout->GetValue ());
     141           0 :             if (aLayout >= AUTOLAYOUT__START
     142           0 :                 && aLayout < AUTOLAYOUT__END)
     143             :             {
     144           0 :                 aNewName        = pNewName->GetValue ();
     145           0 :                 aNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue ();
     146           0 :                 bBVisible       = pBVisible->GetValue ();
     147           0 :                 bBObjsVisible   = pBObjsVisible->GetValue ();
     148             :             }
     149             :             else
     150             :             {
     151             : #ifndef DISABLE_SCRIPTING
     152           0 :                 StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
     153             : #endif
     154           0 :                 rRequest.Ignore ();
     155           0 :                 break;
     156             :             }
     157           0 :             if (ePageKind == PK_HANDOUT)
     158             :             {
     159           0 :                 bHandoutMode = sal_True;
     160           0 :                 pHandoutMPage = pDocument->GetMasterSdPage(0, PK_HANDOUT);
     161             :             }
     162             :         }
     163             :         else
     164             :         {
     165             : #ifndef DISABLE_SCRIPTING
     166           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     167             : #endif
     168           0 :             rRequest.Ignore ();
     169           0 :             break;
     170             :         }
     171             : 
     172             :         SdPage* pUndoPage =
     173           0 :             bHandoutMode ? pHandoutMPage : pCurrentPage;
     174             : 
     175           0 :         ::svl::IUndoManager* pUndoManager = mrViewShell.GetDocSh()->GetUndoManager();
     176             :         DBG_ASSERT(pUndoManager, "No UNDO MANAGER ?!?");
     177             : 
     178           0 :         if( pUndoManager )
     179             :         {
     180           0 :             OUString aComment( SdResId(STR_UNDO_MODIFY_PAGE) );
     181           0 :             pUndoManager->EnterListAction(aComment, aComment);
     182             :             ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
     183           0 :                 pDocument, pUndoPage, aNewName, aNewAutoLayout, bBVisible, bBObjsVisible);
     184           0 :             pUndoManager->AddUndoAction(pAction);
     185             : 
     186             :             // Clear the selection because the selected object may be removed as
     187             :             // a result of the assignment of the layout.
     188           0 :             mrViewShell.GetDrawView()->UnmarkAll();
     189             : 
     190           0 :             if (!bHandoutMode)
     191             :             {
     192           0 :                 if (pCurrentPage->GetName() != aNewName)
     193             :                 {
     194           0 :                     pCurrentPage->SetName(aNewName);
     195             : 
     196           0 :                     if (ePageKind == PK_STANDARD)
     197             :                     {
     198           0 :                         sal_uInt16 nPage = (pCurrentPage->GetPageNum()-1) / 2;
     199           0 :                         SdPage* pNotesPage = pDocument->GetSdPage(nPage, PK_NOTES);
     200           0 :                         if (pNotesPage != NULL)
     201           0 :                             pNotesPage->SetName(aNewName);
     202             :                     }
     203             :                 }
     204             : 
     205           0 :                 pCurrentPage->SetAutoLayout(aNewAutoLayout, sal_True);
     206             : 
     207           0 :                 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false);
     208           0 :                 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false);
     209           0 :                 aVisibleLayers.Set(aBckgrnd, bBVisible);
     210           0 :                 aVisibleLayers.Set(aBckgrndObj, bBObjsVisible);
     211           0 :                 pCurrentPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
     212             :             }
     213             :             else
     214             :             {
     215           0 :                 pHandoutMPage->SetAutoLayout(aNewAutoLayout, sal_True);
     216             :             }
     217             : 
     218             :             mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
     219           0 :                 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     220             : 
     221           0 :             sal_Bool bSetModified = sal_True;
     222             : 
     223           0 :             if (pArgs && pArgs->Count() == 1)
     224             :             {
     225           0 :                 bSetModified = (sal_Bool) ((SfxBoolItem&) pArgs->Get(SID_MODIFYPAGE)).GetValue();
     226             :             }
     227             : 
     228           0 :             pUndoManager->AddUndoAction( new UndoAutoLayoutPosAndSize( *pUndoPage ) );
     229           0 :             pUndoManager->LeaveListAction();
     230             : 
     231           0 :             pDocument->SetChanged(bSetModified);
     232             :         }
     233             :     }
     234             :     while (false);
     235             : 
     236           0 :     mrViewShell.Cancel();
     237           0 :     rRequest.Done ();
     238           0 : }
     239             : 
     240           0 : void ViewShell::Implementation::AssignLayout ( SfxRequest& rRequest, PageKind ePageKind )
     241             : {
     242           0 :     const SfxUInt32Item* pWhatPage = static_cast< const SfxUInt32Item*  > ( rRequest.GetArg( ID_VAL_WHATPAGE, false, TYPE(SfxUInt32Item) ) );
     243           0 :     const SfxUInt32Item* pWhatLayout = static_cast< const SfxUInt32Item*  > ( rRequest.GetArg( ID_VAL_WHATLAYOUT, false, TYPE(SfxUInt32Item) ) );
     244             : 
     245           0 :     SdDrawDocument* pDocument = mrViewShell.GetDoc();
     246           0 :     if( !pDocument )
     247           0 :         return;
     248             : 
     249           0 :     SdPage* pPage = 0;
     250           0 :     if( pWhatPage )
     251             :     {
     252           0 :         pPage = pDocument->GetSdPage(static_cast<sal_uInt16>(pWhatPage->GetValue()), ePageKind);
     253             :     }
     254             : 
     255           0 :     if( pPage == 0 )
     256           0 :         pPage = mrViewShell.getCurrentPage();
     257             : 
     258           0 :     if( pPage )
     259             :     {
     260           0 :         AutoLayout eLayout = pPage->GetAutoLayout();
     261             : 
     262           0 :         if( pWhatLayout )
     263           0 :             eLayout = static_cast< AutoLayout >( pWhatLayout->GetValue() );
     264             : 
     265             :         // Transform the given request into the four argument form that is
     266             :         // understood by ProcessModifyPageSlot().
     267           0 :         SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin());
     268           0 :         sal_uInt8 aBackground (rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false));
     269           0 :         sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false));
     270             : 
     271           0 :         SetOfByte aVisibleLayers;
     272             : 
     273           0 :         if( pPage->GetPageKind() == PK_HANDOUT )
     274           0 :             aVisibleLayers.SetAll();
     275             :         else
     276           0 :             aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
     277             : 
     278           0 :         SfxRequest aRequest (mrViewShell.GetViewShellBase().GetViewFrame(), SID_MODIFYPAGE);
     279           0 :         aRequest.AppendItem(SfxStringItem (ID_VAL_PAGENAME, pPage->GetName()));
     280           0 :         aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, eLayout));
     281           0 :         aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground)));
     282           0 :         aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEOBJ, aVisibleLayers.IsSet(aBackgroundObject)));
     283             : 
     284             :         // Forward the call with the new arguments.
     285           0 :         ProcessModifyPageSlot( aRequest, pPage, pPage->GetPageKind());
     286             :     }
     287             : }
     288             : 
     289             : 
     290             : 
     291             : 
     292           0 : sal_uInt16 ViewShell::Implementation::GetViewId (void)
     293             : {
     294           0 :     switch (mrViewShell.GetShellType())
     295             :     {
     296             :         case ViewShell::ST_IMPRESS:
     297             :         case ViewShell::ST_NOTES:
     298             :         case ViewShell::ST_HANDOUT:
     299           0 :             return IMPRESS_FACTORY_ID;
     300             : 
     301             :         case ViewShell::ST_DRAW:
     302           0 :             return DRAW_FACTORY_ID;
     303             : 
     304             :         case ViewShell::ST_OUTLINE:
     305           0 :             return OUTLINE_FACTORY_ID;
     306             : 
     307             :         case ViewShell::ST_SLIDE_SORTER:
     308           0 :             return SLIDE_SORTER_FACTORY_ID;
     309             : 
     310             :         case ViewShell::ST_PRESENTATION:
     311           0 :             return PRESENTATION_FACTORY_ID;
     312             : 
     313             :         // Since we have to return a view id for every possible shell type
     314             :         // and there is not (yet) a proper ViewShellBase sub class for the
     315             :         // remaining types we chose the Impress factory as a fall back.
     316             :         case ViewShell::ST_SIDEBAR:
     317             :         case ViewShell::ST_NONE:
     318             :         default:
     319           0 :             return IMPRESS_FACTORY_ID;
     320             :     }
     321             : }
     322             : 
     323             : 
     324             : 
     325             : 
     326           0 : SvxIMapDlg* ViewShell::Implementation::GetImageMapDialog (void)
     327             : {
     328           0 :     SvxIMapDlg* pDialog = NULL;
     329             :     SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow(
     330           0 :         SvxIMapDlgChildWindow::GetChildWindowId());
     331           0 :     if (pChildWindow != NULL)
     332           0 :         pDialog = dynamic_cast<SvxIMapDlg*>(pChildWindow->GetWindow());
     333           0 :     return pDialog;
     334             : }
     335             : 
     336             : 
     337             : 
     338             : //===== ToolBarManagerLock ====================================================
     339             : 
     340             : class ViewShell::Implementation::ToolBarManagerLock::Deleter { public:
     341           0 :     void operator() (ToolBarManagerLock* pObject) { delete pObject; }
     342             : };
     343             : 
     344             : ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock>
     345           0 :     ViewShell::Implementation::ToolBarManagerLock::Create (
     346             :         const ::boost::shared_ptr<ToolBarManager>& rpManager)
     347             : {
     348             :     ::boost::shared_ptr<ToolBarManagerLock> pLock (
     349           0 :         new ViewShell::Implementation::ToolBarManagerLock(rpManager),
     350           0 :         ViewShell::Implementation::ToolBarManagerLock::Deleter());
     351           0 :     pLock->mpSelf = pLock;
     352           0 :     return pLock;
     353             : }
     354             : 
     355             : 
     356             : 
     357             : 
     358           0 : ViewShell::Implementation::ToolBarManagerLock::ToolBarManagerLock (
     359             :     const ::boost::shared_ptr<ToolBarManager>& rpManager)
     360           0 :     : mpLock(new ToolBarManager::UpdateLock(rpManager)),
     361           0 :       maTimer()
     362             : {
     363             :     // Start a timer that will unlock the ToolBarManager update lock when
     364             :     // that is not done explicitly by calling Release().
     365           0 :     maTimer.SetTimeoutHdl(LINK(this,ToolBarManagerLock,TimeoutCallback));
     366           0 :     maTimer.SetTimeout(100);
     367           0 :     maTimer.Start();
     368           0 : }
     369             : 
     370             : 
     371             : 
     372             : 
     373           0 : IMPL_LINK_NOARG(ViewShell::Implementation::ToolBarManagerLock, TimeoutCallback)
     374             : {
     375             :     // If possible then release the lock now.  Otherwise start the timer
     376             :     // and try again later.
     377           0 :     if (Application::IsUICaptured())
     378             :     {
     379           0 :         maTimer.Start();
     380             :     }
     381             :     else
     382             :     {
     383           0 :         mpSelf.reset();
     384             :     }
     385           0 :     return 0;
     386             : }
     387             : 
     388             : 
     389             : 
     390             : 
     391           0 : void ViewShell::Implementation::ToolBarManagerLock::Release (bool bForce)
     392             : {
     393             :     // If possible then release the lock now.  Otherwise try again when the
     394             :     // timer expires.
     395           0 :     if (bForce || ! Application::IsUICaptured())
     396             :     {
     397           0 :         mpSelf.reset();
     398             :     }
     399           0 : }
     400             : 
     401             : 
     402             : 
     403             : 
     404           0 : ViewShell::Implementation::ToolBarManagerLock::~ToolBarManagerLock (void)
     405             : {
     406           0 :     mpLock.reset();
     407           0 : }
     408             : 
     409           0 : } // end of namespace sd
     410             : 
     411             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10