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