Add XWPF <br> 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
This commit is contained in:
Nick Burch 2011-03-25 17:00:30 +00:00
parent 2330d4fedc
commit ec4691b409
2 changed files with 9 additions and 3 deletions

View File

@ -609,13 +609,19 @@ public class XWPFRun {
text.append(((CTText) o).getStringValue()); text.append(((CTText) o).getStringValue());
} }
} }
if (o instanceof CTPTab) { if (o instanceof CTPTab) {
text.append("\t"); text.append("\t");
} }
if (o instanceof CTBr) {
text.append("\n");
}
if (o instanceof CTEmpty) { if (o instanceof CTEmpty) {
// Some inline text elements get returned not as // Some inline text elements get returned not as
// themselves, but as CTEmpty, owing to some odd // themselves, but as CTEmpty, owing to some odd
// definitions around line 5642 of the XSDs // 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(); String tagName = o.getDomNode().getNodeName();
if ("w:tab".equals(tagName)) { if ("w:tab".equals(tagName)) {
text.append("\t"); text.append("\t");

View File

@ -88,7 +88,7 @@ public class TestXWPFWordExtractor extends TestCase {
ps++; ps++;
} }
} }
assertEquals(103, ps); assertEquals(134, ps);
} }
public void testGetWithHyperlinks() { public void testGetWithHyperlinks() {
@ -128,7 +128,7 @@ public class TestXWPFWordExtractor extends TestCase {
"\n" + "\n" +
"More on page one\n" + "More on page one\n" +
"\n\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" + "This is page two. It also has a three column heading, and a three column footer.\n" +
"Footer Left\tFooter Middle\tFooter Right\n", "Footer Left\tFooter Middle\tFooter Right\n",
extractor.getText() extractor.getText()
@ -151,7 +151,7 @@ public class TestXWPFWordExtractor extends TestCase {
"\n" + "\n" +
"More on page one\n" + "More on page one\n" +
"\n\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" + "This is page two. It also has a three column heading, and a three column footer.\n" +
"The footer of the first page\n" + "The footer of the first page\n" +
"Footer Left\tFooter Middle\tFooter Right\n", "Footer Left\tFooter Middle\tFooter Right\n",