summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashodnakashian@yahoo.com>2017-11-03 07:59:32 -0400
committerAshod Nakashian <ashnakash@gmail.com>2017-11-07 06:18:40 +0100
commit8c4b480e85bbafb7b914377a3e279f6982ff9044 (patch)
tree8f381cf5feecd92e725bd3f5f6db1f9b054a7374
parent240bf89a5221664414cfab7ff4d7d1dd35662f1e (diff)
tdf#113619 prevent cores when there is no cursor
Change-Id: I508041b6dca4c4ed5be20d9ff8aa2ae72746e0d7 Reviewed-on: https://gerrit.libreoffice.org/44259 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--sw/source/core/crsr/pam.cxx3
-rw-r--r--sw/source/core/edit/edfcol.cxx58
2 files changed, 35 insertions, 26 deletions
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;