summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-10-02 05:20:38 -0400
committerAshod Nakashian <ashnakash@gmail.com>2018-12-03 08:12:23 +0100
commit6ad096aeeb5c85a82fba70526569f074b67a083c (patch)
tree47b071d5297e5110f1498d4d75608e8ae2aff18c /sw
parent3750d0533e0e00941e5aef92fe5a26b6e7e27734 (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')
-rw-r--r--sw/inc/editsh.hxx5
-rw-r--r--sw/source/core/edit/edfcol.cxx27
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx2
3 files changed, 21 insertions, 13 deletions
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 3da4e3617ca0..6dd4c1ca9a9b 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -366,7 +366,10 @@ public:
/// Sign the paragraph at the cursor.
void SignParagraph();
- /// Validate current paragraph signatures, if any, at the cursor start.
+ /// Validate the paragraph signatures, if any, of the current text node.
+ void ValidateParagraphSignatures(SwTextNode* pNode, bool updateDontRemove);
+
+ /// Validate the current paragraph signatures, if any, at the cursor start.
void ValidateCurrentParagraphSignatures(bool updateDontRemove);
/// Validate all paragraph signatures.
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)
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index ce948ec68c3c..4c756a5466c2 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1541,7 +1541,7 @@ void SwTextNode::Update(
// Update the paragraph signatures.
if (SwEditShell* pEditShell = GetDoc()->GetEditShell())
{
- pEditShell->ValidateCurrentParagraphSignatures(true);
+ pEditShell->ValidateParagraphSignatures(this, true);
}
// Inform LOK clients about change in position of redlines (if any)