LibreOffice Module sd (master) 1
present.cxx
Go to the documentation of this file.
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 <svl/itemset.hxx>
21#include <svl/intitem.hxx>
22#include <svl/eitem.hxx>
23#include <svl/stritem.hxx>
24#include <vcl/svapp.hxx>
25
26#include <sdattr.hrc>
27#include <present.hxx>
28#include <cusshow.hxx>
29#include <customshowlist.hxx>
30
31using namespace ::com::sun::star::uno;
32using namespace ::com::sun::star::lang;
33
35 const std::vector<OUString> &rPageNames, SdCustomShowList* pCSList)
36 : GenericDialogController(pWindow, "modules/simpress/ui/presentationdialog.ui", "PresentationDialog")
37 , pCustomShowList(pCSList)
38 , rOutAttrs(rInAttrs)
39 , mnMonitors(0)
40 , m_xRbtAll(m_xBuilder->weld_radio_button("allslides"))
41 , m_xRbtAtDia(m_xBuilder->weld_radio_button("from"))
42 , m_xRbtCustomshow(m_xBuilder->weld_radio_button("customslideshow"))
43 , m_xLbDias(m_xBuilder->weld_combo_box("from_cb"))
44 , m_xLbCustomshow(m_xBuilder->weld_combo_box("customslideshow_cb"))
45 , m_xRbtStandard(m_xBuilder->weld_radio_button("default"))
46 , m_xRbtWindow(m_xBuilder->weld_radio_button("window"))
47 , m_xRbtAuto(m_xBuilder->weld_radio_button("auto"))
48 , m_xTmfPause(m_xBuilder->weld_formatted_spin_button("pauseduration"))
49 , m_xFormatter(new weld::TimeFormatter(*m_xTmfPause))
50 , m_xCbxAutoLogo(m_xBuilder->weld_check_button("showlogo"))
51 , m_xCbxManuel(m_xBuilder->weld_check_button("manualslides"))
52 , m_xCbxMousepointer(m_xBuilder->weld_check_button("pointervisible"))
53 , m_xCbxPen(m_xBuilder->weld_check_button("pointeraspen"))
54 , m_xCbxAnimationAllowed(m_xBuilder->weld_check_button("animationsallowed"))
55 , m_xCbxChangePage(m_xBuilder->weld_check_button("changeslidesbyclick"))
56 , m_xCbxAlwaysOnTop(m_xBuilder->weld_check_button("alwaysontop"))
57 , m_xCbxShowNavigationButton(m_xBuilder->weld_check_button("shownavigationbutton"))
58 , m_xFtMonitor(m_xBuilder->weld_label("presdisplay_label"))
59 , m_xLBMonitor(m_xBuilder->weld_combo_box("presdisplay_cb"))
60 , m_xMonitor(m_xBuilder->weld_label("monitor_str"))
61 , m_xAllMonitors(m_xBuilder->weld_label("allmonitors_str"))
62 , m_xMonitorExternal(m_xBuilder->weld_label("externalmonitor_str"))
63 , m_xExternal(m_xBuilder->weld_label("external_str"))
64{
65 m_xFormatter->SetExtFormat(ExtTimeFieldFormat::LongDuration);
66 m_xFormatter->EnableEmptyField(false);
67
68 Link<weld::Toggleable&,void> aLink( LINK( this, SdStartPresentationDlg, ChangeRangeHdl ) );
69
70 m_xRbtAll->connect_toggled( aLink );
71 m_xRbtAtDia->connect_toggled( aLink );
72 m_xRbtCustomshow->connect_toggled( aLink );
73
74 aLink = LINK( this, SdStartPresentationDlg, ClickWindowPresentationHdl );
75 m_xRbtStandard->connect_toggled( aLink );
76 m_xRbtWindow->connect_toggled( aLink );
77 m_xRbtAuto->connect_toggled( aLink );
78
79 m_xTmfPause->connect_value_changed( LINK( this, SdStartPresentationDlg, ChangePauseHdl ) );
80
81 // fill Listbox with page names
82 for (const auto& rPageName : rPageNames)
83 m_xLbDias->append_text(rPageName);
84
85 if( pCustomShowList )
86 {
87 sal_uInt16 nPosToSelect = pCustomShowList->GetCurPos();
88 SdCustomShow* pCustomShow;
89 // fill Listbox with CustomShows
90 for( pCustomShow = pCustomShowList->First();
91 pCustomShow != nullptr;
92 pCustomShow = pCustomShowList->Next() )
93 {
94 m_xLbCustomshow->append_text( pCustomShow->GetName() );
95 }
96 m_xLbCustomshow->set_active( nPosToSelect );
97 pCustomShowList->Seek( nPosToSelect );
98 }
99 else
100 m_xRbtCustomshow->set_sensitive(false);
101
102 if( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_CUSTOMSHOW ) ).GetValue() && pCSList )
103 m_xRbtCustomshow->set_active(true);
104 else if( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_ALL ) ).GetValue() )
105 m_xRbtAll->set_active(true);
106 else
107 m_xRbtAtDia->set_active(true);
108
109 m_xLbDias->set_active_text( rOutAttrs.Get( ATTR_PRESENT_DIANAME ).GetValue() );
110 m_xCbxManuel->set_active( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_MANUEL ) ).GetValue() );
111 m_xCbxMousepointer->set_active( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_MOUSE ) ).GetValue() );
112 m_xCbxPen->set_active( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_PEN ) ).GetValue() );
113 m_xCbxAnimationAllowed->set_active( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_ANIMATION_ALLOWED ) ).GetValue() );
114 m_xCbxChangePage->set_active( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_CHANGE_PAGE ) ).GetValue() );
115 m_xCbxAlwaysOnTop->set_active( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_ALWAYS_ON_TOP ) ).GetValue() );
116 m_xCbxShowNavigationButton->set_active( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_SHOW_NAVIGATION_BUTTONS) ).GetValue() );
117
118 const bool bEndless = static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_ENDLESS ) ).GetValue();
119 const bool bWindow = !static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_FULLSCREEN ) ).GetValue();
120 const tools::Long nPause = rOutAttrs.Get( ATTR_PRESENT_PAUSE_TIMEOUT ).GetValue();
121
122 m_xFormatter->SetTime( tools::Time( 0, 0, nPause ) );
123 // set cursor in timefield to end
124 m_xTmfPause->set_position(-1);
125
126 m_xCbxAutoLogo->set_active( static_cast<const SfxBoolItem&>( rOutAttrs.Get( ATTR_PRESENT_SHOW_PAUSELOGO ) ).GetValue() );
127
128 if( bWindow )
129 m_xRbtWindow->set_active(true);
130 else if( bEndless )
131 m_xRbtAuto->set_active(true);
132 else
133 m_xRbtStandard->set_active(true);
134
136
137 ChangeRangeHdl(*m_xRbtCustomshow);
138
139 ClickWindowPresentationHdl(*m_xRbtStandard);
140 ChangePause();
141}
142
144{
145}
146
147OUString SdStartPresentationDlg::GetDisplayName( sal_Int32 nDisplay,
148 DisplayType eType )
149{
150 OUString aName;
151
152 switch ( eType )
153 {
155 aName = m_xExternal->get_label();
156 break;
158 aName = m_xMonitorExternal->get_label();
159 break;
160 default:
161 case MONITOR_NORMAL:
162 aName = m_xMonitor->get_label();
163 break;
164 }
165 aName = aName.replaceFirst( "%1", OUString::number( nDisplay ) );
166
167 return aName;
168}
169
171sal_Int32 SdStartPresentationDlg::InsertDisplayEntry(const OUString &aName,
172 sal_Int32 nDisplay)
173{
174 m_xLBMonitor->append(OUString::number(nDisplay), aName);
175 return m_xLBMonitor->get_count() - 1;
176}
177
179{
180 try
181 {
182 m_xFtMonitor->show();
183 m_xLBMonitor->show();
184
186
187 if( mnMonitors <= 1 )
188 {
189 m_xFtMonitor->set_sensitive( false );
190 m_xLBMonitor->set_sensitive( false );
191 }
192 else
193 {
194 sal_Int32 nExternalIndex = Application::GetDisplayExternalScreen();
195
196 sal_Int32 nSelectedIndex (-1);
197 sal_Int32 nDefaultExternalIndex (-1);
198 const sal_Int32 nDefaultSelectedDisplay (
199 rOutAttrs.Get( ATTR_PRESENT_DISPLAY ).GetValue());
200
201 // Un-conditionally add a version for '0' the default external display
202 sal_Int32 nInsertedEntry;
203
204 // Initial entry - the auto-detected external monitor
205 OUString aName = GetDisplayName( nExternalIndex + 1, EXTERNAL_IS_NUMBER);
206 nInsertedEntry = InsertDisplayEntry( aName, 0 );
207 if( nDefaultSelectedDisplay == 0)
208 nSelectedIndex = nInsertedEntry;
209
210 // The user data contains the real setting
211 for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ )
212 {
213 aName = GetDisplayName( nDisplay + 1,
214 nDisplay == nExternalIndex ?
216 nInsertedEntry = InsertDisplayEntry( aName, nDisplay + 1 );
217
218 // Remember the index of the default selection.
219 if( nDisplay + 1 == nDefaultSelectedDisplay )
220 nSelectedIndex = nInsertedEntry;
221
222 // Remember index of the default display.
223 if( nDisplay == nExternalIndex )
224 nDefaultExternalIndex = nInsertedEntry;
225 }
226
227 nInsertedEntry = InsertDisplayEntry( m_xAllMonitors->get_label(), -1 );
228 if( nDefaultSelectedDisplay == -1 )
229 nSelectedIndex = nInsertedEntry;
230
231 if (nSelectedIndex < 0)
232 {
233 if (nExternalIndex < 0)
234 nSelectedIndex = 0;
235 else
236 nSelectedIndex = nDefaultExternalIndex;
237 }
238
239 m_xLBMonitor->set_active(nSelectedIndex);
240 }
241 }
242 catch( Exception& )
243 {
244 }
245}
246
251{
252 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALL, m_xRbtAll->get_active() ) );
253 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CUSTOMSHOW, m_xRbtCustomshow->get_active() ) );
254 rAttr.Put( SfxStringItem ( ATTR_PRESENT_DIANAME, m_xLbDias->get_active_text() ) );
255 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MANUEL, m_xCbxManuel->get_active() ) );
256 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MOUSE, m_xCbxMousepointer->get_active() ) );
257 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_PEN, m_xCbxPen->get_active() ) );
258 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ANIMATION_ALLOWED, m_xCbxAnimationAllowed->get_active() ) );
259 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CHANGE_PAGE, m_xCbxChangePage->get_active() ) );
260 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALWAYS_ON_TOP, m_xCbxAlwaysOnTop->get_active() ) );
261 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_SHOW_NAVIGATION_BUTTONS, m_xCbxShowNavigationButton->get_active() ) );
262 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_FULLSCREEN, !m_xRbtWindow->get_active() ) );
263 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ENDLESS, m_xRbtAuto->get_active() ) );
264 rAttr.Put( SfxUInt32Item ( ATTR_PRESENT_PAUSE_TIMEOUT, m_xFormatter->GetTime().GetMSFromTime() / 1000 ) );
265 rAttr.Put( SfxBoolItem ( ATTR_PRESENT_SHOW_PAUSELOGO, m_xCbxAutoLogo->get_active() ) );
266
267 int nPos = m_xLBMonitor->get_active();
268 if (nPos != -1)
269 rAttr.Put(SfxInt32Item(ATTR_PRESENT_DISPLAY, m_xLBMonitor->get_id(nPos).toInt32()));
270
271 nPos = m_xLbCustomshow->get_active();
272 if (nPos != -1)
274}
275
280{
281 m_xLbDias->set_sensitive( m_xRbtAtDia->get_active() );
282 m_xLbCustomshow->set_sensitive( m_xRbtCustomshow->get_active() );
283}
284
288IMPL_LINK_NOARG(SdStartPresentationDlg, ClickWindowPresentationHdl, weld::Toggleable&, void)
289{
290 const bool bAuto = m_xRbtAuto->get_active();
291 const bool bWindow = m_xRbtWindow->get_active();
292
293 m_xTmfPause->set_sensitive( bAuto );
294 m_xCbxAutoLogo->set_sensitive( bAuto && ( m_xFormatter->GetTime().GetMSFromTime() > 0 ) );
295
296 const bool bDisplay = !bWindow && ( mnMonitors > 1 );
297 m_xFtMonitor->set_sensitive( bDisplay );
298 m_xLBMonitor->set_sensitive( bDisplay );
299
300 if( bWindow )
301 {
302 m_xCbxAlwaysOnTop->set_sensitive(false);
303 m_xCbxAlwaysOnTop->set_active(false);
304 }
305 else
306 m_xCbxAlwaysOnTop->set_sensitive(true);
307}
308
313{
314 ChangePause();
315}
316
318{
319 m_xCbxAutoLogo->set_sensitive(m_xRbtAuto->get_active() && ( m_xFormatter->GetTime().GetMSFromTime() > 0 ));
320}
321
322/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static unsigned int GetScreenCount()
static unsigned int GetDisplayExternalScreen()
sal_uInt16 GetCurPos() const
SdCustomShow * Next()
void Seek(sal_uInt16 nNewPos)
SdCustomShow * First()
const OUString & GetName() const
Definition: cusshow.hxx:60
Dialog to define optionsm_xnd to start the presentation.
Definition: present.hxx:32
virtual ~SdStartPresentationDlg() override
Definition: present.cxx:143
std::unique_ptr< weld::CheckButton > m_xCbxAutoLogo
Definition: present.hxx:49
std::unique_ptr< weld::CheckButton > m_xCbxMousepointer
Definition: present.hxx:52
std::unique_ptr< weld::CheckButton > m_xCbxManuel
Definition: present.hxx:51
std::unique_ptr< weld::CheckButton > m_xCbxShowNavigationButton
Definition: present.hxx:57
SdCustomShowList * pCustomShowList
Definition: present.hxx:34
sal_Int32 InsertDisplayEntry(const OUString &aName, sal_Int32 nDisplay)
Store display index together with name in user data.
Definition: present.cxx:171
std::unique_ptr< weld::FormattedSpinButton > m_xTmfPause
Definition: present.hxx:47
std::unique_ptr< weld::ComboBox > m_xLbCustomshow
Definition: present.hxx:42
std::unique_ptr< weld::CheckButton > m_xCbxAlwaysOnTop
Definition: present.hxx:56
std::unique_ptr< weld::CheckButton > m_xCbxPen
Definition: present.hxx:53
std::unique_ptr< weld::RadioButton > m_xRbtCustomshow
Definition: present.hxx:40
std::unique_ptr< weld::RadioButton > m_xRbtAtDia
Definition: present.hxx:39
OUString GetDisplayName(sal_Int32 nDisplay, DisplayType eType)
Definition: present.cxx:147
std::unique_ptr< weld::CheckButton > m_xCbxChangePage
Definition: present.hxx:55
std::unique_ptr< weld::Label > m_xFtMonitor
Definition: present.hxx:59
std::unique_ptr< weld::RadioButton > m_xRbtWindow
Definition: present.hxx:45
std::unique_ptr< weld::Label > m_xMonitorExternal
Definition: present.hxx:64
std::unique_ptr< weld::RadioButton > m_xRbtStandard
Definition: present.hxx:44
sal_Int32 mnMonitors
Definition: present.hxx:36
void GetAttr(SfxItemSet &rOutAttrs)
sets the selected attributes of the dialog
Definition: present.cxx:250
std::unique_ptr< weld::Label > m_xAllMonitors
Definition: present.hxx:63
std::unique_ptr< weld::CheckButton > m_xCbxAnimationAllowed
Definition: present.hxx:54
SdStartPresentationDlg(weld::Window *pWindow, const SfxItemSet &rInAttrs, const std::vector< OUString > &rPageNames, SdCustomShowList *pCSList)
Definition: present.cxx:34
std::unique_ptr< weld::RadioButton > m_xRbtAuto
Definition: present.hxx:46
std::unique_ptr< weld::ComboBox > m_xLBMonitor
Definition: present.hxx:60
std::unique_ptr< weld::ComboBox > m_xLbDias
Definition: present.hxx:41
const SfxItemSet & rOutAttrs
Definition: present.hxx:35
std::unique_ptr< weld::RadioButton > m_xRbtAll
Definition: present.hxx:38
std::unique_ptr< weld::TimeFormatter > m_xFormatter
Definition: present.hxx:48
std::unique_ptr< weld::Label > m_xMonitor
Definition: present.hxx:62
std::unique_ptr< weld::Label > m_xExternal
Definition: present.hxx:65
bool GetValue() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
DocumentType eType
OUString aName
sal_uInt16 nPos
@ Exception
long Long
const char GetValue[]
IMPL_LINK_NOARG(SdStartPresentationDlg, ChangeRangeHdl, weld::Toggleable &, void)
Handler: Enabled/Disabled Listbox "Dias".
Definition: present.cxx:279