diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-20 00:08:45 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-02-20 00:48:42 +0100 |
commit | a4a457100a3a6e9f59113e82c9d0b12786273671 (patch) | |
tree | 6f04eb8894575d61ef982d902a981b730cae814d | |
parent | 8c40ccb9f603d3062cdfd8e31453c86efdea1ac9 (diff) |
fdo#59928: sw: fix mouse selection of fields differently
Unfortunately selecting the field in SwEditWin::MouseButtonDown()
prevents the click field handling code in SwEditWin::MouseButtonUp()
from running. Instead select the field in MouseButtonUp and
SwWrtShell::ClickToField(), which seems to work better.
(regression from 94721b2aec614e0d99504138d484b2ad6cd550c7)
Change-Id: I3d769487b9d5225ffd07b384fbb0ce01e0733be5
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 43 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh2.cxx | 14 |
2 files changed, 29 insertions, 28 deletions
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 818663f34564..61a8c72a4e8c 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -3559,36 +3559,17 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) // Are we clicking on a field? if (rSh.GetContentAtPos(aDocPos, aFieldAtPos)) { - bool bAddMode(false); // AdditionalMode if applicable - if (KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode()) - { - bAddMode = true; - rSh.EnterAddMode(); - } rSh.SetCursor(&aDocPos, bOnlyText); - // Select the field. Unfortunately cursor may be on field + // Unfortunately the cursor may be on field // position or on position after field depending on which // half of the field was clicked on. SwTxtAttr const*const pTxtFld(aFieldAtPos.pFndTxtAttr); if (rSh.GetCurrentShellCursor().GetPoint()->nContent - .GetIndex() == *pTxtFld->GetStart()) - { - rSh.Right( CRSR_SKIP_CHARS, true, 1, false ); - rSh.NormalizePam(); - } - else + .GetIndex() != *pTxtFld->GetStart()) { assert(rSh.GetCurrentShellCursor().GetPoint()->nContent .GetIndex() == (*pTxtFld->GetStart() + 1)); - rSh.Left( CRSR_SKIP_CHARS, true, 1, false ); - } - // it's a bit of a mystery what this is good for? - // in this case we assume it's valid since we just - // selected a field - bValidCrsrPos = true; - if (bAddMode) - { - rSh.LeaveAddMode(); + rSh.Left( CRSR_SKIP_CHARS, false, 1, false ); } // don't go into the !bOverSelect block below - it moves // the cursor @@ -4422,7 +4403,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) if(pApplyTempl) bExecHyperlinks = sal_False; - SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD | + SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_INETATTR | SwContentAtPos::SW_SMARTTAG | SwContentAtPos::SW_FORMCTRL); @@ -4441,7 +4422,23 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) if( SwContentAtPos::SW_FIELD == aCntntAtPos.eCntntAtPos ) { + bool bAddMode(false); + // AdditionalMode if applicable + if (KEY_MOD1 == rMEvt.GetModifier() + && !rSh.IsAddMode()) + { + bAddMode = true; + rSh.EnterAddMode(); + } rSh.ClickToField( *aCntntAtPos.aFnd.pFld ); + // a bit of a mystery what this is good for? + // in this case we assume it's valid since we + // just selected a field + bValidCrsrPos = true; + if (bAddMode) + { + rSh.LeaveAddMode(); + } } else if ( SwContentAtPos::SW_SMARTTAG == aCntntAtPos.eCntntAtPos ) { diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index f24c2165df6e..74d4537c41e2 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -236,6 +236,15 @@ sal_Bool SwWrtShell::UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet void SwWrtShell::ClickToField( const SwField& rFld ) { + // cross reference field must not be selected because it moves the cursor + if (RES_GETREFFLD != rFld.GetTyp()->Which()) + { + StartAllAction(); + Right( CRSR_SKIP_CHARS, true, 1, false ); // Select the field. + NormalizePam(); + EndAllAction(); + } + bIsInClickToEdit = true; switch( rFld.GetTyp()->Which() ) { @@ -257,11 +266,6 @@ void SwWrtShell::ClickToField( const SwField& rFld ) } - StartAllAction(); - Right( CRSR_SKIP_CHARS, true, 0, false ); // Select the field. - NormalizePam(); // Cursor at the beginning of it. - EndAllAction(); - if( nSlotId ) { StartUndo( UNDO_START ); |