poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1492308 - in /poi/trunk/src/ooxml: java/org/apache/poi/xwpf/usermodel/XWPFRun.java testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
Date Wed, 12 Jun 2013 17:54:39 GMT
Author: nick
Date: Wed Jun 12 17:54:39 2013
New Revision: 1492308

URL: http://svn.apache.org/r1492308
Log:
Patch from akhikhl from github pull #3 - Extract references from XWPF footnotes

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java?rev=1492308&r1=1492307&r2=1492308&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java Wed Jun 12 17:54:39
2013
@@ -52,6 +52,7 @@ import org.openxmlformats.schemas.wordpr
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTEmpty;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdnRef;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab;
@@ -817,6 +818,12 @@ public class XWPFRun {
                     text.append("\n");
                 }
             }
+            if (o instanceof CTFtnEdnRef) {
+                CTFtnEdnRef ftn = (CTFtnEdnRef)o;
+                String footnoteRef = ftn.getDomNode().getLocalName().equals("footnoteReference")
?
+                    "[footnoteRef:" + ftn.getId().intValue() + "]" : "[endnoteRef:" + ftn.getId().intValue()
+ "]";
+                text.append(footnoteRef);
+            }            
         }
 
         c.dispose();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java?rev=1492308&r1=1492307&r2=1492308&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
Wed Jun 12 17:54:39 2013
@@ -166,8 +166,9 @@ public class TestXWPFWordExtractor exten
     public void testFootnotes() throws IOException {
         XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("footnotes.docx");
         XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
-
-        assertTrue(extractor.getText().contains("snoska"));
+        String text = extractor.getText();
+        assertTrue(text.contains("snoska"));
+        assertTrue(text.contains("Eto ochen prostoy[footnoteRef:1] text so snoskoy"));
     }
 
 
@@ -190,8 +191,9 @@ public class TestXWPFWordExtractor exten
     public void testEndnotes() throws IOException {
         XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("endnotes.docx");
         XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
-
-        assertTrue(extractor.getText().contains("XXX"));
+        String text = extractor.getText();
+        assertTrue(text.contains("XXX"));
+        assertTrue(text.contains("tilaka [endnoteRef:2]or 'tika'"));
     }
 
     public void testInsertedDeletedText() throws IOException {



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


Mime
View raw message