@@ -, +, @@ поддержка footnote в таблицах --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -98,7 +98,7 @@ public class XWPFDocument extends POIXMLDocument { // Get any tables for(CTTbl table : body.getTblArray()) { - tables.add(new XWPFTable(table)); + tables.add(new XWPFTable(this, table)); } // Sort out headers and footers @@ -337,7 +337,7 @@ public class XWPFDocument extends POIXMLDocument { * @return a new table */ public XWPFTable createTable(){ - return new XWPFTable(ctDocument.getBody().addNewTbl()); + return new XWPFTable(this, ctDocument.getBody().addNewTbl()); } /** @@ -347,7 +347,7 @@ public class XWPFDocument extends POIXMLDocument { * @return table */ public XWPFTable createTable(int rows, int cols) { - return new XWPFTable(ctDocument.getBody().addNewTbl(), rows, cols); + return new XWPFTable(this, ctDocument.getBody().addNewTbl(), rows, cols); } } --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java +++ a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java @@ -64,7 +64,7 @@ public abstract class XWPFHeaderFooter { XWPFTable[] tables = new XWPFTable[headerFooter.getTblArray().length]; for(int i=0; i 0) { rowText.append('\t'); } --- a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java +++ a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java @@ -60,6 +60,12 @@ public class TestXWPFWordExtractor extends TestCase { private XWPFDocument xmlFootnotes; private File fileFootnotes; + /** + * File with footnote in table + */ + private XWPFDocument xmlFootnotes2; + private File fileFootnotes2; + protected void setUp() throws Exception { super.setUp(); @@ -87,6 +93,10 @@ public class TestXWPFWordExtractor extends TestCase { System.getProperty("HWPF.testdata.path") + File.separator + "snoska.docx" ); + fileFootnotes2 = new File( + System.getProperty("HWPF.testdata.path") + + File.separator + "Table.docx" + ); assertTrue(fileA.exists()); assertTrue(fileB.exists()); @@ -94,6 +104,7 @@ public class TestXWPFWordExtractor extends TestCase { assertTrue(fileD.exists()); assertTrue(fileE.exists()); assertTrue(fileFootnotes.exists()); + assertTrue(fileFootnotes2.exists()); xmlA = new XWPFDocument(POIXMLDocument.openPackage(fileA.toString())); xmlB = new XWPFDocument(POIXMLDocument.openPackage(fileB.toString())); @@ -101,6 +112,7 @@ public class TestXWPFWordExtractor extends TestCase { xmlD = new XWPFDocument(POIXMLDocument.openPackage(fileD.toString())); xmlE = new XWPFDocument(POIXMLDocument.openPackage(fileE.toString())); xmlFootnotes = new XWPFDocument(POIXMLDocument.openPackage(fileFootnotes.toString())); + xmlFootnotes2 = new XWPFDocument(POIXMLDocument.openPackage(fileFootnotes2.toString())); } /** @@ -246,4 +258,13 @@ public class TestXWPFWordExtractor extends TestCase { assertTrue(extractor.getText().contains("snoska")); } + + public void testFootnotes2() throws Exception { + XWPFWordExtractor extractor = + new XWPFWordExtractor(xmlFootnotes2); + extractor.getText(); + + assertTrue(extractor.getText().contains("snoska")); + } + } --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java +++ a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java @@ -43,14 +43,14 @@ public class TestXWPFTable extends TestCase { public void testConstructor() { CTTbl ctTable=CTTbl.Factory.newInstance(); - XWPFTable xtab=new XWPFTable(ctTable); + XWPFTable xtab=new XWPFTable(null, ctTable); 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(ctTable, 3,2); + xtab=new XWPFTable(null, ctTable, 3,2); assertNotNull(xtab); assertEquals(3,ctTable.sizeOfTrArray()); assertEquals(2,ctTable.getTrArray(0).sizeOfTcArray()); @@ -67,7 +67,7 @@ public class TestXWPFTable extends TestCase { CTText text=run.addNewT(); text.setStringValue("finally I can write!"); - XWPFTable xtab=new XWPFTable(table); + XWPFTable xtab=new XWPFTable(null, table); assertEquals("finally I can write!\n",xtab.getText()); } @@ -84,7 +84,7 @@ public class TestXWPFTable extends TestCase { r3.addNewTc().addNewP(); r3.addNewTc().addNewP(); - XWPFTable xtab=new XWPFTable(table); + XWPFTable xtab=new XWPFTable(null, table); assertEquals(3,xtab.getNumberOfRows()); assertNotNull(xtab.getRow(2)); @@ -95,7 +95,7 @@ public class TestXWPFTable extends TestCase { assertEquals(2,table.getTrArray(0).sizeOfTcArray()); //check creation of first row - xtab=new XWPFTable(CTTbl.Factory.newInstance()); + xtab=new XWPFTable(null, CTTbl.Factory.newInstance()); assertEquals(1,xtab.getCTTbl().getTrArray(0).sizeOfTcArray()); } @@ -104,7 +104,7 @@ public class TestXWPFTable extends TestCase { CTTbl table = CTTbl.Factory.newInstance(); table.addNewTblPr().addNewTblW().setW(new BigInteger("1000")); - XWPFTable xtab=new XWPFTable(table); + XWPFTable xtab=new XWPFTable(null, table); assertEquals(1000,xtab.getWidth());