Hook up POIXMLTextExtractor.getMetadataTextExtractor() to the already written POIXMLPropertiesTextExtractor
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@732063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
68e203d5e6
commit
ec521065e2
@ -37,6 +37,7 @@
|
||||
|
||||
<!-- Don't forget to update status.xml too! -->
|
||||
<release version="3.5-beta5" date="2008-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="fix">Hook up POIXMLTextExtractor.getMetadataTextExtractor() to the already written POIXMLPropertiesTextExtractor</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">46472 - Avoid NPE in HPSFPropertiesExtractor when no properties exist</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">46479 - fixed bugs related to cached formula values and HSSFFormulaEvaluator.evaluateInCell()</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">45031 - added implementation for CHOOSE() function</action>
|
||||
|
@ -34,6 +34,7 @@
|
||||
<!-- Don't forget to update changes.xml too! -->
|
||||
<changes>
|
||||
<release version="3.5-beta5" date="2008-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="fix">Hook up POIXMLTextExtractor.getMetadataTextExtractor() to the already written POIXMLPropertiesTextExtractor</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">46472 - Avoid NPE in HPSFPropertiesExtractor when no properties exist</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">46479 - fixed bugs related to cached formula values and HSSFFormulaEvaluator.evaluateInCell()</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">45031 - added implementation for CHOOSE() function</action>
|
||||
|
@ -136,7 +136,7 @@ public class POIXMLPropertiesTextExtractor extends POIXMLTextExtractor {
|
||||
}
|
||||
}
|
||||
|
||||
public POITextExtractor getMetadataTextExtractor() {
|
||||
public POIXMLPropertiesTextExtractor getMetadataTextExtractor() {
|
||||
throw new IllegalStateException("You already have the Metadata Text Extractor, not recursing!");
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public abstract class POIXMLTextExtractor extends POITextExtractor {
|
||||
* Returns an OOXML properties text extractor for the
|
||||
* document properties metadata, such as title and author.
|
||||
*/
|
||||
public POITextExtractor getMetadataTextExtractor() {
|
||||
throw new RuntimeException("Not yet supported for OOXML!");
|
||||
public POIXMLPropertiesTextExtractor getMetadataTextExtractor() {
|
||||
return new POIXMLPropertiesTextExtractor(document);
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,12 @@ package org.apache.poi;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.openxml4j.opc.Package;
|
||||
|
||||
import sun.awt.X11.XModifierKeymap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class TestXMLPropertiesTextExtractor extends TestCase {
|
||||
@ -30,6 +33,27 @@ public class TestXMLPropertiesTextExtractor extends TestCase {
|
||||
dirname = System.getProperty("OOXML.testdata.path");
|
||||
assertTrue( (new File(dirname)).exists() );
|
||||
}
|
||||
|
||||
public void testGetFromMainExtractor() throws Exception {
|
||||
org.openxml4j.opc.Package pkg = Package.open(
|
||||
(new File(dirname, "ExcelWithAttachments.xlsx")).toString()
|
||||
);
|
||||
XSSFWorkbook wb = new XSSFWorkbook(pkg);
|
||||
|
||||
XSSFExcelExtractor ext = new XSSFExcelExtractor(wb);
|
||||
POIXMLPropertiesTextExtractor textExt = ext.getMetadataTextExtractor();
|
||||
|
||||
// Check basics
|
||||
assertNotNull(textExt);
|
||||
assertTrue(textExt.getText().length() > 0);
|
||||
|
||||
// Check some of the content
|
||||
String text = textExt.getText();
|
||||
String cText = textExt.getCorePropertiesText();
|
||||
|
||||
assertTrue(text.contains("LastModifiedBy = Yury Batrakov"));
|
||||
assertTrue(cText.contains("LastModifiedBy = Yury Batrakov"));
|
||||
}
|
||||
|
||||
public void testCore() throws Exception {
|
||||
org.openxml4j.opc.Package pkg = Package.open(
|
||||
|
Loading…
Reference in New Issue
Block a user