xref: /AOO41X/main/sd/source/ui/view/drviewsd.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "DrawViewShell.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #ifndef _SVXIDS_HRC
34*cdf0e10cSrcweir #include <svx/svxids.hrc>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #include <svl/aeitem.hxx>
37*cdf0e10cSrcweir #include <svl/stritem.hxx>
38*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
39*cdf0e10cSrcweir #include <svl/intitem.hxx>
40*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
41*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
42*cdf0e10cSrcweir #include <sfx2/request.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include "app.hrc"
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #include "sdpage.hxx"
50*cdf0e10cSrcweir #include "drawdoc.hxx"
51*cdf0e10cSrcweir #include "DrawDocShell.hxx"
52*cdf0e10cSrcweir #include "slideshow.hxx"
53*cdf0e10cSrcweir #include "pgjump.hxx"
54*cdf0e10cSrcweir #include "NavigatorChildWindow.hxx"
55*cdf0e10cSrcweir #ifndef SD_NAVIGATION_HXX
56*cdf0e10cSrcweir #include "navigatr.hxx"
57*cdf0e10cSrcweir #endif
58*cdf0e10cSrcweir #include "drawview.hxx"
59*cdf0e10cSrcweir #include "slideshow.hxx"
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir namespace sd {
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir /*************************************************************************
64*cdf0e10cSrcweir |*
65*cdf0e10cSrcweir |* SfxRequests fuer Navigator bearbeiten
66*cdf0e10cSrcweir |*
67*cdf0e10cSrcweir \************************************************************************/
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir 	CheckLineTo (rReq);
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	sal_uInt16 nSId = rReq.GetSlot();
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	switch( nSId )
76*cdf0e10cSrcweir 	{
77*cdf0e10cSrcweir 		case SID_NAVIGATOR_INIT:
78*cdf0e10cSrcweir 		{
79*cdf0e10cSrcweir 			sal_uInt16 nId = SID_NAVIGATOR;
80*cdf0e10cSrcweir 			SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
81*cdf0e10cSrcweir 			if( pWindow )
82*cdf0e10cSrcweir 			{
83*cdf0e10cSrcweir 				SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
84*cdf0e10cSrcweir 				if( pNavWin )
85*cdf0e10cSrcweir 					pNavWin->InitTreeLB( GetDoc() );
86*cdf0e10cSrcweir 			}
87*cdf0e10cSrcweir 		}
88*cdf0e10cSrcweir 		break;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 		case SID_NAVIGATOR_PEN:
91*cdf0e10cSrcweir 		case SID_NAVIGATOR_PAGE:
92*cdf0e10cSrcweir 		case SID_NAVIGATOR_OBJECT:
93*cdf0e10cSrcweir 		{
94*cdf0e10cSrcweir 			rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
95*cdf0e10cSrcweir 			if (xSlideshow.is() && xSlideshow->isRunning() )
96*cdf0e10cSrcweir 			{
97*cdf0e10cSrcweir 				xSlideshow->receiveRequest( rReq );
98*cdf0e10cSrcweir 			}
99*cdf0e10cSrcweir 			else if (nSId == SID_NAVIGATOR_PAGE)
100*cdf0e10cSrcweir 			{
101*cdf0e10cSrcweir 				if ( mpDrawView->IsTextEdit() )
102*cdf0e10cSrcweir 					mpDrawView->SdrEndTextEdit();
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 				const SfxItemSet* pArgs = rReq.GetArgs();
105*cdf0e10cSrcweir 				PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->
106*cdf0e10cSrcweir 								  Get(SID_NAVIGATOR_PAGE)).GetValue();
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 				switch (eJump)
109*cdf0e10cSrcweir 				{
110*cdf0e10cSrcweir 					case PAGE_FIRST:
111*cdf0e10cSrcweir 					{
112*cdf0e10cSrcweir 						// Sprung zu erster Seite
113*cdf0e10cSrcweir 						SwitchPage(0);
114*cdf0e10cSrcweir 					}
115*cdf0e10cSrcweir 					break;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 					case PAGE_LAST:
118*cdf0e10cSrcweir 					{
119*cdf0e10cSrcweir 						// Sprung zu letzter Seite
120*cdf0e10cSrcweir 						SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
121*cdf0e10cSrcweir 					}
122*cdf0e10cSrcweir 					break;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 					case PAGE_NEXT:
125*cdf0e10cSrcweir 					{
126*cdf0e10cSrcweir 						// Sprung zu naechster Seite
127*cdf0e10cSrcweir 						sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 						if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
130*cdf0e10cSrcweir 						{
131*cdf0e10cSrcweir 							SwitchPage(nSdPage + 1);
132*cdf0e10cSrcweir 						}
133*cdf0e10cSrcweir 					}
134*cdf0e10cSrcweir 					break;
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 					case PAGE_PREVIOUS:
137*cdf0e10cSrcweir 					{
138*cdf0e10cSrcweir 						// Sprung zu vorheriger Seite
139*cdf0e10cSrcweir 						sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 						if (nSdPage > 0)
142*cdf0e10cSrcweir 						{
143*cdf0e10cSrcweir 							SwitchPage(nSdPage - 1);
144*cdf0e10cSrcweir 						}
145*cdf0e10cSrcweir 					}
146*cdf0e10cSrcweir 					break;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 					case PAGE_NONE:
149*cdf0e10cSrcweir 						break;
150*cdf0e10cSrcweir 				}
151*cdf0e10cSrcweir 			}
152*cdf0e10cSrcweir 			else if (nSId == SID_NAVIGATOR_OBJECT)
153*cdf0e10cSrcweir 			{
154*cdf0e10cSrcweir 				String aBookmarkStr;
155*cdf0e10cSrcweir 				aBookmarkStr += sal_Unicode( '#' );
156*cdf0e10cSrcweir 				const SfxItemSet* pArgs = rReq.GetArgs();
157*cdf0e10cSrcweir 				String aTarget = ((SfxStringItem&) pArgs->
158*cdf0e10cSrcweir 								 Get(SID_NAVIGATOR_OBJECT)).GetValue();
159*cdf0e10cSrcweir 				aBookmarkStr += aTarget;
160*cdf0e10cSrcweir 				SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
161*cdf0e10cSrcweir 				SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
162*cdf0e10cSrcweir 				SfxViewFrame* pFrame = GetViewFrame();
163*cdf0e10cSrcweir 				SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
164*cdf0e10cSrcweir 				SfxBoolItem aBrowseItem(SID_BROWSE, sal_True);
165*cdf0e10cSrcweir 				pFrame->GetDispatcher()->
166*cdf0e10cSrcweir 				Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
167*cdf0e10cSrcweir 							&aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
168*cdf0e10cSrcweir 			}
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 			SfxBindings& rBindings = GetViewFrame()->GetBindings();
171*cdf0e10cSrcweir 			rBindings.Invalidate( SID_NAVIGATOR_STATE );
172*cdf0e10cSrcweir 			rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
173*cdf0e10cSrcweir 		}
174*cdf0e10cSrcweir 		break;
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 		default:
177*cdf0e10cSrcweir 		break;
178*cdf0e10cSrcweir 	}
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir /*************************************************************************
182*cdf0e10cSrcweir |*
183*cdf0e10cSrcweir |* Statuswerte fuer Navigator zurueckgeben
184*cdf0e10cSrcweir |*
185*cdf0e10cSrcweir \************************************************************************/
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
188*cdf0e10cSrcweir {
189*cdf0e10cSrcweir 	sal_uInt32 nState = NAVSTATE_NONE;
190*cdf0e10cSrcweir 	sal_uInt16 nCurrentPage = 0;
191*cdf0e10cSrcweir 	sal_uInt16 nFirstPage = 0;
192*cdf0e10cSrcweir 	sal_uInt16 nLastPage;
193*cdf0e10cSrcweir 	sal_Bool   bEndless = sal_False;
194*cdf0e10cSrcweir 	String aPageName;
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
197*cdf0e10cSrcweir 	if( xSlideshow.is() && xSlideshow->isRunning() )
198*cdf0e10cSrcweir 	{
199*cdf0e10cSrcweir 		// pen activated?
200*cdf0e10cSrcweir 		nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 		nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
203*cdf0e10cSrcweir 		nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
204*cdf0e10cSrcweir 		nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
205*cdf0e10cSrcweir 		bEndless = xSlideshow->isEndless();
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir         // Get the page for the current page number.
208*cdf0e10cSrcweir 		SdPage* pPage = 0;
209*cdf0e10cSrcweir 		if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
210*cdf0e10cSrcweir 			pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 		if(pPage)
213*cdf0e10cSrcweir 			aPageName = pPage->GetName();
214*cdf0e10cSrcweir 	}
215*cdf0e10cSrcweir 	else
216*cdf0e10cSrcweir 	{
217*cdf0e10cSrcweir 		nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir         if (mpActualPage != NULL)
220*cdf0e10cSrcweir         {
221*cdf0e10cSrcweir             nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
222*cdf0e10cSrcweir             aPageName = mpActualPage->GetName();
223*cdf0e10cSrcweir         }
224*cdf0e10cSrcweir 		nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
225*cdf0e10cSrcweir 	}
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	// erste Seite / vorherige Seite
228*cdf0e10cSrcweir 	if( nCurrentPage == nFirstPage )
229*cdf0e10cSrcweir 	{
230*cdf0e10cSrcweir 		nState |= NAVBTN_FIRST_DISABLED;
231*cdf0e10cSrcweir 		if( !bEndless )
232*cdf0e10cSrcweir 			nState |= NAVBTN_PREV_DISABLED;
233*cdf0e10cSrcweir 		else
234*cdf0e10cSrcweir 			nState |= NAVBTN_PREV_ENABLED;
235*cdf0e10cSrcweir 	}
236*cdf0e10cSrcweir 	else
237*cdf0e10cSrcweir 	{
238*cdf0e10cSrcweir 		nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
239*cdf0e10cSrcweir 	}
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 	// letzte Seite / naechste Seite
242*cdf0e10cSrcweir 	if( nCurrentPage == nLastPage )
243*cdf0e10cSrcweir 	{
244*cdf0e10cSrcweir 		nState |= NAVBTN_LAST_DISABLED;
245*cdf0e10cSrcweir 		if( !bEndless )
246*cdf0e10cSrcweir 			nState |= NAVBTN_NEXT_DISABLED;
247*cdf0e10cSrcweir 		else
248*cdf0e10cSrcweir 			nState |= NAVBTN_NEXT_ENABLED;
249*cdf0e10cSrcweir 	}
250*cdf0e10cSrcweir 	else
251*cdf0e10cSrcweir 	{
252*cdf0e10cSrcweir 		nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
253*cdf0e10cSrcweir 	}
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 	rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
256*cdf0e10cSrcweir 	rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir } // end of namespace sd
260