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;
/**
} 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));
} 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));
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);
}
}
--- /dev/null
+/* ====================================================================
+ 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);
+ }
+}
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;
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));
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));
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);
}
}