LCOV - code coverage report
Current view: top level - sw/source/core/uibase/shells - navsh.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 22 45 48.9 %
Date: 2014-04-11 Functions: 6 7 85.7 %
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             : 
      10             : #include "cmdid.h"
      11             : #include <svx/svdview.hxx>
      12             : #include <svl/srchitem.hxx>
      13             : #include <svl/eitem.hxx>
      14             : #include <svl/whiter.hxx>
      15             : #include <svx/svdopath.hxx>
      16             : #include <sfx2/request.hxx>
      17             : #include <sfx2/dispatch.hxx>
      18             : #include <sfx2/objface.hxx>
      19             : #include "wrtsh.hxx"
      20             : #include "view.hxx"
      21             : #include "edtwin.hxx"
      22             : #include "helpid.h"
      23             : #include "globals.hrc"
      24             : #include "navsh.hxx"
      25             : #include "popup.hrc"
      26             : #include "shells.hrc"
      27             : #define SwNavigationShell
      28             : #include "swslots.hxx"
      29             : #include <unomid.h>
      30             : #include "navmgr.hxx"
      31             : 
      32       68575 : SFX_IMPL_INTERFACE(SwNavigationShell, SwBaseShell, SW_RES(STR_SHELLNAME_NAVIGATION))
      33             : {
      34          37 : }
      35             : 
      36        1747 : SwNavigationShell::SwNavigationShell(SwView &_rView):
      37        1747 :   SwBaseShell( _rView )
      38             : 
      39             : {
      40        1747 :   SetName(OUString("Navigation"));
      41        1747 :   SetHelpId(SW_NAVIGATIONSHELL);
      42        1747 : }
      43             : 
      44           0 : void SwNavigationShell::Execute(SfxRequest &rReq)
      45             : {
      46           0 :     SwWrtShell *pSh = &GetShell();
      47           0 :     SdrView*    pSdrView = pSh->GetDrawView();
      48           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
      49           0 :     sal_uInt16      nSlotId = rReq.GetSlot();
      50           0 :     sal_Bool        bChanged = pSdrView->GetModel()->IsChanged();
      51           0 :     pSdrView->GetModel()->SetChanged(false);
      52           0 :     SwNavigationMgr& aSwNavigationMgr = pSh->GetNavigationMgr();
      53             :     const SfxPoolItem* pItem;
      54           0 :     if(pArgs)
      55           0 :         pArgs->GetItemState(nSlotId, false, &pItem);
      56           0 :     switch (nSlotId)
      57             :         {
      58             :         case FN_NAVIGATION_BACK:
      59           0 :             aSwNavigationMgr.goBack();
      60           0 :             break;
      61             : 
      62             :         case FN_NAVIGATION_FORWARD:
      63           0 :             aSwNavigationMgr.goForward();
      64           0 :             break;
      65             :         default:
      66           0 :             break;
      67             :         }
      68           0 :     if (pSdrView->GetModel()->IsChanged())
      69           0 :         GetShell().SetModified();
      70           0 :     else if (bChanged)
      71           0 :         pSdrView->GetModel()->SetChanged(true);
      72           0 : }
      73             : 
      74             : // determine if the buttons should be enabled/disabled
      75             : 
      76           2 : void SwNavigationShell::GetState(SfxItemSet &rSet)
      77             : {
      78           2 :   SwWrtShell *pSh = &GetShell();
      79           2 :   SfxWhichIter aIter( rSet );
      80           2 :   sal_uInt16 nWhich = aIter.FirstWhich();
      81           2 :   SwNavigationMgr& aNavigationMgr = pSh->GetNavigationMgr();
      82           6 :   while( nWhich )
      83             :     {
      84           2 :       switch( nWhich )
      85             :     {
      86             :     case FN_NAVIGATION_BACK:
      87             :       {
      88           1 :         if (!aNavigationMgr.backEnabled()) {
      89           0 :           rSet.DisableItem(FN_NAVIGATION_BACK);
      90             :         }
      91             :       }
      92           1 :       break;
      93             :     case FN_NAVIGATION_FORWARD:
      94             :       {
      95           1 :         if (!aNavigationMgr.forwardEnabled())
      96           1 :           rSet.DisableItem(FN_NAVIGATION_FORWARD);
      97             :       }
      98           1 :       break;
      99             :     default:
     100           0 :       break;
     101             :     }
     102           2 :       nWhich = aIter.NextWhich();
     103           2 :     }
     104           2 : }
     105             : 
     106             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10