1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "DrawViewShell.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #ifndef _SVXIDS_HRC 30cdf0e10cSrcweir #include <svx/svxids.hrc> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #include <svl/aeitem.hxx> 33cdf0e10cSrcweir #include <svl/stritem.hxx> 34cdf0e10cSrcweir #include <sfx2/docfile.hxx> 35cdf0e10cSrcweir #include <svl/intitem.hxx> 36cdf0e10cSrcweir #include <sfx2/bindings.hxx> 37cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 38cdf0e10cSrcweir #include <sfx2/request.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include "app.hrc" 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include "sdpage.hxx" 46cdf0e10cSrcweir #include "drawdoc.hxx" 47cdf0e10cSrcweir #include "DrawDocShell.hxx" 48cdf0e10cSrcweir #include "slideshow.hxx" 49cdf0e10cSrcweir #include "pgjump.hxx" 50cdf0e10cSrcweir #include "NavigatorChildWindow.hxx" 51cdf0e10cSrcweir #ifndef SD_NAVIGATION_HXX 52cdf0e10cSrcweir #include "navigatr.hxx" 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir #include "drawview.hxx" 55cdf0e10cSrcweir #include "slideshow.hxx" 56cdf0e10cSrcweir 57cdf0e10cSrcweir namespace sd { 58cdf0e10cSrcweir 59cdf0e10cSrcweir /************************************************************************* 60cdf0e10cSrcweir |* 61cdf0e10cSrcweir |* SfxRequests fuer Navigator bearbeiten 62cdf0e10cSrcweir |* 63cdf0e10cSrcweir \************************************************************************/ 64cdf0e10cSrcweir 65cdf0e10cSrcweir void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq ) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir CheckLineTo (rReq); 68cdf0e10cSrcweir 69cdf0e10cSrcweir sal_uInt16 nSId = rReq.GetSlot(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir switch( nSId ) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir case SID_NAVIGATOR_INIT: 74cdf0e10cSrcweir { 75cdf0e10cSrcweir sal_uInt16 nId = SID_NAVIGATOR; 76cdf0e10cSrcweir SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId ); 77cdf0e10cSrcweir if( pWindow ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) ); 80cdf0e10cSrcweir if( pNavWin ) 81cdf0e10cSrcweir pNavWin->InitTreeLB( GetDoc() ); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir } 84cdf0e10cSrcweir break; 85cdf0e10cSrcweir 86cdf0e10cSrcweir case SID_NAVIGATOR_PEN: 87cdf0e10cSrcweir case SID_NAVIGATOR_PAGE: 88cdf0e10cSrcweir case SID_NAVIGATOR_OBJECT: 89cdf0e10cSrcweir { 90cdf0e10cSrcweir rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) ); 91cdf0e10cSrcweir if (xSlideshow.is() && xSlideshow->isRunning() ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir xSlideshow->receiveRequest( rReq ); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir else if (nSId == SID_NAVIGATOR_PAGE) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir if ( mpDrawView->IsTextEdit() ) 98cdf0e10cSrcweir mpDrawView->SdrEndTextEdit(); 99cdf0e10cSrcweir 100cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 101cdf0e10cSrcweir PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs-> 102cdf0e10cSrcweir Get(SID_NAVIGATOR_PAGE)).GetValue(); 103cdf0e10cSrcweir 104cdf0e10cSrcweir switch (eJump) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir case PAGE_FIRST: 107cdf0e10cSrcweir { 108cdf0e10cSrcweir // Sprung zu erster Seite 109cdf0e10cSrcweir SwitchPage(0); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir break; 112cdf0e10cSrcweir 113cdf0e10cSrcweir case PAGE_LAST: 114cdf0e10cSrcweir { 115cdf0e10cSrcweir // Sprung zu letzter Seite 116cdf0e10cSrcweir SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir break; 119cdf0e10cSrcweir 120cdf0e10cSrcweir case PAGE_NEXT: 121cdf0e10cSrcweir { 122cdf0e10cSrcweir // Sprung zu naechster Seite 123cdf0e10cSrcweir sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2; 124cdf0e10cSrcweir 125cdf0e10cSrcweir if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir SwitchPage(nSdPage + 1); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir } 130cdf0e10cSrcweir break; 131cdf0e10cSrcweir 132cdf0e10cSrcweir case PAGE_PREVIOUS: 133cdf0e10cSrcweir { 134cdf0e10cSrcweir // Sprung zu vorheriger Seite 135cdf0e10cSrcweir sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2; 136cdf0e10cSrcweir 137cdf0e10cSrcweir if (nSdPage > 0) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir SwitchPage(nSdPage - 1); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir break; 143cdf0e10cSrcweir 144cdf0e10cSrcweir case PAGE_NONE: 145cdf0e10cSrcweir break; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir else if (nSId == SID_NAVIGATOR_OBJECT) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir String aBookmarkStr; 151cdf0e10cSrcweir aBookmarkStr += sal_Unicode( '#' ); 152cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 153cdf0e10cSrcweir String aTarget = ((SfxStringItem&) pArgs-> 154cdf0e10cSrcweir Get(SID_NAVIGATOR_OBJECT)).GetValue(); 155cdf0e10cSrcweir aBookmarkStr += aTarget; 156cdf0e10cSrcweir SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr); 157cdf0e10cSrcweir SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName()); 158cdf0e10cSrcweir SfxViewFrame* pFrame = GetViewFrame(); 159cdf0e10cSrcweir SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame); 160cdf0e10cSrcweir SfxBoolItem aBrowseItem(SID_BROWSE, sal_True); 161cdf0e10cSrcweir pFrame->GetDispatcher()-> 162cdf0e10cSrcweir Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 163cdf0e10cSrcweir &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir SfxBindings& rBindings = GetViewFrame()->GetBindings(); 167cdf0e10cSrcweir rBindings.Invalidate( SID_NAVIGATOR_STATE ); 168cdf0e10cSrcweir rBindings.Invalidate( SID_NAVIGATOR_PAGENAME ); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir break; 171cdf0e10cSrcweir 172cdf0e10cSrcweir default: 173cdf0e10cSrcweir break; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir /************************************************************************* 178cdf0e10cSrcweir |* 179cdf0e10cSrcweir |* Statuswerte fuer Navigator zurueckgeben 180cdf0e10cSrcweir |* 181cdf0e10cSrcweir \************************************************************************/ 182cdf0e10cSrcweir 183cdf0e10cSrcweir void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir sal_uInt32 nState = NAVSTATE_NONE; 186cdf0e10cSrcweir sal_uInt16 nCurrentPage = 0; 187cdf0e10cSrcweir sal_uInt16 nFirstPage = 0; 188cdf0e10cSrcweir sal_uInt16 nLastPage; 189cdf0e10cSrcweir sal_Bool bEndless = sal_False; 190cdf0e10cSrcweir String aPageName; 191cdf0e10cSrcweir 192cdf0e10cSrcweir rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) ); 193cdf0e10cSrcweir if( xSlideshow.is() && xSlideshow->isRunning() ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir // pen activated? 196cdf0e10cSrcweir nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED; 197cdf0e10cSrcweir 198cdf0e10cSrcweir nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber(); 199cdf0e10cSrcweir nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber(); 200cdf0e10cSrcweir nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber(); 201cdf0e10cSrcweir bEndless = xSlideshow->isEndless(); 202cdf0e10cSrcweir 203cdf0e10cSrcweir // Get the page for the current page number. 204cdf0e10cSrcweir SdPage* pPage = 0; 205cdf0e10cSrcweir if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) ) 206cdf0e10cSrcweir pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD); 207cdf0e10cSrcweir 208cdf0e10cSrcweir if(pPage) 209cdf0e10cSrcweir aPageName = pPage->GetName(); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir else 212cdf0e10cSrcweir { 213cdf0e10cSrcweir nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE; 214cdf0e10cSrcweir 215cdf0e10cSrcweir if (mpActualPage != NULL) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2; 218cdf0e10cSrcweir aPageName = mpActualPage->GetName(); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir // erste Seite / vorherige Seite 224cdf0e10cSrcweir if( nCurrentPage == nFirstPage ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir nState |= NAVBTN_FIRST_DISABLED; 227cdf0e10cSrcweir if( !bEndless ) 228cdf0e10cSrcweir nState |= NAVBTN_PREV_DISABLED; 229cdf0e10cSrcweir else 230cdf0e10cSrcweir nState |= NAVBTN_PREV_ENABLED; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir else 233cdf0e10cSrcweir { 234cdf0e10cSrcweir nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED; 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir // letzte Seite / naechste Seite 238cdf0e10cSrcweir if( nCurrentPage == nLastPage ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir nState |= NAVBTN_LAST_DISABLED; 241cdf0e10cSrcweir if( !bEndless ) 242cdf0e10cSrcweir nState |= NAVBTN_NEXT_DISABLED; 243cdf0e10cSrcweir else 244cdf0e10cSrcweir nState |= NAVBTN_NEXT_ENABLED; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir else 247cdf0e10cSrcweir { 248cdf0e10cSrcweir nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED; 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) ); 252cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) ); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir } // end of namespace sd 256