@Test public void testPasteAtFrontOf() { search = null; search = new TextNavigation("delete", doc); TextSelection sel = null; TextNavigation search1 = new TextNavigation("change", doc); if (search1.hasNext()) { sel = (TextSelection) search1.getCurrentItem(); } int i = 0; while (search.hasNext()) { TextSelection item = (TextSelection) search.getCurrentItem(); i++; try { sel.pasteAtFrontOf(item); } catch (InvalidNavigationException e) { Assert.fail(e.getMessage()); } } int j = 0; search = new TextNavigation("changedelete", doc); while (search.hasNext()) { j++; } Assert.assertTrue(i == j); try { doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_COPYTO)); } catch (Exception e) { Logger.getLogger(TextSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e); Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'"); } }
@Override public void pasteAtFrontOf(Selection positionItem) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } int indexOfNew = 0; OdfElement newElement = positionItem.getElement(); if (positionItem instanceof TextSelection) { indexOfNew = ((TextSelection) positionItem).getIndex(); newElement = ((TextSelection) positionItem).getContainerElement(); } OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument()); mIsInserted = false; insertSpan(textSpan, indexOfNew, newElement); adjustStyle(newElement, textSpan, null); SelectionManager.refreshAfterPasteAtFrontOf(this, positionItem); }
TextSelection extends Selection { @Override public void pasteAtFrontOf(Selection positionItem) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } int indexOfNew = 0; OdfElement newElement = positionItem.getElement(); if (positionItem instanceof TextSelection) { indexOfNew = ((TextSelection) positionItem).getIndex(); newElement = ((TextSelection) positionItem).getContainerElement(); } OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument()); mIsInserted = false; insertSpan(textSpan, indexOfNew, newElement); adjustStyle(newElement, textSpan, null); SelectionManager.refreshAfterPasteAtFrontOf(this, positionItem); } }
TextSelection extends Selection { @Override public void pasteAtFrontOf(Selection positionItem) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } int indexOfNew = 0; OdfElement newElement = positionItem.getElement(); if (positionItem instanceof TextSelection) { indexOfNew = ((TextSelection) positionItem).getIndex(); newElement = ((TextSelection) positionItem).getContainerElement(); } OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument()); mIsInserted = false; insertSpan(textSpan, indexOfNew, newElement); adjustStyle(newElement, textSpan, null); SelectionManager.refreshAfterPasteAtFrontOf(this, positionItem); } TextSelection(String text, OdfElement containerElement, int index); }
TextSelection extends Selection { @Override public void pasteAtFrontOf(Selection positionItem) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } int indexOfNew = 0; OdfElement newElement = positionItem.getElement(); if (positionItem instanceof TextSelection) { indexOfNew = ((TextSelection) positionItem).getIndex(); newElement = ((TextSelection) positionItem).getContainerElement(); } OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument()); mIsInserted = false; insertSpan(textSpan, indexOfNew, newElement); adjustStyle(newElement, textSpan, null); SelectionManager.refreshAfterPasteAtFrontOf(this, positionItem); } TextSelection(String text, OdfElement containerElement, int index); @Override OdfElement getElement(); OdfElement getContainerElement(); @Override int getIndex(); String getText(); @Override void cut(); void applyStyle(OdfStyleBase style); void replaceWith(String newText); @Override void pasteAtFrontOf(Selection positionItem); @Override void pasteAtEndOf(Selection positionItem); void addHref(URL url); @Override String toString(); }
TextSelection extends Selection { @Override public void pasteAtFrontOf(Selection positionItem) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } int indexOfNew = 0; OdfElement newElement = positionItem.getElement(); if (positionItem instanceof TextSelection) { indexOfNew = ((TextSelection) positionItem).getIndex(); newElement = ((TextSelection) positionItem).getContainerElement(); } OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument()); mIsInserted = false; insertSpan(textSpan, indexOfNew, newElement); adjustStyle(newElement, textSpan, null); SelectionManager.refreshAfterPasteAtFrontOf(this, positionItem); } TextSelection(String text, OdfElement containerElement, int index); @Override OdfElement getElement(); OdfElement getContainerElement(); @Override int getIndex(); String getText(); @Override void cut(); void applyStyle(OdfStyleBase style); void replaceWith(String newText); @Override void pasteAtFrontOf(Selection positionItem); @Override void pasteAtEndOf(Selection positionItem); void addHref(URL url); @Override String toString();  }