[Libreoffice-commits] core.git: 2 commits - sw/source

Michael Stahl mstahl at redhat.com
Tue Feb 19 15:50:52 PST 2013


 sw/source/core/txtnode/ndtxt.cxx |    3 +-
 sw/source/ui/docvw/edtwin.cxx    |   43 ++++++++++++++++++---------------------
 sw/source/ui/wrtsh/wrtsh2.cxx    |   14 ++++++++----
 3 files changed, 31 insertions(+), 29 deletions(-)

New commits:
commit a4a457100a3a6e9f59113e82c9d0b12786273671
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)
    
    Change-Id: I3d769487b9d5225ffd07b384fbb0ce01e0733be5

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 818663f..61a8c72 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -3559,36 +3559,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
@@ -4422,7 +4403,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);
 
@@ -4441,7 +4422,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 f24c216..74d4537 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 = true;
     switch( rFld.GetTyp()->Which() )
     {
@@ -257,11 +266,6 @@ void SwWrtShell::ClickToField( const SwField& rFld )
 
             }
 
-            StartAllAction();
-            Right( CRSR_SKIP_CHARS, true, 0, false ); // Select the field.
-            NormalizePam();   // Cursor at the beginning of it.
-            EndAllAction();
-
             if( nSlotId )
             {
                 StartUndo( UNDO_START );
commit 8c40ccb9f603d3062cdfd8e31453c86efdea1ac9
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Feb 19 22:08:12 2013 +0100

    SwTxtNode::GetExpandTxt: fix an assertion
    
    Change-Id: Idcca5e38f0cabe1f20e8209a1819660916042f8e

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 1b8b8c3..9866117 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2928,7 +2928,8 @@ XubString SwTxtNode::GetExpandTxt( const xub_StrLen nIdx,
                                    const bool bAddSpaceAfterListLabelStr,
                                    const bool bWithSpacesForLevel ) const
 {
-    XubString aTxt( GetTxt().copy(nIdx, nLen) );
+    XubString aTxt(
+        (STRING_LEN == nLen) ? GetTxt().copy(nIdx) : GetTxt().copy(nIdx, nLen));
     xub_StrLen nTxtStt = nIdx;
     Replace0xFF( aTxt, nTxtStt, aTxt.Len(), sal_True );
     if( bWithNum )


More information about the Libreoffice-commits mailing list