[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sw/source

Michael Stahl mstahl at redhat.com
Wed Feb 20 05:57:23 PST 2013


 sw/source/ui/docvw/edtwin.cxx |   43 +++++++++++++++++++-----------------------
 sw/source/ui/wrtsh/wrtsh2.cxx |   11 ++++++++--
 2 files changed, 29 insertions(+), 25 deletions(-)

New commits:
commit 7063ea7cc1eadb22ac3ca6c2d54001408b60ef95
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Feb 20 00:08:45 2013 +0100

    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 at free.fr>
    Tested-by: Bosdonnat Cedric <cedric.bosdonnat at free.fr>

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 289aa15..27853a8 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 72d4cbd..86fe158 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 );


More information about the Libreoffice-commits mailing list