throw HSLFException instead of RuntimeException
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@541267 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8d87bbd972
commit
ddef996756
@ -37,6 +37,7 @@ import org.apache.poi.hpsf.DocumentSummaryInformation;
|
||||
|
||||
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
|
||||
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
|
||||
@ -376,7 +377,7 @@ public class HSLFSlideShow extends POIDocument
|
||||
int oldLastUserEditAtomPos = (int)currentUser.getCurrentEditOffset();
|
||||
Integer newLastUserEditAtomPos = (Integer)oldToNewPositions.get(new Integer(oldLastUserEditAtomPos));
|
||||
if(newLastUserEditAtomPos == null) {
|
||||
throw new RuntimeException("Couldn't find the new location of the UserEditAtom that used to be at " + oldLastUserEditAtomPos);
|
||||
throw new HSLFException("Couldn't find the new location of the UserEditAtom that used to be at " + oldLastUserEditAtomPos);
|
||||
}
|
||||
currentUser.setCurrentEditOffset(newLastUserEditAtomPos.intValue());
|
||||
currentUser.writeToFS(outFS);
|
||||
|
@ -18,6 +18,7 @@ package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.Shape;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
@ -55,7 +56,7 @@ public class EMF extends Metafile {
|
||||
inflater.close();
|
||||
return out.toByteArray();
|
||||
} catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
throw new HSLFException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.Shape;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
import java.io.*;
|
||||
@ -56,7 +57,7 @@ public class PICT extends Metafile {
|
||||
out.write(pict);
|
||||
return out.toByteArray();
|
||||
} catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
throw new HSLFException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -45,7 +46,7 @@ public class PNG extends Bitmap {
|
||||
data = png;
|
||||
}
|
||||
} catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
throw new HSLFException(e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package org.apache.poi.hslf.blip;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.Shape;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
@ -60,7 +61,7 @@ public class WMF extends Metafile {
|
||||
inflater.close();
|
||||
return out.toByteArray();
|
||||
} catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
throw new HSLFException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +131,7 @@ public class WMF extends Metafile {
|
||||
public void read(byte[] data, int offset){
|
||||
int pos = offset;
|
||||
int key = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE; //header key
|
||||
if (key != APMHEADER_KEY) throw new RuntimeException("Not a valid WMF file");
|
||||
if (key != APMHEADER_KEY) throw new HSLFException("Not a valid WMF file");
|
||||
|
||||
handle = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
|
||||
left = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
|
||||
@ -143,7 +144,7 @@ public class WMF extends Metafile {
|
||||
|
||||
checksum = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
|
||||
if (checksum != getChecksum())
|
||||
throw new RuntimeException("WMF checksum does not match the header data");
|
||||
throw new HSLFException("WMF checksum does not match the header data");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,43 @@
|
||||
|
||||
/* ====================================================================
|
||||
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.hslf.exceptions;
|
||||
|
||||
/**
|
||||
* A generic exception that can be thrown by HSLF classes
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public class HSLFException extends RuntimeException {
|
||||
|
||||
public HSLFException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HSLFException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public HSLFException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public HSLFException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
@ -211,7 +212,7 @@ public class Fill {
|
||||
return pict[i];
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Picture data not found: \n" +
|
||||
throw new HSLFException("Picture data not found: \n" +
|
||||
" bse: " + bse + " at " + bse.getOffset() );
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.util.ArrayList;
|
||||
|
||||
import org.apache.poi.ddf.EscherProperties;
|
||||
import org.apache.poi.hslf.usermodel.RichTextRun;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
/**
|
||||
* Translates Graphics2D calls into PowerPoint.
|
||||
@ -252,43 +253,43 @@ public class PPGraphics2D extends Graphics2D {
|
||||
}
|
||||
//===============================================
|
||||
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawString(String str, int x, int y) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void fillOval(int x, int y, int width, int height) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void fillArc(int x, int y, int width, int height,
|
||||
int startAngle, int arcAngle) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void setPaintMode() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawArc(int x, int y, int width, int height,
|
||||
int startAngle, int arcAngle) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
public void drawPolyline(int xPoints[], int yPoints[],
|
||||
int nPoints) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public Graphics create() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawOval(int x, int y, int width, int height) {
|
||||
@ -308,21 +309,21 @@ public class PPGraphics2D extends Graphics2D {
|
||||
}
|
||||
|
||||
public void setXORMode(Color color1) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
public boolean drawImage(Image img, int x, int y,
|
||||
Color bgcolor,
|
||||
ImageObserver observer) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public boolean drawImage(Image img, int x, int y,
|
||||
int width, int height,
|
||||
Color bgcolor,
|
||||
ImageObserver observer) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
@ -330,7 +331,7 @@ public class PPGraphics2D extends Graphics2D {
|
||||
int dx1, int dy1, int dx2, int dy2,
|
||||
int sx1, int sy1, int sx2, int sy2,
|
||||
ImageObserver observer) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public boolean drawImage(Image img,
|
||||
@ -338,22 +339,22 @@ public class PPGraphics2D extends Graphics2D {
|
||||
int sx1, int sy1, int sx2, int sy2,
|
||||
Color bgcolor,
|
||||
ImageObserver observer) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public boolean drawImage(Image img, int x, int y,
|
||||
ImageObserver observer) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public boolean drawImage(Image img, int x, int y,
|
||||
int width, int height,
|
||||
ImageObserver observer) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawLine(int x1, int y1, int x2, int y2) {
|
||||
@ -369,61 +370,61 @@ public class PPGraphics2D extends Graphics2D {
|
||||
|
||||
public void fillPolygon(int xPoints[], int yPoints[],
|
||||
int nPoints) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public FontMetrics getFontMetrics(Font f) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void fillRect(int x, int y, int width, int height) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawPolygon(int xPoints[], int yPoints[],
|
||||
int nPoints) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void clipRect(int x, int y, int width, int height) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void setClip(Shape clip) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public java.awt.Rectangle getClipBounds() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawString(AttributedCharacterIterator iterator, int x, int y) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void clearRect(int x, int y, int width, int height) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void copyArea(int x, int y, int width, int height, int dx, int dy) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void setClip(int x, int y, int width, int height) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void rotate(double d) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
|
||||
}
|
||||
|
||||
public void rotate(double d, double d1, double d2) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void shear(double d, double d1) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public FontRenderContext getFontRenderContext() {
|
||||
@ -431,83 +432,83 @@ public class PPGraphics2D extends Graphics2D {
|
||||
}
|
||||
|
||||
public void transform(AffineTransform affinetransform) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawImage(BufferedImage bufferedimage, BufferedImageOp op, int x, int y) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void setBackground(Color c) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public Color getBackground() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void setComposite(Composite composite) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
|
||||
}
|
||||
|
||||
public Composite getComposite() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public Object getRenderingHint(java.awt.RenderingHints.Key key) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public boolean drawImage(Image image, AffineTransform affinetransform, ImageObserver imageobserver) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void setRenderingHint(java.awt.RenderingHints.Key key, Object obj) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
public void drawGlyphVector(GlyphVector g, float x, float y) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
|
||||
}
|
||||
|
||||
public GraphicsConfiguration getDeviceConfiguration() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void addRenderingHints(Map map) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void translate(double d, double d1) {
|
||||
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void drawString(AttributedCharacterIterator attributedcharacteriterator, float x, float y) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public boolean hit(java.awt.Rectangle rectangle, Shape shape, boolean flag) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public RenderingHints getRenderingHints() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
|
||||
public void setRenderingHints(Map map) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
|
||||
}
|
||||
|
||||
public void drawRenderableImage(RenderableImage renderableimage, AffineTransform affinetransform) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
throw new HSLFException("Not implemented");
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package org.apache.poi.hslf.model;
|
||||
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.record.OEPlaceholderAtom;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -80,7 +81,7 @@ public class Placeholder extends TextBox {
|
||||
try {
|
||||
oep.writeOut(out);
|
||||
} catch(Exception e){
|
||||
throw new RuntimeException(e);
|
||||
throw new HSLFException(e);
|
||||
}
|
||||
cldata.setRemainingData(out.toByteArray());
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
==================================================================== */
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@ -251,7 +253,7 @@ public class ShapeTypes {
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e){
|
||||
throw new RuntimeException("Failed to initialize shape types");
|
||||
throw new HSLFException("Failed to initialize shape types");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ package org.apache.poi.hslf.model;
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.RichTextRun;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.font.FontRenderContext;
|
||||
@ -193,7 +194,7 @@ public class TextBox extends SimpleShape {
|
||||
try {
|
||||
_txtbox.writeOut(null);
|
||||
} catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
throw new HSLFException(e);
|
||||
}
|
||||
if(getAnchor().equals(new java.awt.Rectangle())) resizeToFitText();
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package org.apache.poi.hslf.usermodel;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.blip.*;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
@ -121,7 +122,7 @@ public abstract class PictureData {
|
||||
try {
|
||||
sha = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e){
|
||||
throw new RuntimeException(e.getMessage());
|
||||
throw new HSLFException(e.getMessage());
|
||||
}
|
||||
sha.update(data);
|
||||
return sha.digest();
|
||||
|
@ -35,6 +35,7 @@ import org.apache.poi.hslf.model.Slide;
|
||||
import org.apache.poi.hslf.record.SlideListWithText.*;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.util.ArrayUtil;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
@ -739,7 +740,7 @@ public class SlideShow
|
||||
is.read(data);
|
||||
is.close();
|
||||
} catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
throw new HSLFException(e);
|
||||
}
|
||||
return addPicture(data, format);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user