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 .
|
|
|
|
*/
|
2007-07-06 09:17:43 +00:00
|
|
|
|
2013-10-23 19:17:00 +02:00
|
|
|
#ifndef INCLUDED_COMPHELPER_SELECTIONMULTIPLEX_HXX
|
|
|
|
#define INCLUDED_COMPHELPER_SELECTIONMULTIPLEX_HXX
|
2007-07-06 09:17:43 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/view/XSelectionChangeListener.hpp>
|
|
|
|
#include <com/sun/star/view/XSelectionSupplier.hpp>
|
2015-07-10 17:50:12 +09:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2013-11-09 13:59:36 -06:00
|
|
|
#include <comphelper/comphelperdllapi.h>
|
2017-01-20 12:05:56 +02:00
|
|
|
#include <rtl/ref.hxx>
|
2007-07-06 09:17:43 +00:00
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
//= selection helper classes
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
namespace comphelper
|
|
|
|
{
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
|
|
|
|
class OSelectionChangeMultiplexer;
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
//= OSelectionChangeListener
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
/// simple listener adapter for selections
|
|
|
|
class COMPHELPER_DLLPUBLIC OSelectionChangeListener
|
|
|
|
{
|
|
|
|
friend class OSelectionChangeMultiplexer;
|
|
|
|
|
2017-01-20 12:05:56 +02:00
|
|
|
rtl::Reference<OSelectionChangeMultiplexer> m_xAdapter;
|
|
|
|
::osl::Mutex& m_rMutex;
|
2007-07-06 09:17:43 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
OSelectionChangeListener(::osl::Mutex& _rMutex)
|
2017-01-20 12:05:56 +02:00
|
|
|
: m_rMutex(_rMutex) { }
|
2007-07-06 09:17:43 +00:00
|
|
|
virtual ~OSelectionChangeListener();
|
|
|
|
|
2017-01-19 18:00:00 +01:00
|
|
|
/// @throws css::uno::RuntimeException
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void _selectionChanged( const css::lang::EventObject& aEvent ) = 0;
|
2017-01-19 18:00:00 +01:00
|
|
|
/// @throws css::uno::RuntimeException
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void _disposing(const css::lang::EventObject& _rSource);
|
2007-07-06 09:17:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// pseudo-private. Making it private now could break compatibility
|
|
|
|
void setAdapter( OSelectionChangeMultiplexer* _pAdapter );
|
|
|
|
};
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
//= OSelectionChangeMultiplexer
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
/// multiplexer for selection changes
|
2015-10-19 12:51:29 +02:00
|
|
|
class COMPHELPER_DLLPUBLIC OSelectionChangeMultiplexer :public cppu::WeakImplHelper< css::view::XSelectionChangeListener>
|
2007-07-06 09:17:43 +00:00
|
|
|
{
|
|
|
|
friend class OSelectionChangeListener;
|
2015-10-19 12:51:29 +02:00
|
|
|
css::uno::Reference< css::view::XSelectionSupplier> m_xSet;
|
|
|
|
OSelectionChangeListener* m_pListener;
|
|
|
|
sal_Int32 m_nLockCount;
|
2007-07-06 09:17:43 +00:00
|
|
|
|
2015-10-12 15:25:41 +02:00
|
|
|
OSelectionChangeMultiplexer(const OSelectionChangeMultiplexer&) = delete;
|
|
|
|
OSelectionChangeMultiplexer& operator=(const OSelectionChangeMultiplexer&) = delete;
|
2007-07-06 09:17:43 +00:00
|
|
|
protected:
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~OSelectionChangeMultiplexer() override;
|
2007-07-06 09:17:43 +00:00
|
|
|
public:
|
2016-04-04 15:01:55 +02:00
|
|
|
OSelectionChangeMultiplexer(OSelectionChangeListener* _pListener, const css::uno::Reference< css::view::XSelectionSupplier>& _rxSet);
|
2007-07-06 09:17:43 +00:00
|
|
|
|
|
|
|
// XEventListener
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
|
2007-07-06 09:17:43 +00:00
|
|
|
|
|
|
|
// XSelectionChangeListener
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void SAL_CALL selectionChanged( const css::lang::EventObject& aEvent ) override;
|
2007-07-06 09:17:43 +00:00
|
|
|
|
|
|
|
/// incremental lock
|
|
|
|
void lock();
|
|
|
|
/// incremental unlock
|
|
|
|
void unlock();
|
|
|
|
/// get the lock count
|
|
|
|
sal_Int32 locked() const { return m_nLockCount; }
|
|
|
|
};
|
|
|
|
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
} // namespace comphelper
|
2014-02-25 19:06:16 +01:00
|
|
|
|
2007-07-06 09:17:43 +00:00
|
|
|
|
2013-10-23 19:17:00 +02:00
|
|
|
#endif // INCLUDED_COMPHELPER_SELECTIONMULTIPLEX_HXX
|
2007-07-06 09:17:43 +00:00
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|