{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("12AB6789");
inserter.insertRange( new Range(0, 0, text) );
MetaNode met1 = new MetaNode( mkId("id") );
XTextContent xMeta = inserter.makeMeta();
XText xDocText = m_xDoc.getText();
XTextCursor xDocTextCursor = xDocText.createTextCursor();
xDocTextCursor.goRight((short)3, false);
xDocTextCursor.goRight((short)2, true);
xDocText.insertTextContent(xDocTextCursor, xMeta, true);
XMetadatable xMetadatable = (XMetadatable)
UnoRuntime.queryInterface(XMetadatable.class, xMeta);
xMetadatable.setMetadataReference(met1.getXmlId());
XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta);
XTextRange xStart = null;
XTextRange xEnd = null;
{
xStart = xText.getStart();
xEnd = xText.getEnd();
TreeNode nod1 = helper.mkTreeNode();
TreeNode nod2 = helper.mkTreeNode();
XTextContent xContent1 = helper.mkTextContent(inserter, nod1);
XTextContent xContent2 = helper.mkTextContent(inserter, nod2);
// insertTextContent with meta getStart()/getEnd()
xText.insertTextContent(xStart, xContent1, false);
xText.insertTextContent(xEnd , xContent2, false);
helper.postInserted(nod1, xContent1);
helper.postInserted(nod2, xContent2);
TreeNode root = new TreeNode()
.appendChild( new TextNode("12") )
.appendChild( met1.dup()
.appendChild( nod1.dup() )
.appendChild( new TextNode("AB") )
.appendChild( nod2.dup() ) )
.appendChild( new TextNode("6789") );
doTest(root, false);
}
{
xText.setString("AB");
xStart = xText.getStart();
xEnd = xText.getEnd();
TreeNode nod1 = helper.mkTreeNode();
TreeNode nod2 = helper.mkTreeNode();
XTextContent xContent1 = helper.mkTextContent(inserter, nod1);
XTextContent xContent2 = helper.mkTextContent(inserter, nod2);
XTextCursor xTextCursor = xText.createTextCursor();
xTextCursor.gotoStart(false);
// insertTextContent with meta cursor
xText.insertTextContent(xTextCursor, xContent1, false);
xTextCursor.gotoEnd(false);
xText.insertTextContent(xTextCursor, xContent2, false);
helper.postInserted(nod1, xContent1);
helper.postInserted(nod2, xContent2);
TreeNode root = new TreeNode()
.appendChild( new TextNode("12") )
.appendChild( met1.dup()
.appendChild( nod1.dup() )
.appendChild( new TextNode("AB") )
.appendChild( nod2.dup() ) )
.appendChild( new TextNode("6789") );
doTest(root, false);
}
if (!helper.isAttribute())
{
// xText.setString("AB");
xStart = xText.getStart();
xEnd = xText.getEnd();
TreeNode nod1 = helper.mkTreeNode();
TreeNode nod2 = helper.mkTreeNode();
XTextContent xContent1 = helper.mkTextContent(inserter, nod1);
XTextContent xContent2 = helper.mkTextContent(inserter, nod2);
XTextCursor xTextCursor = xText.createTextCursor();
xTextCursor.gotoStart(false);
xTextCursor.goRight((short)1, true);
// insertTextContent with meta cursor and absorb
xText.insertTextContent(xTextCursor, xContent1, true);
xTextCursor.gotoEnd(false);
xTextCursor.goLeft((short)1, true);
xText.insertTextContent(xTextCursor, xContent2, true);
helper.postInserted(nod1, xContent1);
helper.postInserted(nod2, xContent2);
TreeNode root = new TreeNode()
.appendChild( new TextNode("12") )
.appendChild( met1.dup()
.appendChild( nod1.dup() )
.appendChild( new TextNode("AB") )
.appendChild( nod2.dup() ) )
.appendChild( new TextNode("6789") );
doTest(root, false);
}
{
xText.setString("AB");
xStart = xText.getStart();
xEnd = xText.getEnd();
TreeNode nod1 = helper.mkTreeNode();
TreeNode nod2 = helper.mkTreeNode();
XTextContent xContent1 = helper.mkTextContent(inserter, nod1);
XTextContent xContent2 = helper.mkTextContent(inserter, nod2);
xDocTextCursor.gotoRange(xStart, false);
// insertTextContent with document cursor
xText.insertTextContent(xDocTextCursor, xContent1, false);
xDocTextCursor.gotoRange(xEnd, false);
xText.insertTextContent(xDocTextCursor, xContent2, false);
helper.postInserted(nod1, xContent1);
helper.postInserted(nod2, xContent2);
TreeNode root = new TreeNode()
.appendChild( new TextNode("12") )
.appendChild( met1.dup()
.appendChild( nod1.dup() )
.appendChild( new TextNode("AB") )
.appendChild( nod2.dup() ) )
.appendChild( new TextNode("6789") );
doTest(root, false);
}
if (!helper.isAttribute())
{
// xText.setString("AB");
xStart = xText.getStart();
xEnd = xText.getEnd();
TreeNode nod1 = helper.mkTreeNode();
TreeNode nod2 = helper.mkTreeNode();
XTextContent xContent1 = helper.mkTextContent(inserter, nod1);
XTextContent xContent2 = helper.mkTextContent(inserter, nod2);
xDocTextCursor.gotoRange(xStart, false);
xDocTextCursor.goRight((short)1, true);
// insertTextContent with document cursor and absorb
xText.insertTextContent(xDocTextCursor, xContent1, true);
xDocTextCursor.gotoRange(xEnd, false);
xDocTextCursor.goLeft((short)1, true);
xText.insertTextContent(xDocTextCursor, xContent2, true);
helper.postInserted(nod1, xContent1);
helper.postInserted(nod2, xContent2);
TreeNode root = new TreeNode()
.appendChild( new TextNode("12") )
.appendChild( met1.dup()
.appendChild( nod1.dup() )
.appendChild( new TextNode("AB") )
.appendChild( nod2.dup() ) )
.appendChild( new TextNode("6789") );
doTest(root, false);
}
{
xText.setString("AB");
xStart = xText.getStart();
xEnd = xText.getEnd();
TreeNode nod1 = helper.mkTreeNode();
TreeNode nod2 = helper.mkTreeNode();
XTextContent xContent1 = helper.mkTextContent(inserter, nod1);
XTextContent xContent2 = helper.mkTextContent(inserter, nod2);
// attach to range from meta getStart()/getEnd()
xContent1.attach(xStart);
xContent2.attach(xEnd);
helper.postInserted(nod1, xContent1);
helper.postInserted(nod2, xContent2);
TreeNode root = new TreeNode()
.appendChild( new TextNode("12") )
.appendChild( met1.dup()
.appendChild( nod1.dup() )
.appendChild( new TextNode("AB") )
.appendChild( nod2.dup() ) )
.appendChild( new TextNode("6789") );
doTest(root, false);
}
{
xText.setString("AB");
xStart = xText.getStart();
xEnd = xText.getEnd();
TreeNode nod1 = helper.mkTreeNode();
TreeNode nod2 = helper.mkTreeNode();
XTextContent xContent1 = helper.mkTextContent(inserter, nod1);
XTextContent xContent2 = helper.mkTextContent(inserter, nod2);
XTextCursor xTextCursor = xText.createTextCursor();
xTextCursor.gotoStart(false);
// attach to cursor from meta XText
xContent1.attach(xTextCursor);
xTextCursor.gotoEnd(false);
xContent2.attach(xTextCursor);
helper.postInserted(nod1, xContent1);
helper.postInserted(nod2, xContent2);
TreeNode root = new TreeNode()