poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r953704 [3/3] - in /poi/trunk/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/ ooxml/java/org/apache/poi/xwpf/model/ ooxml/java/org/apache/poi/xwpf/usermodel/ ooxml/testcases/org/apache/poi/xwpf/ ooxml/testcases/org/apache/poi/x...
Date Fri, 11 Jun 2010 14:37:59 GMT
Added: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java?rev=953704&view=auto
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java (added)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java Fri
Jun 11 14:37:58 2010
@@ -0,0 +1,89 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xwpf.usermodel;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hssf.record.formula.AddPtg;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.xwpf.XWPFTestDataSamples;
+
+
+import junit.framework.TestCase;
+
+public class TestXWPFPictureData extends TestCase {
+	   public void testRead(){
+		   XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("VariousPictures.docx");
+	        List<XWPFPictureData> pictures = sampleDoc.getAllPictures();
+	        assertSame(pictures, sampleDoc.getAllPictures());
+
+	        assertEquals(5, pictures.size());
+	        String[] ext = {"wmf", "png", "emf", "emf", "jpeg"};
+	        for (int i = 0; i < pictures.size(); i++) {
+	            assertEquals(ext[i], pictures.get(i).suggestFileExtension());
+	        }
+
+	        int num = pictures.size();
+
+	        byte[] pictureData = {0xA, 0xB, 0XC, 0xD, 0xE, 0xF};
+
+	        int idx;
+			try {
+				idx = sampleDoc.addPicture(pictureData, XWPFDocument.PICTURE_TYPE_JPEG);
+				assertEquals(num + 1, pictures.size());
+				//idx is 0-based index in the #pictures array
+				assertEquals(pictures.size() - 1, idx);
+				XWPFPictureData pict = pictures.get(idx);
+				assertEquals("jpeg", pict.suggestFileExtension());
+				assertTrue(Arrays.equals(pictureData, pict.getData()));
+			} catch (InvalidFormatException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+	    }
+
+	    public void testNew(){
+	        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("EmptyDocumentWithHeaderFooter.docx");
+	        byte[] jpegData = "test jpeg data".getBytes();
+	        byte[] wmfData =  "test wmf data".getBytes();
+	        byte[] pngData =  "test png data".getBytes();
+	        List<XWPFPictureData> pictures = doc.getAllPictures();
+	        assertEquals(0, pictures.size());
+	        int jpegIdx;
+			try {
+				jpegIdx = doc.addPicture(jpegData, XWPFDocument.PICTURE_TYPE_JPEG);
+				assertEquals(1, pictures.size());
+				assertEquals("jpeg", pictures.get(jpegIdx).suggestFileExtension());
+				assertTrue(Arrays.equals(jpegData, pictures.get(jpegIdx).getData()));
+				
+				PackageRelationship addPictureReference = doc.addPictureReference(jpegData, Document.PICTURE_TYPE_JPEG
);
+				XWPFPictureData pictureDataByID = doc.getPictureDataByID(addPictureReference.getId());
+				byte [] newJPEGData = pictureDataByID.getData();
+				assertEquals(newJPEGData.length, jpegData.length);
+				for(int i = 0; i < newJPEGData.length; i++){
+					assertEquals(newJPEGData[i], jpegData[i]);	
+				}
+			} catch (InvalidFormatException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+	    }
+}

Added: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java?rev=953704&view=auto
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java (added)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java Fri Jun
11 14:37:58 2010
@@ -0,0 +1,54 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xwpf.usermodel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.xwpf.XWPFTestDataSamples;
+
+import junit.framework.TestCase;
+
+public class TestXWPFStyles extends TestCase {
+
+//	protected void setUp() throws Exception {
+//		super.setUp();
+//	}
+	
+	public void testGetUsedStyles(){
+		XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("Styles.docx");
+		List<XWPFStyle> testUsedStyleList = new ArrayList<XWPFStyle>();
+		XWPFStyles styles = sampleDoc.getStyles();
+		XWPFStyle style = styles.getStyle("berschrift1");
+		testUsedStyleList.add(style);
+		testUsedStyleList.add(styles.getStyle("Standard"));
+		testUsedStyleList.add(styles.getStyle("berschrift1Zchn"));
+		testUsedStyleList.add(styles.getStyle("Absatz-Standardschriftart"));
+		style.hasSameName(style);
+		
+		List<XWPFStyle> usedStyleList = styles.getUsedStyleList(style);
+		assertEquals(usedStyleList, testUsedStyleList);
+		
+		
+	}
+
+//	protected void tearDown() throws Exception {
+//		super.tearDown();
+//	}
+
+}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java?rev=953704&r1=953703&r2=953704&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java Fri Jun
11 14:37:58 2010
@@ -43,14 +43,14 @@ public class TestXWPFTable extends TestC
 
     public void testConstructor() {
         CTTbl ctTable = CTTbl.Factory.newInstance();
-        XWPFTable xtab = new XWPFTable(null, ctTable);
+        XWPFTable xtab = new XWPFTable(ctTable, null);
         assertNotNull(xtab);
         assertEquals(1, ctTable.sizeOfTrArray());
         assertEquals(1, ctTable.getTrArray(0).sizeOfTcArray());
         assertNotNull(ctTable.getTrArray(0).getTcArray(0).getPArray(0));
 
         ctTable = CTTbl.Factory.newInstance();
-        xtab = new XWPFTable(null, ctTable, 3, 2);
+        xtab = new XWPFTable(ctTable, null, 3, 2);
         assertNotNull(xtab);
         assertEquals(3, ctTable.sizeOfTrArray());
         assertEquals(2, ctTable.getTrArray(0).sizeOfTcArray());
@@ -67,7 +67,7 @@ public class TestXWPFTable extends TestC
         CTText text = run.addNewT();
         text.setStringValue("finally I can write!");
 
-        XWPFTable xtab = new XWPFTable(null, table);
+        XWPFTable xtab = new XWPFTable(table, null);
         assertEquals("finally I can write!\n", xtab.getText());
     }
 
@@ -84,7 +84,7 @@ public class TestXWPFTable extends TestC
         r3.addNewTc().addNewP();
         r3.addNewTc().addNewP();
 
-        XWPFTable xtab = new XWPFTable(null, table);
+        XWPFTable xtab = new XWPFTable(table, null);
         assertEquals(3, xtab.getNumberOfRows());
         assertNotNull(xtab.getRow(2));
 
@@ -95,7 +95,7 @@ public class TestXWPFTable extends TestC
         assertEquals(2, table.getTrArray(0).sizeOfTcArray());
 
         //check creation of first row
-        xtab = new XWPFTable(null, CTTbl.Factory.newInstance());
+        xtab = new XWPFTable(CTTbl.Factory.newInstance(), null);
         assertEquals(1, xtab.getCTTbl().getTrArray(0).sizeOfTcArray());
     }
 
@@ -104,7 +104,7 @@ public class TestXWPFTable extends TestC
         CTTbl table = CTTbl.Factory.newInstance();
         table.addNewTblPr().addNewTblW().setW(new BigInteger("1000"));
 
-        XWPFTable xtab = new XWPFTable(null, table);
+        XWPFTable xtab = new XWPFTable(table, null);
 
         assertEquals(1000, xtab.getWidth());
 
@@ -115,7 +115,7 @@ public class TestXWPFTable extends TestC
     public void testSetGetHeight() {
         CTTbl table = CTTbl.Factory.newInstance();
 
-        XWPFTable xtab = new XWPFTable(null, table);
+        XWPFTable xtab = new XWPFTable(table, null);
         XWPFTableRow row = xtab.createRow();
         row.setHeight(20);
         assertEquals(20, row.getHeight());

Added: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableRow.java?rev=953704&view=auto
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableRow.java (added)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableRow.java Fri
Jun 11 14:37:58 2010
@@ -0,0 +1,46 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xwpf.usermodel;
+
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow;
+
+import junit.framework.TestCase;
+
+public class TestXWPFTableRow extends TestCase {
+
+	
+	
+	@Override
+	protected void setUp() throws Exception {
+		// TODO Auto-generated method stub
+		super.setUp();
+	}
+
+	public void testSomething() throws Exception {
+		
+		CTRow ctRow = CTRow.Factory.newInstance();
+
+	}
+	
+	@Override
+	protected void tearDown() throws Exception {
+		// TODO Auto-generated method stub
+		super.tearDown();
+	}
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message