From: Nick Burch Date: Tue, 29 Jun 2010 14:04:11 +0000 (+0000) Subject: Fix bug #49508 - Allow the addition of paragraphs to XWPF Table Cells. (Also fixed... X-Git-Tag: REL_3_7_BETA2~47 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6eb06011598164f9ce2fc67c7fc5edd17aaf14d8;p=poi.git Fix bug #49508 - Allow the addition of paragraphs to XWPF Table Cells. (Also fixed a few related warnings too) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@958972 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 89dc67248e..e3cbd0b1a1 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 49508 - Allow the addition of paragraphs to XWPF Table Cells 49446 - Don't consider 17.16.23 field codes as properly part of the paragraph's text XSLFSlideShow shouldn't break on .thmx (theme) files. Support for them is still very limited though diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java index 35ebffd91e..c42fde7d18 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java @@ -19,14 +19,11 @@ package org.apache.poi.xwpf.usermodel; import java.util.List; -import org.apache.poi.POIXMLDocumentPart; import org.apache.xmlbeans.XmlCursor; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc; - - /** *

* 8 Jan 2010 @@ -123,9 +120,6 @@ public interface IBody { * @return */ XWPFTableCell getTableCell(CTTc cell); - - - } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java index f6aa6b1ee8..1bce85fb47 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java @@ -80,7 +80,7 @@ public class XWPFFooter extends XWPFHeaderFooter { protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "ftr")); - Map map = new HashMap(); + Map map = new HashMap(); map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve"); map.put("urn:schemas-microsoft-com:office:office", "o"); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java index 0af3564629..6a5dd37838 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java @@ -84,7 +84,7 @@ public class XWPFHeader extends XWPFHeaderFooter { protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "hdr")); - Map map = new HashMap(); + Map map = new HashMap(); map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve"); map.put("urn:schemas-microsoft-com:office:office", "o"); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java index 3e317cca63..33adec4901 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java @@ -45,7 +45,7 @@ public class XWPFTableCell implements IBody { this.part = part; this.tableRow = tableRow; // NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt. - if(cell.getPArray().length<1) + if(cell.getPList().size()<1) cell.addNewP(); bodyElements = new ArrayList(); paragraphs = new ArrayList(); @@ -89,6 +89,16 @@ public class XWPFTableCell implements IBody { return paragraphs; } + /** + * Add a Paragraph to this Table Cell + * @return The paragraph which was added + */ + public XWPFParagraph addParagraph() { + XWPFParagraph p = new XWPFParagraph(ctTc.addNewP(), this); + addParagraph(p); + return p; + } + /** * add a Paragraph to this TableCell * @param p the paragaph which has to be added @@ -296,7 +306,7 @@ public class XWPFTableCell implements IBody { public void insertTable(int pos, XWPFTable table) { bodyElements.add(pos, table); int i; - for (i = 0; i < ctTc.getTblArray().length; i++) { + for (i = 0; i < ctTc.getTblList().size(); i++) { CTTbl tbl = ctTc.getTblArray(i); if(tbl == table.getCTTbl()){ break;