FieldSelection extends Selection { @Override public void cut() throws InvalidNavigationException { textSelection.cut(); } FieldSelection(TextSelection selection); Field replaceWithSimpleField(Field.FieldType fieldType); void replaceWithReferenceField(ReferenceField field, ReferenceField.DisplayType type); void replaceWithVariableField(VariableField field); ConditionField replaceWithConditionField(String condition, String trueText, String falseText); ConditionField replaceWithHiddenTextField(String condition, String text); void applyStyle(OdfStyleBase style); @Override void cut(); void replaceWith(String newText); @Override void pasteAtEndOf(Selection positionItem); @Override void pasteAtFrontOf(Selection positionItem);  }
@Test public void testCut() throws Exception{ try { search = new TextNavigation("ReplaceDateTarget", doc); while (search.hasNext()) { TextSelection item = (TextSelection) search.nextSelection(); FieldSelection fieldSelection = new FieldSelection(item); fieldSelection.cut(); } doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE)); TextDocument doc1 = (TextDocument) Document.loadDocument(ResourceUtilities.getAbsolutePath(SAVE_FILE_REPLACE)); TextNavigation searchafter = new TextNavigation("ReplaceDateTarget", doc1); if (searchafter.hasNext()) { Assert.fail(); } } catch (Exception e) { Logger.getLogger(FieldSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e); Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'"); } }