sw/source/core/layout/wsfrm.cxx | 8 ---- sw/source/core/text/redlnitr.cxx | 70 ++++++++++++++++++++++++++++++++++----- 2 files changed, 62 insertions(+), 16 deletions(-)
New commits: commit 917e8996e4d665f3727a15bbbb02ca5e43cceacc Author: Michael Stahl <[email protected]> AuthorDate: Thu Sep 6 17:54:46 2018 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Thu Sep 6 17:54:46 2018 +0200 sw_redlinehide_2: tweak CheckParaRedlineMerge() next-node flag update If there's a table or section affected by the editing operation, then it has to be ensured that the table node / section node has its flag reset on Undo; also the next text node following the table, as CheckParaRedlineMerge() isn't called for table nodes. Change-Id: Ic1b085619adbeba69fa641a3a7492b71966fee6e diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index 920960d835e1..10c25b074415 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -135,11 +135,43 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode, rTextNode.SetRedlineMergeFlag(SwNode::Merge::None); } } - { - SwNode *const pNextNode(pNode->GetNodes()[pNode->GetIndex() + 1]); - if (!pNextNode->IsCreateFrameWhenHidingRedlines()) + // Reset flag of the following text node since we know it's not merged; + // also any table/sections in between. + // * the following SwTextNode is in same nodes section as pNode (nLevel=0) + // * the start nodes that don't have a SwTextNode before them + // on their level, and their corresponding end nodes + // * the first SwTextNode inside each start node of the previous point + // Other (non-first) SwTextNodes in nested sections shouldn't be reset! + int nLevel(0); + for (sal_uLong j = pNode->GetIndex() + 1; j < pNode->GetNodes().Count(); ++j) + { + SwNode *const pTmp(pNode->GetNodes()[j]); + if (!pTmp->IsCreateFrameWhenHidingRedlines()) { // clear stale flag caused by editing with redlines shown - pNextNode->SetRedlineMergeFlag(SwNode::Merge::None); + pTmp->SetRedlineMergeFlag(SwNode::Merge::None); + } + if (pTmp->IsStartNode()) + { + ++nLevel; + } + else if (pTmp->IsEndNode()) + { + if (nLevel == 0) + { + break; // there is no following text node; avoid leaving section + } + --nLevel; + } + else if (pTmp->IsTextNode()) + { + if (nLevel == 0) + { + break; // done + } + else + { // skip everything other than 1st text node in section! + j = pTmp->EndOfSectionIndex() - 1; // will be incremented again + } } } if (!bHaveRedlines) commit d88a669f2e0ea50bf0bb1b1466a4f113e6d9877b Author: Michael Stahl <[email protected]> AuthorDate: Thu Sep 6 17:51:46 2018 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Thu Sep 6 17:53:58 2018 +0200 sw_redlinehide_2: do all frame deletion in CheckParaRedlineMerge() Other callers need this too, particularly Undo, so move this into the function so it's done once. Change-Id: I58e89899127650157fe2889929c1c6b47c00649b diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index e6fbd7c553dc..aef1673deada 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -4368,14 +4368,6 @@ static void UnHideRedlines(SwRootFrame & rLayout, auto const pFrame(static_cast<SwContentNode&>(rNode).getLayoutFrame(&rLayout)); assert(!pFrame || static_cast<SwTextFrame*>(pFrame)->GetMergedPara()->pFirstNode != &rNode); } - else if (rNode.IsTableNode()) - { - static_cast<SwTableNode&>(rNode).DelFrames(&rLayout); - } - else if (rNode.IsSectionNode()) - { - static_cast<SwSectionNode&>(rNode).DelFrames(&rLayout); - } } else { diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index f63aed9f9e1b..920960d835e1 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -58,6 +58,8 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode, } bool bHaveRedlines(false); std::vector<SwTextNode *> nodes{ &rTextNode }; + std::vector<SwTableNode *> tables; + std::vector<SwSectionNode *> sections; std::vector<sw::Extent> extents; OUStringBuffer mergedText; SwTextNode const* pParaPropsNode(nullptr); @@ -94,6 +96,21 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode, for (sal_uLong j = pNode->GetIndex() + 1; j < pEnd->nNode.GetIndex(); ++j) { SwNode *const pTmp(pNode->GetNodes()[j]); + if (nLevel == 0) + { + if (pTmp->IsTextNode()) + { + nodes.push_back(pTmp->GetTextNode()); + } + else if (pTmp->IsTableNode()) + { + tables.push_back(pTmp->GetTableNode()); + } + else if (pTmp->IsSectionNode()) + { + sections.push_back(pTmp->GetSectionNode()); + } + } if (pTmp->IsStartNode()) { ++nLevel; @@ -102,10 +119,6 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode, { --nLevel; } - else if (nLevel == 0 && pTmp->IsTextNode()) - { - nodes.push_back(pTmp->GetTextNode()); - } pTmp->SetRedlineMergeFlag(SwNode::Merge::Hidden); } pNode = pEnd->nNode.GetNode().GetTextNode(); @@ -180,6 +193,15 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode, { (**iter).DelFrames(rFrame.getRootFrame()); } + // also delete tables & sections here; not necessary, but convenient + for (auto const pTableNode : tables) + { + pTableNode->DelFrames(rFrame.getRootFrame()); + } + for (auto const pSectionNode : sections) + { + pSectionNode->DelFrames(rFrame.getRootFrame()); + } } auto pRet(o3tl::make_unique<sw::MergedPara>(rFrame, std::move(extents), mergedText.makeStringAndClear(), pParaPropsNode, &rTextNode, _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
