[Libreoffice-commits] .: Branch 'libreoffice-4-0' - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jan 31 01:24:24 PST 2013
sw/source/ui/docvw/edtwin.cxx | 58 ++++++++++++++++++++++++++++++------------
1 file changed, 42 insertions(+), 16 deletions(-)
New commits:
commit afab7f25d20936a93b9d075aadbfcbaff9df8f9e
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Jan 30 00:45:44 2013 +0100
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 at suse.cz>
Tested-by: Miklos Vajna <vmiklos at suse.cz>
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index af64e0f..289aa15 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 );
More information about the Libreoffice-commits
mailing list