summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-04-19 16:05:41 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-04-19 16:05:41 +0200
commit26c6e88ad3779a1a61bb046fc049f0ae9c0df605 (patch)
tree13e4196fca55f3143335c157921fe53cd748c2d0
parent414940e7fbcbcbabd793f053a7849995fe52b8e8 (diff)
bnc#802888, fdo#59928: backport two "mouse selection of fields" fixes from 4.0
94721b2aec614e0d99504138d484b2ad6cd550c7 fdo#59928: sw: fix mouse selection of fields: a4a457100a3a6e9f59113e82c9d0b12786273671 fdo#59928: sw: fix mouse selection of fields differently Change-Id: I2f08c55996c642aeadb93299e4f469d63da1230b
-rw-r--r--sw/source/ui/docvw/edtwin.cxx57
-rw-r--r--sw/source/ui/wrtsh/wrtsh2.cxx11
2 files changed, 49 insertions, 19 deletions
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 814f677d8b30..053bff415775 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -139,6 +139,7 @@
#include <IMark.hxx>
#include <doc.hxx>
+#include <txatbase.hxx> // FIXME this sucks
#include <xmloff/odffields.hxx>
#include <PostItMgr.hxx>
@@ -3107,22 +3108,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:
@@ -3458,6 +3443,28 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
rSh.ClearGCAttr();
}
+ SwContentAtPos aFieldAtPos(SwContentAtPos::SW_FIELD);
+
+ // Are we clicking on a field?
+ if (rSh.GetContentAtPos(aDocPos, aFieldAtPos))
+ {
+ rSh.SetCursor(&aDocPos, bOnlyText);
+ // 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())
+ {
+ assert(rSh.GetCurrentShellCursor().GetPoint()->nContent
+ .GetIndex() == (*pTxtFld->GetStart() + 1));
+ rSh.Left( CRSR_SKIP_CHARS, false, 1, false );
+ }
+ // 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 );
@@ -4288,7 +4295,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);
@@ -4307,7 +4314,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 4d180b549d70..3c2c1ce62967 100644
--- a/sw/source/ui/wrtsh/wrtsh2.cxx
+++ b/sw/source/ui/wrtsh/wrtsh2.cxx
@@ -235,6 +235,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() )
{
@@ -256,8 +265,6 @@ void SwWrtShell::ClickToField( const SwField& rFld )
}
- Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False ); // Feld selektieren
-
if( nSlotId )
{
StartUndo( UNDO_START );