Files
libreoffice/sd/source/ui/view/drviewsd.cxx

235 lines
7.4 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
2000-09-18 16:07:07 +00:00
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2000-09-18 16:07:07 +00:00
*
* This file incorporates work covered by the following license notice:
2000-09-18 16:07:07 +00:00
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include "DrawViewShell.hxx"
2000-09-18 16:07:07 +00:00
#include <svx/svxids.hrc>
#include <svl/aeitem.hxx>
#include <svl/stritem.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/docfile.hxx>
#include <svl/intitem.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
2000-09-18 16:07:07 +00:00
#include "app.hrc"
#include "sdpage.hxx"
#include "drawdoc.hxx"
#include "DrawDocShell.hxx"
#include "slideshow.hxx"
2000-09-18 16:07:07 +00:00
#include "pgjump.hxx"
#include "NavigatorChildWindow.hxx"
2000-09-18 16:07:07 +00:00
#include "navigatr.hxx"
#include "drawview.hxx"
namespace sd {
2000-09-18 16:07:07 +00:00
/**
* handle SfxRequests for navigator
*/
void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
2000-09-18 16:07:07 +00:00
{
CheckLineTo (rReq);
sal_uInt16 nSId = rReq.GetSlot();
2000-09-18 16:07:07 +00:00
switch( nSId )
{
case SID_NAVIGATOR_INIT:
{
sal_uInt16 nId = SID_NAVIGATOR;
2000-09-18 16:07:07 +00:00
SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
if( pWindow )
{
SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
2000-09-18 16:07:07 +00:00
if( pNavWin )
pNavWin->InitTreeLB( GetDoc() );
2000-09-18 16:07:07 +00:00
}
}
break;
case SID_NAVIGATOR_PEN:
case SID_NAVIGATOR_PAGE:
case SID_NAVIGATOR_OBJECT:
{
rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
if (xSlideshow.is() && xSlideshow->isRunning() )
2000-09-18 16:07:07 +00:00
{
xSlideshow->receiveRequest( rReq );
2000-09-18 16:07:07 +00:00
}
else if (nSId == SID_NAVIGATOR_PAGE)
{
if ( mpDrawView->IsTextEdit() )
mpDrawView->SdrEndTextEdit();
2000-09-18 16:07:07 +00:00
const SfxItemSet* pArgs = rReq.GetArgs();
PageJump eJump = (PageJump)static_cast<const SfxAllEnumItem&>( pArgs->
2000-09-18 16:07:07 +00:00
Get(SID_NAVIGATOR_PAGE)).GetValue();
switch (eJump)
{
case PAGE_FIRST:
{
// jump to first page
2000-09-18 16:07:07 +00:00
SwitchPage(0);
}
break;
case PAGE_LAST:
{
// jumpt to last page
SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
2000-09-18 16:07:07 +00:00
}
break;
case PAGE_NEXT:
{
// jump to next page
sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
2000-09-18 16:07:07 +00:00
if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
2000-09-18 16:07:07 +00:00
{
SwitchPage(nSdPage + 1);
}
}
break;
case PAGE_PREVIOUS:
{
// jump to previous page
sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
2000-09-18 16:07:07 +00:00
if (nSdPage > 0)
{
SwitchPage(nSdPage - 1);
}
}
break;
case PAGE_NONE:
break;
2000-09-18 16:07:07 +00:00
}
}
else if (nSId == SID_NAVIGATOR_OBJECT)
{
OUString aBookmarkStr("#");
2000-09-18 16:07:07 +00:00
const SfxItemSet* pArgs = rReq.GetArgs();
OUString aTarget = static_cast<const SfxStringItem&>( pArgs->
2000-09-18 16:07:07 +00:00
Get(SID_NAVIGATOR_OBJECT)).GetValue();
aBookmarkStr += aTarget;
SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
2000-09-18 16:07:07 +00:00
SfxViewFrame* pFrame = GetViewFrame();
SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
SfxBoolItem aBrowseItem(SID_BROWSE, true);
2000-09-18 16:07:07 +00:00
pFrame->GetDispatcher()->
Execute(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
2000-09-18 16:07:07 +00:00
&aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
}
SfxBindings& rBindings = GetViewFrame()->GetBindings();
2000-09-18 16:07:07 +00:00
rBindings.Invalidate( SID_NAVIGATOR_STATE );
rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
}
break;
default:
break;
}
}
void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
2000-09-18 16:07:07 +00:00
{
sal_uInt32 nState = NAVSTATE_NONE;
sal_uInt16 nCurrentPage = 0;
sal_uInt16 nFirstPage = 0;
sal_uInt16 nLastPage;
bool bEndless = false;
OUString aPageName;
2000-09-18 16:07:07 +00:00
rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
if( xSlideshow.is() && xSlideshow->isRunning() )
2000-09-18 16:07:07 +00:00
{
// pen activated?
nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
2000-09-18 16:07:07 +00:00
nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
bEndless = xSlideshow->isEndless();
2000-09-18 16:07:07 +00:00
// Get the page for the current page number.
SdPage* pPage = 0;
if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
2000-09-18 16:07:07 +00:00
if(pPage)
2000-09-18 16:07:07 +00:00
aPageName = pPage->GetName();
}
else
{
nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
2000-09-18 16:07:07 +00:00
if (mpActualPage != NULL)
{
nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
aPageName = mpActualPage->GetName();
}
nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
2000-09-18 16:07:07 +00:00
}
// first page / previous page
2000-09-18 16:07:07 +00:00
if( nCurrentPage == nFirstPage )
{
nState |= NAVBTN_FIRST_DISABLED;
if( !bEndless )
nState |= NAVBTN_PREV_DISABLED;
else
nState |= NAVBTN_PREV_ENABLED;
}
else
{
2000-09-18 16:07:07 +00:00
nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
}
2000-09-18 16:07:07 +00:00
// last page / next page
2000-09-18 16:07:07 +00:00
if( nCurrentPage == nLastPage )
{
nState |= NAVBTN_LAST_DISABLED;
if( !bEndless )
nState |= NAVBTN_NEXT_DISABLED;
else
nState |= NAVBTN_NEXT_ENABLED;
}
else
{
2000-09-18 16:07:07 +00:00
nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
}
2000-09-18 16:07:07 +00:00
rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */