aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/fop/area/BlockViewport.java20
-rw-r--r--src/java/org/apache/fop/area/RegionViewport.java14
-rw-r--r--src/java/org/apache/fop/area/Viewport.java44
-rw-r--r--src/java/org/apache/fop/area/inline/Viewport.java24
-rw-r--r--src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java10
-rw-r--r--src/java/org/apache/fop/render/AbstractRenderer.java9
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFRenderer.java29
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DRenderer.java2
-rw-r--r--src/java/org/apache/fop/render/txt/TXTRenderer.java3
-rw-r--r--src/java/org/apache/fop/render/xml/XMLRenderer.java10
-rw-r--r--test/java/org/apache/fop/StandardTestSuite.java2
-rw-r--r--test/java/org/apache/fop/area/BlockViewportTestCase.java44
-rw-r--r--test/java/org/apache/fop/area/RegionViewportTestCase.java50
-rw-r--r--test/java/org/apache/fop/area/ViewportTestCase.java40
-rw-r--r--test/java/org/apache/fop/area/ViewportTestSuite.java47
-rw-r--r--test/java/org/apache/fop/area/inline/InlineViewportTestCase.java46
16 files changed, 331 insertions, 63 deletions
diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java
index 032b39f95..770ff31fb 100644
--- a/src/java/org/apache/fop/area/BlockViewport.java
+++ b/src/java/org/apache/fop/area/BlockViewport.java
@@ -19,12 +19,14 @@
package org.apache.fop.area;
+import java.awt.Rectangle;
+
/**
* A BlockViewport.
* This is used for block level Viewport/reference pairs.
* The block-container creates this area.
*/
-public class BlockViewport extends Block {
+public class BlockViewport extends Block implements Viewport {
private static final long serialVersionUID = -7840580922580735157L;
@@ -78,14 +80,16 @@ public class BlockViewport extends Block {
clip = cl;
}
- /**
- * Get the clipping for this viewport.
- *
- * @return the clipping for the viewport
- * true if the contents should be clipped for this viewport
- */
- public boolean getClip() {
+ public boolean hasClip() {
return clip;
}
+
+ public Rectangle getClipRectangle() {
+ if (clip) {
+ return new Rectangle(getIPD(), getBPD());
+ } else {
+ return null;
+ }
+ }
}
diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java
index 0654c5f6b..305dc5c10 100644
--- a/src/java/org/apache/fop/area/RegionViewport.java
+++ b/src/java/org/apache/fop/area/RegionViewport.java
@@ -19,6 +19,7 @@
package org.apache.fop.area;
+import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.util.HashMap;
@@ -29,7 +30,7 @@ import java.util.HashMap;
* 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 {
+public class RegionViewport extends Area implements Cloneable, Viewport {
private static final long serialVersionUID = 505781815165102572L;
@@ -75,11 +76,18 @@ public class RegionViewport extends Area implements Cloneable {
clip = c;
}
- /** @return true if the viewport should be clipped. */
- public boolean isClip() {
+ public boolean hasClip() {
return this.clip;
}
+ public Rectangle getClipRectangle() {
+ if (clip) {
+ return new Rectangle(getIPD(), getBPD());
+ } else {
+ return null;
+ }
+ }
+
/**
* Get the view area of this viewport.
*
diff --git a/src/java/org/apache/fop/area/Viewport.java b/src/java/org/apache/fop/area/Viewport.java
new file mode 100644
index 000000000..a92d826cc
--- /dev/null
+++ b/src/java/org/apache/fop/area/Viewport.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area;
+
+import java.awt.Rectangle;
+
+/**
+ * A viewport-area that may clip its content.
+ */
+public interface Viewport {
+
+ /**
+ * Returns true if this area will clip overflowing content.
+ *
+ * @return {@code true} if the overflow trait has the value "hidden", "scroll" or
+ * "error-if-overflow"
+ */
+ boolean hasClip();
+
+ /**
+ * Returns the clipping rectangle of this viewport area.
+ *
+ * @return the clipping rectangle expressed in the viewport's coordinate system, or
+ * null if clipping is disabled
+ */
+ Rectangle getClipRectangle();
+}
diff --git a/src/java/org/apache/fop/area/inline/Viewport.java b/src/java/org/apache/fop/area/inline/Viewport.java
index 206a965e2..610697c36 100644
--- a/src/java/org/apache/fop/area/inline/Viewport.java
+++ b/src/java/org/apache/fop/area/inline/Viewport.java
@@ -19,19 +19,20 @@
package org.apache.fop.area.inline;
-import org.apache.fop.area.Area;
-
-import java.io.IOException;
+import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
+import java.io.IOException;
import java.util.HashMap;
+import org.apache.fop.area.Area;
+
/**
* Inline viewport area.
* This is an inline-level viewport area for inline container,
* external graphic and instream foreign object. This viewport
* holds the area and positions it.
*/
-public class Viewport extends InlineArea {
+public class Viewport extends InlineArea implements org.apache.fop.area.Viewport {
private static final long serialVersionUID = 813338534627918689L;
@@ -60,15 +61,18 @@ public class Viewport extends InlineArea {
this.clip = c;
}
- /**
- * Get the clip of this viewport.
- *
- * @return true if this viewport should clip
- */
- public boolean getClip() {
+ public boolean hasClip() {
return this.clip;
}
+ public Rectangle getClipRectangle() {
+ if (clip) {
+ return new Rectangle(getIPD(), getBPD());
+ } else {
+ return null;
+ }
+ }
+
/**
* Set the position and size of the content of this viewport.
*
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
index cfce3a875..50a95b09a 100644
--- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
@@ -542,7 +542,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
}
//Clipping
- if (bv.getClip()) {
+ if (bv.hasClip()) {
clipRect(0f, 0f, width, height);
}
@@ -593,8 +593,8 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
//Now adjust for border/padding
currentBPPosition += borderPaddingBefore;
- Rectangle2D clippingRect = null;
- if (bv.getClip()) {
+ Rectangle clippingRect = null;
+ if (bv.hasClip()) {
clippingRect = new Rectangle(currentIPPosition, currentBPPosition,
bv.getIPD(), bv.getBPD());
}
@@ -701,14 +701,14 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
drawBackAndBorders(viewport, x, y, width + bpwidth, height + bpheight);
- if (viewport.getClip()) {
+ if (viewport.hasClip()) {
saveGraphicsState();
clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height);
}
super.renderViewport(viewport);
- if (viewport.getClip()) {
+ if (viewport.hasClip()) {
restoreGraphicsState();
}
}
diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java
index 273f0bc16..4e0b13c56 100644
--- a/src/java/org/apache/fop/render/AbstractRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractRenderer.java
@@ -278,7 +278,6 @@ public abstract class AbstractRenderer
* @param port The region viewport to be rendered
*/
protected void renderRegionViewport(RegionViewport port) {
- Rectangle2D view = port.getViewArea();
// The CTM will transform coordinates relative to
// this region-reference area into page coords, so
// set origin for the region to 0,0.
@@ -289,7 +288,7 @@ public abstract class AbstractRenderer
handleRegionTraits(port);
// shouldn't the viewport have the CTM
- startVParea(regionReference.getCTM(), port.isClip() ? view : null);
+ startVParea(regionReference.getCTM(), port.getClipRectangle());
// do after starting viewport area
if (regionReference.getRegionClass() == FO_REGION_BODY) {
renderBodyRegion((BodyRegion) regionReference);
@@ -306,7 +305,7 @@ public abstract class AbstractRenderer
* @param clippingRect the clipping rectangle if the viewport should be clipping,
* null if no clipping is performed.
*/
- protected abstract void startVParea(CTM ctm, Rectangle2D clippingRect);
+ protected abstract void startVParea(CTM ctm, Rectangle clippingRect);
/**
* Signals exit from a viewport area. Subclasses can restore transformation matrices
@@ -461,8 +460,8 @@ public abstract class AbstractRenderer
int saveIP = currentIPPosition;
int saveBP = currentBPPosition;
- Rectangle2D clippingRect = null;
- if (bv.getClip()) {
+ Rectangle clippingRect = null;
+ if (bv.hasClip()) {
clippingRect = new Rectangle(saveIP, saveBP, bv.getIPD(), bv.getBPD());
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
index 046d1703b..dfa2477b6 100644
--- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
@@ -37,7 +37,6 @@ import java.util.Stack;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
-
import org.xml.sax.SAXException;
import org.apache.batik.parser.AWTTransformProducer;
@@ -788,18 +787,11 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
concatenateTransformationMatrixMpt(contentRectTransform, false);
- //Clipping
- Rectangle clipRect = null;
- if (bv.getClip()) {
- clipRect = new Rectangle(0, 0, dim.width, dim.height);
- //clipRect(0f, 0f, width, height);
- }
-
//saveGraphicsState();
//Set up coordinate system for content rectangle
AffineTransform contentTransform = ctm.toAffineTransform();
//concatenateTransformationMatrixMpt(contentTransform);
- startViewport(contentTransform, clipRect);
+ startViewport(contentTransform, bv.getClipRectangle());
currentIPPosition = 0;
currentBPPosition = 0;
@@ -831,13 +823,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
//Now adjust for border/padding
currentBPPosition += borderPaddingBefore;
- Rectangle2D clippingRect = null;
- if (bv.getClip()) {
- clippingRect = new Rectangle(currentIPPosition, currentBPPosition,
- bv.getIPD(), bv.getBPD());
- }
-
- startVParea(ctm, clippingRect);
+ startVParea(ctm, bv.getClipRectangle());
currentIPPosition = 0;
currentBPPosition = 0;
renderBlocks(bv, children);
@@ -863,19 +849,12 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
}
/** {@inheritDoc} */
- protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
+ protected void startVParea(CTM ctm, Rectangle clippingRect) {
if (log.isTraceEnabled()) {
log.trace("startVParea() ctm=" + ctm + ", clippingRect=" + clippingRect);
}
AffineTransform at = new AffineTransform(ctm.toArray());
- Rectangle clipRect = null;
- if (clippingRect != null) {
- clipRect = new Rectangle(
- (int)clippingRect.getMinX() - currentIPPosition,
- (int)clippingRect.getMinY() - currentBPPosition,
- (int)clippingRect.getWidth(), (int)clippingRect.getHeight());
- }
- startViewport(at, clipRect);
+ startViewport(at, clippingRect);
if (log.isTraceEnabled()) {
log.trace("startVPArea: " + at + " --> " + graphicContext.getTransform());
}
diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
index 353aefa25..26f98ddd1 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
@@ -445,7 +445,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
}
/** {@inheritDoc} */
- protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
+ protected void startVParea(CTM ctm, Rectangle clippingRect) {
saveGraphicsState();
diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java
index aa36ea28f..386f95838 100644
--- a/src/java/org/apache/fop/render/txt/TXTRenderer.java
+++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java
@@ -21,6 +21,7 @@ package org.apache.fop.render.txt;
import java.awt.Color;
import java.awt.Point;
+import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
@@ -560,7 +561,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/**
* {@inheritDoc}
*/
- protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
+ protected void startVParea(CTM ctm, Rectangle clippingRect) {
currentState.push(ctm);
}
diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java
index 85995e8b2..a7f085d7f 100644
--- a/src/java/org/apache/fop/render/xml/XMLRenderer.java
+++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java
@@ -21,6 +21,7 @@ package org.apache.fop.render.xml;
// Java
import java.awt.Color;
+import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.OutputStream;
@@ -518,7 +519,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
addAreaAttributes(port);
addTraitAttributes(port);
addAttribute("rect", port.getViewArea());
- if (port.isClip()) {
+ if (port.hasClip()) {
addAttribute("clipped", "true");
}
startElement("regionViewport", atts);
@@ -558,9 +559,8 @@ public class XMLRenderer extends AbstractXMLRenderer {
}
}
- /** {@inheritDoc} */
@Override
- protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
+ protected void startVParea(CTM ctm, Rectangle clippingRect) {
//only necessary for graphical output
}
@@ -679,7 +679,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
addAttribute("top-position", bvp.getYOffset());
}
addAttribute("ctm", bvp.getCTM().toString());
- if (bvp.getClip()) {
+ if (bvp.hasClip()) {
addAttribute("clipped", "true");
}
} else {
@@ -749,7 +749,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
addTraitAttributes(viewport);
addAttribute("offset", viewport.getOffset());
addAttribute("pos", viewport.getContentPosition());
- if (viewport.getClip()) {
+ if (viewport.hasClip()) {
addAttribute("clip", "true");
}
startElement("viewport", atts);
diff --git a/test/java/org/apache/fop/StandardTestSuite.java b/test/java/org/apache/fop/StandardTestSuite.java
index 61a9bdc5e..480ab8bd0 100644
--- a/test/java/org/apache/fop/StandardTestSuite.java
+++ b/test/java/org/apache/fop/StandardTestSuite.java
@@ -22,6 +22,7 @@ package org.apache.fop;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.fop.area.ViewportTestSuite;
import org.apache.fop.fonts.DejaVuLGCSerifTest;
import org.apache.fop.image.loader.batik.ImageLoaderTestCase;
import org.apache.fop.image.loader.batik.ImagePreloaderTestCase;
@@ -65,6 +66,7 @@ public class StandardTestSuite {
suite.addTest(new TestSuite(PageBoundariesTest.class));
suite.addTest(new TestSuite(PageScaleTest.class));
suite.addTest(new TestSuite(MinOptMaxTest.class));
+ suite.addTest(ViewportTestSuite.suite());
//$JUnit-END$
return suite;
}
diff --git a/test/java/org/apache/fop/area/BlockViewportTestCase.java b/test/java/org/apache/fop/area/BlockViewportTestCase.java
new file mode 100644
index 000000000..a2a897322
--- /dev/null
+++ b/test/java/org/apache/fop/area/BlockViewportTestCase.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area;
+
+
+/**
+ * Tests the {@linkplain BlockViewport} class.
+ */
+public class BlockViewportTestCase extends ViewportTestCase {
+
+ public void testNonClip() throws Exception {
+ BlockViewport bv = new BlockViewport();
+ bv.setIPD(100);
+ bv.setBPD(50);
+ checkNonClip(bv);
+ }
+
+ public void testClip() throws Exception {
+ BlockViewport bv = new BlockViewport();
+ int ipd = 100;
+ int bpd = 50;
+ bv.setIPD(ipd);
+ bv.setBPD(bpd);
+ bv.setClip(true);
+ checkClip(bv, ipd, bpd);
+ }
+}
diff --git a/test/java/org/apache/fop/area/RegionViewportTestCase.java b/test/java/org/apache/fop/area/RegionViewportTestCase.java
new file mode 100644
index 000000000..f55d08b66
--- /dev/null
+++ b/test/java/org/apache/fop/area/RegionViewportTestCase.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area;
+
+import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Tests the {@linkplain RegionViewport} class.
+ */
+public class RegionViewportTestCase extends ViewportTestCase {
+
+ private RegionViewport createRegionViewport(int x, int y, int ipd, int bpd) {
+ Rectangle2D v = new Rectangle(x, y, ipd, bpd);
+ RegionViewport viewport = new RegionViewport(v);
+ viewport.setIPD(ipd);
+ viewport.setBPD(bpd);
+ return viewport;
+ }
+
+ public void testNonClip() throws Exception {
+ RegionViewport viewport = createRegionViewport(10, 10, 100, 20);
+ checkNonClip(viewport);
+ }
+
+ public void testClip() throws Exception {
+ int ipd = 150;
+ int bpd = 20;
+ RegionViewport viewport = createRegionViewport(10, 10, ipd, bpd);
+ viewport.setClip(true);
+ checkClip(viewport, ipd, bpd);
+ }
+}
diff --git a/test/java/org/apache/fop/area/ViewportTestCase.java b/test/java/org/apache/fop/area/ViewportTestCase.java
new file mode 100644
index 000000000..335ca2f8d
--- /dev/null
+++ b/test/java/org/apache/fop/area/ViewportTestCase.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area;
+
+import java.awt.Rectangle;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests implementations of the {@linkplain Viewport} interface.
+ */
+public abstract class ViewportTestCase extends TestCase {
+
+ protected void checkNonClip(Viewport v) throws Exception {
+ assertFalse(v.hasClip());
+ assertNull(v.getClipRectangle());
+ }
+
+ protected void checkClip(Viewport v, int expectedWidth, int expectedHeight) throws Exception {
+ assertTrue(v.hasClip());
+ assertEquals(new Rectangle(0, 0, expectedWidth, expectedHeight), v.getClipRectangle());
+ }
+}
diff --git a/test/java/org/apache/fop/area/ViewportTestSuite.java b/test/java/org/apache/fop/area/ViewportTestSuite.java
new file mode 100644
index 000000000..babbe8910
--- /dev/null
+++ b/test/java/org/apache/fop/area/ViewportTestSuite.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.fop.area.inline.InlineViewportTestCase;
+
+/**
+ * A suite of all the tests relating to the {@linkplain Viewport} interface.
+ */
+public final class ViewportTestSuite {
+
+ private ViewportTestSuite() { }
+
+ /**
+ * Returns the suite of {@linkplain Viewport} implementation tests.
+ *
+ * @return the tests
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Tests for viewport-areas");
+ suite.addTestSuite(RegionViewportTestCase.class);
+ suite.addTestSuite(BlockViewportTestCase.class);
+ suite.addTestSuite(InlineViewportTestCase.class);
+ return suite;
+ }
+
+}
diff --git a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
new file mode 100644
index 000000000..ccd866d64
--- /dev/null
+++ b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area.inline;
+
+import org.apache.fop.area.ViewportTestCase;
+
+/**
+ * Tests the {@linkplain Viewport} class.
+ */
+public class InlineViewportTestCase extends ViewportTestCase {
+
+ public void testNonClip() throws Exception {
+ Viewport v = new Viewport(null);
+ v.setIPD(50);
+ v.setBPD(25);
+ checkNonClip(v);
+ }
+
+ public void testClip() throws Exception {
+ Viewport v = new Viewport(null);
+ int ipd = 50;
+ int bpd = 25;
+ v.setIPD(ipd);
+ v.setBPD(bpd);
+ v.setClip(true);
+ checkClip(v, ipd, bpd);
+ }
+
+}