LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/view - drviewsd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 90 38.9 %
Date: 2013-07-09 Functions: 4 4 100.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 "DrawViewShell.hxx"
      22             : 
      23             : #include <svx/svxids.hrc>
      24             : #include <svl/aeitem.hxx>
      25             : #include <svl/stritem.hxx>
      26             : #include <sfx2/docfile.hxx>
      27             : #include <svl/intitem.hxx>
      28             : #include <sfx2/bindings.hxx>
      29             : #include <sfx2/dispatch.hxx>
      30             : #include <sfx2/request.hxx>
      31             : 
      32             : #include <sfx2/viewfrm.hxx>
      33             : 
      34             : 
      35             : #include "app.hrc"
      36             : 
      37             : #include "sdpage.hxx"
      38             : #include "drawdoc.hxx"
      39             : #include "DrawDocShell.hxx"
      40             : #include "slideshow.hxx"
      41             : #include "pgjump.hxx"
      42             : #include "NavigatorChildWindow.hxx"
      43             : #include "navigatr.hxx"
      44             : #include "drawview.hxx"
      45             : 
      46             : namespace sd {
      47             : 
      48             : /**
      49             :  * handle SfxRequests for navigator
      50             :  */
      51         131 : void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
      52             : {
      53         131 :     CheckLineTo (rReq);
      54             : 
      55         131 :     sal_uInt16 nSId = rReq.GetSlot();
      56             : 
      57         131 :     switch( nSId )
      58             :     {
      59             :         case SID_NAVIGATOR_INIT:
      60             :         {
      61         131 :             sal_uInt16 nId = SID_NAVIGATOR;
      62         131 :             SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
      63         131 :             if( pWindow )
      64             :             {
      65           0 :                 SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
      66           0 :                 if( pNavWin )
      67           0 :                     pNavWin->InitTreeLB( GetDoc() );
      68             :             }
      69             :         }
      70         131 :         break;
      71             : 
      72             :         case SID_NAVIGATOR_PEN:
      73             :         case SID_NAVIGATOR_PAGE:
      74             :         case SID_NAVIGATOR_OBJECT:
      75             :         {
      76           0 :             rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
      77           0 :             if (xSlideshow.is() && xSlideshow->isRunning() )
      78             :             {
      79           0 :                 xSlideshow->receiveRequest( rReq );
      80             :             }
      81           0 :             else if (nSId == SID_NAVIGATOR_PAGE)
      82             :             {
      83           0 :                 if ( mpDrawView->IsTextEdit() )
      84           0 :                     mpDrawView->SdrEndTextEdit();
      85             : 
      86           0 :                 const SfxItemSet* pArgs = rReq.GetArgs();
      87             :                 PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->
      88           0 :                                   Get(SID_NAVIGATOR_PAGE)).GetValue();
      89             : 
      90           0 :                 switch (eJump)
      91             :                 {
      92             :                     case PAGE_FIRST:
      93             :                     {
      94             :                         // jump to first page
      95           0 :                         SwitchPage(0);
      96             :                     }
      97           0 :                     break;
      98             : 
      99             :                     case PAGE_LAST:
     100             :                     {
     101             :                         // jumpt to last page
     102           0 :                         SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
     103             :                     }
     104           0 :                     break;
     105             : 
     106             :                     case PAGE_NEXT:
     107             :                     {
     108             :                         // jump to next page
     109           0 :                         sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
     110             : 
     111           0 :                         if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
     112             :                         {
     113           0 :                             SwitchPage(nSdPage + 1);
     114             :                         }
     115             :                     }
     116           0 :                     break;
     117             : 
     118             :                     case PAGE_PREVIOUS:
     119             :                     {
     120             :                         // jump to previous page
     121           0 :                         sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
     122             : 
     123           0 :                         if (nSdPage > 0)
     124             :                         {
     125           0 :                             SwitchPage(nSdPage - 1);
     126             :                         }
     127             :                     }
     128           0 :                     break;
     129             : 
     130             :                     case PAGE_NONE:
     131           0 :                         break;
     132             :                 }
     133             :             }
     134           0 :             else if (nSId == SID_NAVIGATOR_OBJECT)
     135             :             {
     136           0 :                 String aBookmarkStr;
     137           0 :                 aBookmarkStr += sal_Unicode( '#' );
     138           0 :                 const SfxItemSet* pArgs = rReq.GetArgs();
     139             :                 String aTarget = ((SfxStringItem&) pArgs->
     140           0 :                                  Get(SID_NAVIGATOR_OBJECT)).GetValue();
     141           0 :                 aBookmarkStr += aTarget;
     142           0 :                 SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
     143           0 :                 SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
     144           0 :                 SfxViewFrame* pFrame = GetViewFrame();
     145           0 :                 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
     146           0 :                 SfxBoolItem aBrowseItem(SID_BROWSE, sal_True);
     147             :                 pFrame->GetDispatcher()->
     148             :                 Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
     149           0 :                             &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
     150             :             }
     151             : 
     152           0 :             SfxBindings& rBindings = GetViewFrame()->GetBindings();
     153           0 :             rBindings.Invalidate( SID_NAVIGATOR_STATE );
     154           0 :             rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
     155             :         }
     156           0 :         break;
     157             : 
     158             :         default:
     159           0 :         break;
     160             :     }
     161         131 : }
     162             : 
     163             : 
     164         131 : void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
     165             : {
     166         131 :     sal_uInt32 nState = NAVSTATE_NONE;
     167         131 :     sal_uInt16 nCurrentPage = 0;
     168         131 :     sal_uInt16 nFirstPage = 0;
     169             :     sal_uInt16 nLastPage;
     170         131 :     sal_Bool   bEndless = sal_False;
     171         131 :     String aPageName;
     172             : 
     173         262 :     rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
     174         131 :     if( xSlideshow.is() && xSlideshow->isRunning() )
     175             :     {
     176             :         // pen activated?
     177           0 :         nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
     178             : 
     179           0 :         nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
     180           0 :         nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
     181           0 :         nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
     182           0 :         bEndless = xSlideshow->isEndless();
     183             : 
     184             :         // Get the page for the current page number.
     185           0 :         SdPage* pPage = 0;
     186           0 :         if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
     187           0 :             pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
     188             : 
     189           0 :         if(pPage)
     190           0 :             aPageName = pPage->GetName();
     191             :     }
     192             :     else
     193             :     {
     194         131 :         nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
     195             : 
     196         131 :         if (mpActualPage != NULL)
     197             :         {
     198         131 :             nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
     199         131 :             aPageName = mpActualPage->GetName();
     200             :         }
     201         131 :         nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
     202             :     }
     203             : 
     204             :     // first page / previous page
     205         131 :     if( nCurrentPage == nFirstPage )
     206             :     {
     207         131 :         nState |= NAVBTN_FIRST_DISABLED;
     208         131 :         if( !bEndless )
     209         131 :             nState |= NAVBTN_PREV_DISABLED;
     210             :         else
     211           0 :             nState |= NAVBTN_PREV_ENABLED;
     212             :     }
     213             :     else
     214             :     {
     215           0 :         nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
     216             :     }
     217             : 
     218             :     // last page / next page
     219         131 :     if( nCurrentPage == nLastPage )
     220             :     {
     221         127 :         nState |= NAVBTN_LAST_DISABLED;
     222         127 :         if( !bEndless )
     223         127 :             nState |= NAVBTN_NEXT_DISABLED;
     224             :         else
     225           0 :             nState |= NAVBTN_NEXT_ENABLED;
     226             :     }
     227             :     else
     228             :     {
     229           4 :         nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
     230             :     }
     231             : 
     232         131 :     rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
     233         262 :     rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
     234         131 : }
     235             : 
     236          33 : } // end of namespace sd
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10