summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-01-30 00:45:44 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-01-31 09:24:04 +0000
commitafab7f25d20936a93b9d075aadbfcbaff9df8f9e (patch)
tree91aa5d1a728812b0a38fae65532170fab330226c
parentcad24bc49681e0a765bee01b00825ab02d537705 (diff)
fdo#59928: sw: fix mouse selection of fields:
SwEditWin::MouseButtonDown: the selection of fields was messed up by a call to rSh.SetCursor near the bottom of the method. This used to be fixed up by SwEditWin::MouseButtonUp previously, but that was broken with commit dcb080347ca127044313bbb3c11c37761cc2a7a2. To fix that move the field selection code to a place where it prevents the other code from running, in the hope that it is not necessary. Also it does not make any sense to select whole words when clicking on a field, just selecting the field seems much better. Change-Id: I8d604450789844b6a446cf3a35f62ed530d0328e (cherry picked from commit 94721b2aec614e0d99504138d484b2ad6cd550c7) Reviewed-on: https://gerrit.libreoffice.org/1925 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r--sw/source/ui/docvw/edtwin.cxx58
1 files changed, 42 insertions, 16 deletions
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index af64e0fd8789..289aa158803a 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -131,6 +131,7 @@
#include <IMark.hxx>
#include <doc.hxx>
+#include <txatbase.hxx> // FIXME this sucks
#include <xmloff/odffields.hxx>
#include <PostItMgr.hxx>
@@ -3216,22 +3217,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
if (aVEvt.eEvent == SDREVENT_EXECUTEURL)
bExecDrawTextLink = sal_True;
}
-
- SwContentAtPos aFieldAtPos ( SwContentAtPos::SW_FIELD );
-
- // Are we selecting a field?
- if ( rSh.GetContentAtPos( aDocPos, aFieldAtPos ) )
- {
- // select work, AdditionalMode if applicable
- if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() )
- {
- rSh.EnterAddMode();
- rSh.SelWrd( &aDocPos );
- rSh.LeaveAddMode();
- }
- else
- rSh.SelWrd( &aDocPos );
- }
break;
}
case 2:
@@ -3567,6 +3552,47 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
rSh.ClearGCAttr();
}
+ SwContentAtPos aFieldAtPos(SwContentAtPos::SW_FIELD);
+
+ // 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
+ // 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
+ {
+ 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();
+ }
+ // don't go into the !bOverSelect block below - it moves
+ // the cursor
+ break;
+ }
+
sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
if( !bOverSelect )
bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );