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 <com/sun/star/lang/XMultiServiceFactory.hpp>
21 : #include <com/sun/star/beans/XPropertySet.hpp>
22 : #include <com/sun/star/container/XIndexAccess.hpp>
23 : #include <comphelper/processfactory.hxx>
24 : #include <svl/itemset.hxx>
25 : #include <vcl/svapp.hxx>
26 :
27 : #include "sdattr.hxx"
28 : #include "present.hxx"
29 : #include "sdresid.hxx"
30 : #include "cusshow.hxx"
31 : #include "customshowlist.hxx"
32 :
33 : using namespace ::com::sun::star::uno;
34 : using namespace ::com::sun::star::lang;
35 : using namespace ::com::sun::star::container;
36 : using namespace ::com::sun::star::beans;
37 :
38 0 : SdStartPresentationDlg::SdStartPresentationDlg( vcl::Window* pWindow,
39 : const SfxItemSet& rInAttrs,
40 : const std::vector<OUString> &rPageNames, SdCustomShowList* pCSList ) :
41 : ModalDialog ( pWindow, "PresentationDialog", "modules/simpress/ui/presentationdialog.ui" ),
42 : pCustomShowList ( pCSList ),
43 : rOutAttrs ( rInAttrs ),
44 0 : mnMonitors ( 0 )
45 : {
46 0 : get( aRbtAll, "allslides" );
47 0 : get( aRbtAtDia, "from" );
48 0 : get( aRbtCustomshow, "customslideshow" );
49 0 : get( aLbDias, "from_cb" );
50 0 : get( aLbCustomshow, "customslideshow_cb" );
51 :
52 0 : get( aRbtStandard, "default" );
53 0 : get( aRbtWindow, "window" );
54 0 : get( aRbtAuto, "auto" );
55 0 : get( aTmfPause, "pauseduration" );
56 0 : get( aCbxAutoLogo, "showlogo" );
57 :
58 0 : get( aCbxManuel, "manualslides" );
59 0 : get( aCbxMousepointer, "pointervisible" );
60 0 : get( aCbxPen, "pointeraspen" );
61 0 : get( aCbxNavigator, "navigatorvisible" );
62 0 : get( aCbxAnimationAllowed, "animationsallowed" );
63 0 : get( aCbxChangePage, "changeslidesbyclick" );
64 0 : get( aCbxAlwaysOnTop, "alwaysontop" );
65 :
66 0 : get( maFtMonitor, "presdisplay_label" );
67 0 : get( maLBMonitor, "presdisplay_cb" );
68 :
69 0 : get( msMonitor, "monitor_str" );
70 0 : get( msMonitorExternal, "externalmonitor_str" );
71 0 : get( msExternal, "external_str" );
72 0 : get( msMonitor, "monitor_str" );
73 0 : get( msAllMonitors, "allmonitors_str" );
74 :
75 0 : Link<> aLink( LINK( this, SdStartPresentationDlg, ChangeRangeHdl ) );
76 :
77 0 : aRbtAll->SetClickHdl( aLink );
78 0 : aRbtAtDia->SetClickHdl( aLink );
79 0 : aRbtCustomshow->SetClickHdl( aLink );
80 :
81 0 : aLink = LINK( this, SdStartPresentationDlg, ClickWindowPresentationHdl );
82 0 : aRbtStandard->SetClickHdl( aLink );
83 0 : aRbtWindow->SetClickHdl( aLink );
84 0 : aRbtAuto->SetClickHdl( aLink );
85 :
86 0 : aTmfPause->SetModifyHdl( LINK( this, SdStartPresentationDlg, ChangePauseHdl ) );
87 0 : aTmfPause->SetFormat( TimeFieldFormat::F_SEC );
88 :
89 : // fill Listbox with page names
90 0 : for (std::vector<OUString>::const_iterator pIter = rPageNames.begin(); pIter != rPageNames.end(); ++pIter)
91 0 : aLbDias->InsertEntry(*pIter);
92 :
93 0 : if( pCustomShowList )
94 : {
95 0 : sal_uInt16 nPosToSelect = (sal_uInt16) pCustomShowList->GetCurPos();
96 : SdCustomShow* pCustomShow;
97 : // fill Listbox with CustomShows
98 0 : for( pCustomShow = pCustomShowList->First();
99 : pCustomShow != NULL;
100 0 : pCustomShow = pCustomShowList->Next() )
101 : {
102 0 : aLbCustomshow->InsertEntry( pCustomShow->GetName() );
103 : }
104 0 : aLbCustomshow->SelectEntryPos( nPosToSelect );
105 0 : pCustomShowList->Seek( nPosToSelect );
106 : }
107 : else
108 0 : aRbtCustomshow->Disable();
109 :
110 0 : if( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_CUSTOMSHOW ) ).GetValue() && pCSList )
111 0 : aRbtCustomshow->Check();
112 0 : else if( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_ALL ) ).GetValue() )
113 0 : aRbtAll->Check();
114 : else
115 0 : aRbtAtDia->Check();
116 :
117 0 : aLbDias->SelectEntry( static_cast<const SfxStringItem&>( rOutAttrs.Get( ATTR_PRESENT_DIANAME ) ).GetValue() );
118 0 : aCbxManuel->Check( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_MANUEL ) ).GetValue() );
119 0 : aCbxMousepointer->Check( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_MOUSE ) ).GetValue() );
120 0 : aCbxPen->Check( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_PEN ) ).GetValue() );
121 0 : aCbxNavigator->Check( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_NAVIGATOR ) ).GetValue() );
122 0 : aCbxAnimationAllowed->Check( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_ANIMATION_ALLOWED ) ).GetValue() );
123 0 : aCbxChangePage->Check( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_CHANGE_PAGE ) ).GetValue() );
124 0 : aCbxAlwaysOnTop->Check( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_ALWAYS_ON_TOP ) ).GetValue() );
125 :
126 0 : const bool bEndless = static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_ENDLESS ) ).GetValue();
127 0 : const bool bWindow = !static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_FULLSCREEN ) ).GetValue();
128 0 : const long nPause = static_cast<const SfxUInt32Item&>( rOutAttrs.Get( ATTR_PRESENT_PAUSE_TIMEOUT ) ).GetValue();
129 :
130 0 : aTmfPause->SetTime( tools::Time( 0, 0, nPause ) );
131 : // set cursor in timefield
132 0 : Edit *pEdit = aTmfPause->GetField();
133 0 : Selection aSel( pEdit->GetMaxTextLen(), pEdit->GetMaxTextLen() );
134 0 : pEdit->SetSelection( aSel );
135 :
136 0 : aCbxAutoLogo->Check( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_SHOW_PAUSELOGO ) ).GetValue() );
137 :
138 0 : if( bWindow )
139 0 : aRbtWindow->Check( true );
140 0 : else if( bEndless )
141 0 : aRbtAuto->Check( true );
142 : else
143 0 : aRbtStandard->Check( true );
144 :
145 0 : InitMonitorSettings();
146 :
147 0 : ChangeRangeHdl( this );
148 :
149 0 : ClickWindowPresentationHdl( NULL );
150 0 : ChangePauseHdl( NULL );
151 0 : }
152 :
153 0 : SdStartPresentationDlg::~SdStartPresentationDlg()
154 : {
155 0 : disposeOnce();
156 0 : }
157 :
158 0 : void SdStartPresentationDlg::dispose()
159 : {
160 0 : aRbtAll.clear();
161 0 : aRbtAtDia.clear();
162 0 : aRbtCustomshow.clear();
163 0 : aLbDias.clear();
164 0 : aLbCustomshow.clear();
165 0 : aRbtStandard.clear();
166 0 : aRbtWindow.clear();
167 0 : aRbtAuto.clear();
168 0 : aTmfPause.clear();
169 0 : aCbxAutoLogo.clear();
170 0 : aCbxManuel.clear();
171 0 : aCbxMousepointer.clear();
172 0 : aCbxPen.clear();
173 0 : aCbxNavigator.clear();
174 0 : aCbxAnimationAllowed.clear();
175 0 : aCbxChangePage.clear();
176 0 : aCbxAlwaysOnTop.clear();
177 0 : maFtMonitor.clear();
178 0 : maLBMonitor.clear();
179 0 : msMonitor.clear();
180 0 : msAllMonitors.clear();
181 0 : msMonitorExternal.clear();
182 0 : msExternal.clear();
183 0 : ModalDialog::dispose();
184 0 : }
185 :
186 0 : OUString SdStartPresentationDlg::GetDisplayName( sal_Int32 nDisplay,
187 : DisplayType eType )
188 : {
189 0 : OUString aName;
190 :
191 0 : switch ( eType )
192 : {
193 : case EXTERNAL_IS_NUMBER:
194 0 : aName = msExternal->GetText();
195 0 : break;
196 : case MONITOR_IS_EXTERNAL:
197 0 : aName = msMonitorExternal->GetText();
198 0 : break;
199 : default:
200 : case MONITOR_NORMAL:
201 0 : aName = msMonitor->GetText();
202 0 : break;
203 : }
204 0 : aName = aName.replaceFirst( "%1", OUString::number( nDisplay ) );
205 :
206 0 : return aName;
207 : }
208 :
209 : /// Store display index together with name in user data
210 0 : sal_Int32 SdStartPresentationDlg::InsertDisplayEntry(const rtl::OUString &aName,
211 : sal_Int32 nDisplay)
212 : {
213 0 : maLBMonitor->InsertEntry( aName );
214 0 : const sal_uInt32 nEntryIndex = maLBMonitor->GetEntryCount() - 1;
215 0 : maLBMonitor->SetEntryData( nEntryIndex, reinterpret_cast<void*>((sal_IntPtr)nDisplay) );
216 :
217 0 : return nEntryIndex;
218 : }
219 :
220 0 : void SdStartPresentationDlg::InitMonitorSettings()
221 : {
222 : try
223 : {
224 0 : maFtMonitor->Show( true );
225 0 : maLBMonitor->Show( true );
226 :
227 0 : mnMonitors = Application::GetScreenCount();
228 :
229 0 : if( mnMonitors <= 1 )
230 : {
231 0 : maFtMonitor->Enable( false );
232 0 : maLBMonitor->Enable( false );
233 : }
234 : else
235 : {
236 0 : bool bUnifiedDisplay = Application::IsUnifiedDisplay();
237 0 : sal_Int32 nExternalIndex = Application::GetDisplayExternalScreen();
238 :
239 0 : sal_Int32 nSelectedIndex (-1);
240 0 : sal_Int32 nDefaultExternalIndex (-1);
241 : const sal_Int32 nDefaultSelectedDisplay (
242 0 : static_cast<const SfxInt32Item&>( rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue());
243 :
244 : // Un-conditionally add a version for '0' the default external display
245 : sal_Int32 nInsertedEntry;
246 :
247 : // Initial entry - the auto-detected external monitor
248 0 : OUString aName = GetDisplayName( nExternalIndex + 1, EXTERNAL_IS_NUMBER);
249 0 : nInsertedEntry = InsertDisplayEntry( aName, 0 );
250 0 : if( nDefaultSelectedDisplay == 0)
251 0 : nSelectedIndex = nInsertedEntry;
252 :
253 : // The user data contains the real setting
254 0 : for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ )
255 : {
256 0 : aName = GetDisplayName( nDisplay + 1,
257 : nDisplay == nExternalIndex ?
258 0 : MONITOR_IS_EXTERNAL : MONITOR_NORMAL );
259 0 : nInsertedEntry = InsertDisplayEntry( aName, nDisplay + 1 );
260 :
261 : // Remember the index of the default selection.
262 0 : if( nDisplay + 1 == nDefaultSelectedDisplay )
263 0 : nSelectedIndex = nInsertedEntry;
264 :
265 : // Remember index of the default display.
266 0 : if( nDisplay == nExternalIndex )
267 0 : nDefaultExternalIndex = nInsertedEntry;
268 : }
269 :
270 0 : if( bUnifiedDisplay )
271 : {
272 0 : nInsertedEntry = InsertDisplayEntry( msAllMonitors->GetText(), -1 );
273 0 : if( nDefaultSelectedDisplay == -1 )
274 0 : nSelectedIndex = nInsertedEntry;
275 : }
276 :
277 0 : if (nSelectedIndex < 0)
278 : {
279 0 : if (nExternalIndex < 0)
280 0 : nSelectedIndex = 0;
281 : else
282 0 : nSelectedIndex = nDefaultExternalIndex;
283 : }
284 :
285 0 : maLBMonitor->SelectEntryPos(nSelectedIndex);
286 : }
287 : }
288 0 : catch( Exception& )
289 : {
290 : }
291 0 : }
292 :
293 : /**
294 : * sets the selected attributes of the dialog
295 : */
296 0 : void SdStartPresentationDlg::GetAttr( SfxItemSet& rAttr )
297 : {
298 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALL, aRbtAll->IsChecked() ) );
299 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CUSTOMSHOW, aRbtCustomshow->IsChecked() ) );
300 0 : rAttr.Put( SfxStringItem ( ATTR_PRESENT_DIANAME, aLbDias->GetSelectEntry() ) );
301 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MANUEL, aCbxManuel->IsChecked() ) );
302 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MOUSE, aCbxMousepointer->IsChecked() ) );
303 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_PEN, aCbxPen->IsChecked() ) );
304 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_NAVIGATOR, aCbxNavigator->IsChecked() ) );
305 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ANIMATION_ALLOWED, aCbxAnimationAllowed->IsChecked() ) );
306 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CHANGE_PAGE, aCbxChangePage->IsChecked() ) );
307 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALWAYS_ON_TOP, aCbxAlwaysOnTop->IsChecked() ) );
308 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_FULLSCREEN, !aRbtWindow->IsChecked() ) );
309 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ENDLESS, aRbtAuto->IsChecked() ) );
310 0 : rAttr.Put( SfxUInt32Item ( ATTR_PRESENT_PAUSE_TIMEOUT, aTmfPause->GetTime().GetMSFromTime() / 1000 ) );
311 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_SHOW_PAUSELOGO, aCbxAutoLogo->IsChecked() ) );
312 :
313 0 : sal_Int32 nPos = maLBMonitor->GetSelectEntryPos();
314 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
315 0 : rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, (sal_Int32)reinterpret_cast<sal_IntPtr>(maLBMonitor->GetEntryData(nPos))) );
316 :
317 0 : nPos = aLbCustomshow->GetSelectEntryPos();
318 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
319 0 : pCustomShowList->Seek( nPos );
320 0 : }
321 :
322 : /**
323 : * Handler: Enabled/Disabled Listbox "Dias"
324 : */
325 0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangeRangeHdl)
326 : {
327 0 : aLbDias->Enable( aRbtAtDia->IsChecked() );
328 0 : aLbCustomshow->Enable( aRbtCustomshow->IsChecked() );
329 :
330 0 : return 0L;
331 : }
332 :
333 : /**
334 : * Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
335 : */
336 0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ClickWindowPresentationHdl)
337 : {
338 0 : const bool bAuto = aRbtAuto->IsChecked();
339 0 : const bool bWindow = aRbtWindow->IsChecked();
340 :
341 : // aFtPause.Enable( bAuto );
342 0 : aTmfPause->Enable( bAuto );
343 0 : aCbxAutoLogo->Enable( bAuto && ( aTmfPause->GetTime().GetMSFromTime() > 0 ) );
344 :
345 0 : const bool bDisplay = !bWindow && ( mnMonitors > 1 );
346 0 : maFtMonitor->Enable( bDisplay );
347 0 : maLBMonitor->Enable( bDisplay );
348 :
349 0 : if( bWindow )
350 : {
351 0 : aCbxAlwaysOnTop->Enable( false );
352 0 : aCbxAlwaysOnTop->Check( false );
353 : }
354 : else
355 0 : aCbxAlwaysOnTop->Enable();
356 :
357 0 : return 0L;
358 : }
359 :
360 : /**
361 : * Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
362 : */
363 0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangePauseHdl)
364 : {
365 0 : aCbxAutoLogo->Enable( aRbtAuto->IsChecked() && ( aTmfPause->GetTime().GetMSFromTime() > 0 ) );
366 0 : return 0L;
367 0 : }
368 :
369 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|