2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2000-09-29 10:28:15 +00:00
|
|
|
|
2013-10-23 19:17:00 +02:00
|
|
|
#ifndef INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
|
|
|
|
#define INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
|
2000-09-29 10:28:15 +00:00
|
|
|
|
|
|
|
#include <comphelper/propstate.hxx>
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
2013-11-09 13:59:36 -06:00
|
|
|
#include <comphelper/comphelperdllapi.h>
|
2000-09-29 10:28:15 +00:00
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2000-09-29 10:28:15 +00:00
|
|
|
//= property helper classes
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
|
|
|
|
2000-09-29 10:28:15 +00:00
|
|
|
namespace comphelper
|
|
|
|
{
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2000-09-29 10:28:15 +00:00
|
|
|
|
2005-06-14 15:46:37 +00:00
|
|
|
class OPropertyChangeMultiplexer;
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2001-01-08 09:33:03 +00:00
|
|
|
//= OPropertyChangeListener
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2001-01-08 09:33:03 +00:00
|
|
|
/// simple listener adapter for property sets
|
2005-02-16 15:00:09 +00:00
|
|
|
class COMPHELPER_DLLPUBLIC OPropertyChangeListener
|
2001-01-08 09:33:03 +00:00
|
|
|
{
|
|
|
|
friend class OPropertyChangeMultiplexer;
|
|
|
|
|
|
|
|
OPropertyChangeMultiplexer* m_pAdapter;
|
|
|
|
::osl::Mutex& m_rMutex;
|
|
|
|
|
|
|
|
public:
|
|
|
|
OPropertyChangeListener(::osl::Mutex& _rMutex)
|
2004-04-21 13:05:25 +00:00
|
|
|
: m_pAdapter(NULL), m_rMutex(_rMutex) { }
|
2001-01-08 09:33:03 +00:00
|
|
|
virtual ~OPropertyChangeListener();
|
|
|
|
|
2014-05-22 21:03:48 +01:00
|
|
|
virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent)
|
|
|
|
throw (css::uno::RuntimeException, std::exception) = 0;
|
2014-02-25 15:54:52 +00:00
|
|
|
virtual void _disposing(const ::com::sun::star::lang::EventObject& _rSource)
|
|
|
|
throw( ::com::sun::star::uno::RuntimeException, std::exception);
|
2001-01-08 09:33:03 +00:00
|
|
|
|
|
|
|
protected:
|
2004-11-16 11:35:15 +00:00
|
|
|
/** If the derivee also owns the mutex which we know as reference, then call this within your
|
|
|
|
derivee's dtor.
|
|
|
|
*/
|
|
|
|
void disposeAdapter();
|
|
|
|
|
|
|
|
// pseudo-private. Making it private now could break compatibility
|
|
|
|
void setAdapter( OPropertyChangeMultiplexer* _pAdapter );
|
2001-01-08 09:33:03 +00:00
|
|
|
};
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2001-01-08 09:33:03 +00:00
|
|
|
//= OPropertyChangeMultiplexer
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2001-01-08 09:33:03 +00:00
|
|
|
/// multiplexer for property changes
|
2005-02-16 15:00:09 +00:00
|
|
|
class COMPHELPER_DLLPUBLIC OPropertyChangeMultiplexer :public cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertyChangeListener>
|
2001-01-08 09:33:03 +00:00
|
|
|
{
|
|
|
|
friend class OPropertyChangeListener;
|
2013-04-07 12:06:47 +02:00
|
|
|
::com::sun::star::uno::Sequence< OUString > m_aProperties;
|
2001-01-08 09:33:03 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xSet;
|
|
|
|
OPropertyChangeListener* m_pListener;
|
|
|
|
sal_Int32 m_nLockCount;
|
2014-02-16 22:51:15 +01:00
|
|
|
bool m_bListening : 1;
|
|
|
|
bool m_bAutoSetRelease : 1;
|
2001-01-08 09:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
virtual ~OPropertyChangeMultiplexer();
|
|
|
|
public:
|
2014-02-16 22:51:15 +01:00
|
|
|
OPropertyChangeMultiplexer(OPropertyChangeListener* _pListener, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxSet, bool _bAutoReleaseSet = true);
|
2001-01-08 09:33:03 +00:00
|
|
|
|
|
|
|
// XEventListener
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2001-01-08 09:33:03 +00:00
|
|
|
|
|
|
|
// XPropertyChangeListener
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2001-01-08 09:33:03 +00:00
|
|
|
|
|
|
|
/// incremental lock
|
|
|
|
void lock();
|
|
|
|
/// incremental unlock
|
|
|
|
void unlock();
|
|
|
|
/// get the lock count
|
|
|
|
sal_Int32 locked() const { return m_nLockCount; }
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void addProperty(const OUString& aPropertyName);
|
2001-01-08 09:33:03 +00:00
|
|
|
void dispose();
|
|
|
|
};
|
2000-09-29 10:28:15 +00:00
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2000-09-29 10:28:15 +00:00
|
|
|
} // namespace comphelper
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2000-09-29 10:28:15 +00:00
|
|
|
|
2013-10-23 19:17:00 +02:00
|
|
|
#endif // INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
|
2000-09-29 10:28:15 +00:00
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|