diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-20 00:08:45 +0100 |
---|---|---|
committer | Bosdonnat Cedric <cedric.bosdonnat@free.fr> | 2013-02-20 13:57:04 +0000 |
commit | 7063ea7cc1eadb22ac3ca6c2d54001408b60ef95 (patch) | |
tree | a12ec1df4d2d0a9eb471fb3d60ddcd019596e5b4 | |
parent | 227676cb6378ed90bce62384d3aa9813d30dd997 (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)
Conflicts:
sw/source/ui/wrtsh/wrtsh2.cxx
Change-Id: I3d769487b9d5225ffd07b384fbb0ce01e0733be5
(cherry picked from commit a4a457100a3a6e9f59113e82c9d0b12786273671)
Reviewed-on: https://gerrit.libreoffice.org/2286
Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 43 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh2.cxx | 11 |
2 files changed, 29 insertions, 25 deletions
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 289aa158803a..27853a856a7d 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -3557,36 +3557,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 @@ -4421,7 +4402,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); @@ -4440,7 +4421,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 72d4cbd8324f..86fe1581d7bc 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 = sal_True; switch( rFld.GetTyp()->Which() ) { @@ -257,8 +266,6 @@ void SwWrtShell::ClickToField( const SwField& rFld ) } - Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False ); // Feld selektieren - if( nSlotId ) { StartUndo( UNDO_START ); |