AbstractFormContainer implements FormContainer { public boolean removeForm(Form form) { if (form == null) return true; OdfElement containerElement = getFormContainerElement(); FormFormElement formElement = form.getOdfElement(); try { containerElement.removeChild(formElement); } catch (DOMException exception) { Logger.getLogger(AbstractFormContainer.class.getName()).log( Level.WARNING, exception.getMessage()); return false; } return true; }  abstract OfficeFormsElement getFormContainerElement(); Form createForm(String name); boolean removeForm(Form form); Form getFormByName(String name); Iterator<Form> getFormIterator(); boolean getApplyDesignMode(); boolean getAutomaticFocus(); void setApplyDesignMode(boolean isDesignMode); void setAutomaticFocus(boolean isAutoFocus); void setProvider(FormProvider provider); FormProvider getProvider();  }
@Test public void testRemoveForm() { try { TextDocument textDoc = TextDocument.loadDocument(ResourceUtilities .getTestResourceAsStream("TestCreateForm.odt")); Form deleteForm = null; Iterator<Form> iterator = textDoc.getFormIterator(); while (iterator.hasNext()) { deleteForm = iterator.next(); if (deleteForm.getFormName().equals("Form3")) break; } textDoc.removeForm(deleteForm); Assert.assertNotNull(textDoc.getFormByName("Form1")); Assert.assertNotNull(textDoc.getFormByName("Form2")); Assert.assertNull(textDoc.getFormByName("Form3")); textDoc.save(ResourceUtilities .newTestOutputFile("TestRemoveForm.odt")); } catch (Exception e) { Logger.getLogger(AbstractFormContainerTest.class.getName()).log( Level.SEVERE, null, e); Assert.fail(); } }