Kaydet (Commit) 653a074e authored tarafından Armin Le Grand's avatar Armin Le Grand

#120040# Added C++ style initialisations to all constructors, secured…

#120040# Added C++ style initialisations to all constructors, secured destruction of pImpl, secured all accesses to pImpl if not initialized, asserting if not
üst f3c156fd
...@@ -134,12 +134,19 @@ public: ...@@ -134,12 +134,19 @@ public:
*************************************************************************/ *************************************************************************/
SvBaseLink::SvBaseLink() SvBaseLink::SvBaseLink()
: SvRefBase(),
xObj(),
aLinkName(),
pImpl(new BaseLink_Impl()),
nObjType(OBJECT_CLIENT_SO),
bVisible(sal_True),
bSynchron(sal_True),
bUseCache(sal_True),
bWasLastEditOK(sal_False),
pImplData(new ImplBaseLinkData),
m_bIsReadOnly(false),
m_xInputStreamToLoadFrom()
{ {
pImpl = new BaseLink_Impl();
nObjType = OBJECT_CLIENT_SO;
pImplData = new ImplBaseLinkData;
bVisible = bSynchron = bUseCache = sal_True;
bWasLastEditOK = sal_False;
} }
/************************************************************************ /************************************************************************
...@@ -149,13 +156,19 @@ SvBaseLink::SvBaseLink() ...@@ -149,13 +156,19 @@ SvBaseLink::SvBaseLink()
*************************************************************************/ *************************************************************************/
SvBaseLink::SvBaseLink( sal_uInt16 nUpdateMode, sal_uIntPtr nContentType ) SvBaseLink::SvBaseLink( sal_uInt16 nUpdateMode, sal_uIntPtr nContentType )
: SvRefBase(),
xObj(),
aLinkName(),
pImpl(new BaseLink_Impl()),
nObjType(OBJECT_CLIENT_SO),
bVisible(sal_True),
bSynchron(sal_True),
bUseCache(sal_True),
bWasLastEditOK(sal_False),
pImplData(new ImplBaseLinkData),
m_bIsReadOnly(false),
m_xInputStreamToLoadFrom()
{ {
pImpl = new BaseLink_Impl();
nObjType = OBJECT_CLIENT_SO;
pImplData = new ImplBaseLinkData;
bVisible = bSynchron = bUseCache = sal_True;
bWasLastEditOK = sal_False;
// falls es ein Ole-Link wird, // falls es ein Ole-Link wird,
pImplData->ClientType.nUpdateMode = nUpdateMode; pImplData->ClientType.nUpdateMode = nUpdateMode;
pImplData->ClientType.nCntntType = nContentType; pImplData->ClientType.nCntntType = nContentType;
...@@ -169,13 +182,19 @@ SvBaseLink::SvBaseLink( sal_uInt16 nUpdateMode, sal_uIntPtr nContentType ) ...@@ -169,13 +182,19 @@ SvBaseLink::SvBaseLink( sal_uInt16 nUpdateMode, sal_uIntPtr nContentType )
*************************************************************************/ *************************************************************************/
SvBaseLink::SvBaseLink( const String& rLinkName, sal_uInt16 nObjectType, SvLinkSource* pObj ) SvBaseLink::SvBaseLink( const String& rLinkName, sal_uInt16 nObjectType, SvLinkSource* pObj )
: SvRefBase(),
xObj(),
aLinkName(rLinkName),
pImpl(0),
nObjType(nObjectType),
bVisible(sal_True),
bSynchron(sal_True),
bUseCache(sal_True),
bWasLastEditOK(sal_False),
pImplData(new ImplBaseLinkData),
m_bIsReadOnly(false),
m_xInputStreamToLoadFrom()
{ {
bVisible = bSynchron = bUseCache = sal_True;
bWasLastEditOK = sal_False;
aLinkName = rLinkName;
pImplData = new ImplBaseLinkData;
nObjType = nObjectType;
if( !pObj ) if( !pObj )
{ {
DBG_ASSERT( pObj, "Wo ist mein zu linkendes Object" ); DBG_ASSERT( pObj, "Wo ist mein zu linkendes Object" );
...@@ -223,10 +242,17 @@ SvBaseLink::~SvBaseLink() ...@@ -223,10 +242,17 @@ SvBaseLink::~SvBaseLink()
} }
delete pImplData; delete pImplData;
if(pImpl)
{
delete pImpl;
}
} }
IMPL_LINK( SvBaseLink, EndEditHdl, String*, _pNewName ) IMPL_LINK( SvBaseLink, EndEditHdl, String*, _pNewName )
{ {
if(pImpl)
{
String sNewName; String sNewName;
if ( _pNewName ) if ( _pNewName )
sNewName = *_pNewName; sNewName = *_pNewName;
...@@ -235,6 +261,11 @@ IMPL_LINK( SvBaseLink, EndEditHdl, String*, _pNewName ) ...@@ -235,6 +261,11 @@ IMPL_LINK( SvBaseLink, EndEditHdl, String*, _pNewName )
bWasLastEditOK = ( sNewName.Len() > 0 ); bWasLastEditOK = ( sNewName.Len() > 0 );
if ( pImpl->m_aEndEditLink.IsSet() ) if ( pImpl->m_aEndEditLink.IsSet() )
pImpl->m_aEndEditLink.Call( this ); pImpl->m_aEndEditLink.Call( this );
}
else
{
OSL_ENSURE(false, "No pImpl (!)");
}
return 0; return 0;
} }
...@@ -408,6 +439,8 @@ sal_uInt16 SvBaseLink::GetUpdateMode() const ...@@ -408,6 +439,8 @@ sal_uInt16 SvBaseLink::GetUpdateMode() const
void SvBaseLink::_GetRealObject( sal_Bool bConnect) void SvBaseLink::_GetRealObject( sal_Bool bConnect)
{ {
if(pImpl)
{
if( !pImpl->m_pLinkMgr ) if( !pImpl->m_pLinkMgr )
return; return;
...@@ -432,11 +465,16 @@ void SvBaseLink::_GetRealObject( sal_Bool bConnect) ...@@ -432,11 +465,16 @@ void SvBaseLink::_GetRealObject( sal_Bool bConnect)
xObj = pImpl->m_pLinkMgr->CreateObj( this ); xObj = pImpl->m_pLinkMgr->CreateObj( this );
} }
} }
else if( (OBJECT_CLIENT_SO & nObjType) ) else if( OBJECT_CLIENT_SO & nObjType )
xObj = pImpl->m_pLinkMgr->CreateObj( this ); xObj = pImpl->m_pLinkMgr->CreateObj( this );
if( bConnect && ( !xObj.Is() || !xObj->Connect( this ) ) ) if( bConnect && ( !xObj.Is() || !xObj->Connect( this ) ) )
Disconnect(); Disconnect();
}
else
{
OSL_ENSURE(false, "No pImpl (!)");
}
} }
sal_uIntPtr SvBaseLink::GetContentType() const sal_uIntPtr SvBaseLink::GetContentType() const
...@@ -460,17 +498,34 @@ sal_Bool SvBaseLink::SetContentType( sal_uIntPtr nType ) ...@@ -460,17 +498,34 @@ sal_Bool SvBaseLink::SetContentType( sal_uIntPtr nType )
LinkManager* SvBaseLink::GetLinkManager() LinkManager* SvBaseLink::GetLinkManager()
{ {
if(pImpl)
{
return pImpl->m_pLinkMgr; return pImpl->m_pLinkMgr;
}
return 0;
} }
const LinkManager* SvBaseLink::GetLinkManager() const const LinkManager* SvBaseLink::GetLinkManager() const
{ {
if(pImpl)
{
return pImpl->m_pLinkMgr; return pImpl->m_pLinkMgr;
}
return 0;
} }
void SvBaseLink::SetLinkManager( LinkManager* _pMgr ) void SvBaseLink::SetLinkManager( LinkManager* _pMgr )
{ {
if(pImpl)
{
pImpl->m_pLinkMgr = _pMgr; pImpl->m_pLinkMgr = _pMgr;
}
else
{
OSL_ENSURE(false, "No pImpl (!)");
}
} }
void SvBaseLink::Disconnect() void SvBaseLink::Disconnect()
...@@ -496,6 +551,8 @@ void SvBaseLink::DataChanged( const String &, const ::com::sun::star::uno::Any & ...@@ -496,6 +551,8 @@ void SvBaseLink::DataChanged( const String &, const ::com::sun::star::uno::Any &
void SvBaseLink::Edit( Window* pParent, const Link& rEndEditHdl ) void SvBaseLink::Edit( Window* pParent, const Link& rEndEditHdl )
{ {
if(pImpl)
{
pImpl->m_pParentWin = pParent; pImpl->m_pParentWin = pParent;
pImpl->m_aEndEditLink = rEndEditHdl; pImpl->m_aEndEditLink = rEndEditHdl;
pImpl->m_bIsConnect = ( xObj.Is() != sal_False ); pImpl->m_bIsConnect = ( xObj.Is() != sal_False );
...@@ -530,10 +587,17 @@ void SvBaseLink::Edit( Window* pParent, const Link& rEndEditHdl ) ...@@ -530,10 +587,17 @@ void SvBaseLink::Edit( Window* pParent, const Link& rEndEditHdl )
if ( pImpl->m_aEndEditLink.IsSet() ) if ( pImpl->m_aEndEditLink.IsSet() )
pImpl->m_aEndEditLink.Call( this ); pImpl->m_aEndEditLink.Call( this );
} }
}
else
{
OSL_ENSURE(false, "No pImpl (!)");
}
} }
bool SvBaseLink::ExecuteEdit( const String& _rNewName ) bool SvBaseLink::ExecuteEdit( const String& _rNewName )
{ {
if(pImpl)
{
if( _rNewName.Len() != 0 ) if( _rNewName.Len() != 0 )
{ {
SetLinkSourceName( _rNewName ); SetLinkSourceName( _rNewName );
...@@ -569,6 +633,12 @@ bool SvBaseLink::ExecuteEdit( const String& _rNewName ) ...@@ -569,6 +633,12 @@ bool SvBaseLink::ExecuteEdit( const String& _rNewName )
Disconnect(); Disconnect();
pImpl->m_bIsConnect = false; pImpl->m_bIsConnect = false;
return true; return true;
}
else
{
OSL_ENSURE(false, "No pImpl (!)");
return false;
}
} }
void SvBaseLink::Closed() void SvBaseLink::Closed()
...@@ -580,10 +650,18 @@ void SvBaseLink::Closed() ...@@ -580,10 +650,18 @@ void SvBaseLink::Closed()
FileDialogHelper* SvBaseLink::GetFileDialog( sal_uInt32 nFlags, const String& rFactory ) const FileDialogHelper* SvBaseLink::GetFileDialog( sal_uInt32 nFlags, const String& rFactory ) const
{ {
if(pImpl)
{
if ( pImpl->m_pFileDlg ) if ( pImpl->m_pFileDlg )
delete pImpl->m_pFileDlg; delete pImpl->m_pFileDlg;
pImpl->m_pFileDlg = new FileDialogHelper( nFlags, rFactory ); pImpl->m_pFileDlg = new FileDialogHelper( nFlags, rFactory );
return pImpl->m_pFileDlg; return pImpl->m_pFileDlg;
}
else
{
OSL_ENSURE(false, "No pImpl (!)");
return 0;
}
} }
ImplDdeItem::~ImplDdeItem() ImplDdeItem::~ImplDdeItem()
......
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