diff options
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/text/frmcrsr.cxx | 48 | ||||
-rw-r--r-- | sw/source/core/text/itrcrsr.cxx | 34 |
2 files changed, 62 insertions, 20 deletions
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx index af3027907865..b82f8403074a 100644 --- a/sw/source/core/text/frmcrsr.cxx +++ b/sw/source/core/text/frmcrsr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: frmcrsr.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: ama $ $Date: 2000-10-20 14:48:04 $ + * last change: $Author: ama $ $Date: 2001-03-15 16:08:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -470,7 +470,6 @@ sal_Bool SwTxtFrm::_GetCrsrOfst(SwPosition* pPos, const Point& rPoint, pFillData->nLineWidth = aLine.GetCurr()->Width(); } } - } } if( pFillData && FindPageFrm()->Frm().IsInside( rPoint ) ) @@ -641,7 +640,14 @@ sal_Bool SwTxtFrm::_UnitUp( SwPaM *pPam, const SwTwips nOffset, aLine.Top(); const SwLineLayout *pPrevLine = aLine.GetPrevLine(); - if( !pPrevLine && GetOfst() && !IsFollow() ) + const xub_StrLen nStart = aLine.GetStart(); + SwRect aCharBox; + aLine.GetCharRect( &aCharBox, nPos ); + + sal_Bool bSecondOfDouble = ( aInf.IsMulti() && ! aInf.IsFirstMulti() ); + sal_Bool bPrevLine = ( pPrevLine && pPrevLine != aLine.GetCurr() ); + + if( !pPrevLine && !bSecondOfDouble && GetOfst() && !IsFollow() ) { nFormat = GetOfst(); xub_StrLen nDiff = aLine.GetLength(); @@ -653,16 +659,20 @@ sal_Bool SwTxtFrm::_UnitUp( SwPaM *pPam, const SwTwips nOffset, nFormat = 0; continue; } - if( pPrevLine && pPrevLine != aLine.GetCurr() ) + + // we select the target line for the cursor, in case we are in a + // double line portion, prev line = curr line + if( bPrevLine && !bSecondOfDouble ) { - const xub_StrLen nStart = aLine.GetStart(); - SwRect aCharBox; - aLine.GetCharRect( &aCharBox, nPos ); aLine.PrevLine(); while ( aLine.GetStart() == nStart && 0 != ( pPrevLine = aLine.GetPrevLine() ) && pPrevLine != aLine.GetCurr() ) aLine.PrevLine(); + } + + if ( bPrevLine || bSecondOfDouble ) + { aCharBox.SSize().Width() /= 2; // siehe Kommentar in SwTxtFrm::GetCrsrOfst() @@ -676,7 +686,7 @@ sal_Bool SwTxtFrm::_UnitUp( SwPaM *pPam, const SwTwips nOffset, "SwTxtFrm::UnitUp: illegal node change" ) // 7684: Wir stellen sicher, dass wir uns nach oben bewegen. - if( nOfst >= nStart && nStart ) + if( nOfst >= nStart && nStart && !bSecondOfDouble ) { // nOfst = nStart - 1; nOfst = nStart; @@ -686,6 +696,7 @@ sal_Bool SwTxtFrm::_UnitUp( SwPaM *pPam, const SwTwips nOffset, SwIndex( ((SwTxtFrm*)this)->GetTxtNode(), nOfst ); return sal_True; } + if ( IsFollow() ) { aLine.GetCharRect( &aCharBox, nPos ); @@ -762,24 +773,31 @@ sal_Bool SwTxtFrm::_UnitDown(SwPaM *pPam, const SwTwips nOffset, nFormat = aLine.GetEnd(); aLine.CharCrsrToLine( nPos ); - if( aLine.GetNextLine() ) + + const SwLineLayout* pNextLine = aLine.GetNextLine(); + const xub_StrLen nStart = aLine.GetStart(); + SwRect aCharBox; + aLine.GetCharRect( &aCharBox, nPos ); + + sal_Bool bFirstOfDouble = ( aInf.IsMulti() && aInf.IsFirstMulti() ); + + if( pNextLine || bFirstOfDouble ) { - const xub_StrLen nStart = aLine.GetStart(); - SwRect aCharBox; - aLine.GetCharRect( &aCharBox, nPos ); - aLine.NextLine(); aCharBox.SSize().Width() /= 2; #ifndef PRODUCT // siehe Kommentar in SwTxtFrm::GetCrsrOfst() const xub_StrLen nOldNode = pPam->pPoint->nNode.GetIndex(); #endif + if ( pNextLine && ! bFirstOfDouble ) + aLine.NextLine(); + xub_StrLen nOfst = aLine.GetCrsrOfst( pPam->pPoint, aCharBox.Pos(), sal_False ); ASSERT( nOldNode == pPam->pPoint->nNode.GetIndex(), "SwTxtFrm::UnitDown: illegal node change" ) // 7684: Wir stellen sicher, dass wir uns nach unten bewegen. - if( nOfst <= nStart ) + if( nOfst <= nStart && ! bFirstOfDouble ) nOfst = nStart + 1; pPam->pPoint->nContent = SwIndex( ((SwTxtFrm*)this)->GetTxtNode(), nOfst ); diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 51fc7a22f9a1..fc9ead019b2f 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: itrcrsr.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: ama $ $Date: 2001-02-06 15:25:28 $ + * last change: $Author: ama $ $Date: 2001-03-15 16:09:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -473,6 +473,11 @@ void SwTxtCursor::_GetCharRect( SwRect* pOrig, const xub_StrLen nOfst, { if( pPor->IsMultiPortion() ) { + // setting this flag indicates that we are in a double line + // portion, important for cursor travelling in these portions + if ( ((SwMultiPortion*)pPor)->IsDouble() ) + GetInfo().SetMulti( sal_True ); + pOrig->Pos().Y() += nTmpAscent - nPorAscent; if( ( ((SwMultiPortion*)pPor)->IsDouble() || ((SwMultiPortion*)pPor)->HasRotation() ) @@ -498,7 +503,7 @@ void SwTxtCursor::_GetCharRect( SwRect* pOrig, const xub_StrLen nOfst, } // In a multi-portion we use GetCharRect()-function - // rekursively and must add the x-position + // recursively and must add the x-position // of the multi-portion. xub_StrLen nOldStart = nStart; BYTE nOldProp = GetPropFont(); @@ -513,6 +518,16 @@ void SwTxtCursor::_GetCharRect( SwRect* pOrig, const xub_StrLen nOfst, Next(); } + // if we are still in the first row of + // our 2 line multiportion, we use the FirstMulti flag + // to indicate this + if ( pCurr == &((SwMultiPortion*)pPor)->GetRoot() ) + { + GetInfo().SetFirstMulti( sal_True ); + if ( !pCurr->GetNext() || !pCurr->GetNext()->GetLen() ) + GetInfo().SetMulti( sal_False ); + } + sal_Bool bSpaceChg = ((SwMultiPortion*)pPor)-> ChgSpaceAdd( pCurr, nSpaceAdd ); Point aOldPos = pOrig->Pos(); @@ -1013,12 +1028,21 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint, if( bLastPortion && (pCurr->GetNext() || pFrm->GetFollow() ) ) --nLength; - if( nWidth > nX ) + if( nWidth > nX || + ( nWidth == nX && pPor->IsMultiPortion() && ((SwMultiPortion*)pPor)->IsDouble() ) ) { if( pPor->IsMultiPortion() ) { - // In a multi-portion we use GetCrsrOfst()-funtion rekursively + // In a multi-portion we use GetCrsrOfst()-function recursively SwTwips nTmpY = rPoint.Y() - pCurr->GetAscent() + pPor->GetAscent(); + // if we are in the first line of a double line portion, we have + // to add a value to nTmpY for not staying in this line + // note: these flags are only set, if this function is called during + // up/down cursor travelling + if ( ((SwTxtSizeInfo*)pInf)->IsMulti() && + ((SwTxtSizeInfo*)pInf)->IsFirstMulti() ) + nTmpY += ((SwMultiPortion*)pPor)->Height(); + SwTxtCursorSave aSave( (SwTxtCursor*)this, (SwMultiPortion*)pPor, nTmpY, nCurrStart, nSpaceAdd ); if( ((SwMultiPortion*)pPor)->HasRotation() ) |