From bef9cc01c7da9fd75393bfa1818e07f484306829 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 27 Jan 2015 15:39:00 +0000 Subject: merge these two selection changing hunks of code Change-Id: I4113a38a3a15cd2173f9a2530dc2e7278b8713b2 --- sw/source/ui/fldui/fldedt.cxx | 49 ++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'sw/source/ui') diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx index 8a1eb1eb0690..98f959f24708 100644 --- a/sw/source/ui/fldui/fldedt.cxx +++ b/sw/source/ui/fldui/fldedt.cxx @@ -49,6 +49,28 @@ #include #include +void SwFldEditDlg::EnsureSelection(SwField *pCurFld) +{ + if (pSh->CrsrInsideInputFld()) + { + // move cursor to start of Input Field + SwInputField* pInputFld = dynamic_cast(pCurFld); + if (pInputFld && pInputFld->GetFmtFld()) + { + pSh->GotoField( *(pInputFld->GetFmtFld()) ); + } + } + + /* Only create selection if there is none already. + Normalize PaM instead of swapping. */ + if (!pSh->HasSelection()) + { + //Note that after this, it is possible that rMgr.GetCurFld() != pCurFld + pSh->Right(CRSR_SKIP_CHARS, true, 1, false ); + } + + pSh->NormalizePam(); +} SwFldEditDlg::SwFldEditDlg(SwView& rVw) : SfxSingleTabDialog(&rVw.GetViewFrame()->GetWindow(), 0, @@ -62,28 +84,12 @@ SwFldEditDlg::SwFldEditDlg(SwView& rVw) SwFldMgr aMgr(pSh); SwField *pCurFld = aMgr.GetCurFld(); - if(!pCurFld) + if (!pCurFld) return; SwViewShell::SetCareWin(this); - if ( pSh->CrsrInsideInputFld() ) - { - // move cursor to start of Input Field - SwInputField* pInputFld = dynamic_cast(pCurFld); - if ( pInputFld != NULL - && pInputFld->GetFmtFld() != NULL ) - { - pSh->GotoField( *(pInputFld->GetFmtFld()) ); - } - } - - if ( ! pSh->HasSelection() ) - { - pSh->Right(CRSR_SKIP_CHARS, true, 1, false); - } - - pSh->NormalizePam(); + EnsureSelection(pCurFld); sal_uInt16 nGroup = aMgr.GetGroup(false, pCurFld->GetTypeId(), pCurFld->GetSubType()); @@ -254,12 +260,7 @@ IMPL_LINK( SwFldEditDlg, NextPrevHdl, Button *, pButton ) rMgr.GoNextPrev( bNext, pOldTyp ); pCurFld = rMgr.GetCurFld(); - /* #108536# Only create selection if there is none - already. Normalize PaM instead of swapping. */ - if ( ! pSh->HasSelection() ) - pSh->Right(CRSR_SKIP_CHARS, true, 1, false ); - - pSh->NormalizePam(); + EnsureSelection(pCurFld); sal_uInt16 nGroup = rMgr.GetGroup(false, pCurFld->GetTypeId(), pCurFld->GetSubType()); -- cgit