diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-03-25 17:33:24 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-03-25 17:33:24 +0100 |
commit | 0527adbab1eca41ae6aeefa6e63c2e02a796c111 (patch) | |
tree | 7e010b157c25b63f38a1999047d3891e6c3b77fc /svx/source/form/fmobj.cxx | |
parent | e71901089adf1ec3d62fef0c6c07559381e5a551 (diff) |
more sensible SdrObject::Clone() and SdrObject::operator=()
Virtual operator=() is IMO pointless, and especially in a class hierarchy
like SdrObject it's pretty unlikely one could reasonably assign any
SdrObject-based object to any other one. Moreover, it was actually
only used in Clone(), which was almost never reimplemented, so the
more sensible choice is to have non-virtual operator= and virtual
Clone() always being reimplemented and using that.
This commit also fixes various smaller or bigger, er, interesting
details in the various operator= implementations.
Diffstat (limited to 'svx/source/form/fmobj.cxx')
-rwxr-xr-x | svx/source/form/fmobj.cxx | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index 87458cc0ef38..c86e492251f1 100755 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -388,16 +388,14 @@ void FmFormObj::clonedFrom(const FmFormObj* _pSource) } //------------------------------------------------------------------ -SdrObject* FmFormObj::Clone() const +FmFormObj* FmFormObj::Clone() const { - SdrObject* pReturn = SdrUnoObj::Clone(); - - FmFormObj* pFormObject = PTR_CAST(FmFormObj, pReturn); + FmFormObj* pFormObject = CloneHelper< FmFormObj >(); DBG_ASSERT(pFormObject != NULL, "FmFormObj::Clone : invalid clone !"); if (pFormObject) pFormObject->clonedFrom(this); - return pReturn; + return pFormObject; } //------------------------------------------------------------------ @@ -408,30 +406,29 @@ void FmFormObj::NbcReformatText() } //------------------------------------------------------------------ -void FmFormObj::operator= (const SdrObject& rObj) +FmFormObj& FmFormObj::operator= (const FmFormObj& rObj) { + if( this == &rObj ) + return *this; SdrUnoObj::operator= (rObj); - FmFormObj* pFormObj = PTR_CAST(FmFormObj, &rObj); - if (pFormObj) + // liegt das UnoControlModel in einer Eventumgebung, + // dann koennen noch Events zugeordnet sein + Reference< XFormComponent > xContent(rObj.xUnoControlModel, UNO_QUERY); + if (xContent.is()) { - // liegt das UnoControlModel in einer Eventumgebung, - // dann koennen noch Events zugeordnet sein - Reference< XFormComponent > xContent(pFormObj->xUnoControlModel, UNO_QUERY); - if (xContent.is()) + Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY); + Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY); + if (xManagerAsIndex.is()) { - Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY); - Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY); - if (xManagerAsIndex.is()) - { - sal_Int32 nPos = getElementPos( xManagerAsIndex, xContent ); - if ( nPos >= 0 ) - aEvts = xManager->getScriptEvents( nPos ); - } + sal_Int32 nPos = getElementPos( xManagerAsIndex, xContent ); + if ( nPos >= 0 ) + aEvts = xManager->getScriptEvents( nPos ); } - else - aEvts = pFormObj->aEvts; } + else + aEvts = rObj.aEvts; + return *this; } //------------------------------------------------------------------ |