diff options
author | Glenn Adams <gadams@apache.org> | 2012-04-08 23:48:11 +0000 |
---|---|---|
committer | Glenn Adams <gadams@apache.org> | 2012-04-08 23:48:11 +0000 |
commit | 279a59e164a87e527e89b283424c394adb254a65 (patch) | |
tree | f67ff7f24de2b48399988f6d0408f4992e3aee29 /src/java/org/apache | |
parent | 92ca968f8c1bb90a6b6110c589c0484e08323ca4 (diff) | |
download | xmlgraphics-fop-279a59e164a87e527e89b283424c394adb254a65.tar.gz xmlgraphics-fop-279a59e164a87e527e89b283424c394adb254a65.zip |
Bugzilla #49754: Bring clone() in line with the recommendations in Object.clone().
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1311120 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
20 files changed, 150 insertions, 112 deletions
diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java index ce9d9638c..240a0ab10 100644 --- a/src/java/org/apache/fop/area/Area.java +++ b/src/java/org/apache/fop/area/Area.java @@ -21,6 +21,7 @@ package org.apache.fop.area; import java.io.Serializable; import java.util.Map; +import java.util.TreeMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -116,9 +117,9 @@ public class Area extends AreaTreeObject implements Serializable { protected int bidiLevel = -1; /** - * Traits for this area stored in a HashMap + * Traits for this area. */ - protected transient Map<Integer, Object> traits = null; + protected TreeMap<Integer, Object> traits; /** * logging instance @@ -134,6 +135,15 @@ public class Area extends AreaTreeObject implements Serializable { return this.areaClass; } + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + Area area = (Area) super.clone(); + if (traits != null) { + area.traits = (TreeMap<Integer, Object>) traits.clone(); + } + return area; + } + /** * Set the area class of this area. * @@ -390,10 +400,9 @@ public class Area extends AreaTreeObject implements Serializable { * @param prop the value of the trait */ public void addTrait(Integer traitCode, Object prop) { - // use treemap instead of hashmap since the typical number - // of traits are less than four + // use treemap since the typical number of traits are less than four if (traits == null) { - traits = new java.util.TreeMap<Integer, Object>(); + traits = new TreeMap<Integer, Object>(); } traits.put(traitCode, prop); } @@ -405,7 +414,7 @@ public class Area extends AreaTreeObject implements Serializable { */ public void setTraits ( Map traits ) { if ( traits != null ) { - this.traits = new java.util.TreeMap ( traits ); + this.traits = new TreeMap<Integer, Object>( traits ); } else { this.traits = null; } diff --git a/src/java/org/apache/fop/area/AreaTreeObject.java b/src/java/org/apache/fop/area/AreaTreeObject.java index ebd88b887..91e76c3d4 100644 --- a/src/java/org/apache/fop/area/AreaTreeObject.java +++ b/src/java/org/apache/fop/area/AreaTreeObject.java @@ -19,7 +19,9 @@ package org.apache.fop.area; +import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,7 +32,7 @@ import org.apache.fop.fo.extensions.ExtensionAttachment; /** * Abstract base class for all area tree objects. */ -public abstract class AreaTreeObject { +public abstract class AreaTreeObject implements Cloneable { /** Foreign attributes */ protected Map<QName, String> foreignAttributes = null; @@ -38,6 +40,18 @@ public abstract class AreaTreeObject { /** Extension attachments */ protected List<ExtensionAttachment> extensionAttachments = null; + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + AreaTreeObject ato = (AreaTreeObject) super.clone(); + if (foreignAttributes != null) { + ato.foreignAttributes = (Map) ((HashMap) foreignAttributes).clone(); + } + if (extensionAttachments != null) { + ato.extensionAttachments = (List) ((ArrayList) extensionAttachments).clone(); + } + return ato; + } + /** * Sets a foreign attribute. * @param name the qualified name of the attribute @@ -45,7 +59,7 @@ public abstract class AreaTreeObject { */ public void setForeignAttribute(QName name, String value) { if (this.foreignAttributes == null) { - this.foreignAttributes = new java.util.HashMap<QName, String>(); + this.foreignAttributes = new HashMap<QName, String>(); } this.foreignAttributes.put(name, value); } @@ -88,7 +102,7 @@ public abstract class AreaTreeObject { private void prepareExtensionAttachmentContainer() { if (this.extensionAttachments == null) { - this.extensionAttachments = new java.util.ArrayList<ExtensionAttachment>(); + this.extensionAttachments = new ArrayList<ExtensionAttachment>(); } } diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index 2fd0b014b..61de7852b 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -151,19 +151,11 @@ public class BodyRegion extends RegionReference { } } - /** - * Clone this object. - * - * @return a shallow copy of this object - */ - public Object clone() { - BodyRegion br = new BodyRegion(getRegionClass(), getRegionName(), regionViewport, - getColumnCount(), getColumnGap()); - br.setCTM(getCTM()); - br.setIPD(getIPD()); - br.beforeFloat = beforeFloat; - br.mainReference = mainReference; - br.footnote = footnote; + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + BodyRegion br = (BodyRegion) super.clone(); + br.mainReference = new MainReference(br); return br; } + } diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index 9bf670a0e..209476199 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -54,7 +54,7 @@ import static org.apache.fop.fo.Constants.FO_REGION_START; * The page is cloneable so the page master can make copies of * the top level page and regions. */ -public class Page extends AreaTreeObject implements Serializable, Cloneable { +public class Page extends AreaTreeObject implements Serializable { private static final long serialVersionUID = 6272157047421543866L; @@ -72,10 +72,9 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { private boolean fakeNonEmpty = false; /** - * Empty constructor, for cloning + * Empty constructor */ - public Page() { - } + public Page() { } /** * Constructor @@ -258,14 +257,9 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { } } - /** - * Clone this page. - * This returns a new page with a clone of all the regions. - * - * @return a new clone of this page - */ - public Object clone() { - Page p = new Page(); + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + Page p = (Page) super.clone(); if (regionBefore != null) { p.regionBefore = (RegionViewport)regionBefore.clone(); } diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index 9ec46a53d..f38964ebc 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -32,6 +32,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.apps.FOPException; import org.apache.fop.fo.flow.Marker; import org.apache.fop.fo.pagination.SimplePageMaster; import org.apache.fop.traits.WritingModeTraitsGetter; @@ -50,7 +51,7 @@ import static org.apache.fop.fo.Constants.FO_REGION_BODY; * This is the level that creates the page. * The page (reference area) is then rendered inside the page object */ -public class PageViewport extends AreaTreeObject implements Resolvable, Cloneable { +public class PageViewport extends AreaTreeObject implements Resolvable { private Page page; private Rectangle viewArea; @@ -130,8 +131,9 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl /** * Copy constructor. * @param original the original PageViewport to copy from + * @throws FOPException when cloning of the page is not supported */ - public PageViewport(PageViewport original) { + public PageViewport(PageViewport original) throws FOPException { if (original.extensionAttachments != null) { setExtensionAttachments(original.extensionAttachments); } @@ -141,7 +143,11 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl this.pageIndex = original.pageIndex; this.pageNumber = original.pageNumber; this.pageNumberString = original.pageNumberString; - this.page = (Page)original.page.clone(); + try { + this.page = (Page) original.page.clone(); + } catch (CloneNotSupportedException e) { + throw new FOPException(e); + } this.viewArea = new Rectangle(original.viewArea); this.simplePageMasterName = original.simplePageMasterName; this.blank = original.blank; @@ -557,13 +563,12 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl } } - /** - * Clone this page. - * Used by the page master to create a copy of an original page. - * @return a copy of this page and associated viewports - */ - public Object clone() { - return new PageViewport(this); + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + PageViewport pvp = (PageViewport) super.clone(); + pvp.page = (Page) page.clone(); + pvp.viewArea = (Rectangle) viewArea.clone(); + return pvp; } /** diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java index 4158f924a..e6b46fee4 100644 --- a/src/java/org/apache/fop/area/RegionReference.java +++ b/src/java/org/apache/fop/area/RegionReference.java @@ -29,7 +29,7 @@ import org.apache.fop.fo.pagination.Region; * This area is the direct child of a region-viewport-area. It is cloneable * so the page master can make copies from the original page and regions. */ -public class RegionReference extends Area implements Cloneable { +public class RegionReference extends Area { private static final long serialVersionUID = -298980963268244238L; @@ -134,17 +134,10 @@ public class RegionReference extends Area implements Cloneable { addChildArea(block); } - /** - * Clone this region. - * This is used when cloning the page by the page master. - * - * @return a copy of this region reference area - */ - public Object clone() { - RegionReference rr = new RegionReference(regionClass, regionName, regionViewport); - rr.ctm = ctm; - rr.setIPD(getIPD()); - rr.blocks = (ArrayList<Area>)blocks.clone(); + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + RegionReference rr = (RegionReference) super.clone(); + rr.blocks = (ArrayList) blocks.clone(); return rr; } diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java index 093b891bc..1b1c5ae7d 100644 --- a/src/java/org/apache/fop/area/RegionViewport.java +++ b/src/java/org/apache/fop/area/RegionViewport.java @@ -22,7 +22,6 @@ package org.apache.fop.area; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.IOException; -import java.util.HashMap; import java.util.TreeMap; import org.apache.fop.traits.WritingModeTraitsGetter; @@ -33,7 +32,7 @@ import org.apache.fop.traits.WritingModeTraitsGetter; * region-reference-area as its child. These areas are described * in the fo:region-body description in the XSL Recommendation. */ -public class RegionViewport extends Area implements Cloneable, Viewport { +public class RegionViewport extends Area implements Viewport { private static final long serialVersionUID = 505781815165102572L; @@ -122,21 +121,11 @@ public class RegionViewport extends Area implements Cloneable, Viewport { setRegionReference((RegionReference) in.readObject()); } - /** - * Clone this region viewport. - * Used when creating a copy from the page master. - * - * @return a new copy of this region viewport - */ - public Object clone() { - RegionViewport rv = new RegionViewport((Rectangle2D)viewArea.clone()); - rv.regionReference = (RegionReference)regionReference.clone(); - if (traits != null) { - rv.traits = new TreeMap(traits); - } - if (foreignAttributes != null) { - rv.foreignAttributes = new HashMap(foreignAttributes); - } + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + RegionViewport rv = (RegionViewport) super.clone(); + rv.regionReference = (RegionReference) regionReference.clone(); + rv.viewArea = (Rectangle2D) viewArea.clone(); return rv; } diff --git a/src/java/org/apache/fop/hyphenation/CharVector.java b/src/java/org/apache/fop/hyphenation/CharVector.java index e957be87e..de95a7699 100644 --- a/src/java/org/apache/fop/hyphenation/CharVector.java +++ b/src/java/org/apache/fop/hyphenation/CharVector.java @@ -101,9 +101,9 @@ public class CharVector implements Cloneable, Serializable { } /** {@inheritDoc} */ - public Object clone() { - CharVector cv = new CharVector((char[])array.clone(), blockSize); - cv.n = this.n; + public Object clone() throws CloneNotSupportedException { + CharVector cv = (CharVector) super.clone(); + cv.array = (char[])array.clone(); return cv; } diff --git a/src/java/org/apache/fop/hyphenation/TernaryTree.java b/src/java/org/apache/fop/hyphenation/TernaryTree.java index 2a9b7705d..04def1927 100644 --- a/src/java/org/apache/fop/hyphenation/TernaryTree.java +++ b/src/java/org/apache/fop/hyphenation/TernaryTree.java @@ -48,7 +48,7 @@ import java.util.Stack; * patterns which will be keys in this tree. The strings patterns * are usually small (from 2 to 5 characters), but each char in the * tree is stored in a node. Thus memory usage is the main concern. - * We will sacrify 'elegance' to keep memory requirenments to the + * We will sacrify 'elegance' to keep memory requirements to the * minimum. Using java's char type as pointer (yes, I know pointer * it is a forbidden word in java) we can keep the size of the node * to be just 8 bytes (3 pointers and the data char). This gives @@ -406,16 +406,13 @@ public class TernaryTree implements Cloneable, Serializable { } /** {@inheritDoc} */ - public Object clone() { - TernaryTree t = new TernaryTree(); + public Object clone() throws CloneNotSupportedException { + TernaryTree t = (TernaryTree) super.clone(); t.lo = (char[])this.lo.clone(); t.hi = (char[])this.hi.clone(); t.eq = (char[])this.eq.clone(); t.sc = (char[])this.sc.clone(); t.kv = (CharVector)this.kv.clone(); - t.root = this.root; - t.freenode = this.freenode; - t.length = this.length; return t; } diff --git a/src/java/org/apache/fop/render/awt/AWTRenderer.java b/src/java/org/apache/fop/render/awt/AWTRenderer.java index c36655204..826dde233 100644 --- a/src/java/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/java/org/apache/fop/render/awt/AWTRenderer.java @@ -103,8 +103,9 @@ public class AWTRenderer extends Java2DRenderer implements Pageable { /** * {@inheritDoc} + * @throws FOPException thrown by java2DRenderer */ - public void renderPage(PageViewport pageViewport) throws IOException { + public void renderPage(PageViewport pageViewport) throws IOException, FOPException { super.renderPage(pageViewport); if (statusListener != null) { diff --git a/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java b/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java index 6e431e513..8c3f998a9 100644 --- a/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java +++ b/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java @@ -22,7 +22,7 @@ package org.apache.fop.render.intermediate; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.geom.AffineTransform; -import java.util.List; +import java.util.ArrayList; import org.apache.xmlgraphics.java2d.GraphicContext; @@ -33,7 +33,7 @@ public class IFGraphicContext extends GraphicContext { private static final AffineTransform[] EMPTY_TRANSFORM_ARRAY = new AffineTransform[0]; - private List groupList = new java.util.ArrayList(); + private ArrayList groupList = new ArrayList(); /** * Default constructor. @@ -48,17 +48,20 @@ public class IFGraphicContext extends GraphicContext { */ protected IFGraphicContext(IFGraphicContext graphicContext) { super(graphicContext); - //We don't clone groupDepth! + // N.B. do not perform deep copy on groupList; doing so causes + // a junit regression... have not investigated cause... [GA] + // groupList = (ArrayList) graphicContext.groupList.clone(); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ public Object clone() { - return new IFGraphicContext(this); + return new IFGraphicContext ( this ); } /** @param group a group */ public void pushGroup(Group group) { - //this.groupDepth++; this.groupList.add(group); for (int i = 0, c = group.getTransforms().length; i < c; i++) { transform(group.getTransforms()[i]); diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index 45c91b2ee..8b60df746 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -267,10 +267,15 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem * @param pageViewport the <code>PageViewport</code> object supplied by * the Area Tree * @throws IOException In case of an I/O error + * @throws FOPException if cloning of pageViewport is not supported * @see org.apache.fop.render.Renderer */ - public void renderPage(PageViewport pageViewport) throws IOException { - rememberPage((PageViewport)pageViewport.clone()); + public void renderPage(PageViewport pageViewport) throws IOException, FOPException { + try { + rememberPage((PageViewport)pageViewport.clone()); + } catch (CloneNotSupportedException e) { + throw new FOPException(e); + } //The clone() call is necessary as we store the page for later. Otherwise, the //RenderPagesModel calls PageViewport.clear() to release memory as early as possible. currentPageNumber++; diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextContainer.java index 5d0ab30d8..4a7779cc4 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextContainer.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextContainer.java @@ -28,6 +28,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; import java.io.IOException; +import org.apache.fop.apps.FOPException; + /** * <p>Interface for RtfElements that can contain RtfText elements.</p> * @@ -61,6 +63,7 @@ public interface IRtfTextContainer { /** * Text containers usually provide default attributes for all texts that they contain. * @return a copy of the container's attributes. + * @throws FOPException if attributes cannot be obtained */ - RtfAttributes getTextContainerAttributes(); + RtfAttributes getTextContainerAttributes() throws FOPException; } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java index b5d4db114..f1f25f3b4 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java @@ -39,8 +39,8 @@ import org.xml.sax.helpers.AttributesImpl; * <p>This work was authored by Bertrand Delacretaz (bdelacretaz@codeconsult.ch).</p> */ -public class RtfAttributes -implements java.lang.Cloneable { +public class RtfAttributes implements Cloneable { + private HashMap values = new HashMap(); /** @@ -108,12 +108,9 @@ implements java.lang.Cloneable { return values.toString() + "(" + super.toString() + ")"; } - /** - * implement cloning - * @return cloned Object - */ - public Object clone() { - final RtfAttributes result = new RtfAttributes(); + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + RtfAttributes result = (RtfAttributes) super.clone(); result.values = (HashMap)values.clone(); // Added by Normand Masse diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java index 0ca76715b..baca88926 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java @@ -29,6 +29,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; import java.io.IOException; import java.io.Writer; +import org.apache.fop.apps.FOPException; + /** * <p>Creates an hyperlink. * This class belongs to the <fo:basic-link> tag processing.</p> @@ -157,12 +159,17 @@ implements IRtfTextContainer, /** * IRtfTextContainer requirement: * @return a copy of our attributes + * @throws FOPException if attributes cannot be cloned */ - public RtfAttributes getTextContainerAttributes() { + public RtfAttributes getTextContainerAttributes() throws FOPException { if (attrib == null) { return null; } - return (RtfAttributes) this.attrib.clone (); + try { + return (RtfAttributes) this.attrib.clone (); + } catch (CloneNotSupportedException e) { + throw new FOPException(e); + } } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java index b4ff23b74..30f573dd5 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java @@ -30,6 +30,8 @@ import java.io.IOException; import java.io.Writer; import java.util.List; +import org.apache.fop.apps.FOPException; + /** * <p>Model of an RTF paragraph, which can contain RTF text elements.</p> * @@ -93,12 +95,17 @@ implements IRtfTextContainer, IRtfPageBreakContainer, IRtfHyperLinkContainer, /** * IRtfTextContainer requirement: return a copy of our attributes * @return a copy of this paragraphs attributes + * @throws FOPException if attributes cannot be cloned */ - public RtfAttributes getTextContainerAttributes() { + public RtfAttributes getTextContainerAttributes() throws FOPException { if (attrib == null) { return null; } - return (RtfAttributes)this.attrib.clone(); + try { + return (RtfAttributes)this.attrib.clone(); + } catch (CloneNotSupportedException e) { + throw new FOPException(e); + } } /** diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java index 9b74f5b45..018cbd845 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java @@ -29,6 +29,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; import java.io.IOException; import java.io.Writer; +import org.apache.fop.apps.FOPException; + /** * <p>Container for RtfRow elements.</p> * @@ -86,11 +88,16 @@ public class RtfTable extends RtfContainer { * @param attrs attributs of new RtfTableRow * @return new RtfTableRow * @throws IOException for I/O problems + * @throws FOPException if attributes cannot be cloned */ - public RtfTableRow newTableRow(RtfAttributes attrs) throws IOException { + public RtfTableRow newTableRow(RtfAttributes attrs) throws IOException, FOPException { RtfAttributes attr = null; if (attrib != null) { - attr = (RtfAttributes) attrib.clone (); + try { + attr = (RtfAttributes) attrib.clone (); + } catch (CloneNotSupportedException e) { + throw new FOPException(e); + } attr.set (attrs); } else { attr = attrs; diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java index 74634da7f..19bda2e14 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java @@ -30,6 +30,8 @@ import java.io.IOException; import java.io.Writer; import java.util.Iterator; +import org.apache.fop.apps.FOPException; + /** * <p>Container for RtfTableCell elements.</p> * @@ -106,15 +108,20 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { * @param cellWidth width of new cell * @return new RtfTableCell * @throws IOException for I/O problems + * @throws FOPException if attributes cannot be cloned */ public RtfTableCell newTableCellMergedHorizontally (int cellWidth, - RtfAttributes attrs) throws IOException { + RtfAttributes attrs) throws IOException, FOPException { highestCell++; // Added by Normand Masse // Inherit attributes from base cell for merge RtfAttributes wAttributes = null; if (attrs != null) { - wAttributes = (RtfAttributes)attrs.clone(); + try { + wAttributes = (RtfAttributes)attrs.clone(); + } catch (CloneNotSupportedException e) { + throw new FOPException(e); + } } cell = new RtfTableCell(this, writer, cellWidth, wAttributes, highestCell); diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java index 4df178af1..89c7d2899 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java @@ -29,6 +29,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; import java.io.IOException; import java.io.Writer; +import org.apache.fop.apps.FOPException; + /** * <p>Model of a text run (a piece of text with attributes) in an RTF document.</p> * @@ -240,12 +242,18 @@ public class RtfText extends RtfElement { } /** IRtfTextContainer requirement: - * @return a copy of our attributes */ - public RtfAttributes getTextContainerAttributes() { + * @return a copy of our attributes + * @throws FOPException if attributes cannot be cloned + */ + public RtfAttributes getTextContainerAttributes() throws FOPException { if (attrib == null) { return null; } - return (RtfAttributes)this.attrib.clone(); + try { + return (RtfAttributes)this.attrib.clone(); + } catch (CloneNotSupportedException e) { + throw new FOPException(e); + } } /** direct access to our text */ diff --git a/src/java/org/apache/fop/tools/anttasks/FileCompare.java b/src/java/org/apache/fop/tools/anttasks/FileCompare.java index 462049907..4906bdc6c 100644 --- a/src/java/org/apache/fop/tools/anttasks/FileCompare.java +++ b/src/java/org/apache/fop/tools/anttasks/FileCompare.java @@ -126,7 +126,7 @@ public class FileCompare { */ private static boolean compareFileSize(File oldFile, File newFile) { return oldFile.length() == newFile.length(); - } // end: compareBytes + } private boolean filesExist(File oldFile, File newFile) { if (!oldFile.exists()) { |