Kaydet (Commit) 9b7542b0 authored tarafından Michael Stahl's avatar Michael Stahl

sw: fix insertion of hyperlink inside hyperlink...

... when either the start or the end position of the new hint is equal
to an existing hint.  There is not just 1 case here but 3 different
ones; don't attempt to insert hints with start > end.

Change-Id: I39cf8a352f67d77b56b0d01de5872f4d341f6bdd
üst 68754260
......@@ -2051,6 +2051,29 @@ public class TextPortionEnumerationTest
// this one gets eaten, but we still need to test inserting it (#i106930#)
// .appendChild( url6.dup().appendChild( new TextNode("") ) )
.appendChild( new TextNode("89") );
// inside (left-edge)
TreeNode url7 = new HyperlinkNode( mkName("url") );
inserter.insertRange( new Range(0, 1, url7) );
root = new TreeNode()
.appendChild( url7.dup().appendChild( new TextNode("1") ) )
.appendChild( url2.dup().appendChild( new TextNode("2") ) )
.appendChild( url1.dup().appendChild( new TextNode("3") ) )
.appendChild( url4.dup().appendChild( new TextNode("4") ) )
.appendChild( url5.dup().appendChild( new TextNode("56") ) )
.appendChild( url4.dup().appendChild( new TextNode("7") ) )
.appendChild( new TextNode("89") );
// inside (right-edge)
TreeNode url8 = new HyperlinkNode( mkName("url") );
inserter.insertRange( new Range(5, 6, url8) );
root = new TreeNode()
.appendChild( url7.dup().appendChild( new TextNode("1") ) )
.appendChild( url2.dup().appendChild( new TextNode("2") ) )
.appendChild( url1.dup().appendChild( new TextNode("3") ) )
.appendChild( url4.dup().appendChild( new TextNode("4") ) )
.appendChild( url5.dup().appendChild( new TextNode("5") ) )
.appendChild( url8.dup().appendChild( new TextNode("6") ) )
.appendChild( url4.dup().appendChild( new TextNode("7") ) )
.appendChild( new TextNode("89") );
doTest(root, false);
}
......
......@@ -550,23 +550,31 @@ SwpHints::TryInsertNesting( SwTxtNode & rNode, SwTxtAttrNesting & rNewHint )
}
else
{
assert((nOtherStart < nNewStart) && (nNewEnd < nOtherEnd));
assert((nOtherStart < nNewStart) || (nNewEnd < nOtherEnd));
// scenario: there is a RUBY, and contained within that a META;
// now a RUBY is inserted within the META => the exising RUBY is split:
// here it is not possible to simply insert the left/right fragment
// of the existing RUBY because they <em>overlap</em> with the META!
Delete( *itOther ); // this also does NoteInHistory!
*(*itOther)->GetEnd() = nNewStart;
bool bSuccess( TryInsertNesting(rNode, **itOther) );
OSL_ENSURE(bSuccess, "recursive call 1 failed?");
SwTxtAttrNesting * const pOtherRight(
MakeTxtAttrNesting(
rNode, **itOther, nNewEnd, nOtherEnd ) );
bSuccess = TryInsertNesting(rNode, *pOtherRight);
OSL_ENSURE(bSuccess, "recursive call 2 failed?");
(void)bSuccess;
if (nNewEnd < nOtherEnd)
{
SwTxtAttrNesting * const pOtherRight(
MakeTxtAttrNesting(
rNode, **itOther, nNewEnd, nOtherEnd ) );
bool const bSuccess( TryInsertNesting(rNode, *pOtherRight) );
SAL_WARN_IF(!bSuccess, "sw.core", "recursive call 1 failed?");
}
if (nOtherStart < nNewStart)
{
*(*itOther)->GetEnd() = nNewStart;
bool const bSuccess( TryInsertNesting(rNode, **itOther) );
SAL_WARN_IF(!bSuccess, "sw.core", "recursive call 2 failed?");
}
else
{
rNode.DestroyAttr(*itOther);
}
}
}
return true;
......
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