summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-23 08:45:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-23 09:42:01 +0200
commite5f5d9022150242a8a1222ccc657f7769d881594 (patch)
tree5992f71fe2d867c67d60c9c7224d589649dda607
parentc3199d1d58957a421d68ffbf6a63666aac755a51 (diff)
use rtl::Reference in OLocalExchangeHelper
instead of manual acquire/release Change-Id: I40035df2995b71d868fc4d1f08a20b5fa4546fc9
-rw-r--r--svx/source/form/fmexch.cxx21
-rw-r--r--svx/source/inc/filtnav.hxx2
-rw-r--r--svx/source/inc/fmexch.hxx17
3 files changed, 19 insertions, 21 deletions
diff --git a/svx/source/form/fmexch.cxx b/svx/source/form/fmexch.cxx
index 0880968c309e..59b8c209f695 100644
--- a/svx/source/form/fmexch.cxx
+++ b/svx/source/form/fmexch.cxx
@@ -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();
}
diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx
index 5f458f7f241f..a48391a6c63b 100644
--- a/svx/source/inc/filtnav.hxx
+++ b/svx/source/inc/filtnav.hxx
@@ -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;
diff --git a/svx/source/inc/fmexch.hxx b/svx/source/inc/fmexch.hxx
index b750e490114b..90e425922885 100644
--- a/svx/source/inc/fmexch.hxx
+++ b/svx/source/inc/fmexch.hxx
@@ -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;