merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / view / drviewsd.cxx
blobde5b21a19ef6bc4bf70901c61fbba8c7f45c1e66
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviewsd.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "DrawViewShell.hxx"
36 #ifndef _SVXIDS_HRC
37 #include <svx/svxids.hrc>
38 #endif
39 #include <svtools/aeitem.hxx>
40 #include <svtools/stritem.hxx>
41 #include <sfx2/docfile.hxx>
42 #include <svtools/intitem.hxx>
43 #include <sfx2/bindings.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/request.hxx>
47 #include <sfx2/viewfrm.hxx>
50 #include "app.hrc"
52 #include "sdpage.hxx"
53 #include "drawdoc.hxx"
54 #include "DrawDocShell.hxx"
55 #include "slideshow.hxx"
56 #include "pgjump.hxx"
57 #include "NavigatorChildWindow.hxx"
58 #ifndef SD_NAVIGATION_HXX
59 #include "navigatr.hxx"
60 #endif
61 #include "drawview.hxx"
62 #include "slideshow.hxx"
64 namespace sd {
66 /*************************************************************************
68 |* SfxRequests fuer Navigator bearbeiten
70 \************************************************************************/
72 void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
74 CheckLineTo (rReq);
76 USHORT nSId = rReq.GetSlot();
78 switch( nSId )
80 case SID_NAVIGATOR_INIT:
82 USHORT nId = SID_NAVIGATOR;
83 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
84 if( pWindow )
86 SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
87 if( pNavWin )
88 pNavWin->InitTreeLB( GetDoc() );
91 break;
93 case SID_NAVIGATOR_PEN:
94 case SID_NAVIGATOR_PAGE:
95 case SID_NAVIGATOR_OBJECT:
97 rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
98 if (xSlideshow.is() && xSlideshow->isRunning() )
100 xSlideshow->receiveRequest( rReq );
102 else if (nSId == SID_NAVIGATOR_PAGE)
104 if ( mpDrawView->IsTextEdit() )
105 mpDrawView->SdrEndTextEdit();
107 const SfxItemSet* pArgs = rReq.GetArgs();
108 PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->
109 Get(SID_NAVIGATOR_PAGE)).GetValue();
111 switch (eJump)
113 case PAGE_FIRST:
115 // Sprung zu erster Seite
116 SwitchPage(0);
118 break;
120 case PAGE_LAST:
122 // Sprung zu letzter Seite
123 SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
125 break;
127 case PAGE_NEXT:
129 // Sprung zu naechster Seite
130 USHORT nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
132 if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
134 SwitchPage(nSdPage + 1);
137 break;
139 case PAGE_PREVIOUS:
141 // Sprung zu vorheriger Seite
142 USHORT nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
144 if (nSdPage > 0)
146 SwitchPage(nSdPage - 1);
149 break;
151 case PAGE_NONE:
152 break;
155 else if (nSId == SID_NAVIGATOR_OBJECT)
157 String aBookmarkStr;
158 aBookmarkStr += sal_Unicode( '#' );
159 const SfxItemSet* pArgs = rReq.GetArgs();
160 String aTarget = ((SfxStringItem&) pArgs->
161 Get(SID_NAVIGATOR_OBJECT)).GetValue();
162 aBookmarkStr += aTarget;
163 SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
164 SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
165 SfxViewFrame* pFrame = GetViewFrame();
166 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
167 SfxBoolItem aBrowseItem(SID_BROWSE, TRUE);
168 pFrame->GetDispatcher()->
169 Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
170 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
173 SfxBindings& rBindings = GetViewFrame()->GetBindings();
174 rBindings.Invalidate( SID_NAVIGATOR_STATE );
175 rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
177 break;
179 default:
180 break;
184 /*************************************************************************
186 |* Statuswerte fuer Navigator zurueckgeben
188 \************************************************************************/
190 void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
192 UINT32 nState = NAVSTATE_NONE;
193 USHORT nCurrentPage = 0;
194 USHORT nFirstPage = 0;
195 USHORT nLastPage;
196 BOOL bEndless = FALSE;
197 String aPageName;
199 rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
200 if( xSlideshow.is() && xSlideshow->isRunning() )
202 // pen activated?
203 nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
205 nCurrentPage = (USHORT)xSlideshow->getCurrentPageNumber();
206 nFirstPage = (USHORT)xSlideshow->getFirstPageNumber();
207 nLastPage = (USHORT)xSlideshow->getLastPageNumber();
208 bEndless = xSlideshow->isEndless();
210 // Get the page for the current page number.
211 SdPage* pPage = 0;
212 if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
213 pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
215 if(pPage)
216 aPageName = pPage->GetName();
218 else
220 nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
222 if (mpActualPage != NULL)
224 nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
225 aPageName = mpActualPage->GetName();
227 nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
230 // erste Seite / vorherige Seite
231 if( nCurrentPage == nFirstPage )
233 nState |= NAVBTN_FIRST_DISABLED;
234 if( !bEndless )
235 nState |= NAVBTN_PREV_DISABLED;
236 else
237 nState |= NAVBTN_PREV_ENABLED;
239 else
241 nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
244 // letzte Seite / naechste Seite
245 if( nCurrentPage == nLastPage )
247 nState |= NAVBTN_LAST_DISABLED;
248 if( !bEndless )
249 nState |= NAVBTN_NEXT_DISABLED;
250 else
251 nState |= NAVBTN_NEXT_ENABLED;
253 else
255 nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
258 rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
259 rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
262 } // end of namespace sd