Kaydet (Commit) f256fafd authored tarafından Michael Stahl's avatar Michael Stahl

sw: Sw*Contact::GetAnchoredObj() convert to assert and simplify

Change-Id: I0aa18fafd1759cd7c4d2ada18120fa8b97b353a4
üst 68a1a7a0
...@@ -400,21 +400,15 @@ SwFlyDrawContact::~SwFlyDrawContact() ...@@ -400,21 +400,15 @@ SwFlyDrawContact::~SwFlyDrawContact()
} }
// #i26791# // #i26791#
const SwAnchoredObject* SwFlyDrawContact::GetAnchoredObj( const SdrObject* _pSdrObj ) const const SwAnchoredObject* SwFlyDrawContact::GetAnchoredObj(const SdrObject* pSdrObj) const
{ {
OSL_ENSURE( _pSdrObj, assert(pSdrObj);
"<SwFlyDrawContact::GetAnchoredObj(..)> - no object provided" ); assert(dynamic_cast<const SwVirtFlyDrawObj*>(pSdrObj) != nullptr);
OSL_ENSURE( dynamic_cast<const SwVirtFlyDrawObj*>( _pSdrObj) != nullptr, assert(GetUserCall(pSdrObj) == this &&
"<SwFlyDrawContact::GetAnchoredObj(..)> - wrong object type object provided" );
assert(GetUserCall(_pSdrObj) == this &&
"<SwFlyDrawContact::GetAnchoredObj(..)> - provided object doesn't belong to this contact"); "<SwFlyDrawContact::GetAnchoredObj(..)> - provided object doesn't belong to this contact");
const SwAnchoredObject* pRetAnchoredObj = nullptr; const SwAnchoredObject *const pRetAnchoredObj =
static_cast<const SwVirtFlyDrawObj*>(pSdrObj)->GetFlyFrame();
if (const SwVirtFlyDrawObj* pFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>(_pSdrObj))
{
pRetAnchoredObj = pFlyDrawObj->GetFlyFrame();
}
return pRetAnchoredObj; return pRetAnchoredObj;
} }
...@@ -642,35 +636,31 @@ void SwDrawContact::GetTextObjectsFromFormat( std::list<SdrTextObj*>& rTextObjec ...@@ -642,35 +636,31 @@ void SwDrawContact::GetTextObjectsFromFormat( std::list<SdrTextObj*>& rTextObjec
} }
// #i26791# // #i26791#
const SwAnchoredObject* SwDrawContact::GetAnchoredObj( const SdrObject* _pSdrObj ) const const SwAnchoredObject* SwDrawContact::GetAnchoredObj(const SdrObject* pSdrObj ) const
{ {
// handle default parameter value // handle default parameter value
if ( !_pSdrObj ) if (!pSdrObj)
{ {
_pSdrObj = GetMaster(); pSdrObj = GetMaster();
} }
OSL_ENSURE( _pSdrObj, assert(pSdrObj);
"<SwDrawContact::GetAnchoredObj(..)> - no object provided" ); assert(dynamic_cast<const SwDrawVirtObj*>(pSdrObj) != nullptr ||
OSL_ENSURE( dynamic_cast<const SwDrawVirtObj*>( _pSdrObj) != nullptr || dynamic_cast<const SdrVirtObj*>(pSdrObj) == nullptr);
( dynamic_cast<const SdrVirtObj*>( _pSdrObj) == nullptr && dynamic_cast<const SwDrawVirtObj*>( _pSdrObj) == nullptr ), assert((GetUserCall(pSdrObj) == this ||
"<SwDrawContact::GetAnchoredObj(..)> - wrong object type object provided" ); pSdrObj == GetMaster()) &&
OSL_ENSURE( GetUserCall( _pSdrObj ) == this ||
_pSdrObj == GetMaster(),
"<SwDrawContact::GetAnchoredObj(..)> - provided object doesn't belongs to this contact" ); "<SwDrawContact::GetAnchoredObj(..)> - provided object doesn't belongs to this contact" );
const SwAnchoredObject* pRetAnchoredObj = nullptr; const SwAnchoredObject* pRetAnchoredObj = nullptr;
if ( _pSdrObj ) if (dynamic_cast<const SwDrawVirtObj*>(pSdrObj) != nullptr)
{ {
if ( dynamic_cast<const SwDrawVirtObj*>( _pSdrObj) != nullptr ) pRetAnchoredObj = &(static_cast<const SwDrawVirtObj*>(pSdrObj)->GetAnchoredObj());
{ }
pRetAnchoredObj = &(static_cast<const SwDrawVirtObj*>(_pSdrObj)->GetAnchoredObj()); else
} {
else if ( dynamic_cast<const SdrVirtObj*>( _pSdrObj) == nullptr && dynamic_cast<const SwDrawVirtObj*>( _pSdrObj) == nullptr) assert(dynamic_cast<const SdrVirtObj*>(pSdrObj) == nullptr);
{ pRetAnchoredObj = &maAnchoredDrawObj;
pRetAnchoredObj = &maAnchoredDrawObj;
}
} }
return pRetAnchoredObj; return pRetAnchoredObj;
......
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