LibreOffice Module sdext (master)  1
PresenterFrameworkObserver.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
21 #include <com/sun/star/lang/IllegalArgumentException.hpp>
22 
23 using namespace ::com::sun::star;
24 using namespace ::com::sun::star::uno;
25 using namespace ::com::sun::star::drawing::framework;
26 
27 
28 namespace sdext { namespace presenter {
29 
31  const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
32  const Action& rAction)
34  mxConfigurationController(rxController),
35  maAction(rAction)
36 {
37  if ( ! mxConfigurationController.is())
38  throw lang::IllegalArgumentException();
39 
40  if (mxConfigurationController->hasPendingRequests())
41  {
42  mxConfigurationController->addConfigurationChangeListener(
43  this,
44  "ConfigurationUpdateEnd",
45  Any());
46  }
47  else
48  {
49  rAction(true);
50  }
51 }
52 
54 {
55 }
56 
58  const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
59  const Action& rAction)
60 {
62  rxController,
63  rAction);
64 }
65 
67 {
68  if (maAction)
69  maAction(false);
70  Shutdown();
71 }
72 
74 {
75  maAction = Action();
76  if (mxConfigurationController != nullptr)
77  {
78  mxConfigurationController->removeConfigurationChangeListener(this);
79  mxConfigurationController = nullptr;
80  }
81 }
82 
83 void SAL_CALL PresenterFrameworkObserver::disposing (const lang::EventObject& rEvent)
84 {
85  if ( ! rEvent.Source.is())
86  return;
87 
88  if (rEvent.Source == mxConfigurationController)
89  {
90  mxConfigurationController = nullptr;
91  if (maAction)
92  maAction(false);
93  }
94 }
95 
97  const ConfigurationChangeEvent& /*rEvent*/)
98 {
99  Action aAction(maAction);
100  Shutdown();
101  aAction(true);
102 
103  maAction = nullptr;
104  dispose();
105 }
106 
107 } } // end of namespace ::sdext::presenter
108 
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
osl::Mutex m_aMutex
const Action maAction
css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
static void RunOnUpdateEnd(const css::uno::Reference< css::drawing::framework::XConfigurationController > &rxController, const Action &rAction)
PresenterFrameworkObserver(const PresenterFrameworkObserver &)=delete
::cppu::WeakComponentImplHelper< css::drawing::framework::XConfigurationChangeListener > PresenterFrameworkObserverInterfaceBase
virtual void SAL_CALL notifyConfigurationChange(const css::drawing::framework::ConfigurationChangeEvent &rEvent) override
void dispose()