diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-08-23 07:01:44 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-08-23 07:01:44 +0000 |
commit | f830588605badb9c1b2e43567f4de558db7a601c (patch) | |
tree | 342056886f5258c619ff74fd740ac632fc70905c /sw/source | |
parent | 73c220b6e14dc07ce10076818634be2d3dc8d32b (diff) |
INTEGRATION: CWS swdrawobjapi (1.27.50); FILE MERGED
2004/08/12 07:04:16 od 1.27.50.2: RESYNC: (1.27-1.29); FILE MERGED
2004/08/06 04:46:36 od 1.27.50.1: #i31698# - adjustments for changed drawing object API in Writer
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 157 |
1 files changed, 89 insertions, 68 deletions
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 29790c120584..994bfb0ed477 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dcontact.cxx,v $ * - * $Revision: 1.30 $ + * $Revision: 1.31 $ * - * last change: $Author: obo $ $Date: 2004-08-12 12:37:03 $ + * last change: $Author: rt $ $Date: 2004-08-23 08:01:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1202,94 +1202,115 @@ void SwDrawContact::_Changed( const SdrObject& rObj, case SDRUSERCALL_CHILD_INSERTED : case SDRUSERCALL_CHILD_REMOVED : { - const Rectangle& aOldObjRect = - static_cast<const SwAnchoredDrawObject*>( - GetAnchoredObj( &rObj ))->GetLastObjRect(); + // --> OD 2004-08-04 #i31698# - improvement: + // get instance <SwAnchoredDrawObject> only once + const SwAnchoredDrawObject* pAnchoredDrawObj = + static_cast<const SwAnchoredDrawObject*>( GetAnchoredObj( &rObj ) ); + // <-- + const Rectangle& aOldObjRect = pAnchoredDrawObj->GetLastObjRect(); // OD 2004-04-06 #i26791# - adjust positioning and alignment attributes, // if positioning of drawing object isn't in progress. - if ( !GetAnchoredObj( &rObj )->IsPositioningInProgress() ) + if ( !pAnchoredDrawObj->IsPositioningInProgress() ) { - const SwFrm* pAnchorFrm = GetAnchorFrm( &rObj ); - if ( pAnchorFrm ) + // --> OD 2004-08-04 #i31698# - determine layout direction + // via draw frame format. + SwFrmFmt::tLayoutDir eLayoutDir = + pAnchoredDrawObj->GetFrmFmt().GetLayoutDir(); + // <-- + // use geometry of drawing object + SwRect aObjRect( rObj.GetSnapRect() ); + // If drawing object is a member of a group, the adjustment + // of the positioning and the alignment attributes has to + // be done for the top group object. + if ( rObj.GetUpGroup() ) { - const bool bVert = pAnchorFrm->IsVertical(); - const bool bR2L = pAnchorFrm->IsRightToLeft(); - // use geometry of drawing object - SwRect aObjRect( rObj.GetSnapRect() ); - // If drawing object is a member of a group, the adjustment - // of the positioning and the alignment attributes has to - // be done for the top group object. - if ( rObj.GetUpGroup() ) + const SdrObject* pGroupObj = rObj.GetUpGroup(); + while ( pGroupObj->GetUpGroup() ) { - const SdrObject* pGroupObj = rObj.GetUpGroup(); - while ( pGroupObj->GetUpGroup() ) - { - pGroupObj = pGroupObj->GetUpGroup(); - } - // use geometry of drawing object - aObjRect = pGroupObj->GetSnapRect(); + pGroupObj = pGroupObj->GetUpGroup(); } - SwTwips nXPosDiff(0L); - SwTwips nYPosDiff(0L); - if ( bVert ) + // use geometry of drawing object + aObjRect = pGroupObj->GetSnapRect(); + } + SwTwips nXPosDiff(0L); + SwTwips nYPosDiff(0L); + switch ( eLayoutDir ) + { + case SwFrmFmt::HORI_L2R: { - nXPosDiff = aObjRect.Top() - aOldObjRect.Top(); - nYPosDiff = aOldObjRect.Right() - aObjRect.Right(); + nXPosDiff = aObjRect.Left() - aOldObjRect.Left(); + nYPosDiff = aObjRect.Top() - aOldObjRect.Top(); } - else if ( bR2L ) + break; + case SwFrmFmt::HORI_R2L: { nXPosDiff = aOldObjRect.Right() - aObjRect.Right(); nYPosDiff = aObjRect.Top() - aOldObjRect.Top(); } - else + break; + case SwFrmFmt::VERT_R2L: { - nXPosDiff = aObjRect.Left() - aOldObjRect.Left(); - nYPosDiff = aObjRect.Top() - aOldObjRect.Top(); + nXPosDiff = aObjRect.Top() - aOldObjRect.Top(); + nYPosDiff = aOldObjRect.Right() - aObjRect.Right(); } - SfxItemSet aSet( GetFmt()->GetDoc()->GetAttrPool(), - RES_VERT_ORIENT, RES_HORI_ORIENT, 0 ); - const SwFmtVertOrient& rVert = GetFmt()->GetVertOrient(); - if ( nYPosDiff != 0 ) + break; + default: { - - if ( rVert.GetRelationOrient() == REL_CHAR || - rVert.GetRelationOrient() == REL_VERT_LINE ) - { - nYPosDiff = -nYPosDiff; - } - aSet.Put( SwFmtVertOrient( rVert.GetPos()+nYPosDiff, - VERT_NONE, - rVert.GetRelationOrient() ) ); + ASSERT( false, + "<SwDrawContact::_Changed(..)> - unsupported layout direction" ); } + } + SfxItemSet aSet( GetFmt()->GetDoc()->GetAttrPool(), + RES_VERT_ORIENT, RES_HORI_ORIENT, 0 ); + const SwFmtVertOrient& rVert = GetFmt()->GetVertOrient(); + if ( nYPosDiff != 0 ) + { - const SwFmtHoriOrient& rHori = GetFmt()->GetHoriOrient(); - if ( !ObjAnchoredAsChar() && nXPosDiff != 0 ) + if ( rVert.GetRelationOrient() == REL_CHAR || + rVert.GetRelationOrient() == REL_VERT_LINE ) { - aSet.Put( SwFmtHoriOrient( rHori.GetPos()+nXPosDiff, - HORI_NONE, - rHori.GetRelationOrient() ) ); + nYPosDiff = -nYPosDiff; } + // --> OD 2004-08-04 #i31698# - don't change orientation, + // if drawing object isn't yet attached to a anchor frame + SwVertOrient eVertOrient( + pAnchoredDrawObj->NotYetAttachedToAnchorFrm() + ? rVert.GetVertOrient() + : VERT_NONE ); + // <-- + aSet.Put( SwFmtVertOrient( rVert.GetPos()+nYPosDiff, + eVertOrient, + rVert.GetRelationOrient() ) ); + } - if ( nYPosDiff || - ( !ObjAnchoredAsChar() && nXPosDiff != 0 ) ) - { - GetFmt()->GetDoc()->SetFlyFrmAttr( *(GetFmt()), aSet ); - // keep new object rectangle, to avoid multiple - // changes of the attributes by multiple event from - // the drawing layer - e.g. group objects and its members - static_cast<SwAnchoredDrawObject*>( - GetAnchoredObj( &(const_cast<SdrObject&>(rObj) ))) - ->LastObjRect() = aObjRect.SVRect(); - } - else if ( aObjRect.SSize() != aOldObjRect.GetSize() ) - { - _InvalidateObjs(); - } + const SwFmtHoriOrient& rHori = GetFmt()->GetHoriOrient(); + if ( !ObjAnchoredAsChar() && nXPosDiff != 0 ) + { + // --> OD 2004-08-04 #i31698# - don't change orientation, + // if drawing object isn't yet attached to a anchor frame + SwHoriOrient eHoriOrient( + pAnchoredDrawObj->NotYetAttachedToAnchorFrm() + ? rHori.GetHoriOrient() + : HORI_NONE ); + // <-- + aSet.Put( SwFmtHoriOrient( rHori.GetPos()+nXPosDiff, + eHoriOrient, + rHori.GetRelationOrient() ) ); } - else + + if ( nYPosDiff || + ( !ObjAnchoredAsChar() && nXPosDiff != 0 ) ) + { + GetFmt()->GetDoc()->SetFlyFrmAttr( *(GetFmt()), aSet ); + // keep new object rectangle, to avoid multiple + // changes of the attributes by multiple event from + // the drawing layer - e.g. group objects and its members + const_cast<SwAnchoredDrawObject*>(pAnchoredDrawObj) + ->LastObjRect() = aObjRect.SVRect(); + } + else if ( aObjRect.SSize() != aOldObjRect.GetSize() ) { - static_cast<SwAnchoredDrawObject*>( - GetAnchoredObj( GetMaster() ))->SetPositioningAttr(); + _InvalidateObjs(); } } if ( bNotify ) |