From a7e39ad6c25e1149a0f3615c3677c6770ad2b1c1 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 25 Mar 2011 17:00:30 +0000 Subject: [PATCH] Add XWPF
detection for the other kind of ooxml schemas git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1085471 13f79535-47bb-0310-9956-ffa450edef68 --- src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java | 6 ++++++ .../apache/poi/xwpf/extractor/TestXWPFWordExtractor.java | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index 0e8bbb20a..e8689a6b9 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -609,13 +609,19 @@ public class XWPFRun { text.append(((CTText) o).getStringValue()); } } + if (o instanceof CTPTab) { text.append("\t"); } + if (o instanceof CTBr) { + text.append("\n"); + } if (o instanceof CTEmpty) { // Some inline text elements get returned not as // themselves, but as CTEmpty, owing to some odd // definitions around line 5642 of the XSDs + // This bit works around it, and replicates the above + // rules for that case String tagName = o.getDomNode().getNodeName(); if ("w:tab".equals(tagName)) { text.append("\t"); diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java index 116b69906..d1cc2eea5 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java @@ -88,7 +88,7 @@ public class TestXWPFWordExtractor extends TestCase { ps++; } } - assertEquals(103, ps); + assertEquals(134, ps); } public void testGetWithHyperlinks() { @@ -128,7 +128,7 @@ public class TestXWPFWordExtractor extends TestCase { "\n" + "More on page one\n" + "\n\n" + - "End of page 1\n\n" + + "End of page 1\n\n\n" + "This is page two. It also has a three column heading, and a three column footer.\n" + "Footer Left\tFooter Middle\tFooter Right\n", extractor.getText() @@ -151,7 +151,7 @@ public class TestXWPFWordExtractor extends TestCase { "\n" + "More on page one\n" + "\n\n" + - "End of page 1\n\n" + + "End of page 1\n\n\n" + "This is page two. It also has a three column heading, and a three column footer.\n" + "The footer of the first page\n" + "Footer Left\tFooter Middle\tFooter Right\n",