Span extends Component implements TextHyperlinkContainer { public void removeTextContent() { Paragraph.removeTextContentImpl(getOdfElement()); NodeList nodeList = getOdfElement().getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node; node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String nodename = node.getNodeName(); if (nodename.equals("text:a") && node.hasChildNodes() == false) getOdfElement().removeChild(node); } } } private  Span(TextSpanElement element); static Span getInstanceof(TextSpanElement sElement); static Span newSpan(TextSelection textSelection); DefaultStyleHandler getStyleHandler(); Document getOwnerDocument(); @Override TextSpanElement getOdfElement(); void removeTextContent(); void setTextContent(String content); String getTextContent(); void appendTextContent(String content); void appendTextContent(String content, boolean isStyleInherited); TextHyperlink applyHyperlink(URI linkto); Iterator<TextHyperlink> getHyperlinkIterator(); void removeHyperlinks(); TextHyperlink appendHyperlink(String text, URI linkto);  }
@Test public void testRemoveTextContent() { try { TextDocument doc = TextDocument.newTextDocument(); Iterator<Paragraph> paraA = doc.getParagraphIterator(); while(paraA.hasNext()){ Paragraph pp = paraA.next(); doc.removeParagraph(pp); } doc.addParagraph("This is a test paragraph!"); TextNavigation navigation = new TextNavigation("test", doc); TextSelection sel = (TextSelection) navigation.nextSelection(); Span span = Span.newSpan(sel); span.removeTextContent(); boolean flag = false; Iterator<Paragraph> parai = doc.getParagraphIterator(); while(parai.hasNext()){ Paragraph pp = parai.next(); if("This is a paragraph!".equals(pp.getTextContent())) flag = true; } Assert.assertTrue(flag); doc.save(ResourceUtilities.newTestOutputFile("spantest.odt")); } catch (Exception e) { Logger.getLogger(SpanTest.class.getName()).log(Level.SEVERE, null, e); Assert.fail(); } }