mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
#64716 - wmf display error - use FileMagic also for File-based input
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1881838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
997b95a4f8
commit
8eefca1bfe
@ -362,46 +362,42 @@ public final class PPTX2PNG {
|
||||
}
|
||||
}
|
||||
|
||||
private interface ProxyConsumer {
|
||||
void parse(MFProxy proxy) throws IOException;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"resource", "squid:S2095"})
|
||||
private MFProxy initProxy(File file) throws IOException {
|
||||
MFProxy proxy;
|
||||
final String fileName = file.getName().toLowerCase(Locale.ROOT);
|
||||
FileMagic fm;
|
||||
ProxyConsumer con;
|
||||
if ("stdin".equals(fileName)) {
|
||||
InputStream bis = FileMagic.prepareToCheckMagic(System.in);
|
||||
FileMagic fm = FileMagic.valueOf(bis);
|
||||
if (fm == FileMagic.UNKNOWN) {
|
||||
fm = defaultFileType;
|
||||
}
|
||||
switch (fm) {
|
||||
case EMF:
|
||||
proxy = new EMFHandler();
|
||||
break;
|
||||
case WMF:
|
||||
proxy = new WMFHandler();
|
||||
break;
|
||||
default:
|
||||
proxy = new PPTHandler();
|
||||
break;
|
||||
}
|
||||
proxy.setIgnoreParse(ignoreParse);
|
||||
proxy.setQuite(quiet);
|
||||
proxy.parse(bis);
|
||||
fm = FileMagic.valueOf(bis);
|
||||
con = (p) -> p.parse(bis);
|
||||
} else {
|
||||
switch (fileName.contains(".") ? fileName.substring(fileName.lastIndexOf('.')) : "") {
|
||||
case ".emf":
|
||||
proxy = new EMFHandler();
|
||||
break;
|
||||
case ".wmf":
|
||||
proxy = new WMFHandler();
|
||||
break;
|
||||
default:
|
||||
proxy = new PPTHandler();
|
||||
break;
|
||||
}
|
||||
proxy.setIgnoreParse(ignoreParse);
|
||||
proxy.setQuite(quiet);
|
||||
proxy.parse(file);
|
||||
fm = FileMagic.valueOf(file);
|
||||
con = (p) -> p.parse(file);
|
||||
}
|
||||
|
||||
if (fm == FileMagic.UNKNOWN) {
|
||||
fm = defaultFileType;
|
||||
}
|
||||
switch (fm) {
|
||||
case EMF:
|
||||
proxy = new EMFHandler();
|
||||
break;
|
||||
case WMF:
|
||||
proxy = new WMFHandler();
|
||||
break;
|
||||
default:
|
||||
proxy = new PPTHandler();
|
||||
break;
|
||||
}
|
||||
proxy.setIgnoreParse(ignoreParse);
|
||||
proxy.setQuite(quiet);
|
||||
con.parse(proxy);
|
||||
proxy.setDefaultCharset(charset);
|
||||
|
||||
return proxy;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user