mirror of https://github.com/apache/poi.git
#62966 - init presetShapeDefinitions.xml fail under IBM jdk
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1848494 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dc3c437d14
commit
fba0181413
|
@ -27,12 +27,12 @@ import javax.xml.bind.JAXBElement;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
import javax.xml.stream.EventFilter;
|
import javax.xml.stream.EventFilter;
|
||||||
import javax.xml.stream.XMLEventReader;
|
|
||||||
import javax.xml.stream.XMLInputFactory;
|
import javax.xml.stream.XMLInputFactory;
|
||||||
|
import javax.xml.stream.XMLStreamConstants;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
import javax.xml.stream.XMLStreamReader;
|
import javax.xml.stream.XMLStreamReader;
|
||||||
import javax.xml.stream.events.StartElement;
|
|
||||||
import javax.xml.stream.events.XMLEvent;
|
import javax.xml.stream.events.XMLEvent;
|
||||||
|
import javax.xml.transform.stream.StreamSource;
|
||||||
|
|
||||||
import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;
|
import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;
|
||||||
import org.apache.poi.util.POILogFactory;
|
import org.apache.poi.util.POILogFactory;
|
||||||
|
@ -61,27 +61,30 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
|
||||||
};
|
};
|
||||||
|
|
||||||
XMLInputFactory staxFactory = StaxHelper.newXMLInputFactory();
|
XMLInputFactory staxFactory = StaxHelper.newXMLInputFactory();
|
||||||
XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
|
XMLStreamReader streamReader = staxFactory.createXMLStreamReader(new StreamSource(is));
|
||||||
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
|
try {
|
||||||
// ignore StartElement:
|
// ignore StartElement:
|
||||||
/* XMLEvent evDoc = */ staxFiltRd.nextEvent();
|
streamReader.nextTag();
|
||||||
// JAXB:
|
|
||||||
JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
|
|
||||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
|
||||||
|
|
||||||
long cntElem = 0;
|
// JAXB:
|
||||||
while (staxFiltRd.peek() != null) {
|
JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
|
||||||
StartElement evRoot = (StartElement)staxFiltRd.peek();
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
String name = evRoot.getName().getLocalPart();
|
|
||||||
JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class);
|
long cntElem = 0;
|
||||||
CTCustomGeometry2D cus = el.getValue();
|
while (streamReader.hasNext() && streamReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
|
||||||
cntElem++;
|
String name = streamReader.getLocalName();
|
||||||
|
JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(streamReader, CTCustomGeometry2D.class);
|
||||||
if(containsKey(name)) {
|
CTCustomGeometry2D cus = el.getValue();
|
||||||
LOG.log(POILogger.WARN, "Duplicate definition of " + name);
|
cntElem++;
|
||||||
|
|
||||||
|
if (containsKey(name)) {
|
||||||
|
LOG.log(POILogger.WARN, "Duplicate definition of " + name);
|
||||||
|
}
|
||||||
|
put(name, new CustomGeometry(cus));
|
||||||
}
|
}
|
||||||
put(name, new CustomGeometry(cus));
|
} finally {
|
||||||
}
|
streamReader.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue