Kaydet (Commit) e5f5d902 authored tarafından Noel Grandin's avatar Noel Grandin

use rtl::Reference in OLocalExchangeHelper

instead of manual acquire/release

Change-Id: I40035df2995b71d868fc4d1f08a20b5fa4546fc9
üst c3199d1d
......@@ -359,7 +359,6 @@ namespace svxform
OLocalExchangeHelper::OLocalExchangeHelper(vcl::Window* _pDragSource)
:m_pDragSource(_pDragSource)
,m_pTransferable(nullptr)
{
}
......@@ -372,36 +371,34 @@ namespace svxform
void OLocalExchangeHelper::startDrag( sal_Int8 nDragSourceActions )
{
DBG_ASSERT(m_pTransferable, "OLocalExchangeHelper::startDrag: not prepared!");
m_pTransferable->startDrag( m_pDragSource, nDragSourceActions, OLocalExchange::GrantAccess() );
DBG_ASSERT(m_xTransferable.is(), "OLocalExchangeHelper::startDrag: not prepared!");
m_xTransferable->startDrag( m_pDragSource, nDragSourceActions, OLocalExchange::GrantAccess() );
}
void OLocalExchangeHelper::copyToClipboard( ) const
{
DBG_ASSERT( m_pTransferable, "OLocalExchangeHelper::copyToClipboard: not prepared!" );
m_pTransferable->copyToClipboard( m_pDragSource, OLocalExchange::GrantAccess() );
DBG_ASSERT( m_xTransferable.is(), "OLocalExchangeHelper::copyToClipboard: not prepared!" );
m_xTransferable->copyToClipboard( m_pDragSource, OLocalExchange::GrantAccess() );
}
void OLocalExchangeHelper::implReset()
{
if (m_pTransferable)
if (m_xTransferable.is())
{
m_pTransferable->setClipboardListener( Link<OLocalExchange&,void>() );
m_pTransferable->release();
m_pTransferable = nullptr;
m_xTransferable->setClipboardListener( Link<OLocalExchange&,void>() );
m_xTransferable.clear();
}
}
void OLocalExchangeHelper::prepareDrag( )
{
DBG_ASSERT(!m_pTransferable || !m_pTransferable->isDragging(), "OLocalExchangeHelper::prepareDrag: recursive DnD?");
DBG_ASSERT(!m_xTransferable.is() || !m_xTransferable->isDragging(), "OLocalExchangeHelper::prepareDrag: recursive DnD?");
implReset();
m_pTransferable = createExchange();
m_pTransferable->acquire();
m_xTransferable = createExchange();
}
......
......@@ -220,7 +220,7 @@ class OFilterExchangeHelper : public OLocalExchangeHelper
public:
OFilterExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_pTransferable); }
OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_xTransferable.get()); }
protected:
virtual OLocalExchange* createExchange() const override;
......
......@@ -28,6 +28,7 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/form/XForms.hpp>
#include <rtl/ref.hxx>
#include <tools/link.hxx>
#include <vcl/window.hxx>
#include <svx/svxdllapi.h>
......@@ -92,8 +93,8 @@ namespace svxform
class SVX_DLLPUBLIC OLocalExchangeHelper
{
protected:
VclPtr<vcl::Window> m_pDragSource;
OLocalExchange* m_pTransferable;
VclPtr<vcl::Window> m_pDragSource;
rtl::Reference<OLocalExchange> m_xTransferable;
public:
OLocalExchangeHelper( vcl::Window* _pDragSource );
......@@ -104,12 +105,12 @@ namespace svxform
void startDrag( sal_Int8 nDragSourceActions );
void copyToClipboard( ) const;
inline bool isDragSource() const { return m_pTransferable && m_pTransferable->isDragging(); }
inline bool isClipboardOwner() const { return m_pTransferable && m_pTransferable->isClipboardOwner(); }
inline bool isDragSource() const { return m_xTransferable.is() && m_xTransferable->isDragging(); }
inline bool isClipboardOwner() const { return m_xTransferable.is() && m_xTransferable->isClipboardOwner(); }
inline bool isDataExchangeActive( ) const { return isDragSource() || isClipboardOwner(); }
inline void clear() { if ( isDataExchangeActive() ) m_pTransferable->clear(); }
inline void clear() { if ( isDataExchangeActive() ) m_xTransferable->clear(); }
SVX_DLLPRIVATE void setClipboardListener( const Link<OLocalExchange&,void>& _rListener ) { if ( m_pTransferable ) m_pTransferable->setClipboardListener( _rListener ); }
SVX_DLLPRIVATE void setClipboardListener( const Link<OLocalExchange&,void>& _rListener ) { if ( m_xTransferable.is() ) m_xTransferable->setClipboardListener( _rListener ); }
protected:
SVX_DLLPRIVATE virtual OLocalExchange* createExchange() const = 0;
......@@ -219,8 +220,8 @@ namespace svxform
public:
OControlExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
OControlExchange* operator->() const { return static_cast< OControlExchange* >( m_pTransferable ); }
OControlExchange& operator*() const { return *static_cast< OControlExchange* >( m_pTransferable ); }
OControlExchange* operator->() const { return static_cast< OControlExchange* >( m_xTransferable.get() ); }
OControlExchange& operator*() const { return *static_cast< OControlExchange* >( m_xTransferable.get() ); }
protected:
virtual OLocalExchange* createExchange() const override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment