xref: /AOO41X/main/sd/source/ui/func/fusldlg.cxx (revision 79aad27f7f29270c03e208e3d687e8e3850af11d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 
28 #include "fusldlg.hxx"
29 #include <svl/itemset.hxx>
30 #ifndef _MSGBOX_HXX //autogen
31 #include <vcl/msgbox.hxx>
32 #endif
33 
34 #include "drawdoc.hxx"
35 #include "sdpage.hxx"
36 #include "sdresid.hxx"
37 #include "strings.hrc"
38 #include "sdattr.hxx"
39 #include "glob.hrc"
40 #include "sdmod.hxx"
41 #include "ViewShell.hxx"
42 #include "Window.hxx"
43 #include "optsitem.hxx"
44 #include "sdabstdlg.hxx"
45 
46 namespace sd {
47 
48 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
49 
50 TYPEINIT1( FuSlideShowDlg, FuPoor );
51 
52 
53 /*************************************************************************
54 |*
55 |* Konstruktor
56 |*
57 \************************************************************************/
58 
FuSlideShowDlg(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)59 FuSlideShowDlg::FuSlideShowDlg (
60     ViewShell* pViewSh,
61     ::sd::Window* pWin,
62     ::sd::View* pView,
63     SdDrawDocument* pDoc,
64     SfxRequest& rReq)
65     : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
66 {
67 }
68 
Create(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)69 FunctionReference FuSlideShowDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
70 {
71     FunctionReference xFunc( new FuSlideShowDlg( pViewSh, pWin, pView, pDoc, rReq ) );
72     xFunc->DoExecute(rReq);
73     return xFunc;
74 }
75 
DoExecute(SfxRequest &)76 void FuSlideShowDlg::DoExecute( SfxRequest& )
77 {
78     PresentationSettings& rPresentationSettings = mpDoc->getPresentationSettings();
79 
80     SfxItemSet      aDlgSet( mpDoc->GetPool(), ATTR_PRESENT_START, ATTR_PRESENT_END );
81     List            aPageNameList;
82     const String&   rPresPage = rPresentationSettings.maPresPage;
83     String          aFirstPage;
84     String          aStandardName( SdResId( STR_PAGE ) );
85     SdPage*         pPage = NULL;
86     long            nPage;
87 
88     for( nPage = mpDoc->GetSdPageCount( PK_STANDARD ) - 1L; nPage >= 0L; nPage-- )
89     {
90         pPage = mpDoc->GetSdPage( (sal_uInt16) nPage, PK_STANDARD );
91         String* pStr = new String( pPage->GetName() );
92 
93         if ( !pStr->Len() )
94         {
95             *pStr = String( SdResId( STR_PAGE ) );
96             (*pStr).Append( UniString::CreateFromInt32( nPage + 1 ) );
97         }
98 
99         aPageNameList.Insert( pStr, (sal_uLong) 0 );
100 
101         // ist dies unsere (vorhandene) erste Seite?
102         if ( rPresPage == *pStr )
103             aFirstPage = rPresPage;
104         else if ( pPage->IsSelected() && !aFirstPage.Len() )
105             aFirstPage = *pStr;
106     }
107     List* pCustomShowList = mpDoc->GetCustomShowList(); // No Create
108 
109     sal_Bool bStartWithActualPage = SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsStartWithActualPage();
110 /* #109180# change in behaviour, even when always start with current page is enabled, range settings are
111             still used
112     if( bStartWithActualPage )
113     {
114         aFirstPage = pViewSh->GetActualPage()->GetName();
115         pCustomShowList = NULL;
116     }
117 */
118     if( !aFirstPage.Len() && pPage )
119         aFirstPage = pPage->GetName();
120 
121     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALL, rPresentationSettings.mbAll ) );
122     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CUSTOMSHOW, rPresentationSettings.mbCustomShow ) );
123     aDlgSet.Put( SfxStringItem( ATTR_PRESENT_DIANAME, aFirstPage ) );
124     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ENDLESS, rPresentationSettings.mbEndless ) );
125     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MANUEL, rPresentationSettings.mbManual ) );
126     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MOUSE, rPresentationSettings.mbMouseVisible ) );
127     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_PEN, rPresentationSettings.mbMouseAsPen ) );
128     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_NAVIGATOR, rPresentationSettings.mbStartWithNavigator ) );
129     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ANIMATION_ALLOWED, rPresentationSettings.mbAnimationAllowed ) );
130     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CHANGE_PAGE, !rPresentationSettings.mbLockedPages ) );
131     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALWAYS_ON_TOP, rPresentationSettings.mbAlwaysOnTop ) );
132     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_FULLSCREEN, rPresentationSettings.mbFullScreen ) );
133     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_START_ACTUAL_PAGE, bStartWithActualPage ) );
134     aDlgSet.Put( SfxUInt32Item( ATTR_PRESENT_PAUSE_TIMEOUT, rPresentationSettings.mnPauseTimeout ) );
135     aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_SHOW_PAUSELOGO, rPresentationSettings.mbShowPauseLogo ) );
136 
137     SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
138     aDlgSet.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY, pOptions->GetDisplay() ) );
139 
140     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
141     AbstractSdStartPresDlg* pDlg = pFact ? pFact->CreateSdStartPresentationDlg(mpWindow, aDlgSet, aPageNameList, pCustomShowList ) : 0;
142     if( pDlg && (pDlg->Execute() == RET_OK) )
143     {
144         rtl::OUString aPage;
145         long    nValue32;
146         sal_Bool bValue;
147         bool    bValuesChanged = sal_False;
148 
149         pDlg->GetAttr( aDlgSet );
150 
151         aPage = ITEMVALUE( aDlgSet, ATTR_PRESENT_DIANAME, SfxStringItem );
152         if( aPage != rPresentationSettings.maPresPage )
153         {
154             bValuesChanged = true;
155             rPresentationSettings.maPresPage = aPage;
156         }
157 
158         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem );
159         if ( bValue != rPresentationSettings.mbAll )
160         {
161             bValuesChanged = true;
162             rPresentationSettings.mbAll = bValue;
163         }
164 
165         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem );
166         if ( bValue != rPresentationSettings.mbCustomShow )
167         {
168             bValuesChanged = true;
169             rPresentationSettings.mbCustomShow = bValue;
170         }
171 
172         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem );
173         if ( bValue != rPresentationSettings.mbEndless )
174         {
175             bValuesChanged = true;
176             rPresentationSettings.mbEndless = bValue;
177         }
178 
179         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem );
180         if ( bValue != rPresentationSettings.mbManual )
181         {
182             bValuesChanged = true;
183             rPresentationSettings.mbManual = bValue;
184         }
185 
186         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem );
187         if ( bValue != rPresentationSettings.mbMouseVisible )
188         {
189             bValuesChanged = true;
190             rPresentationSettings.mbMouseVisible = bValue;
191         }
192 
193         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem );
194         if ( bValue != rPresentationSettings.mbMouseAsPen )
195         {
196             bValuesChanged = true;
197             rPresentationSettings.mbMouseAsPen = bValue;
198         }
199 
200         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_NAVIGATOR, SfxBoolItem );
201         if( bValue != rPresentationSettings.mbStartWithNavigator )
202         {
203             bValuesChanged = true;
204             rPresentationSettings.mbStartWithNavigator = bValue;
205         }
206 
207         bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem );
208         if ( bValue != rPresentationSettings.mbLockedPages )
209         {
210             bValuesChanged = true;
211             rPresentationSettings.mbLockedPages = bValue;
212         }
213 
214         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem );
215         if ( bValue != rPresentationSettings.mbAnimationAllowed )
216         {
217             bValuesChanged = true;
218             rPresentationSettings.mbAnimationAllowed = bValue;
219         }
220 
221         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem );
222         if ( bValue != rPresentationSettings.mbAlwaysOnTop )
223         {
224             bValuesChanged = true;
225             rPresentationSettings.mbAlwaysOnTop = bValue;
226         }
227 
228         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem );
229         if ( bValue != rPresentationSettings.mbFullScreen )
230         {
231             bValuesChanged = true;
232             rPresentationSettings.mbFullScreen = bValue;
233         }
234 
235         nValue32 = ITEMVALUE( aDlgSet, ATTR_PRESENT_PAUSE_TIMEOUT, SfxUInt32Item );
236         if( nValue32 != rPresentationSettings.mnPauseTimeout )
237         {
238             bValuesChanged = true;
239             rPresentationSettings.mnPauseTimeout = nValue32;
240         }
241 
242         bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem );
243         if ( bValue != rPresentationSettings.mbShowPauseLogo )
244         {
245             bValuesChanged = true;
246             rPresentationSettings.mbShowPauseLogo = bValue;
247         }
248 
249         pOptions->SetDisplay( ITEMVALUE( aDlgSet, ATTR_PRESENT_DISPLAY, SfxInt32Item ) );
250 
251         // wenn sich etwas geaendert hat, setzen wir das Modified-Flag,
252         if ( bValuesChanged )
253             mpDoc->SetChanged( sal_True );
254     }
255     delete pDlg;
256     // Strings aus Liste loeschen
257     for( void* pStr = aPageNameList.First(); pStr; pStr = aPageNameList.Next() )
258         delete (String*) pStr;
259 }
260 
261 } // end of namespace sd
262