aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi/xwpf
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-08-13 20:23:58 +0000
committerNick Burch <nick@apache.org>2015-08-13 20:23:58 +0000
commit6181eef6a02179f82d3d4cd4550deef2c263fbde (patch)
treec678dc25a774ceb44bcdd03edd1c5e5a880c628e /src/ooxml/testcases/org/apache/poi/xwpf
parent94071f03953ea89bc71ccf2149c981172170013f (diff)
downloadpoi-6181eef6a02179f82d3d4cd4550deef2c263fbde.tar.gz
poi-6181eef6a02179f82d3d4cd4550deef2c263fbde.zip
#58237 When adding a picture to a XWPF header or footer, attach it to the right part
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1695772 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/xwpf')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java
index 0b29956c67..02ab71adcf 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java
@@ -30,7 +30,6 @@ import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.xssf.usermodel.XSSFRelation;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
public class TestXWPFPictureData extends TestCase {
@@ -64,7 +63,7 @@ public class TestXWPFPictureData extends TestCase {
verifyOneHeaderPicture(readBack);
}
- public void FIXMEtestCreateHeaderPicture() throws Exception { // TODO Fix
+ public void testCreateHeaderPicture() throws Exception {
XWPFDocument doc = new XWPFDocument();
// Starts with no header
@@ -73,16 +72,13 @@ public class TestXWPFPictureData extends TestCase {
// Add a default header
policy = doc.createHeaderFooterPolicy();
-
- XWPFParagraph[] hparas = new XWPFParagraph[] {
- new XWPFParagraph(CTP.Factory.newInstance(), doc)
- };
- hparas[0].createRun().setText("Header Hello World!");
- XWPFHeader header = policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT, hparas);
+ XWPFHeader header = policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT);
+ header.getParagraphs().get(0).createRun().setText("Hello, Header World!");
+ header.createParagraph().createRun().setText("Paragraph 2");
assertEquals(0, header.getAllPictures().size());
- assertEquals(1, header.getParagraphs().size());
+ assertEquals(2, header.getParagraphs().size());
- // Add a picture to it
+ // Add a picture to the first paragraph
header.getParagraphs().get(0).getRuns().get(0).addPicture(
new ByteArrayInputStream(new byte[] {1,2,3,4}),
Document.PICTURE_TYPE_JPEG, "test.jpg", 2, 2);