Bump version to 5.0-14
[LibreOffice.git] / sdext / source / presenter / PresenterFrameworkObserver.hxx
blob3ebc2cb5914010f4b84635bb37c4b07bf9fb19c0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERFRAMEWORKOBSERVER_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERFRAMEWORKOBSERVER_HXX
23 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
24 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
25 #include <cppuhelper/basemutex.hxx>
26 #include <cppuhelper/compbase1.hxx>
27 #include <boost/function.hpp>
28 #include <boost/noncopyable.hpp>
30 namespace sdext { namespace presenter {
32 typedef ::cppu::WeakComponentImplHelper1 <
33 css::drawing::framework::XConfigurationChangeListener
34 > PresenterFrameworkObserverInterfaceBase;
36 /** Watch the drawing framework for changes and run callbacks when a certain
37 change takes place.
39 class PresenterFrameworkObserver
40 : private ::boost::noncopyable,
41 private ::cppu::BaseMutex,
42 public PresenterFrameworkObserverInterfaceBase
44 public:
45 typedef ::boost::function<bool()> Predicate;
46 typedef ::boost::function<void(bool)> Action;
48 static void RunOnUpdateEnd (
49 const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
50 const Action& rAction);
52 virtual void SAL_CALL disposing() SAL_OVERRIDE;
53 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
54 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
55 virtual void SAL_CALL notifyConfigurationChange (
56 const css::drawing::framework::ConfigurationChangeEvent& rEvent)
57 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
59 private:
60 css::uno::Reference<css::drawing::framework::XConfigurationController> mxConfigurationController;
61 Predicate maPredicate;
62 Action maAction;
64 /** Create a new PresenterFrameworkObserver object.
65 @param rsEventName
66 An event name other than ConfigurationUpdateEnd. When the
67 observer shall only listen for ConfigurationUpdateEnd then pass
68 an empty name.
69 @param rPredicate
70 This functor tests whether the action is to be executed or not.
71 @param rAction
72 The functor to execute when the predicate returns true,
73 e.g. when some resource has been created.
75 PresenterFrameworkObserver (
76 const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
77 const OUString& rsEventName,
78 const Predicate& rPredicate,
79 const Action& rAction);
80 virtual ~PresenterFrameworkObserver();
82 void Shutdown();
84 /** Predicate that always returns true.
86 static bool True();
89 } } // end of namespace ::sdext::presenter
91 #endif
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */