Kaydet (Commit) 4edc484b authored tarafından Michael Stahl's avatar Michael Stahl

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
üst de551f0f
...@@ -450,13 +450,14 @@ static void InsertCharAttrs(SfxPoolItem const** pAttrs, SfxItemSet const& rItems ...@@ -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 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 // 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, size_t & rStartIndex, size_t & rEndIndex,
bool const isTheAnswerYes) bool const isTheAnswerYes)
{ {
size_t nStartIndex(rStartIndex); size_t nStartIndex(rStartIndex);
size_t nEndIndex(rEndIndex); size_t nEndIndex(rEndIndex);
SwPosition const*const pRLStart(rRedline.Start());
SwPosition const*const pRLEnd(rRedline.End()); SwPosition const*const pRLEnd(rRedline.End());
if (!pRLEnd->nNode.GetNode().IsTextNode() // if fully deleted... if (!pRLEnd->nNode.GetNode().IsTextNode() // if fully deleted...
|| pRLEnd->nContent == pRLEnd->nNode.GetNode().GetTextNode()->Len()) || pRLEnd->nContent == pRLEnd->nNode.GetNode().GetTextNode()->Len())
...@@ -469,17 +470,16 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline, ...@@ -469,17 +470,16 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
// can't compare the SwFont that's stored somewhere, it doesn't have compare // 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 // operator, so try to recreate the situation with some temp arrays here
SfxPoolItem const* activeCharAttrsStart[RES_CHRATR_END - RES_CHRATR_BEGIN + 1] = { nullptr, }; 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 { // nodes' attributes are only needed if there are different nodes
InsertCharAttrs(activeCharAttrsStart, InsertCharAttrs(activeCharAttrsStart, rStartNode.GetSwAttrSet());
pRLStart->nNode.GetNode().GetTextNode()->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 // 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() ? pRLEnd->nContent.GetIndex()
: pRLStart->nNode.GetNode().GetTextNode()->Len()); : rStartNode.Len());
for ( ; nEndIndex < pStartHints->Count(); ++nEndIndex) for ( ; nEndIndex < pStartHints->Count(); ++nEndIndex)
{ {
SwTextAttr *const pAttr(pStartHints->GetSortedByEnd(nEndIndex)); SwTextAttr *const pAttr(pStartHints->GetSortedByEnd(nEndIndex));
...@@ -491,7 +491,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline, ...@@ -491,7 +491,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
{ {
break; break;
} }
if (pRLStart->nContent.GetIndex() <= pAttr->GetStart()) if (nStartRedline <= pAttr->GetStart())
{ {
continue; continue;
} }
...@@ -542,7 +542,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline, ...@@ -542,7 +542,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
pRLEnd->nContent.GetIndex() < *pStartHints->GetSortedByEnd(nEndIndex)->GetAnyEnd()); pRLEnd->nContent.GetIndex() < *pStartHints->GetSortedByEnd(nEndIndex)->GetAnyEnd());
} }
if (pRLStart->nNode != pRLEnd->nNode) if (&rStartNode != &pRLEnd->nNode.GetNode())
{ {
nStartIndex = 0; nStartIndex = 0;
nEndIndex = 0; nEndIndex = 0;
...@@ -554,7 +554,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline, ...@@ -554,7 +554,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
// ... and the charfmt must be *nominally* the same // ... and the charfmt must be *nominally* the same
SfxPoolItem const* activeCharAttrsEnd[RES_CHRATR_END - RES_CHRATR_BEGIN + 1] = { nullptr, }; 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 { // nodes' attributes are only needed if there are different nodes
InsertCharAttrs(activeCharAttrsEnd, InsertCharAttrs(activeCharAttrsEnd,
pRLEnd->nNode.GetNode().GetTextNode()->GetSwAttrSet()); pRLEnd->nNode.GetNode().GetTextNode()->GetSwAttrSet());
...@@ -564,8 +564,8 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline, ...@@ -564,8 +564,8 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
{ {
// check hint starts of hints that start within and end after // check hint starts of hints that start within and end after
#ifndef NDEBUG #ifndef NDEBUG
sal_Int32 const nRedlineStart(pRLStart->nNode == pRLEnd->nNode sal_Int32 const nRedlineStart(&rStartNode == &pRLEnd->nNode.GetNode()
? pRLStart->nContent.GetIndex() ? nStartRedline
: 0); : 0);
#endif #endif
for ( ; nStartIndex < pEndHints->Count(); ++nStartIndex) for ( ; nStartIndex < pEndHints->Count(); ++nStartIndex)
...@@ -629,7 +629,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline, ...@@ -629,7 +629,7 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
default: assert(false); 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 // need to iterate the nEndIndex forward too so the loop in the
// caller can look for the right ends in the next iteration // caller can look for the right ends in the next iteration
...@@ -743,7 +743,7 @@ TextFrameIndex SwAttrIter::GetNextAttr() const ...@@ -743,7 +743,7 @@ TextFrameIndex SwAttrIter::GetNextAttr() const
assert(m_pMergedPara); assert(m_pMergedPara);
assert(redline.second.first->End()->nNode.GetIndex() <= m_pMergedPara->pLastNode->GetIndex() assert(redline.second.first->End()->nNode.GetIndex() <= m_pMergedPara->pLastNode->GetIndex()
|| !redline.second.first->End()->nNode.GetNode().IsTextNode()); || !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)) nStartIndex, nEndIndex, m_nPosition == redline.first))
{ // if current position is start of the redline, must skip! { // if current position is start of the redline, must skip!
nActRedline += redline.second.second; nActRedline += redline.second.second;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment