diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-01-27 15:39:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-01-27 16:50:55 +0000 |
commit | bef9cc01c7da9fd75393bfa1818e07f484306829 (patch) | |
tree | 78cb13d13b0348a9e6994b286c9e93633cddf451 /sw/source | |
parent | 7daf15884d980a8b848f3bdf9bdaed498dcb7b55 (diff) |
merge these two selection changing hunks of code
Change-Id: I4113a38a3a15cd2173f9a2530dc2e7278b8713b2
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/fldui/fldedt.cxx | 49 | ||||
-rw-r--r-- | sw/source/uibase/inc/fldedt.hxx | 3 |
2 files changed, 27 insertions, 25 deletions
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 <boost/scoped_ptr.hpp> #include <swuiexp.hxx> +void SwFldEditDlg::EnsureSelection(SwField *pCurFld) +{ + if (pSh->CrsrInsideInputFld()) + { + // move cursor to start of Input Field + SwInputField* pInputFld = dynamic_cast<SwInputField*>(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<SwInputField*>(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()); diff --git a/sw/source/uibase/inc/fldedt.hxx b/sw/source/uibase/inc/fldedt.hxx index 0c859e9fd69d..fc8f27d6eaca 100644 --- a/sw/source/uibase/inc/fldedt.hxx +++ b/sw/source/uibase/inc/fldedt.hxx @@ -37,9 +37,10 @@ class SwFldEditDlg : public SfxSingleTabDialog void Init(); SfxTabPage* CreatePage(sal_uInt16 nGroup); + void EnsureSelection(SwField *pCurFld); public: - SwFldEditDlg(SwView& rVw); + SwFldEditDlg(SwView& rVw); virtual ~SwFldEditDlg(); DECL_LINK(OKHdl, void *); |