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

use rtl::Reference in FmFormModelImplData

instead of manual acquire/release

Change-Id: I925b45bcc2f09e09330ae8c79f3f40b81ae120ed
üst e5f5d902
...@@ -37,15 +37,14 @@ using namespace svxform; ...@@ -37,15 +37,14 @@ using namespace svxform;
struct FmFormModelImplData struct FmFormModelImplData
{ {
FmXUndoEnvironment* pUndoEnv; rtl::Reference<FmXUndoEnvironment> mxUndoEnv;
bool bOpenInDesignIsDefaulted; bool bOpenInDesignIsDefaulted;
bool bMovingPage; bool bMovingPage;
::boost::optional< sal_Bool > ::boost::optional< sal_Bool >
aControlsUseRefDevice; aControlsUseRefDevice;
FmFormModelImplData() FmFormModelImplData()
:pUndoEnv( nullptr ) :bOpenInDesignIsDefaulted( true )
,bOpenInDesignIsDefaulted( true )
,bMovingPage( false ) ,bMovingPage( false )
,aControlsUseRefDevice() ,aControlsUseRefDevice()
{ {
...@@ -60,8 +59,7 @@ FmFormModel::FmFormModel(SfxItemPool* pPool, SfxObjectShell* pPers) ...@@ -60,8 +59,7 @@ FmFormModel::FmFormModel(SfxItemPool* pPool, SfxObjectShell* pPers)
, m_bAutoControlFocus(false) , m_bAutoControlFocus(false)
{ {
m_pImpl.reset( new FmFormModelImplData ); m_pImpl.reset( new FmFormModelImplData );
m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this); m_pImpl->mxUndoEnv = new FmXUndoEnvironment(*this);
m_pImpl->pUndoEnv->acquire();
} }
FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers) FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers)
...@@ -72,8 +70,7 @@ FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShe ...@@ -72,8 +70,7 @@ FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShe
, m_bAutoControlFocus(false) , m_bAutoControlFocus(false)
{ {
m_pImpl.reset( new FmFormModelImplData ); m_pImpl.reset( new FmFormModelImplData );
m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this); m_pImpl->mxUndoEnv = new FmXUndoEnvironment(*this);
m_pImpl->pUndoEnv->acquire();
} }
FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers, FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers,
...@@ -85,20 +82,17 @@ FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShe ...@@ -85,20 +82,17 @@ FmFormModel::FmFormModel(const OUString& rPath, SfxItemPool* pPool, SfxObjectShe
, m_bAutoControlFocus(false) , m_bAutoControlFocus(false)
{ {
m_pImpl.reset( new FmFormModelImplData ); m_pImpl.reset( new FmFormModelImplData );
m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this); m_pImpl->mxUndoEnv = new FmXUndoEnvironment(*this);
m_pImpl->pUndoEnv->acquire();
} }
FmFormModel::~FmFormModel() FmFormModel::~FmFormModel()
{ {
if (m_pObjShell && m_pImpl->pUndoEnv->IsListening(*m_pObjShell)) if (m_pObjShell && m_pImpl->mxUndoEnv->IsListening(*m_pObjShell))
SetObjectShell(nullptr); SetObjectShell(nullptr);
ClearUndoBuffer(); ClearUndoBuffer();
// minimale grenze fuer undos // minimale grenze fuer undos
SetMaxUndoActionCount(1); SetMaxUndoActionCount(1);
m_pImpl->pUndoEnv->release();
} }
SdrPage* FmFormModel::AllocPage(bool bMasterPage) SdrPage* FmFormModel::AllocPage(bool bMasterPage)
...@@ -109,7 +103,7 @@ SdrPage* FmFormModel::AllocPage(bool bMasterPage) ...@@ -109,7 +103,7 @@ SdrPage* FmFormModel::AllocPage(bool bMasterPage)
void FmFormModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos) void FmFormModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
{ {
// hack solange Methode intern // 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); SetObjectShell(m_pObjShell);
SdrModel::InsertPage( pPage, nPos ); SdrModel::InsertPage( pPage, nPos );
...@@ -134,7 +128,7 @@ SdrPage* FmFormModel::RemovePage(sal_uInt16 nPgNum) ...@@ -134,7 +128,7 @@ SdrPage* FmFormModel::RemovePage(sal_uInt16 nPgNum)
{ {
Reference< XNameContainer > xForms( pToBeRemovedPage->GetForms( false ), css::uno::UNO_QUERY ); Reference< XNameContainer > xForms( pToBeRemovedPage->GetForms( false ), css::uno::UNO_QUERY );
if ( xForms.is() ) if ( xForms.is() )
m_pImpl->pUndoEnv->RemoveForms( xForms ); m_pImpl->mxUndoEnv->RemoveForms( xForms );
} }
FmFormPage* pRemovedPage = static_cast<FmFormPage*>(SdrModel::RemovePage(nPgNum)); FmFormPage* pRemovedPage = static_cast<FmFormPage*>(SdrModel::RemovePage(nPgNum));
...@@ -145,7 +139,7 @@ SdrPage* FmFormModel::RemovePage(sal_uInt16 nPgNum) ...@@ -145,7 +139,7 @@ SdrPage* FmFormModel::RemovePage(sal_uInt16 nPgNum)
void FmFormModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos) void FmFormModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
{ {
// hack solange Methode intern // 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); SetObjectShell(m_pObjShell);
SdrModel::InsertMasterPage(pPage, nPos); SdrModel::InsertMasterPage(pPage, nPos);
...@@ -159,7 +153,7 @@ SdrPage* FmFormModel::RemoveMasterPage(sal_uInt16 nPgNum) ...@@ -159,7 +153,7 @@ SdrPage* FmFormModel::RemoveMasterPage(sal_uInt16 nPgNum)
{ {
Reference< XNameContainer > xForms( pPage->GetForms( false ), css::uno::UNO_QUERY ); Reference< XNameContainer > xForms( pPage->GetForms( false ), css::uno::UNO_QUERY );
if ( xForms.is() ) if ( xForms.is() )
m_pImpl->pUndoEnv->RemoveForms( xForms ); m_pImpl->mxUndoEnv->RemoveForms( xForms );
} }
return pPage; return pPage;
...@@ -222,27 +216,27 @@ void FmFormModel::SetObjectShell( SfxObjectShell* pShell ) ...@@ -222,27 +216,27 @@ void FmFormModel::SetObjectShell( SfxObjectShell* pShell )
if (m_pObjShell) if (m_pObjShell)
{ {
m_pImpl->pUndoEnv->EndListening( *this ); m_pImpl->mxUndoEnv->EndListening( *this );
m_pImpl->pUndoEnv->EndListening( *m_pObjShell ); m_pImpl->mxUndoEnv->EndListening( *m_pObjShell );
} }
m_pObjShell = pShell; m_pObjShell = pShell;
if (m_pObjShell) 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()) if (!m_pImpl->mxUndoEnv->IsReadOnly())
m_pImpl->pUndoEnv->StartListening(*this); m_pImpl->mxUndoEnv->StartListening(*this);
m_pImpl->pUndoEnv->StartListening( *m_pObjShell ); m_pImpl->mxUndoEnv->StartListening( *m_pObjShell );
} }
} }
FmXUndoEnvironment& FmFormModel::GetUndoEnv() FmXUndoEnvironment& FmFormModel::GetUndoEnv()
{ {
return *m_pImpl->pUndoEnv; return *m_pImpl->mxUndoEnv;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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