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<String> &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( msExternalMonitor, "externalmonitor_str" );
71 0 : get( msMonitor, "monitor_str" );
72 0 : get( msAllMonitors, "allmonitors_str" );
73 :
74 0 : Link aLink( LINK( this, SdStartPresentationDlg, ChangeRangeHdl ) );
75 :
76 0 : aRbtAll->SetClickHdl( aLink );
77 0 : aRbtAtDia->SetClickHdl( aLink );
78 0 : aRbtCustomshow->SetClickHdl( aLink );
79 :
80 0 : aLink = LINK( this, SdStartPresentationDlg, ClickWindowPresentationHdl );
81 0 : aRbtStandard->SetClickHdl( aLink );
82 0 : aRbtWindow->SetClickHdl( aLink );
83 0 : aRbtAuto->SetClickHdl( aLink );
84 :
85 0 : aTmfPause->SetModifyHdl( LINK( this, SdStartPresentationDlg, ChangePauseHdl ) );
86 0 : aTmfPause->SetFormat( TIMEF_SEC );
87 :
88 : // fill Listbox with page names
89 0 : for (std::vector<String>::const_iterator pIter = rPageNames.begin(); pIter != rPageNames.end(); ++pIter)
90 0 : aLbDias->InsertEntry(*pIter);
91 :
92 0 : if( pCustomShowList )
93 : {
94 0 : sal_uInt16 nPosToSelect = (sal_uInt16) pCustomShowList->GetCurPos();
95 : SdCustomShow* pCustomShow;
96 : // fill Listbox with CustomShows
97 0 : for( pCustomShow = (SdCustomShow*) pCustomShowList->First();
98 : pCustomShow != NULL;
99 0 : pCustomShow = (SdCustomShow*) pCustomShowList->Next() )
100 : {
101 0 : aLbCustomshow->InsertEntry( pCustomShow->GetName() );
102 : }
103 0 : aLbCustomshow->SelectEntryPos( nPosToSelect );
104 0 : pCustomShowList->Seek( nPosToSelect );
105 : }
106 : else
107 0 : aRbtCustomshow->Disable();
108 :
109 0 : if( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_CUSTOMSHOW ) ).GetValue() && pCSList )
110 0 : aRbtCustomshow->Check();
111 0 : else if( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ALL ) ).GetValue() )
112 0 : aRbtAll->Check();
113 : else
114 0 : aRbtAtDia->Check();
115 :
116 0 : aLbDias->SelectEntry( ( ( const SfxStringItem& ) rOutAttrs.Get( ATTR_PRESENT_DIANAME ) ).GetValue() );
117 0 : aCbxManuel->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_MANUEL ) ).GetValue() );
118 0 : aCbxMousepointer->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_MOUSE ) ).GetValue() );
119 0 : aCbxPen->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_PEN ) ).GetValue() );
120 0 : aCbxNavigator->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_NAVIGATOR ) ).GetValue() );
121 0 : aCbxAnimationAllowed->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ANIMATION_ALLOWED ) ).GetValue() );
122 0 : aCbxChangePage->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_CHANGE_PAGE ) ).GetValue() );
123 0 : aCbxAlwaysOnTop->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ALWAYS_ON_TOP ) ).GetValue() );
124 :
125 0 : const sal_Bool bEndless = ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ENDLESS ) ).GetValue();
126 0 : const sal_Bool bWindow = !( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_FULLSCREEN ) ).GetValue();
127 0 : const long nPause = ( ( const SfxUInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_PAUSE_TIMEOUT ) ).GetValue();
128 :
129 0 : aTmfPause->SetTime( Time( 0, 0, nPause ) );
130 : // set cursor in timefield
131 0 : Edit *pEdit = aTmfPause->GetField();
132 0 : Selection aSel( pEdit->GetMaxTextLen(), pEdit->GetMaxTextLen() );
133 0 : pEdit->SetSelection( aSel );
134 :
135 0 : aCbxAutoLogo->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_SHOW_PAUSELOGO ) ).GetValue() );
136 :
137 0 : if( bWindow )
138 0 : aRbtWindow->Check( sal_True );
139 0 : else if( bEndless )
140 0 : aRbtAuto->Check( sal_True );
141 : else
142 0 : aRbtStandard->Check( sal_True );
143 :
144 0 : InitMonitorSettings();
145 :
146 0 : ChangeRangeHdl( this );
147 :
148 0 : ClickWindowPresentationHdl( NULL );
149 0 : ChangePauseHdl( NULL );
150 0 : }
151 :
152 0 : void SdStartPresentationDlg::InitMonitorSettings()
153 : {
154 : try
155 : {
156 0 : maFtMonitor->Show( true );
157 0 : maLBMonitor->Show( true );
158 :
159 0 : mnMonitors = Application::GetScreenCount();
160 :
161 0 : if( mnMonitors <= 1 )
162 : {
163 0 : maFtMonitor->Enable( false );
164 0 : maLBMonitor->Enable( false );
165 : }
166 : else
167 : {
168 0 : sal_Bool bUnifiedDisplay = Application::IsUnifiedDisplay();
169 0 : sal_Int32 nExternalIndex = Application::GetDisplayExternalScreen();
170 :
171 0 : sal_Int32 nSelectedIndex (-1);
172 0 : sal_Int32 nDefaultExternalIndex (-1);
173 : const sal_Int32 nDefaultSelectedDisplay (
174 0 : ( ( const SfxInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue());
175 0 : const String sPlaceHolder( "%1" );
176 0 : for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ )
177 : {
178 : String aName( nDisplay == nExternalIndex ?
179 0 : msExternalMonitor->GetText() :
180 0 : msMonitor->GetText() );
181 0 : const String aNumber( OUString::number( nDisplay + 1 ) );
182 0 : aName.SearchAndReplace( sPlaceHolder, aNumber );
183 0 : maLBMonitor->InsertEntry( aName );
184 :
185 : // Store display index together with name.
186 0 : const sal_uInt32 nEntryIndex (maLBMonitor->GetEntryCount()-1);
187 0 : maLBMonitor->SetEntryData(nEntryIndex, (void*)(sal_IntPtr)nDisplay);
188 :
189 : // Remember the index of the default selection.
190 0 : if (nDefaultSelectedDisplay == nDisplay)
191 0 : nSelectedIndex = nEntryIndex;
192 :
193 : // Remember index of the default display.
194 0 : if (nDisplay == nExternalIndex)
195 0 : nDefaultExternalIndex = nEntryIndex;
196 0 : }
197 :
198 0 : if( bUnifiedDisplay )
199 : {
200 0 : maLBMonitor->InsertEntry( msAllMonitors->GetText() );
201 0 : const sal_uInt32 nEntryIndex (maLBMonitor->GetEntryCount()-1);
202 0 : maLBMonitor->SetEntryData(nEntryIndex, (void*)-1);
203 0 : if (nDefaultSelectedDisplay == -1)
204 0 : nSelectedIndex = nEntryIndex;
205 : }
206 :
207 0 : if (nSelectedIndex < 0)
208 : {
209 0 : if (nExternalIndex < 0)
210 0 : nSelectedIndex = 0;
211 : else
212 0 : nSelectedIndex = nDefaultExternalIndex;
213 : }
214 :
215 0 : maLBMonitor->SelectEntryPos((sal_uInt16)nSelectedIndex);
216 : }
217 : }
218 0 : catch( Exception& )
219 : {
220 : }
221 0 : }
222 :
223 : /**
224 : * sets the selected attributes of the dialog
225 : */
226 0 : void SdStartPresentationDlg::GetAttr( SfxItemSet& rAttr )
227 : {
228 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALL, aRbtAll->IsChecked() ) );
229 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CUSTOMSHOW, aRbtCustomshow->IsChecked() ) );
230 0 : rAttr.Put( SfxStringItem ( ATTR_PRESENT_DIANAME, aLbDias->GetSelectEntry() ) );
231 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MANUEL, aCbxManuel->IsChecked() ) );
232 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MOUSE, aCbxMousepointer->IsChecked() ) );
233 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_PEN, aCbxPen->IsChecked() ) );
234 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_NAVIGATOR, aCbxNavigator->IsChecked() ) );
235 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ANIMATION_ALLOWED, aCbxAnimationAllowed->IsChecked() ) );
236 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CHANGE_PAGE, aCbxChangePage->IsChecked() ) );
237 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALWAYS_ON_TOP, aCbxAlwaysOnTop->IsChecked() ) );
238 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_FULLSCREEN, !aRbtWindow->IsChecked() ) );
239 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ENDLESS, aRbtAuto->IsChecked() ) );
240 0 : rAttr.Put( SfxUInt32Item ( ATTR_PRESENT_PAUSE_TIMEOUT, aTmfPause->GetTime().GetMSFromTime() / 1000 ) );
241 0 : rAttr.Put( SfxBoolItem ( ATTR_PRESENT_SHOW_PAUSELOGO, aCbxAutoLogo->IsChecked() ) );
242 :
243 0 : sal_uInt16 nPos = maLBMonitor->GetSelectEntryPos();
244 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
245 0 : rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, (sal_Int32)(sal_IntPtr)maLBMonitor->GetEntryData(nPos)) );
246 :
247 0 : nPos = aLbCustomshow->GetSelectEntryPos();
248 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
249 0 : pCustomShowList->Seek( nPos );
250 0 : }
251 :
252 : /**
253 : * Handler: Enabled/Disabled Listbox "Dias"
254 : */
255 0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangeRangeHdl)
256 : {
257 0 : aLbDias->Enable( aRbtAtDia->IsChecked() );
258 0 : aLbCustomshow->Enable( aRbtCustomshow->IsChecked() );
259 :
260 0 : return( 0L );
261 : }
262 :
263 : /**
264 : * Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
265 : */
266 0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ClickWindowPresentationHdl)
267 : {
268 0 : const bool bAuto = aRbtAuto->IsChecked();
269 0 : const bool bWindow = aRbtWindow->IsChecked();
270 :
271 : // aFtPause.Enable( bAuto );
272 0 : aTmfPause->Enable( bAuto );
273 0 : aCbxAutoLogo->Enable( bAuto && ( aTmfPause->GetTime().GetMSFromTime() > 0 ) );
274 :
275 0 : const bool bDisplay = !bWindow && ( mnMonitors > 1 );
276 0 : maFtMonitor->Enable( bDisplay );
277 0 : maLBMonitor->Enable( bDisplay );
278 :
279 0 : if( bWindow )
280 : {
281 0 : aCbxAlwaysOnTop->Enable( sal_False );
282 0 : aCbxAlwaysOnTop->Check( sal_False );
283 : }
284 : else
285 0 : aCbxAlwaysOnTop->Enable();
286 :
287 0 : return( 0L );
288 : }
289 :
290 : /**
291 : * Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
292 : */
293 0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangePauseHdl)
294 : {
295 0 : aCbxAutoLogo->Enable( aRbtAuto->IsChecked() && ( aTmfPause->GetTime().GetMSFromTime() > 0 ) );
296 0 : return( 0L );
297 0 : }
298 :
299 :
300 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|