-->
<!-- START - APPROVED EXCLUSIONS -->
+ <Match>
+ <Bug pattern="BC_BAD_CAST_TO_CONCRETE_COLLECTION"/>
+ <!-- TODO - Not sure what to do with those two... Seems messy/hacky -->
+ <And>
+ <Class name="org.apache.fop.area.AreaTreeObject"/>
+ <Method name="clone"/>
+ </And>
+ </Match>
+ <Match>
+ <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/>
+ <!-- TODO - See if these can be solved in a better way -->
+ <Or>
+ <And>
+ <Class name="org.apache.fop.layoutmgr.PageBreakingAlgorithm"/>
+ <Or>
+ <Method name="createFootnotePages"/>
+ <Method name="finish"/>
+ </Or>
+ </And>
+ <And>
+ <Class name="org.apache.fop.render.rtf.RTFHandler"/>
+ <Or>
+ <Method name="endCell"/>
+ <Method name="endFootnoteBody"/>
+ <Method name="endPart"/>
+ <Method name="endRow"/>
+ <Method name="startCell"/>
+ <Method name="startFootnoteBody"/>
+ <Method name="startListItem"/>
+ <Method name="startListLabel"/>
+ <Method name="startPart"/>
+ <Method name="startRow"/>
+ </Or>
+ </And>
+ </Or>
+ </Match>
<Match>
<Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
<Or>
dout.writeByte(a);
dout.writeByte(b);
} else {
- IOUtils.closeQuietly(dout);
IOUtils.closeQuietly(baout);
throw new IllegalStateException();
}
protected List<ExtensionAttachment> extensionAttachments;
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
public Object clone() throws CloneNotSupportedException {
AreaTreeObject ato = (AreaTreeObject) super.clone();
if (foreignAttributes != null) {
- ato.foreignAttributes = (Map) ((HashMap) foreignAttributes).clone();
+ // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION")
+ ato.foreignAttributes = (Map<QName, String>)
+ ((HashMap<QName, String>)foreignAttributes).clone();
}
if (extensionAttachments != null) {
- ato.extensionAttachments = (List) ((ArrayList) extensionAttachments).clone();
+ // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION")
+ ato.extensionAttachments = (List<ExtensionAttachment>)
+ ((ArrayList<ExtensionAttachment>) extensionAttachments).clone();
}
return ato;
}
@Override
protected void finish() {
for (int i = startLine; i < endLine; i++) {
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
for (KnuthPageNode node = (KnuthPageNode) getNode(i);
node != null;
node = (KnuthPageNode) node.next) {
// footnoteElementIndex has already been set in getFootnoteSplit()
} else {
// cannot add any content: create a new node and start again
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
KnuthPageNode node = (KnuthPageNode)
createNode(lastNode.position, prevNode.line + 1, 1,
insertedFootnotesLength - prevNode.insertedFootnotes,
}
}
// create the last node
+ // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
KnuthPageNode node = (KnuthPageNode)
createNode(lastNode.position, prevNode.line + 1, 1,
totalFootnotesLength - prevNode.insertedFootnotes, 0, 0,
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.area.Area;
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.AreaTreeModel;
import org.apache.fop.area.LineArea;
try {
ContentLayoutManager clm = getLayoutManagerMaker()
.makeContentLayoutManager(this, getPageSequence().getTitleFO());
- title = (LineArea) clm.getParentArea(null);
+ Area parentArea = clm.getParentArea(null);
+ assert (parentArea instanceof LineArea);
+ title = (LineArea) parentArea;
} catch (IllegalStateException e) {
// empty title; do nothing
}
* Each value holds the start and end indexes into a List of
* inline break positions.
*/
- private static class LineBreakPosition extends LeafPosition {
+ static class LineBreakPosition extends LeafPosition {
private final int parIndex; // index of the Paragraph this Position refers to
private final int startIndex; //index of the first element this Position refers to
private final int availableShrink;
keep.getContext(),
context));
}
- endIndex = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos();
+ endIndex = llPoss.getChosenPosition(i).getLeafPos();
// create a list of the FootnoteBodyLM handling footnotes
// whose citations are in this line
List<FootnoteBodyLayoutManager> footnoteList = FootenoteUtil.getFootnotes(
List<FloatContentLayoutManager> floats = FloatContentLayoutManager.checkForFloats(seq,
startIndex, endIndex);
startIndex = endIndex + 1;
- LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i);
+ LineBreakPosition lbp = llPoss.getChosenPosition(i);
if (baselineOffset < 0) {
baselineOffset = lbp.spaceBefore + lbp.baseline;
}
/** {@inheritDoc} */
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
- LeafPosition pos = (LeafPosition)lastElement.getPosition();
+ Position lastPos = lastElement.getPosition();
+ assert (lastPos instanceof LeafPosition);
+ LeafPosition pos = (LeafPosition) lastPos;
//if (lastElement.isPenalty()) {
// totalAdj += lastElement.getWidth();
//}
// null penalty allowing a page break between lines
returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
}
- LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i);
+ LineBreakPosition lbp = llPoss.getChosenPosition(i);
//log.debug("LLM.getChangedKnuthElements> lineWidth= "
// + lbp.lineWidth + " difference= " + lbp.difference);
//log.debug(" shrink= "
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.layoutmgr.Position;
-
/**
* Line layout possibilities.
*/
private final class Possibility {
private int lineCount;
private double demerits;
- private List breakPositions;
+ private List<LineLayoutManager.LineBreakPosition> breakPositions;
private Possibility(int lc, double dem) {
lineCount = lc;
demerits = dem;
- breakPositions = new java.util.ArrayList(lc);
+ breakPositions = new java.util.ArrayList<LineLayoutManager.LineBreakPosition>(lc);
}
private int getLineCount() {
return demerits;
}
- private void addBreakPosition(Position pos) {
+ private void addBreakPosition(LineLayoutManager.LineBreakPosition pos) {
// Positions are always added with index 0 because
// they are created backward, from the last one to
// the first one
breakPositions.add(0, pos);
}
- private Position getBreakPosition(int i) {
- return (Position)breakPositions.get(i);
+ private LineLayoutManager.LineBreakPosition getBreakPosition(int i) {
+ return breakPositions.get(i);
}
}
* @param pos a position
* @param i an index into posibilities list
*/
- public void addBreakPosition(Position pos, int i) {
+ public void addBreakPosition(LineLayoutManager.LineBreakPosition pos, int i) {
((Possibility)possibilitiesList.get(i)).addBreakPosition(pos);
}
* @param i the break position index
* @return the chosen position
*/
- public Position getChosenPosition(int i) {
+ public LineLayoutManager.LineBreakPosition getChosenPosition(int i) {
return ((Possibility)possibilitiesList.get(chosenIndex)).getBreakPosition(i);
}
*/
GlyphMapping lastMapping = null;
while (posIter.hasNext()) {
- final LeafPosition tbpNext = (LeafPosition) posIter.next();
+ Position nextPos = posIter.next();
+ assert (nextPos instanceof LeafPosition);
+ final LeafPosition tbpNext = (LeafPosition) nextPos;
if (tbpNext == null) {
continue; //Ignore elements without Positions
}
ListIterator oldListIterator = oldList.listIterator();
KnuthElement knuthElement = (KnuthElement) oldListIterator.next();
Position pos = knuthElement.getPosition();
- LeafPosition leafPos = (LeafPosition) pos.getPosition(depth);
+ Position innerPosition = pos.getPosition(depth);
+ assert (innerPosition instanceof LeafPosition);
+ LeafPosition leafPos = (LeafPosition) innerPosition;
int index = leafPos.getLeafPos();
//element could refer to '-1' position, for non-collapsed spaces (?)
if (index > -1) {
ListIterator oldListIter;
for (oldListIter = oldList.listIterator(); oldListIter.hasNext();) {
Position pos = ((KnuthElement) oldListIter.next()).getPosition();
- startPos = (LeafPosition) pos.getPosition(depth);
+ Position innerPosition = pos.getPosition(depth);
+ assert (innerPosition == null || innerPosition instanceof LeafPosition);
+ startPos = (LeafPosition) innerPosition;
if (startPos != null && startPos.getLeafPos() != -1) {
break;
}
}
for (oldListIter = oldList.listIterator(oldList.size()); oldListIter.hasPrevious();) {
Position pos = ((KnuthElement) oldListIter.previous()).getPosition();
- endPos = (LeafPosition) pos.getPosition(depth);
+ Position innerPosition = pos.getPosition(depth);
+ assert (innerPosition instanceof LeafPosition);
+ endPos = (LeafPosition) innerPosition;
if (endPos != null && endPos.getLeafPos() != -1) {
break;
}
} else {
borderAfterWhich = ConditionalBorder.REST;
}
+ assert (currentGU instanceof EmptyGridUnit);
addAreaForEmptyGridUnit((EmptyGridUnit)currentGU,
currentRow.getIndex(), i,
actualRowHeight,
for (int i = 0; i < columnCount; i++) {
GridUnit gu = row.getGridUnit(i);
if (!gu.isEmpty() && gu.isPrimary()) {
+ assert (gu instanceof PrimaryGridUnit);
activeCellList.add(new ActiveCell((PrimaryGridUnit) gu, row, rowIndex,
previousRowsLength, getTableLM()));
}
startVParea(regionReference.getCTM(), port.getClipRectangle());
// do after starting viewport area
if (regionReference.getRegionClass() == FO_REGION_BODY) {
+ assert (regionReference instanceof BodyRegion);
renderBodyRegion((BodyRegion) regionReference);
} else {
renderRegion(regionReference);
import org.apache.fop.afp.AFPResourceInfo;
import org.apache.fop.afp.AFPUnitConverter;
import org.apache.fop.render.ImageHandlerBase;
+import org.apache.fop.render.RendererContext;
/**
* A base abstract AFP image handler
(int)Math.round(position.getWidth()),
(int)Math.round(position.getHeight()));
- AFPRendererContext rendererContext
- = (AFPRendererContext)rendererImageInfo.getRendererContext();
+ RendererContext context = rendererImageInfo.getRendererContext();
+ assert (context instanceof AFPRendererContext);
+ AFPRendererContext rendererContext = (AFPRendererContext) context;
AFPInfo afpInfo = rendererContext.getInfo();
AFPPaintingState paintingState = afpInfo.getPaintingState();
throws IOException {
AFPRenderingContext afpContext = (AFPRenderingContext)context;
- AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();
+ AFPDataObjectInfo info = createDataObjectInfo();
+ assert (info instanceof AFPGraphicsObjectInfo);
+ AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo) info;
// set resource information
throws IOException {
AFPRenderingContext afpContext = (AFPRenderingContext)context;
- AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
+ AFPDataObjectInfo info = createDataObjectInfo();
+ assert (info instanceof AFPImageObjectInfo);
+ AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo) info;
AFPPaintingState paintingState = afpContext.getPaintingState();
// set resource information
throws IOException {
AFPRenderingContext afpContext = (AFPRenderingContext)context;
- AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
+ AFPDataObjectInfo info = createDataObjectInfo();
+ assert (info instanceof AFPImageObjectInfo);
+ AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo) info;
AFPPaintingState paintingState = afpContext.getPaintingState();
// set resource information
ImageXMLDOM imageSVG = (ImageXMLDOM)image;
FOUserAgent userAgent = afpContext.getUserAgent();
- AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();
+ AFPDataObjectInfo info = createDataObjectInfo();
+ assert (info instanceof AFPGraphicsObjectInfo);
+ AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo) info;
AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo();
setDefaultToInlineResourceLevel(graphicsObjectInfo);
public class ImageProxyPanel extends JPanel {
/** The reference to the BufferedImage storing the page data */
- private Reference imageRef;
+ private transient Reference imageRef;
/** The maximum and preferred size of the panel */
private Dimension size;
transformer.transform(src, res);
} catch (TransformerException te) {
+ Throwable cause = te.getCause();
//Unpack original IFException if applicable
- if (te.getCause() instanceof SAXException) {
- SAXException se = (SAXException)te.getCause();
- if (se.getCause() instanceof IFException) {
- throw (IFException)se.getCause();
+ if (cause instanceof SAXException) {
+ SAXException se = (SAXException) cause;
+ cause = se.getCause();
+ if (cause instanceof IFException) {
+ throw (IFException) cause;
}
- } else if (te.getCause() instanceof IFException) {
- throw (IFException)te.getCause();
+ } else if (cause instanceof IFException) {
+ throw (IFException) cause;
}
throw te;
}
}
private void handleIFException(IFException ife) throws SAXException {
- if (ife.getCause() instanceof SAXException) {
+ Throwable cause = ife.getCause();
+ if (cause instanceof SAXException) {
//unwrap
- throw (SAXException)ife.getCause();
+ throw (SAXException) cause;
} else {
//wrap
throw new SAXException(ife);
}
private void handleIFExceptionWithIOException(IFException ife) throws IOException {
- if (ife.getCause() instanceof IOException) {
- throw (IOException)ife.getCause();
+ Throwable cause = ife.getCause();
+ if (cause instanceof IOException) {
+ throw (IOException) cause;
} else {
handleIFException(ife);
}
String s = word.getWord();
int[][] dp = word.getGlyphPositionAdjustments();
+ Area parentArea = word.getParentArea();
+ assert (parentArea instanceof AbstractTextArea);
if (dp == null) {
renderTextWithAdjustments(s, word.getLetterAdjustArray(), word.isReversed(),
- font, (AbstractTextArea)word.getParentArea());
+ font, (AbstractTextArea) parentArea);
} else if (IFUtil.isDPOnlyDX(dp)) {
renderTextWithAdjustments(s, IFUtil.convertDPToDX(dp), word.isReversed(),
- font, (AbstractTextArea)word.getParentArea());
+ font, (AbstractTextArea) parentArea);
} else {
renderTextWithAdjustments(s, dp, word.isReversed(),
- font, (AbstractTextArea)word.getParentArea());
+ font, (AbstractTextArea) parentArea);
}
super.renderWord(word);
Font font = getFontFromArea(space.getParentArea());
String s = space.getSpace();
- AbstractTextArea textArea = (AbstractTextArea)space.getParentArea();
+ Area parentArea = space.getParentArea();
+ assert (parentArea instanceof AbstractTextArea);
+ AbstractTextArea textArea = (AbstractTextArea) parentArea;
renderTextWithAdjustments(s, (int[]) null, false, font, textArea);
/* COMBINED is always false
} else if (type == PDFObjectType.Number) {
array.add(new PDFNumber(entry.getValueAsNumber()));
} else if (type == PDFObjectType.Reference) {
+ assert (entry instanceof PDFReferenceExtension);
array.add(resolveReference((PDFReferenceExtension) entry));
} else if (type == PDFObjectType.String) {
array.add(entry.getValue());
} else if (type == PDFObjectType.Number) {
dictionary.put(key, new PDFNumber(entry.getValueAsNumber()));
} else if (type == PDFObjectType.Reference) {
+ assert (entry instanceof PDFReferenceExtension);
dictionary.put(key, resolveReference((PDFReferenceExtension) entry));
} else if (type == PDFObjectType.String) {
dictionary.put(key, entry.getValue());
}
public PDFArrayExtension getArrayExtension() {
- assert getExtension() instanceof PDFArrayExtension;
- return (PDFArrayExtension) getExtension();
+ PDFCollectionEntryExtension extension = getExtension();
+ assert (extension instanceof PDFArrayExtension);
+ return (PDFArrayExtension) extension;
}
@Override
}
public PDFDictionaryExtension getDictionaryExtension() {
- assert getExtension() instanceof PDFDictionaryExtension;
- return (PDFDictionaryExtension) getExtension();
+ PDFCollectionEntryExtension extension = getExtension();
+ assert extension instanceof PDFDictionaryExtension;
+ return (PDFDictionaryExtension) extension;
}
@Override
} else if (refid.length() == 0) {
invalidPropertyValueError(ATT_REFID, refid, null);
} else {
- ((PDFReferenceExtension) getExtension()).setReferenceId(refid);
+ PDFCollectionEntryExtension extension = getExtension();
+ assert (extension instanceof PDFReferenceExtension);
+ ((PDFReferenceExtension) extension).setReferenceId(refid);
}
}
}
renderRegion(region);
endElement("regionStart");
} else if (region.getRegionClass() == FO_REGION_BODY) {
- BodyRegion body = (BodyRegion)region;
+ assert (region instanceof BodyRegion);
+ BodyRegion body = (BodyRegion) region;
if (body.getColumnCount() != 1) {
addAttribute("columnGap", body.getColumnGap());
addAttribute("columnCount", body.getColumnCount());
resourceContext.addXObject(imageInfo);
} else {
Raster r = pctx.getRaster(devX, devY, devW, devH);
- WritableRaster wr = (WritableRaster)r;
+ assert (r instanceof WritableRaster);
+ WritableRaster wr = (WritableRaster) r;
wr = wr.createWritableTranslatedChild(0, 0);
ColorModel pcm = pctx.getColorModel();