[Libreoffice-commits] core.git: sw/source
Caolán McNamara
caolanm at redhat.com
Wed Jan 28 05:50:06 PST 2015
sw/source/ui/fldui/fldedt.cxx | 65 +++++++++++++++++++++++++---------------
sw/source/uibase/inc/fldedt.hxx | 4 +-
2 files changed, 44 insertions(+), 25 deletions(-)
New commits:
commit d04540a55f533279d2b404223cc625fa251a6ea2
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jan 28 13:10:33 2015 +0000
Resolves: fdo#50640 make sure we don't move away from the current field
by accident by trying to select the entire field if its inside an invisible
area where WrtShell::Right will skip automatically to the next visible area
Change-Id: Iafe9ebd1430db8e6022fec89729d0abb62dad0bb
diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx
index 8a1eb1e..32dd26e 100644
--- a/sw/source/ui/fldui/fldedt.cxx
+++ b/sw/source/ui/fldui/fldedt.cxx
@@ -49,6 +49,44 @@
#include <boost/scoped_ptr.hpp>
#include <swuiexp.hxx>
+void SwFldEditDlg::EnsureSelection(SwField *pCurFld, SwFldMgr &rMgr)
+{
+ 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())
+ {
+ SwShellCrsr* pCrsr = pSh->getShellCrsr(true);
+ SwPosition aOrigPos(*pCrsr->GetPoint());
+
+ //After this attempt it is possible that rMgr.GetCurFld() != pCurFld if
+ //the field was in e.g. a zero height portion and so invisible in which
+ //case it will be skipped over
+ pSh->Right(CRSR_SKIP_CHARS, true, 1, false );
+ //So (fdo#50640) if it didn't work then reposition back to the original
+ //location where the field was
+ SwField *pRealCurFld = rMgr.GetCurFld();
+ bool bSelectionFailed = pCurFld != pRealCurFld;
+ if (bSelectionFailed)
+ {
+ pCrsr->DeleteMark();
+ *pCrsr->GetPoint() = aOrigPos;
+ }
+ }
+
+ pSh->NormalizePam();
+
+ assert(pCurFld == rMgr.GetCurFld());
+}
SwFldEditDlg::SwFldEditDlg(SwView& rVw)
: SfxSingleTabDialog(&rVw.GetViewFrame()->GetWindow(), 0,
@@ -62,28 +100,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, aMgr);
sal_uInt16 nGroup = aMgr.GetGroup(false, pCurFld->GetTypeId(), pCurFld->GetSubType());
@@ -254,12 +276,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, rMgr);
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 0c859e9..26dc320 100644
--- a/sw/source/uibase/inc/fldedt.hxx
+++ b/sw/source/uibase/inc/fldedt.hxx
@@ -23,6 +23,7 @@
class SwView;
class SwWrtShell;
+class SwFldMgr;
class SwFldEditDlg : public SfxSingleTabDialog
{
@@ -37,9 +38,10 @@ class SwFldEditDlg : public SfxSingleTabDialog
void Init();
SfxTabPage* CreatePage(sal_uInt16 nGroup);
+ void EnsureSelection(SwField *pCurFld, SwFldMgr &rMgr);
public:
- SwFldEditDlg(SwView& rVw);
+ SwFldEditDlg(SwView& rVw);
virtual ~SwFldEditDlg();
DECL_LINK(OKHdl, void *);
More information about the Libreoffice-commits
mailing list