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

Ashod Nakashian ashodnakashian at yahoo.com
Tue Nov 7 05:19:17 UTC 2017


 sw/source/core/crsr/pam.cxx    |    3 +-
 sw/source/core/edit/edfcol.cxx |   58 +++++++++++++++++++++++------------------
 2 files changed, 35 insertions(+), 26 deletions(-)

New commits:
commit 8c4b480e85bbafb7b914377a3e279f6982ff9044
Author: Ashod Nakashian <ashodnakashian at yahoo.com>
Date:   Fri Nov 3 07:59:32 2017 -0400

    tdf#113619 prevent cores when there is no cursor
    
    Change-Id: I508041b6dca4c4ed5be20d9ff8aa2ae72746e0d7
    Reviewed-on: https://gerrit.libreoffice.org/44259
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 2afae847e64b..86aa82e088ce 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -716,7 +716,8 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const
     if (!bRet)
     {
         // Paragraph Signatures and Classification fields are read-only.
-        bRet = pDoc->GetEditShell()->IsCursorInParagraphMetadataField();
+        if (pDoc && pDoc->GetEditShell())
+            bRet = pDoc->GetEditShell()->IsCursorInParagraphMetadataField();
     }
 
     return bRet;
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index f1b2d7c7ec61..1671271a23e6 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -1097,7 +1097,7 @@ void SwEditShell::SetClassification(const OUString& rName, SfxClassificationPoli
 void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationResult> aResults)
 {
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
-    if (!pDocShell)
+    if (!pDocShell || !GetCursor() || !GetCursor()->Start())
         return;
 
     SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
@@ -1242,7 +1242,7 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectParagraphClassificati
     std::vector<svx::ClassificationResult> aResult;
 
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
-    if (!pDocShell)
+    if (!pDocShell || !GetCursor() || !GetCursor()->Start())
         return aResult;
 
     SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
@@ -1642,7 +1642,7 @@ void SwUndoParagraphSigning::Remove()
 void SwEditShell::SignParagraph()
 {
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
-    if (!pDocShell)
+    if (!pDocShell || !GetCursor() || !GetCursor()->Start())
         return;
     const SwPosition* pPosStart = GetCursor()->Start();
     if (!pPosStart)
@@ -1710,7 +1710,7 @@ void SwEditShell::SignParagraph()
 void SwEditShell::ValidateCurrentParagraphSignatures(bool updateDontRemove)
 {
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
-    if (!pDocShell || !IsParagraphSignatureValidationEnabled())
+    if (!pDocShell || !GetCursor() || !GetCursor()->Start() || !IsParagraphSignatureValidationEnabled())
         return;
 
     SwPaM* pPaM = GetCursor();
@@ -1877,33 +1877,41 @@ void SwEditShell::RestoreMetadataFields()
 
 bool SwEditShell::IsCursorInParagraphMetadataField() const
 {
-    SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
-    const sal_uLong index = GetCursor()->Start()->nContent.GetIndex();
-    uno::Reference<text::XTextField> xField = lcl_GetParagraphMetadataFieldAtIndex(GetDoc()->GetDocShell(), pNode, index);
-    return xField.is();
+    if (GetCursor() && GetCursor()->Start())
+    {
+        SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
+        const sal_uLong index = GetCursor()->Start()->nContent.GetIndex();
+        uno::Reference<text::XTextField> xField = lcl_GetParagraphMetadataFieldAtIndex(GetDoc()->GetDocShell(), pNode, index);
+        return xField.is();
+    }
+
+    return false;
 }
 
 bool SwEditShell::RemoveParagraphMetadataFieldAtCursor(const bool bBackspaceNotDel)
 {
-    SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
-    sal_uLong index = GetCursor()->Start()->nContent.GetIndex();
-    uno::Reference<text::XTextField> xField = lcl_GetParagraphMetadataFieldAtIndex(GetDoc()->GetDocShell(), pNode, index);
-    if (!xField.is())
+    if (GetCursor() && GetCursor()->Start())
     {
-        // Try moving the cursor to see if we're _facing_ a metafield or not,
-        // as opposed to being within one.
-        if (bBackspaceNotDel)
-            index--; // Backspace moves left
-        else
-            index++; // Delete moves right
-
-        xField = lcl_GetParagraphMetadataFieldAtIndex(GetDoc()->GetDocShell(), pNode, index);
-    }
+        SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
+        sal_uLong index = GetCursor()->Start()->nContent.GetIndex();
+        uno::Reference<text::XTextField> xField = lcl_GetParagraphMetadataFieldAtIndex(GetDoc()->GetDocShell(), pNode, index);
+        if (!xField.is())
+        {
+            // Try moving the cursor to see if we're _facing_ a metafield or not,
+            // as opposed to being within one.
+            if (bBackspaceNotDel)
+                index--; // Backspace moves left
+            else
+                index++; // Delete moves right
+
+            xField = lcl_GetParagraphMetadataFieldAtIndex(GetDoc()->GetDocShell(), pNode, index);
+        }
 
-    if (xField.is())
-    {
-        lcl_RemoveParagraphMetadataField(xField);
-        return true;
+        if (xField.is())
+        {
+            lcl_RemoveParagraphMetadataField(xField);
+            return true;
+        }
     }
 
     return false;


More information about the Libreoffice-commits mailing list