Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "fusldlg.hxx"
21 : #include <svl/itemset.hxx>
22 : #include <vcl/msgbox.hxx>
23 :
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>
36 :
37 : namespace sd {
38 :
39 : #define ITEMVALUE(ItemSet,Id,Cast) static_cast<const Cast&>((ItemSet).Get(Id)).GetValue()
40 :
41 0 : TYPEINIT1( FuSlideShowDlg, FuPoor );
42 :
43 0 : FuSlideShowDlg::FuSlideShowDlg (
44 : ViewShell* pViewSh,
45 : ::sd::Window* pWin,
46 : ::sd::View* pView,
47 : SdDrawDocument* pDoc,
48 : SfxRequest& rReq)
49 0 : : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
50 : {
51 0 : }
52 :
53 0 : rtl::Reference<FuPoor> FuSlideShowDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
54 : {
55 0 : rtl::Reference<FuPoor> xFunc( new FuSlideShowDlg( pViewSh, pWin, pView, pDoc, rReq ) );
56 0 : xFunc->DoExecute(rReq);
57 0 : return xFunc;
58 : }
59 :
60 0 : void FuSlideShowDlg::DoExecute( SfxRequest& )
61 : {
62 0 : PresentationSettings& rPresentationSettings = mpDoc->getPresentationSettings();
63 :
64 0 : SfxItemSet aDlgSet( mpDoc->GetPool(), ATTR_PRESENT_START, ATTR_PRESENT_END );
65 0 : std::vector<OUString> aPageNameList(mpDoc->GetSdPageCount( PK_STANDARD ));
66 0 : const OUString& rPresPage = rPresentationSettings.maPresPage;
67 0 : OUString aFirstPage;
68 0 : SdPage* pPage = NULL;
69 : long nPage;
70 :
71 0 : for( nPage = mpDoc->GetSdPageCount( PK_STANDARD ) - 1L; nPage >= 0L; nPage-- )
72 : {
73 0 : pPage = mpDoc->GetSdPage( (sal_uInt16) nPage, PK_STANDARD );
74 0 : OUString aStr( pPage->GetName() );
75 :
76 0 : if ( aStr.isEmpty() )
77 : {
78 0 : aStr = SD_RESSTR( STR_PAGE ) + OUString::number( nPage + 1 );
79 : }
80 :
81 0 : aPageNameList[ nPage ] = aStr;
82 :
83 : // is this our (existing) first page?
84 0 : if ( rPresPage == aStr )
85 0 : aFirstPage = rPresPage;
86 0 : else if ( pPage->IsSelected() && aFirstPage.isEmpty() )
87 0 : aFirstPage = aStr;
88 0 : }
89 0 : SdCustomShowList* pCustomShowList = mpDoc->GetCustomShowList(); // No Create
90 :
91 0 : if( aFirstPage.isEmpty() && pPage )
92 0 : aFirstPage = pPage->GetName();
93 :
94 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALL, rPresentationSettings.mbAll ) );
95 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CUSTOMSHOW, rPresentationSettings.mbCustomShow ) );
96 0 : aDlgSet.Put( SfxStringItem( ATTR_PRESENT_DIANAME, aFirstPage ) );
97 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ENDLESS, rPresentationSettings.mbEndless ) );
98 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MANUEL, rPresentationSettings.mbManual ) );
99 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MOUSE, rPresentationSettings.mbMouseVisible ) );
100 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_PEN, rPresentationSettings.mbMouseAsPen ) );
101 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_NAVIGATOR, rPresentationSettings.mbStartWithNavigator ) );
102 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ANIMATION_ALLOWED, rPresentationSettings.mbAnimationAllowed ) );
103 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CHANGE_PAGE, !rPresentationSettings.mbLockedPages ) );
104 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALWAYS_ON_TOP, rPresentationSettings.mbAlwaysOnTop ) );
105 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_FULLSCREEN, rPresentationSettings.mbFullScreen ) );
106 0 : aDlgSet.Put( SfxUInt32Item( ATTR_PRESENT_PAUSE_TIMEOUT, rPresentationSettings.mnPauseTimeout ) );
107 0 : aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_SHOW_PAUSELOGO, rPresentationSettings.mbShowPauseLogo ) );
108 :
109 0 : SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
110 0 : aDlgSet.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY, pOptions->GetDisplay() ) );
111 :
112 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
113 0 : boost::scoped_ptr<AbstractSdStartPresDlg> pDlg(pFact ? pFact->CreateSdStartPresentationDlg(mpWindow, aDlgSet, aPageNameList, pCustomShowList) : 0);
114 0 : if( pDlg && (pDlg->Execute() == RET_OK) )
115 : {
116 0 : OUString aPage;
117 : long nValue32;
118 : bool bValue;
119 0 : bool bValuesChanged = false;
120 :
121 0 : pDlg->GetAttr( aDlgSet );
122 :
123 0 : aPage = ITEMVALUE( aDlgSet, ATTR_PRESENT_DIANAME, SfxStringItem );
124 0 : if( aPage != rPresentationSettings.maPresPage )
125 : {
126 0 : bValuesChanged = true;
127 0 : rPresentationSettings.maPresPage = aPage;
128 : }
129 :
130 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem );
131 0 : if ( bValue != rPresentationSettings.mbAll )
132 : {
133 0 : bValuesChanged = true;
134 0 : rPresentationSettings.mbAll = bValue;
135 : }
136 :
137 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem );
138 0 : if ( bValue != rPresentationSettings.mbCustomShow )
139 : {
140 0 : bValuesChanged = true;
141 0 : rPresentationSettings.mbCustomShow = bValue;
142 : }
143 :
144 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem );
145 0 : if ( bValue != rPresentationSettings.mbEndless )
146 : {
147 0 : bValuesChanged = true;
148 0 : rPresentationSettings.mbEndless = bValue;
149 : }
150 :
151 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem );
152 0 : if ( bValue != rPresentationSettings.mbManual )
153 : {
154 0 : bValuesChanged = true;
155 0 : rPresentationSettings.mbManual = bValue;
156 : }
157 :
158 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem );
159 0 : if ( bValue != rPresentationSettings.mbMouseVisible )
160 : {
161 0 : bValuesChanged = true;
162 0 : rPresentationSettings.mbMouseVisible = bValue;
163 : }
164 :
165 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem );
166 0 : if ( bValue != rPresentationSettings.mbMouseAsPen )
167 : {
168 0 : bValuesChanged = true;
169 0 : rPresentationSettings.mbMouseAsPen = bValue;
170 : }
171 :
172 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_NAVIGATOR, SfxBoolItem );
173 0 : if( bValue != rPresentationSettings.mbStartWithNavigator )
174 : {
175 0 : bValuesChanged = true;
176 0 : rPresentationSettings.mbStartWithNavigator = bValue;
177 : }
178 :
179 0 : bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem );
180 0 : if ( bValue != rPresentationSettings.mbLockedPages )
181 : {
182 0 : bValuesChanged = true;
183 0 : rPresentationSettings.mbLockedPages = bValue;
184 : }
185 :
186 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem );
187 0 : if ( bValue != rPresentationSettings.mbAnimationAllowed )
188 : {
189 0 : bValuesChanged = true;
190 0 : rPresentationSettings.mbAnimationAllowed = bValue;
191 : }
192 :
193 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem );
194 0 : if ( bValue != rPresentationSettings.mbAlwaysOnTop )
195 : {
196 0 : bValuesChanged = true;
197 0 : rPresentationSettings.mbAlwaysOnTop = bValue;
198 : }
199 :
200 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem );
201 0 : if ( bValue != rPresentationSettings.mbFullScreen )
202 : {
203 0 : bValuesChanged = true;
204 0 : rPresentationSettings.mbFullScreen = bValue;
205 : }
206 :
207 0 : nValue32 = ITEMVALUE( aDlgSet, ATTR_PRESENT_PAUSE_TIMEOUT, SfxUInt32Item );
208 0 : if( nValue32 != rPresentationSettings.mnPauseTimeout )
209 : {
210 0 : bValuesChanged = true;
211 0 : rPresentationSettings.mnPauseTimeout = nValue32;
212 : }
213 :
214 0 : bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem );
215 0 : if ( bValue != rPresentationSettings.mbShowPauseLogo )
216 : {
217 0 : bValuesChanged = true;
218 0 : rPresentationSettings.mbShowPauseLogo = bValue;
219 : }
220 :
221 0 : pOptions->SetDisplay( ITEMVALUE( aDlgSet, ATTR_PRESENT_DISPLAY, SfxInt32Item ) );
222 :
223 : // is something has changed, we set the modified flag
224 0 : if ( bValuesChanged )
225 0 : mpDoc->SetChanged( true );
226 0 : }
227 0 : }
228 :
229 66 : } // end of namespace sd
230 :
231 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|