summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-12-07 13:49:48 +0100
committerMichael Stahl <mstahl@redhat.com>2016-12-07 14:46:08 +0100
commit4cda288e06146416c762dbc82132a1083b86c630 (patch)
tree204304c5035d257946779b7d0b956917ddb44a60 /sw
parent689cead9e0837dc932e3a4cd765f7d319b529018 (diff)
sw: remove some copypasta in SwDrawContact with const_casts
Change-Id: Ib9b1b578cb111ba47e04d844d5afa9984bac89f3
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/draw/dcontact.cxx61
1 files changed, 8 insertions, 53 deletions
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 1ee4787575ea..2dad7eaa258f 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -697,37 +697,9 @@ const SwAnchoredObject* SwDrawContact::GetAnchoredObj( const SdrObject* _pSdrObj
return pRetAnchoredObj;
}
-SwAnchoredObject* SwDrawContact::GetAnchoredObj( SdrObject* _pSdrObj )
+SwAnchoredObject* SwDrawContact::GetAnchoredObj(SdrObject *const pSdrObj)
{
- // handle default parameter value
- if ( !_pSdrObj )
- {
- _pSdrObj = GetMaster();
- }
-
- OSL_ENSURE( _pSdrObj,
- "<SwDrawContact::GetAnchoredObj(..)> - no object provided" );
- OSL_ENSURE( dynamic_cast<const SwDrawVirtObj*>( _pSdrObj) != nullptr ||
- ( dynamic_cast<const SdrVirtObj*>( _pSdrObj) == nullptr && dynamic_cast<const SwDrawVirtObj*>( _pSdrObj) == nullptr),
- "<SwDrawContact::GetAnchoredObj(..)> - wrong object type object provided" );
- OSL_ENSURE( GetUserCall( _pSdrObj ) == this || _pSdrObj == GetMaster(),
- "<SwDrawContact::GetAnchoredObj(..)> - provided object doesn't belongs to this contact" );
-
- SwAnchoredObject* pRetAnchoredObj = nullptr;
-
- if ( _pSdrObj )
- {
- if ( dynamic_cast<const SwDrawVirtObj*>( _pSdrObj) != nullptr )
- {
- pRetAnchoredObj = &(static_cast<SwDrawVirtObj*>(_pSdrObj)->AnchoredObj());
- }
- else if ( dynamic_cast<const SdrVirtObj*>( _pSdrObj) == nullptr && dynamic_cast<const SwDrawVirtObj*>( _pSdrObj) == nullptr)
- {
- pRetAnchoredObj = &maAnchoredDrawObj;
- }
- }
-
- return pRetAnchoredObj;
+ return const_cast<SwAnchoredObject*>(const_cast<SwDrawContact const*>(this)->GetAnchoredObj(pSdrObj));
}
const SdrObject* SwDrawContact::GetMaster() const
@@ -769,39 +741,22 @@ const SwFrame* SwDrawContact::GetAnchorFrame( const SdrObject* _pDrawObj ) const
if ( !_pDrawObj ||
_pDrawObj == GetMaster() ||
( !_pDrawObj->GetUserCall() &&
- GetUserCall( _pDrawObj ) == static_cast<const SwContact* const>(this) ) )
+ GetUserCall( _pDrawObj ) == this ) )
{
pAnchorFrame = maAnchoredDrawObj.GetAnchorFrame();
}
- else if ( dynamic_cast<const SwDrawVirtObj*>( _pDrawObj) != nullptr )
- {
- pAnchorFrame = static_cast<const SwDrawVirtObj*>(_pDrawObj)->GetAnchorFrame();
- }
else
{
- OSL_FAIL( "<SwDrawContact::GetAnchorFrame(..)> - unknown drawing object." );
+ assert(dynamic_cast<SwDrawVirtObj const*>(_pDrawObj) != nullptr);
+ pAnchorFrame = static_cast<const SwDrawVirtObj*>(_pDrawObj)->GetAnchorFrame();
}
return pAnchorFrame;
}
-SwFrame* SwDrawContact::GetAnchorFrame( SdrObject* _pDrawObj )
-{
- SwFrame* pAnchorFrame = nullptr;
- if ( !_pDrawObj ||
- _pDrawObj == GetMaster() ||
- ( !_pDrawObj->GetUserCall() &&
- GetUserCall( _pDrawObj ) == this ) )
- {
- pAnchorFrame = maAnchoredDrawObj.AnchorFrame();
- }
- else
- {
- OSL_ENSURE( dynamic_cast<const SwDrawVirtObj*>( _pDrawObj) != nullptr,
- "<SwDrawContact::GetAnchorFrame(..)> - unknown drawing object." );
- pAnchorFrame = static_cast<SwDrawVirtObj*>(_pDrawObj)->AnchorFrame();
- }
- return pAnchorFrame;
+SwFrame* SwDrawContact::GetAnchorFrame(SdrObject *const pDrawObj)
+{
+ return const_cast<SwFrame *>(const_cast<SwDrawContact const*>(this)->GetAnchorFrame(pDrawObj));
}
/// create a new 'virtual' drawing object.