bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / view / drviewsd.cxx
blob922f148ae50c2aadba0fa63e5494fd2e29562041
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "DrawViewShell.hxx"
22 #include <svx/svxids.hrc>
23 #include <svl/aeitem.hxx>
24 #include <svl/stritem.hxx>
25 #include <sfx2/docfile.hxx>
26 #include <svl/intitem.hxx>
27 #include <sfx2/bindings.hxx>
28 #include <sfx2/dispatch.hxx>
29 #include <sfx2/request.hxx>
31 #include <sfx2/viewfrm.hxx>
33 #include "app.hrc"
35 #include "sdpage.hxx"
36 #include "drawdoc.hxx"
37 #include "DrawDocShell.hxx"
38 #include "slideshow.hxx"
39 #include "pgjump.hxx"
40 #include "NavigatorChildWindow.hxx"
41 #include "navigatr.hxx"
42 #include "drawview.hxx"
44 namespace sd {
46 /**
47 * handle SfxRequests for navigator
49 void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
51 CheckLineTo (rReq);
53 sal_uInt16 nSId = rReq.GetSlot();
55 switch( nSId )
57 case SID_NAVIGATOR_INIT:
59 sal_uInt16 nId = SID_NAVIGATOR;
60 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
61 if( pWindow )
63 SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
64 if( pNavWin )
65 pNavWin->InitTreeLB( GetDoc() );
68 break;
70 case SID_NAVIGATOR_PEN:
71 case SID_NAVIGATOR_PAGE:
72 case SID_NAVIGATOR_OBJECT:
74 rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
75 if (xSlideshow.is() && xSlideshow->isRunning() )
77 xSlideshow->receiveRequest( rReq );
79 else if (nSId == SID_NAVIGATOR_PAGE)
81 if ( mpDrawView->IsTextEdit() )
82 mpDrawView->SdrEndTextEdit();
84 const SfxItemSet* pArgs = rReq.GetArgs();
85 PageJump eJump = (PageJump)static_cast<const SfxAllEnumItem&>( pArgs->
86 Get(SID_NAVIGATOR_PAGE)).GetValue();
88 switch (eJump)
90 case PAGE_FIRST:
92 // jump to first page
93 SwitchPage(0);
95 break;
97 case PAGE_LAST:
99 // jumpt to last page
100 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
102 break;
104 case PAGE_NEXT:
106 // jump to next page
107 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
109 if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
111 SwitchPage(nSdPage + 1);
114 break;
116 case PAGE_PREVIOUS:
118 // jump to previous page
119 sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
121 if (nSdPage > 0)
123 SwitchPage(nSdPage - 1);
126 break;
128 case PAGE_NONE:
129 break;
132 else if (nSId == SID_NAVIGATOR_OBJECT)
134 OUString aBookmarkStr("#");
135 const SfxItemSet* pArgs = rReq.GetArgs();
136 OUString aTarget = static_cast<const SfxStringItem&>( pArgs->
137 Get(SID_NAVIGATOR_OBJECT)).GetValue();
138 aBookmarkStr += aTarget;
139 SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
140 SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
141 SfxViewFrame* pFrame = GetViewFrame();
142 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
143 SfxBoolItem aBrowseItem(SID_BROWSE, true);
144 pFrame->GetDispatcher()->
145 Execute(SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
146 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
149 SfxBindings& rBindings = GetViewFrame()->GetBindings();
150 rBindings.Invalidate( SID_NAVIGATOR_STATE );
151 rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
153 break;
155 default:
156 break;
160 void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
162 sal_uInt32 nState = NAVSTATE_NONE;
163 sal_uInt16 nCurrentPage = 0;
164 sal_uInt16 nFirstPage = 0;
165 sal_uInt16 nLastPage;
166 bool bEndless = false;
167 OUString aPageName;
169 rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
170 if( xSlideshow.is() && xSlideshow->isRunning() )
172 // pen activated?
173 nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
175 nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
176 nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
177 nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
178 bEndless = xSlideshow->isEndless();
180 // Get the page for the current page number.
181 SdPage* pPage = 0;
182 if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
183 pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
185 if(pPage)
186 aPageName = pPage->GetName();
188 else
190 nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
192 if (mpActualPage != NULL)
194 nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
195 aPageName = mpActualPage->GetName();
197 nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
200 // first page / previous page
201 if( nCurrentPage == nFirstPage )
203 nState |= NAVBTN_FIRST_DISABLED;
204 if( !bEndless )
205 nState |= NAVBTN_PREV_DISABLED;
206 else
207 nState |= NAVBTN_PREV_ENABLED;
209 else
211 nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
214 // last page / next page
215 if( nCurrentPage == nLastPage )
217 nState |= NAVBTN_LAST_DISABLED;
218 if( !bEndless )
219 nState |= NAVBTN_NEXT_DISABLED;
220 else
221 nState |= NAVBTN_NEXT_ENABLED;
223 else
225 nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
228 rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
229 rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
232 } // end of namespace sd
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */