summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-11-09 10:33:00 +0100
committerLuboš Luňák <l.lunak@collabora.com>2014-11-09 19:45:23 +0100
commitb21df5a993a3815cf736fe3d2eab73eee646b38e (patch)
tree5c57fb30fe11f3a96da957bdc08a6d248a7e4a4c /sw/source
parent92e00493aed5a9d82d306bbd9a9e76276d1abcea (diff)
do not break encapsulation of SwFmtAnchor::GetCntntAnchor()
Change-Id: I0a320eb990f9a3b6800447a97a84c118239bae96
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx18
-rw-r--r--sw/source/core/frmedt/fefly1.cxx18
-rw-r--r--sw/source/core/frmedt/feshview.cxx17
-rw-r--r--sw/source/core/layout/flycnt.cxx19
-rw-r--r--sw/source/core/txtnode/atrflyin.cxx9
-rw-r--r--sw/source/core/undo/undobj1.cxx2
6 files changed, 46 insertions, 37 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 7a6319b630c4..8b53daf4ce72 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3275,7 +3275,8 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
// #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
@@ -3341,25 +3342,26 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
}
}
// 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 8c104cb8c74f..43ca2eaf0872 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -479,9 +479,10 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, 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:
@@ -501,19 +502,20 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, 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 8fe4b7ccc9ba..18bcf016e03d 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -352,15 +352,15 @@ bool SwFEShell::MoveAnchor( SwMove nDir )
OSL_ENSURE( pOld->IsCntntFrm(), "Wrong anchor, page expected." );
if( SwMove::LEFT == nDir || SwMove::RIGHT == nDir )
{
- SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor();
+ SwPosition pos = *aAnch.GetCntntAnchor();
SwTxtNode* pTxtNd = ((SwTxtFrm*)pOld)->GetTxtNode();
- const sal_Int32 nAct = pPos->nContent.GetIndex();
+ const sal_Int32 nAct = pos.nContent.GetIndex();
if( SwMove::LEFT == nDir )
{
bRet = true;
if( nAct )
{
- pPos->nContent.Assign( pTxtNd, nAct-1 );
+ pos.nContent.Assign( pTxtNd, nAct-1 );
}
else
nDir = SwMove::UP;
@@ -372,11 +372,13 @@ bool SwFEShell::MoveAnchor( SwMove nDir )
if( nAct < nMax )
{
bRet = true;
- pPos->nContent.Assign( pTxtNd, nAct+1 );
+ pos.nContent.Assign( pTxtNd, nAct+1 );
}
else
nDir = SwMove::DOWN;
}
+ if( pos != *aAnch.GetCntntAnchor())
+ aAnch.SetAnchor( &pos );
}
} // no break!
case FLY_AT_PARA:
@@ -388,9 +390,9 @@ bool SwFEShell::MoveAnchor( SwMove 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;
sal_Int32 nTmp = 0;
if( bRet )
{
@@ -398,7 +400,8 @@ bool SwFEShell::MoveAnchor( SwMove nDir )
if( nTmp )
--nTmp;
}
- pPos->nContent.Assign( pTxtNd, nTmp );
+ pos.nContent.Assign( pTxtNd, nTmp );
+ aAnch.SetAnchor( &pos );
bRet = true;
}
else if( SwMove::UP == nDir || SwMove::DOWN == nDir )
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 062633883ccf..b391363f3e60 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -1327,21 +1327,21 @@ 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() )
{
if ( pCnt->GetNode()->GetTxtNode() != NULL )
{
const SwTxtAttr* pTxtInputFld =
- pCnt->GetNode()->GetTxtNode()->GetTxtAttrAt( pPos->nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTxtNode::PARENT );
+ pCnt->GetNode()->GetTxtNode()->GetTxtAttrAt( pos.nContent.GetIndex(), RES_TXTATR_INPUTFIELD, SwTxtNode::PARENT );
if ( pTxtInputFld != NULL )
{
- pPos->nContent = pTxtInputFld->GetStart();
+ pos.nContent = pTxtInputFld->GetStart();
}
}
ResetLastCharRectHeight();
@@ -1352,15 +1352,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 a961b6420779..7dc780e5d64b 100644
--- a/sw/source/core/txtnode/atrflyin.cxx
+++ b/sw/source/core/txtnode/atrflyin.cxx
@@ -115,17 +115,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( false, "CopyFlyFmt: Was fuer ein Anker?" );
}
+ aAnchor.SetAnchor( &pos );
}
SwFrmFmt* pNew = pDoc->getIDocumentLayoutAccess().CopyLayoutFmt( *pFmt, aAnchor, false, false );
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 572cd1657602..13a0c12400ac 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -593,7 +593,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 );