mirror of https://github.com/apache/poi.git
Introduce an OldVisioFormatException similar to other file-types
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897321 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
16a24ecd79
commit
9a0933b04e
|
@ -14,11 +14,11 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.hdgf.chunks;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.poi.hdgf.exceptions.OldVisioFormatException;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ public abstract class ChunkHeader {
|
|||
} else {
|
||||
ch = new ChunkHeaderV6();
|
||||
}
|
||||
ch.setType((int)LittleEndian.getUInt(data, offset + 0));
|
||||
ch.setType((int)LittleEndian.getUInt(data, offset));
|
||||
ch.setId((int)LittleEndian.getUInt(data, offset + 4));
|
||||
ch.setUnknown1((int)LittleEndian.getUInt(data, offset + 8));
|
||||
ch.setLength((int)LittleEndian.getUInt(data, offset + 12));
|
||||
|
@ -58,7 +58,7 @@ public abstract class ChunkHeader {
|
|||
} else if(documentVersion == 5 || documentVersion == 4) {
|
||||
ChunkHeaderV4V5 ch = new ChunkHeaderV4V5();
|
||||
|
||||
ch.setType(LittleEndian.getShort(data, offset + 0));
|
||||
ch.setType(LittleEndian.getShort(data, offset));
|
||||
ch.setId(LittleEndian.getShort(data, offset + 2));
|
||||
ch.setUnknown2(LittleEndian.getUByte(data, offset + 4));
|
||||
ch.setUnknown3(LittleEndian.getUByte(data, offset + 5));
|
||||
|
@ -67,7 +67,7 @@ public abstract class ChunkHeader {
|
|||
|
||||
return ch;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Visio files with versions below 4 are not supported, yours was " + documentVersion);
|
||||
throw new OldVisioFormatException("Visio files with versions below 4 are not supported, yours was " + documentVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.hdgf.exceptions;
|
||||
|
||||
import org.apache.poi.OldFileFormatException;
|
||||
|
||||
public class OldVisioFormatException extends OldFileFormatException {
|
||||
public OldVisioFormatException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
|
@ -14,9 +14,9 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.hdgf.pointers;
|
||||
|
||||
import org.apache.poi.hdgf.exceptions.OldVisioFormatException;
|
||||
import org.apache.poi.hdgf.streams.PointerContainingStream;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
@ -43,7 +43,7 @@ public final class PointerFactory {
|
|||
Pointer p;
|
||||
if(version >= 6) {
|
||||
p = new PointerV6();
|
||||
p.setType(LittleEndian.getInt(data, offset+0));
|
||||
p.setType(LittleEndian.getInt(data, offset));
|
||||
p.setAddress((int)LittleEndian.getUInt(data, offset+4));
|
||||
p.setOffset((int)LittleEndian.getUInt(data, offset+8));
|
||||
p.setLength((int)LittleEndian.getUInt(data, offset+12));
|
||||
|
@ -52,7 +52,7 @@ public final class PointerFactory {
|
|||
return p;
|
||||
} else if(version == 5) {
|
||||
p = new PointerV5();
|
||||
p.setType(LittleEndian.getShort(data, offset+0));
|
||||
p.setType(LittleEndian.getShort(data, offset));
|
||||
p.setFormat(LittleEndian.getShort(data, offset+2));
|
||||
p.setAddress((int)LittleEndian.getUInt(data, offset+4));
|
||||
p.setOffset((int)LittleEndian.getUInt(data, offset+8));
|
||||
|
@ -60,7 +60,7 @@ public final class PointerFactory {
|
|||
|
||||
return p;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Visio files with versions below 5 are not supported, yours was " + version);
|
||||
throw new OldVisioFormatException("Visio files with versions below 5 are not supported, yours was " + version);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue