summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-10-02 05:20:38 -0400
committerAshod Nakashian <ashnakash@gmail.com>2019-12-26 04:34:15 +0100
commit412eaa9d66157e1da71580a245e1693143e6de34 (patch)
tree9c7ac866646b811730bb1a756b0de08dde8bf5ed
parentcdc3145021bf873f07105d2daef35c9feb446477 (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> (cherry picked from commit 25446d1c7d021ba99201f36b04d59c29c85b7733) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85805 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-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 a29313d6e181..74323492d538 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 bfbb4fa62f1c..ccc5028eb311 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -1811,16 +1811,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.
@@ -1829,12 +1826,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 619e99efa1b5..c83c5f5dfc55 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1540,7 +1540,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)