1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "PresenterScreen.hxx"
#include "PresenterConfigurationAccess.hxx"
#include "PresenterController.hxx"
#include "PresenterFrameworkObserver.hxx"
#include "PresenterHelper.hxx"
#include "PresenterPaneContainer.hxx"
#include "PresenterPaneFactory.hxx"
#include "PresenterViewFactory.hxx"
#include "PresenterWindowManager.hxx"
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/drawing/framework/XControllerManager.hpp>
#include <com/sun/star/drawing/framework/ResourceId.hpp>
#include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
#include <com/sun/star/presentation/XPresentation2.hpp>
#include <com/sun/star/presentation/XPresentationSupplier.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp>
#include <cppuhelper/compbase.hxx>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::presentation;
using namespace ::com::sun::star::drawing::framework;
namespace sdext::presenter {
namespace {
typedef ::cppu::WeakComponentImplHelper <
css::document::XEventListener
> PresenterScreenListenerInterfaceBase;
/** One instance of a PresenterScreenListener is registered per Impress
document and waits for the full screen slide show to start and to
end.
*/
class PresenterScreenListener
: private ::cppu::BaseMutex,
public PresenterScreenListenerInterfaceBase
{
public:
PresenterScreenListener (
const css::uno::Reference<css::uno::XComponentContext>& rxContext,
const css::uno::Reference<css::frame::XModel2>& rxModel);
PresenterScreenListener(const PresenterScreenListener&) = delete;
PresenterScreenListener& operator=(const PresenterScreenListener&) = delete;
void Initialize();
virtual void SAL_CALL disposing() override;
// document::XEventListener
virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) override;
// XEventListener
virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) override;
private:
css::uno::Reference<css::frame::XModel2 > mxModel;
css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
rtl::Reference<PresenterScreen> mpPresenterScreen;
};
}
//----- Service ---------------------------------------------------------------
OUString PresenterScreenJob::getImplementationName_static()
{
return "org.libreoffice.comp.PresenterScreenJob";
}
Sequence<OUString> PresenterScreenJob::getSupportedServiceNames_static()
{
return Sequence<OUString>();
}
Reference<XInterface> PresenterScreenJob::Create (const Reference<uno::XComponentContext>& rxContext)
{
return Reference<XInterface>(static_cast<XWeak*>(new PresenterScreenJob(rxContext)));
}
//===== PresenterScreenJob ====================================================
PresenterScreenJob::PresenterScreenJob (const Reference<XComponentContext>& rxContext)
: PresenterScreenJobInterfaceBase(m_aMutex),
mxComponentContext(rxContext)
{
}
PresenterScreenJob::~PresenterScreenJob()
{
}
void SAL_CALL PresenterScreenJob::disposing()
{
mxComponentContext = nullptr;
}
//----- XJob -----------------------------------------------------------
Any SAL_CALL PresenterScreenJob::execute(
const Sequence< beans::NamedValue >& Arguments )
{
Sequence< beans::NamedValue > lEnv;
auto pArg = std::find_if(Arguments.begin(), Arguments.end(),
[](const beans::NamedValue& rArg) { return rArg.Name == "Environment"; });
if (pArg != Arguments.end())
pArg->Value >>= lEnv;
Reference<frame::XModel2> xModel;
auto pProp = std::find_if(lEnv.begin(), lEnv.end(),
[](const beans::NamedValue& rProp) { return rProp.Name == "Model"; });
if (pProp != lEnv.end())
pProp->Value >>= xModel;
Reference< XServiceInfo > xInfo( xModel, UNO_QUERY );
if( xInfo.is() && xInfo->supportsService("com.sun.star.presentation.PresentationDocument") )
{
// Create a new listener that waits for the full screen presentation
// to start and to end. It takes care of its own lifetime.
::rtl::Reference<PresenterScreenListener> pListener (
new PresenterScreenListener(mxComponentContext, xModel));
pListener->Initialize();
}
return Any();
}
//===== PresenterScreenListener ===============================================
namespace {
PresenterScreenListener::PresenterScreenListener (
const css::uno::Reference<css::uno::XComponentContext>& rxContext,
const css::uno::Reference<css::frame::XModel2>& rxModel)
: PresenterScreenListenerInterfaceBase(m_aMutex),
mxModel(rxModel),
mxComponentContext(rxContext),
mpPresenterScreen()
{
}
void PresenterScreenListener::Initialize()
{
Reference< document::XEventListener > xDocListener(
static_cast< document::XEventListener* >(this), UNO_QUERY);
Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
if( xDocBroadcaster.is() )
xDocBroadcaster->addEventListener(xDocListener);
}
void SAL_CALL PresenterScreenListener::disposing()
{
Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
if( xDocBroadcaster.is() )
xDocBroadcaster->removeEventListener(
Reference<document::XEventListener>(
static_cast<document::XEventListener*>(this), UNO_QUERY));
if (mpPresenterScreen.is())
{
mpPresenterScreen->RequestShutdownPresenterScreen();
mpPresenterScreen = nullptr;
}
}
// document::XEventListener
void SAL_CALL PresenterScreenListener::notifyEvent( const css::document::EventObject& Event )
{
if (rBHelper.bDisposed || rBHelper.bInDispose)
{
throw lang::DisposedException (
"PresenterScreenListener object has already been disposed",
static_cast<uno::XWeak*>(this));
}
if ( Event.EventName == "OnStartPresentation" )
{
mpPresenterScreen = new PresenterScreen(mxComponentContext, mxModel);
if(PresenterScreen::isPresenterScreenEnabled(mxComponentContext))
mpPresenterScreen->InitializePresenterScreen();
}
else if ( Event.EventName == "OnEndPresentation" )
{
if (mpPresenterScreen.is())
{
mpPresenterScreen->RequestShutdownPresenterScreen();
mpPresenterScreen = nullptr;
}
}
}
// XEventListener
void SAL_CALL PresenterScreenListener::disposing (const css::lang::EventObject&)
{
if (mpPresenterScreen.is())
{
mpPresenterScreen->RequestShutdownPresenterScreen();
mpPresenterScreen = nullptr;
}
}
} // end of anonymous namespace
//===== PresenterScreen =======================================================
PresenterScreen::PresenterScreen (
const Reference<XComponentContext>& rxContext,
const css::uno::Reference<css::frame::XModel2>& rxModel)
: PresenterScreenInterfaceBase(m_aMutex),
mxModel(rxModel),
mxController(),
mxConfigurationControllerWeak(),
mxContextWeak(rxContext),
mpPresenterController(),
mxSavedConfiguration(),
mpPaneContainer(),
mxPaneFactory(),
mxViewFactory(),
maViewDescriptors()
{
}
PresenterScreen::~PresenterScreen()
{
}
bool PresenterScreen::isPresenterScreenEnabled(const css::uno::Reference<css::uno::XComponentContext>& rxContext)
{
bool dEnablePresenterScreen=true;
PresenterConfigurationAccess aConfiguration (
rxContext,
"/org.openoffice.Office.Impress/",
PresenterConfigurationAccess::READ_ONLY);
aConfiguration.GetConfigurationNode("Misc/Start/EnablePresenterScreen")
>>= dEnablePresenterScreen;<--- Variable 'aConfiguration.GetConfigurationNode("Misc/Start/EnablePresenterScreen")' is assigned a value that is never used.
return dEnablePresenterScreen;
}
void SAL_CALL PresenterScreen::disposing()
{
Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
if (xCC.is() && mxSavedConfiguration.is())
{
xCC->restoreConfiguration(mxSavedConfiguration);
}
mxConfigurationControllerWeak = Reference<XConfigurationController>(nullptr);
Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
if (xViewFactoryComponent.is())
xViewFactoryComponent->dispose();
Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
if (xPaneFactoryComponent.is())
xPaneFactoryComponent->dispose();
mxModel = nullptr;
}
//----- XEventListener --------------------------------------------------------
void SAL_CALL PresenterScreen::disposing (const lang::EventObject& /*rEvent*/)
{
RequestShutdownPresenterScreen();
}
void PresenterScreen::InitializePresenterScreen()
{
try
{
Reference<XComponentContext> xContext (mxContextWeak);
mpPaneContainer = new PresenterPaneContainer(xContext);
Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
Reference<presentation::XSlideShowController> xSlideShowController( xPresentation->getController() );
if( !xSlideShowController.is() || !xSlideShowController->isFullScreen() )
return;
// find first controller that is not the current controller (the one with the slideshow
mxController = mxModel->getCurrentController();
Reference< container::XEnumeration > xEnum( mxModel->getControllers() );
if( xEnum.is() )
{
while( xEnum->hasMoreElements() )
{
Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY );
if( xC.is() && (xC != mxController) )
{
mxController = xC;
break;
}
}
}
// Get the XController from the first argument.
Reference<XControllerManager> xCM(mxController, UNO_QUERY_THROW);
Reference<XConfigurationController> xCC( xCM->getConfigurationController());
mxConfigurationControllerWeak = xCC;
Reference<drawing::framework::XResourceId> xMainPaneId(
GetMainPaneId(xPresentation));
// An empty reference means that the presenter screen can
// not or must not be displayed.
if ( ! xMainPaneId.is())
return;
if (xCC.is() && xContext.is())
{
// Store the current configuration so that we can restore it when
// the presenter view is deactivated.
mxSavedConfiguration = xCC->getRequestedConfiguration();
xCC->lock();
try
{
// At the moment the presenter controller is displayed in its
// own full screen window that is controlled by the same
// configuration controller as the Impress document from
// which the presentation was started. Therefore the main
// pane is activated additionally to the already existing
// panes and does not replace them.
xCC->requestResourceActivation(
xMainPaneId,
ResourceActivationMode_ADD);
SetupConfiguration(xContext, xMainPaneId);
mpPresenterController = new PresenterController(
css::uno::WeakReference<css::lang::XEventListener>(this),
xContext,
mxController,
xSlideShowController,
mpPaneContainer,
xMainPaneId);
// Create pane and view factories and integrate them into the
// drawing framework.
SetupPaneFactory(xContext);
SetupViewFactory(xContext);
mpPresenterController->GetWindowManager()->RestoreViewMode();
}
catch (const RuntimeException&)
{
xCC->restoreConfiguration(mxSavedConfiguration);
}
xCC->unlock();
}
}
catch (const Exception&)
{
}
}
void PresenterScreen::SwitchMonitors()
{
try {
Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
// Get the existing presenter console screen, we want to switch the
// presentation to use that instead.
sal_Int32 nNewScreen = GetPresenterScreenNumber (xPresentation);
if (nNewScreen < 0)
return;
// Adapt that display number to be the 'default' setting of 0 if it matches
sal_Int32 nExternalDisplay = Application::GetDisplayExternalScreen();
if (nNewScreen == nExternalDisplay)
nNewScreen = 0; // screen zero is best == the primary display
else
nNewScreen++; // otherwise we store screens offset by one.
// Set the new presentation display
Reference<beans::XPropertySet> xProperties (xPresentation, UNO_QUERY_THROW);
xProperties->setPropertyValue("Display", Any(nNewScreen));
} catch (const uno::Exception &) {
}
}
/**
* Return the real VCL screen number to show the presenter console
* on or -1 to not show anything.
*/
sal_Int32 PresenterScreen::GetPresenterScreenNumber (
const Reference<presentation::XPresentation2>& rxPresentation) const
{
sal_Int32 nScreenNumber (0);
sal_Int32 nScreenCount (1);
try
{
if ( ! rxPresentation.is())
return -1;
// Determine the screen on which the full screen presentation is being
// displayed.
sal_Int32 nDisplayNumber (-1);
if ( ! (rxPresentation->getPropertyValue("Display") >>= nDisplayNumber))
return -1;
if (nDisplayNumber == -1)
{
// The special value -1 indicates that the slide show
// spans all available displays. That leaves no room for
// the presenter screen.
return -1;
}
SAL_INFO("sdext.presenter", "Display number is " << nDisplayNumber);
if (nDisplayNumber > 0)
{
nScreenNumber = nDisplayNumber - 1;
}
else if (nDisplayNumber == 0)
{
// A display number value of 0 indicates the primary screen.
// Find out which screen number that is.
nScreenNumber = Application::GetDisplayExternalScreen();
}
// We still have to determine the number of screens to decide
// whether the presenter screen may be shown at all.
nScreenCount = Application::GetScreenCount();
if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
{
// There is either only one screen or the full screen
// presentation spans all available screens. The presenter
// screen is shown only when a special flag in the configuration
// is set.
Reference<XComponentContext> xContext (mxContextWeak);
PresenterConfigurationAccess aConfiguration (
xContext,
"/org.openoffice.Office.PresenterScreen/",
PresenterConfigurationAccess::READ_ONLY);
bool bStartAlways (false);
if (aConfiguration.GetConfigurationNode(
"Presenter/StartAlways") >>= bStartAlways)
{
if (bStartAlways)
return GetPresenterScreenFromScreen(nScreenNumber);
}
return -1;
}
}
catch (const beans::UnknownPropertyException&)
{
OSL_ASSERT(false);
// For some reason we can not access the screen number. Use
// the default instead.
}
SAL_INFO("sdext.presenter", "Get presenter screen for screen " << nScreenNumber);
return GetPresenterScreenFromScreen(nScreenNumber);
}
sal_Int32 PresenterScreen::GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen )
{
// Setup the resource id of the full screen background pane so that
// it is displayed on another screen than the presentation.
sal_Int32 nPresenterScreenNumber (1);
switch (nPresentationScreen)
{
case 0:
nPresenterScreenNumber = 1;
break;
case 1:
nPresenterScreenNumber = 0;
break;
default:
SAL_INFO("sdext.presenter", "Warning unexpected, out of bound screen "
"mapped to 0" << nPresentationScreen);
// When the full screen presentation is displayed on a screen
// other than 0 or 1 then place the presenter on the first
// available screen.
nPresenterScreenNumber = 0;
break;
}
return nPresenterScreenNumber;
}
Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
const Reference<presentation::XPresentation2>& rxPresentation) const
{
// A negative value means that the presentation spans all available
// displays. That leaves no room for the presenter.
const sal_Int32 nScreen(GetPresenterScreenNumber(rxPresentation));
if (nScreen < 0)
return nullptr;
return ResourceId::create(
Reference<XComponentContext>(mxContextWeak),
PresenterHelper::msFullScreenPaneURL
+ "?FullScreen=true&ScreenNumber="
+ OUString::number(nScreen));
}
void PresenterScreen::RequestShutdownPresenterScreen()
{
// Restore the configuration that was active before the presenter screen
// has been activated. Now, that the presenter screen is displayed in
// its own top level window this probably not necessary, but one never knows.
Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
if (xCC.is() && mxSavedConfiguration.is())
{
xCC->restoreConfiguration(mxSavedConfiguration);
mxSavedConfiguration = nullptr;
}
if (xCC.is())
{
// The actual restoration of the configuration takes place
// asynchronously. The view and pane factories can only by disposed
// after that. Therefore, set up a listener and wait for the
// restoration.
rtl::Reference<PresenterScreen> pSelf (this);
PresenterFrameworkObserver::RunOnUpdateEnd(
xCC,
[pSelf](bool){ return pSelf->ShutdownPresenterScreen(); });
xCC->update();
}
}
void PresenterScreen::ShutdownPresenterScreen()
{
Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
if (xViewFactoryComponent.is())
xViewFactoryComponent->dispose();
mxViewFactory = nullptr;
Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
if (xPaneFactoryComponent.is())
xPaneFactoryComponent->dispose();
mxPaneFactory = nullptr;
if (mpPresenterController)
{
mpPresenterController->dispose();
mpPresenterController.clear();
}
mpPaneContainer = new PresenterPaneContainer(Reference<XComponentContext>(mxContextWeak));
}
void PresenterScreen::SetupPaneFactory (const Reference<XComponentContext>& rxContext)
{
try
{
if ( ! mxPaneFactory.is())
mxPaneFactory = PresenterPaneFactory::Create(
rxContext,
mxController,
mpPresenterController);
}
catch (const RuntimeException&)
{
OSL_ASSERT(false);
}
}
void PresenterScreen::SetupViewFactory (const Reference<XComponentContext>& rxContext)
{
try
{
if ( ! mxViewFactory.is())
mxViewFactory = PresenterViewFactory::Create(
rxContext,
mxController,
mpPresenterController);
}
catch (const RuntimeException&)
{
OSL_ASSERT(false);
}
}
void PresenterScreen::SetupConfiguration (
const Reference<XComponentContext>& rxContext,
const Reference<XResourceId>& rxAnchorId)
{
try
{
PresenterConfigurationAccess aConfiguration (
rxContext,
"org.openoffice.Office.PresenterScreen",
PresenterConfigurationAccess::READ_ONLY);
maViewDescriptors.clear();
ProcessViewDescriptions(aConfiguration);
OUString sLayoutName ("DefaultLayout");
aConfiguration.GetConfigurationNode(
"Presenter/CurrentLayout") >>= sLayoutName;
ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
}
catch (const RuntimeException&)
{
}
}
void PresenterScreen::ProcessLayout (
PresenterConfigurationAccess& rConfiguration,
const OUString& rsLayoutName,
const Reference<XComponentContext>& rxContext,
const Reference<XResourceId>& rxAnchorId)
{
try
{
Reference<container::XHierarchicalNameAccess> xLayoutNode (
rConfiguration.GetConfigurationNode(
"Presenter/Layouts/"+rsLayoutName),
UNO_QUERY_THROW);
// Read the parent layout first, if one is referenced.
OUString sParentLayout;
PresenterConfigurationAccess::GetConfigurationNode(
xLayoutNode,
"ParentLayout") >>= sParentLayout;
if (!sParentLayout.isEmpty())
{
// Prevent infinite recursion.
if (rsLayoutName != sParentLayout)
ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
}
// Process the actual layout list.
Reference<container::XNameAccess> xList (
PresenterConfigurationAccess::GetConfigurationNode(
xLayoutNode,
"Layout"),
UNO_QUERY_THROW);
::std::vector<OUString> aProperties (6);
aProperties[0] = "PaneURL";
aProperties[1] = "ViewURL";
aProperties[2] = "RelativeX";
aProperties[3] = "RelativeY";
aProperties[4] = "RelativeWidth";
aProperties[5] = "RelativeHeight";
PresenterConfigurationAccess::ForAll(
xList,
aProperties,
[this, rxContext, rxAnchorId](std::vector<uno::Any> const& rArgs)
{
this->ProcessComponent(rArgs, rxContext, rxAnchorId);
});
}
catch (const RuntimeException&)
{
}
}
void PresenterScreen::ProcessViewDescriptions (
PresenterConfigurationAccess& rConfiguration)
{
try
{
Reference<container::XNameAccess> xViewDescriptionsNode (
rConfiguration.GetConfigurationNode("Presenter/Views"),
UNO_QUERY_THROW);
::std::vector<OUString> aProperties (4);
aProperties[0] = "ViewURL";
aProperties[1] = "Title";
aProperties[2] = "AccessibleTitle";
aProperties[3] = "IsOpaque";
PresenterConfigurationAccess::ForAll(
xViewDescriptionsNode,
aProperties,
[this](std::vector<uno::Any> const& rArgs)
{
return this->ProcessViewDescription(rArgs);
});
}
catch (const RuntimeException&)
{
OSL_ASSERT(false);
}
}
void PresenterScreen::ProcessComponent (
const ::std::vector<Any>& rValues,
const Reference<XComponentContext>& rxContext,
const Reference<XResourceId>& rxAnchorId)
{
if (rValues.size() != 6)
return;
try
{
OUString sPaneURL;
OUString sViewURL;
double nX = 0;<--- 'nX' is assigned value '0' here.<--- 'nX' is assigned value '0' here.
double nY = 0;<--- 'nY' is assigned value '0' here.<--- 'nY' is assigned value '0' here.
double nWidth = 0;<--- 'nWidth' is assigned value '0' here.<--- 'nWidth' is assigned value '0' here.
double nHeight = 0;<--- 'nHeight' is assigned value '0' here.<--- 'nHeight' is assigned value '0' here.
rValues[0] >>= sPaneURL;
rValues[1] >>= sViewURL;
rValues[2] >>= nX;
rValues[3] >>= nY;
rValues[4] >>= nWidth;
rValues[5] >>= nHeight;
if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)<--- Redundant condition: If 'nWidth > 0', the comparison 'nY >= 0' is always true.<--- The comparison 'nX >= 0' is always true. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- Same expression on both sides of '&&' because 'nX>=0' and 'nY>=0' represent the same value. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- The comparison 'nY >= 0' is always true. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- The comparison 'nWidth > 0' is always false. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- Same expression on both sides of '&&' because 'nHeight>0' and 'nWidth>0' represent the same value. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- The comparison 'nHeight > 0' is always false. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
{
SetupView(
rxContext,
rxAnchorId,
sPaneURL,
sViewURL,
PresenterPaneContainer::ViewInitializationFunction());
}
}
catch (const Exception&)
{
OSL_ASSERT(false);
}
}
void PresenterScreen::ProcessViewDescription (
const ::std::vector<Any>& rValues)
{
if (rValues.size() != 4)
return;
try
{
ViewDescriptor aViewDescriptor;
OUString sViewURL;
rValues[0] >>= sViewURL;
rValues[1] >>= aViewDescriptor.msTitle;
rValues[2] >>= aViewDescriptor.msAccessibleTitle;
rValues[3] >>= aViewDescriptor.mbIsOpaque;
if (aViewDescriptor.msAccessibleTitle.isEmpty())
aViewDescriptor.msAccessibleTitle = aViewDescriptor.msTitle;
maViewDescriptors[sViewURL] = aViewDescriptor;
}
catch (const Exception&)
{
OSL_ASSERT(false);
}
}
void PresenterScreen::SetupView(
const Reference<XComponentContext>& rxContext,
const Reference<XResourceId>& rxAnchorId,
const OUString& rsPaneURL,
const OUString& rsViewURL,
const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization)
{
Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
if (!xCC.is())
return;
Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
// Look up the view descriptor.
ViewDescriptor aViewDescriptor;
ViewDescriptorContainer::const_iterator iDescriptor (maViewDescriptors.find(rsViewURL));
if (iDescriptor != maViewDescriptors.end())
aViewDescriptor = iDescriptor->second;
// Prepare the pane.
OSL_ASSERT(mpPaneContainer);
mpPaneContainer->PreparePane(
xPaneId,
rsViewURL,
aViewDescriptor.msTitle,
aViewDescriptor.msAccessibleTitle,
aViewDescriptor.mbIsOpaque,
rViewInitialization);
}
} // end of namespace ::sdext::presenter
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|