diff options
-rw-r--r-- | sw/source/core/crsr/crstrvl.cxx | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 7eb498f1f96a..86ebf8cd034b 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -673,6 +673,8 @@ bool SwCrsrShell::MoveFldType( SwTxtFld * pTxtFld = pTNd->GetFldTxtAttrAt( rPos.nContent.GetIndex(), true ); const bool bDelFld = ( pTxtFld == NULL ); + sal_Int32 nContentOffset = -1; + if( bDelFld ) { // create dummy for the search @@ -683,23 +685,47 @@ bool SwCrsrShell::MoveFldType( mpDoc->IsClipBoard() ); pTxtFld->ChgTxtNode( pTNd ); } + else + { + // the cursor might be anywhere inside the input field, + // but we will be searching for the field start + if (pTxtFld->Which() == RES_TXTATR_INPUTFIELD + && rPos.nContent.GetIndex() != pTxtFld->GetStart()) + nContentOffset = pTxtFld->GetStart(); + } + + _SetGetExpFld *pSrch = NULL; + SwIndex *pIndex = NULL; + if( -1 == nContentOffset ) + { + pSrch = new _SetGetExpFld( rPos.nNode, pTxtFld, &rPos.nContent ); + } + else + { + pIndex = new SwIndex( rPos.nNode.GetNode().GetCntntNode(), nContentOffset ); + pSrch = new _SetGetExpFld( rPos.nNode, pTxtFld, pIndex ); + } - _SetGetExpFld aSrch( rPos.nNode, pTxtFld, &rPos.nContent ); if( rPos.nNode.GetIndex() < mpDoc->GetNodes().GetEndOfExtras().GetIndex() ) { // also at collection use only the first frame Point aPt; - aSrch.SetBodyPos( *pTNd->getLayoutFrm( GetLayout(), &aPt, &rPos, false ) ); + pSrch->SetBodyPos( *pTNd->getLayoutFrm( GetLayout(), &aPt, &rPos, false ) ); } - it = aSrtLst.lower_bound( &aSrch ); + it = aSrtLst.lower_bound( pSrch ); + + bool isSrch = (**it == *pSrch); + delete pIndex; + delete pSrch; + if( bDelFld ) { delete (SwFmtFld*)&pTxtFld->GetAttr(); delete pTxtFld; } - if( it != aSrtLst.end() && **it == aSrch ) // found + if( it != aSrtLst.end() && isSrch ) // found { if( bNext ) { |