bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / func / fusldlg.cxx
blob93db40368f92929d09bcc7b5046314094e5e63a5
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 "fusldlg.hxx"
21 #include <svl/itemset.hxx>
22 #include <vcl/msgbox.hxx>
24 #include "drawdoc.hxx"
25 #include "sdpage.hxx"
26 #include "sdresid.hxx"
27 #include "strings.hrc"
28 #include "sdattr.hxx"
29 #include "glob.hrc"
30 #include "sdmod.hxx"
31 #include "ViewShell.hxx"
32 #include "Window.hxx"
33 #include "optsitem.hxx"
34 #include "sdabstdlg.hxx"
36 namespace sd {
38 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
40 TYPEINIT1( FuSlideShowDlg, FuPoor );
43 FuSlideShowDlg::FuSlideShowDlg (
44 ViewShell* pViewSh,
45 ::sd::Window* pWin,
46 ::sd::View* pView,
47 SdDrawDocument* pDoc,
48 SfxRequest& rReq)
49 : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
53 FunctionReference FuSlideShowDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
55 FunctionReference xFunc( new FuSlideShowDlg( pViewSh, pWin, pView, pDoc, rReq ) );
56 xFunc->DoExecute(rReq);
57 return xFunc;
60 void FuSlideShowDlg::DoExecute( SfxRequest& )
62 PresentationSettings& rPresentationSettings = mpDoc->getPresentationSettings();
64 SfxItemSet aDlgSet( mpDoc->GetPool(), ATTR_PRESENT_START, ATTR_PRESENT_END );
65 std::vector<String> aPageNameList(mpDoc->GetSdPageCount( PK_STANDARD ));
66 const String& rPresPage = rPresentationSettings.maPresPage;
67 String aFirstPage;
68 SdPage* pPage = NULL;
69 long nPage;
71 for( nPage = mpDoc->GetSdPageCount( PK_STANDARD ) - 1L; nPage >= 0L; nPage-- )
73 pPage = mpDoc->GetSdPage( (sal_uInt16) nPage, PK_STANDARD );
74 String aStr( pPage->GetName() );
76 if ( !aStr.Len() )
78 aStr = String( SdResId( STR_PAGE ) );
79 aStr.Append( OUString::valueOf( nPage + 1 ) );
82 aPageNameList[ nPage ] = aStr;
84 // is this our (existing) first page?
85 if ( rPresPage == aStr )
86 aFirstPage = rPresPage;
87 else if ( pPage->IsSelected() && !aFirstPage.Len() )
88 aFirstPage = aStr;
90 SdCustomShowList* pCustomShowList = mpDoc->GetCustomShowList(); // No Create
92 sal_Bool bStartWithActualPage = SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsStartWithActualPage();
93 if( !aFirstPage.Len() && pPage )
94 aFirstPage = pPage->GetName();
96 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALL, rPresentationSettings.mbAll ) );
97 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CUSTOMSHOW, rPresentationSettings.mbCustomShow ) );
98 aDlgSet.Put( SfxStringItem( ATTR_PRESENT_DIANAME, aFirstPage ) );
99 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ENDLESS, rPresentationSettings.mbEndless ) );
100 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MANUEL, rPresentationSettings.mbManual ) );
101 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MOUSE, rPresentationSettings.mbMouseVisible ) );
102 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_PEN, rPresentationSettings.mbMouseAsPen ) );
103 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_NAVIGATOR, rPresentationSettings.mbStartWithNavigator ) );
104 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ANIMATION_ALLOWED, rPresentationSettings.mbAnimationAllowed ) );
105 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CHANGE_PAGE, !rPresentationSettings.mbLockedPages ) );
106 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALWAYS_ON_TOP, rPresentationSettings.mbAlwaysOnTop ) );
107 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_FULLSCREEN, rPresentationSettings.mbFullScreen ) );
108 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_START_ACTUAL_PAGE, bStartWithActualPage ) );
109 aDlgSet.Put( SfxUInt32Item( ATTR_PRESENT_PAUSE_TIMEOUT, rPresentationSettings.mnPauseTimeout ) );
110 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_SHOW_PAUSELOGO, rPresentationSettings.mbShowPauseLogo ) );
112 SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
113 aDlgSet.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY, pOptions->GetDisplay() ) );
115 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
116 AbstractSdStartPresDlg* pDlg = pFact ? pFact->CreateSdStartPresentationDlg(mpWindow, aDlgSet, aPageNameList, pCustomShowList) : 0;
117 if( pDlg && (pDlg->Execute() == RET_OK) )
119 OUString aPage;
120 long nValue32;
121 sal_Bool bValue;
122 bool bValuesChanged = sal_False;
124 pDlg->GetAttr( aDlgSet );
126 aPage = ITEMVALUE( aDlgSet, ATTR_PRESENT_DIANAME, SfxStringItem );
127 if( aPage != rPresentationSettings.maPresPage )
129 bValuesChanged = true;
130 rPresentationSettings.maPresPage = aPage;
133 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem );
134 if ( bValue != rPresentationSettings.mbAll )
136 bValuesChanged = true;
137 rPresentationSettings.mbAll = bValue;
140 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem );
141 if ( bValue != rPresentationSettings.mbCustomShow )
143 bValuesChanged = true;
144 rPresentationSettings.mbCustomShow = bValue;
147 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem );
148 if ( bValue != rPresentationSettings.mbEndless )
150 bValuesChanged = true;
151 rPresentationSettings.mbEndless = bValue;
154 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem );
155 if ( bValue != rPresentationSettings.mbManual )
157 bValuesChanged = true;
158 rPresentationSettings.mbManual = bValue;
161 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem );
162 if ( bValue != rPresentationSettings.mbMouseVisible )
164 bValuesChanged = true;
165 rPresentationSettings.mbMouseVisible = bValue;
168 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem );
169 if ( bValue != rPresentationSettings.mbMouseAsPen )
171 bValuesChanged = true;
172 rPresentationSettings.mbMouseAsPen = bValue;
175 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_NAVIGATOR, SfxBoolItem );
176 if( bValue != rPresentationSettings.mbStartWithNavigator )
178 bValuesChanged = true;
179 rPresentationSettings.mbStartWithNavigator = bValue;
182 bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem );
183 if ( bValue != rPresentationSettings.mbLockedPages )
185 bValuesChanged = true;
186 rPresentationSettings.mbLockedPages = bValue;
189 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem );
190 if ( bValue != rPresentationSettings.mbAnimationAllowed )
192 bValuesChanged = true;
193 rPresentationSettings.mbAnimationAllowed = bValue;
196 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem );
197 if ( bValue != rPresentationSettings.mbAlwaysOnTop )
199 bValuesChanged = true;
200 rPresentationSettings.mbAlwaysOnTop = bValue;
203 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem );
204 if ( bValue != rPresentationSettings.mbFullScreen )
206 bValuesChanged = true;
207 rPresentationSettings.mbFullScreen = bValue;
210 nValue32 = ITEMVALUE( aDlgSet, ATTR_PRESENT_PAUSE_TIMEOUT, SfxUInt32Item );
211 if( nValue32 != rPresentationSettings.mnPauseTimeout )
213 bValuesChanged = true;
214 rPresentationSettings.mnPauseTimeout = nValue32;
217 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem );
218 if ( bValue != rPresentationSettings.mbShowPauseLogo )
220 bValuesChanged = true;
221 rPresentationSettings.mbShowPauseLogo = bValue;
224 pOptions->SetDisplay( ITEMVALUE( aDlgSet, ATTR_PRESENT_DISPLAY, SfxInt32Item ) );
226 // is something has changed, we set the modified flag
227 if ( bValuesChanged )
228 mpDoc->SetChanged( sal_True );
230 delete pDlg;
233 } // end of namespace sd
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */