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

Michael Stahl mstahl at redhat.com
Thu Apr 2 14:59:55 PDT 2015


 sw/source/core/bastyp/index.cxx |    1 +
 sw/source/core/edit/eddel.cxx   |   15 +++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit b24a15a0aaea310806259eaa20a7d509ce30e5c8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Apr 2 23:33:41 2015 +0200

    sw: fix crash on SwUndoDelete after select-all with table at start
    
    Somehow the Redo leaves the shell cursor at an invalid offset into the
    paragraph, which then leads to out-of-bounds string access.
    
    Noticed that SwUndRng::SetPaM() leaves an invalid nContent.m_nIndex on
    the start position, due to a surprising omission in SwIndex::ChgValue().
    
    (regression from 555ff26501d1bbd8a7872c20671c6303db1e1701)
    
    Change-Id: I6e6ad7f70835d7e9d6da1fb680e2ae15469fad71

diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
index d77e2396..dc5041f 100644
--- a/sw/source/core/bastyp/index.cxx
+++ b/sw/source/core/bastyp/index.cxx
@@ -81,6 +81,7 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, sal_Int32 nNewValue )
     assert(m_pIndexReg == rIdx.m_pIndexReg);
     if (!m_pIndexReg)
     {
+        m_nIndex = 0;
         return *this; // no IndexReg => no list to sort into; m_nIndex is 0
     }
     SwIndex* pFnd = const_cast<SwIndex*>(&rIdx);
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 313d079..b5f2db9 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -99,6 +99,7 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
             // Selection starts at the first para of the first cell, but we
             // want to delete the table node before the first cell as well.
             pNewPam->Start()->nNode = pNewPam->Start()->nNode.GetNode().FindTableNode()->GetIndex();
+            pNewPam->Start()->nContent.Assign(nullptr, 0);
             pPam = pNewPam.get();
         }
         // delete everything
commit 41e4998cdeb54a6fc316f349de61296be820fe47
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Apr 2 22:32:59 2015 +0200

    tdf#87400: sw: fix ~SwIndexReg assertion in AutoCorrect
    
    SwAutoFormat::DoUnderline() calls DeleteSel() with a SwPaM that is not
    corrected, except if it's passed along directly to SwDoc methods.
    
    (regression from f9b62506b22c3eb885ffd5a4ec8025c33df7b2d4)
    
    Change-Id: I741e0391e7f8e09a64bcfe99ca4d650f1016aaa7

diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index a700116..313d079 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -90,14 +90,20 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
     }
     else
     {
-        SwPaM aPam(rPam);
+        std::unique_ptr<SwPaM> pNewPam;
+        SwPaM * pPam = &rPam;
         if (bSelectAll)
+        {
+            assert(dynamic_cast<SwShellCrsr*>(&rPam)); // must be corrected pam
+            pNewPam.reset(new SwPaM(rPam));
             // Selection starts at the first para of the first cell, but we
             // want to delete the table node before the first cell as well.
-            aPam.Start()->nNode = aPam.Start()->nNode.GetNode().FindTableNode()->GetIndex();
+            pNewPam->Start()->nNode = pNewPam->Start()->nNode.GetNode().FindTableNode()->GetIndex();
+            pPam = pNewPam.get();
+        }
         // delete everything
-        GetDoc()->getIDocumentContentOperations().DeleteAndJoin( aPam );
-        SaveTblBoxCntnt( aPam.GetPoint() );
+        GetDoc()->getIDocumentContentOperations().DeleteAndJoin(*pPam);
+        SaveTblBoxCntnt( pPam->GetPoint() );
     }
 
     // Selection is not needed anymore


More information about the Libreoffice-commits mailing list