112 lines
4.2 KiB
C++
112 lines
4.2 KiB
C++
![]() |
/*************************************************************************
|
||
|
*
|
||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||
|
*
|
||
|
* $RCSfile: PresenterFrameworkObserver.hxx,v $
|
||
|
*
|
||
|
* $Revision: 1.2 $
|
||
|
*
|
||
|
* last change: $Author: kz $ $Date: 2008-04-03 15:58:23 $
|
||
|
*
|
||
|
* The Contents of this file are made available subject to
|
||
|
* the terms of GNU Lesser General Public License Version 2.1.
|
||
|
*
|
||
|
*
|
||
|
* GNU Lesser General Public License Version 2.1
|
||
|
* =============================================
|
||
|
* Copyright 2005 by Sun Microsystems, Inc.
|
||
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Lesser General Public
|
||
|
* License version 2.1, as published by the Free Software Foundation.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public
|
||
|
* License along with this library; if not, write to the Free Software
|
||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||
|
* MA 02111-1307 USA
|
||
|
*
|
||
|
************************************************************************/
|
||
|
|
||
|
#ifndef SDEXT_PRESENTER_PRESENTER_FRAMEWORK_OBSERVER_HXX
|
||
|
#define SDEXT_PRESENTER_PRESENTER_FRAMEWORK_OBSERVER_HXX
|
||
|
|
||
|
#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
|
||
|
#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
|
||
|
#include <cppuhelper/basemutex.hxx>
|
||
|
#include <cppuhelper/compbase1.hxx>
|
||
|
#include <boost/function.hpp>
|
||
|
#include <boost/noncopyable.hpp>
|
||
|
|
||
|
namespace css = ::com::sun::star;
|
||
|
|
||
|
namespace sdext { namespace presenter {
|
||
|
|
||
|
|
||
|
typedef ::cppu::WeakComponentImplHelper1 <
|
||
|
::com::sun::star::drawing::framework::XConfigurationChangeListener
|
||
|
> PresenterFrameworkObserverInterfaceBase;
|
||
|
|
||
|
/** Watch the drawing framework for changes and run callbacks when a certain
|
||
|
change takes place.
|
||
|
*/
|
||
|
class PresenterFrameworkObserver
|
||
|
: private ::boost::noncopyable,
|
||
|
private ::cppu::BaseMutex,
|
||
|
public PresenterFrameworkObserverInterfaceBase
|
||
|
{
|
||
|
public:
|
||
|
typedef ::boost::function<bool(void)> Predicate;
|
||
|
typedef ::boost::function<void(bool)> Action;
|
||
|
|
||
|
/** Register an action callback to be run when the specified resource is
|
||
|
activated. The action may be called synchronously when the resource
|
||
|
is already active or asynchronously when the resource is actived in
|
||
|
the future.
|
||
|
@param rxController
|
||
|
The controller gives access to the drawing framework.
|
||
|
@param rxResourceId
|
||
|
The id of the resource to watch for activation.
|
||
|
@param rAction
|
||
|
The callback that is called when the resource is activated.
|
||
|
*/
|
||
|
static void RunOnResourceActivation (
|
||
|
const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
|
||
|
const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
|
||
|
const Action& rAction);
|
||
|
|
||
|
virtual void SAL_CALL disposing (void);
|
||
|
virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
|
||
|
throw (css::uno::RuntimeException);
|
||
|
virtual void SAL_CALL notifyConfigurationChange (
|
||
|
const css::drawing::framework::ConfigurationChangeEvent& rEvent)
|
||
|
throw (css::uno::RuntimeException);
|
||
|
|
||
|
private:
|
||
|
::rtl::OUString msEventType;
|
||
|
::css::uno::Reference<css::drawing::framework::XConfigurationController> mxConfigurationController;
|
||
|
Predicate maPredicate;
|
||
|
Action maAction;
|
||
|
|
||
|
PresenterFrameworkObserver (
|
||
|
const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
|
||
|
const ::rtl::OUString& rsEventName,
|
||
|
const Predicate& rPredicate,
|
||
|
const Action& rAction);
|
||
|
virtual ~PresenterFrameworkObserver (void);
|
||
|
|
||
|
static bool HasResource (
|
||
|
const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
|
||
|
const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
|
||
|
};
|
||
|
|
||
|
|
||
|
} } // end of namespace ::sdext::presenter
|
||
|
|
||
|
#endif
|