[Libreoffice-commits] core.git: 2 commits - svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Jan 23 07:42:32 UTC 2017
svx/source/form/fmexch.cxx | 21 +++++++++------------
svx/source/form/fmmodel.cxx | 40 +++++++++++++++++-----------------------
svx/source/inc/filtnav.hxx | 2 +-
svx/source/inc/fmexch.hxx | 17 +++++++++--------
4 files changed, 36 insertions(+), 44 deletions(-)
New commits:
commit 10d0c60947da520779040af25b0c558564b71aff
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jan 23 08:48:02 2017 +0200
use rtl::Reference in FmFormModelImplData
instead of manual acquire/release
Change-Id: I925b45bcc2f09e09330ae8c79f3f40b81ae120ed
diff --git a/svx/source/form/fmmodel.cxx b/svx/source/form/fmmodel.cxx
index 3c7b1b4..22c9e20 100644
--- a/svx/source/form/fmmodel.cxx
+++ b/svx/source/form/fmmodel.cxx
@@ -37,15 +37,14 @@ using namespace svxform;
struct FmFormModelImplData
{
- FmXUndoEnvironment* pUndoEnv;
+ rtl::Reference<FmXUndoEnvironment> mxUndoEnv;
bool bOpenInDesignIsDefaulted;
bool bMovingPage;
::boost::optional< sal_Bool >
aControlsUseRefDevice;
FmFormModelImplData()
- :pUndoEnv( nullptr )
- ,bOpenInDesignIsDefaulted( true )
+ :bOpenInDesignIsDefaulted( true )
,bMovingPage( false )
,aControlsUseRefDevice()
{
@@ -60,8 +59,7 @@ FmFormModel::FmFormModel(SfxItemPool* pPool, SfxObjectShell* pPers)
, m_bAutoControlFocus(false)
{
m_pImpl.reset( new FmFormModelImplData );
- m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this);
- m_pImpl->pUndoEnv->acquire();
+ m_pImpl->mxUndoEnv = new FmXUndoEnvironment(*this);
}
FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers)
@@ -72,8 +70,7 @@ FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShe
, m_bAutoControlFocus(false)
{
m_pImpl.reset( new FmFormModelImplData );
- m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this);
- m_pImpl->pUndoEnv->acquire();
+ m_pImpl->mxUndoEnv = new FmXUndoEnvironment(*this);
}
FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers,
@@ -85,20 +82,17 @@ FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShe
, m_bAutoControlFocus(false)
{
m_pImpl.reset( new FmFormModelImplData );
- m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this);
- m_pImpl->pUndoEnv->acquire();
+ m_pImpl->mxUndoEnv = new FmXUndoEnvironment(*this);
}
FmFormModel::~FmFormModel()
{
- if (m_pObjShell && m_pImpl->pUndoEnv->IsListening(*m_pObjShell))
+ if (m_pObjShell && m_pImpl->mxUndoEnv->IsListening(*m_pObjShell))
SetObjectShell(nullptr);
ClearUndoBuffer();
// minimale grenze fuer undos
SetMaxUndoActionCount(1);
-
- m_pImpl->pUndoEnv->release();
}
SdrPage* FmFormModel::AllocPage(bool bMasterPage)
@@ -109,7 +103,7 @@ SdrPage* FmFormModel::AllocPage(bool bMasterPage)
void FmFormModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
{
// hack solange Methode intern
- if (m_pObjShell && !m_pImpl->pUndoEnv->IsListening( *m_pObjShell ))
+ if (m_pObjShell && !m_pImpl->mxUndoEnv->IsListening( *m_pObjShell ))
SetObjectShell(m_pObjShell);
SdrModel::InsertPage( pPage, nPos );
@@ -134,7 +128,7 @@ SdrPage* FmFormModel::RemovePage(sal_uInt16 nPgNum)
{
Reference< XNameContainer > xForms( pToBeRemovedPage->GetForms( false ), css::uno::UNO_QUERY );
if ( xForms.is() )
- m_pImpl->pUndoEnv->RemoveForms( xForms );
+ m_pImpl->mxUndoEnv->RemoveForms( xForms );
}
FmFormPage* pRemovedPage = static_cast<FmFormPage*>(SdrModel::RemovePage(nPgNum));
@@ -145,7 +139,7 @@ SdrPage* FmFormModel::RemovePage(sal_uInt16 nPgNum)
void FmFormModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
{
// hack solange Methode intern
- if (m_pObjShell && !m_pImpl->pUndoEnv->IsListening( *m_pObjShell ))
+ if (m_pObjShell && !m_pImpl->mxUndoEnv->IsListening( *m_pObjShell ))
SetObjectShell(m_pObjShell);
SdrModel::InsertMasterPage(pPage, nPos);
@@ -159,7 +153,7 @@ SdrPage* FmFormModel::RemoveMasterPage(sal_uInt16 nPgNum)
{
Reference< XNameContainer > xForms( pPage->GetForms( false ), css::uno::UNO_QUERY );
if ( xForms.is() )
- m_pImpl->pUndoEnv->RemoveForms( xForms );
+ m_pImpl->mxUndoEnv->RemoveForms( xForms );
}
return pPage;
@@ -222,27 +216,27 @@ void FmFormModel::SetObjectShell( SfxObjectShell* pShell )
if (m_pObjShell)
{
- m_pImpl->pUndoEnv->EndListening( *this );
- m_pImpl->pUndoEnv->EndListening( *m_pObjShell );
+ m_pImpl->mxUndoEnv->EndListening( *this );
+ m_pImpl->mxUndoEnv->EndListening( *m_pObjShell );
}
m_pObjShell = pShell;
if (m_pObjShell)
{
- m_pImpl->pUndoEnv->SetReadOnly( m_pObjShell->IsReadOnly() || m_pObjShell->IsReadOnlyUI(), FmXUndoEnvironment::Accessor() );
+ m_pImpl->mxUndoEnv->SetReadOnly( m_pObjShell->IsReadOnly() || m_pObjShell->IsReadOnlyUI(), FmXUndoEnvironment::Accessor() );
- if (!m_pImpl->pUndoEnv->IsReadOnly())
- m_pImpl->pUndoEnv->StartListening(*this);
+ if (!m_pImpl->mxUndoEnv->IsReadOnly())
+ m_pImpl->mxUndoEnv->StartListening(*this);
- m_pImpl->pUndoEnv->StartListening( *m_pObjShell );
+ m_pImpl->mxUndoEnv->StartListening( *m_pObjShell );
}
}
FmXUndoEnvironment& FmFormModel::GetUndoEnv()
{
- return *m_pImpl->pUndoEnv;
+ return *m_pImpl->mxUndoEnv;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e5f5d9022150242a8a1222ccc657f7769d881594
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jan 23 08:45:50 2017 +0200
use rtl::Reference in OLocalExchangeHelper
instead of manual acquire/release
Change-Id: I40035df2995b71d868fc4d1f08a20b5fa4546fc9
diff --git a/svx/source/form/fmexch.cxx b/svx/source/form/fmexch.cxx
index 0880968..59b8c20 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 5f458f7..a48391a 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 b750e49..90e4259 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;
More information about the Libreoffice-commits
mailing list