diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-11-09 10:33:00 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-11-14 13:26:57 +0100 |
commit | 0bc4baf73ce11a777195a31c23496960f60f6dfb (patch) | |
tree | cb883fa142aa18c0b641bb3a4d7e4c309e6d0ae9 | |
parent | 0e8534395c3ba0d328a14525d145ff3e75b1457d (diff) |
do not break encapsulation of SwFmtAnchor::GetCntntAnchor()
Conflicts:
sw/source/core/doc/DocumentContentOperationsManager.cxx
sw/source/core/frmedt/fefly1.cxx
sw/source/core/frmedt/feshview.cxx
sw/source/core/layout/flycnt.cxx
sw/source/core/txtnode/atrflyin.cxx
Change-Id: I0a320eb990f9a3b6800447a97a84c118239bae96
-rw-r--r-- | sw/source/core/docnode/ndcopy.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/frmedt/fefly1.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/layout/flycnt.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/txtnode/atrflyin.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/undo/undobj1.cxx | 2 |
6 files changed, 43 insertions, 35 deletions
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index dde2b22ede03..c205d6633c0f 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -1465,7 +1465,8 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, // #i59964# // correct determination of new anchor position SwFmtAnchor aAnchor( *(*it).GetAnchor() ); - SwPosition* pNewPos = (SwPosition*)aAnchor.GetCntntAnchor(); + assert( aAnchor.GetCntntAnchor() != NULL ); + SwPosition newPos = *aAnchor.GetCntntAnchor(); // for at-paragraph and at-character anchored objects the new anchor // position can *not* be determined by the difference of the current // anchor position to the start of the copied range, because not @@ -1531,25 +1532,26 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, } } // apply found anchor text node as new anchor position - pNewPos->nNode = aAnchorNdIdx; + newPos.nNode = aAnchorNdIdx; } else { - long nOffset = pNewPos->nNode.GetIndex() - rRg.aStart.GetIndex(); + long nOffset = newPos.nNode.GetIndex() - rRg.aStart.GetIndex(); SwNodeIndex aIdx( rStartIdx, nOffset ); - pNewPos->nNode = aIdx; + newPos.nNode = aIdx; } // Set the character bound Flys back at the original character if ((FLY_AT_CHAR == aAnchor.GetAnchorId()) && - pNewPos->nNode.GetNode().IsTxtNode() ) + newPos.nNode.GetNode().IsTxtNode() ) { - pNewPos->nContent.Assign( (SwTxtNode*)&pNewPos->nNode.GetNode(), - pNewPos->nContent.GetIndex() ); + newPos.nContent.Assign( (SwTxtNode*)&newPos.nNode.GetNode(), + newPos.nContent.GetIndex() ); } else { - pNewPos->nContent.Assign( 0, 0 ); + newPos.nContent.Assign( 0, 0 ); } + aAnchor.SetAnchor( &newPos ); // Check recursion: copy content in its own frame, then don't copy it. bool bMakeCpy = true; diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 7fc3756b5ec7..1e2f3af01889 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -497,9 +497,10 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) { case FLY_AT_PARA: { - SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); - pPos->nNode = *pTxtFrm->GetNode(); - pPos->nContent.Assign(0,0); + SwPosition pos = *aAnch.GetCntntAnchor(); + pos.nNode = *pTxtFrm->GetNode(); + pos.nContent.Assign(0,0); + aAnch.SetAnchor( &pos ); break; } case FLY_AT_PAGE: @@ -517,19 +518,20 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) } case FLY_AT_CHAR: { - SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); + SwPosition pos = *aAnch.GetCntntAnchor(); Point aTmpPnt( rAbsPos ); - if( pTxtFrm->GetCrsrOfst( pPos, aTmpPnt, NULL ) ) + if( pTxtFrm->GetCrsrOfst( &pos, aTmpPnt, NULL ) ) { SwRect aTmpRect; - pTxtFrm->GetCharRect( aTmpRect, *pPos ); + pTxtFrm->GetCharRect( aTmpRect, pos ); aRet = aTmpRect.Pos(); } else { - pPos->nNode = *pTxtFrm->GetNode(); - pPos->nContent.Assign(0,0); + pos.nNode = *pTxtFrm->GetNode(); + pos.nContent.Assign(0,0); } + aAnch.SetAnchor( &pos ); break; } default: diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 535c67e7a1d6..6a0781671245 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -340,16 +340,16 @@ sal_Bool SwFEShell::MoveAnchor( sal_uInt16 nDir ) OSL_ENSURE( pOld->IsCntntFrm(), "Wrong anchor, page expected." ); if( SW_MOVE_LEFT == nDir || SW_MOVE_RIGHT == nDir ) { - SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); + SwPosition pos = *aAnch.GetCntntAnchor(); SwTxtNode* pTxtNd = ((SwTxtFrm*)pOld)->GetTxtNode(); - xub_StrLen nAct = pPos->nContent.GetIndex(); + xub_StrLen nAct = pos.nContent.GetIndex(); if( SW_MOVE_LEFT == nDir ) { bRet = sal_True; if( nAct ) { --nAct; - pPos->nContent.Assign( pTxtNd, nAct ); + pos.nContent.Assign( pTxtNd, nAct ); } else nDir = SW_MOVE_UP; @@ -362,11 +362,13 @@ sal_Bool SwFEShell::MoveAnchor( sal_uInt16 nDir ) { ++nAct; bRet = sal_True; - pPos->nContent.Assign( pTxtNd, nAct ); + pos.nContent.Assign( pTxtNd, nAct ); } else nDir = SW_MOVE_DOWN; } + if( pos != *aAnch.GetCntntAnchor()) + aAnch.SetAnchor( &pos ); } } // no break! case FLY_AT_PARA: @@ -378,9 +380,9 @@ sal_Bool SwFEShell::MoveAnchor( sal_uInt16 nDir ) pNew = pOld->FindNext(); if( pNew && pNew != pOld && pNew->IsCntntFrm() ) { - SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); + SwPosition pos = *aAnch.GetCntntAnchor(); SwTxtNode* pTxtNd = ((SwTxtFrm*)pNew)->GetTxtNode(); - pPos->nNode = *pTxtNd; + pos.nNode = *pTxtNd; xub_StrLen nTmp = 0; if( bRet ) { @@ -388,7 +390,7 @@ sal_Bool SwFEShell::MoveAnchor( sal_uInt16 nDir ) if( nTmp ) --nTmp; } - pPos->nContent.Assign( pTxtNd, nTmp ); + pos.nContent.Assign( pTxtNd, nTmp ); bRet = sal_True; } else if( SW_MOVE_UP == nDir || SW_MOVE_DOWN == nDir ) diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 32c6f89a9016..613e5e0418ee 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1391,13 +1391,13 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew ) { //Set the anchor attribute according to the new Cnt. SwFmtAnchor aAnch( pFmt->GetAnchor() ); - SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); + SwPosition pos = *aAnch.GetCntntAnchor(); if( IsAutoPos() && pCnt->IsTxtFrm() ) { SwCrsrMoveState eTmpState( MV_SETONLYTEXT ); Point aPt( rNew ); - if( pCnt->GetCrsrOfst( pPos, aPt, &eTmpState ) - && pPos->nNode == *pCnt->GetNode() ) + if( pCnt->GetCrsrOfst( &pos, aPt, &eTmpState ) + && pos.nNode == *pCnt->GetNode() ) { ResetLastCharRectHeight(); if( text::RelOrientation::CHAR == pFmt->GetVertOrient().GetRelationOrient() ) @@ -1407,15 +1407,16 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew ) } else { - pPos->nNode = *pCnt->GetNode(); - pPos->nContent.Assign( pCnt->GetNode(), 0 ); + pos.nNode = *pCnt->GetNode(); + pos.nContent.Assign( pCnt->GetNode(), 0 ); } } else { - pPos->nNode = *pCnt->GetNode(); - pPos->nContent.Assign( pCnt->GetNode(), 0 ); + pos.nNode = *pCnt->GetNode(); + pos.nContent.Assign( pCnt->GetNode(), 0 ); } + aAnch.SetAnchor( &pos ); // handle change of anchor node: // if count of the anchor frame also change, the fly frames have to be diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index a52606fc2ca1..99904ecd1651 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -119,17 +119,18 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) if( !pCNd ) pCNd = pDoc->GetNodes().GoNext( &aIdx ); - SwPosition* pPos = (SwPosition*)aAnchor.GetCntntAnchor(); - pPos->nNode = aIdx; + SwPosition pos = *aAnchor.GetCntntAnchor(); + pos.nNode = aIdx; if (FLY_AS_CHAR == aAnchor.GetAnchorId()) { - pPos->nContent.Assign( pCNd, 0 ); + pos.nContent.Assign( pCNd, 0 ); } else { - pPos->nContent.Assign( 0, 0 ); + pos.nContent.Assign( 0, 0 ); OSL_ENSURE( !this, "CopyFlyFmt: Was fuer ein Anker?" ); } + aAnchor.SetAnchor( &pos ); } SwFrmFmt* pNew = pDoc->CopyLayoutFmt( *pFmt, aAnchor, false, false ); diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index ab3e3f4f86e4..007685dc3ef5 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -589,7 +589,7 @@ void SwUndoSetFlyFmt::UndoImpl(::sw::UndoRedoContext & rContext) if (FLY_AS_CHAR == aNewAnchor.GetAnchorId()) { - SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor(); + const SwPosition* pPos = aNewAnchor.GetCntntAnchor(); SwFmtFlyCnt aFmt( pFrmFmt ); pPos->nNode.GetNode().GetTxtNode()->InsertItem( aFmt, nOldCntnt, 0 ); |