poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1768005 - in /poi/trunk: src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNum.java src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java test-data/document/ComplexNumberedLists.docx
Date Fri, 04 Nov 2016 10:55:31 GMT
Author: nick
Date: Fri Nov  4 10:55:31 2016
New Revision: 1768005

URL: http://svn.apache.org/viewvc?rev=1768005&view=rev
Log:
More unit testing for XWPF list numbering complex cases, and some TODOs on improving it, inspired
by users@ discussions

Added:
    poi/trunk/test-data/document/ComplexNumberedLists.docx   (with props)
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNum.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNum.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNum.java?rev=1768005&r1=1768004&r2=1768005&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNum.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNum.java Fri Nov  4 10:55:31
2016
@@ -19,8 +19,8 @@ package org.apache.poi.xwpf.usermodel;
 
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNum;
 
-/**
- * @author Philipp Epp
+/**
+ * TODO Bring more of the logic over from XWPFParagraph
  */
 public class XWPFNum {
     protected XWPFNumbering numbering;

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java?rev=1768005&r1=1768004&r2=1768005&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java Fri
Nov  4 10:55:31 2016
@@ -592,4 +592,88 @@ public final class TestXWPFParagraph {
         }
         assertEquals("This is a test.\n\n\n\n3\n4\n5\n\n\n\nThis is a whole paragraph where
one word is deleted.\n", str.toString());
     }
+    
+    @Test
+    public void testNumberedLists() throws Exception {
+        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("ComplexNumberedLists.docx");
+        XWPFParagraph p;
+        
+        p = doc.getParagraphArray(0);
+        assertEquals("This is a document with numbered lists", p.getText());
+        assertEquals(null, p.getNumID());
+        assertEquals(null, p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(1);
+        assertEquals("Entry #1", p.getText());
+        assertEquals(BigInteger.valueOf(1), p.getNumID());
+        assertEquals(BigInteger.valueOf(0), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(2);
+        assertEquals("Entry #2, with children", p.getText());
+        assertEquals(BigInteger.valueOf(1), p.getNumID());
+        assertEquals(BigInteger.valueOf(0), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(3);
+        assertEquals("2-a", p.getText());
+        assertEquals(BigInteger.valueOf(1), p.getNumID());
+        assertEquals(BigInteger.valueOf(1), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(4);
+        assertEquals("2-b", p.getText());
+        assertEquals(BigInteger.valueOf(1), p.getNumID());
+        assertEquals(BigInteger.valueOf(1), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(5);
+        assertEquals("2-c", p.getText());
+        assertEquals(BigInteger.valueOf(1), p.getNumID());
+        assertEquals(BigInteger.valueOf(1), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(6);
+        assertEquals("Entry #3", p.getText());
+        assertEquals(BigInteger.valueOf(1), p.getNumID());
+        assertEquals(BigInteger.valueOf(0), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(7);
+        assertEquals("Entry #4", p.getText());
+        assertEquals(BigInteger.valueOf(1), p.getNumID());
+        assertEquals(BigInteger.valueOf(0), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        // New list
+        p = doc.getParagraphArray(8);
+        assertEquals("Restarted to 1 from 5", p.getText());
+        assertEquals(BigInteger.valueOf(2), p.getNumID());
+        assertEquals(BigInteger.valueOf(0), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(9);
+        assertEquals("Restarted @ 2", p.getText());
+        assertEquals(BigInteger.valueOf(2), p.getNumID());
+        assertEquals(BigInteger.valueOf(0), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        p = doc.getParagraphArray(10);
+        assertEquals("Restarted @ 3", p.getText());
+        assertEquals(BigInteger.valueOf(2), p.getNumID());
+        assertEquals(BigInteger.valueOf(0), p.getNumIlvl());
+        assertEquals(null, p.getNumStartOverride());
+        
+        // New list starting at 10
+        p = doc.getParagraphArray(11);
+        assertEquals("Jump to new list at 10", p.getText());
+        assertEquals(BigInteger.valueOf(6), p.getNumID());
+        assertEquals(BigInteger.valueOf(0), p.getNumIlvl());
+        // TODO Why isn't this seen as 10?
+        assertEquals(null, p.getNumStartOverride());
+        
+        // TODO Shouldn't we use XWPFNumbering or similar here?
+        // TODO Make it easier to change
+    }
 }

Added: poi/trunk/test-data/document/ComplexNumberedLists.docx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/ComplexNumberedLists.docx?rev=1768005&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/document/ComplexNumberedLists.docx
------------------------------------------------------------------------------
--- svn:mime-type (added)
+++ svn:mime-type Fri Nov  4 10:55:31 2016
@@ -0,0 +1 @@
+application/vnd.openxmlformats-officedocument.wordprocessingml.document



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


Mime
View raw message