Bug 53282 - Hyperlink with a non-breaking space throws java.lang.IllegalStateException
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1563540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
028ec314ae
commit
c1a7ab3860
@ -22,14 +22,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
|
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
|
||||||
|
import org.apache.poi.util.POILogFactory;
|
||||||
|
import org.apache.poi.util.POILogger;
|
||||||
import org.dom4j.Attribute;
|
import org.dom4j.Attribute;
|
||||||
import org.dom4j.Document;
|
import org.dom4j.Document;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
import org.dom4j.io.SAXReader;
|
import org.dom4j.io.SAXReader;
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
|
|
||||||
import org.apache.poi.util.POILogger;
|
|
||||||
import org.apache.poi.util.POILogFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a collection of PackageRelationship elements that are owned by a
|
* Represents a collection of PackageRelationship elements that are owned by a
|
||||||
@ -320,10 +320,11 @@ public final class PackageRelationshipCollection implements
|
|||||||
// Check OPC compliance M4.1 rule
|
// Check OPC compliance M4.1 rule
|
||||||
boolean fCorePropertiesRelationship = false;
|
boolean fCorePropertiesRelationship = false;
|
||||||
|
|
||||||
for (Iterator i = root
|
@SuppressWarnings("unchecked")
|
||||||
.elementIterator(PackageRelationship.RELATIONSHIP_TAG_NAME); i
|
Iterator<Element> iter = (Iterator<Element>)
|
||||||
.hasNext();) {
|
root.elementIterator(PackageRelationship.RELATIONSHIP_TAG_NAME);
|
||||||
Element element = (Element) i.next();
|
while (iter.hasNext()) {
|
||||||
|
Element element = iter.next();
|
||||||
// Relationship ID
|
// Relationship ID
|
||||||
String id = element.attribute(
|
String id = element.attribute(
|
||||||
PackageRelationship.ID_ATTRIBUTE_NAME).getValue();
|
PackageRelationship.ID_ATTRIBUTE_NAME).getValue();
|
||||||
@ -353,19 +354,19 @@ public final class PackageRelationshipCollection implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Target converted in URI
|
// Target converted in URI
|
||||||
URI target;
|
URI target = PackagingURIHelper.toURI("http://invalid.uri"); // dummy url
|
||||||
String value = "";
|
String value = element.attribute(
|
||||||
try {
|
|
||||||
value = element.attribute(
|
|
||||||
PackageRelationship.TARGET_ATTRIBUTE_NAME)
|
PackageRelationship.TARGET_ATTRIBUTE_NAME)
|
||||||
.getValue();
|
.getValue();
|
||||||
|
try {
|
||||||
|
// when parsing of the given uri fails, we can either
|
||||||
|
// ignore this relationship, which leads to IllegalStateException
|
||||||
|
// later on, or use a dummy value and thus enable processing of the
|
||||||
|
// package
|
||||||
target = PackagingURIHelper.toURI(value);
|
target = PackagingURIHelper.toURI(value);
|
||||||
|
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
logger.log(POILogger.ERROR, "Cannot convert " + value
|
logger.log(POILogger.ERROR, "Cannot convert " + value
|
||||||
+ " in a valid relationship URI-> ignored", e);
|
+ " in a valid relationship URI-> dummy-URI used", e);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
addRelationship(target, targetMode, type, id);
|
addRelationship(target, targetMode, type, id);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import org.apache.poi.openxml4j.opc.PackagePart;
|
|||||||
import org.apache.poi.openxml4j.opc.PackagePartName;
|
import org.apache.poi.openxml4j.opc.PackagePartName;
|
||||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||||
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
|
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
|
||||||
|
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
|
||||||
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
|
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
|
||||||
import org.apache.poi.util.POILogFactory;
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
@ -62,64 +63,73 @@ public final class XSSFRelation extends POIXMLRelation {
|
|||||||
);
|
);
|
||||||
public static final XSSFRelation MACROS_WORKBOOK = new XSSFRelation(
|
public static final XSSFRelation MACROS_WORKBOOK = new XSSFRelation(
|
||||||
"application/vnd.ms-excel.sheet.macroEnabled.main+xml",
|
"application/vnd.ms-excel.sheet.macroEnabled.main+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
PackageRelationshipTypes.CORE_DOCUMENT,
|
||||||
"/xl/workbook.xml",
|
"/xl/workbook.xml",
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
public static final XSSFRelation TEMPLATE_WORKBOOK = new XSSFRelation(
|
public static final XSSFRelation TEMPLATE_WORKBOOK = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml",
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
PackageRelationshipTypes.CORE_DOCUMENT,
|
||||||
"/xl/workbook.xml",
|
"/xl/workbook.xml",
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation MACRO_TEMPLATE_WORKBOOK = new XSSFRelation(
|
public static final XSSFRelation MACRO_TEMPLATE_WORKBOOK = new XSSFRelation(
|
||||||
"application/vnd.ms-excel.template.macroEnabled.main+xml",
|
"application/vnd.ms-excel.template.macroEnabled.main+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
PackageRelationshipTypes.CORE_DOCUMENT,
|
||||||
"/xl/workbook.xml",
|
"/xl/workbook.xml",
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation MACRO_ADDIN_WORKBOOK = new XSSFRelation(
|
public static final XSSFRelation MACRO_ADDIN_WORKBOOK = new XSSFRelation(
|
||||||
"application/vnd.ms-excel.addin.macroEnabled.main+xml",
|
"application/vnd.ms-excel.addin.macroEnabled.main+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
PackageRelationshipTypes.CORE_DOCUMENT,
|
||||||
"/xl/workbook.xml",
|
"/xl/workbook.xml",
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation WORKSHEET = new XSSFRelation(
|
public static final XSSFRelation WORKSHEET = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
|
||||||
"/xl/worksheets/sheet#.xml",
|
"/xl/worksheets/sheet#.xml",
|
||||||
XSSFSheet.class
|
XSSFSheet.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation CHARTSHEET = new XSSFRelation(
|
public static final XSSFRelation CHARTSHEET = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml",
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet",
|
||||||
"/xl/chartsheets/sheet#.xml",
|
"/xl/chartsheets/sheet#.xml",
|
||||||
XSSFChartSheet.class
|
XSSFChartSheet.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation SHARED_STRINGS = new XSSFRelation(
|
public static final XSSFRelation SHARED_STRINGS = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",
|
||||||
"/xl/sharedStrings.xml",
|
"/xl/sharedStrings.xml",
|
||||||
SharedStringsTable.class
|
SharedStringsTable.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation STYLES = new XSSFRelation(
|
public static final XSSFRelation STYLES = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
|
PackageRelationshipTypes.STYLE_PART,
|
||||||
"/xl/styles.xml",
|
"/xl/styles.xml",
|
||||||
StylesTable.class
|
StylesTable.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation DRAWINGS = new XSSFRelation(
|
public static final XSSFRelation DRAWINGS = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.drawing+xml",
|
"application/vnd.openxmlformats-officedocument.drawing+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
|
||||||
"/xl/drawings/drawing#.xml",
|
"/xl/drawings/drawing#.xml",
|
||||||
XSSFDrawing.class
|
XSSFDrawing.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation VML_DRAWINGS = new XSSFRelation(
|
public static final XSSFRelation VML_DRAWINGS = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.vmlDrawing",
|
"application/vnd.openxmlformats-officedocument.vmlDrawing",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
|
||||||
"/xl/drawings/vmlDrawing#.vml",
|
"/xl/drawings/vmlDrawing#.vml",
|
||||||
XSSFVMLDrawing.class
|
XSSFVMLDrawing.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation CHART = new XSSFRelation(
|
public static final XSSFRelation CHART = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
|
"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
|
||||||
@ -150,75 +160,84 @@ public final class XSSFRelation extends POIXMLRelation {
|
|||||||
|
|
||||||
public static final XSSFRelation IMAGES = new XSSFRelation(
|
public static final XSSFRelation IMAGES = new XSSFRelation(
|
||||||
null,
|
null,
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
null,
|
null,
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_EMF = new XSSFRelation(
|
public static final XSSFRelation IMAGE_EMF = new XSSFRelation(
|
||||||
"image/x-emf",
|
"image/x-emf",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.emf",
|
"/xl/media/image#.emf",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_WMF = new XSSFRelation(
|
public static final XSSFRelation IMAGE_WMF = new XSSFRelation(
|
||||||
"image/x-wmf",
|
"image/x-wmf",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.wmf",
|
"/xl/media/image#.wmf",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_PICT = new XSSFRelation(
|
public static final XSSFRelation IMAGE_PICT = new XSSFRelation(
|
||||||
"image/pict",
|
"image/pict",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.pict",
|
"/xl/media/image#.pict",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_JPEG = new XSSFRelation(
|
public static final XSSFRelation IMAGE_JPEG = new XSSFRelation(
|
||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.jpeg",
|
"/xl/media/image#.jpeg",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_PNG = new XSSFRelation(
|
public static final XSSFRelation IMAGE_PNG = new XSSFRelation(
|
||||||
"image/png",
|
"image/png",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.png",
|
"/xl/media/image#.png",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_DIB = new XSSFRelation(
|
public static final XSSFRelation IMAGE_DIB = new XSSFRelation(
|
||||||
"image/dib",
|
"image/dib",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.dib",
|
"/xl/media/image#.dib",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_GIF = new XSSFRelation(
|
public static final XSSFRelation IMAGE_GIF = new XSSFRelation(
|
||||||
"image/gif",
|
"image/gif",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.gif",
|
"/xl/media/image#.gif",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_TIFF = new XSSFRelation(
|
public static final XSSFRelation IMAGE_TIFF = new XSSFRelation(
|
||||||
"image/tiff",
|
"image/tiff",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.tiff",
|
"/xl/media/image#.tiff",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_EPS = new XSSFRelation(
|
public static final XSSFRelation IMAGE_EPS = new XSSFRelation(
|
||||||
"image/x-eps",
|
"image/x-eps",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.eps",
|
"/xl/media/image#.eps",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_BMP = new XSSFRelation(
|
public static final XSSFRelation IMAGE_BMP = new XSSFRelation(
|
||||||
"image/x-ms-bmp",
|
"image/x-ms-bmp",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.bmp",
|
"/xl/media/image#.bmp",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation IMAGE_WPG = new XSSFRelation(
|
public static final XSSFRelation IMAGE_WPG = new XSSFRelation(
|
||||||
"image/x-wpg",
|
"image/x-wpg",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
PackageRelationshipTypes.IMAGE_PART,
|
||||||
"/xl/media/image#.wpg",
|
"/xl/media/image#.wpg",
|
||||||
XSSFPictureData.class
|
XSSFPictureData.class
|
||||||
);
|
);
|
||||||
@ -229,18 +248,21 @@ public final class XSSFRelation extends POIXMLRelation {
|
|||||||
"/xl/comments#.xml",
|
"/xl/comments#.xml",
|
||||||
CommentsTable.class
|
CommentsTable.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation SHEET_HYPERLINKS = new XSSFRelation(
|
public static final XSSFRelation SHEET_HYPERLINKS = new XSSFRelation(
|
||||||
null,
|
null,
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
|
PackageRelationshipTypes.HYPERLINK_PART,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation OLEEMBEDDINGS = new XSSFRelation(
|
public static final XSSFRelation OLEEMBEDDINGS = new XSSFRelation(
|
||||||
null,
|
null,
|
||||||
POIXMLDocument.OLE_OBJECT_REL_TYPE,
|
POIXMLDocument.OLE_OBJECT_REL_TYPE,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation PACKEMBEDDINGS = new XSSFRelation(
|
public static final XSSFRelation PACKEMBEDDINGS = new XSSFRelation(
|
||||||
null,
|
null,
|
||||||
POIXMLDocument.PACK_OBJECT_REL_TYPE,
|
POIXMLDocument.PACK_OBJECT_REL_TYPE,
|
||||||
@ -254,30 +276,35 @@ public final class XSSFRelation extends POIXMLRelation {
|
|||||||
"/xl/vbaProject.bin",
|
"/xl/vbaProject.bin",
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation ACTIVEX_CONTROLS = new XSSFRelation(
|
public static final XSSFRelation ACTIVEX_CONTROLS = new XSSFRelation(
|
||||||
"application/vnd.ms-office.activeX+xml",
|
"application/vnd.ms-office.activeX+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control",
|
||||||
"/xl/activeX/activeX#.xml",
|
"/xl/activeX/activeX#.xml",
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation ACTIVEX_BINS = new XSSFRelation(
|
public static final XSSFRelation ACTIVEX_BINS = new XSSFRelation(
|
||||||
"application/vnd.ms-office.activeX",
|
"application/vnd.ms-office.activeX",
|
||||||
"http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary",
|
"http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary",
|
||||||
"/xl/activeX/activeX#.bin",
|
"/xl/activeX/activeX#.bin",
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation THEME = new XSSFRelation(
|
public static final XSSFRelation THEME = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.theme+xml",
|
"application/vnd.openxmlformats-officedocument.theme+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
|
||||||
"/xl/theme/theme#.xml",
|
"/xl/theme/theme#.xml",
|
||||||
ThemesTable.class
|
ThemesTable.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation CALC_CHAIN = new XSSFRelation(
|
public static final XSSFRelation CALC_CHAIN = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml",
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain",
|
||||||
"/xl/calcChain.xml",
|
"/xl/calcChain.xml",
|
||||||
CalculationChain.class
|
CalculationChain.class
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final XSSFRelation PRINTER_SETTINGS = new XSSFRelation(
|
public static final XSSFRelation PRINTER_SETTINGS = new XSSFRelation(
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings",
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings",
|
||||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings",
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings",
|
||||||
@ -311,7 +338,6 @@ public final class XSSFRelation extends POIXMLRelation {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get POIXMLRelation by relation type
|
* Get POIXMLRelation by relation type
|
||||||
*
|
*
|
||||||
|
@ -26,7 +26,6 @@ import static org.junit.Assert.fail;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.EncryptedDocumentException;
|
import org.apache.poi.EncryptedDocumentException;
|
||||||
@ -1414,30 +1413,31 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
* error message when called via WorkbookFactory.
|
* error message when called via WorkbookFactory.
|
||||||
* (You need to supply a password explicitly for them)
|
* (You need to supply a password explicitly for them)
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test(expected=EncryptedDocumentException.class)
|
||||||
public void bug55692() throws Exception {
|
public void bug55692_stream() throws Exception {
|
||||||
InputStream inpA = POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx");
|
|
||||||
InputStream inpB = POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx");
|
|
||||||
InputStream inpC = POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx");
|
|
||||||
|
|
||||||
// Directly on a Stream
|
// Directly on a Stream
|
||||||
try {
|
WorkbookFactory.create(POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));
|
||||||
WorkbookFactory.create(inpA);
|
}
|
||||||
fail("Should've raised a EncryptedDocumentException error");
|
|
||||||
} catch (EncryptedDocumentException e) {}
|
|
||||||
|
|
||||||
|
@Test(expected=EncryptedDocumentException.class)
|
||||||
|
public void bug55692_poifs() throws Exception {
|
||||||
// Via a POIFSFileSystem
|
// Via a POIFSFileSystem
|
||||||
POIFSFileSystem fsP = new POIFSFileSystem(inpB);
|
POIFSFileSystem fsP = new POIFSFileSystem(POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));
|
||||||
try {
|
|
||||||
WorkbookFactory.create(fsP);
|
WorkbookFactory.create(fsP);
|
||||||
fail("Should've raised a EncryptedDocumentException error");
|
}
|
||||||
} catch (EncryptedDocumentException e) {}
|
|
||||||
|
|
||||||
|
@Test(expected=EncryptedDocumentException.class)
|
||||||
|
public void bug55692_npoifs() throws Exception {
|
||||||
// Via a NPOIFSFileSystem
|
// Via a NPOIFSFileSystem
|
||||||
NPOIFSFileSystem fsNP = new NPOIFSFileSystem(inpC);
|
NPOIFSFileSystem fsNP = new NPOIFSFileSystem(POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));
|
||||||
try {
|
|
||||||
WorkbookFactory.create(fsNP);
|
WorkbookFactory.create(fsNP);
|
||||||
fail("Should've raised a EncryptedDocumentException error");
|
}
|
||||||
} catch (EncryptedDocumentException e) {}
|
|
||||||
|
@Test
|
||||||
|
public void bug53282() {
|
||||||
|
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53282b.xlsx");
|
||||||
|
Cell c = wb.getSheetAt(0).getRow(1).getCell(0);
|
||||||
|
assertEquals("#@_#", c.getStringCellValue());
|
||||||
|
assertEquals("http://invalid.uri", c.getHyperlink().getAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
test-data/spreadsheet/53282b.xlsx
Normal file
BIN
test-data/spreadsheet/53282b.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user