mirror of https://github.com/apache/poi.git
bug 60316 -- until we can implement it properly, gracefully skip the glossary document in XWPF.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1845517 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5416787da5
commit
341f456ef7
|
@ -42,6 +42,7 @@ import org.apache.poi.util.POILogger;
|
||||||
import org.apache.poi.xddf.usermodel.chart.XDDFChart;
|
import org.apache.poi.xddf.usermodel.chart.XDDFChart;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFRelation;
|
import org.apache.poi.xssf.usermodel.XSSFRelation;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFRelation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an entry of a OOXML package.
|
* Represents an entry of a OOXML package.
|
||||||
|
@ -613,6 +614,14 @@ public class POIXMLDocumentPart {
|
||||||
*/
|
*/
|
||||||
protected void read(POIXMLFactory factory, Map<PackagePart, POIXMLDocumentPart> context) throws OpenXML4JException {
|
protected void read(POIXMLFactory factory, Map<PackagePart, POIXMLDocumentPart> context) throws OpenXML4JException {
|
||||||
PackagePart pp = getPackagePart();
|
PackagePart pp = getPackagePart();
|
||||||
|
|
||||||
|
if (pp.getContentType().equals(XWPFRelation.TEMPLATE.getContentType())) {
|
||||||
|
logger.log(POILogger.WARN,
|
||||||
|
"POI does not currently support template.main+xml (glossary) parts. " +
|
||||||
|
"Skipping this part for now.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// add mapping a second time, in case of initial caller hasn't done so
|
// add mapping a second time, in case of initial caller hasn't done so
|
||||||
POIXMLDocumentPart otherChild = context.put(pp, this);
|
POIXMLDocumentPart otherChild = context.put(pp, this);
|
||||||
if (otherChild != null && otherChild != this) {
|
if (otherChild != null && otherChild != this) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.poi.xwpf.XWPFTestDataSamples;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import static org.apache.poi.POITestCase.assertContains;
|
import static org.apache.poi.POITestCase.assertContains;
|
||||||
import static org.apache.poi.POITestCase.assertEndsWith;
|
import static org.apache.poi.POITestCase.assertEndsWith;
|
||||||
|
import static org.apache.poi.POITestCase.assertNotContained;
|
||||||
import static org.apache.poi.POITestCase.assertStartsWith;
|
import static org.apache.poi.POITestCase.assertStartsWith;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -441,4 +442,14 @@ public class TestXWPFWordExtractor extends TestCase {
|
||||||
assertContains(txt, "Sequencing data");
|
assertContains(txt, "Sequencing data");
|
||||||
extractor.close();
|
extractor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGlossary() throws IOException {
|
||||||
|
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("60316.dotx");
|
||||||
|
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
||||||
|
String txt = extractor.getText();
|
||||||
|
assertContains(txt, "Getting the perfect");
|
||||||
|
//this content appears only in the glossary document
|
||||||
|
//once we add processing for this, we can change this to contains
|
||||||
|
assertNotContained(txt, "table rows");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue