Bug Summary

File:home/maarten/src/libreoffice/core/include/rtl/ref.hxx
Warning:line 192, column 9
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name slideshowimpl.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SD_DLLIMPLEMENTATION -D SDUI_DLL_NAME="libsduilo.so" -D SYSTEM_LIBXML -D ENABLE_SDREMOTE -D ENABLE_SDREMOTE_BLUETOOTH -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/external/bluez_bluetooth/inc -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/sd/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/slidesorter/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sd/sdi -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/oox/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx

/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx

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 <sal/config.h>
21
22#include <algorithm>
23
24#include <config_features.h>
25
26#include <com/sun/star/frame/theAutoRecovery.hpp>
27#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28#include <com/sun/star/document/XEventsSupplier.hpp>
29#include <com/sun/star/drawing/XMasterPageTarget.hpp>
30#include <com/sun/star/beans/PropertyValue.hpp>
31#include <com/sun/star/beans/XPropertySetInfo.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
33#include <com/sun/star/awt/SystemPointer.hpp>
34#include <com/sun/star/util/URLTransformer.hpp>
35#include <com/sun/star/util/XURLTransformer.hpp>
36#include <com/sun/star/frame/XDispatch.hpp>
37#include <com/sun/star/frame/XLayoutManager.hpp>
38#include <com/sun/star/presentation/SlideShow.hpp>
39#include <com/sun/star/media/XPlayer.hpp>
40#include <svl/stritem.hxx>
41#include <svl/urihelper.hxx>
42#include <unotools/saveopt.hxx>
43#include <basic/sbstar.hxx>
44
45#include <toolkit/helper/vclunohelper.hxx>
46#include <tools/diagnose_ex.h>
47
48#include <sfx2/infobar.hxx>
49#include <sfx2/dispatch.hxx>
50#include <sfx2/docfile.hxx>
51#include <sfx2/app.hxx>
52#include <sfx2/viewfrm.hxx>
53#include <svx/unoapi.hxx>
54#include <svx/svdoole2.hxx>
55#include <svx/f3dchild.hxx>
56#include <svx/imapdlg.hxx>
57#include <svx/fontwork.hxx>
58#include <svx/SvxColorChildWindow.hxx>
59#include <svx/bmpmask.hxx>
60#include <svx/srchdlg.hxx>
61#include <svx/hyperdlg.hxx>
62#include <svx/svxids.hrc>
63#include <AnimationChildWindow.hxx>
64#include <notifydocumentevent.hxx>
65#include "slideshowimpl.hxx"
66#include "slideshowviewimpl.hxx"
67#include "PaneHider.hxx"
68
69#include <bitmaps.hlst>
70#include <vcl/canvastools.hxx>
71#include <vcl/commandevent.hxx>
72#include <vcl/commandinfoprovider.hxx>
73
74#include <vcl/settings.hxx>
75#include <vcl/scheduler.hxx>
76#include <vcl/svapp.hxx>
77#include <vcl/help.hxx>
78#include <comphelper/processfactory.hxx>
79#include <rtl/ref.hxx>
80#include <avmedia/mediawindow.hxx>
81#include <svtools/colrdlg.hxx>
82#include <DrawDocShell.hxx>
83#include <ViewShellBase.hxx>
84#include <PresentationViewShell.hxx>
85#include <RemoteServer.hxx>
86#include <customshowlist.hxx>
87#include <unopage.hxx>
88#include <sdpage.hxx>
89#include <sdmod.hxx>
90#include <app.hrc>
91#include <cusshow.hxx>
92#include <optsitem.hxx>
93
94#define CM_SLIDES21 21
95
96using ::com::sun::star::animations::XAnimationNode;
97using ::com::sun::star::animations::XAnimationListener;
98using ::com::sun::star::awt::XWindow;
99using namespace ::com::sun::star;
100using namespace ::com::sun::star::lang;
101using namespace ::com::sun::star::uno;
102using namespace ::com::sun::star::drawing;
103using namespace ::com::sun::star::container;
104using namespace ::com::sun::star::document;
105using namespace ::com::sun::star::presentation;
106using namespace ::com::sun::star::beans;
107
108namespace sd
109{
110/** Slots, which will be disabled in the slide show and are managed by Sfx.
111 Have to be sorted in the order of the SIDs */
112sal_uInt16 const pAllowed[] =
113{
114 SID_OPENDOC(5000 + 501) , // 5501 ///< that internally jumps work
115 SID_JUMPTOMARK(5000 + 598) , // 5598
116 SID_OPENHYPERLINK(5000 + 1676) , // 6676
117 SID_PRESENTATION_END(27000 +18) // 27218
118};
119
120class AnimationSlideController
121{
122public:
123 enum Mode { ALL, FROM, CUSTOM, PREVIEW };
124
125public:
126 AnimationSlideController( Reference< XIndexAccess > const & xSlides, Mode eMode );
127
128 void setStartSlideNumber( sal_Int32 nSlideNumber ) { mnStartSlideNumber = nSlideNumber; }
129 sal_Int32 getStartSlideIndex() const;
130
131 sal_Int32 getCurrentSlideNumber() const;
132 sal_Int32 getCurrentSlideIndex() const;
133
134 sal_Int32 getSlideIndexCount() const { return maSlideNumbers.size(); }
135 sal_Int32 getSlideNumberCount() const { return mnSlideCount; }
136
137 sal_Int32 getSlideNumber( sal_Int32 nSlideIndex ) const;
138
139 void insertSlideNumber( sal_Int32 nSlideNumber, bool bVisible = true );
140 void setPreviewNode( const Reference< XAnimationNode >& xPreviewNode );
141
142 bool jumpToSlideIndex( sal_Int32 nNewSlideIndex );
143 bool jumpToSlideNumber( sal_Int32 nNewSlideIndex );
144
145 bool nextSlide();
146 bool previousSlide();
147
148 void displayCurrentSlide( const Reference< XSlideShow >& xShow,
149 const Reference< XDrawPagesSupplier>& xDrawPages,
150 const bool bSkipAllMainSequenceEffects );
151
152 sal_Int32 getNextSlideIndex() const;
153 sal_Int32 getPreviousSlideIndex() const;
154
155 bool isVisibleSlideNumber( sal_Int32 nSlideNumber ) const;
156
157 Reference< XDrawPage > getSlideByNumber( sal_Int32 nSlideNumber ) const;
158
159 sal_Int32 getNextSlideNumber() const;
160
161 bool hasSlides() const { return !maSlideNumbers.empty(); }
162
163private:
164 bool getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode );
165 sal_Int32 findSlideIndex( sal_Int32 nSlideNumber ) const;
166
167 bool isValidIndex( sal_Int32 nIndex ) const { return (nIndex >= 0) && (nIndex < static_cast<sal_Int32>(maSlideNumbers.size())); }
168 bool isValidSlideNumber( sal_Int32 nSlideNumber ) const { return (nSlideNumber >= 0) && (nSlideNumber < mnSlideCount); }
169
170private:
171 Mode meMode;
172 sal_Int32 mnStartSlideNumber;
173 std::vector< sal_Int32 > maSlideNumbers;
174 std::vector< bool > maSlideVisible;
175 std::vector< bool > maSlideVisited;
176 Reference< XAnimationNode > mxPreviewNode;
177 sal_Int32 mnSlideCount;
178 sal_Int32 mnCurrentSlideIndex;
179 sal_Int32 mnHiddenSlideNumber;
180 Reference< XIndexAccess > mxSlides;
181};
182
183Reference< XDrawPage > AnimationSlideController::getSlideByNumber( sal_Int32 nSlideNumber ) const
184{
185 Reference< XDrawPage > xSlide;
186 if( mxSlides.is() && (nSlideNumber >= 0) && (nSlideNumber < mxSlides->getCount()) )
187 mxSlides->getByIndex( nSlideNumber ) >>= xSlide;
188 return xSlide;
189}
190
191bool AnimationSlideController::isVisibleSlideNumber( sal_Int32 nSlideNumber ) const
192{
193 sal_Int32 nIndex = findSlideIndex( nSlideNumber );
194
195 if( nIndex != -1 )
196 return maSlideVisible[ nIndex ];
197 else
198 return false;
199}
200
201void AnimationSlideController::setPreviewNode( const Reference< XAnimationNode >& xPreviewNode )
202{
203 mxPreviewNode = xPreviewNode;
204}
205
206AnimationSlideController::AnimationSlideController( Reference< XIndexAccess > const & xSlides, Mode eMode )
207: meMode( eMode )
208, mnStartSlideNumber(-1)
209, mnSlideCount( 0 )
210, mnCurrentSlideIndex(0)
211, mnHiddenSlideNumber( -1 )
212, mxSlides( xSlides )
213{
214 if( mxSlides.is() )
215 mnSlideCount = xSlides->getCount();
216}
217
218sal_Int32 AnimationSlideController::getStartSlideIndex() const
219{
220 if( mnStartSlideNumber >= 0 )
221 {
222 sal_Int32 nIndex;
223 const sal_Int32 nCount = maSlideNumbers.size();
224
225 for( nIndex = 0; nIndex < nCount; nIndex++ )
226 {
227 if( maSlideNumbers[nIndex] == mnStartSlideNumber )
228 return nIndex;
229 }
230 }
231
232 return 0;
233}
234
235sal_Int32 AnimationSlideController::getCurrentSlideNumber() const
236{
237 if( mnHiddenSlideNumber != -1 )
238 return mnHiddenSlideNumber;
239 else if( !maSlideNumbers.empty() )
240 return maSlideNumbers[mnCurrentSlideIndex];
241 else
242 return 0;
243}
244
245sal_Int32 AnimationSlideController::getCurrentSlideIndex() const
246{
247 if( mnHiddenSlideNumber != -1 )
248 return -1;
249 else
250 return mnCurrentSlideIndex;
251}
252
253bool AnimationSlideController::jumpToSlideIndex( sal_Int32 nNewSlideIndex )
254{
255 if( isValidIndex( nNewSlideIndex ) )
256 {
257 mnCurrentSlideIndex = nNewSlideIndex;
258 mnHiddenSlideNumber = -1;
259 maSlideVisited[mnCurrentSlideIndex] = true;
260 return true;
261 }
262 else
263 {
264 return false;
265 }
266}
267
268bool AnimationSlideController::jumpToSlideNumber( sal_Int32 nNewSlideNumber )
269{
270 sal_Int32 nIndex = findSlideIndex( nNewSlideNumber );
271 if( isValidIndex( nIndex ) )
272 {
273 return jumpToSlideIndex( nIndex );
274 }
275 else if( (nNewSlideNumber >= 0) && (nNewSlideNumber < mnSlideCount) )
276 {
277 // jump to a hidden slide
278 mnHiddenSlideNumber = nNewSlideNumber;
279 return true;
280 }
281 else
282 {
283 return false;
284 }
285}
286
287sal_Int32 AnimationSlideController::getSlideNumber( sal_Int32 nSlideIndex ) const
288{
289 if( isValidIndex( nSlideIndex ) )
290 return maSlideNumbers[nSlideIndex];
291 else
292 return -1;
293}
294
295void AnimationSlideController::insertSlideNumber( sal_Int32 nSlideNumber, bool bVisible /* = true */ )
296{
297 DBG_ASSERT( isValidSlideNumber( nSlideNumber ), "sd::AnimationSlideController::insertSlideNumber(), illegal index" )do { if (true && (!(isValidSlideNumber( nSlideNumber )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"
), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "297" ": "), "%s", "sd::AnimationSlideController::insertSlideNumber(), illegal index"
); } } while (false)
;
298 if( isValidSlideNumber( nSlideNumber ) )
299 {
300 maSlideNumbers.push_back( nSlideNumber );
301 maSlideVisible.push_back( bVisible );
302 maSlideVisited.push_back( false );
303 }
304}
305
306bool AnimationSlideController::getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode )
307{
308 if( isValidSlideNumber( nSlideNumber ) ) try
309 {
310 xSlide.set( mxSlides->getByIndex(nSlideNumber), UNO_QUERY_THROW );
311
312 if( meMode == PREVIEW )
313 {
314 xAnimNode = mxPreviewNode;
315 }
316 else
317 {
318 Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier( xSlide, UNO_QUERY_THROW );
319 xAnimNode = xAnimNodeSupplier->getAnimationNode();
320 }
321
322 return true;
323 }
324 catch( Exception& )
325 {
326 TOOLS_WARN_EXCEPTION( "sd", "sd::AnimationSlideController::getSlideAPI()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::AnimationSlideController::getSlideAPI()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "326" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "sd::AnimationSlideController::getSlideAPI()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::AnimationSlideController::getSlideAPI()" <<
" " << exceptionToString(tools_warn_exception); ::sal::
detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "326" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::AnimationSlideController::getSlideAPI()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "326" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "sd::AnimationSlideController::getSlideAPI()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::AnimationSlideController::getSlideAPI()" <<
" " << exceptionToString(tools_warn_exception); ::sal::
detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "326" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
327 }
328
329 return false;
330}
331
332sal_Int32 AnimationSlideController::findSlideIndex( sal_Int32 nSlideNumber ) const
333{
334 sal_Int32 nIndex;
335 const sal_Int32 nCount = maSlideNumbers.size();
336
337 for( nIndex = 0; nIndex < nCount; nIndex++ )
338 {
339 if( maSlideNumbers[nIndex] == nSlideNumber )
340 return nIndex;
341 }
342
343 return -1;
344}
345
346sal_Int32 AnimationSlideController::getNextSlideIndex() const
347{
348 switch( meMode )
349 {
350 case ALL:
351 {
352 sal_Int32 nNewSlideIndex = mnCurrentSlideIndex + 1;
353 if( isValidIndex( nNewSlideIndex ) )
354 {
355 // if the current slide is not excluded, make sure the
356 // next slide is also not excluded.
357 // if the current slide is excluded, we want to go
358 // to the next slide, even if this is also excluded.
359 if( maSlideVisible[mnCurrentSlideIndex] )
360 {
361 while( isValidIndex( nNewSlideIndex ) )
362 {
363 if( maSlideVisible[nNewSlideIndex] )
364 break;
365
366 nNewSlideIndex++;
367 }
368 }
369 }
370 return isValidIndex( nNewSlideIndex ) ? nNewSlideIndex : -1;
371 }
372
373 case FROM:
374 case CUSTOM:
375 return mnHiddenSlideNumber == -1 ? mnCurrentSlideIndex + 1 : mnCurrentSlideIndex;
376
377 default:
378 case PREVIEW:
379 return -1;
380
381 }
382}
383
384sal_Int32 AnimationSlideController::getNextSlideNumber() const
385{
386 sal_Int32 nNextSlideIndex = getNextSlideIndex();
387 if( isValidIndex( nNextSlideIndex ) )
388 {
389 return maSlideNumbers[nNextSlideIndex];
390 }
391 else
392 {
393 return -1;
394 }
395}
396
397bool AnimationSlideController::nextSlide()
398{
399 return jumpToSlideIndex( getNextSlideIndex() );
400}
401
402sal_Int32 AnimationSlideController::getPreviousSlideIndex() const
403{
404 sal_Int32 nNewSlideIndex = mnCurrentSlideIndex - 1;
405
406 switch( meMode )
407 {
408 case ALL:
409 {
410 // make sure the previous slide is visible
411 // or was already visited
412 while( isValidIndex( nNewSlideIndex ) )
413 {
414 if( maSlideVisible[nNewSlideIndex] || maSlideVisited[nNewSlideIndex] )
415 break;
416
417 nNewSlideIndex--;
418 }
419
420 break;
421 }
422
423 case PREVIEW:
424 return -1;
425
426 default:
427 break;
428 }
429
430 return nNewSlideIndex;
431}
432
433bool AnimationSlideController::previousSlide()
434{
435 return jumpToSlideIndex( getPreviousSlideIndex() );
436}
437
438void AnimationSlideController::displayCurrentSlide( const Reference< XSlideShow >& xShow,
439 const Reference< XDrawPagesSupplier>& xDrawPages,
440 const bool bSkipAllMainSequenceEffects )
441{
442 const sal_Int32 nCurrentSlideNumber = getCurrentSlideNumber();
443
444 if( !(xShow.is() && (nCurrentSlideNumber != -1 )) )
445 return;
446
447 Reference< XDrawPage > xSlide;
448 Reference< XAnimationNode > xAnimNode;
449 ::std::vector<PropertyValue> aProperties;
450
451 const sal_Int32 nNextSlideNumber = getNextSlideNumber();
452 if( getSlideAPI( nNextSlideNumber, xSlide, xAnimNode ) )
453 {
454 Sequence< Any > aValue(2);
455 aValue[0] <<= xSlide;
456 aValue[1] <<= xAnimNode;
457 aProperties.emplace_back( "Prefetch" ,
458 -1,
459 Any(aValue),
460 PropertyState_DIRECT_VALUE);
461 }
462 if (bSkipAllMainSequenceEffects)
463 {
464 // Add one property that prevents the slide transition from being
465 // shown (to speed up the transition to the previous slide) and
466 // one to show all main sequence effects so that the user can
467 // continue to undo effects.
468 aProperties.emplace_back( "SkipAllMainSequenceEffects",
469 -1,
470 Any(true),
471 PropertyState_DIRECT_VALUE);
472 aProperties.emplace_back("SkipSlideTransition",
473 -1,
474 Any(true),
475 PropertyState_DIRECT_VALUE);
476 }
477
478 if( getSlideAPI( nCurrentSlideNumber, xSlide, xAnimNode ) )
479 xShow->displaySlide( xSlide, xDrawPages, xAnimNode, comphelper::containerToSequence(aProperties) );
480}
481
482constexpr OUStringLiteral gsOnClick( u"OnClick" );
483constexpr OUStringLiteral gsBookmark( u"Bookmark" );
484constexpr OUStringLiteral gsVerb( u"Verb" );
485
486SlideshowImpl::SlideshowImpl( const Reference< XPresentation2 >& xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, vcl::Window* pParentWindow )
487: SlideshowImplBase( m_aMutex )
488, mxModel(pDoc->getUnoModel(),UNO_QUERY_THROW)
489, mpView(pView)
490, mpViewShell(pViewSh)
491, mpDocSh(pDoc->GetDocSh())
492, mpDoc(pDoc)
493, mpParentWindow(pParentWindow)
494, mpShowWindow(nullptr)
495, mnRestoreSlide(0)
496, maPresSize( -1, -1 )
497, meAnimationMode(ANIMATIONMODE_SHOW)
498, mpOldActiveWindow(nullptr)
499, mnChildMask( 0 )
500, mbDisposed(false)
501, mbAutoSaveWasOn(false)
502, mbRehearseTimings(false)
503, mbIsPaused(false)
504, mbWasPaused(false)
505, mbInputFreeze(false)
506, mbActive(false)
507, maPresSettings( pDoc->getPresentationSettings() )
508, mnUserPaintColor( 0x80ff0000L )
509, mbUsePen(false)
510, mdUserPaintStrokeWidth ( 150.0 )
511, mnEndShowEvent(nullptr)
512, mnContextMenuEvent(nullptr)
513, mxPresentation( xPresentation )
514{
515 if( mpViewShell )
516 mpOldActiveWindow = mpViewShell->GetActiveWindow();
517
518 maUpdateTimer.SetInvokeHandler(LINK(this, SlideshowImpl, updateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubupdateHdl)
);
519 // Priority must not be too high or we'll starve input handling etc.
520 maUpdateTimer.SetPriority(TaskPriority::REPAINT);
521
522 maDeactivateTimer.SetInvokeHandler(LINK(this, SlideshowImpl, deactivateHdl)::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubdeactivateHdl)
);
523 maDeactivateTimer.SetTimeout( 20 );
524
525 maInputFreezeTimer.SetInvokeHandler( LINK( this, SlideshowImpl, ReadyForNextInputHdl )::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubReadyForNextInputHdl
)
);
526 maInputFreezeTimer.SetTimeout( 20 );
527
528 SvtSaveOptions aOptions;
529
530 // no autosave during show
531 if( aOptions.IsAutoSave() )
532 mbAutoSaveWasOn = true;
533
534 Application::AddEventListener( LINK( this, SlideshowImpl, EventListenerHdl )::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubEventListenerHdl)
);
535
536 mbUsePen = maPresSettings.mbMouseAsPen;
537
538 SdOptions* pOptions = SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->GetSdOptions(DocumentType::Impress);
539 if( pOptions )
540 {
541 mnUserPaintColor = pOptions->GetPresentationPenColor();
542 mdUserPaintStrokeWidth = pOptions->GetPresentationPenWidth();
543 }
544}
545
546SlideshowImpl::~SlideshowImpl()
547{
548 SdModule *pModule = SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
;
549 //rhbz#806663 SlideshowImpl can outlive SdModule
550 SdOptions* pOptions = pModule ?
1
Assuming 'pModule' is null
2
'?' condition is false
551 pModule->GetSdOptions(DocumentType::Impress) : nullptr;
552 if( pOptions
2.1
'pOptions' is null
2.1
'pOptions' is null
2.1
'pOptions' is null
2.1
'pOptions' is null
)
3
Taking false branch
553 {
554 pOptions->SetPresentationPenColor(mnUserPaintColor);
555 pOptions->SetPresentationPenWidth(mdUserPaintStrokeWidth);
556 }
557
558 Application::RemoveEventListener( LINK( this, SlideshowImpl, EventListenerHdl )::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubEventListenerHdl)
);
559
560 maDeactivateTimer.Stop();
561
562 if( !mbDisposed )
4
Assuming field 'mbDisposed' is false
5
Taking true branch
563 {
564 OSL_FAIL("SlideshowImpl::~SlideshowImpl(), component was not disposed!")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "564" ": "), "%s", "SlideshowImpl::~SlideshowImpl(), component was not disposed!"
); } } while (false)
;
6
Taking true branch
7
Loop condition is false. Exiting loop
565 disposing();
8
Calling 'SlideshowImpl::disposing'
566 }
567}
568
569void SAL_CALL SlideshowImpl::disposing()
570{
571#ifdef ENABLE_SDREMOTE1
572 RemoteServer::presentationStopped();
573#endif
574 if( mxShow.is() && mpDoc )
575 NotifyDocumentEvent(
576 *mpDoc,
577 "OnEndPresentation" );
578
579 if( mbAutoSaveWasOn )
9
Assuming field 'mbAutoSaveWasOn' is false
10
Taking false branch
580 setAutoSaveState( true );
581
582 if( mnEndShowEvent )
11
Assuming field 'mnEndShowEvent' is null
12
Taking false branch
583 Application::RemoveUserEvent( mnEndShowEvent );
584 if( mnContextMenuEvent )
13
Assuming field 'mnContextMenuEvent' is null
14
Taking false branch
585 Application::RemoveUserEvent( mnContextMenuEvent );
586
587 maInputFreezeTimer.Stop();
588
589 SolarMutexGuard aSolarGuard;
590
591 if( !mxShow.is() )
15
Taking false branch
592 return;
593
594 if( mxPresentation.is() )
16
Taking false branch
595 mxPresentation->end();
596
597 maUpdateTimer.Stop();
598
599 removeShapeEvents();
600
601 if( mxListenerProxy.is() )
17
Taking false branch
602 mxListenerProxy->removeAsSlideShowListener();
603
604 try
605 {
606 if( mxView.is() )
18
Taking false branch
607 mxShow->removeView( mxView.get() );
608
609 Reference< XComponent > xComponent( mxShow, UNO_QUERY );
610 if( xComponent.is() )
19
Taking false branch
611 xComponent->dispose();
612
613 if( mxView.is() )
20
Taking false branch
614 mxView->dispose();
615 }
616 catch( Exception& )
617 {
618 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::stop()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::stop()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "618" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "sd::SlideshowImpl::stop()" << " "
<< exceptionToString(tools_warn_exception)), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"sd::SlideshowImpl::stop()" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "618" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::stop()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "618" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "sd::SlideshowImpl::stop()" << " "
<< exceptionToString(tools_warn_exception)), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"sd::SlideshowImpl::stop()" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "618" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
619 }
620
621 mxShow.clear();
622 mxView.clear();
623 mxListenerProxy.clear();
624 mpSlideController.reset();
625
626 // take DrawView from presentation window, but give the old window back
627 if( mpShowWindow && mpView )
21
Assuming field 'mpView' is null
22
Taking false branch
628 mpView->DeleteWindowFromPaintView( mpShowWindow );
629
630 if( mpView
22.1
Field 'mpView' is null
22.1
Field 'mpView' is null
22.1
Field 'mpView' is null
22.1
Field 'mpView' is null
)
23
Taking false branch
631 mpView->SetAnimationPause( false );
632
633 if( mpViewShell )
24
Assuming field 'mpViewShell' is null
25
Taking false branch
634 {
635 mpViewShell->SetActiveWindow(mpOldActiveWindow);
636 if (mpShowWindow)
637 mpShowWindow->SetViewShell( nullptr );
638 }
639
640 if( mpView
25.1
Field 'mpView' is null
25.1
Field 'mpView' is null
25.1
Field 'mpView' is null
25.1
Field 'mpView' is null
)
26
Taking false branch
641 mpView->InvalidateAllWin();
642
643 if( maPresSettings.mbFullScreen )
27
Assuming field 'mbFullScreen' is true
28
Taking true branch
644 {
645#if HAVE_FEATURE_SCRIPTING1
646 // restore StarBASICErrorHdl
647 StarBASIC::SetGlobalErrorHdl(maStarBASICGlobalErrorHdl);
648 maStarBASICGlobalErrorHdl = Link<StarBASIC*,bool>();
649#endif
650 }
651 else
652 {
653 if( mpShowWindow )
654 mpShowWindow->Hide();
655 }
656
657 if( meAnimationMode == ANIMATIONMODE_SHOW )
29
Assuming field 'meAnimationMode' is not equal to ANIMATIONMODE_SHOW
30
Taking false branch
658 {
659 mpDocSh->SetSlotFilter();
660 mpDocSh->ApplySlotFilter();
661
662 Help::EnableContextHelp();
663 Help::EnableExtHelp();
664
665 showChildWindows();
666 mnChildMask = 0;
667 }
668
669 // show current window again
670 if( mpViewShell
30.1
Field 'mpViewShell' is null
30.1
Field 'mpViewShell' is null
30.1
Field 'mpViewShell' is null
30.1
Field 'mpViewShell' is null
&& dynamic_cast< PresentationViewShell *>( mpViewShell ) == nullptr)
671 {
672 if( meAnimationMode == ANIMATIONMODE_SHOW )
673 {
674 mpViewShell->GetViewShellBase().ShowUIControls (true);
675 mpPaneHider.reset();
676 }
677 else if( meAnimationMode == ANIMATIONMODE_PREVIEW )
678 {
679 mpViewShell->ShowUIControls(true);
680 }
681 }
682
683 if( mpShowWindow )
31
Taking true branch
684 mpShowWindow->Hide();
685 mpShowWindow.disposeAndClear();
32
Calling 'VclPtr::disposeAndClear'
686
687 if ( mpViewShell )
688 {
689 if( meAnimationMode == ANIMATIONMODE_SHOW )
690 {
691 ::sd::Window* pActWin = mpViewShell->GetActiveWindow();
692
693 if (pActWin)
694 {
695 Size aVisSizePixel = pActWin->GetOutputSizePixel();
696 ::tools::Rectangle aVisAreaWin = pActWin->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
697 mpViewShell->VisAreaChanged(aVisAreaWin);
698 if (mpView)
699 mpView->VisAreaChanged(pActWin);
700 pActWin->GrabFocus();
701 }
702 }
703
704 // restart the custom show dialog if he started us
705 if( mpViewShell->IsStartShowWithDialog() && getDispatcher() )
706 {
707 mpViewShell->SetStartShowWithDialog( false );
708 getDispatcher()->Execute( SID_CUSTOMSHOW_DLG(27000 +365), SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
709 }
710
711 mpViewShell->GetViewShellBase().UpdateBorder(true);
712 }
713
714 if( mpShowWindow )
715 {
716 mpShowWindow.disposeAndClear();
717 }
718
719 setActiveXToolbarsVisible( true );
720
721 mbDisposed = true;
722}
723
724bool SlideshowImpl::startPreview(
725 const Reference< XDrawPage >& xDrawPage,
726 const Reference< XAnimationNode >& xAnimationNode,
727 vcl::Window * pParent )
728{
729 bool bRet = false;
730
731 try
732 {
733 const Reference<lang::XServiceInfo> xServiceInfo( xDrawPage, UNO_QUERY );
734 if (xServiceInfo.is()) {
735 const Sequence<OUString> supportedServices(
736 xServiceInfo->getSupportedServiceNames() );
737 if (comphelper::findValue(supportedServices, "com.sun.star.drawing.MasterPage") != -1) {
738 OSL_FAIL("sd::SlideshowImpl::startPreview() "do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "739" ": "), "%s", "sd::SlideshowImpl::startPreview() " "not allowed on master page!"
); } } while (false)
739 "not allowed on master page!")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "739" ": "), "%s", "sd::SlideshowImpl::startPreview() " "not allowed on master page!"
); } } while (false)
;
740 return false;
741 }
742 }
743
744 mxPreviewDrawPage = xDrawPage;
745 mxPreviewAnimationNode = xAnimationNode;
746 meAnimationMode = ANIMATIONMODE_PREVIEW;
747
748 maPresSettings.mbAll = false;
749 maPresSettings.mbEndless = false;
750 maPresSettings.mbCustomShow = false;
751 maPresSettings.mbManual = false;
752 maPresSettings.mbMouseVisible = false;
753 maPresSettings.mbMouseAsPen = false;
754 maPresSettings.mbLockedPages = false;
755 maPresSettings.mbAlwaysOnTop = false;
756 maPresSettings.mbFullScreen = false;
757 maPresSettings.mbAnimationAllowed = true;
758 maPresSettings.mnPauseTimeout = 0;
759 maPresSettings.mbShowPauseLogo = false;
760
761 Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
762 Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
763 mpSlideController = std::make_shared<AnimationSlideController>( xSlides, AnimationSlideController::PREVIEW );
764
765 sal_Int32 nSlideNumber = 0;
766 Reference< XPropertySet > xSet( mxPreviewDrawPage, UNO_QUERY_THROW );
767 xSet->getPropertyValue( "Number" ) >>= nSlideNumber;
768 mpSlideController->insertSlideNumber( nSlideNumber-1 );
769 mpSlideController->setPreviewNode( xAnimationNode );
770
771 mpShowWindow = VclPtr<ShowWindow>::Create( this, ((pParent == nullptr) && mpViewShell) ? mpParentWindow.get() : pParent );
772 if( mpViewShell )
773 {
774 mpViewShell->SetActiveWindow( mpShowWindow );
775 mpShowWindow->SetViewShell (mpViewShell);
776 mpViewShell->ShowUIControls (false);
777 }
778
779 if( mpView )
780 {
781 mpView->AddWindowToPaintView( mpShowWindow, nullptr );
782 mpView->SetAnimationPause( true );
783 }
784
785 // call resize handler
786 if( pParent )
787 {
788 maPresSize = pParent->GetSizePixel();
789 }
790 else if( mpViewShell )
791 {
792 ::tools::Rectangle aContentRect (mpViewShell->GetViewShellBase().getClientRectangle());
793 if (AllSettings::GetLayoutRTL())
794 {
795 aContentRect.SetLeft( aContentRect.Right() );
796 aContentRect.AdjustRight(aContentRect.Right() );
797 }
798 maPresSize = aContentRect.GetSize();
799 mpShowWindow->SetPosPixel( aContentRect.TopLeft() );
800 }
801 else
802 {
803 OSL_FAIL("sd::SlideshowImpl::startPreview(), I need either a parent window or a viewshell!")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "803" ": "), "%s", "sd::SlideshowImpl::startPreview(), I need either a parent window or a viewshell!"
); } } while (false)
;
804 }
805 resize( maPresSize );
806
807 sal_Int32 nPropertyCount = 1;
808 if( mxPreviewAnimationNode.is() )
809 nPropertyCount++;
810
811 Sequence< beans::PropertyValue > aProperties(nPropertyCount);
812 aProperties[0].Name = "AutomaticAdvancement";
813 aProperties[0].Value <<= 1.0; // one second timeout
814
815 if( mxPreviewAnimationNode.is() )
816 {
817 aProperties[1].Name = "NoSlideTransitions";
818 aProperties[1].Value <<= true;
819 }
820
821 bRet = startShowImpl( aProperties );
822
823 if( mpShowWindow != nullptr && meAnimationMode == ANIMATIONMODE_PREVIEW )
824 mpShowWindow->SetPreviewMode();
825
826 }
827 catch( Exception& )
828 {
829 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::startPreview()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::startPreview()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "829" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "sd::SlideshowImpl::startPreview()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::startPreview()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "829" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::startPreview()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "829" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "sd::SlideshowImpl::startPreview()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::startPreview()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "829" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
830 bRet = false;
831 }
832
833 return bRet;
834}
835
836bool SlideshowImpl::startShow( PresentationSettingsEx const * pPresSettings )
837{
838 const rtl::Reference<SlideshowImpl> xKeepAlive(this);
839
840 DBG_ASSERT( !mxShow.is(), "sd::SlideshowImpl::startShow(), called twice!" )do { if (true && (!(!mxShow.is()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "840" ": "), "%s", "sd::SlideshowImpl::startShow(), called twice!"
); } } while (false)
;
841 if( mxShow.is() )
842 return true;
843 DBG_ASSERT( mpParentWindow!=nullptr, "sd::SlideshowImpl::startShow() called without parent window" )do { if (true && (!(mpParentWindow!=nullptr))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "843" ": "), "%s", "sd::SlideshowImpl::startShow() called without parent window"
); } } while (false)
;
844 if (mpParentWindow == nullptr)
845 return false;
846
847 // Autoplay (pps/ppsx)
848 if (mpViewShell->GetDoc()->IsStartWithPresentation()){
849 mpViewShell->GetDoc()->SetExitAfterPresenting(true);
850 }
851
852 bool bRet = false;
853
854 try
855 {
856 if( pPresSettings )
857 {
858 maPresSettings = *pPresSettings;
859 mbRehearseTimings = pPresSettings->mbRehearseTimings;
860 }
861
862 OUString aPresSlide( maPresSettings.maPresPage );
863 SdPage* pStartPage = mpViewShell->GetActualPage();
864 bool bStartWithActualSlide = pStartPage;
865
866 // times should be measured?
867 if( mbRehearseTimings )
868 {
869 maPresSettings.mbEndless = false;
870 maPresSettings.mbManual = true;
871 maPresSettings.mbMouseVisible = true;
872 maPresSettings.mbMouseAsPen = false;
873 maPresSettings.mnPauseTimeout = 0;
874 maPresSettings.mbShowPauseLogo = false;
875 }
876
877 if( pStartPage )
878 {
879 if( pStartPage->GetPageKind() == PageKind::Notes )
880 {
881 // we are in notes page mode, so get
882 // the corresponding draw page
883 const sal_uInt16 nPgNum = ( pStartPage->GetPageNum() - 2 ) >> 1;
884 pStartPage = mpDoc->GetSdPage( nPgNum, PageKind::Standard );
885 }
886 }
887
888 if( bStartWithActualSlide )
889 {
890 if ( aPresSlide.isEmpty())
891 {
892 // no preset slide yet, so pick current on one
893 aPresSlide = pStartPage->GetName();
894 // if the starting slide is hidden, we can't set slide controller to ALL mode
895 maPresSettings.mbAll = !pStartPage->IsExcluded();
896 }
897
898 if( meAnimationMode != ANIMATIONMODE_SHOW )
899 {
900 if( pStartPage->GetPageKind() == PageKind::Standard )
901 {
902 maPresSettings.mbAll = false;
903 }
904 }
905 }
906
907 // build page list
908 createSlideList( maPresSettings.mbAll, aPresSlide );
909
910 // remember Slide number from where the show was started
911 if( pStartPage )
912 mnRestoreSlide = ( pStartPage->GetPageNum() - 1 ) / 2;
913
914 if( mpSlideController->hasSlides() )
915 {
916 // hide child windows
917 hideChildWindows();
918
919 mpShowWindow = VclPtr<ShowWindow>::Create( this, mpParentWindow );
920 mpShowWindow->SetMouseAutoHide( !maPresSettings.mbMouseVisible );
921 mpViewShell->SetActiveWindow( mpShowWindow );
922 mpShowWindow->SetViewShell (mpViewShell);
923 mpViewShell->GetViewShellBase().ShowUIControls (false);
924 // Hide the side panes for in-place presentations.
925 if ( ! maPresSettings.mbFullScreen)
926 mpPaneHider.reset(new PaneHider(*mpViewShell,this));
927
928 // these Slots are forbidden in other views for this document
929 if( mpDocSh )
930 {
931 mpDocSh->SetSlotFilter( true, pAllowed );
932 mpDocSh->ApplySlotFilter();
933 }
934
935 Help::DisableContextHelp();
936 Help::DisableExtHelp();
937
938 if( maPresSettings.mbFullScreen )
939 {
940#if HAVE_FEATURE_SCRIPTING1
941 // disable basic ide error handling
942 maStarBASICGlobalErrorHdl = StarBASIC::GetGlobalErrorHdl();
943 StarBASIC::SetGlobalErrorHdl( Link<StarBASIC*,bool>() );
944#endif
945 }
946
947 // call resize handler
948 maPresSize = mpParentWindow->GetSizePixel();
949 if (!maPresSettings.mbFullScreen)
950 {
951 const ::tools::Rectangle& aClientRect = mpViewShell->GetViewShellBase().getClientRectangle();
952 maPresSize = aClientRect.GetSize();
953 mpShowWindow->SetPosPixel( aClientRect.TopLeft() );
954 resize( maPresSize );
955 }
956
957 // #i41824#
958 // Note: In FullScreen Mode the OS (window manager) sends a resize to
959 // the WorkWindow once it actually resized it to full size. The
960 // WorkWindow propagates the resize to the DrawViewShell which calls
961 // resize() at the SlideShow (this). Calling resize here results in a
962 // temporary display of a black window in the window's default size
963
964 if( mpView )
965 {
966 mpView->AddWindowToPaintView( mpShowWindow, nullptr );
967 mpView->SetAnimationPause( true );
968 }
969
970 SfxBindings* pBindings = getBindings();
971 if( pBindings )
972 {
973 pBindings->Invalidate( SID_PRESENTATION( 10000 + 157 ) );
974 pBindings->Invalidate( SID_REHEARSE_TIMINGS( 10000 + 159 ) );
975 }
976
977 // Defer the sd::ShowWindow's GrabFocus to SlideShow::activate. so that the accessible event can be fired correctly.
978 //mpShowWindow->GrabFocus();
979
980 std::vector<beans::PropertyValue> aProperties;
981 aProperties.reserve( 4 );
982
983 aProperties.emplace_back( "AdvanceOnClick" ,
984 -1, Any( !maPresSettings.mbLockedPages ),
985 beans::PropertyState_DIRECT_VALUE );
986
987 aProperties.emplace_back( "ImageAnimationsAllowed" ,
988 -1, Any( maPresSettings.mbAnimationAllowed ),
989 beans::PropertyState_DIRECT_VALUE );
990
991 const bool bZOrderEnabled(
992 SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->GetSdOptions( mpDoc->GetDocumentType() )->IsSlideshowRespectZOrder() );
993 aProperties.emplace_back( "DisableAnimationZOrder" ,
994 -1, Any( !bZOrderEnabled ),
995 beans::PropertyState_DIRECT_VALUE );
996
997 aProperties.emplace_back( "ForceManualAdvance" ,
998 -1, Any( maPresSettings.mbManual ),
999 beans::PropertyState_DIRECT_VALUE );
1000
1001 if( mbUsePen )
1002 {
1003 aProperties.emplace_back( "UserPaintColor" ,
1004 // User paint color is black by default.
1005 -1, Any( mnUserPaintColor ),
1006 beans::PropertyState_DIRECT_VALUE );
1007
1008 aProperties.emplace_back( "UserPaintStrokeWidth" ,
1009 // User paint color is black by default.
1010 -1, Any( mdUserPaintStrokeWidth ),
1011 beans::PropertyState_DIRECT_VALUE );
1012 }
1013
1014 if (mbRehearseTimings) {
1015 aProperties.emplace_back( "RehearseTimings" ,
1016 -1, Any(true), beans::PropertyState_DIRECT_VALUE );
1017 }
1018
1019 bRet = startShowImpl( Sequence<beans::PropertyValue>(
1020 aProperties.data(), aProperties.size() ) );
1021
1022 }
1023
1024 setActiveXToolbarsVisible( false );
1025 }
1026 catch (const Exception&)
1027 {
1028 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::startShow()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::startShow()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1028" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::startShow()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::startShow()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1028" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::startShow()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1028" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::startShow()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::startShow()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1028" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1029 bRet = false;
1030 }
1031
1032 return bRet;
1033}
1034
1035bool SlideshowImpl::startShowImpl( const Sequence< beans::PropertyValue >& aProperties )
1036{
1037 try
1038 {
1039 mxShow.set( createSlideShow(), UNO_SET_THROW );
1040
1041 mxView = new SlideShowView(
1042 *mpShowWindow,
1043 mpDoc,
1044 meAnimationMode,
1045 this,
1046 maPresSettings.mbFullScreen);
1047
1048 // try add wait symbol to properties:
1049 const Reference<rendering::XSpriteCanvas> xSpriteCanvas(
1050 mxView->getCanvas() );
1051 if (xSpriteCanvas.is())
1052 {
1053 BitmapEx waitSymbolBitmap(BMP_WAIT_ICON"sd/res/waiticon.png");
1054 const Reference<rendering::XBitmap> xBitmap(
1055 vcl::unotools::xBitmapFromBitmapEx( waitSymbolBitmap ) );
1056 if (xBitmap.is())
1057 {
1058 mxShow->setProperty(
1059 beans::PropertyValue( "WaitSymbolBitmap" ,
1060 -1,
1061 makeAny( xBitmap ),
1062 beans::PropertyState_DIRECT_VALUE ) );
1063 }
1064
1065 BitmapEx pointerSymbolBitmap(BMP_POINTER_ICON"sd/res/pointericon.png");
1066 const Reference<rendering::XBitmap> xPointerBitmap(
1067 vcl::unotools::xBitmapFromBitmapEx( pointerSymbolBitmap ) );
1068 if (xPointerBitmap.is())
1069 {
1070 mxShow->setProperty(
1071 beans::PropertyValue( "PointerSymbolBitmap" ,
1072 -1,
1073 makeAny( xPointerBitmap ),
1074 beans::PropertyState_DIRECT_VALUE ) );
1075 }
1076 }
1077
1078 for( const auto& rProp : aProperties )
1079 mxShow->setProperty( rProp );
1080
1081 mxShow->addView( mxView.get() );
1082
1083 mxListenerProxy.set( new SlideShowListenerProxy( this, mxShow ) );
1084 mxListenerProxy->addAsSlideShowListener();
1085
1086 NotifyDocumentEvent(
1087 *mpDoc,
1088 "OnStartPresentation");
1089 displaySlideIndex( mpSlideController->getStartSlideIndex() );
1090
1091 return true;
1092 }
1093 catch( Exception& )
1094 {
1095 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::startShowImpl()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::startShowImpl()" << " "
<< exceptionToString(tools_warn_exception)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1095" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::startShowImpl()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::startShowImpl()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1095" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::startShowImpl()" << " "
<< exceptionToString(tools_warn_exception)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1095" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::startShowImpl()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::startShowImpl()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1095" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1096 return false;
1097 }
1098}
1099
1100/** called only by the slideshow view when the first paint event occurs.
1101 This actually starts the slideshow. */
1102void SlideshowImpl::onFirstPaint()
1103{
1104 if( mpShowWindow )
1105 {
1106 /*
1107 mpShowWindow->SetBackground( Wallpaper( COL_BLACK ) );
1108 mpShowWindow->Erase();
1109 mpShowWindow->SetBackground();
1110 */
1111 }
1112
1113 SolarMutexGuard aSolarGuard;
1114 maUpdateTimer.SetTimeout( sal_uLong(100) );
1115 maUpdateTimer.Start();
1116}
1117
1118void SlideshowImpl::paint()
1119{
1120 if( mxView.is() ) try
1121 {
1122 awt::PaintEvent aEvt;
1123 // aEvt.UpdateRect = TODO
1124 mxView->paint( aEvt );
1125 }
1126 catch( Exception& )
1127 {
1128 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::paint()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::paint()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1128" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::paint()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::paint()" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1128" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::paint()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1128" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::paint()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::paint()" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1128" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1129 }
1130}
1131
1132void SAL_CALL SlideshowImpl::addSlideShowListener( const Reference< XSlideShowListener >& xListener )
1133{
1134 if( mxListenerProxy.is() )
1135 mxListenerProxy->addSlideShowListener( xListener );
1136}
1137
1138void SAL_CALL SlideshowImpl::removeSlideShowListener( const Reference< XSlideShowListener >& xListener )
1139{
1140 if( mxListenerProxy.is() )
1141 mxListenerProxy->removeSlideShowListener( xListener );
1142}
1143
1144void SlideshowImpl::slideEnded(const bool bReverse)
1145{
1146 if (bReverse)
1147 gotoPreviousSlide(true);
1148 else
1149 gotoNextSlide();
1150}
1151
1152bool SlideshowImpl::swipe(const CommandSwipeData &rSwipeData)
1153{
1154 if (mbUsePen || mnContextMenuEvent)
1155 return false;
1156 double nVelocityX = rSwipeData.getVelocityX();
1157 // tdf#108475 make it swipe only if some reasonable movement was involved
1158 if (fabs(nVelocityX) < 50)
1159 return false;
1160 if (nVelocityX > 0)
1161 {
1162 gotoPreviousSlide();
1163 }
1164 else
1165 {
1166 gotoNextEffect();
1167 }
1168 //a swipe is followed by a mouse up, tell the view to ignore that mouse up as we've reacted
1169 //to the swipe instead
1170 mxView->ignoreNextMouseReleased();
1171 return true;
1172}
1173
1174bool SlideshowImpl::longpress(const CommandLongPressData &rLongPressData)
1175{
1176 if (mnContextMenuEvent)
1177 return false;
1178
1179 maPopupMousePos = Point(rLongPressData.getX(), rLongPressData.getY());
1180 mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl )::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubContextMenuHdl)
);
1181
1182 return true;
1183}
1184
1185void SlideshowImpl::removeShapeEvents()
1186{
1187 if( !(mxShow.is() && mxListenerProxy.is()) )
1188 return;
1189
1190 try
1191 {
1192 for( const auto& rEntry : maShapeEventMap )
1193 {
1194 mxListenerProxy->removeShapeEventListener( rEntry.first );
1195 mxShow->setShapeCursor( rEntry.first, awt::SystemPointer::ARROW );
1196 }
1197
1198 maShapeEventMap.clear();
1199 }
1200 catch( Exception& )
1201 {
1202 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::removeShapeEvents()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::removeShapeEvents()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1202" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::removeShapeEvents()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::removeShapeEvents()" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1202" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::removeShapeEvents()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1202" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::removeShapeEvents()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::removeShapeEvents()" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1202" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1203 }
1204}
1205
1206void SlideshowImpl::registerShapeEvents(sal_Int32 nSlideNumber)
1207{
1208 if( nSlideNumber < 0 )
1209 return;
1210
1211 try
1212 {
1213 Reference< XDrawPagesSupplier > xDrawPages( mxModel, UNO_QUERY_THROW );
1214 Reference< XIndexAccess > xPages( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
1215
1216 Reference< XShapes > xDrawPage;
1217 xPages->getByIndex(nSlideNumber) >>= xDrawPage;
1218
1219 if( xDrawPage.is() )
1220 {
1221 Reference< XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY );
1222 if( xMasterPageTarget.is() )
1223 {
1224 Reference< XShapes > xMasterPage = xMasterPageTarget->getMasterPage();
1225 if( xMasterPage.is() )
1226 registerShapeEvents( xMasterPage );
1227 }
1228 registerShapeEvents( xDrawPage );
1229 }
1230 }
1231 catch( Exception& )
1232 {
1233 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::registerShapeEvents()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::registerShapeEvents()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1233" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::registerShapeEvents()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::registerShapeEvents()" <<
" " << exceptionToString(tools_warn_exception); ::sal::
detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1233" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::registerShapeEvents()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1233" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::registerShapeEvents()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::registerShapeEvents()" <<
" " << exceptionToString(tools_warn_exception); ::sal::
detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1233" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1234 }
1235}
1236
1237void SlideshowImpl::registerShapeEvents( Reference< XShapes > const & xShapes )
1238{
1239 try
1240 {
1241 const sal_Int32 nShapeCount = xShapes->getCount();
1242 sal_Int32 nShape;
1243 for( nShape = 0; nShape < nShapeCount; nShape++ )
1244 {
1245 Reference< XShape > xShape;
1246 xShapes->getByIndex( nShape ) >>= xShape;
1247
1248 if( xShape.is() && xShape->getShapeType() == "com.sun.star.drawing.GroupShape" )
1249 {
1250 Reference< XShapes > xSubShapes( xShape, UNO_QUERY );
1251 if( xSubShapes.is() )
1252 registerShapeEvents( xSubShapes );
1253 }
1254
1255 Reference< XPropertySet > xSet( xShape, UNO_QUERY );
1256 if( !xSet.is() )
1257 continue;
1258
1259 Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1260 if( !xSetInfo.is() || !xSetInfo->hasPropertyByName( gsOnClick ) )
1261 continue;
1262
1263 WrappedShapeEventImplPtr pEvent = std::make_shared<WrappedShapeEventImpl>();
1264 xSet->getPropertyValue( gsOnClick ) >>= pEvent->meClickAction;
1265
1266 switch( pEvent->meClickAction )
1267 {
1268 case ClickAction_PREVPAGE:
1269 case ClickAction_NEXTPAGE:
1270 case ClickAction_FIRSTPAGE:
1271 case ClickAction_LASTPAGE:
1272 case ClickAction_STOPPRESENTATION:
1273 break;
1274 case ClickAction_BOOKMARK:
1275 if( xSetInfo->hasPropertyByName( gsBookmark ) )
1276 xSet->getPropertyValue( gsBookmark ) >>= pEvent->maStrBookmark;
1277 if( getSlideNumberForBookmark( pEvent->maStrBookmark ) == -1 )
1278 continue;
1279 break;
1280 case ClickAction_DOCUMENT:
1281 case ClickAction_SOUND:
1282 case ClickAction_PROGRAM:
1283 case ClickAction_MACRO:
1284 if( xSetInfo->hasPropertyByName( gsBookmark ) )
1285 xSet->getPropertyValue( gsBookmark ) >>= pEvent->maStrBookmark;
1286 break;
1287 case ClickAction_VERB:
1288 if( xSetInfo->hasPropertyByName( gsVerb ) )
1289 xSet->getPropertyValue( gsVerb ) >>= pEvent->mnVerb;
1290 break;
1291 default:
1292 continue; // skip all others
1293 }
1294
1295 maShapeEventMap[ xShape ] = pEvent;
1296
1297 if( mxListenerProxy.is() )
1298 mxListenerProxy->addShapeEventListener( xShape );
1299 mxShow->setShapeCursor( xShape, awt::SystemPointer::REFHAND );
1300 }
1301 }
1302 catch( Exception& )
1303 {
1304 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::registerShapeEvents()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::registerShapeEvents()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1304" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::registerShapeEvents()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::registerShapeEvents()" <<
" " << exceptionToString(tools_warn_exception); ::sal::
detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1304" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::registerShapeEvents()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1304" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::registerShapeEvents()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::registerShapeEvents()" <<
" " << exceptionToString(tools_warn_exception); ::sal::
detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1304" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1305 }
1306}
1307
1308void SlideshowImpl::displayCurrentSlide (const bool bSkipAllMainSequenceEffects)
1309{
1310 stopSound();
1311 removeShapeEvents();
1312
1313 if( mpSlideController && mxShow.is() )
1314 {
1315 Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(),
1316 UNO_QUERY_THROW );
1317 mpSlideController->displayCurrentSlide( mxShow, xDrawPages, bSkipAllMainSequenceEffects );
1318 registerShapeEvents(mpSlideController->getCurrentSlideNumber());
1319 update();
1320
1321 }
1322 // send out page change event and notify to update all acc info for current page
1323 if (mpViewShell)
1324 {
1325 sal_Int32 currentPageIndex = getCurrentSlideIndex();
1326 mpViewShell->fireSwitchCurrentPage(currentPageIndex);
1327 mpViewShell->NotifyAccUpdate();
1328 }
1329}
1330
1331void SlideshowImpl::endPresentation()
1332{
1333 if( maPresSettings.mbMouseAsPen)
1334 {
1335 Reference< XMultiServiceFactory > xDocFactory(mpDoc->getUnoModel(), UNO_QUERY );
1336 if( xDocFactory.is() )
1337 mxShow->registerUserPaintPolygons(xDocFactory);
1338 }
1339
1340 if( !mnEndShowEvent )
1341 mnEndShowEvent = Application::PostUserEvent( LINK(this, SlideshowImpl, endPresentationHdl)::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubendPresentationHdl)
);
1342}
1343
1344IMPL_LINK_NOARG(SlideshowImpl, endPresentationHdl, void*, void)void SlideshowImpl::LinkStubendPresentationHdl(void * instance
, void* data) { return static_cast<SlideshowImpl *>(instance
)->endPresentationHdl(data); } void SlideshowImpl::endPresentationHdl
(__attribute__ ((unused)) void*)
1345{
1346 mnEndShowEvent = nullptr;
1347
1348 if( mxPresentation.is() )
1349 mxPresentation->end();
1350}
1351
1352void SAL_CALL SlideshowImpl::pause()
1353{
1354 SolarMutexGuard aSolarGuard;
1355
1356 if( mbIsPaused )
1357 return;
1358
1359 try
1360 {
1361 mbIsPaused = true;
1362 if( mxShow.is() )
1363 {
1364 mxShow->pause(true);
1365
1366 if( mxListenerProxy.is() )
1367 mxListenerProxy->paused();
1368 }
1369 }
1370 catch( Exception& )
1371 {
1372 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::pause()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::pause()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1372" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::pause()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::pause()" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1372" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::pause()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1372" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::pause()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::pause()" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1372" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1373 }
1374}
1375
1376void SAL_CALL SlideshowImpl::resume()
1377{
1378 SolarMutexGuard aSolarGuard;
1379
1380 if( mbIsPaused ) try
1381 {
1382 if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
1383 {
1384 mpShowWindow->RestartShow();
1385 }
1386 else
1387 {
1388 mbIsPaused = false;
1389 if( mxShow.is() )
1390 {
1391 mxShow->pause(false);
1392 update();
1393
1394 if( mxListenerProxy.is() )
1395 mxListenerProxy->resumed();
1396 }
1397 }
1398 }
1399 catch( Exception& )
1400 {
1401 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::resume()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::resume()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1401" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::resume()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::resume()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1401" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::resume()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1401" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::resume()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::resume()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1401" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1402 }
1403#ifdef ENABLE_SDREMOTE1
1404 RemoteServer::presentationStarted( this );
1405#endif
1406}
1407
1408sal_Bool SAL_CALL SlideshowImpl::isPaused()
1409{
1410 SolarMutexGuard aSolarGuard;
1411 return mbIsPaused;
1412}
1413
1414void SAL_CALL SlideshowImpl::blankScreen( sal_Int32 nColor )
1415{
1416 SolarMutexGuard aSolarGuard;
1417
1418 if( mpShowWindow && mpSlideController )
1419 {
1420 if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), Color(nColor) ) )
1421 {
1422 pause();
1423 }
1424 }
1425}
1426
1427// XShapeEventListener
1428
1429void SlideshowImpl::click( const Reference< XShape >& xShape )
1430{
1431 SolarMutexGuard aSolarGuard;
1432
1433 WrappedShapeEventImplPtr pEvent = maShapeEventMap[xShape];
1434 if( !pEvent )
1435 return;
1436
1437 switch( pEvent->meClickAction )
1438 {
1439 case ClickAction_PREVPAGE: gotoPreviousSlide(); break;
1440 case ClickAction_NEXTPAGE: gotoNextSlide(); break;
1441 case ClickAction_FIRSTPAGE: gotoFirstSlide(); break;
1442 case ClickAction_LASTPAGE: gotoLastSlide(); break;
1443 case ClickAction_STOPPRESENTATION: endPresentation(); break;
1444 case ClickAction_BOOKMARK:
1445 {
1446 gotoBookmark( pEvent->maStrBookmark );
1447 }
1448 break;
1449 case ClickAction_SOUND:
1450 {
1451#if HAVE_FEATURE_AVMEDIA1
1452 try
1453 {
1454 mxPlayer.set(avmedia::MediaWindow::createPlayer(pEvent->maStrBookmark, ""/*TODO?*/), uno::UNO_SET_THROW );
1455 mxPlayer->start();
1456 }
1457 catch( uno::Exception& )
1458 {
1459 OSL_FAIL("sd::SlideshowImpl::click(), exception caught!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1459" ": "), "%s", "sd::SlideshowImpl::click(), exception caught!"
); } } while (false)
;
1460 }
1461#endif
1462 }
1463 break;
1464
1465 case ClickAction_DOCUMENT:
1466 {
1467 OUString aBookmark( pEvent->maStrBookmark );
1468
1469 sal_Int32 nPos = aBookmark.indexOf( '#' );
1470 if( nPos >= 0 )
1471 {
1472 OUString aURL( aBookmark.copy( 0, nPos+1 ) );
1473 OUString aName( aBookmark.copy( nPos+1 ) );
1474 aURL += getUiNameFromPageApiNameImpl( aName );
1475 aBookmark = aURL;
1476 }
1477
1478 mpDocSh->OpenBookmark( aBookmark );
1479 }
1480 break;
1481
1482 case ClickAction_PROGRAM:
1483 {
1484 INetURLObject aURL(
1485 ::URIHelper::SmartRel2Abs(
1486 INetURLObject(mpDocSh->GetMedium()->GetBaseURL()),
1487 pEvent->maStrBookmark, ::URIHelper::GetMaybeFileHdl(), true,
1488 false, INetURLObject::EncodeMechanism::WasEncoded,
1489 INetURLObject::DecodeMechanism::Unambiguous ) );
1490
1491 if( INetProtocol::File == aURL.GetProtocol() )
1492 {
1493 SfxStringItem aUrl( SID_FILE_NAME(5000 + 507), aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1494 SfxBoolItem aBrowsing( SID_BROWSE(5000 + 1658), true );
1495
1496 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
1497 if (pViewFrm)
1498 {
1499 pViewFrm->GetDispatcher()->ExecuteList( SID_OPENDOC(5000 + 501),
1500 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
1501 { &aUrl, &aBrowsing });
1502 }
1503 }
1504 }
1505 break;
1506
1507 case presentation::ClickAction_MACRO:
1508 {
1509 const OUString aMacro( pEvent->maStrBookmark );
1510
1511 if ( SfxApplication::IsXScriptURL( aMacro ) )
1512 {
1513 Any aRet;
1514 Sequence< sal_Int16 > aOutArgsIndex;
1515 Sequence< Any > aOutArgs;
1516 Sequence< Any >* pInArgs = new Sequence< Any >(0);
1517 mpDocSh->CallXScript( aMacro, *pInArgs, aRet, aOutArgsIndex, aOutArgs);
1518 }
1519 else
1520 {
1521 // aMacro has the following syntax:
1522 // "Macroname.Modulname.Libname.Documentname" or
1523 // "Macroname.Modulname.Libname.Applicationname"
1524 sal_Int32 nIdx{ 0 };
1525 const OUString aMacroName = aMacro.getToken(0, '.', nIdx);
1526 const OUString aModulName = aMacro.getToken(0, '.', nIdx);
1527
1528 // todo: is the limitation still given that only
1529 // Modulname+Macroname can be used here?
1530 OUString aExecMacro = aModulName + "." + aMacroName;
1531 mpDocSh->GetBasic()->Call(aExecMacro);
1532 }
1533 }
1534 break;
1535
1536 case ClickAction_VERB:
1537 {
1538 // todo, better do it async?
1539 SdrObject* pObj = GetSdrObjectFromXShape( xShape );
1540 SdrOle2Obj* pOleObject = dynamic_cast< SdrOle2Obj* >(pObj);
1541 if (pOleObject && mpViewShell )
1542 mpViewShell->ActivateObject(pOleObject, pEvent->mnVerb);
1543 }
1544 break;
1545 default:
1546 break;
1547 }
1548}
1549
1550sal_Int32 SlideshowImpl::getSlideNumberForBookmark( const OUString& rStrBookmark )
1551{
1552 bool bIsMasterPage;
1553 OUString aBookmark = getUiNameFromPageApiNameImpl( rStrBookmark );
1554 sal_uInt16 nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
1555
1556 if( nPgNum == SDRPAGE_NOTFOUND0xFFFF )
1557 {
1558 // Is the bookmark an object?
1559 SdrObject* pObj = mpDoc->GetObj( aBookmark );
1560
1561 if( pObj )
1562 {
1563 nPgNum = pObj->getSdrPageFromSdrObject()->GetPageNum();
1564 bIsMasterPage = pObj->getSdrPageFromSdrObject()->IsMasterPage();
1565 }
1566 }
1567
1568 if( (nPgNum == SDRPAGE_NOTFOUND0xFFFF) || bIsMasterPage || static_cast<SdPage*>(mpDoc->GetPage(nPgNum))->GetPageKind() != PageKind::Standard )
1569 return -1;
1570
1571 return ( nPgNum - 1) >> 1;
1572}
1573
1574void SlideshowImpl::hyperLinkClicked( OUString const& aHyperLink )
1575{
1576 OUString aBookmark( aHyperLink );
1577
1578 sal_Int32 nPos = aBookmark.indexOf( '#' );
1579 if( nPos >= 0 )
1580 {
1581 OUString aURL( aBookmark.copy( 0, nPos+1 ) );
1582 OUString aName( aBookmark.copy( nPos+1 ) );
1583 aURL += getUiNameFromPageApiNameImpl( aName );
1584 aBookmark = aURL;
1585 }
1586
1587 mpDocSh->OpenBookmark( aBookmark );
1588}
1589
1590void SlideshowImpl::displaySlideNumber( sal_Int32 nSlideNumber )
1591{
1592 if( mpSlideController )
1593 {
1594 if( mpSlideController->jumpToSlideNumber( nSlideNumber ) )
1595 {
1596 displayCurrentSlide();
1597 }
1598 }
1599}
1600
1601/** nSlideIndex == -1 displays current slide again */
1602void SlideshowImpl::displaySlideIndex( sal_Int32 nSlideIndex )
1603{
1604 if( mpSlideController )
1605 {
1606 if( (nSlideIndex == -1) || mpSlideController->jumpToSlideIndex( nSlideIndex ) )
1607 {
1608 displayCurrentSlide();
1609 }
1610 }
1611}
1612
1613void SlideshowImpl::jumpToBookmark( const OUString& sBookmark )
1614{
1615 sal_Int32 nSlideNumber = getSlideNumberForBookmark( sBookmark );
1616 if( nSlideNumber != -1 )
1617 displaySlideNumber( nSlideNumber );
1618}
1619
1620sal_Int32 SlideshowImpl::getCurrentSlideNumber() const
1621{
1622 return mpSlideController ? mpSlideController->getCurrentSlideNumber() : -1;
1623}
1624
1625sal_Bool SAL_CALL SlideshowImpl::isEndless()
1626{
1627 SolarMutexGuard aSolarGuard;
1628 return maPresSettings.mbEndless;
1629}
1630
1631void SlideshowImpl::update()
1632{
1633 startUpdateTimer();
1634}
1635
1636void SlideshowImpl::startUpdateTimer()
1637{
1638 SolarMutexGuard aSolarGuard;
1639 maUpdateTimer.SetTimeout( 0 );
1640 maUpdateTimer.Start();
1641}
1642
1643/** this timer is called 20ms after a new slide was displayed.
1644 This is used to unfreeze user input that was disabled after
1645 slide change to skip input that was buffered during slide
1646 transition preparation */
1647IMPL_LINK_NOARG(SlideshowImpl, ReadyForNextInputHdl, Timer *, void)void SlideshowImpl::LinkStubReadyForNextInputHdl(void * instance
, Timer * data) { return static_cast<SlideshowImpl *>(instance
)->ReadyForNextInputHdl(data); } void SlideshowImpl::ReadyForNextInputHdl
(__attribute__ ((unused)) Timer *)
1648{
1649 mbInputFreeze = false;
1650}
1651
1652/** if I catch someone someday who calls this method by hand
1653 and not by using the timer, I will personally punish this
1654 person seriously, even if this person is me.
1655*/
1656IMPL_LINK_NOARG(SlideshowImpl, updateHdl, Timer *, void)void SlideshowImpl::LinkStubupdateHdl(void * instance, Timer *
data) { return static_cast<SlideshowImpl *>(instance)->
updateHdl(data); } void SlideshowImpl::updateHdl(__attribute__
((unused)) Timer *)
1657{
1658 updateSlideShow();
1659}
1660
1661void SlideshowImpl::updateSlideShow()
1662{
1663 // prevent me from deletion when recursing (App::EnableYieldMode does)
1664 const rtl::Reference<SlideshowImpl> xKeepAlive(this);
1665
1666 Reference< XSlideShow > xShow( mxShow );
1667 if ( ! xShow.is())
1668 return;
1669
1670 try
1671 {
1672 double fUpdate = 0.0;
1673 if( !xShow->update(fUpdate) )
1674 fUpdate = -1.0;
1675
1676 if (mxShow.is() && (fUpdate >= 0.0))
1677 {
1678 if (::basegfx::fTools::equalZero(fUpdate))
1679 {
1680 // Make sure idle tasks don't starve when we don't have to wait.
1681 Scheduler::ProcessEventsToIdle();
1682 }
1683 else
1684 {
1685 // Avoid busy loop when the previous call to update()
1686 // returns a small positive number but not 0 (which is
1687 // handled above). Also, make sure that calls to update()
1688 // have a minimum frequency.
1689 // => Allow up to 60 frames per second. Call at least once
1690 // every 4 seconds.
1691 const static sal_Int32 nMaximumFrameCount (60);
1692 const static double nMinimumTimeout (1.0 / nMaximumFrameCount);
1693 const static double nMaximumTimeout (4.0);
1694 fUpdate = std::clamp(fUpdate, nMinimumTimeout, nMaximumTimeout);
1695
1696 // Make sure that the maximum frame count has not been set
1697 // too high (only then conversion to milliseconds and long
1698 // integer may lead to zero value.)
1699 OSL_ASSERT(static_cast<sal_uLong>(fUpdate * 1000.0) > 0)do { if (true && (!(static_cast<sal_uLong>(fUpdate
* 1000.0) > 0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1699" ": "), "OSL_ASSERT: %s", "static_cast<sal_uLong>(fUpdate * 1000.0) > 0"
); } } while (false)
;
1700 }
1701
1702 // Use our high resolution timers for the asynchronous callback.
1703 maUpdateTimer.SetTimeout(static_cast<sal_uLong>(fUpdate * 1000.0));
1704 maUpdateTimer.Start();
1705 }
1706 }
1707 catch( Exception& )
1708 {
1709 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::updateSlideShow()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::updateSlideShow()" << " "
<< exceptionToString(tools_warn_exception)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1709" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::updateSlideShow()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::updateSlideShow()" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1709" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::updateSlideShow()" << " "
<< exceptionToString(tools_warn_exception)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1709" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::updateSlideShow()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::updateSlideShow()" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1709" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1710 }
1711}
1712
1713bool SlideshowImpl::keyInput(const KeyEvent& rKEvt)
1714{
1715 if( !mxShow.is() || mbInputFreeze )
1716 return false;
1717
1718 bool bRet = true;
1719
1720 try
1721 {
1722 const int nKeyCode = rKEvt.GetKeyCode().GetCode();
1723 switch( nKeyCode )
1724 {
1725 case awt::Key::CONTEXTMENU:
1726 if( !mnContextMenuEvent )
1727 {
1728 if( mpShowWindow )
1729 maPopupMousePos = mpShowWindow->GetPointerState().maPos;
1730 mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl )::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubContextMenuHdl)
);
1731 }
1732 break;
1733
1734 // cancel show
1735 case KEY_ESCAPE:
1736 case KEY_SUBTRACT:
1737 // in case the user cancels the presentation, switch to current slide
1738 // in edit mode
1739 if( mpSlideController && (ANIMATIONMODE_SHOW == meAnimationMode) )
1740 {
1741 if( mpSlideController->getCurrentSlideNumber() != -1 )
1742 mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
1743 }
1744 endPresentation();
1745 break;
1746
1747 // advance show
1748 case KEY_PAGEDOWN:
1749 if(rKEvt.GetKeyCode().IsMod2())
1750 {
1751 gotoNextSlide();
1752 break;
1753 }
1754 [[fallthrough]];
1755 case KEY_SPACE:
1756 case KEY_RIGHT:
1757 case KEY_DOWN:
1758 case KEY_N:
1759 gotoNextEffect();
1760 break;
1761
1762 case KEY_RETURN:
1763 {
1764 if( !maCharBuffer.isEmpty() )
1765 {
1766 if( mpSlideController )
1767 {
1768 if( mpSlideController->jumpToSlideNumber( maCharBuffer.toInt32() - 1 ) )
1769 displayCurrentSlide();
1770 }
1771 maCharBuffer.clear();
1772 }
1773 else
1774 {
1775 gotoNextEffect();
1776 }
1777 }
1778 break;
1779
1780 // numeric: add to buffer
1781 case KEY_0:
1782 case KEY_1:
1783 case KEY_2:
1784 case KEY_3:
1785 case KEY_4:
1786 case KEY_5:
1787 case KEY_6:
1788 case KEY_7:
1789 case KEY_8:
1790 case KEY_9:
1791 maCharBuffer += OUStringChar( rKEvt.GetCharCode() );
1792 break;
1793
1794 case KEY_PAGEUP:
1795 if(rKEvt.GetKeyCode().IsMod2())
1796 {
1797 gotoPreviousSlide();
1798 break;
1799 }
1800 [[fallthrough]];
1801 case KEY_LEFT:
1802 case KEY_UP:
1803 case KEY_P:
1804 case KEY_BACKSPACE:
1805 gotoPreviousEffect();
1806 break;
1807
1808 case KEY_HOME:
1809 gotoFirstSlide();
1810 break;
1811
1812 case KEY_END:
1813 gotoLastSlide();
1814 break;
1815
1816 case KEY_B:
1817 case KEY_W:
1818 case KEY_POINT:
1819 case KEY_COMMA:
1820 {
1821 blankScreen( ((nKeyCode == KEY_W ) || (nKeyCode == KEY_COMMA)) ? 0x00ffffff : 0x00000000 );
1822 }
1823 break;
1824
1825 default:
1826 bRet = false;
1827 break;
1828 }
1829 }
1830 catch( Exception& )
1831 {
1832 bRet = false;
1833 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::keyInput()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::keyInput()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1833" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::keyInput()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::keyInput()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1833" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::keyInput()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1833" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::keyInput()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::keyInput()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "1833" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1834 }
1835
1836 return bRet;
1837}
1838
1839IMPL_LINK( SlideshowImpl, EventListenerHdl, VclSimpleEvent&, rSimpleEvent, void )void SlideshowImpl::LinkStubEventListenerHdl(void * instance,
VclSimpleEvent& data) { return static_cast<SlideshowImpl
*>(instance)->EventListenerHdl(data); } void SlideshowImpl
::EventListenerHdl(VclSimpleEvent& rSimpleEvent)
1840{
1841 if( !mxShow.is() || mbInputFreeze )
1842 return;
1843
1844 if( !((rSimpleEvent.GetId() == VclEventId::WindowCommand) && static_cast<VclWindowEvent*>(&rSimpleEvent)->GetData()) )
1845 return;
1846
1847 const CommandEvent& rEvent = *static_cast<const CommandEvent*>(static_cast<VclWindowEvent*>(&rSimpleEvent)->GetData());
1848
1849 if( rEvent.GetCommand() != CommandEventId::Media )
1850 return;
1851
1852 CommandMediaData* pMediaData = rEvent.GetMediaData();
1853 pMediaData->SetPassThroughToOS(false);
1854 switch (pMediaData->GetMediaId())
1855 {
1856#if defined( MACOSX )
1857 case MediaCommand::Menu:
1858 if( !mnContextMenuEvent )
1859 {
1860 if( mpShowWindow )
1861 maPopupMousePos = mpShowWindow->GetPointerState().maPos;
1862 mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl )::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubContextMenuHdl)
);
1863 }
1864 break;
1865 case MediaCommand::VolumeDown:
1866 gotoPreviousSlide();
1867 break;
1868 case MediaCommand::VolumeUp:
1869 gotoNextEffect();
1870 break;
1871#endif
1872 case MediaCommand::NextTrack:
1873 gotoNextEffect();
1874 break;
1875 case MediaCommand::Pause:
1876 if( !mbIsPaused )
1877 blankScreen(0);
1878 break;
1879 case MediaCommand::Play:
1880 if( mbIsPaused )
1881 resume();
1882 break;
1883
1884 case MediaCommand::PlayPause:
1885 if( mbIsPaused )
1886 resume();
1887 else
1888 blankScreen(0);
1889 break;
1890 case MediaCommand::PreviousTrack:
1891 gotoPreviousSlide();
1892 break;
1893 case MediaCommand::NextTrackHold:
1894 gotoLastSlide();
1895 break;
1896
1897 case MediaCommand::Rewind:
1898 gotoFirstSlide();
1899 break;
1900 case MediaCommand::Stop:
1901 // in case the user cancels the presentation, switch to current slide
1902 // in edit mode
1903 if( mpSlideController && (ANIMATIONMODE_SHOW == meAnimationMode) )
1904 {
1905 if( mpSlideController->getCurrentSlideNumber() != -1 )
1906 mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
1907 }
1908 endPresentation();
1909 break;
1910 default:
1911 pMediaData->SetPassThroughToOS(true);
1912 break;
1913 }
1914}
1915
1916void SlideshowImpl::mouseButtonUp(const MouseEvent& rMEvt)
1917{
1918 if( rMEvt.IsRight() && !mnContextMenuEvent )
1919 {
1920 maPopupMousePos = rMEvt.GetPosPixel();
1921 mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl )::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubContextMenuHdl)
);
1922 }
1923}
1924
1925IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, void)void SlideshowImpl::LinkStubContextMenuHdl(void * instance, void
* data) { return static_cast<SlideshowImpl *>(instance)
->ContextMenuHdl(data); } void SlideshowImpl::ContextMenuHdl
(__attribute__ ((unused)) void*)
1926{
1927 mnContextMenuEvent = nullptr;
1928
1929 if (mpSlideController == nullptr)
1930 return;
1931
1932 mbWasPaused = mbIsPaused;
1933 if( !mbWasPaused )
1934 pause();
1935
1936 VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), "modules/simpress/ui/slidecontextmenu.ui", "");
1937 VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu"));
1938
1939 // Adding button to display if in Pen mode
1940 pMenu->CheckItem("pen", mbUsePen);
1941
1942 const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
1943 pMenu->EnableItem(pMenu->GetItemId("next"), mpSlideController->getNextSlideIndex() != -1);
1944 pMenu->EnableItem(pMenu->GetItemId("prev"), (mpSlideController->getPreviousSlideIndex() != -1 ) || (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK));
1945 pMenu->EnableItem(pMenu->GetItemId("edit"), mpViewShell->GetDoc()->IsStartWithPresentation());
1946
1947 PopupMenu* pPageMenu = pMenu->GetPopupMenu(pMenu->GetItemId("goto"));
1948
1949 SfxViewFrame* pViewFrame = getViewFrame();
1950 if( pViewFrame )
1951 {
1952 Reference< css::frame::XFrame > xFrame( pViewFrame->GetFrame().GetFrameInterface() );
1953 if( xFrame.is() )
1954 {
1955 pMenu->SetItemImage(pMenu->GetItemId("next"), vcl::CommandInfoProvider::GetImageForCommand(".uno:NextRecord", xFrame));
1956 pMenu->SetItemImage(pMenu->GetItemId("prev"), vcl::CommandInfoProvider::GetImageForCommand(".uno:PrevRecord", xFrame));
1957
1958 if( pPageMenu )
1959 {
1960 pPageMenu->SetItemImage(pPageMenu->GetItemId("first"), vcl::CommandInfoProvider::GetImageForCommand(".uno:FirstRecord", xFrame));
1961 pPageMenu->SetItemImage(pPageMenu->GetItemId("last"), vcl::CommandInfoProvider::GetImageForCommand(".uno:LastRecord", xFrame));
1962 }
1963 }
1964 }
1965
1966 // populate slide goto list
1967 if( pPageMenu )
1968 {
1969 const sal_Int32 nPageNumberCount = mpSlideController->getSlideNumberCount();
1970 if( nPageNumberCount <= 1 )
1971 {
1972 pMenu->EnableItem(pMenu->GetItemId("goto"), false);
1973 }
1974 else
1975 {
1976 sal_Int32 nCurrentSlideNumber = mpSlideController->getCurrentSlideNumber();
1977 if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
1978 nCurrentSlideNumber = -1;
1979
1980 pPageMenu->EnableItem(pPageMenu->GetItemId("first"), mpSlideController->getSlideNumber(0) != nCurrentSlideNumber);
1981 pPageMenu->EnableItem(pPageMenu->GetItemId("last"), mpSlideController->getSlideNumber(mpSlideController->getSlideIndexCount() - 1) != nCurrentSlideNumber);
1982
1983 sal_Int32 nPageNumber;
1984
1985 for( nPageNumber = 0; nPageNumber < nPageNumberCount; nPageNumber++ )
1986 {
1987 if( mpSlideController->isVisibleSlideNumber( nPageNumber ) )
1988 {
1989 SdPage* pPage = mpDoc->GetSdPage(static_cast<sal_uInt16>(nPageNumber), PageKind::Standard);
1990 if (pPage)
1991 {
1992 pPageMenu->InsertItem( static_cast<sal_uInt16>(CM_SLIDES21 + nPageNumber), pPage->GetName() );
1993 if( nPageNumber == nCurrentSlideNumber )
1994 pPageMenu->CheckItem( static_cast<sal_uInt16>(CM_SLIDES21 + nPageNumber) );
1995 }
1996 }
1997 }
1998 }
1999 }
2000
2001 if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
2002 {
2003 PopupMenu* pBlankMenu = pMenu->GetPopupMenu(pMenu->GetItemId("screen"));
2004 if( pBlankMenu )
2005 {
2006 pBlankMenu->CheckItem((mpShowWindow->GetBlankColor() == COL_WHITE) ? "white" : "black");
2007 }
2008 }
2009
2010 PopupMenu* pWidthMenu = pMenu->GetPopupMenu(pMenu->GetItemId("width"));
2011
2012 // populate color width list
2013 if( pWidthMenu )
2014 {
2015 sal_Int32 nIterator;
2016 double nWidth;
2017
2018 nWidth = 4.0;
2019 for( nIterator = 1; nIterator < 6; nIterator++)
2020 {
2021 switch(nIterator)
2022 {
2023 case 1:
2024 nWidth = 4.0;
2025 break;
2026 case 2:
2027 nWidth = 100.0;
2028 break;
2029 case 3:
2030 nWidth = 150.0;
2031 break;
2032 case 4:
2033 nWidth = 200.0;
2034 break;
2035 case 5:
2036 nWidth = 400.0;
2037 break;
2038 default:
2039 break;
2040 }
2041
2042 if (nWidth == mdUserPaintStrokeWidth)
2043 pWidthMenu->CheckItem(OString::number(nWidth));
2044 }
2045 }
2046
2047 pMenu->SetSelectHdl( LINK( this, SlideshowImpl, ContextMenuSelectHdl )::tools::detail::makeLink( ::tools::detail::castTo<SlideshowImpl
*>(this), &SlideshowImpl::LinkStubContextMenuSelectHdl
)
);
2048 pMenu->Execute( mpShowWindow, maPopupMousePos );
2049
2050 if( mxView.is() )
2051 mxView->ignoreNextMouseReleased();
2052
2053 if( !mbWasPaused )
2054 resume();
2055}
2056
2057IMPL_LINK( SlideshowImpl, ContextMenuSelectHdl, Menu *, pMenu, bool )bool SlideshowImpl::LinkStubContextMenuSelectHdl(void * instance
, Menu * data) { return static_cast<SlideshowImpl *>(instance
)->ContextMenuSelectHdl(data); } bool SlideshowImpl::ContextMenuSelectHdl
(Menu * pMenu)
2058{
2059 if (!pMenu)
2060 return false;
2061
2062 OString sMenuId = pMenu->GetCurItemIdent();
2063
2064 if (sMenuId == "prev")
2065 {
2066 gotoPreviousSlide();
2067 mbWasPaused = false;
2068 }
2069 else if(sMenuId == "next")
2070 {
2071 gotoNextSlide();
2072 mbWasPaused = false;
2073 }
2074 else if (sMenuId == "first")
2075 {
2076 gotoFirstSlide();
2077 mbWasPaused = false;
2078 }
2079 else if (sMenuId == "last")
2080 {
2081 gotoLastSlide();
2082 mbWasPaused = false;
2083 }
2084 else if (sMenuId == "black" || sMenuId == "white")
2085 {
2086 const Color aBlankColor(sMenuId == "white" ? COL_WHITE : COL_BLACK);
2087 if( mbWasPaused )
2088 {
2089 if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
2090 {
2091 if( mpShowWindow->GetBlankColor() == aBlankColor )
2092 {
2093 mbWasPaused = false;
2094 mpShowWindow->RestartShow();
2095 return false;
2096 }
2097 }
2098 mpShowWindow->RestartShow();
2099 }
2100 if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), aBlankColor ) )
2101 {
2102 pause();
2103 mbWasPaused = true;
2104 }
2105 }
2106 else if (sMenuId == "color")
2107 {
2108 //Open a color picker based on SvColorDialog
2109 ::Color aColor( mnUserPaintColor );
2110 SvColorDialog aColorDlg;
2111 aColorDlg.SetColor( aColor );
2112
2113 if (aColorDlg.Execute(mpShowWindow->GetFrameWeld()))
2114 {
2115 aColor = aColorDlg.GetColor();
2116 setPenColor(sal_Int32(aColor));
2117 }
2118 mbWasPaused = false;
2119 }
2120 else if (sMenuId == "4")
2121 {
2122 setPenWidth(4.0);
2123 mbWasPaused = false;
2124 }
2125 else if (sMenuId == "100")
2126 {
2127 setPenWidth(100.0);
2128 mbWasPaused = false;
2129 }
2130 else if (sMenuId == "150")
2131 {
2132 setPenWidth(150.0);
2133 mbWasPaused = false;
2134 }
2135 else if (sMenuId == "200")
2136 {
2137 setPenWidth(200.0);
2138 mbWasPaused = false;
2139 }
2140 else if (sMenuId == "400")
2141 {
2142 setPenWidth(400.0);
2143 mbWasPaused = false;
2144 }
2145 else if (sMenuId == "erase")
2146 {
2147 setEraseAllInk(true);
2148 mbWasPaused = false;
2149 }
2150 else if (sMenuId == "pen")
2151 {
2152 setUsePen(!mbUsePen);
2153 mbWasPaused = false;
2154 }
2155 else if (sMenuId == "edit")
2156 {
2157 // When in autoplay mode (pps/ppsx), offer editing of the presentation
2158 // Turn autostart off, else Impress will close when exiting the Presentation
2159 mpViewShell->GetDoc()->SetExitAfterPresenting(false);
2160 if( mpSlideController && (ANIMATIONMODE_SHOW == meAnimationMode) )
2161 {
2162 if( mpSlideController->getCurrentSlideNumber() != -1 )
2163 {
2164 mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
2165 }
2166 }
2167 endPresentation();
2168 }
2169 else if (sMenuId == "end")
2170 {
2171 // in case the user cancels the presentation, switch to current slide
2172 // in edit mode
2173 if( mpSlideController && (ANIMATIONMODE_SHOW == meAnimationMode) )
2174 {
2175 if( mpSlideController->getCurrentSlideNumber() != -1 )
2176 {
2177 mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
2178 }
2179 }
2180 endPresentation();
2181 }
2182 else
2183 {
2184 sal_Int32 nPageNumber = pMenu->GetCurItemId() - CM_SLIDES21;
2185 const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2186 if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2187 {
2188 mpShowWindow->RestartShow( nPageNumber );
2189 }
2190 else if( nPageNumber != mpSlideController->getCurrentSlideNumber() )
2191 {
2192 displaySlideNumber( nPageNumber );
2193 }
2194 mbWasPaused = false;
2195 }
2196
2197 return false;
2198}
2199
2200Reference< XSlideShow > SlideshowImpl::createSlideShow()
2201{
2202 Reference< XSlideShow > xShow;
2203
2204 try
2205 {
2206 Reference< uno::XComponentContext > xContext =
2207 ::comphelper::getProcessComponentContext();
2208
2209 xShow.set( presentation::SlideShow::create(xContext), UNO_SET_THROW );
2210 }
2211 catch( uno::Exception& )
2212 {
2213 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::createSlideShow()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::createSlideShow()" << " "
<< exceptionToString(tools_warn_exception)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2213" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::createSlideShow()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::createSlideShow()" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2213" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::createSlideShow()" << " "
<< exceptionToString(tools_warn_exception)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2213" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::createSlideShow()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::createSlideShow()" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2213" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
2214 }
2215
2216 return xShow;
2217}
2218
2219void SlideshowImpl::createSlideList( bool bAll, const OUString& rPresSlide )
2220{
2221 const sal_uInt16 nSlideCount = mpDoc->GetSdPageCount( PageKind::Standard );
2222
2223 if( !nSlideCount )
2224 return;
2225
2226 SdCustomShow* pCustomShow;
2227
2228 if( mpDoc->GetCustomShowList() && maPresSettings.mbCustomShow )
2229 pCustomShow = mpDoc->GetCustomShowList()->GetCurObject();
2230 else
2231 pCustomShow = nullptr;
2232
2233 // create animation slide controller
2234 AnimationSlideController::Mode eMode =
2235 ( pCustomShow && !pCustomShow->PagesVector().empty() ) ? AnimationSlideController::CUSTOM :
2236 (bAll ? AnimationSlideController::ALL : AnimationSlideController::FROM);
2237
2238 Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
2239 Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
2240 mpSlideController = std::make_shared<AnimationSlideController>( xSlides, eMode );
2241
2242 if( eMode != AnimationSlideController::CUSTOM )
2243 {
2244 sal_Int32 nFirstVisibleSlide = 0;
2245
2246 // normal presentation
2247 if( !rPresSlide.isEmpty() )
2248 {
2249 sal_Int32 nSlide;
2250 bool bTakeNextAvailable = false;
2251
2252 for( nSlide = 0, nFirstVisibleSlide = -1;
2253 ( nSlide < nSlideCount ) && ( -1 == nFirstVisibleSlide ); nSlide++ )
2254 {
2255 SdPage* pTestSlide = mpDoc->GetSdPage( static_cast<sal_uInt16>(nSlide), PageKind::Standard );
2256
2257 if( pTestSlide->GetName() == rPresSlide )
2258 {
2259 if( pTestSlide->IsExcluded() )
2260 bTakeNextAvailable = true;
2261 else
2262 nFirstVisibleSlide = nSlide;
2263 }
2264 else if( bTakeNextAvailable && !pTestSlide->IsExcluded() )
2265 nFirstVisibleSlide = nSlide;
2266 }
2267
2268 if( -1 == nFirstVisibleSlide )
2269 nFirstVisibleSlide = 0;
2270 }
2271
2272 for( sal_Int32 i = 0; i < nSlideCount; i++ )
2273 {
2274 bool bVisible = ! mpDoc->GetSdPage( static_cast<sal_uInt16>(i), PageKind::Standard )->IsExcluded();
2275 if( bVisible || (eMode == AnimationSlideController::ALL) )
2276 mpSlideController->insertSlideNumber( i, bVisible );
2277 }
2278
2279 mpSlideController->setStartSlideNumber( nFirstVisibleSlide );
2280 }
2281 else
2282 {
2283 if( meAnimationMode != ANIMATIONMODE_SHOW && !rPresSlide.isEmpty() )
2284 {
2285 sal_Int32 nSlide;
2286 for( nSlide = 0; nSlide < nSlideCount; nSlide++ )
2287 if( rPresSlide == mpDoc->GetSdPage( static_cast<sal_uInt16>(nSlide), PageKind::Standard )->GetName() )
2288 break;
2289
2290 if( nSlide < nSlideCount )
2291 mpSlideController->insertSlideNumber( static_cast<sal_uInt16>(nSlide) );
2292 }
2293
2294 for( const auto& rpPage : pCustomShow->PagesVector() )
2295 {
2296 const sal_uInt16 nSdSlide = ( rpPage->GetPageNum() - 1 ) / 2;
2297
2298 if( ! mpDoc->GetSdPage( nSdSlide, PageKind::Standard )->IsExcluded())
2299 mpSlideController->insertSlideNumber( nSdSlide );
2300 }
2301 }
2302}
2303
2304typedef sal_uInt16 (*FncGetChildWindowId)();
2305
2306const FncGetChildWindowId aShowChildren[] =
2307{
2308 &AnimationChildWindow::GetChildWindowId,
2309 &Svx3DChildWindow::GetChildWindowId,
2310 &SvxFontWorkChildWindow::GetChildWindowId,
2311 &SvxColorChildWindow::GetChildWindowId,
2312 &SvxSearchDialogWrapper::GetChildWindowId,
2313 &SvxBmpMaskChildWindow::GetChildWindowId,
2314 &SvxIMapDlgChildWindow::GetChildWindowId,
2315 &SvxHlinkDlgWrapper::GetChildWindowId,
2316 &SfxInfoBarContainerChild::GetChildWindowId
2317};
2318
2319void SlideshowImpl::hideChildWindows()
2320{
2321 mnChildMask = 0;
2322
2323 if( ANIMATIONMODE_SHOW != meAnimationMode )
2324 return;
2325
2326 SfxViewFrame* pViewFrame = getViewFrame();
2327
2328 if( !pViewFrame )
2329 return;
2330
2331 for( sal_uLong i = 0; i < SAL_N_ELEMENTS( aShowChildren )(sizeof(sal_n_array_size(aShowChildren))); i++ )
2332 {
2333 const sal_uInt16 nId = ( *aShowChildren[ i ] )();
2334
2335 if( pViewFrame->GetChildWindow( nId ) )
2336 {
2337 pViewFrame->SetChildWindow( nId, false );
2338 mnChildMask |= 1 << i;
2339 }
2340 }
2341}
2342
2343void SlideshowImpl::showChildWindows()
2344{
2345 if( ANIMATIONMODE_SHOW == meAnimationMode )
2346 {
2347 SfxViewFrame* pViewFrame = getViewFrame();
2348 if( pViewFrame )
2349 {
2350 for( sal_uLong i = 0; i < SAL_N_ELEMENTS(aShowChildren)(sizeof(sal_n_array_size(aShowChildren))); i++ )
2351 {
2352 if( mnChildMask & ( 1 << i ) )
2353 pViewFrame->SetChildWindow( ( *aShowChildren[ i ] )(), true );
2354 }
2355 }
2356 }
2357}
2358
2359SfxViewFrame* SlideshowImpl::getViewFrame() const
2360{
2361 return mpViewShell ? mpViewShell->GetViewFrame() : nullptr;
2362}
2363
2364SfxDispatcher* SlideshowImpl::getDispatcher() const
2365{
2366 return (mpViewShell && mpViewShell->GetViewFrame()) ? mpViewShell->GetViewFrame()->GetDispatcher() : nullptr;
2367}
2368
2369SfxBindings* SlideshowImpl::getBindings() const
2370{
2371 return (mpViewShell && mpViewShell->GetViewFrame()) ? &mpViewShell->GetViewFrame()->GetBindings() : nullptr;
2372}
2373
2374void SlideshowImpl::resize( const Size& rSize )
2375{
2376 maPresSize = rSize;
2377
2378 if(mpShowWindow)
2379 {
2380 mpShowWindow->SetSizePixel( maPresSize );
2381 mpShowWindow->Show();
2382 }
2383
2384 if( mxView.is() ) try
2385 {
2386 awt::WindowEvent aEvt;
2387 mxView->windowResized(aEvt);
2388 }
2389 catch( Exception& )
2390 {
2391 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::resize()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::resize()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2391" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::resize()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::resize()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2391" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::resize()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2391" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::resize()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::resize()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2391" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
2392 }
2393}
2394
2395void SlideshowImpl::setActiveXToolbarsVisible( bool bVisible )
2396{
2397 // in case of ActiveX control the toolbars should not be visible if slide show runs in window mode
2398 // actually it runs always in window mode in case of ActiveX control
2399 if ( !(!maPresSettings.mbFullScreen && mpDocSh && mpDocSh->GetMedium()) )
2400 return;
2401
2402 const SfxBoolItem* pItem = SfxItemSet::GetItem<SfxBoolItem>(mpDocSh->GetMedium()->GetItemSet(), SID_VIEWONLY(5000 + 1682), false);
2403 if ( !(pItem && pItem->GetValue()) )
2404 return;
2405
2406 // this is a plugin/activex mode, no toolbars should be visible during slide show
2407 // after the end of slide show they should be visible again
2408 SfxViewFrame* pViewFrame = getViewFrame();
2409 if( !pViewFrame )
2410 return;
2411
2412 try
2413 {
2414 Reference< frame::XLayoutManager > xLayoutManager;
2415 Reference< beans::XPropertySet > xFrameProps( pViewFrame->GetFrame().GetFrameInterface(), UNO_QUERY_THROW );
2416 if ( ( xFrameProps->getPropertyValue( "LayoutManager" )
2417 >>= xLayoutManager )
2418 && xLayoutManager.is() )
2419 {
2420 xLayoutManager->setVisible( bVisible );
2421 }
2422 }
2423 catch( uno::Exception& )
2424 {}
2425}
2426
2427void SAL_CALL SlideshowImpl::activate()
2428{
2429 SolarMutexGuard aSolarGuard;
2430
2431 maDeactivateTimer.Stop();
2432
2433 if( mbActive || !mxShow.is() )
2434 return;
2435
2436 mbActive = true;
2437
2438 if( ANIMATIONMODE_SHOW == meAnimationMode )
2439 {
2440 if( mbAutoSaveWasOn )
2441 setAutoSaveState( false );
2442
2443 if( mpShowWindow )
2444 {
2445 SfxViewFrame* pViewFrame = getViewFrame();
2446 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : nullptr;
2447
2448 hideChildWindows();
2449
2450 if( pDispatcher )
2451 {
2452 // filter all forbidden slots
2453 pDispatcher->SetSlotFilter( SfxSlotFilterState::ENABLED, pAllowed );
2454 }
2455
2456 if( getBindings() )
2457 getBindings()->InvalidateAll(true);
2458
2459 mpShowWindow->GrabFocus();
2460 }
2461 }
2462
2463 resume();
2464}
2465
2466void SAL_CALL SlideshowImpl::deactivate()
2467{
2468 SolarMutexGuard aSolarGuard;
2469
2470 if( mbActive && mxShow.is() )
2471 {
2472 maDeactivateTimer.Start();
2473 }
2474}
2475
2476IMPL_LINK_NOARG(SlideshowImpl, deactivateHdl, Timer *, void)void SlideshowImpl::LinkStubdeactivateHdl(void * instance, Timer
* data) { return static_cast<SlideshowImpl *>(instance
)->deactivateHdl(data); } void SlideshowImpl::deactivateHdl
(__attribute__ ((unused)) Timer *)
2477{
2478 if( !(mbActive && mxShow.is()) )
2479 return;
2480
2481 mbActive = false;
2482
2483 pause();
2484
2485 if( ANIMATIONMODE_SHOW == meAnimationMode )
2486 {
2487 if( mbAutoSaveWasOn )
2488 setAutoSaveState( true );
2489
2490 if( mpShowWindow )
2491 {
2492 showChildWindows();
2493 }
2494 }
2495}
2496
2497sal_Bool SAL_CALL SlideshowImpl::isActive()
2498{
2499 SolarMutexGuard aSolarGuard;
2500 return mbActive;
2501}
2502
2503void SlideshowImpl::setAutoSaveState( bool bOn)
2504{
2505 try
2506 {
2507 uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
2508
2509 uno::Reference< util::XURLTransformer > xParser(util::URLTransformer::create(xContext));
2510 util::URL aURL;
2511 aURL.Complete = "vnd.sun.star.autorecovery:/setAutoSaveState";
2512 xParser->parseStrict(aURL);
2513
2514 Sequence< beans::PropertyValue > aArgs(1);
2515 aArgs[0].Name = "AutoSaveState";
2516 aArgs[0].Value <<= bOn;
2517
2518 uno::Reference< frame::XDispatch > xAutoSave = frame::theAutoRecovery::get(xContext);
2519 xAutoSave->dispatch(aURL, aArgs);
2520 }
2521 catch( Exception& )
2522 {
2523 OSL_FAIL("sd::SlideshowImpl::setAutoSaveState(), exception caught!")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2523" ": "), "%s", "sd::SlideshowImpl::setAutoSaveState(), exception caught!"
); } } while (false)
;
2524 }
2525}
2526
2527Reference< XDrawPage > SAL_CALL SlideshowImpl::getCurrentSlide()
2528{
2529 SolarMutexGuard aSolarGuard;
2530
2531 Reference< XDrawPage > xSlide;
2532 if( mxShow.is() && mpSlideController )
2533 {
2534 sal_Int32 nSlide = getCurrentSlideNumber();
2535 if( (nSlide >= 0) && (nSlide < mpSlideController->getSlideNumberCount() ) )
2536 xSlide = mpSlideController->getSlideByNumber( nSlide );
2537 }
2538
2539 return xSlide;
2540}
2541
2542sal_Int32 SAL_CALL SlideshowImpl::getNextSlideIndex()
2543{
2544 SolarMutexGuard aSolarGuard;
2545
2546 if( mxShow.is() )
2547 {
2548 return mpSlideController->getNextSlideIndex();
2549 }
2550 else
2551 {
2552 return -1;
2553 }
2554}
2555
2556sal_Int32 SAL_CALL SlideshowImpl::getCurrentSlideIndex()
2557{
2558 return mpSlideController ? mpSlideController->getCurrentSlideIndex() : -1;
2559}
2560
2561// css::presentation::XSlideShowController:
2562
2563::sal_Int32 SAL_CALL SlideshowImpl::getSlideCount()
2564{
2565 return mpSlideController ? mpSlideController->getSlideIndexCount() : 0;
2566}
2567
2568Reference< XDrawPage > SAL_CALL SlideshowImpl::getSlideByIndex(::sal_Int32 Index)
2569{
2570 if ((mpSlideController == nullptr) || (Index < 0)
2571 || (Index >= mpSlideController->getSlideIndexCount()))
2572 throw IndexOutOfBoundsException();
2573
2574 return mpSlideController->getSlideByNumber( mpSlideController->getSlideNumber( Index ) );
2575}
2576
2577sal_Bool SAL_CALL SlideshowImpl::getAlwaysOnTop()
2578{
2579 SolarMutexGuard aSolarGuard;
2580 return maPresSettings.mbAlwaysOnTop;
2581}
2582
2583void SAL_CALL SlideshowImpl::setAlwaysOnTop( sal_Bool bAlways )
2584{
2585 SolarMutexGuard aSolarGuard;
2586 if( maPresSettings.mbAlwaysOnTop != bool(bAlways) )
2587 {
2588 maPresSettings.mbAlwaysOnTop = bAlways;
2589 // todo, can this be changed while running?
2590 }
2591}
2592
2593sal_Bool SAL_CALL SlideshowImpl::isFullScreen()
2594{
2595 SolarMutexGuard aSolarGuard;
2596 return maPresSettings.mbFullScreen;
2597}
2598
2599sal_Bool SAL_CALL SlideshowImpl::getMouseVisible()
2600{
2601 SolarMutexGuard aSolarGuard;
2602 return maPresSettings.mbMouseVisible;
2603}
2604
2605void SAL_CALL SlideshowImpl::setMouseVisible( sal_Bool bVisible )
2606{
2607 SolarMutexGuard aSolarGuard;
2608 if( maPresSettings.mbMouseVisible != bool(bVisible) )
2609 {
2610 maPresSettings.mbMouseVisible = bVisible;
2611 if( mpShowWindow )
2612 mpShowWindow->SetMouseAutoHide( !maPresSettings.mbMouseVisible );
2613 }
2614}
2615
2616sal_Bool SAL_CALL SlideshowImpl::getUsePen()
2617{
2618 SolarMutexGuard aSolarGuard;
2619 return mbUsePen;
2620}
2621
2622void SAL_CALL SlideshowImpl::setUsePen( sal_Bool bMouseAsPen )
2623{
2624 SolarMutexGuard aSolarGuard;
2625 mbUsePen = bMouseAsPen;
2626 if( !mxShow.is() )
2627 return;
2628
2629 try
2630 {
2631 // For Pencolor;
2632 Any aValue;
2633 if( mbUsePen )
2634 aValue <<= mnUserPaintColor;
2635 beans::PropertyValue aPenProp;
2636 aPenProp.Name = "UserPaintColor";
2637 aPenProp.Value = aValue;
2638 mxShow->setProperty( aPenProp );
2639
2640 //for StrokeWidth :
2641 if( mbUsePen )
2642 {
2643 beans::PropertyValue aPenPropWidth;
2644 aPenPropWidth.Name = "UserPaintStrokeWidth";
2645 aPenPropWidth.Value <<= mdUserPaintStrokeWidth;
2646 mxShow->setProperty( aPenPropWidth );
2647
2648 // for Pen Mode
2649 beans::PropertyValue aPenPropSwitchPenMode;
2650 aPenPropSwitchPenMode.Name = "SwitchPenMode";
2651 aPenPropSwitchPenMode.Value <<= true;
2652 mxShow->setProperty( aPenPropSwitchPenMode );
2653 }
2654 }
2655 catch( Exception& )
2656 {
2657 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::setUsePen()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::setUsePen()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2657" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::setUsePen()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::setUsePen()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2657" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::setUsePen()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2657" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::setUsePen()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::setUsePen()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2657" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
2658 }
2659}
2660
2661double SAL_CALL SlideshowImpl::getPenWidth()
2662{
2663 SolarMutexGuard aSolarGuard;
2664 return mdUserPaintStrokeWidth;
2665}
2666
2667void SAL_CALL SlideshowImpl::setPenWidth( double dStrokeWidth )
2668{
2669 SolarMutexGuard aSolarGuard;
2670 mdUserPaintStrokeWidth = dStrokeWidth;
2671 setUsePen( true ); // enable pen mode, update color and width
2672}
2673
2674sal_Int32 SAL_CALL SlideshowImpl::getPenColor()
2675{
2676 SolarMutexGuard aSolarGuard;
2677 return mnUserPaintColor;
2678}
2679
2680void SAL_CALL SlideshowImpl::setPenColor( sal_Int32 nColor )
2681{
2682 SolarMutexGuard aSolarGuard;
2683 mnUserPaintColor = nColor;
2684 setUsePen( true ); // enable pen mode, update color
2685}
2686
2687void SlideshowImpl::setEraseAllInk(bool bEraseAllInk)
2688{
2689 if( !bEraseAllInk )
2690 return;
2691
2692 SolarMutexGuard aSolarGuard;
2693 if( !mxShow.is() )
2694 return;
2695
2696 try
2697 {
2698 beans::PropertyValue aPenPropEraseAllInk;
2699 aPenPropEraseAllInk.Name = "EraseAllInk";
2700 aPenPropEraseAllInk.Value <<= bEraseAllInk;
2701 mxShow->setProperty( aPenPropEraseAllInk );
2702 }
2703 catch( Exception& )
2704 {
2705 TOOLS_WARN_EXCEPTION( "sd.slideshow", "sd::SlideshowImpl::setEraseAllInk()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd.slideshow")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "sd::SlideshowImpl::setEraseAllInk()"
<< " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"sd.slideshow"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2705" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::setEraseAllInk()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::setEraseAllInk()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.slideshow"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2705" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::setEraseAllInk()" << " "
<< exceptionToString(tools_warn_exception)) == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.slideshow"
), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2705" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::setEraseAllInk()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::setEraseAllInk()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.slideshow"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2705" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
2706 }
2707}
2708
2709// XSlideShowController Methods
2710sal_Bool SAL_CALL SlideshowImpl::isRunning( )
2711{
2712 SolarMutexGuard aSolarGuard;
2713 return mxShow.is();
2714}
2715
2716void SAL_CALL SlideshowImpl::gotoNextEffect( )
2717{
2718 SolarMutexGuard aSolarGuard;
2719
2720 if( !(mxShow.is() && mpSlideController && mpShowWindow) )
2721 return;
2722
2723 if( mbIsPaused )
2724 resume();
2725
2726 const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2727 if( eMode == SHOWWINDOWMODE_END )
2728 {
2729 endPresentation();
2730 }
2731 else if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2732 {
2733 mpShowWindow->RestartShow();
2734 }
2735 else
2736 {
2737 mxShow->nextEffect();
2738 update();
2739 }
2740}
2741
2742void SAL_CALL SlideshowImpl::gotoPreviousEffect( )
2743{
2744 SolarMutexGuard aSolarGuard;
2745
2746 if( !(mxShow.is() && mpSlideController && mpShowWindow) )
2747 return;
2748
2749 if( mbIsPaused )
2750 resume();
2751
2752 const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2753 if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2754 {
2755 mpShowWindow->RestartShow();
2756 }
2757 else
2758 {
2759 mxShow->previousEffect();
2760 update();
2761 }
2762}
2763
2764void SAL_CALL SlideshowImpl::gotoFirstSlide( )
2765{
2766 SolarMutexGuard aSolarGuard;
2767
2768 if( !(mpShowWindow && mpSlideController) )
2769 return;
2770
2771 if( mbIsPaused )
2772 resume();
2773
2774 if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_END )
2775 {
2776 if( mpSlideController->getSlideIndexCount() )
2777 mpShowWindow->RestartShow( 0);
2778 }
2779 else
2780 {
2781 displaySlideIndex( 0 );
2782 }
2783}
2784
2785void SAL_CALL SlideshowImpl::gotoNextSlide( )
2786{
2787 SolarMutexGuard aSolarGuard;
2788
2789 if( mbIsPaused )
2790 resume();
2791
2792 const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2793 if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2794 {
2795 mpShowWindow->RestartShow();
2796 }
2797 else
2798 {
2799 // if this is a show, ignore user inputs and
2800 // start 20ms timer to reenable inputs to filter
2801 // buffered inputs during slide transition
2802 if( meAnimationMode == ANIMATIONMODE_SHOW )
2803 {
2804 mbInputFreeze = true;
2805 maInputFreezeTimer.Start();
2806 }
2807
2808 if( mpSlideController )
2809 {
2810 if( mpSlideController->nextSlide() )
2811 {
2812 displayCurrentSlide();
2813 }
2814 else
2815 {
2816 stopSound();
2817
2818 if( meAnimationMode == ANIMATIONMODE_PREVIEW )
2819 {
2820 endPresentation();
2821 }
2822 else if( maPresSettings.mbEndless )
2823 {
2824 if( maPresSettings.mnPauseTimeout )
2825 {
2826 if( mpShowWindow )
2827 {
2828 if ( maPresSettings.mbShowPauseLogo )
2829 {
2830 Graphic aGraphic(SfxApplication::GetApplicationLogo(360));
2831 mpShowWindow->SetPauseMode( maPresSettings.mnPauseTimeout, &aGraphic );
2832 }
2833 else
2834 mpShowWindow->SetPauseMode( maPresSettings.mnPauseTimeout );
2835 }
2836 }
2837 else
2838 {
2839 displaySlideIndex( 0 );
2840 }
2841 }
2842 else
2843 {
2844 if( mpShowWindow )
2845 {
2846 mpShowWindow->SetEndMode();
2847 if( !mpViewShell->GetDoc()->IsStartWithPresentation() )
2848 pause();
2849 }
2850 }
2851 }
2852 }
2853 }
2854}
2855
2856void SAL_CALL SlideshowImpl::gotoPreviousSlide( )
2857{
2858 gotoPreviousSlide(false);
2859}
2860
2861void SlideshowImpl::gotoPreviousSlide (const bool bSkipAllMainSequenceEffects)
2862{
2863 SolarMutexGuard aSolarGuard;
2864
2865 if( !(mxShow.is() && mpSlideController) )
2866 return;
2867
2868 try
2869 {
2870 if( mbIsPaused )
2871 resume();
2872
2873 const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2874 if( eMode == SHOWWINDOWMODE_END )
2875 {
2876 mpShowWindow->RestartShow( mpSlideController->getCurrentSlideIndex() );
2877 }
2878 else if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2879 {
2880 mpShowWindow->RestartShow();
2881 }
2882 else
2883 {
2884 if( mpSlideController->previousSlide())
2885 displayCurrentSlide(bSkipAllMainSequenceEffects);
2886 else if (bSkipAllMainSequenceEffects)
2887 {
2888 // We could not go to the previous slide (probably because
2889 // the current slide is already the first one). We still
2890 // have to call displayCurrentSlide because the calling
2891 // slideshow can not determine whether there is a previous
2892 // slide or not and has already prepared for a slide change.
2893 // This slide change has to be completed now, even when
2894 // changing to the same slide.
2895 // Note that in this special case we do NOT pass
2896 // bSkipAllMainSequenceEffects because we display the same
2897 // slide as before and do not want to show all its effects.
2898 displayCurrentSlide();
2899 }
2900 }
2901 }
2902 catch( Exception& )
2903 {
2904 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::gotoPreviousSlide()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::gotoPreviousSlide()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2904" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::gotoPreviousSlide()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::gotoPreviousSlide()" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2904" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::gotoPreviousSlide()" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2904" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::gotoPreviousSlide()"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::gotoPreviousSlide()" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2904" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
2905 }
2906}
2907
2908void SAL_CALL SlideshowImpl::gotoLastSlide()
2909{
2910 SolarMutexGuard aSolarGuard;
2911
2912 if( !mpSlideController )
2913 return;
2914
2915 if( mbIsPaused )
2916 resume();
2917
2918 const sal_Int32 nLastSlideIndex = mpSlideController->getSlideIndexCount() - 1;
2919 if( nLastSlideIndex >= 0 )
2920 {
2921 if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_END )
2922 {
2923 mpShowWindow->RestartShow( nLastSlideIndex );
2924 }
2925 else
2926 {
2927 displaySlideIndex( nLastSlideIndex );
2928 }
2929 }
2930}
2931
2932void SAL_CALL SlideshowImpl::gotoBookmark( const OUString& rBookmark )
2933{
2934 SolarMutexGuard aSolarGuard;
2935
2936 if( mbIsPaused )
2937 resume();
2938
2939 sal_Int32 nSlideNumber = getSlideNumberForBookmark( rBookmark );
2940 if( nSlideNumber != -1 )
2941 displaySlideNumber( nSlideNumber );
2942}
2943
2944void SAL_CALL SlideshowImpl::gotoSlide( const Reference< XDrawPage >& xSlide )
2945{
2946 SolarMutexGuard aSolarGuard;
2947
2948 if( !(mpSlideController && xSlide.is()) )
2949 return;
2950
2951 if( mbIsPaused )
2952 resume();
2953
2954 const sal_Int32 nSlideCount = mpSlideController->getSlideNumberCount();
2955 for( sal_Int32 nSlide = 0; nSlide < nSlideCount; nSlide++ )
2956 {
2957 if( mpSlideController->getSlideByNumber( nSlide ) == xSlide )
2958 {
2959 displaySlideNumber( nSlide );
2960 }
2961 }
2962}
2963
2964void SAL_CALL SlideshowImpl::gotoSlideIndex( sal_Int32 nIndex )
2965{
2966 SolarMutexGuard aSolarGuard;
2967
2968 if( mbIsPaused )
2969 resume();
2970
2971 displaySlideIndex( nIndex );
2972}
2973
2974void SAL_CALL SlideshowImpl::stopSound( )
2975{
2976 SolarMutexGuard aSolarGuard;
2977
2978 try
2979 {
2980 if( mxPlayer.is() )
2981 {
2982 mxPlayer->stop();
2983 mxPlayer.clear();
2984 }
2985 }
2986 catch( Exception& )
2987 {
2988 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::stopSound()" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::stopSound()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2988" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::stopSound()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::stopSound()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2988" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "sd::SlideshowImpl::stopSound()" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2988" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "sd::SlideshowImpl::stopSound()" <<
" " << exceptionToString(tools_warn_exception)), 0); }
else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "sd::SlideshowImpl::stopSound()" << " " <<
exceptionToString(tools_warn_exception); ::sal::detail::log(
(::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/slideshow/slideshowimpl.cxx"
":" "2988" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
2989 }
2990}
2991
2992// XIndexAccess
2993
2994::sal_Int32 SAL_CALL SlideshowImpl::getCount( )
2995{
2996 return getSlideCount();
2997}
2998
2999css::uno::Any SAL_CALL SlideshowImpl::getByIndex( ::sal_Int32 Index )
3000{
3001 return Any( getSlideByIndex( Index ) );
3002}
3003
3004css::uno::Type SAL_CALL SlideshowImpl::getElementType( )
3005{
3006 return cppu::UnoType<XDrawPage>::get();
3007}
3008
3009sal_Bool SAL_CALL SlideshowImpl::hasElements( )
3010{
3011 return getSlideCount() != 0;
3012}
3013
3014Reference< XSlideShow > SAL_CALL SlideshowImpl::getSlideShow()
3015{
3016 return mxShow;
3017}
3018
3019PresentationSettingsEx::PresentationSettingsEx( const PresentationSettingsEx& r )
3020: PresentationSettings( r )
3021, mbRehearseTimings(r.mbRehearseTimings)
3022, mbPreview(r.mbPreview)
3023, mpParentWindow( nullptr )
3024{
3025}
3026
3027PresentationSettingsEx::PresentationSettingsEx( PresentationSettings const & r )
3028: PresentationSettings( r )
3029, mbRehearseTimings(false)
3030, mbPreview(false)
3031, mpParentWindow(nullptr)
3032{
3033}
3034
3035void PresentationSettingsEx::SetArguments( const Sequence< PropertyValue >& rArguments )
3036{
3037 for( const PropertyValue& rValue : rArguments )
3038 {
3039 SetPropertyValue( rValue.Name, rValue.Value );
3040 }
3041}
3042
3043void PresentationSettingsEx::SetPropertyValue( const OUString& rProperty, const Any& rValue )
3044{
3045 if ( rProperty == "RehearseTimings" )
3046 {
3047 if( rValue >>= mbRehearseTimings )
3048 return;
3049 }
3050 else if ( rProperty == "Preview" )
3051 {
3052 if( rValue >>= mbPreview )
3053 return;
3054 }
3055 else if ( rProperty == "AnimationNode" )
3056 {
3057 if( rValue >>= mxAnimationNode )
3058 return;
3059 }
3060 else if ( rProperty == "ParentWindow" )
3061 {
3062 Reference< XWindow > xWindow;
3063 if( rValue >>= xWindow )
3064 {
3065 mpParentWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow )
3066 : VclPtr<vcl::Window>();
3067 return;
3068 }
3069 }
3070 else if ( rProperty == "AllowAnimations" )
3071 {
3072 if( rValue >>= mbAnimationAllowed )
3073 return;
3074 }
3075 else if ( rProperty == "FirstPage" )
3076 {
3077 OUString aPresPage;
3078 if( rValue >>= aPresPage )
3079 {
3080 maPresPage = getUiNameFromPageApiNameImpl(aPresPage);
3081 mbCustomShow = false;
3082 mbAll = false;
3083 return;
3084 }
3085 else
3086 {
3087 if( rValue >>= mxStartPage )
3088 return;
3089 }
3090 }
3091 else if ( rProperty == "IsAlwaysOnTop" )
3092 {
3093 if( rValue >>= mbAlwaysOnTop )
3094 return;
3095 }
3096 else if ( rProperty == "IsAutomatic" )
3097 {
3098 if( rValue >>= mbManual )
3099 return;
3100 }
3101 else if ( rProperty == "IsEndless" )
3102 {
3103 if( rValue >>= mbEndless )
3104 return;
3105 }
3106 else if ( rProperty == "IsFullScreen" )
3107 {
3108 if( rValue >>= mbFullScreen )
3109 return;
3110 }
3111 else if ( rProperty == "IsMouseVisible" )
3112 {
3113 if( rValue >>= mbMouseVisible )
3114 return;
3115 }
3116 else if ( rProperty == "Pause" )
3117 {
3118 sal_Int32 nPause = -1;
3119 if( (rValue >>= nPause) && (nPause >= 0) )
3120 {
3121 mnPauseTimeout = nPause;
3122 return;
3123 }
3124 }
3125 else if ( rProperty == "UsePen" )
3126 {
3127 if( rValue >>= mbMouseAsPen )
3128 return;
3129 }
3130 throw IllegalArgumentException();
3131}
3132
3133// XAnimationListener
3134
3135SlideShowListenerProxy::SlideShowListenerProxy( const rtl::Reference< SlideshowImpl >& xController, const css::uno::Reference< css::presentation::XSlideShow >& xSlideShow )
3136: maListeners( m_aMutex )
3137, mxController( xController )
3138, mxSlideShow( xSlideShow )
3139{
3140}
3141
3142SlideShowListenerProxy::~SlideShowListenerProxy()
3143{
3144}
3145
3146void SlideShowListenerProxy::addAsSlideShowListener()
3147{
3148 if( mxSlideShow.is() )
3149 {
3150 Reference< XSlideShowListener > xSlideShowListener( this );
3151 mxSlideShow->addSlideShowListener( xSlideShowListener );
3152 }
3153}
3154
3155void SlideShowListenerProxy::removeAsSlideShowListener()
3156{
3157 if( mxSlideShow.is() )
3158 {
3159 Reference< XSlideShowListener > xSlideShowListener( this );
3160 mxSlideShow->removeSlideShowListener( xSlideShowListener );
3161 }
3162}
3163
3164void SlideShowListenerProxy::addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape )
3165{
3166 if( mxSlideShow.is() )
3167 {
3168 Reference< XShapeEventListener > xListener( this );
3169 mxSlideShow->addShapeEventListener( xListener, xShape );
3170 }
3171}
3172
3173void SlideShowListenerProxy::removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape )
3174{
3175 if( mxSlideShow.is() )
3176 {
3177 Reference< XShapeEventListener > xListener( this );
3178 mxSlideShow->removeShapeEventListener( xListener, xShape );
3179 }
3180}
3181
3182void SlideShowListenerProxy::addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& xListener )
3183{
3184 maListeners.addInterface(xListener);
3185}
3186
3187void SlideShowListenerProxy::removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& xListener )
3188{
3189 maListeners.removeInterface(xListener);
3190}
3191
3192void SAL_CALL SlideShowListenerProxy::beginEvent( const Reference< XAnimationNode >& xNode )
3193{
3194 ::osl::MutexGuard aGuard( m_aMutex );
3195
3196 if( maListeners.getLength() >= 0 )
3197 {
3198 maListeners.forEach<XSlideShowListener>(
3199 [&] (Reference<XAnimationListener> const& xListener) {
3200 return xListener->beginEvent(xNode);
3201 } );
3202 }
3203}
3204
3205void SAL_CALL SlideShowListenerProxy::endEvent( const Reference< XAnimationNode >& xNode )
3206{
3207 ::osl::MutexGuard aGuard( m_aMutex );
3208
3209 if( maListeners.getLength() >= 0 )
3210 {
3211 maListeners.forEach<XSlideShowListener>(
3212 [&] (Reference<XAnimationListener> const& xListener) {
3213 return xListener->endEvent(xNode);
3214 } );
3215 }
3216}
3217
3218void SAL_CALL SlideShowListenerProxy::repeat( const Reference< XAnimationNode >& xNode, ::sal_Int32 nRepeat )
3219{
3220 ::osl::MutexGuard aGuard( m_aMutex );
3221
3222 if( maListeners.getLength() >= 0 )
3223 {
3224 maListeners.forEach<XSlideShowListener>(
3225 [&] (Reference<XAnimationListener> const& xListener) {
3226 return xListener->repeat(xNode, nRepeat);
3227 } );
3228 }
3229}
3230
3231// css::presentation::XSlideShowListener:
3232
3233void SAL_CALL SlideShowListenerProxy::paused( )
3234{
3235 ::osl::MutexGuard aGuard( m_aMutex );
3236
3237 maListeners.forEach<XSlideShowListener>(
3238 [](uno::Reference<presentation::XSlideShowListener> const& xListener)
3239 {
3240 xListener->paused();
3241 });
3242}
3243
3244void SAL_CALL SlideShowListenerProxy::resumed( )
3245{
3246 ::osl::MutexGuard aGuard( m_aMutex );
3247
3248 maListeners.forEach<XSlideShowListener>(
3249 [](uno::Reference<presentation::XSlideShowListener> const& xListener)
3250 {
3251 xListener->resumed();
3252 });
3253}
3254
3255void SAL_CALL SlideShowListenerProxy::slideTransitionStarted( )
3256{
3257 ::osl::MutexGuard aGuard( m_aMutex );
3258
3259 maListeners.forEach<XSlideShowListener>(
3260 [](uno::Reference<presentation::XSlideShowListener> const& xListener)
3261 {
3262 xListener->slideTransitionStarted();
3263 });
3264}
3265
3266void SAL_CALL SlideShowListenerProxy::slideTransitionEnded( )
3267{
3268 ::osl::MutexGuard aGuard( m_aMutex );
3269
3270 maListeners.forEach<XSlideShowListener>(
3271 [](uno::Reference<presentation::XSlideShowListener> const& xListener)
3272 {
3273 xListener->slideTransitionEnded ();
3274 });
3275}
3276
3277void SAL_CALL SlideShowListenerProxy::slideAnimationsEnded( )
3278{
3279 ::osl::MutexGuard aGuard( m_aMutex );
3280
3281 maListeners.forEach<XSlideShowListener>(
3282 [](uno::Reference<presentation::XSlideShowListener> const& xListener)
3283 {
3284 xListener->slideAnimationsEnded ();
3285 });
3286}
3287
3288void SlideShowListenerProxy::slideEnded(sal_Bool bReverse)
3289{
3290 {
3291 ::osl::MutexGuard aGuard( m_aMutex );
3292
3293 if( maListeners.getLength() >= 0 )
3294 {
3295 maListeners.forEach<XSlideShowListener>(
3296 [&] (Reference<XSlideShowListener> const& xListener) {
3297 return xListener->slideEnded(bReverse);
3298 } );
3299 }
3300 }
3301
3302 {
3303 SolarMutexGuard aSolarGuard;
3304 if( mxController.is() )
3305 mxController->slideEnded(bReverse);
3306 }
3307}
3308
3309void SlideShowListenerProxy::hyperLinkClicked( OUString const& aHyperLink )
3310{
3311 {
3312 ::osl::MutexGuard aGuard( m_aMutex );
3313
3314 if( maListeners.getLength() >= 0 )
3315 {
3316 maListeners.forEach<XSlideShowListener>(
3317 [&] (Reference<XSlideShowListener> const& xListener) {
3318 return xListener->hyperLinkClicked(aHyperLink);
3319 } );
3320 }
3321 }
3322
3323 {
3324 SolarMutexGuard aSolarGuard;
3325 if( mxController.is() )
3326 mxController->hyperLinkClicked(aHyperLink);
3327 }
3328}
3329
3330// XEventListener
3331
3332void SAL_CALL SlideShowListenerProxy::disposing( const css::lang::EventObject& aDisposeEvent )
3333{
3334 maListeners.disposeAndClear( aDisposeEvent );
3335 mxController.clear();
3336 mxSlideShow.clear();
3337}
3338
3339// XShapeEventListener
3340
3341void SAL_CALL SlideShowListenerProxy::click( const Reference< XShape >& xShape, const css::awt::MouseEvent& /*aOriginalEvent*/ )
3342{
3343 SolarMutexGuard aSolarGuard;
3344 if( mxController.is() )
3345 mxController->click(xShape );
3346}
3347
3348} // namespace ::sd
3349
3350/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx

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#ifndef INCLUDED_VCL_PTR_HXX
21#define INCLUDED_VCL_PTR_HXX
22
23#include <sal/config.h>
24
25#include <rtl/ref.hxx>
26
27#include <utility>
28#include <type_traits>
29
30#ifdef DBG_UTIL
31#ifndef _WIN32
32#include <vcl/vclmain.hxx>
33#endif
34#endif
35
36class VclReferenceBase;
37
38namespace vcl::detail {
39
40template<typename>
41constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; }
42
43template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase(
44 int (*)[sizeof(T)])
45{ return std::is_base_of<VclReferenceBase, T>::value; }
46
47} // namespace vcl::detail
48
49/**
50 * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses.
51 *
52 * For more details on the design please see vcl/README.lifecycle
53 *
54 * @param reference_type must be a subclass of vcl::Window
55 */
56template <class reference_type>
57class VclPtr
58{
59 static_assert(
60 vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>(
61 nullptr),
62 "template argument type must be derived from VclReferenceBase");
63
64 ::rtl::Reference<reference_type> m_rInnerRef;
65
66public:
67 /** Constructor...
68 */
69 VclPtr()
70 : m_rInnerRef()
71 {}
72
73 /** Constructor...
74 */
75 VclPtr (reference_type * pBody)
76 : m_rInnerRef(pBody)
77 {}
78
79 /** Constructor... that doesn't take a ref.
80 */
81 VclPtr (reference_type * pBody, __sal_NoAcquire)
82 : m_rInnerRef(pBody, SAL_NO_ACQUIRE)
83 {}
84
85 /** Up-casting conversion constructor: Copies interface reference.
86
87 Does not work for up-casts to ambiguous bases. For the special case of
88 up-casting to Reference< XInterface >, see the corresponding conversion
89 operator.
90
91 @param rRef another reference
92 */
93 template< class derived_type >
94 VclPtr(
95 const VclPtr< derived_type > & rRef,
96 typename std::enable_if<
97 std::is_base_of<reference_type, derived_type>::value, int>::type
98 = 0 )
99 : m_rInnerRef( static_cast<reference_type*>(rRef) )
100 {
101 }
102
103#if defined(DBG_UTIL) && !defined(_WIN32)
104 virtual ~VclPtr()
105 {
106 assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain
::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()"
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 106, __extension__ __PRETTY_FUNCTION__))
;
107 // We can be one of the intermediate counts, but if we are the last
108 // VclPtr keeping this object alive, then something forgot to call dispose().
109 assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef
->isDisposed() || m_rInnerRef->getRefCount() > 1) &&
"someone forgot to call dispose()") ? void (0) : __assert_fail
("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\""
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 110, __extension__ __PRETTY_FUNCTION__))
110 && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef
->isDisposed() || m_rInnerRef->getRefCount() > 1) &&
"someone forgot to call dispose()") ? void (0) : __assert_fail
("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\""
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 110, __extension__ __PRETTY_FUNCTION__))
;
111 }
112 VclPtr(VclPtr const &) = default;
113 VclPtr(VclPtr &&) = default;
114 VclPtr & operator =(VclPtr const &) = default;
115 VclPtr & operator =(VclPtr &&) = default;
116#endif
117
118 /**
119 * A construction helper for VclPtr. Since VclPtr types are created
120 * with a reference-count of one - to help fit into the existing
121 * code-flow; this helps us to construct them easily.
122 *
123 * For more details on the design please see vcl/README.lifecycle
124 *
125 * @tparam reference_type must be a subclass of vcl::Window
126 */
127 template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg)
128 {
129 return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE );
130 }
131
132 /** Probably most common used: handle->someBodyOp().
133 */
134 reference_type * operator->() const
135 {
136 return m_rInnerRef.get();
137 }
138
139 /** Get the body. Can be used instead of operator->().
140 I.e. handle->someBodyOp() and handle.get()->someBodyOp()
141 are the same.
142 */
143 reference_type * get() const
144 {
145 return m_rInnerRef.get();
146 }
147
148 void set(reference_type *pBody)
149 {
150 m_rInnerRef.set(pBody);
151 }
152
153 void reset(reference_type *pBody)
154 {
155 m_rInnerRef.set(pBody);
156 }
157
158 /** Up-casting copy assignment operator.
159
160 Does not work for up-casts to ambiguous bases.
161
162 @param rRef another reference
163 */
164 template<typename derived_type>
165 typename std::enable_if<
166 std::is_base_of<reference_type, derived_type>::value,
167 VclPtr &>::type
168 operator =(VclPtr<derived_type> const & rRef)
169 {
170 m_rInnerRef.set(rRef.get());
171 return *this;
172 }
173
174 VclPtr & operator =(reference_type * pBody)
175 {
176 m_rInnerRef.set(pBody);
177 return *this;
178 }
179
180 operator reference_type * () const
181 {
182 return m_rInnerRef.get();
183 }
184
185 explicit operator bool () const
186 {
187 return m_rInnerRef.get() != nullptr;
188 }
189
190 void clear()
191 {
192 m_rInnerRef.clear();
193 }
194
195 void reset()
196 {
197 m_rInnerRef.clear();
198 }
199
200 void disposeAndClear()
201 {
202 // hold it alive for the lifetime of this method
203 ::rtl::Reference<reference_type> aTmp(m_rInnerRef);
204 m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-)
33
Calling 'Reference::clear'
40
Returning; memory was released
205 if (aTmp.get()) {
41
Calling 'Reference::get'
206 aTmp->disposeOnce();
207 }
208 }
209
210 /** Needed to place VclPtr's into STL collection.
211 */
212 bool operator< (const VclPtr<reference_type> & handle) const
213 {
214 return (m_rInnerRef < handle.m_rInnerRef);
215 }
216}; // class VclPtr
217
218template<typename T1, typename T2>
219inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) {
220 return p1.get() == p2.get();
221}
222
223template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2)
224{
225 return p1.get() == p2;
226}
227
228template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) {
229 return p1.get() == p2;
230}
231
232template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2)
233{
234 return p1 == p2.get();
235}
236
237template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) {
238 return p1 == p2.get();
239}
240
241template<typename T1, typename T2>
242inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) {
243 return !(p1 == p2);
244}
245
246template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2)
247{
248 return !(p1 == p2);
249}
250
251template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) {
252 return !(p1 == p2);
253}
254
255template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2)
256{
257 return !(p1 == p2);
258}
259
260template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) {
261 return !(p1 == p2);
262}
263
264/**
265 * A construction helper for a temporary VclPtr. Since VclPtr types
266 * are created with a reference-count of one - to help fit into
267 * the existing code-flow; this helps us to construct them easily.
268 * see also VclPtr::Create and ScopedVclPtr
269 *
270 * For more details on the design please see vcl/README.lifecycle
271 *
272 * @param reference_type must be a subclass of vcl::Window
273 */
274template <class reference_type>
275class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type>
276{
277public:
278 template<typename... Arg> VclPtrInstance(Arg &&... arg)
279 : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE )
280 {
281 }
282
283 /**
284 * Override and disallow this, to prevent people accidentally calling it and actually
285 * getting VclPtr::Create and getting a naked VclPtr<> instance
286 */
287 template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete;
288};
289
290template <class reference_type>
291class ScopedVclPtr : public VclPtr<reference_type>
292{
293public:
294 /** Constructor...
295 */
296 ScopedVclPtr()
297 : VclPtr<reference_type>()
298 {}
299
300 /** Constructor
301 */
302 ScopedVclPtr (reference_type * pBody)
303 : VclPtr<reference_type>(pBody)
304 {}
305
306 /** Copy constructor...
307 */
308 ScopedVclPtr (const VclPtr<reference_type> & handle)
309 : VclPtr<reference_type>(handle)
310 {}
311
312 /**
313 Assignment that releases the last reference.
314 */
315 void disposeAndReset(reference_type *pBody)
316 {
317 if (pBody != this->get()) {
318 VclPtr<reference_type>::disposeAndClear();
319 VclPtr<reference_type>::set(pBody);
320 }
321 }
322
323 /**
324 Assignment that releases the last reference.
325 */
326 ScopedVclPtr<reference_type>& operator = (reference_type * pBody)
327 {
328 disposeAndReset(pBody);
329 return *this;
330 }
331
332 /** Up-casting conversion constructor: Copies interface reference.
333
334 Does not work for up-casts to ambiguous bases. For the special case of
335 up-casting to Reference< XInterface >, see the corresponding conversion
336 operator.
337
338 @param rRef another reference
339 */
340 template< class derived_type >
341 ScopedVclPtr(
342 const VclPtr< derived_type > & rRef,
343 typename std::enable_if<
344 std::is_base_of<reference_type, derived_type>::value, int>::type
345 = 0 )
346 : VclPtr<reference_type>( rRef )
347 {
348 }
349
350 /** Up-casting assignment operator.
351
352 Does not work for up-casts to ambiguous bases.
353
354 @param rRef another VclPtr
355 */
356 template<typename derived_type>
357 typename std::enable_if<
358 std::is_base_of<reference_type, derived_type>::value,
359 ScopedVclPtr &>::type
360 operator =(VclPtr<derived_type> const & rRef)
361 {
362 disposeAndReset(rRef.get());
363 return *this;
364 }
365
366 /**
367 * Override and disallow this, to prevent people accidentally calling it and actually
368 * getting VclPtr::Create and getting a naked VclPtr<> instance
369 */
370 template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete;
371
372 ~ScopedVclPtr()
373 {
374 VclPtr<reference_type>::disposeAndClear();
375 assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get(
) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr"
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 375, __extension__ __PRETTY_FUNCTION__))
; // make sure there are no lingering references
376 }
377
378private:
379 // Most likely we don't want this default copy-constructor.
380 ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete;
381 // And certainly we don't want a default assignment operator.
382 ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete;
383 // And disallow reset as that doesn't call disposeAndClear on the original reference
384 void reset() = delete;
385 void reset(reference_type *pBody) = delete;
386
387protected:
388 ScopedVclPtr (reference_type * pBody, __sal_NoAcquire)
389 : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE)
390 {}
391};
392
393/**
394 * A construction helper for ScopedVclPtr. Since VclPtr types are created
395 * with a reference-count of one - to help fit into the existing
396 * code-flow; this helps us to construct them easily.
397 *
398 * For more details on the design please see vcl/README.lifecycle
399 *
400 * @param reference_type must be a subclass of vcl::Window
401 */
402#if defined _MSC_VER
403#pragma warning(push)
404#pragma warning(disable: 4521) // " multiple copy constructors specified"
405#endif
406template <class reference_type>
407class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type>
408{
409public:
410 template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg)
411 : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE )
412 {
413 }
414
415 /**
416 * Override and disallow this, to prevent people accidentally calling it and actually
417 * getting VclPtr::Create and getting a naked VclPtr<> instance
418 */
419 template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete;
420
421private:
422 // Prevent the above perfect forwarding ctor from hijacking (accidental)
423 // attempts at ScopedVclPtrInstance copy construction (where the hijacking
424 // would typically lead to somewhat obscure error messages); both non-const
425 // and const variants are needed here, as the ScopedVclPtr base class has a
426 // const--variant copy ctor, so the implicitly declared copy ctor for
427 // ScopedVclPtrInstance would also be the const variant, so non-const copy
428 // construction attempts would be hijacked by the perfect forwarding ctor;
429 // but if we only declared a non-const variant here, the const variant would
430 // no longer be implicitly declared (as there would already be an explicitly
431 // declared copy ctor), so const copy construction attempts would then be
432 // hijacked by the perfect forwarding ctor:
433 ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete;
434 ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete;
435};
436#if defined _MSC_VER
437#pragma warning(pop)
438#endif
439
440#endif // INCLUDED_VCL_PTR_HXX
441
442/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/rtl/ref.hxx

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#ifndef INCLUDED_RTL_REF_HXX
21#define INCLUDED_RTL_REF_HXX
22
23#include "sal/config.h"
24
25#include <cassert>
26#include <cstddef>
27#include <functional>
28#ifdef LIBO_INTERNAL_ONLY1
29#include <type_traits>
30#endif
31
32#include "sal/types.h"
33
34namespace rtl
35{
36
37/** Template reference class for reference type.
38*/
39template <class reference_type>
40class Reference
41{
42 /** The <b>reference_type</b> body pointer.
43 */
44 reference_type * m_pBody;
45
46
47public:
48 /** Constructor...
49 */
50 Reference()
51 : m_pBody (NULL__null)
52 {}
53
54
55 /** Constructor...
56 */
57 Reference (reference_type * pBody, __sal_NoAcquire)
58 : m_pBody (pBody)
59 {
60 }
61
62 /** Constructor...
63 */
64 Reference (reference_type * pBody)
65 : m_pBody (pBody)
66 {
67 if (m_pBody)
68 m_pBody->acquire();
69 }
70
71 /** Copy constructor...
72 */
73 Reference (const Reference<reference_type> & handle)
74 : m_pBody (handle.m_pBody)
75 {
76 if (m_pBody)
77 m_pBody->acquire();
78 }
79
80#ifdef LIBO_INTERNAL_ONLY1
81 /** Move constructor...
82 */
83 Reference (Reference<reference_type> && handle) noexcept
84 : m_pBody (handle.m_pBody)
85 {
86 handle.m_pBody = nullptr;
87 }
88#endif
89
90#if defined LIBO_INTERNAL_ONLY1
91 /** Up-casting conversion constructor: Copies interface reference.
92
93 Does not work for up-casts to ambiguous bases.
94
95 @param rRef another reference
96 */
97 template< class derived_type >
98 inline Reference(
99 const Reference< derived_type > & rRef,
100 std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 )
101 : m_pBody (rRef.get())
102 {
103 if (m_pBody)
104 m_pBody->acquire();
105 }
106#endif
107
108 /** Destructor...
109 */
110 ~Reference() COVERITY_NOEXCEPT_FALSE
111 {
112 if (m_pBody)
113 m_pBody->release();
114 }
115
116 /** Set...
117 Similar to assignment.
118 */
119 Reference<reference_type> &
120 SAL_CALL set (reference_type * pBody)
121 {
122 if (pBody)
123 pBody->acquire();
124 reference_type * const pOld = m_pBody;
125 m_pBody = pBody;
126 if (pOld)
127 pOld->release();
128 return *this;
129 }
130
131 /** Assignment.
132 Unbinds this instance from its body (if bound) and
133 bind it to the body represented by the handle.
134 */
135 Reference<reference_type> &
136 SAL_CALL operator= (const Reference<reference_type> & handle)
137 {
138 return set( handle.m_pBody );
139 }
140
141#ifdef LIBO_INTERNAL_ONLY1
142 /** Assignment.
143 * Unbinds this instance from its body (if bound),
144 * bind it to the body represented by the handle, and
145 * set the body represented by the handle to nullptr.
146 */
147 Reference<reference_type> &
148 operator= (Reference<reference_type> && handle)
149 {
150 // self-movement guts ourself
151 if (m_pBody)
152 m_pBody->release();
153 m_pBody = handle.m_pBody;
154 handle.m_pBody = nullptr;
155 return *this;
156 }
157#endif
158
159 /** Assignment...
160 */
161 Reference<reference_type> &
162 SAL_CALL operator= (reference_type * pBody)
163 {
164 return set( pBody );
165 }
166
167 /** Unbind the body from this handle.
168 Note that for a handle representing a large body,
169 "handle.clear().set(new body());" _might_
170 perform a little bit better than "handle.set(new body());",
171 since in the second case two large objects exist in memory
172 (the old body and the new body).
173 */
174 Reference<reference_type> & SAL_CALL clear()
175 {
176 if (m_pBody
33.1
Field 'm_pBody' is non-null
33.1
Field 'm_pBody' is non-null
33.1
Field 'm_pBody' is non-null
33.1
Field 'm_pBody' is non-null
)
34
Taking true branch
177 {
178 reference_type * const pOld = m_pBody;
179 m_pBody = NULL__null;
180 pOld->release();
35
Calling 'VclReferenceBase::release'
39
Returning; memory was released
181 }
182 return *this;
183 }
184
185
186 /** Get the body. Can be used instead of operator->().
187 I.e. handle->someBodyOp() and handle.get()->someBodyOp()
188 are the same.
189 */
190 reference_type * SAL_CALL get() const
191 {
192 return m_pBody;
42
Use of memory after it is freed
193 }
194
195
196 /** Probably most common used: handle->someBodyOp().
197 */
198 reference_type * SAL_CALL operator->() const
199 {
200 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 200, __extension__ __PRETTY_FUNCTION__))
;
201 return m_pBody;
202 }
203
204
205 /** Allows (*handle).someBodyOp().
206 */
207 reference_type & SAL_CALL operator*() const
208 {
209 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 209, __extension__ __PRETTY_FUNCTION__))
;
210 return *m_pBody;
211 }
212
213
214 /** Returns True if the handle does point to a valid body.
215 */
216 bool SAL_CALL is() const
217 {
218 return (m_pBody != NULL__null);
219 }
220
221#if defined LIBO_INTERNAL_ONLY1
222 /** Returns True if the handle does point to a valid body.
223 */
224 explicit operator bool() const
225 {
226 return is();
227 }
228#endif
229
230 /** Returns True if this points to pBody.
231 */
232 bool SAL_CALL operator== (const reference_type * pBody) const
233 {
234 return (m_pBody == pBody);
235 }
236
237
238 /** Returns True if handle points to the same body.
239 */
240 bool
241 SAL_CALL operator== (const Reference<reference_type> & handle) const
242 {
243 return (m_pBody == handle.m_pBody);
244 }
245
246
247 /** Needed to place References into STL collection.
248 */
249 bool
250 SAL_CALL operator!= (const Reference<reference_type> & handle) const
251 {
252 return (m_pBody != handle.m_pBody);
253 }
254
255
256 /** Needed to place References into STL collection.
257 */
258 bool
259 SAL_CALL operator< (const Reference<reference_type> & handle) const
260 {
261 return (m_pBody < handle.m_pBody);
262 }
263
264
265 /** Needed to place References into STL collection.
266 */
267 bool
268 SAL_CALL operator> (const Reference<reference_type> & handle) const
269 {
270 return (m_pBody > handle.m_pBody);
271 }
272};
273
274} // namespace rtl
275
276#if defined LIBO_INTERNAL_ONLY1
277namespace std
278{
279
280/// @cond INTERNAL
281/**
282 Make rtl::Reference hashable by default for use in STL containers.
283
284 @since LibreOffice 6.3
285*/
286template<typename T>
287struct hash<::rtl::Reference<T>>
288{
289 std::size_t operator()(::rtl::Reference<T> const & s) const
290 { return std::size_t(s.get()); }
291};
292/// @endcond
293
294}
295
296#endif
297
298#endif /* ! INCLUDED_RTL_REF_HXX */
299
300/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/vcl/vclreferencebase.hxx

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#ifndef INCLUDED_VCL_Reference_HXX
20#define INCLUDED_VCL_Reference_HXX
21
22#include <vcl/dllapi.h>
23#include <osl/interlck.h>
24
25class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase
26{
27 mutable oslInterlockedCount mnRefCnt;
28
29 template<typename T> friend class VclPtr;
30
31public:
32 void acquire() const
33 {
34 osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1);
35 }
36
37 void release() const
38 {
39 if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0)
36
Assuming the condition is true
37
Taking true branch
40 delete this;
38
Memory is released
41 }
42#ifdef DBG_UTIL
43#ifndef _WIN32
44 sal_Int32 getRefCount() const { return mnRefCnt; }
45#endif
46#endif
47
48
49private:
50 VclReferenceBase(const VclReferenceBase&) = delete;
51 VclReferenceBase& operator=(const VclReferenceBase&) = delete;
52
53 bool mbDisposed : 1;
54
55protected:
56 VclReferenceBase();
57protected:
58 virtual ~VclReferenceBase();
59
60protected:
61 virtual void dispose();
62
63public:
64 void disposeOnce();
65 bool isDisposed() const { return mbDisposed; }
66
67};
68#endif