bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / func / fusldlg.cxx
blobb62eb9b888027cb6c1ffe0a5961bfd049aedd620
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"
35 #include <boost/scoped_ptr.hpp>
37 namespace sd {
39 #define ITEMVALUE(ItemSet,Id,Cast) static_cast<const Cast&>((ItemSet).Get(Id)).GetValue()
41 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 rtl::Reference<FuPoor> FuSlideShowDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
55 rtl::Reference<FuPoor> 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<OUString> aPageNameList(mpDoc->GetSdPageCount( PK_STANDARD ));
66 const OUString& rPresPage = rPresentationSettings.maPresPage;
67 OUString 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 OUString aStr( pPage->GetName() );
76 if ( aStr.isEmpty() )
78 aStr = SD_RESSTR( STR_PAGE ) + OUString::number( nPage + 1 );
81 aPageNameList[ nPage ] = aStr;
83 // is this our (existing) first page?
84 if ( rPresPage == aStr )
85 aFirstPage = rPresPage;
86 else if ( pPage->IsSelected() && aFirstPage.isEmpty() )
87 aFirstPage = aStr;
89 SdCustomShowList* pCustomShowList = mpDoc->GetCustomShowList(); // No Create
91 if( aFirstPage.isEmpty() && pPage )
92 aFirstPage = pPage->GetName();
94 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALL, rPresentationSettings.mbAll ) );
95 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CUSTOMSHOW, rPresentationSettings.mbCustomShow ) );
96 aDlgSet.Put( SfxStringItem( ATTR_PRESENT_DIANAME, aFirstPage ) );
97 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ENDLESS, rPresentationSettings.mbEndless ) );
98 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MANUEL, rPresentationSettings.mbManual ) );
99 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MOUSE, rPresentationSettings.mbMouseVisible ) );
100 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_PEN, rPresentationSettings.mbMouseAsPen ) );
101 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_NAVIGATOR, rPresentationSettings.mbStartWithNavigator ) );
102 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ANIMATION_ALLOWED, rPresentationSettings.mbAnimationAllowed ) );
103 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CHANGE_PAGE, !rPresentationSettings.mbLockedPages ) );
104 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALWAYS_ON_TOP, rPresentationSettings.mbAlwaysOnTop ) );
105 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_FULLSCREEN, rPresentationSettings.mbFullScreen ) );
106 aDlgSet.Put( SfxUInt32Item( ATTR_PRESENT_PAUSE_TIMEOUT, rPresentationSettings.mnPauseTimeout ) );
107 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_SHOW_PAUSELOGO, rPresentationSettings.mbShowPauseLogo ) );
109 SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
110 aDlgSet.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY, pOptions->GetDisplay() ) );
112 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
113 boost::scoped_ptr<AbstractSdStartPresDlg> pDlg(pFact ? pFact->CreateSdStartPresentationDlg(mpWindow, aDlgSet, aPageNameList, pCustomShowList) : 0);
114 if( pDlg && (pDlg->Execute() == RET_OK) )
116 OUString aPage;
117 long nValue32;
118 bool bValue;
119 bool bValuesChanged = false;
121 pDlg->GetAttr( aDlgSet );
123 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem );
124 if ( bValue != rPresentationSettings.mbAll )
126 bValuesChanged = true;
127 rPresentationSettings.mbAll = bValue;
128 // remove any previous existing slide
129 rPresentationSettings.maPresPage = "";
132 if (!rPresentationSettings.mbAll)
134 aPage = ITEMVALUE( aDlgSet, ATTR_PRESENT_DIANAME, SfxStringItem );
135 if( aPage != rPresentationSettings.maPresPage )
137 bValuesChanged = true;
138 rPresentationSettings.maPresPage = aPage;
142 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem );
143 if ( bValue != rPresentationSettings.mbCustomShow )
145 bValuesChanged = true;
146 rPresentationSettings.mbCustomShow = bValue;
149 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem );
150 if ( bValue != rPresentationSettings.mbEndless )
152 bValuesChanged = true;
153 rPresentationSettings.mbEndless = bValue;
156 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem );
157 if ( bValue != rPresentationSettings.mbManual )
159 bValuesChanged = true;
160 rPresentationSettings.mbManual = bValue;
163 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem );
164 if ( bValue != rPresentationSettings.mbMouseVisible )
166 bValuesChanged = true;
167 rPresentationSettings.mbMouseVisible = bValue;
170 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem );
171 if ( bValue != rPresentationSettings.mbMouseAsPen )
173 bValuesChanged = true;
174 rPresentationSettings.mbMouseAsPen = bValue;
177 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_NAVIGATOR, SfxBoolItem );
178 if( bValue != rPresentationSettings.mbStartWithNavigator )
180 bValuesChanged = true;
181 rPresentationSettings.mbStartWithNavigator = bValue;
184 bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem );
185 if ( bValue != rPresentationSettings.mbLockedPages )
187 bValuesChanged = true;
188 rPresentationSettings.mbLockedPages = bValue;
191 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem );
192 if ( bValue != rPresentationSettings.mbAnimationAllowed )
194 bValuesChanged = true;
195 rPresentationSettings.mbAnimationAllowed = bValue;
198 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem );
199 if ( bValue != rPresentationSettings.mbAlwaysOnTop )
201 bValuesChanged = true;
202 rPresentationSettings.mbAlwaysOnTop = bValue;
205 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem );
206 if ( bValue != rPresentationSettings.mbFullScreen )
208 bValuesChanged = true;
209 rPresentationSettings.mbFullScreen = bValue;
212 nValue32 = ITEMVALUE( aDlgSet, ATTR_PRESENT_PAUSE_TIMEOUT, SfxUInt32Item );
213 if( nValue32 != rPresentationSettings.mnPauseTimeout )
215 bValuesChanged = true;
216 rPresentationSettings.mnPauseTimeout = nValue32;
219 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem );
220 if ( bValue != rPresentationSettings.mbShowPauseLogo )
222 bValuesChanged = true;
223 rPresentationSettings.mbShowPauseLogo = bValue;
226 pOptions->SetDisplay( ITEMVALUE( aDlgSet, ATTR_PRESENT_DISPLAY, SfxInt32Item ) );
228 // is something has changed, we set the modified flag
229 if ( bValuesChanged )
230 mpDoc->SetChanged( true );
234 } // end of namespace sd
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */