xref: /aoo41x/main/sd/source/ui/func/fusldlg.cxx (revision cdf0e10c)
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 
32*cdf0e10cSrcweir #include "fusldlg.hxx"
33*cdf0e10cSrcweir #include <svl/itemset.hxx>
34*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
35*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
36*cdf0e10cSrcweir #endif
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include "drawdoc.hxx"
39*cdf0e10cSrcweir #include "sdpage.hxx"
40*cdf0e10cSrcweir #include "sdresid.hxx"
41*cdf0e10cSrcweir #include "strings.hrc"
42*cdf0e10cSrcweir #include "sdattr.hxx"
43*cdf0e10cSrcweir #include "glob.hrc"
44*cdf0e10cSrcweir #include "sdmod.hxx"
45*cdf0e10cSrcweir #include "ViewShell.hxx"
46*cdf0e10cSrcweir #include "Window.hxx"
47*cdf0e10cSrcweir #include "optsitem.hxx"
48*cdf0e10cSrcweir #include "sdabstdlg.hxx"
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir namespace sd {
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir TYPEINIT1( FuSlideShowDlg, FuPoor );
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /*************************************************************************
58*cdf0e10cSrcweir |*
59*cdf0e10cSrcweir |* Konstruktor
60*cdf0e10cSrcweir |*
61*cdf0e10cSrcweir \************************************************************************/
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir FuSlideShowDlg::FuSlideShowDlg (
64*cdf0e10cSrcweir     ViewShell* pViewSh,
65*cdf0e10cSrcweir     ::sd::Window* pWin,
66*cdf0e10cSrcweir     ::sd::View*	pView,
67*cdf0e10cSrcweir     SdDrawDocument* pDoc,
68*cdf0e10cSrcweir     SfxRequest& rReq)
69*cdf0e10cSrcweir     : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir }
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir FunctionReference FuSlideShowDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir 	FunctionReference xFunc( new FuSlideShowDlg( pViewSh, pWin, pView, pDoc, rReq ) );
76*cdf0e10cSrcweir 	xFunc->DoExecute(rReq);
77*cdf0e10cSrcweir 	return xFunc;
78*cdf0e10cSrcweir }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir void FuSlideShowDlg::DoExecute( SfxRequest& )
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir 	PresentationSettings& rPresentationSettings = mpDoc->getPresentationSettings();
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	SfxItemSet		aDlgSet( mpDoc->GetPool(), ATTR_PRESENT_START, ATTR_PRESENT_END );
85*cdf0e10cSrcweir 	List			aPageNameList;
86*cdf0e10cSrcweir 	const String&	rPresPage = rPresentationSettings.maPresPage;
87*cdf0e10cSrcweir 	String			aFirstPage;
88*cdf0e10cSrcweir 	String			aStandardName( SdResId( STR_PAGE ) );
89*cdf0e10cSrcweir 	SdPage*			pPage = NULL;
90*cdf0e10cSrcweir 	long			nPage;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	for( nPage = mpDoc->GetSdPageCount( PK_STANDARD ) - 1L; nPage >= 0L; nPage-- )
93*cdf0e10cSrcweir 	{
94*cdf0e10cSrcweir 		pPage = mpDoc->GetSdPage( (sal_uInt16) nPage, PK_STANDARD );
95*cdf0e10cSrcweir 		String* pStr = new String( pPage->GetName() );
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 		if ( !pStr->Len() )
98*cdf0e10cSrcweir 		{
99*cdf0e10cSrcweir 			*pStr = String( SdResId( STR_PAGE ) );
100*cdf0e10cSrcweir 			(*pStr).Append( UniString::CreateFromInt32( nPage + 1 ) );
101*cdf0e10cSrcweir 		}
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 		aPageNameList.Insert( pStr, (sal_uLong) 0 );
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 		// ist dies unsere (vorhandene) erste Seite?
106*cdf0e10cSrcweir 		if ( rPresPage == *pStr )
107*cdf0e10cSrcweir 			aFirstPage = rPresPage;
108*cdf0e10cSrcweir 		else if ( pPage->IsSelected() && !aFirstPage.Len() )
109*cdf0e10cSrcweir 			aFirstPage = *pStr;
110*cdf0e10cSrcweir 	}
111*cdf0e10cSrcweir 	List* pCustomShowList = mpDoc->GetCustomShowList(); // No Create
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	sal_Bool bStartWithActualPage = SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsStartWithActualPage();
114*cdf0e10cSrcweir /* #109180# change in behaviour, even when always start with current page is enabled, range settings are
115*cdf0e10cSrcweir 			still used
116*cdf0e10cSrcweir 	if( bStartWithActualPage )
117*cdf0e10cSrcweir 	{
118*cdf0e10cSrcweir 		aFirstPage = pViewSh->GetActualPage()->GetName();
119*cdf0e10cSrcweir 		pCustomShowList = NULL;
120*cdf0e10cSrcweir 	}
121*cdf0e10cSrcweir */
122*cdf0e10cSrcweir 	if( !aFirstPage.Len() && pPage )
123*cdf0e10cSrcweir 		aFirstPage = pPage->GetName();
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALL, rPresentationSettings.mbAll ) );
126*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CUSTOMSHOW, rPresentationSettings.mbCustomShow ) );
127*cdf0e10cSrcweir 	aDlgSet.Put( SfxStringItem( ATTR_PRESENT_DIANAME, aFirstPage ) );
128*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ENDLESS, rPresentationSettings.mbEndless ) );
129*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MANUEL, rPresentationSettings.mbManual ) );
130*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MOUSE, rPresentationSettings.mbMouseVisible ) );
131*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_PEN, rPresentationSettings.mbMouseAsPen ) );
132*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_NAVIGATOR, rPresentationSettings.mbStartWithNavigator ) );
133*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ANIMATION_ALLOWED, rPresentationSettings.mbAnimationAllowed ) );
134*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CHANGE_PAGE, !rPresentationSettings.mbLockedPages ) );
135*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALWAYS_ON_TOP, rPresentationSettings.mbAlwaysOnTop ) );
136*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_FULLSCREEN, rPresentationSettings.mbFullScreen ) );
137*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_START_ACTUAL_PAGE, bStartWithActualPage ) );
138*cdf0e10cSrcweir 	aDlgSet.Put( SfxUInt32Item( ATTR_PRESENT_PAUSE_TIMEOUT, rPresentationSettings.mnPauseTimeout ) );
139*cdf0e10cSrcweir 	aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_SHOW_PAUSELOGO, rPresentationSettings.mbShowPauseLogo ) );
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
142*cdf0e10cSrcweir 	aDlgSet.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY, pOptions->GetDisplay() ) );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 	SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
145*cdf0e10cSrcweir 	AbstractSdStartPresDlg* pDlg = pFact ? pFact->CreateSdStartPresentationDlg(mpWindow, aDlgSet, aPageNameList, pCustomShowList ) : 0;
146*cdf0e10cSrcweir 	if( pDlg && (pDlg->Execute() == RET_OK) )
147*cdf0e10cSrcweir 	{
148*cdf0e10cSrcweir 		rtl::OUString aPage;
149*cdf0e10cSrcweir 		long	nValue32;
150*cdf0e10cSrcweir 		sal_Bool bValue;
151*cdf0e10cSrcweir 		bool	bValuesChanged = sal_False;
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 		pDlg->GetAttr( aDlgSet );
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 		aPage = ITEMVALUE( aDlgSet, ATTR_PRESENT_DIANAME, SfxStringItem );
156*cdf0e10cSrcweir 		if( aPage != rPresentationSettings.maPresPage )
157*cdf0e10cSrcweir 		{
158*cdf0e10cSrcweir 			bValuesChanged = true;
159*cdf0e10cSrcweir 			rPresentationSettings.maPresPage = aPage;
160*cdf0e10cSrcweir 		}
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem );
163*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbAll )
164*cdf0e10cSrcweir 		{
165*cdf0e10cSrcweir 			bValuesChanged = true;
166*cdf0e10cSrcweir 			rPresentationSettings.mbAll = bValue;
167*cdf0e10cSrcweir 		}
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem );
170*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbCustomShow )
171*cdf0e10cSrcweir 		{
172*cdf0e10cSrcweir 			bValuesChanged = true;
173*cdf0e10cSrcweir 			rPresentationSettings.mbCustomShow = bValue;
174*cdf0e10cSrcweir 		}
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem );
177*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbEndless )
178*cdf0e10cSrcweir 		{
179*cdf0e10cSrcweir 			bValuesChanged = true;
180*cdf0e10cSrcweir 			rPresentationSettings.mbEndless = bValue;
181*cdf0e10cSrcweir 		}
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem );
184*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbManual )
185*cdf0e10cSrcweir 		{
186*cdf0e10cSrcweir 			bValuesChanged = true;
187*cdf0e10cSrcweir 			rPresentationSettings.mbManual = bValue;
188*cdf0e10cSrcweir 		}
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem );
191*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbMouseVisible )
192*cdf0e10cSrcweir 		{
193*cdf0e10cSrcweir 			bValuesChanged = true;
194*cdf0e10cSrcweir 			rPresentationSettings.mbMouseVisible = bValue;
195*cdf0e10cSrcweir 		}
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem );
198*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbMouseAsPen )
199*cdf0e10cSrcweir 		{
200*cdf0e10cSrcweir 			bValuesChanged = true;
201*cdf0e10cSrcweir 			rPresentationSettings.mbMouseAsPen = bValue;
202*cdf0e10cSrcweir 		}
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_NAVIGATOR, SfxBoolItem );
205*cdf0e10cSrcweir 		if( bValue != rPresentationSettings.mbStartWithNavigator )
206*cdf0e10cSrcweir 		{
207*cdf0e10cSrcweir 			bValuesChanged = true;
208*cdf0e10cSrcweir 			rPresentationSettings.mbStartWithNavigator = bValue;
209*cdf0e10cSrcweir 		}
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 		bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem );
212*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbLockedPages )
213*cdf0e10cSrcweir 		{
214*cdf0e10cSrcweir 			bValuesChanged = true;
215*cdf0e10cSrcweir 			rPresentationSettings.mbLockedPages = bValue;
216*cdf0e10cSrcweir 		}
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem );
219*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbAnimationAllowed )
220*cdf0e10cSrcweir 		{
221*cdf0e10cSrcweir 			bValuesChanged = true;
222*cdf0e10cSrcweir 			rPresentationSettings.mbAnimationAllowed = bValue;
223*cdf0e10cSrcweir 		}
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem );
226*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbAlwaysOnTop )
227*cdf0e10cSrcweir 		{
228*cdf0e10cSrcweir 			bValuesChanged = true;
229*cdf0e10cSrcweir 			rPresentationSettings.mbAlwaysOnTop = bValue;
230*cdf0e10cSrcweir 		}
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem );
233*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbFullScreen )
234*cdf0e10cSrcweir 		{
235*cdf0e10cSrcweir 			bValuesChanged = true;
236*cdf0e10cSrcweir 			rPresentationSettings.mbFullScreen = bValue;
237*cdf0e10cSrcweir 		}
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 		nValue32 = ITEMVALUE( aDlgSet, ATTR_PRESENT_PAUSE_TIMEOUT, SfxUInt32Item );
240*cdf0e10cSrcweir 		if( nValue32 != rPresentationSettings.mnPauseTimeout )
241*cdf0e10cSrcweir 		{
242*cdf0e10cSrcweir 			bValuesChanged = true;
243*cdf0e10cSrcweir 			rPresentationSettings.mnPauseTimeout = nValue32;
244*cdf0e10cSrcweir 		}
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 		bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem );
247*cdf0e10cSrcweir 		if ( bValue != rPresentationSettings.mbShowPauseLogo )
248*cdf0e10cSrcweir 		{
249*cdf0e10cSrcweir 			bValuesChanged = true;
250*cdf0e10cSrcweir 			rPresentationSettings.mbShowPauseLogo = bValue;
251*cdf0e10cSrcweir 		}
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 		pOptions->SetDisplay( ITEMVALUE( aDlgSet, ATTR_PRESENT_DISPLAY, SfxInt32Item ) );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 		// wenn sich etwas geaendert hat, setzen wir das Modified-Flag,
256*cdf0e10cSrcweir 		if ( bValuesChanged )
257*cdf0e10cSrcweir 			mpDoc->SetChanged( sal_True );
258*cdf0e10cSrcweir 	}
259*cdf0e10cSrcweir 	delete pDlg;
260*cdf0e10cSrcweir 	// Strings aus Liste loeschen
261*cdf0e10cSrcweir 	for( void* pStr = aPageNameList.First(); pStr; pStr = aPageNameList.Next() )
262*cdf0e10cSrcweir 		delete (String*) pStr;
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir } // end of namespace sd
266