summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-12-06 18:56:11 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-12-06 19:23:15 +0100
commit062b4762fcb410fe2c624de06975b673545407ab (patch)
tree8115b5a4ef1554b9eea72b781fc5ed47a6b350f4
parent4956318e4eed44f1f13ff1f1a242474fa6e8eb6f (diff)
sw_redlinehide_4b: fix CanSkipOverRedline() using wrong start position
It must use the start position that GetNextRedln() returned, not the start of the end redline that GetNextRedln() returned, obviously. This triggers an assert in CanSkipOverRedline() in ooo31961-27.odt. Change-Id: I40b9647e0b8be9768e49047d309dd22470e658bd
-rw-r--r--sw/source/core/text/itratr.cxx30
1 files changed, 15 insertions, 15 deletions
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 8a3afaf5419c..298214fc9ea2 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -450,13 +450,14 @@ static void InsertCharAttrs(SfxPoolItem const** pAttrs, SfxItemSet const& rItems
// if return false: portion ends at start of redline, indexes unchanged
// if return true: portion end not known (past end of redline), indexes point to first hint past end of redline
-static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
+static bool CanSkipOverRedline(
+ SwTextNode const& rStartNode, sal_Int32 const nStartRedline,
+ SwRangeRedline const& rRedline,
size_t & rStartIndex, size_t & rEndIndex,
bool const isTheAnswerYes)
{
size_t nStartIndex(rStartIndex);
size_t nEndIndex(rEndIndex);
- SwPosition const*const pRLStart(rRedline.Start());
SwPosition const*const pRLEnd(rRedline.End());
if (!pRLEnd->nNode.GetNode().IsTextNode() // if fully deleted...
|| pRLEnd->nContent == pRLEnd->nNode.GetNode().GetTextNode()->Len())
@@ -469,17 +470,16 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
// can't compare the SwFont that's stored somewhere, it doesn't have compare
// operator, so try to recreate the situation with some temp arrays here
SfxPoolItem const* activeCharAttrsStart[RES_CHRATR_END - RES_CHRATR_BEGIN + 1] = { nullptr, };
- if (pRLStart->nNode != pRLEnd->nNode)
+ if (&rStartNode != &pRLEnd->nNode.GetNode())
{ // nodes' attributes are only needed if there are different nodes
- InsertCharAttrs(activeCharAttrsStart,
- pRLStart->nNode.GetNode().GetTextNode()->GetSwAttrSet());
+ InsertCharAttrs(activeCharAttrsStart, rStartNode.GetSwAttrSet());
}
- if (SwpHints *const pStartHints = pRLStart->nNode.GetNode().GetTextNode()->GetpSwpHints())
+ if (SwpHints const*const pStartHints = rStartNode.GetpSwpHints())
{
// check hint ends of hints that start before and end within
- sal_Int32 const nRedlineEnd(pRLStart->nNode == pRLEnd->nNode
+ sal_Int32 const nRedlineEnd(&rStartNode == &pRLEnd->nNode.GetNode()
? pRLEnd->nContent.GetIndex()
- : pRLStart->nNode.GetNode().GetTextNode()->Len());
+ : rStartNode.Len());
for ( ; nEndIndex < pStartHints->Count(); ++nEndIndex)
{
SwTextAttr *const pAttr(pStartHints->GetSortedByEnd(nEndIndex));
@@ -491,7 +491,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
{
break;
}
- if (pRLStart->nContent.GetIndex() <= pAttr->GetStart())
+ if (nStartRedline <= pAttr->GetStart())
{
continue;
}
@@ -542,7 +542,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
pRLEnd->nContent.GetIndex() < *pStartHints->GetSortedByEnd(nEndIndex)->GetAnyEnd());
}
- if (pRLStart->nNode != pRLEnd->nNode)
+ if (&rStartNode != &pRLEnd->nNode.GetNode())
{
nStartIndex = 0;
nEndIndex = 0;
@@ -554,7 +554,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
// ... and the charfmt must be *nominally* the same
SfxPoolItem const* activeCharAttrsEnd[RES_CHRATR_END - RES_CHRATR_BEGIN + 1] = { nullptr, };
- if (pRLStart->nNode != pRLEnd->nNode)
+ if (&rStartNode != &pRLEnd->nNode.GetNode())
{ // nodes' attributes are only needed if there are different nodes
InsertCharAttrs(activeCharAttrsEnd,
pRLEnd->nNode.GetNode().GetTextNode()->GetSwAttrSet());
@@ -564,8 +564,8 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
{
// check hint starts of hints that start within and end after
#ifndef NDEBUG
- sal_Int32 const nRedlineStart(pRLStart->nNode == pRLEnd->nNode
- ? pRLStart->nContent.GetIndex()
+ sal_Int32 const nRedlineStart(&rStartNode == &pRLEnd->nNode.GetNode()
+ ? nStartRedline
: 0);
#endif
for ( ; nStartIndex < pEndHints->Count(); ++nStartIndex)
@@ -629,7 +629,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
default: assert(false);
}
}
- if (pRLStart->nNode != pRLEnd->nNode)
+ if (&rStartNode != &pRLEnd->nNode.GetNode())
{
// need to iterate the nEndIndex forward too so the loop in the
// caller can look for the right ends in the next iteration
@@ -743,7 +743,7 @@ TextFrameIndex SwAttrIter::GetNextAttr() const
assert(m_pMergedPara);
assert(redline.second.first->End()->nNode.GetIndex() <= m_pMergedPara->pLastNode->GetIndex()
|| !redline.second.first->End()->nNode.GetNode().IsTextNode());
- if (CanSkipOverRedline(*redline.second.first,
+ if (CanSkipOverRedline(*pTextNode, redline.first, *redline.second.first,
nStartIndex, nEndIndex, m_nPosition == redline.first))
{ // if current position is start of the redline, must skip!
nActRedline += redline.second.second;