Section extends Component implements ParagraphContainer,
		TableContainer, ListContainer { public String getName() { return mSectionElement.getTextNameAttribute(); } private  Section(Document doc, TextSectionElement element); static Section getInstance(TextSectionElement element); Document getOwnerDocument(); String getName(); void setName(String name); void remove(); TextSectionElement getOdfElement(); void setProtected(boolean isProtected); boolean isProtected(); void setProtectedWithPassword(String key); String getProtectedPassword(); String getProtectionKeyDigestAlgorithm(); void setProtectionKeyDigestProvider(
			ProtectionKeyDigestProvider provider); ProtectionKeyDigestProvider getProtectionKeyDigestProvier(); ProtectionKeyDigestProvider getDefaultProtectionKeyDigestProvider(); @Override boolean equals(Object obj); Paragraph addParagraph(String textContent); OdfElement getParagraphContainerElement(); boolean removeParagraph(Paragraph para); Paragraph getParagraphByIndex(int index, boolean isEmptyParagraphSkipped); Paragraph getParagraphByReverseIndex(int reverseIndex, boolean isEmptyParagraphSkipped); Iterator<Paragraph> getParagraphIterator(); Table addTable(); Table addTable(int numRows, int numCols); TableBuilder getTableBuilder(); Table getTableByName(String name); OdfElement getTableContainerElement(); List<Table> getTableList(); org.odftoolkit.simple.text.list.List addList(); org.odftoolkit.simple.text.list.List addList(ListDecorator decorator); void clearList(); OdfElement getListContainerElement(); Iterator<org.odftoolkit.simple.text.list.List> getListIterator(); boolean removeList(org.odftoolkit.simple.text.list.List list); Section getEmbeddedSectionByName(String chdSecName);  }
@Test public void testForeignCopyPaste() { try { TextDocument newDoc = TextDocument.newTextDocument(); TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt")); Iterator<Section> sections = doc.getSectionIterator(); int count = 0; while (sections.hasNext()) { Section aSection = sections.next(); count++; newDoc.newParagraph("----Start of " + aSection.getName() + "---------"); newDoc.appendSection(aSection, false); newDoc.newParagraph("----End of " + aSection.getName() + "---------"); newDoc.newParagraph(); newDoc.newParagraph(); newDoc.newParagraph(); } newDoc.save(ResourceUtilities.newTestOutputFile("NewNewSections.odt")); newDoc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("NewNewSections.odt")); sections = newDoc.getSectionIterator(); int i = 0; while (sections.hasNext()) { sections.next(); i++; } Assert.assertEquals(count + 1, i); OdfPackage packageDocument = newDoc.getPackage(); String imagePathPrefix = "Pictures/"; count = 0; Iterator<String> filePaths = packageDocument.getFilePaths().iterator(); while (filePaths.hasNext()) { String path = filePaths.next(); if (path.startsWith(imagePathPrefix) && path.length() > imagePathPrefix.length()) count++; if (count > 2) break; } Assert.assertEquals(1, count); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } }
@Test public void testCopyPasteAll() { try { TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt")); Iterator<Section> sections = doc.getSectionIterator(); int count = 0; while (sections.hasNext()) { Section aSection = sections.next(); count++; doc.newParagraph("----Start of " + aSection.getName() + "---------"); doc.appendSection(aSection, false); doc.newParagraph("----End of " + aSection.getName() + "---------"); doc.newParagraph(); doc.newParagraph(); doc.newParagraph(); } doc.save(ResourceUtilities.newTestOutputFile("NewSections.odt")); doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("NewSections.odt")); sections = doc.getSectionIterator(); int i = 0; while (sections.hasNext()) { sections.next(); i++; } Assert.assertEquals(count * 2 + 1, i); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } }