diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-10-02 05:20:38 -0400 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2018-12-03 08:12:23 +0100 |
commit | 6ad096aeeb5c85a82fba70526569f074b67a083c (patch) | |
tree | 47b071d5297e5110f1498d4d75608e8ae2aff18c /sw/source/core/edit/edfcol.cxx | |
parent | 3750d0533e0e00941e5aef92fe5a26b6e7e27734 (diff) |
sw: paragraph-sign: validate current SwTextNode directly
When invoking undo, it turns out that the cursor position
is updated after the text modification, which triggers the
paragraph signature validation. Relying on the cursor
position, then, results in the wrong (previous) paragraph
to be validated (if the undo is in a different paragraph).
Since we have the correct SwTextNode when it's modified
(due to undo or otherwise), there is no reason why
we shouldn't use it and try to deduce it from the cursor.
Change-Id: I4c3283d59738988dcc1c592a9f3ef2c818ce675d
Reviewed-on: https://gerrit.libreoffice.org/63004
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'sw/source/core/edit/edfcol.cxx')
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index b827f9306fc1..f2be581ff73f 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -1804,16 +1804,13 @@ void SwEditShell::SignParagraph() GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::PARA_SIGN_ADD, nullptr); } -void SwEditShell::ValidateCurrentParagraphSignatures(bool updateDontRemove) +void SwEditShell::ValidateParagraphSignatures(SwTextNode* pNode, bool updateDontRemove) { - SwDocShell* pDocShell = GetDoc()->GetDocShell(); - if (!pDocShell || !GetCursor() || !GetCursor()->Start() || !IsParagraphSignatureValidationEnabled()) + if (!pNode || !IsParagraphSignatureValidationEnabled()) return; - SwPaM* pPaM = GetCursor(); - const SwPosition* pPosStart = pPaM->Start(); - SwTextNode* pNode = pPosStart->nNode.GetNode().GetTextNode(); - if (!pNode) + // Table text signing is not supported. + if (pNode->FindTableNode() != nullptr) return; // Prevent recursive validation since this is triggered on node updates, which we do below. @@ -1822,12 +1819,20 @@ void SwEditShell::ValidateCurrentParagraphSignatures(bool updateDontRemove) SetParagraphSignatureValidation(bOldValidationFlag); }); - // Table text signing is not supported. - if (pNode->FindTableNode() != nullptr) + uno::Reference<text::XTextContent> xParentText = SwXParagraph::CreateXParagraph(*GetDoc(), pNode); + lcl_ValidateParagraphSignatures(GetDoc(), xParentText, updateDontRemove); +} + +void SwEditShell::ValidateCurrentParagraphSignatures(bool updateDontRemove) +{ + SwDocShell* pDocShell = GetDoc()->GetDocShell(); + if (!pDocShell || !GetCursor() || !GetCursor()->Start() || !IsParagraphSignatureValidationEnabled()) return; - uno::Reference<text::XTextContent> xParentText = SwXParagraph::CreateXParagraph(*pNode->GetDoc(), pNode); - lcl_ValidateParagraphSignatures(GetDoc(), xParentText, updateDontRemove); + SwPaM* pPaM = GetCursor(); + const SwPosition* pPosStart = pPaM->Start(); + SwTextNode* pNode = pPosStart->nNode.GetNode().GetTextNode(); + ValidateParagraphSignatures(pNode, updateDontRemove); } void SwEditShell::ValidateAllParagraphSignatures(bool updateDontRemove) |