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/svdraw/svdotext.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/svdraw/svdotext.cxx')
-rwxr-xr-x | svx/source/svdraw/svdotext.cxx | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 39f1cfa51656..84da2a35173f 100755 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1208,47 +1208,51 @@ void SdrTextObj::TakeObjNamePlural(XubString& rName) const } // switch } -void SdrTextObj::operator=(const SdrObject& rObj) +SdrTextObj* SdrTextObj::Clone() const { + return CloneHelper< SdrTextObj >(); +} + +SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj) +{ + if( this == &rObj ) + return *this; // call parent SdrObject::operator=(rObj); - const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >( &rObj ); - if (pTextObj!=NULL) - { - aRect =pTextObj->aRect; - aGeo =pTextObj->aGeo; - eTextKind =pTextObj->eTextKind; - bTextFrame=pTextObj->bTextFrame; - aTextSize=pTextObj->aTextSize; - bTextSizeDirty=pTextObj->bTextSizeDirty; + aRect =rObj.aRect; + aGeo =rObj.aGeo; + eTextKind =rObj.eTextKind; + bTextFrame=rObj.bTextFrame; + aTextSize=rObj.aTextSize; + bTextSizeDirty=rObj.bTextSizeDirty; - // #101776# Not all of the necessary parameters were copied yet. - bNoShear = pTextObj->bNoShear; - bNoRotate = pTextObj->bNoRotate; - bNoMirror = pTextObj->bNoMirror; - bDisableAutoWidthOnDragging = pTextObj->bDisableAutoWidthOnDragging; + // #101776# Not all of the necessary parameters were copied yet. + bNoShear = rObj.bNoShear; + bNoRotate = rObj.bNoRotate; + bNoMirror = rObj.bNoMirror; + bDisableAutoWidthOnDragging = rObj.bDisableAutoWidthOnDragging; - OutlinerParaObject* pNewOutlinerParaObject = 0; + OutlinerParaObject* pNewOutlinerParaObject = 0; - SdrText* pText = getActiveText(); + SdrText* pText = getActiveText(); - if( pText && pTextObj->HasText() ) + if( pText && rObj.HasText() ) + { + const Outliner* pEO=rObj.pEdtOutl; + if (pEO!=NULL) { - const Outliner* pEO=pTextObj->pEdtOutl; - if (pEO!=NULL) - { - pNewOutlinerParaObject = pEO->CreateParaObject(); - } - else - { - pNewOutlinerParaObject = new OutlinerParaObject(*pTextObj->getActiveText()->GetOutlinerParaObject()); - } + pNewOutlinerParaObject = pEO->CreateParaObject(); + } + else + { + pNewOutlinerParaObject = new OutlinerParaObject(*rObj.getActiveText()->GetOutlinerParaObject()); } - - mpText->SetOutlinerParaObject( pNewOutlinerParaObject ); - ImpSetTextStyleSheetListeners(); } + + mpText->SetOutlinerParaObject( pNewOutlinerParaObject ); + ImpSetTextStyleSheetListeners(); + return *this; } basegfx::B2DPolyPolygon SdrTextObj::TakeXorPoly() const |