[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide_4b' - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Dec 18 18:36:24 UTC 2018
sw/source/core/layout/frmtool.cxx | 30 ++++++++++------
sw/source/core/layout/wsfrm.cxx | 70 ++++++++++++++++++++++++++------------
2 files changed, 68 insertions(+), 32 deletions(-)
New commits:
commit 9147b9eac084080f4d37a11545689ae4bfaff71a
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Dec 18 19:19:37 2018 +0100
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Dec 18 19:35:20 2018 +0100
sw_redlinehide_4b: visibility of flys anchored at empty nodes
The new mode would consider a fly anchored at a node that contains the
start or end of a redline but has no visible text displayed to be
hidden, while the old move-code would move it to the merged SwTextNode
and therefore keep it visible.
Change this to give the same result both on layout creation
AppendObjs() and switching AddRemoveFlysAnchoredToFrameStartingAtNode().
Reproduces with ooo108073-2.odt, tdf104735-1.odt
Change-Id: Ibac795dcf7848d78e8a2200124bc2557f35ba434
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 9790d77241d1..429a1066044a 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1161,24 +1161,34 @@ void AppendObjs(const SwFrameFormats *const pTable, sal_uLong const nIndex,
{
std::vector<sw::Extent>::const_iterator iterFirst(pMerged->extents.begin());
std::vector<sw::Extent>::const_iterator iter(iterFirst);
- SwTextNode const* pNode(nullptr);
- for ( ; iter != pMerged->extents.end(); ++iter)
+ SwTextNode const* pNode(pMerged->pFirstNode);
+ for ( ; ; ++iter)
{
- if (iter->pNode != pNode)
+ if (iter == pMerged->extents.end()
+ || iter->pNode != pNode)
{
- if (pNode)
+ AppendObjsOfNode(pTable, pNode->GetIndex(), pFrame, pPage, pDoc, &iterFirst, &iter);
+ sal_uLong const until = iter == pMerged->extents.end()
+ ? pMerged->pLastNode->GetIndex() + 1
+ : iter->pNode->GetIndex();
+ for (sal_uLong i = pNode->GetIndex() + 1; i < until; ++i)
{
- AppendObjsOfNode(pTable, pNode->GetIndex(), pFrame, pPage, pDoc, &iterFirst, &iter);
+ // let's show at-para flys on nodes that contain start/end of
+ // redline too, even if there's no text there
+ SwNode const*const pTmp(pNode->GetNodes()[i]);
+ if (pTmp->GetRedlineMergeFlag() == SwNode::Merge::NonFirst)
+ {
+ AppendObjsOfNode(pTable, pTmp->GetIndex(), pFrame, pPage, pDoc, &iter, &iter);
+ }
+ }
+ if (iter == pMerged->extents.end())
+ {
+ break;
}
pNode = iter->pNode;
iterFirst = iter;
}
}
- if (!pNode)
- { // no extents?
- pNode = pMerged->pFirstNode;
- }
- AppendObjsOfNode(pTable, pNode->GetIndex(), pFrame, pPage, pDoc, &iterFirst, &iter);
}
else
{
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 03997c7b7e81..a5a589bae4a0 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -4157,6 +4157,42 @@ void SwRootFrame::InvalidateAllObjPos()
}
}
+static void AddRemoveFlysForNode(
+ SwTextFrame & rFrame, SwTextNode & rTextNode,
+ std::set<sal_uLong> *const pSkipped,
+ SwFrameFormats & rTable,
+ SwPageFrame *const pPage,
+ SwTextNode const*const pNode,
+ std::vector<sw::Extent>::const_iterator & rIterFirst,
+ std::vector<sw::Extent>::const_iterator const& rIterEnd)
+{
+ if (pNode == &rTextNode)
+ { // remove existing hidden at-char anchored flys
+ RemoveHiddenObjsOfNode(rTextNode, &rIterFirst, &rIterEnd);
+ }
+ else if (rTextNode.GetIndex() < pNode->GetIndex())
+ {
+ // pNode's frame has been deleted by CheckParaRedlineMerge()
+ AppendObjsOfNode(&rTable,
+ pNode->GetIndex(), &rFrame, pPage, rTextNode.GetDoc(),
+ &rIterFirst, &rIterEnd);
+ if (pSkipped)
+ {
+ // if a fly has been added by AppendObjsOfNode, it must be skipped; if not, then it doesn't matter if it's skipped or not because it has no frames and because of that it would be skipped anyway
+ if (auto const pFlys = pNode->GetAnchoredFlys())
+ {
+ for (auto const pFly : *pFlys)
+ {
+ if (pFly->Which() != RES_DRAWFRMFMT)
+ {
+ pSkipped->insert(pFly->GetContent().GetContentIdx()->GetIndex());
+ }
+ }
+ }
+ }
+ }
+}
+
namespace sw {
/// rTextNode is the first one of the "new" merge - if rTextNode isn't the same
@@ -4186,30 +4222,20 @@ void AddRemoveFlysAnchoredToFrameStartingAtNode(
if (iter == pMerged->extents.end()
|| iter->pNode != pNode)
{
- if (pNode == &rTextNode)
- { // remove existing hidden at-char anchored flys
- RemoveHiddenObjsOfNode(
- rTextNode, &iterFirst, &iter);
- }
- else if (rTextNode.GetIndex() < pNode->GetIndex())
+ AddRemoveFlysForNode(rFrame, rTextNode, pSkipped, rTable, pPage,
+ pNode, iterFirst, iter);
+ sal_uLong const until = iter == pMerged->extents.end()
+ ? pMerged->pLastNode->GetIndex() + 1
+ : iter->pNode->GetIndex();
+ for (sal_uLong i = pNode->GetIndex() + 1; i < until; ++i)
{
- // pNode's frame has been deleted by CheckParaRedlineMerge()
- AppendObjsOfNode(&rTable,
- pNode->GetIndex(), &rFrame, pPage, rTextNode.GetDoc(),
- &iterFirst, &iter);
- if (pSkipped)
+ // let's show at-para flys on nodes that contain start/end of
+ // redline too, even if there's no text there
+ SwNode const*const pTmp(pNode->GetNodes()[i]);
+ if (pTmp->GetRedlineMergeFlag() == SwNode::Merge::NonFirst)
{
- // if a fly has been added by AppendObjsOfNode, it must be skipped; if not, then it doesn't matter if it's skipped or not because it has no frames and because of that it would be skipped anyway
- if (auto const pFlys = pNode->GetAnchoredFlys())
- {
- for (auto const pFly : *pFlys)
- {
- if (pFly->Which() != RES_DRAWFRMFMT)
- {
- pSkipped->insert(pFly->GetContent().GetContentIdx()->GetIndex());
- }
- }
- }
+ AddRemoveFlysForNode(rFrame, rTextNode, pSkipped,
+ rTable, pPage, pTmp->GetTextNode(), iter, iter);
}
}
if (iter == pMerged->extents.end())
More information about the Libreoffice-commits
mailing list