summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-01-30 00:45:44 +0100
committerMichael Stahl <mstahl@redhat.com>2013-01-30 12:26:45 +0100
commit94721b2aec614e0d99504138d484b2ad6cd550c7 (patch)
tree286bbbe9af82fec0368cfd132bed0d22ab39aba2
parent21159c0d092ca269306576171ddcb17c5b51ef5b (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
-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 9b4ec054173a..78c6491f9e67 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>
@@ -3210,22 +3211,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
if (aVEvt.eEvent == SDREVENT_EXECUTEURL)
bExecDrawTextLink = 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:
@@ -3563,6 +3548,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 );