aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/area
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/area')
-rw-r--r--src/java/org/apache/fop/area/AbstractOffDocumentItem.java71
-rw-r--r--src/java/org/apache/fop/area/Area.java518
-rw-r--r--src/java/org/apache/fop/area/AreaEventProducer.java93
-rw-r--r--src/java/org/apache/fop/area/AreaEventProducer.xml25
-rw-r--r--src/java/org/apache/fop/area/AreaTreeHandler.java531
-rw-r--r--src/java/org/apache/fop/area/AreaTreeModel.java134
-rw-r--r--src/java/org/apache/fop/area/AreaTreeObject.java149
-rw-r--r--src/java/org/apache/fop/area/AreaTreeParser.java1225
-rw-r--r--src/java/org/apache/fop/area/BeforeFloat.java75
-rw-r--r--src/java/org/apache/fop/area/Block.java204
-rw-r--r--src/java/org/apache/fop/area/BlockParent.java147
-rw-r--r--src/java/org/apache/fop/area/BlockViewport.java101
-rw-r--r--src/java/org/apache/fop/area/BodyRegion.java171
-rw-r--r--src/java/org/apache/fop/area/BookmarkData.java264
-rw-r--r--src/java/org/apache/fop/area/CTM.java362
-rw-r--r--src/java/org/apache/fop/area/CachedRenderPagesModel.java153
-rw-r--r--src/java/org/apache/fop/area/DestinationData.java113
-rw-r--r--src/java/org/apache/fop/area/Footnote.java90
-rw-r--r--src/java/org/apache/fop/area/IDTracker.java259
-rw-r--r--src/java/org/apache/fop/area/LineArea.java301
-rw-r--r--src/java/org/apache/fop/area/LinkResolver.java124
-rw-r--r--src/java/org/apache/fop/area/MainReference.java136
-rw-r--r--src/java/org/apache/fop/area/NormalFlow.java48
-rw-r--r--src/java/org/apache/fop/area/OffDocumentExtensionAttachment.java56
-rw-r--r--src/java/org/apache/fop/area/OffDocumentItem.java61
-rw-r--r--src/java/org/apache/fop/area/Page.java326
-rw-r--r--src/java/org/apache/fop/area/PageSequence.java109
-rw-r--r--src/java/org/apache/fop/area/PageViewport.java541
-rw-r--r--src/java/org/apache/fop/area/RegionReference.java163
-rw-r--r--src/java/org/apache/fop/area/RegionViewport.java144
-rw-r--r--src/java/org/apache/fop/area/RenderPagesModel.java271
-rw-r--r--src/java/org/apache/fop/area/Resolvable.java63
-rw-r--r--src/java/org/apache/fop/area/SideFloat.java31
-rw-r--r--src/java/org/apache/fop/area/Span.java226
-rw-r--r--src/java/org/apache/fop/area/Trait.java689
-rw-r--r--src/java/org/apache/fop/area/Viewport.java44
-rw-r--r--src/java/org/apache/fop/area/inline/AbstractTextArea.java200
-rw-r--r--src/java/org/apache/fop/area/inline/Anchor.java34
-rw-r--r--src/java/org/apache/fop/area/inline/BasicLinkArea.java72
-rw-r--r--src/java/org/apache/fop/area/inline/Container.java80
-rw-r--r--src/java/org/apache/fop/area/inline/FilledArea.java132
-rw-r--r--src/java/org/apache/fop/area/inline/ForeignObject.java85
-rw-r--r--src/java/org/apache/fop/area/inline/Image.java54
-rw-r--r--src/java/org/apache/fop/area/inline/InlineArea.java351
-rw-r--r--src/java/org/apache/fop/area/inline/InlineBlockParent.java76
-rw-r--r--src/java/org/apache/fop/area/inline/InlineParent.java155
-rw-r--r--src/java/org/apache/fop/area/inline/InlineViewport.java155
-rw-r--r--src/java/org/apache/fop/area/inline/Leader.java121
-rw-r--r--src/java/org/apache/fop/area/inline/ResolvedPageNumber.java37
-rw-r--r--src/java/org/apache/fop/area/inline/Space.java36
-rw-r--r--src/java/org/apache/fop/area/inline/SpaceArea.java62
-rw-r--r--src/java/org/apache/fop/area/inline/TextArea.java217
-rw-r--r--src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java180
-rw-r--r--src/java/org/apache/fop/area/inline/WordArea.java310
-rw-r--r--src/java/org/apache/fop/area/inline/package.html23
-rw-r--r--src/java/org/apache/fop/area/package.html23
56 files changed, 0 insertions, 10421 deletions
diff --git a/src/java/org/apache/fop/area/AbstractOffDocumentItem.java b/src/java/org/apache/fop/area/AbstractOffDocumentItem.java
deleted file mode 100644
index bdec281d4..000000000
--- a/src/java/org/apache/fop/area/AbstractOffDocumentItem.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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;
-
-/**
- * Abstract base class for objects that are processed by the renderer outside
- * of the actual document.
- * This object can be handled by the renderer according to these
- * possibilities: IMMEDIATELY, AFTER_PAGE, START_OF_DOC or END_OF_DOC.
- */
-public abstract class AbstractOffDocumentItem implements OffDocumentItem {
-
- /**
- * Process this extension immediately when
- * being handled by the area tree.
- */
- public static final int IMMEDIATELY = 0;
-
- /**
- * Process this extension after the next page is rendered
- * or prepared when being handled by the area tree.
- */
- public static final int AFTER_PAGE = 1;
-
- /**
- * Process this extension at the end of the document once
- * all pages have been fully rendered.
- */
- public static final int END_OF_DOC = 2;
-
- /**
- * Process this extension at the start of the document right
- * before the first page-sequence is processed.
- */
- public static final int START_OF_DOC = 2;
-
-
- /** Indicates in what phase the item should be processed. */
- protected int whenToProcess = IMMEDIATELY;
-
- /**
- * Get an indicator of when this item should be processed
- * @return int constant (IMMEDIATELY, AFTER_PAGE, START_OF_DOC, END_OF_DOC)
- */
- public int getWhenToProcess() {
- return whenToProcess;
- }
-
- /**
- * Return a human-readable name for this ODI (for error messages, etc.)
- * @return String name of ODI
- */
- public abstract String getName();
-}
diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java
deleted file mode 100644
index 895367c19..000000000
--- a/src/java/org/apache/fop/area/Area.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * 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.io.Serializable;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.fop.traits.BorderProps;
-import org.apache.fop.traits.WritingModeTraitsGetter;
-
-// If the area appears more than once in the output
-// or if the area has external data it is cached
-// to keep track of it and to minimize rendered output
-// renderers can render the output once and display it
-// for every occurence
-// this should also extend to all outputs (including PDFGraphics2D)
-// and all types of renderers
-
-/**
- * Base object for all areas.
- */
-public class Area extends AreaTreeObject implements Serializable {
-
- private static final long serialVersionUID = 6342888466142626492L;
-
- // orientations for reference areas
- /**
- * Normal orientation
- */
- public static final int ORIENT_0 = 0;
-
- /**
- * Rotated 90 degrees clockwise
- */
- public static final int ORIENT_90 = 1;
-
- /**
- * Rotate 180 degrees
- */
- public static final int ORIENT_180 = 2;
-
- /**
- * Rotated 270 degrees clockwise
- */
- public static final int ORIENT_270 = 3;
-
- // area class values
-
- /**
- * Normal class
- */
- public static final int CLASS_NORMAL = 0;
-
- /**
- * Fixed position class
- */
- public static final int CLASS_FIXED = 1;
-
- /**
- * Absolute position class
- */
- public static final int CLASS_ABSOLUTE = 2;
-
- /**
- * Before float class
- */
- public static final int CLASS_BEFORE_FLOAT = 3;
-
- /**
- * Footnote class
- */
- public static final int CLASS_FOOTNOTE = 4;
-
- /**
- * Side float class
- */
- public static final int CLASS_SIDE_FLOAT = 5;
-
- // IMPORTANT: make sure this is the maximum + 1
- /**
- * Maximum class count
- */
- public static final int CLASS_MAX = CLASS_SIDE_FLOAT + 1;
-
- private int areaClass = CLASS_NORMAL;
-
- /** the area's inline-progression-dimension */
- protected int ipd;
-
- /** the area's block-progression-dimension */
- protected int bpd;
-
- protected int effectiveIPD = -1;
-
- /**
- * Resolved bidirectional level for area.
- */
- protected int bidiLevel = -1;
-
- /**
- * Traits for this area.
- */
- protected TreeMap<Integer, Object> traits;
-
- /**
- * logging instance
- */
- protected static final Log log = LogFactory.getLog(Area.class);
-
- /**
- * Get the area class of this area.
- *
- * @return the area class
- */
- public int getAreaClass() {
- 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.
- *
- * @param areaClass the area class
- */
- public void setAreaClass(int areaClass) {
- this.areaClass = areaClass;
- }
-
- /**
- * Set the inline progression dimension of content rectangle
- * for this area.
- *
- * @param ipd the new inline progression dimension
- * @see <a href="http://www.w3.org/TR/xsl/#inline-progression-dimension">ipd</a>
- */
- public void setIPD(int ipd) {
- this.ipd = ipd;
- }
-
- /**
- * Get the inline progression dimension of the content rectangle
- * for this area.
- *
- * @return the inline progression dimension
- * @see <a href="http://www.w3.org/TR/xsl/#inline-progression-dimension">ipd</a>
- */
- public int getIPD() {
- return ipd;
- }
-
- /**
- * Set the block progression dimension of the content rectangle
- * for this area.
- *
- * @param bpd the new block progression dimension
- * @see <a href="http://www.w3.org/TR/xsl/#block-progression-dimension">bpd</a>
- */
- public void setBPD(int bpd) {
- this.bpd = bpd;
- }
-
- /**
- * Get the block progression dimension of the content rectangle
- * for this area.
- *
- * @return the block progression dimension
- * @see <a href="http://www.w3.org/TR/xsl/#block-progression-dimension">bpd</a>
- */
- public int getBPD() {
- return bpd;
- }
-
- /**
- * Get the allocation inline progression dimension of this area.
- * This adds the content, borders and the padding to find the
- * total allocated IPD.
- *
- * @return the total IPD allocation for this area
- */
- public int getAllocIPD() {
- return getBorderAndPaddingWidthStart() + getIPD() + getBorderAndPaddingWidthEnd();
- }
-
- public int getEffectiveAllocIPD() {
- return getBorderAndPaddingWidthStart() + getEffectiveIPD() + getBorderAndPaddingWidthEnd();
- }
-
- /**
- * Get the allocation block progression dimension of this area.
- * This adds the content, borders, padding and spaces to find the
- * total allocated BPD.
- *
- * @return the total BPD allocation for this area
- */
- public int getAllocBPD() {
- return getSpaceBefore() + getBorderAndPaddingWidthBefore() + getBPD()
- + getBorderAndPaddingWidthAfter() + getSpaceAfter();
- }
-
- /**
- * Set the bidirectional embedding level.
- *
- * @param bidiLevel the bidirectional embedding level
- */
- public void setBidiLevel(int bidiLevel) {
- this.bidiLevel = bidiLevel;
- }
-
- /**
- * Reset the bidirectional embedding level to default
- * value (-1).
- */
- public void resetBidiLevel() {
- setBidiLevel(-1);
- }
-
- /**
- * Get the bidirectional embedding level.
- *
- * @return the bidirectional embedding level
- */
- public int getBidiLevel() {
- return bidiLevel;
- }
-
- /**
- * Return the sum of region border- and padding-before
- *
- * @return width in millipoints
- */
- public int getBorderAndPaddingWidthBefore() {
- int margin = 0;
- BorderProps bps = (BorderProps) getTrait(Trait.BORDER_BEFORE);
- if (bps != null) {
- margin = bps.width;
- }
-
- Integer padWidth = (Integer) getTrait(Trait.PADDING_BEFORE);
- if (padWidth != null) {
- margin += padWidth;
- }
-
- return margin;
- }
-
- /**
- * Return the sum of region border- and padding-after
- *
- * @return width in millipoints
- */
- public int getBorderAndPaddingWidthAfter() {
- int margin = 0;
-
- BorderProps bps = (BorderProps) getTrait(Trait.BORDER_AFTER);
- if (bps != null) {
- margin = bps.width;
- }
-
- Integer padWidth = (Integer) getTrait(Trait.PADDING_AFTER);
- if (padWidth != null) {
- margin += padWidth;
- }
-
- return margin;
- }
-
- /**
- * Return the sum of region border- and padding-start
- *
- * @return width in millipoints
- */
- public int getBorderAndPaddingWidthStart() {
- int margin = 0;
- BorderProps bps = (BorderProps) getTrait(Trait.BORDER_START);
- if (bps != null) {
- margin = bps.width;
- }
-
- Integer padWidth = (Integer) getTrait(Trait.PADDING_START);
- if (padWidth != null) {
- margin += padWidth;
- }
-
- return margin;
- }
-
- /**
- * Return the sum of region border- and padding-end
- *
- * @return width in millipoints
- */
- public int getBorderAndPaddingWidthEnd() {
- int margin = 0;
- BorderProps bps = (BorderProps) getTrait(Trait.BORDER_END);
- if (bps != null) {
- margin = bps.width;
- }
-
- Integer padWidth = (Integer) getTrait(Trait.PADDING_END);
- if (padWidth != null) {
- margin += padWidth;
- }
-
- return margin;
- }
-
- /**
- * Returns the space before
- *
- * @return width in millipoints
- */
- public int getSpaceBefore() {
- int margin = 0;
- Integer space = (Integer) getTrait(Trait.SPACE_BEFORE);
- if (space != null) {
- margin = space;
- }
- return margin;
- }
-
- /**
- * Returns the space after
- *
- * @return width in millipoints
- */
- public int getSpaceAfter() {
- int margin = 0;
- Integer space = (Integer) getTrait(Trait.SPACE_AFTER);
- if (space != null) {
- margin = space;
- }
- return margin;
- }
-
- /**
- * Returns the space start
- *
- * @return width in millipoints
- */
- public int getSpaceStart() {
- int margin = 0;
- Integer space = (Integer) getTrait(Trait.SPACE_START);
- if (space != null) {
- margin = space;
- }
- return margin;
- }
-
- /**
- * Returns the space end
- *
- * @return width in millipoints
- */
- public int getSpaceEnd() {
- int margin = 0;
- Integer space = (Integer) getTrait(Trait.SPACE_END);
- if (space != null) {
- margin = space;
- }
- return margin;
- }
-
- /**
- * Add a child to this area.
- * The default is to do nothing. Subclasses must override
- * to do something if they can have child areas.
- *
- * @param child the child area to add
- */
- public void addChildArea(Area child) {
- }
-
- /**
- * Add a trait to this area.
- *
- * @param traitCode the trait key
- * @param prop the value of the trait
- */
- public void addTrait(Integer traitCode, Object prop) {
- // use treemap since the typical number of traits are less than four
- if (traits == null) {
- traits = new TreeMap<Integer, Object>();
- }
- traits.put(traitCode, prop);
- }
-
- /**
- * Set traits on this area, copying from an existing traits map.
- *
- * @param traits the map of traits
- */
- public void setTraits(Map traits) {
- if (traits != null) {
- this.traits = new TreeMap<Integer, Object>(traits);
- } else {
- this.traits = null;
- }
- }
-
- /**
- * Get the map of all traits on this area.
- *
- * @return the map of traits
- */
- public Map<Integer, Object> getTraits() {
- return this.traits;
- }
-
- /** @return true if the area has traits */
- public boolean hasTraits() {
- return (this.traits != null);
- }
-
- /**
- * Get a trait from this area.
- *
- * @param traitCode the trait key
- * @return the trait value
- */
- public Object getTrait(Integer traitCode) {
- return (traits != null ? traits.get(traitCode) : null);
- }
-
- /**
- * Checks whether a certain trait is set on this area.
- * @param traitCode the trait key
- * @return true if the trait is set
- */
- public boolean hasTrait(Integer traitCode) {
- return (getTrait(traitCode) != null);
- }
-
- /**
- * Get a boolean trait from this area.
- * @param traitCode the trait key
- * @return the trait value
- */
- public boolean getTraitAsBoolean(Integer traitCode) {
- return Boolean.TRUE.equals(getTrait(traitCode));
- }
-
- /**
- * Get a trait from this area as an integer.
- *
- * @param traitCode the trait key
- * @return the trait value
- */
- public int getTraitAsInteger(Integer traitCode) {
- final Object obj = getTrait(traitCode);
- if (obj instanceof Integer) {
- return (Integer) obj;
- } else {
- throw new IllegalArgumentException("Trait "
- + traitCode.getClass().getName()
- + " could not be converted to an integer");
- }
- }
-
- /**
- * Sets the writing mode traits for this area. Default implementation
- * does nothing.
- * @param wmtg a WM traits getter
- */
- public void setWritingModeTraits(WritingModeTraitsGetter wmtg) {
- }
-
- /**
- * {@inheritDoc}
- * @return ipd and bpd of area
- */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer(super.toString());
- sb.append(" {ipd=").append(Integer.toString(getIPD()));
- sb.append(", bpd=").append(Integer.toString(getBPD()));
- sb.append("}");
- return sb.toString();
- }
-
- public int getEffectiveIPD() {
- return 0;
- }
-
- public void activateEffectiveIPD() {
- if (effectiveIPD != -1) {
- ipd = effectiveIPD;
- }
- }
-}
diff --git a/src/java/org/apache/fop/area/AreaEventProducer.java b/src/java/org/apache/fop/area/AreaEventProducer.java
deleted file mode 100644
index da7c0acc1..000000000
--- a/src/java/org/apache/fop/area/AreaEventProducer.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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 org.apache.fop.events.EventBroadcaster;
-import org.apache.fop.events.EventProducer;
-
-/**
- * Event producer interface for events related to the area tree.
- */
-public interface AreaEventProducer extends EventProducer {
-
- /**
- * Provider class for the event producer.
- */
- static final class Provider {
-
- private Provider() {
- }
-
- /**
- * Returns an event producer.
- * @param broadcaster the event broadcaster to use
- * @return the event producer
- */
- public static AreaEventProducer get(EventBroadcaster broadcaster) {
- return broadcaster.getEventProducerFor(AreaEventProducer.class);
- }
- }
-
- /**
- * An unresolved ID reference was encountered.
- * @param source the event source
- * @param type the type of reference
- * @param id the unresolved ID
- * @event.severity WARN
- */
- void unresolvedIDReference(Object source, String type, String id);
-
- /**
- * An unresolved ID reference was encountered on a page.
- * @param source the event source
- * @param page the page the ID reference was found on
- * @param id the unresolved ID
- * @event.severity WARN
- */
- void unresolvedIDReferenceOnPage(Object source, String page, String id);
-
- /**
- * A page could not be loaded/deserialized from a file.
- * @param source the event source
- * @param page the page to be loaded
- * @param e the original exception
- * @event.severity ERROR
- */
- void pageLoadError(Object source, String page, Exception e);
-
- /**
- * A page could not be saved/serialized to a file.
- * @param source the event source
- * @param page the page to be serialized
- * @param e the original exception
- * @event.severity ERROR
- */
- void pageSaveError(Object source, String page, Exception e);
-
- /**
- * A page could not be rendered.
- * @param source the event source
- * @param page the page to be serialized
- * @param e the original exception
- * @event.severity ERROR
- */
- void pageRenderingError(Object source, String page, Exception e);
-
-}
diff --git a/src/java/org/apache/fop/area/AreaEventProducer.xml b/src/java/org/apache/fop/area/AreaEventProducer.xml
deleted file mode 100644
index 576007eb9..000000000
--- a/src/java/org/apache/fop/area/AreaEventProducer.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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$ -->
-<catalogue xml:lang="en">
- <message key="unresolvedIDReference">{type}: Unresolved ID reference "{id}" found.</message>
- <message key="unresolvedIDReferenceOnPage">Page {page}: Unresolved ID reference "{id}" found.</message>
- <message key="pageLoadError">Error while deserializing page {page}.[ Reason: {e}]</message>
- <message key="pageSaveError">Error while serializing page {page}.[ Reason: {e}]</message>
- <message key="pageRenderingError">Error while rendering page {page}.[ Reason: {e}]</message>
-</catalogue>
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java
deleted file mode 100644
index fda5ad07b..000000000
--- a/src/java/org/apache/fop/area/AreaTreeHandler.java
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * 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;
-
-// Java
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Locale;
-
-import org.xml.sax.SAXException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.FormattingResults;
-import org.apache.fop.datatypes.Numeric;
-import org.apache.fop.fo.FOEventHandler;
-import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.apache.fop.fo.extensions.ExternalDocument;
-import org.apache.fop.fo.extensions.destination.Destination;
-import org.apache.fop.fo.pagination.AbstractPageSequence;
-import org.apache.fop.fo.pagination.PageSequence;
-import org.apache.fop.fo.pagination.Root;
-import org.apache.fop.fo.pagination.bookmarks.BookmarkTree;
-import org.apache.fop.layoutmgr.ExternalDocumentLayoutManager;
-import org.apache.fop.layoutmgr.LayoutManagerMaker;
-import org.apache.fop.layoutmgr.LayoutManagerMapping;
-import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
-import org.apache.fop.layoutmgr.TopLevelLayoutManager;
-
-/**
- * Area tree handler for formatting objects.
- *
- * Concepts: The area tree is to be as small as possible. With minimal classes
- * and data to fully represent an area tree for formatting objects. The area
- * tree needs to be simple to render and follow the spec closely. This area tree
- * has the concept of page sequences. Wherever possible information is discarded
- * or optimized to keep memory use low. The data is also organized to make it
- * possible for renderers to minimize their output. A page can be saved if not
- * fully resolved and once rendered a page contains only size and id reference
- * information. The area tree pages are organized in a model that depends on the
- * type of renderer.
- */
-public class AreaTreeHandler extends FOEventHandler {
-
- private static Log log = LogFactory.getLog(AreaTreeHandler.class);
-
- // Recorder of debug statistics
- private Statistics statistics;
-
- // The LayoutManager maker
- private LayoutManagerMaker lmMaker;
-
- /** The AreaTreeModel in use */
- protected AreaTreeModel model;
-
- // Flag for controlling complex script features (default: true).
- private boolean useComplexScriptFeatures = true;
-
- // Keeps track of all meaningful id references
- private IDTracker idTracker;
-
- // The fo:root node of the document
- private Root rootFObj;
-
- // The formatting results to be handed back to the caller.
- private FormattingResults results = new FormattingResults();
-
- private TopLevelLayoutManager prevPageSeqLM;
-
- private int idGen;
-
- /**
- * Constructor.
- *
- * @param userAgent FOUserAgent object for process
- * @param outputFormat the MIME type of the output format to use (ex.
- * "application/pdf").
- * @param stream OutputStream
- * @throws FOPException if the RenderPagesModel cannot be created
- */
- public AreaTreeHandler(FOUserAgent userAgent, String outputFormat,
- OutputStream stream) throws FOPException {
- super(userAgent);
-
- setupModel(userAgent, outputFormat, stream);
-
- this.lmMaker = userAgent.getLayoutManagerMakerOverride();
- if (lmMaker == null) {
- lmMaker = new LayoutManagerMapping();
- }
-
- this.idTracker = new IDTracker();
-
- this.useComplexScriptFeatures = userAgent.isComplexScriptFeaturesEnabled();
-
- if (log.isDebugEnabled()) {
- statistics = new Statistics();
- }
- }
-
- /**
- * Sets up the AreaTreeModel instance for use by the AreaTreeHandler.
- *
- * @param userAgent FOUserAgent object for process
- * @param outputFormat the MIME type of the output format to use (ex.
- * "application/pdf").
- * @param stream OutputStream
- * @throws FOPException if the RenderPagesModel cannot be created
- */
- protected void setupModel(FOUserAgent userAgent, String outputFormat,
- OutputStream stream) throws FOPException {
- if (userAgent.isConserveMemoryPolicyEnabled()) {
- this.model = new CachedRenderPagesModel(userAgent, outputFormat, fontInfo, stream);
- } else {
- this.model = new RenderPagesModel(userAgent, outputFormat, fontInfo, stream);
- }
- }
-
- /**
- * Get the area tree model for this area tree.
- *
- * @return AreaTreeModel the model being used for this area tree
- */
- public AreaTreeModel getAreaTreeModel() {
- return this.model;
- }
-
- /**
- * Get the LayoutManager maker for this area tree.
- *
- * @return LayoutManagerMaker the LayoutManager maker being used for this
- * area tree
- */
- public LayoutManagerMaker getLayoutManagerMaker() {
- return this.lmMaker;
- }
-
- /**
- * Get the IDTracker for this area tree.
- *
- * @return IDTracker used to track reference ids for items in this area tree
- */
- public IDTracker getIDTracker() {
- return this.idTracker;
- }
-
- /**
- * Get information about the rendered output, like number of pages created.
- *
- * @return the results structure
- */
- public FormattingResults getResults() {
- return this.results;
- }
-
- /**
- * Check whether complex script features are enabled.
- *
- * @return true if using complex script features
- */
- public boolean isComplexScriptFeaturesEnabled() {
- return useComplexScriptFeatures;
- }
-
- /**
- * Prepare AreaTreeHandler for document processing This is called from
- * FOTreeBuilder.startDocument()
- *
- * @throws SAXException
- * if there is an error
- */
- @Override
- public void startDocument() throws SAXException {
- // Initialize statistics
- if (statistics != null) {
- statistics.start();
- }
- }
-
- @Override
- public void startRoot(Root root) {
- Locale locale = root.getLocale();
- if (locale != null) {
- model.setDocumentLocale(locale);
- }
- }
-
- /**
- * finish the previous pageSequence
- */
- private void finishPrevPageSequence(Numeric initialPageNumber) {
- if (prevPageSeqLM != null) {
- prevPageSeqLM.doForcePageCount(initialPageNumber);
- prevPageSeqLM.finishPageSequence();
- prevPageSeqLM = null;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void startPageSequence(PageSequence pageSequence) {
- startAbstractPageSequence(pageSequence);
- }
-
- private void startAbstractPageSequence(AbstractPageSequence pageSequence) {
- rootFObj = pageSequence.getRoot();
-
- //Before the first page-sequence...
- if (this.prevPageSeqLM == null) {
- // extension attachments from fo:root
- wrapAndAddExtensionAttachments(rootFObj.getExtensionAttachments());
- // extension attachments from fo:declarations
- if (rootFObj.getDeclarations() != null) {
- wrapAndAddExtensionAttachments(
- rootFObj.getDeclarations().getExtensionAttachments());
- }
- }
-
- finishPrevPageSequence(pageSequence.getInitialPageNumber());
- pageSequence.initPageNumber();
- }
-
- private void wrapAndAddExtensionAttachments(List<ExtensionAttachment> list) {
- for (ExtensionAttachment attachment : list) {
- addOffDocumentItem(new OffDocumentExtensionAttachment(attachment));
- }
- }
-
- /**
- * End the PageSequence. The PageSequence formats Pages and adds them to the
- * AreaTree. The area tree then handles what happens with the pages.
- *
- * @param pageSequence the page sequence ending
- */
- @Override
- public void endPageSequence(PageSequence pageSequence) {
-
- if (statistics != null) {
- statistics.end();
- }
-
- // If no main flow, nothing to layout!
- if (pageSequence.getMainFlow() != null) {
- PageSequenceLayoutManager pageSLM;
- pageSLM = getLayoutManagerMaker().makePageSequenceLayoutManager(
- this, pageSequence);
- pageSLM.activateLayout();
- // preserve the current PageSequenceLayoutManger for the
- // force-page-count check at the beginning of the next PageSequence
- prevPageSeqLM = pageSLM;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void startExternalDocument(ExternalDocument document) {
- startAbstractPageSequence(document);
- }
-
- /** {@inheritDoc} */
- @Override
- public void endExternalDocument(ExternalDocument document) {
- if (statistics != null) {
- statistics.end();
- }
-
- ExternalDocumentLayoutManager edLM;
- edLM = getLayoutManagerMaker().makeExternalDocumentLayoutManager(this, document);
- edLM.activateLayout();
- // preserve the current PageSequenceLayoutManger for the
- // force-page-count check at the beginning of the next PageSequence
- prevPageSeqLM = edLM;
-
- }
-
- /**
- * Called by the PageSequenceLayoutManager when it is finished with a
- * page-sequence.
- *
- * @param pageSequence the page-sequence just finished
- * @param pageCount The number of pages generated for the page-sequence
- */
- public void notifyPageSequenceFinished(AbstractPageSequence pageSequence,
- int pageCount) {
- this.results.haveFormattedPageSequence(pageSequence, pageCount);
- if (log.isDebugEnabled()) {
- log.debug("Last page-sequence produced " + pageCount + " pages.");
- }
- }
-
- /**
- * End the document.
- *
- * @throws SAXException if there is some error
- */
- @Override
- public void endDocument() throws SAXException {
-
- finishPrevPageSequence(null);
- // process fox:destination elements
- if (rootFObj != null) {
- List<Destination> destinationList = rootFObj.getDestinationList();
- if (destinationList != null) {
- while (destinationList.size() > 0) {
- Destination destination = destinationList.remove(0);
- DestinationData destinationData = new DestinationData(destination);
- addOffDocumentItem(destinationData);
- }
- }
- // process fo:bookmark-tree
- BookmarkTree bookmarkTree = rootFObj.getBookmarkTree();
- if (bookmarkTree != null) {
- BookmarkData data = new BookmarkData(bookmarkTree);
- addOffDocumentItem(data);
- if (!data.isResolved()) {
- // bookmarks did not fully resolve, add anyway. (hacky? yeah)
- model.handleOffDocumentItem(data);
- }
- }
- idTracker.signalIDProcessed(rootFObj.getId());
- }
- model.endDocument();
-
- if (statistics != null) {
- statistics.logResults();
- }
- }
-
- /**
- * Add a OffDocumentItem to the area tree model. This checks if the
- * OffDocumentItem is resolvable and attempts to resolve or add the
- * resolvable ids for later resolution.
- *
- * @param odi the OffDocumentItem to add.
- */
- private void addOffDocumentItem(OffDocumentItem odi) {
- if (odi instanceof Resolvable) {
- Resolvable res = (Resolvable) odi;
- String[] ids = res.getIDRefs();
- for (String id : ids) {
- List<PageViewport> pageVPList = idTracker.getPageViewportsContainingID(id);
- if (pageVPList != null && !pageVPList.isEmpty()) {
- res.resolveIDRef(id, pageVPList);
- } else {
- AreaEventProducer eventProducer = AreaEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.unresolvedIDReference(this, odi.getName(), id);
- idTracker.addUnresolvedIDRef(id, res);
- }
- }
- // check to see if ODI is now fully resolved, if so process it
- if (res.isResolved()) {
- model.handleOffDocumentItem(odi);
- }
- } else {
- model.handleOffDocumentItem(odi);
- }
- }
-
- /**
- * Generates and returns a unique key for a page viewport.
- *
- * @return the generated key.
- */
- public String generatePageViewportKey() {
- this.idGen++;
- return "P" + this.idGen;
- }
-
- /**
- * Tie a PageViewport with an ID found on a child area of the PV. Note that
- * an area with a given ID may be on more than one PV, hence an ID may have
- * more than one PV associated with it.
- *
- * @param id the property ID of the area
- * @param pv a page viewport that contains the area with this ID
- * @deprecated use getIDTracker().associateIDWithPageViewport(id, pv) instead
- */
- @Deprecated
- public void associateIDWithPageViewport(String id, PageViewport pv) {
- idTracker.associateIDWithPageViewport(id, pv);
- }
-
- /**
- * This method tie an ID to the areaTreeHandler until this one is ready to
- * be processed. This is used in page-number-citation-last processing so we
- * know when an id can be resolved.
- *
- * @param id the id of the object being processed
- * @deprecated use getIDTracker().signalPendingID(id) instead
- */
- @Deprecated
- public void signalPendingID(String id) {
- idTracker.signalPendingID(id);
- }
-
- /**
- * Signals that all areas for the formatting object with the given ID have
- * been generated. This is used to determine when page-number-citation-last
- * ref-ids can be resolved.
- *
- * @param id the id of the formatting object which was just finished
- * @deprecated use getIDTracker().signalIDProcessed(id) instead
- */
- @Deprecated
- public void signalIDProcessed(String id) {
- idTracker.signalIDProcessed(id);
- }
-
- /**
- * Check if an ID has already been resolved
- *
- * @param id the id to check
- * @return true if the ID has been resolved
- * @deprecated use getIDTracker().alreadyResolvedID(id) instead
- */
- @Deprecated
- public boolean alreadyResolvedID(String id) {
- return idTracker.alreadyResolvedID(id);
- }
-
- /**
- * Tries to resolve all unresolved ID references on the given page.
- *
- * @param pv page viewport whose ID refs to resolve
- * @deprecated use getIDTracker().tryIDResolution(pv) instead
- */
- @Deprecated
- public void tryIDResolution(PageViewport pv) {
- idTracker.tryIDResolution(pv);
- }
-
- /**
- * Get the set of page viewports that have an area with a given id.
- *
- * @param id the id to lookup
- * @return the list of PageViewports
- * @deprecated use getIDTracker().getPageViewportsContainingID(id) instead
- */
- @Deprecated
- public List<PageViewport> getPageViewportsContainingID(String id) {
- return idTracker.getPageViewportsContainingID(id);
- }
-
- /**
- * Add an Resolvable object with an unresolved idref
- *
- * @param idref the idref whose target id has not yet been located
- * @param res the Resolvable object needing the idref to be resolved
- * @deprecated use getIDTracker().addUnresolvedIDRef(idref, res) instead
- */
- @Deprecated
- public void addUnresolvedIDRef(String idref, Resolvable res) {
- idTracker.addUnresolvedIDRef(idref, res);
- }
-
- private class Statistics {
- // for statistics gathering
- private Runtime runtime;
-
- // heap memory allocated (for statistics)
- private long initialMemory;
-
- // time used in rendering (for statistics)
- private long startTime;
-
- /**
- * Default constructor
- */
- protected Statistics() {
- this.runtime = Runtime.getRuntime();
- }
-
- /**
- * starts the area tree handler statistics gathering
- */
- protected void start() {
- this.initialMemory = runtime.totalMemory() - runtime.freeMemory();
- this.startTime = System.currentTimeMillis();
- }
-
- /**
- * ends the area tree handler statistics gathering
- */
- protected void end() {
- long memoryNow = runtime.totalMemory() - runtime.freeMemory();
- log.debug("Current heap size: " + (memoryNow / 1024L) + "KB");
- }
-
- /**
- * logs the results of the area tree handler statistics gathering
- */
- protected void logResults() {
- long memoryNow = runtime.totalMemory() - runtime.freeMemory();
- long memoryUsed = (memoryNow - initialMemory) / 1024L;
- long timeUsed = System.currentTimeMillis() - startTime;
- int pageCount = rootFObj.getTotalPagesGenerated();
- log.debug("Initial heap size: " + (initialMemory / 1024L) + "KB");
- log.debug("Current heap size: " + (memoryNow / 1024L) + "KB");
- log.debug("Total memory used: " + memoryUsed + "KB");
- log.debug("Total time used: " + timeUsed + "ms");
- log.debug("Pages rendered: " + pageCount);
- if (pageCount > 0) {
- long perPage = (timeUsed / pageCount);
- long ppm = (timeUsed != 0 ? Math.round(60000 * pageCount
- / (double) timeUsed) : -1);
- log.debug("Avg render time: " + perPage + "ms/page (" + ppm + "pages/min)");
- }
- }
- }
-}
diff --git a/src/java/org/apache/fop/area/AreaTreeModel.java b/src/java/org/apache/fop/area/AreaTreeModel.java
deleted file mode 100644
index baa30245e..000000000
--- a/src/java/org/apache/fop/area/AreaTreeModel.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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;
-
-// Java
-import java.util.List;
-import java.util.Locale;
-
-import org.xml.sax.SAXException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This is the model for the area tree object.
- * The model implementation can handle the page sequence,
- * page and off-document items.
- * The methods to access the page viewports can only
- * assume the PageViewport is valid as it remains for
- * the life of the area tree model.
- */
-public class AreaTreeModel {
- private List<PageSequence> pageSequenceList;
- private int currentPageIndex;
-
- /** the current page sequence */
- protected PageSequence currentPageSequence;
- /** logger instance */
- protected static final Log log = LogFactory.getLog(AreaTreeModel.class);
-
- /**
- * Create a new store pages model
- */
- public AreaTreeModel() {
- pageSequenceList = new java.util.ArrayList<PageSequence>();
- }
-
- /**
- * Start a page sequence on this model.
- * @param pageSequence the page sequence about to start
- */
- public void startPageSequence(PageSequence pageSequence) {
- if (pageSequence == null) {
- throw new NullPointerException("pageSequence must not be null");
- }
- if (currentPageSequence != null) {
- currentPageIndex += currentPageSequence.getPageCount();
- }
- this.currentPageSequence = pageSequence;
- pageSequenceList.add(currentPageSequence);
- }
-
- /**
- * Add a page to this model.
- * @param page the page to add to the model.
- */
- public void addPage(PageViewport page) {
- currentPageSequence.addPage(page);
- page.setPageIndex(currentPageIndex
- + currentPageSequence.getPageCount() - 1);
- page.setPageSequence(currentPageSequence);
- }
-
- /**
- * Handle an OffDocumentItem
- * @param ext the extension to handle
- */
- public void handleOffDocumentItem(OffDocumentItem ext) { };
-
- /**
- * Signal the end of the document for any processing.
- * @throws SAXException if a problem was encountered.
- */
- public void endDocument() throws SAXException { };
-
- /**
- * Returns the currently active page-sequence.
- * @return the currently active page-sequence
- */
- public PageSequence getCurrentPageSequence() {
- return this.currentPageSequence;
- }
-
- /**
- * Get the page sequence count.
- * @return the number of page sequences in the document.
- */
- public int getPageSequenceCount() {
- return pageSequenceList.size();
- }
-
- /**
- * Get the page count.
- * @param seq the page sequence to count.
- * @return returns the number of pages in a page sequence
- */
- public int getPageCount(int seq) {
- return pageSequenceList.get(seq - 1).getPageCount();
- }
-
- /**
- * Get the page for a position in the document.
- * @param seq the page sequence number
- * @param count the page count in the sequence
- * @return the PageViewport for the particular page
- */
- public PageViewport getPage(int seq, int count) {
- return pageSequenceList.get(seq - 1).getPage(count);
- }
-
- /**
- *
- * @param locale The locale of the document
- */
- public void setDocumentLocale(Locale locale) {
- }
-}
diff --git a/src/java/org/apache/fop/area/AreaTreeObject.java b/src/java/org/apache/fop/area/AreaTreeObject.java
deleted file mode 100644
index 02d81ef0a..000000000
--- a/src/java/org/apache/fop/area/AreaTreeObject.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * 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.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.xmlgraphics.util.QName;
-
-import org.apache.fop.fo.extensions.ExtensionAttachment;
-
-/**
- * Abstract base class for all area tree objects.
- */
-public abstract class AreaTreeObject implements Cloneable {
-
- /** Foreign attributes */
- protected Map<QName, String> foreignAttributes;
-
- /** Extension attachments */
- protected List<ExtensionAttachment> extensionAttachments;
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- public Object clone() throws CloneNotSupportedException {
- AreaTreeObject ato = (AreaTreeObject) super.clone();
- if (foreignAttributes != null) {
- // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION")
- ato.foreignAttributes = (Map<QName, String>)
- ((HashMap<QName, String>)foreignAttributes).clone();
- }
- if (extensionAttachments != null) {
- // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION")
- ato.extensionAttachments = (List<ExtensionAttachment>)
- ((ArrayList<ExtensionAttachment>) extensionAttachments).clone();
- }
- return ato;
- }
-
- /**
- * Sets a foreign attribute.
- * @param name the qualified name of the attribute
- * @param value the attribute value
- */
- public void setForeignAttribute(QName name, String value) {
- if (this.foreignAttributes == null) {
- this.foreignAttributes = new HashMap<QName, String>();
- }
- this.foreignAttributes.put(name, value);
- }
-
- /**
- * Add foreign attributes from a Map.
- *
- * @param atts a Map with attributes (keys: QName, values: String)
- */
- public void setForeignAttributes(Map<QName, String> atts) {
- if (atts == null || atts.size() == 0) {
- return;
- }
- for (Map.Entry<QName, String> e : atts.entrySet()) {
- setForeignAttribute(e.getKey(), e.getValue());
- }
- }
-
- /**
- * Returns the value of a foreign attribute on the area.
- * @param name the qualified name of the attribute
- * @return the attribute value or null if it isn't set
- */
- public String getForeignAttributeValue(QName name) {
- if (this.foreignAttributes != null) {
- return this.foreignAttributes.get(name);
- } else {
- return null;
- }
- }
-
- /** @return the foreign attributes associated with this area */
- public Map<QName, String> getForeignAttributes() {
- if (this.foreignAttributes != null) {
- return Collections.unmodifiableMap(this.foreignAttributes);
- } else {
- return Collections.emptyMap();
- }
- }
-
- private void prepareExtensionAttachmentContainer() {
- if (this.extensionAttachments == null) {
- this.extensionAttachments = new ArrayList<ExtensionAttachment>();
- }
- }
-
- /**
- * Adds a new ExtensionAttachment instance to this page.
- * @param attachment the ExtensionAttachment
- */
- public void addExtensionAttachment(ExtensionAttachment attachment) {
- prepareExtensionAttachmentContainer();
- extensionAttachments.add(attachment);
- }
-
- /**
- * Set extension attachments from a List
- * @param extensionAttachments a List with extension attachments
- */
- public void setExtensionAttachments(List<ExtensionAttachment> extensionAttachments) {
- prepareExtensionAttachmentContainer();
- this.extensionAttachments.addAll(extensionAttachments);
- }
-
- /** @return the extension attachments associated with this area */
- public List<ExtensionAttachment> getExtensionAttachments() {
- if (this.extensionAttachments != null) {
- return Collections.unmodifiableList(this.extensionAttachments);
- } else {
- return Collections.emptyList();
- }
- }
-
- /**
- * Indicates whether this area tree object has any extension attachments.
- * @return true if there are extension attachments
- */
- public boolean hasExtensionAttachments() {
- return this.extensionAttachments != null && !this.extensionAttachments.isEmpty();
- }
-
-}
diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java
deleted file mode 100644
index 640f04335..000000000
--- a/src/java/org/apache/fop/area/AreaTreeParser.java
+++ /dev/null
@@ -1,1225 +0,0 @@
-/*
- * 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.Color;
-import java.awt.Rectangle;
-import java.awt.geom.Rectangle2D;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.nio.CharBuffer;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.helpers.DefaultHandler;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.image.loader.ImageException;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.util.QName;
-
-import org.apache.fop.ResourceEventProducer;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.area.Trait.Background;
-import org.apache.fop.area.Trait.InternalLink;
-import org.apache.fop.area.inline.AbstractTextArea;
-import org.apache.fop.area.inline.Container;
-import org.apache.fop.area.inline.ForeignObject;
-import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.InlineBlockParent;
-import org.apache.fop.area.inline.InlineParent;
-import org.apache.fop.area.inline.InlineViewport;
-import org.apache.fop.area.inline.Leader;
-import org.apache.fop.area.inline.Space;
-import org.apache.fop.area.inline.SpaceArea;
-import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.fo.ElementMappingRegistry;
-import org.apache.fop.fo.expr.PropertyException;
-import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.traits.BorderProps;
-import org.apache.fop.util.ColorUtil;
-import org.apache.fop.util.ContentHandlerFactory;
-import org.apache.fop.util.ContentHandlerFactoryRegistry;
-import org.apache.fop.util.ConversionUtils;
-import org.apache.fop.util.DefaultErrorListener;
-import org.apache.fop.util.LanguageTags;
-import org.apache.fop.util.XMLConstants;
-import org.apache.fop.util.XMLUtil;
-
-import static org.apache.fop.fo.Constants.FO_REGION_AFTER;
-import static org.apache.fop.fo.Constants.FO_REGION_BEFORE;
-import static org.apache.fop.fo.Constants.FO_REGION_BODY;
-import static org.apache.fop.fo.Constants.FO_REGION_END;
-import static org.apache.fop.fo.Constants.FO_REGION_START;
-
-/**
- * This is a parser for the area tree XML (intermediate format) which is used to reread an area
- * tree (or part of it) into memory again for rendering to the final output format.
- */
-public class AreaTreeParser {
-
- /** Logger instance */
- protected static final Log log = LogFactory.getLog(AreaTreeParser.class);
-
- private static SAXTransformerFactory tFactory
- = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
-
- /**
- * Parses an intermediate file (area tree XML) into an AreaTreeModel instance by adding
- * pages to it.
- * @param src the Source instance pointing to the intermediate file
- * @param treeModel the AreaTreeModel that the parsed pages are added to
- * @param userAgent the user agent
- * @throws TransformerException if an error occurs while parsing the area tree XML
- */
- public void parse(Source src, AreaTreeModel treeModel, FOUserAgent userAgent)
- throws TransformerException {
- Transformer transformer = tFactory.newTransformer();
- transformer.setErrorListener(new DefaultErrorListener(log));
-
- SAXResult res = new SAXResult(getContentHandler(treeModel, userAgent));
-
- transformer.transform(src, res);
- }
-
- /**
- * Creates a new ContentHandler instance that you can send the area tree XML to. The parsed
- * pages are added to the AreaTreeModel instance you pass in as a parameter.
- * @param treeModel the AreaTreeModel that the parsed pages are added to
- * @param userAgent the user agent
- * @return the ContentHandler instance to receive the SAX stream from the area tree XML
- */
- public ContentHandler getContentHandler(AreaTreeModel treeModel, FOUserAgent userAgent) {
- ElementMappingRegistry elementMappingRegistry
- = userAgent.getElementMappingRegistry();
- return new Handler(treeModel, userAgent, elementMappingRegistry);
- }
-
- private static class Handler extends DefaultHandler {
-
- private Map<String, AbstractMaker> makers = new java.util.HashMap<String, AbstractMaker>();
-
- private AreaTreeModel treeModel;
- private FOUserAgent userAgent;
- private ElementMappingRegistry elementMappingRegistry;
-
- private Attributes lastAttributes;
-
- private CharBuffer content = CharBuffer.allocate(64);
- private boolean ignoreCharacters = true;
-
- private PageViewport currentPageViewport;
- private Map<String, PageViewport> pageViewportsByKey
- = new java.util.HashMap<String, PageViewport>();
- // set of "ID firsts" that have already been assigned to a PV:
- private Set<String> idFirstsAssigned = new java.util.HashSet<String>();
-
- private Stack<Object> areaStack = new Stack<Object>();
- private boolean firstFlow;
-
- private Stack<String> delegateStack = new Stack<String>();
- private ContentHandler delegate;
- private DOMImplementation domImplementation;
- private Locator locator;
-
- public Handler(AreaTreeModel treeModel, FOUserAgent userAgent,
- ElementMappingRegistry elementMappingRegistry) {
- this.treeModel = treeModel;
- this.userAgent = userAgent;
- this.elementMappingRegistry = elementMappingRegistry;
- makers.put("areaTree", new AreaTreeMaker());
- makers.put("page", new PageMaker());
- makers.put("pageSequence", new PageSequenceMaker());
- makers.put("title", new TitleMaker());
- makers.put("pageViewport", new PageViewportMaker());
- makers.put("regionViewport", new RegionViewportMaker());
- makers.put("regionBefore", new RegionBeforeMaker());
- makers.put("regionAfter", new RegionAfterMaker());
- makers.put("regionStart", new RegionStartMaker());
- makers.put("regionEnd", new RegionEndMaker());
- makers.put("regionBody", new RegionBodyMaker());
- makers.put("flow", new FlowMaker());
- makers.put("mainReference", new MainReferenceMaker());
- makers.put("span", new SpanMaker());
- makers.put("footnote", new FootnoteMaker());
- makers.put("beforeFloat", new BeforeFloatMaker());
- makers.put("block", new BlockMaker());
- makers.put("lineArea", new LineAreaMaker());
- makers.put("inline", new InlineMaker());
- makers.put("inlineparent", new InlineParentMaker());
- makers.put("inlineblockparent", new InlineBlockParentMaker());
- makers.put("text", new TextMaker());
- makers.put("word", new WordMaker());
- makers.put("space", new SpaceMaker());
- makers.put("leader", new LeaderMaker());
- makers.put("viewport", new InlineViewportMaker());
- makers.put("container", new ContainerMaker());
- makers.put("image", new ImageMaker());
- makers.put("foreignObject", new ForeignObjectMaker());
- makers.put("bookmarkTree", new BookmarkTreeMaker());
- makers.put("bookmark", new BookmarkMaker());
- makers.put("destination", new DestinationMaker());
- }
-
- private Area findAreaType(Class clazz) {
- if (areaStack.size() > 0) {
- int pos = areaStack.size() - 1;
- Object obj = null;
- while (pos >= 0) {
- obj = areaStack.get(pos);
- if (clazz.isInstance(obj)) {
- break;
- } else {
- pos--;
- }
- }
- if (pos >= 0) {
- return (Area)obj;
- }
- }
- return null;
- }
-
- private RegionViewport getCurrentRegionViewport() {
- return (RegionViewport)findAreaType(RegionViewport.class);
- }
-
- private BodyRegion getCurrentBodyRegion() {
- return (BodyRegion)findAreaType(BodyRegion.class);
- }
-
- private BlockParent getCurrentBlockParent() {
- return (BlockParent)findAreaType(BlockParent.class);
- }
-
- private AbstractTextArea getCurrentText() {
- return (AbstractTextArea)findAreaType(AbstractTextArea.class);
- }
-
- private InlineViewport getCurrentViewport() {
- return (InlineViewport)findAreaType(InlineViewport.class);
- }
-
- /** {@inheritDoc} */
- public void setDocumentLocator(Locator locator) {
- this.locator = locator;
- }
-
- private Locator getLocator() {
- return this.locator;
- }
-
- /** {@inheritDoc} */
- public void startElement(String uri, String localName, String qName, Attributes attributes)
- throws SAXException {
- if (delegate != null) {
- delegateStack.push(qName);
- delegate.startElement(uri, localName, qName, attributes);
- } else if (domImplementation != null) {
- //domImplementation is set so we need to start a new DOM building sub-process
- TransformerHandler handler;
- try {
- handler = tFactory.newTransformerHandler();
- } catch (TransformerConfigurationException e) {
- throw new SAXException("Error creating a new TransformerHandler", e);
- }
- Document doc = domImplementation.createDocument(uri, qName, null);
- //It's easier to work with an empty document, so remove the root element
- doc.removeChild(doc.getDocumentElement());
- handler.setResult(new DOMResult(doc));
- Area parent = (Area)areaStack.peek();
- ((ForeignObject)parent).setDocument(doc);
-
- //activate delegate for nested foreign document
- domImplementation = null; //Not needed anymore now
- this.delegate = handler;
- delegateStack.push(qName);
- delegate.startDocument();
- delegate.startElement(uri, localName, qName, attributes);
- } else {
- boolean handled = true;
- if ("".equals(uri)) {
- if (localName.equals("structureTree")) {
-
- /* The area tree parser no longer supports the structure tree. */
- delegate = new DefaultHandler();
-
- delegateStack.push(qName);
- delegate.startDocument();
- delegate.startElement(uri, localName, qName, attributes);
- } else {
- handled = startAreaTreeElement(localName, attributes);
- }
- } else {
- ContentHandlerFactoryRegistry registry
- = userAgent.getContentHandlerFactoryRegistry();
- ContentHandlerFactory factory = registry.getFactory(uri);
- if (factory != null) {
- delegate = factory.createContentHandler();
- delegateStack.push(qName);
- delegate.startDocument();
- delegate.startElement(uri, localName, qName, attributes);
- } else {
- handled = false;
- }
- }
- if (!handled) {
- if (uri == null || uri.length() == 0) {
- throw new SAXException("Unhandled element " + localName
- + " in namespace: " + uri);
- } else {
- log.warn("Unhandled element " + localName
- + " in namespace: " + uri);
- }
- }
- }
- }
-
- private boolean startAreaTreeElement(String localName, Attributes attributes)
- throws SAXException {
- lastAttributes = new AttributesImpl(attributes);
- Maker maker = makers.get(localName);
- content.clear();
- ignoreCharacters = true;
- if (maker != null) {
- ignoreCharacters = maker.ignoreCharacters();
- maker.startElement(attributes);
- } else if ("extension-attachments".equals(localName)) {
- //TODO implement me
- } else {
- return false;
- }
- return true;
- }
-
- /** {@inheritDoc} */
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (delegate != null) {
- delegate.endElement(uri, localName, qName);
- delegateStack.pop();
- if (delegateStack.size() == 0) {
- delegate.endDocument();
- if (delegate instanceof ContentHandlerFactory.ObjectSource) {
- Object obj = ((ContentHandlerFactory.ObjectSource)delegate).getObject();
- handleExternallyGeneratedObject(obj);
- }
- delegate = null; //Sub-document is processed, return to normal processing
- }
- } else {
- if ("".equals(uri)) {
- Maker maker = makers.get(localName);
- if (maker != null) {
- maker.endElement();
- content.clear();
- }
- ignoreCharacters = true;
- } else {
- //log.debug("Ignoring " + localName + " in namespace: " + uri);
- }
- }
- }
-
- // ============== Maker classes for the area tree objects =============
-
- private interface Maker {
- void startElement(Attributes attributes) throws SAXException;
- void endElement();
- boolean ignoreCharacters();
- }
-
- private abstract class AbstractMaker implements Maker {
-
- public void startElement(Attributes attributes) throws SAXException {
- //nop
- }
-
- public void endElement() {
- //nop
- }
-
- public boolean ignoreCharacters() {
- return true;
- }
- }
-
- private class AreaTreeMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- // In case the Handler is reused:
- idFirstsAssigned.clear();
- }
- }
-
- private class PageSequenceMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- PageSequence pageSequence = new PageSequence(null);
- String lang = attributes.getValue(javax.xml.XMLConstants.XML_NS_URI, "lang");
- if (lang != null) {
- pageSequence.setLocale(LanguageTags.toLocale(lang));
- }
- transferForeignObjects(attributes, pageSequence);
- areaStack.push(pageSequence);
- }
- }
-
- private class TitleMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- LineArea line = new LineArea();
- transferForeignObjects(attributes, line);
- areaStack.push(line);
- }
-
- public void endElement() {
- LineArea line = (LineArea)areaStack.pop();
- PageSequence pageSequence = (PageSequence)areaStack.peek();
- pageSequence.setTitle(line);
- }
-
- }
-
- private class PageViewportMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- if (!areaStack.isEmpty()) {
- PageSequence pageSequence = (PageSequence)areaStack.peek();
- treeModel.startPageSequence(pageSequence);
- areaStack.pop();
- }
- if (currentPageViewport != null) {
- throw new IllegalStateException("currentPageViewport must be null");
- }
- Rectangle viewArea = XMLUtil.getAttributeAsRectangle(attributes, "bounds");
- int pageNumber = XMLUtil.getAttributeAsInt(attributes, "nr", -1);
- String key = attributes.getValue("key");
- String pageNumberString = attributes.getValue("formatted-nr");
- String pageMaster = attributes.getValue("simple-page-master-name");
- boolean blank = XMLUtil.getAttributeAsBoolean(attributes, "blank", false);
- currentPageViewport = new PageViewport(viewArea,
- pageNumber, pageNumberString,
- pageMaster, blank);
- transferForeignObjects(attributes, currentPageViewport);
- currentPageViewport.setKey(key);
- pageViewportsByKey.put(key, currentPageViewport);
- }
-
- }
-
- private class PageMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- Page p = new Page();
- currentPageViewport.setPage(p);
- }
-
- public void endElement() {
- treeModel.addPage(currentPageViewport);
- currentPageViewport = null;
- }
- }
-
- private class RegionViewportMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- RegionViewport rv = getCurrentRegionViewport();
- if (rv != null) {
- throw new IllegalStateException("Current RegionViewport must be null");
- }
- Rectangle2D viewArea = XMLUtil.getAttributeAsRectangle2D(attributes, "rect");
- rv = new RegionViewport(viewArea);
- transferForeignObjects(attributes, rv);
- rv.setClip(XMLUtil.getAttributeAsBoolean(attributes, "clipped", false));
- setAreaAttributes(attributes, rv);
- setTraits(attributes, rv, SUBSET_COMMON);
- setTraits(attributes, rv, SUBSET_BOX);
- setTraits(attributes, rv, SUBSET_COLOR);
- areaStack.push(rv);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), RegionViewport.class);
- }
- }
-
- private class RegionBeforeMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- pushNewRegionReference(attributes, FO_REGION_BEFORE);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), RegionReference.class);
- }
- }
-
- private class RegionAfterMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- pushNewRegionReference(attributes, FO_REGION_AFTER);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), RegionReference.class);
- }
- }
-
- private class RegionStartMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- pushNewRegionReference(attributes, FO_REGION_START);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), RegionReference.class);
- }
- }
-
- private class RegionEndMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- pushNewRegionReference(attributes, FO_REGION_END);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), RegionReference.class);
- }
- }
-
- private class RegionBodyMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- BodyRegion body = getCurrentBodyRegion();
- if (body != null) {
- throw new IllegalStateException("Current BodyRegion must be null");
- }
- String regionName = attributes.getValue("name");
- int columnCount = XMLUtil.getAttributeAsInt(attributes, "columnCount", 1);
- int columnGap = XMLUtil.getAttributeAsInt(attributes, "columnGap", 0);
- RegionViewport rv = getCurrentRegionViewport();
- body = new BodyRegion(FO_REGION_BODY, regionName, rv, columnCount, columnGap);
- transferForeignObjects(attributes, body);
- body.setCTM(getAttributeAsCTM(attributes, "ctm"));
- setAreaAttributes(attributes, body);
- setTraits(attributes, body, SUBSET_BORDER_PADDING);
- rv.setRegionReference(body);
- currentPageViewport.getPage().setRegionViewport(FO_REGION_BODY, rv);
- areaStack.push(body);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), BodyRegion.class);
- }
- }
-
- private class FlowMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- BodyRegion body = getCurrentBodyRegion();
- if (!firstFlow) {
- body.getMainReference().getCurrentSpan().moveToNextFlow();
- } else {
- firstFlow = false;
- }
- NormalFlow flow = body.getMainReference().getCurrentSpan().getCurrentFlow();
- transferForeignObjects(attributes, flow);
- setAreaAttributes(attributes, flow);
- areaStack.push(flow);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), NormalFlow.class);
- }
- }
-
- private class MainReferenceMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- //mainReference is created by the BodyRegion
- MainReference mr = getCurrentBodyRegion().getMainReference();
- transferForeignObjects(attributes, mr);
- setAreaAttributes(attributes, mr);
- }
- }
-
- private class SpanMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- int ipd = XMLUtil.getAttributeAsInt(attributes, "ipd", 0);
- int columnCount = XMLUtil.getAttributeAsInt(attributes, "columnCount", 1);
- BodyRegion body = getCurrentBodyRegion();
- Span span = new Span(columnCount,
- body.getColumnGap(), ipd);
- transferForeignObjects(attributes, span);
- setAreaAttributes(attributes, span);
- body.getMainReference().getSpans().add(span);
- firstFlow = true;
- }
- }
-
- private class FootnoteMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- Footnote fn = getCurrentBodyRegion().getFootnote();
- transferForeignObjects(attributes, fn);
- fn.setTop(XMLUtil.getAttributeAsInt(attributes, "top-offset", 0));
- areaStack.push(fn);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), Footnote.class);
- }
- }
-
- private class BeforeFloatMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- BeforeFloat bf = getCurrentBodyRegion().getBeforeFloat();
- transferForeignObjects(attributes, bf);
- areaStack.push(bf);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), BeforeFloat.class);
- }
- }
-
- private class BlockMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- boolean isViewport = XMLUtil.getAttributeAsBoolean(attributes,
- "is-viewport-area", false);
- Block block;
- if (isViewport) {
- BlockViewport bv = new BlockViewport();
- bv.setClip(XMLUtil.getAttributeAsBoolean(attributes, "clipped", false));
- bv.setCTM(getAttributeAsCTM(attributes, "ctm"));
- if (bv.getPositioning() != BlockViewport.RELATIVE) {
- bv.setXOffset(
- XMLUtil.getAttributeAsInt(attributes, "left-position", 0));
- bv.setYOffset(
- XMLUtil.getAttributeAsInt(attributes, "top-position", 0));
- }
- block = bv;
- } else {
- block = new Block();
- }
- String positioning = attributes.getValue("positioning");
- if ("absolute".equalsIgnoreCase(positioning)) {
- block.setPositioning(Block.ABSOLUTE);
- } else if ("fixed".equalsIgnoreCase(positioning)) {
- block.setPositioning(Block.FIXED);
- } else if ("relative".equalsIgnoreCase(positioning)) {
- block.setPositioning(Block.RELATIVE);
- } else {
- block.setPositioning(Block.STACK);
- }
- if (attributes.getValue("left-offset") != null) {
- block.setXOffset(XMLUtil.getAttributeAsInt(attributes, "left-offset", 0));
- }
- if (attributes.getValue("top-offset") != null) {
- block.setYOffset(XMLUtil.getAttributeAsInt(attributes, "top-offset", 0));
- }
- transferForeignObjects(attributes, block);
- setAreaAttributes(attributes, block);
- setTraits(attributes, block, SUBSET_COMMON);
- setTraits(attributes, block, SUBSET_BOX);
- setTraits(attributes, block, SUBSET_COLOR);
- Area parent = (Area)areaStack.peek();
- //BlockParent parent = getCurrentBlockParent();
- parent.addChildArea(block);
- areaStack.push(block);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), Block.class);
- }
- }
-
- private class LineAreaMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- LineArea line = new LineArea();
- setAreaAttributes(attributes, line);
- setTraits(attributes, line, SUBSET_COMMON);
- setTraits(attributes, line, SUBSET_BOX);
- setTraits(attributes, line, SUBSET_COLOR);
- BlockParent parent = getCurrentBlockParent();
- parent.addChildArea(line);
- areaStack.push(line);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), LineArea.class);
- }
- }
-
- // Maker for "generic" inline areas
- private class InlineMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- InlineArea inl = new InlineArea();
- transferForeignObjects(attributes, inl);
- inl.setBlockProgressionOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
- setAreaAttributes(attributes, inl);
- setTraits(attributes, inl, SUBSET_COMMON);
- setTraits(attributes, inl, SUBSET_BOX);
- setTraits(attributes, inl, SUBSET_COLOR);
- Area parent = (Area)areaStack.peek();
- parent.addChildArea(inl);
- areaStack.push(inl);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), InlineArea.class);
- }
- }
-
- private class InlineParentMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- InlineParent ip = new InlineParent();
- transferForeignObjects(attributes, ip);
- ip.setBlockProgressionOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
- setAreaAttributes(attributes, ip);
- setTraits(attributes, ip, SUBSET_COMMON);
- setTraits(attributes, ip, SUBSET_BOX);
- setTraits(attributes, ip, SUBSET_COLOR);
- setTraits(attributes, ip, SUBSET_LINK);
- Area parent = (Area)areaStack.peek();
- parent.addChildArea(ip);
- areaStack.push(ip);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), InlineParent.class);
- }
- }
-
- private class InlineBlockParentMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- InlineBlockParent ibp = new InlineBlockParent();
- transferForeignObjects(attributes, ibp);
- ibp.setBlockProgressionOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
- setAreaAttributes(attributes, ibp);
- setTraits(attributes, ibp, SUBSET_COMMON);
- setTraits(attributes, ibp, SUBSET_BOX);
- setTraits(attributes, ibp, SUBSET_COLOR);
- Area parent = (Area)areaStack.peek();
- parent.addChildArea(ibp);
- areaStack.push(ibp);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), InlineBlockParent.class);
- }
- }
-
- private class TextMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- if (getCurrentText() != null) {
- throw new IllegalStateException("Current Text must be null");
- }
- TextArea text = new TextArea();
- setAreaAttributes(attributes, text);
- setTraits(attributes, text, SUBSET_COMMON);
- setTraits(attributes, text, SUBSET_BOX);
- setTraits(attributes, text, SUBSET_COLOR);
- setTraits(attributes, text, SUBSET_FONT);
- text.setBaselineOffset(XMLUtil.getAttributeAsInt(attributes, "baseline", 0));
- text.setBlockProgressionOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
- text.setTextLetterSpaceAdjust(XMLUtil.getAttributeAsInt(attributes,
- "tlsadjust", 0));
- text.setTextWordSpaceAdjust(XMLUtil.getAttributeAsInt(attributes,
- "twsadjust", 0));
- Area parent = (Area)areaStack.peek();
- parent.addChildArea(text);
- areaStack.push(text);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), TextArea.class);
- }
- }
-
- private class WordMaker extends AbstractMaker {
-
- public void endElement() {
- int offset = XMLUtil.getAttributeAsInt(lastAttributes, "offset", 0);
- int[] letterAdjust
- = ConversionUtils.toIntArray(
- lastAttributes.getValue("letter-adjust"), "\\s");
- int level = XMLUtil.getAttributeAsInt(lastAttributes, "level", -1);
- boolean reversed = XMLUtil.getAttributeAsBoolean(lastAttributes, "reversed", false);
- int[][] gposAdjustments
- = XMLUtil.getAttributeAsPositionAdjustments(lastAttributes, "position-adjust");
- content.flip();
- WordArea word = new WordArea(
- offset, level, content.toString().trim(), letterAdjust,
- null, gposAdjustments, reversed);
- AbstractTextArea text = getCurrentText();
- word.setParentArea(text);
- text.addChildArea(word);
- }
-
- public boolean ignoreCharacters() {
- return false;
- }
- }
-
- private class SpaceMaker extends AbstractMaker {
-
- public void endElement() {
- int offset = XMLUtil.getAttributeAsInt(lastAttributes, "offset", 0);
- //TODO the isAdjustable parameter is currently not used/implemented
- if (content.position() > 0) {
- content.flip();
- boolean adjustable = XMLUtil.getAttributeAsBoolean(lastAttributes, "adj", true);
- int level = XMLUtil.getAttributeAsInt(lastAttributes, "level", -1);
- SpaceArea space = new SpaceArea(offset, level, content.charAt(0), adjustable);
- AbstractTextArea text = getCurrentText();
- space.setParentArea(text);
- text.addChildArea(space);
- } else {
- Space space = new Space();
- setAreaAttributes(lastAttributes, space);
- setTraits(lastAttributes, space, SUBSET_COMMON);
- setTraits(lastAttributes, space, SUBSET_BOX);
- setTraits(lastAttributes, space, SUBSET_COLOR);
- space.setBlockProgressionOffset(offset);
- Area parent = (Area)areaStack.peek();
- parent.addChildArea(space);
- }
- }
-
- public boolean ignoreCharacters() {
- return false;
- }
- }
-
- private class LeaderMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- Leader leader = new Leader();
- transferForeignObjects(attributes, leader);
- setAreaAttributes(attributes, leader);
- setTraits(attributes, leader, SUBSET_COMMON);
- setTraits(attributes, leader, SUBSET_BOX);
- setTraits(attributes, leader, SUBSET_COLOR);
- setTraits(attributes, leader, SUBSET_FONT);
- leader.setBlockProgressionOffset(
- XMLUtil.getAttributeAsInt(attributes, "offset", 0));
- String ruleStyle = attributes.getValue("ruleStyle");
- if (ruleStyle != null) {
- leader.setRuleStyle(ruleStyle);
- }
- leader.setRuleThickness(
- XMLUtil.getAttributeAsInt(attributes, "ruleThickness", 0));
- Area parent = (Area)areaStack.peek();
- parent.addChildArea(leader);
- }
- }
-
- private class ContainerMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- Container container = new Container();
- transferForeignObjects(attributes, container);
- InlineViewport parent = (InlineViewport) areaStack.peek();
- parent.setContent(container);
- areaStack.push(container);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), Container.class);
- }
- }
-
- private class InlineViewportMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- int level = XMLUtil.getAttributeAsInt(attributes, "level", -1);
- InlineViewport viewport = new InlineViewport(null, level);
- transferForeignObjects(attributes, viewport);
- setAreaAttributes(attributes, viewport);
- setTraits(attributes, viewport, SUBSET_COMMON);
- setTraits(attributes, viewport, SUBSET_BOX);
- setTraits(attributes, viewport, SUBSET_COLOR);
- viewport.setContentPosition(XMLUtil.getAttributeAsRectangle2D(attributes, "pos"));
- viewport.setClip(XMLUtil.getAttributeAsBoolean(attributes, "clip", false));
- viewport.setBlockProgressionOffset(
- XMLUtil.getAttributeAsInt(attributes, "offset", 0));
- Area parent = (Area)areaStack.peek();
- parent.addChildArea(viewport);
- areaStack.push(viewport);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), InlineViewport.class);
- }
- }
-
- private class ImageMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- String url = attributes.getValue("url");
- Image image = new Image(url);
- transferForeignObjects(attributes, image);
- setAreaAttributes(attributes, image);
- setTraits(attributes, image, SUBSET_COMMON);
- getCurrentViewport().setContent(image);
- }
- }
-
- private class ForeignObjectMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) throws SAXException {
- String ns = attributes.getValue("ns");
- domImplementation
- = elementMappingRegistry.getDOMImplementationForNamespace(ns);
- if (domImplementation == null) {
- throw new SAXException("No DOMImplementation could be"
- + " identified to handle namespace: " + ns);
- }
- ForeignObject foreign = new ForeignObject(ns);
- transferForeignObjects(attributes, foreign);
- setAreaAttributes(attributes, foreign);
- setTraits(attributes, foreign, SUBSET_COMMON);
- getCurrentViewport().setContent(foreign);
- areaStack.push(foreign);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), ForeignObject.class);
- }
- }
-
- private class BookmarkTreeMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- BookmarkData bm = new BookmarkData();
- areaStack.push(bm);
- }
-
- public void endElement() {
- Object tos = areaStack.pop();
- assertObjectOfClass(tos, BookmarkData.class);
- treeModel.handleOffDocumentItem((BookmarkData) tos);
- // as long as the bookmark tree comes after the last PageViewport in the
- // area tree XML, we don't have to worry about resolved/unresolved. The
- // only resolution needed is the mapping of the pvKey to the PV instance.
- }
- }
-
- private class BookmarkMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- String title = attributes.getValue("title");
- boolean showChildren = XMLUtil.getAttributeAsBoolean(
- attributes, "show-children", false);
- String[] linkdata
- = InternalLink.parseXMLAttribute(attributes.getValue("internal-link"));
- PageViewport pv = pageViewportsByKey.get(linkdata[0]);
- BookmarkData bm = new BookmarkData(title, showChildren, pv, linkdata[1]);
- Object tos = areaStack.peek();
- if (tos instanceof BookmarkData) {
- BookmarkData parent = (BookmarkData) tos;
- parent.addSubData(bm);
- }
- areaStack.push(bm);
- }
-
- public void endElement() {
- assertObjectOfClass(areaStack.pop(), BookmarkData.class);
- }
- }
-
- private class DestinationMaker extends AbstractMaker {
-
- public void startElement(Attributes attributes) {
- String[] linkdata
- = InternalLink.parseXMLAttribute(lastAttributes.getValue("internal-link"));
- PageViewport pv = pageViewportsByKey.get(linkdata[0]);
- DestinationData dest = new DestinationData(linkdata[1]);
- List<PageViewport> pages = new java.util.ArrayList<PageViewport>();
- pages.add(pv);
- dest.resolveIDRef(linkdata[1], pages);
- areaStack.push(dest);
- }
-
- public void endElement() {
- Object tos = areaStack.pop();
- assertObjectOfClass(tos, DestinationData.class);
- treeModel.handleOffDocumentItem((DestinationData) tos);
- }
- }
-
- // ====================================================================
-
-
- private void pushNewRegionReference(Attributes attributes, int side) {
- String regionName = attributes.getValue("name");
- RegionViewport rv = getCurrentRegionViewport();
- RegionReference reg = new RegionReference(side,
- regionName, rv);
- transferForeignObjects(attributes, reg);
- reg.setCTM(getAttributeAsCTM(attributes, "ctm"));
- setAreaAttributes(attributes, reg);
- setTraits(attributes, reg, SUBSET_BORDER_PADDING);
- rv.setRegionReference(reg);
- currentPageViewport.getPage().setRegionViewport(
- side, rv);
- areaStack.push(reg);
- }
-
- private void assertObjectOfClass(Object obj, Class clazz) {
- if (!clazz.isInstance(obj)) {
- throw new IllegalStateException("Object is not an instance of "
- + clazz.getName() + " but of " + obj.getClass().getName());
- }
- }
-
- /**
- * Handles objects created by "sub-parsers" that implement the ObjectSource interface.
- * An example of object handled here are ExtensionAttachments.
- * @param obj the Object to be handled.
- */
- protected void handleExternallyGeneratedObject(Object obj) {
- if (areaStack.size() == 0 && obj instanceof ExtensionAttachment) {
- ExtensionAttachment attachment = (ExtensionAttachment)obj;
- if (this.currentPageViewport == null) {
- this.treeModel.handleOffDocumentItem(
- new OffDocumentExtensionAttachment(attachment));
- } else {
- this.currentPageViewport.addExtensionAttachment(attachment);
- }
- } else {
- Object o = areaStack.peek();
- if (o instanceof AreaTreeObject && obj instanceof ExtensionAttachment) {
- AreaTreeObject ato = (AreaTreeObject)o;
- ExtensionAttachment attachment = (ExtensionAttachment)obj;
- ato.addExtensionAttachment(attachment);
- } else {
- log.warn("Don't know how to handle externally generated object: " + obj);
- }
- }
- }
-
- private void setAreaAttributes(Attributes attributes, Area area) {
- area.setIPD(Integer.parseInt(attributes.getValue("ipd")));
- area.setBPD(Integer.parseInt(attributes.getValue("bpd")));
- area.setBidiLevel(XMLUtil.getAttributeAsInt(attributes, "level", -1));
- }
-
- private static final Object[] SUBSET_COMMON = new Object[] {
- Trait.PROD_ID, Trait.LAYER};
- private static final Object[] SUBSET_LINK = new Object[] {
- Trait.INTERNAL_LINK, Trait.EXTERNAL_LINK};
- private static final Object[] SUBSET_COLOR = new Object[] {
- Trait.BACKGROUND, Trait.COLOR};
- private static final Object[] SUBSET_FONT = new Object[] {
- Trait.FONT, Trait.FONT_SIZE, Trait.BLINK,
- Trait.OVERLINE, Trait.OVERLINE_COLOR,
- Trait.LINETHROUGH, Trait.LINETHROUGH_COLOR,
- Trait.UNDERLINE, Trait.UNDERLINE_COLOR};
- private static final Object[] SUBSET_BOX = new Object[] {
- Trait.BORDER_BEFORE, Trait.BORDER_AFTER, Trait.BORDER_START, Trait.BORDER_END,
- Trait.SPACE_BEFORE, Trait.SPACE_AFTER, Trait.SPACE_START, Trait.SPACE_END,
- Trait.PADDING_BEFORE, Trait.PADDING_AFTER, Trait.PADDING_START, Trait.PADDING_END,
- Trait.START_INDENT, Trait.END_INDENT,
- Trait.IS_REFERENCE_AREA, Trait.IS_VIEWPORT_AREA};
- private static final Object[] SUBSET_BORDER_PADDING = new Object[] {
- Trait.BORDER_BEFORE, Trait.BORDER_AFTER, Trait.BORDER_START, Trait.BORDER_END,
- Trait.PADDING_BEFORE, Trait.PADDING_AFTER, Trait.PADDING_START, Trait.PADDING_END};
-
- private void setTraits(Attributes attributes, Area area, Object[] traitSubset) {
- for (int i = traitSubset.length; --i >= 0;) {
- Integer trait = (Integer) traitSubset[i];
- String traitName = Trait.getTraitName(trait);
- String value = attributes.getValue(traitName);
- if (value != null) {
- Class cl = Trait.getTraitClass(trait);
- if (cl == Integer.class) {
- area.addTrait(trait, new Integer(value));
- } else if (cl == Boolean.class) {
- area.addTrait(trait, Boolean.valueOf(value));
- } else if (cl == String.class) {
- area.addTrait(trait, value);
- if (Trait.PROD_ID.equals(trait)
- && !idFirstsAssigned.contains(value)
- && currentPageViewport != null) {
- currentPageViewport.setFirstWithID(value);
- idFirstsAssigned.add(value);
- }
- } else if (cl == Color.class) {
- try {
- area.addTrait(trait, ColorUtil.parseColorString(this.userAgent, value));
- } catch (PropertyException e) {
- throw new IllegalArgumentException(e.getMessage());
- }
- } else if (cl == InternalLink.class) {
- area.addTrait(trait, new InternalLink(value));
- } else if (cl == Trait.ExternalLink.class) {
- area.addTrait(trait, Trait.ExternalLink.makeFromTraitValue(value));
- } else if (cl == Background.class) {
- Background bkg = new Background();
- try {
- Color col = ColorUtil.parseColorString(
- this.userAgent, attributes.getValue("bkg-color"));
- bkg.setColor(col);
- } catch (PropertyException e) {
- throw new IllegalArgumentException(e.getMessage());
- }
- String uri = attributes.getValue("bkg-img");
- if (uri != null) {
- bkg.setURL(uri);
-
- try {
- ImageManager manager = userAgent.getImageManager();
- ImageSessionContext sessionContext
- = userAgent.getImageSessionContext();
- ImageInfo info = manager.getImageInfo(uri, sessionContext);
- bkg.setImageInfo(info);
- } catch (ImageException e) {
- ResourceEventProducer eventProducer
- = ResourceEventProducer.Provider.get(
- this.userAgent.getEventBroadcaster());
- eventProducer.imageError(this, uri, e, getLocator());
- } catch (FileNotFoundException fnfe) {
- ResourceEventProducer eventProducer
- = ResourceEventProducer.Provider.get(
- this.userAgent.getEventBroadcaster());
- eventProducer.imageNotFound(this, uri, fnfe, getLocator());
- } catch (IOException ioe) {
- ResourceEventProducer eventProducer
- = ResourceEventProducer.Provider.get(
- this.userAgent.getEventBroadcaster());
- eventProducer.imageIOError(this, uri, ioe, getLocator());
- }
-
- String repeat = attributes.getValue("bkg-repeat");
- if (repeat != null) {
- bkg.setRepeat(repeat);
- }
- bkg.setHoriz(XMLUtil.getAttributeAsInt(attributes,
- "bkg-horz-offset", 0));
- bkg.setVertical(XMLUtil.getAttributeAsInt(attributes,
- "bkg-vert-offset", 0));
- }
- area.addTrait(trait, bkg);
- } else if (cl == BorderProps.class) {
- area.addTrait(trait, BorderProps.valueOf(this.userAgent, value));
- }
- } else {
- if (Trait.FONT.equals(trait)) {
- String fontName = attributes.getValue("font-name");
- if (fontName != null) {
- String fontStyle = attributes.getValue("font-style");
- int fontWeight = XMLUtil.getAttributeAsInt(
- attributes, "font-weight", Font.WEIGHT_NORMAL);
- area.addTrait(trait,
- FontInfo.createFontKey(fontName, fontStyle, fontWeight));
- }
- }
- }
- }
- }
-
- private static CTM getAttributeAsCTM(Attributes attributes, String name) {
- String s = attributes.getValue(name).trim();
- if (s.startsWith("[") && s.endsWith("]")) {
- s = s.substring(1, s.length() - 1);
- double[] values = ConversionUtils.toDoubleArray(s, "\\s");
- if (values.length != 6) {
- throw new IllegalArgumentException("CTM must consist of 6 double values!");
- }
- return new CTM(values[0], values[1], values[2], values[3], values[4], values[5]);
- } else {
- throw new IllegalArgumentException("CTM must be surrounded by square brackets!");
- }
- }
-
- private static void transferForeignObjects(Attributes atts, AreaTreeObject ato) {
- for (int i = 0, c = atts.getLength(); i < c; i++) {
- String ns = atts.getURI(i);
- if (ns.length() > 0) {
- if (XMLConstants.XMLNS_NAMESPACE_URI.equals(ns)) {
- continue;
- }
- QName qname = new QName(ns, atts.getQName(i));
- ato.setForeignAttribute(qname, atts.getValue(i));
- }
- }
- }
-
- /** {@inheritDoc} */
- public void characters(char[] ch, int start, int length) throws SAXException {
- if (delegate != null) {
- delegate.characters(ch, start, length);
- } else if (!ignoreCharacters) {
- int maxLength = this.content.capacity() - this.content.position();
- if (maxLength < length) {
- // allocate a larger buffer and transfer content
- CharBuffer newContent
- = CharBuffer.allocate(this.content.position() + length);
- this.content.flip();
- newContent.put(this.content);
- this.content = newContent;
- }
- // make sure the full capacity is used
- this.content.limit(this.content.capacity());
- // add characters to the buffer
- this.content.put(ch, start, length);
- // decrease the limit, if necessary
- if (this.content.position() < this.content.limit()) {
- this.content.limit(this.content.position());
- }
- }
- }
- }
-}
diff --git a/src/java/org/apache/fop/area/BeforeFloat.java b/src/java/org/apache/fop/area/BeforeFloat.java
deleted file mode 100644
index 37f7332a0..000000000
--- a/src/java/org/apache/fop/area/BeforeFloat.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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;
-
-/**
- * The before-float-reference-area optionally generated by an fo:region-body.
- * It has an optional separator and before float block children.
- * See fo:region-body definition in the XSL Rec for more information.
- */
-public class BeforeFloat extends BlockParent {
-
- private static final long serialVersionUID = 4101415711488333380L;
-
- // this is an optional block area that will be rendered
- // as the separator only if there are float areas
- private Block separator;
-
- /**
- * Set the separator area for this before float.
- *
- * @param sep the before float separator area
- */
- public void setSeparator(Block sep) {
- separator = sep;
- }
-
- /**
- * Get the separator area for this before float.
- *
- * @return the before float separator area
- */
- public Block getSeparator() {
- return separator;
- }
-
- /**
- * Get the height of this before float.
- * It gets the height of the children and if there is a
- * separator its height is also added.
- *
- * @return the height of the before float including separator
- */
- @Override
- public int getBPD() {
- int h = super.getBPD();
- if (separator != null) {
- h += separator.getBPD();
- }
- return h;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isEmpty() {
- return true; // before floats are not yet implemented
- }
-}
-
diff --git a/src/java/org/apache/fop/area/Block.java b/src/java/org/apache/fop/area/Block.java
deleted file mode 100644
index 565146415..000000000
--- a/src/java/org/apache/fop/area/Block.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * 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.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Locale;
-
-// block areas hold either more block areas or line
-// areas can also be used as a block spacer
-// a block area may have children positioned by stacking
-// or by relative to the parent for floats, tables and lists
-// cacheable object
-// has id information
-
-/**
- * This is the block area class.
- * It holds child block areas such as other blocks or lines.
- */
-public class Block extends BlockParent {
-
- private static final long serialVersionUID = 6843727817993665788L;
-
- /**
- * Normally stacked with other blocks.
- */
- public static final int STACK = 0;
-
- /**
- * Placed relative to the flow position.
- * This effects the flow placement of stacking normally.
- */
- public static final int RELATIVE = 1;
-
- /**
- * Relative to the block parent but not effecting the stacking
- * Used for block-container, tables and lists.
- */
- public static final int ABSOLUTE = 2;
-
- /**
- * Relative to a viewport/page but not effecting the stacking
- * Used for block-container.
- */
- public static final int FIXED = 3;
-
- private int positioning = STACK;
-
- /** if true, allow BPD update */
- protected transient boolean allowBPDUpdate;
-
- private Locale locale;
-
- private String location;
-
- public Block() {
- allowBPDUpdate = true;
- }
-
- private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- }
-
- /**
- * Add the block to this block area.
- *
- * @param block the block area to add
- */
- public void addBlock(Block block) {
- addBlock(block, true);
- }
-
- /**
- * Add the block to this block area.
- *
- * @param block the block area to add
- * @param autoHeight increase the height of the block.
- */
- public void addBlock(Block block, boolean autoHeight) {
- if (autoHeight && allowBPDUpdate && block.isStacked()) {
- bpd += block.getAllocBPD();
- }
- addChildArea(block);
- }
-
- /**
- * Add the line area to this block area.
- *
- * @param line the line area to add
- */
- public void addLineArea(LineArea line) {
- bpd += line.getAllocBPD();
- addChildArea(line);
- }
-
- /**
- * Set the positioning of this area.
- *
- * @param pos the positioning to use when rendering this area
- */
- public void setPositioning(int pos) {
- positioning = pos;
- }
-
- /**
- * Get the positioning of this area.
- *
- * @return the positioning to use when rendering this area
- */
- public int getPositioning() {
- return positioning;
- }
-
- /**
- * Indicates whether this block is stacked, rather than absolutely positioned.
- * @return true if it is stacked
- */
- public boolean isStacked() {
- return (getPositioning() == Block.STACK || getPositioning() == Block.RELATIVE);
- }
-
- /**
- * @return the start-indent trait
- */
- public int getStartIndent() {
- Integer startIndent = (Integer)getTrait(Trait.START_INDENT);
- return (startIndent != null ? startIndent : 0);
- }
-
- /**
- * @return the end-indent trait
- */
- public int getEndIndent() {
- Integer endIndent = (Integer)getTrait(Trait.END_INDENT);
- return (endIndent != null ? endIndent : 0);
- }
-
- /**
- * Sets the language information coming from the FO that generated this area.
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- /**
- * Returns the language information for the FO that generated this area.
- */
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * Sets the location in the source XML of the FO that generated this area.
- *
- * @location the line and column location
- */
- public void setLocation(String location) {
- this.location = location;
- }
-
- /**
- * Returns the location in the source XML of the FO that generated this area.
- *
- * @return the line and column location, {@code null} if that information is not available
- */
- public String getLocation() {
- return location;
- }
-
- // maybe this can be done in the parent?
- public int getEffectiveIPD() {
- int eIPD = super.getEffectiveIPD();
- if (eIPD != 0) {
- effectiveIPD = eIPD;
- }
- return eIPD;
- }
-
- // maybe this can be done in the parent?
- public void activateEffectiveIPD() {
- super.activateEffectiveIPD();
- if (effectiveIPD != -1) {
- ipd = effectiveIPD;
- }
- }
-}
-
diff --git a/src/java/org/apache/fop/area/BlockParent.java b/src/java/org/apache/fop/area/BlockParent.java
deleted file mode 100644
index fa599f31a..000000000
--- a/src/java/org/apache/fop/area/BlockParent.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.util.ArrayList;
-import java.util.List;
-
-/**
- * A BlockParent holds block-level areas.
- */
-public class BlockParent extends Area {
-
- private static final long serialVersionUID = 7076916890348533805L;
-
- // this position is used for absolute position
- // or as an indent
- // this has the size in the block progression dimension
-
- /**
- * The x offset position of this block parent.
- * Used for relative (serves as left-offset trait) and absolute positioning
- * (serves as left-position trait).
- */
- protected int xOffset;
-
- /**
- * The y offset position of this block parent.
- * Used for relative (serves as top-offset trait) and absolute positioning
- * (serves as top-position trait).
- */
- protected int yOffset;
-
- /**
- * The children of this block parent area.
- */
- protected List<Area> children;
-
- /** {@inheritDoc} */
- @Override
- public void addChildArea(Area childArea) {
- if (children == null) {
- children = new ArrayList<Area>();
- }
- children.add(childArea);
- }
-
- /**
- * Add the block area to this block parent.
- *
- * @param block the child block area to add
- */
- public void addBlock(Block block) {
- addChildArea(block);
- }
-
- /**
- * Get the list of child areas for this block area.
- *
- * @return the list of child areas
- */
- public List getChildAreas() {
- return children;
- }
-
- /**
- * Check whether there are child areas.
- *
- * @return the result.
- */
- public boolean isEmpty() {
- return children == null || children.size() == 0;
- }
-
- /**
- * Set the X offset of this block parent area.
- *
- * @param off the x offset of the block parent area
- */
- public void setXOffset(int off) {
- xOffset = off;
- }
-
- /**
- * Set the Y offset of this block parent area.
- *
- * @param off the y offset of the block parent area
- */
- public void setYOffset(int off) {
- yOffset = off;
- }
-
- /**
- * Get the X offset of this block parent area.
- *
- * @return the x offset of the block parent area
- */
- public int getXOffset() {
- return xOffset;
- }
-
- /**
- * Get the Y offset of this block parent area.
- *
- * @return the y offset of the block parent area
- */
- public int getYOffset() {
- return yOffset;
- }
-
- public int getEffectiveIPD() {
- int maxIPD = 0;
- if (children != null) {
- for (Area area : children) {
- int effectiveIPD = area.getEffectiveIPD();
- if (effectiveIPD > maxIPD) {
- maxIPD = effectiveIPD;
- }
- }
- }
- return maxIPD;
- }
-
- public void activateEffectiveIPD() {
- if (children != null) {
- for (Area area : children) {
- area.activateEffectiveIPD();
- }
- }
- }
-}
diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java
deleted file mode 100644
index d33a060e4..000000000
--- a/src/java/org/apache/fop/area/BlockViewport.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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 BlockViewport.
- * This is used for block level Viewport/reference pairs.
- * The block-container creates this area.
- */
-public class BlockViewport extends Block implements Viewport {
-
- private static final long serialVersionUID = -7840580922580735157L;
-
- // clipping for this viewport
- private boolean clip;
- // transform if rotated or absolute
- private CTM viewportCTM;
-
- /**
- * Create a new block viewport area.
- */
- public BlockViewport() {
- this(false);
- }
-
- /**
- * Create a new block viewport area.
- * @param allowBPDUpdate true allows the BPD to be updated when children are added
- */
- public BlockViewport(boolean allowBPDUpdate) {
- this.allowBPDUpdate = allowBPDUpdate;
- }
-
- /**
- * Set the transform of this viewport.
- * If the viewport is rotated or has an absolute positioning
- * this transform will do the work.
- *
- * @param ctm the transformation
- */
- public void setCTM(CTM ctm) {
- viewportCTM = ctm;
- }
-
- /**
- * Get the transform of this block viewport.
- *
- * @return the transformation of this viewport
- * or null if normally stacked without rotation
- */
- public CTM getCTM() {
- return viewportCTM;
- }
-
- /**
- * Set the clipping for this viewport.
- *
- * @param cl the clipping for the viewport
- */
- public void setClip(boolean cl) {
- clip = cl;
- }
-
- /** {@inheritDoc} */
- public boolean hasClip() {
- return clip;
- }
-
- /** {@inheritDoc} */
- public Rectangle getClipRectangle() {
- if (clip) {
- return new Rectangle(getIPD(), getBPD());
- } else {
- return null;
- }
- }
-
- public int getEffectiveIPD() {
- return getIPD();
- }
-}
-
diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java
deleted file mode 100644
index df7e914b7..000000000
--- a/src/java/org/apache/fop/area/BodyRegion.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.util.List;
-
-import org.apache.fop.fo.pagination.RegionBody;
-import org.apache.fop.traits.WritingModeTraitsGetter;
-
-/**
- * This class is a container for the areas that may be generated by
- * an fo:region-body. It extends the RegionReference that is used
- * directly by the other region classes.
- * See fo:region-body definition in the XSL Rec for more information.
- */
-public class BodyRegion extends RegionReference {
-
- private static final long serialVersionUID = -1848872997724078080L;
-
- private BeforeFloat beforeFloat; // optional
- private MainReference mainReference; // mandatory
- private Footnote footnote; // optional
- private int columnGap;
- private int columnCount;
-
- /**
- * Constructor which can read traits directly
- * from an fo:region-body formatting object.
- * @param rb the region-body FO node
- * @param parent the parent region viewport
- */
- public BodyRegion(RegionBody rb, RegionViewport parent) {
- this(rb.getNameId(), rb.getRegionName(), parent, rb.getColumnCount(), rb.getColumnGap());
- }
-
- /**
- * Constructor which can read traits directly
- * from an fo:region-body formatting object.
- * @param regionClass the region class (as returned by Region.getNameId())
- * @param regionName the name of the region (as returned by Region.getRegionName())
- * @param parent the parent region viewport
- * @param columnCount the number of columns
- * @param columnGap the gap between columns
- */
- public BodyRegion(int regionClass, String regionName, RegionViewport parent,
- int columnCount, int columnGap) {
- super(regionClass, regionName, parent);
- this.columnCount = columnCount;
- this.columnGap = columnGap;
- mainReference = new MainReference(this);
- }
-
- /**
- * Get the number of columns when not spanning
- *
- * @return the number of columns
- */
- public int getColumnCount() {
- return this.columnCount;
- }
-
- /** @return the column-gap value */
- public int getColumnGap() {
- return this.columnGap;
- }
-
- int getContentIPD() {
- RegionViewport rv = getRegionViewport();
- return getIPD() - rv.getBorderAndPaddingWidthStart() - rv.getBorderAndPaddingWidthEnd();
- }
-
- public int getColumnIPD() {
- return (getContentIPD() - (columnCount - 1) * columnGap) / columnCount;
- }
-
- /**
- * Get the main reference area.
- *
- * @return the main reference area
- */
- public MainReference getMainReference() {
- return mainReference;
- }
-
- /**
- * indicates whether the main reference area has any child areas added to it
- *
- * @return whether the main reference area has any child areas added to it
- */
- public boolean isEmpty() {
- return (mainReference == null || mainReference.isEmpty())
- && (footnote == null || footnote.isEmpty())
- && (beforeFloat == null || beforeFloat.isEmpty());
- }
-
-
- /**
- * Get the before float area.
- *
- * @return the before float area
- */
- public BeforeFloat getBeforeFloat() {
- if (beforeFloat == null) {
- beforeFloat = new BeforeFloat();
- }
- return beforeFloat;
- }
-
- /**
- * Get the footnote area.
- *
- * @return the footnote area
- */
- public Footnote getFootnote() {
- if (footnote == null) {
- footnote = new Footnote();
- }
- return footnote;
- }
-
- /**
- * @return the available BPD in the main reference area after the previous span reference
- * areas are subtracted.
- */
- public int getRemainingBPD() {
- int usedBPD = 0;
- List<Span> spans = getMainReference().getSpans();
- int previousSpanCount = spans.size() - 1;
- for (int i = 0; i < previousSpanCount; i++) {
- usedBPD += spans.get(i).getHeight();
- }
- return getBPD() - usedBPD;
- }
-
- /**
- * Sets the writing mode traits for the main reference area of
- * this body region area.
- * @param wmtg a WM traits getter
- */
- public void setWritingModeTraits(WritingModeTraitsGetter wmtg) {
- if (getMainReference() != null) {
- getMainReference().setWritingModeTraits(wmtg);
- }
- }
-
- /** {@inheritDoc} */
- public Object clone() throws CloneNotSupportedException {
- BodyRegion br = (BodyRegion) super.clone();
- br.mainReference = new MainReference(br);
- br.mainReference.setSpans(mainReference.getSpans());
- return br;
- }
-
-}
diff --git a/src/java/org/apache/fop/area/BookmarkData.java b/src/java/org/apache/fop/area/BookmarkData.java
deleted file mode 100644
index 495fd1901..000000000
--- a/src/java/org/apache/fop/area/BookmarkData.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * 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.util.List;
-import java.util.Map;
-
-import org.apache.fop.fo.pagination.bookmarks.Bookmark;
-import org.apache.fop.fo.pagination.bookmarks.BookmarkTree;
-
-/**
- * An instance of this class is either a PDF bookmark-tree and
- * its child bookmark-items, or a bookmark-item and the child
- * child bookmark-items under it.
- */
-public class BookmarkData extends AbstractOffDocumentItem implements Resolvable {
-
- private List<BookmarkData> subData = new java.util.ArrayList<BookmarkData>();
-
- // bookmark-title for this fo:bookmark
- private String bookmarkTitle;
-
- // indicator of whether to initially display/hide child bookmarks of this object
- private boolean showChildren = true;
-
- // ID Reference for this bookmark
- private String idRef;
-
- // PageViewport that the idRef item refers to
- private PageViewport pageRef;
-
- // unresolved idrefs by this bookmark and child bookmarks below it
- private Map<String, List<Resolvable>> unresolvedIDRefs
- = new java.util.HashMap<String, List<Resolvable>>();
-
- /**
- * Create a new bookmark data object.
- * This should only be called by the bookmark-tree item because
- * it has no idref item that needs to be resolved.
- *
- * @param bookmarkTree fo:bookmark-tree for this document
- */
- public BookmarkData(BookmarkTree bookmarkTree) {
- this.idRef = null;
- this.whenToProcess = END_OF_DOC;
- // top level defined in Rec to show all child bookmarks
- this.showChildren = true;
-
- for (int count = 0; count < bookmarkTree.getBookmarks().size(); count++) {
- Bookmark bkmk = (Bookmark)(bookmarkTree.getBookmarks()).get(count);
- addSubData(createBookmarkData(bkmk));
- }
- }
-
- /**
- * Create a new pdf bookmark data object.
- * This is used by the bookmark-items to create a data object
- * with a idref. During processing, this idref will be
- * subsequently resolved to a particular PageViewport.
- *
- * @param bookmark the fo:bookmark object
- */
- public BookmarkData(Bookmark bookmark) {
- this.bookmarkTitle = bookmark.getBookmarkTitle();
- this.showChildren = bookmark.showChildItems();
- this.idRef = bookmark.getInternalDestination();
- }
-
- private void putUnresolved(String id, BookmarkData bd) {
- List<Resolvable> refs = unresolvedIDRefs.get(id);
- if (refs == null) {
- refs = new java.util.ArrayList<Resolvable>();
- unresolvedIDRefs.put(id, refs);
- }
- refs.add(bd);
- }
-
- /**
- * Create a new bookmark data root object.
- * This constructor is called by the AreaTreeParser when the
- * <bookmarkTree> element is read from the XML file
- */
- public BookmarkData() {
- idRef = null;
- whenToProcess = END_OF_DOC;
- showChildren = true;
- }
-
- /**
- * Create a new bookmark data object.
- * This constructor is called by the AreaTreeParser when a
- * <bookmark> element is read from the XML file.
- *
- * @param title the bookmark's title
- * @param showChildren whether to initially display the bookmark's children
- * @param pv the target PageViewport
- * @param idRef the target ID
- */
- public BookmarkData(String title, boolean showChildren, PageViewport pv, String idRef) {
- bookmarkTitle = title;
- this.showChildren = showChildren;
- pageRef = pv;
- this.idRef = idRef;
- }
-
- /**
- * Get the idref for this bookmark-item
- *
- * @return the idref for the bookmark-item
- */
- public String getIDRef() {
- return idRef;
- }
-
- /**
- * Add a child bookmark data object.
- * This adds a child bookmark in the bookmark hierarchy.
- *
- * @param sub the child bookmark data
- */
- public void addSubData(BookmarkData sub) {
- subData.add(sub);
- if (sub.pageRef == null) {
- putUnresolved(sub.getIDRef(), sub);
- String[] ids = sub.getIDRefs();
- for (String id : ids) {
- putUnresolved(id, sub);
- }
- }
- }
-
- /**
- * Get the title for this bookmark object.
- *
- * @return the bookmark title
- */
- public String getBookmarkTitle() {
- return bookmarkTitle;
- }
-
- /**
- * Indicator of whether to initially display child bookmarks.
- *
- * @return true to initially display child bookmarks, false otherwise
- */
- public boolean showChildItems() {
- return showChildren;
- }
-
- /**
- * Get the size of child data objects.
- *
- * @return the number of child bookmark data
- */
- public int getCount() {
- return subData.size();
- }
-
- /**
- * Get the child data object.
- *
- * @param count the index to get
- * @return the child bookmark data
- */
- public BookmarkData getSubData(int count) {
- return subData.get(count);
- }
-
- /**
- * Get the PageViewport object that this bookmark refers to
- *
- * @return the PageViewport that this bookmark points to
- */
- public PageViewport getPageViewport() {
- return pageRef;
- }
-
- /**
- * Check if this resolvable object has been resolved.
- * A BookmarkData object is considered resolved once the idrefs for it
- * and for all of its child bookmark-items have been resolved.
- *
- * @return true if this object has been resolved
- */
- public boolean isResolved() {
- return unresolvedIDRefs == null || (unresolvedIDRefs.size() == 0);
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getIDRefs() {
- return unresolvedIDRefs.keySet().toArray(
- new String[unresolvedIDRefs.keySet().size()]);
- }
-
- /**
- * Resolve this resolvable object.
- * This resolves the idref of this object and if possible also
- * resolves id references of child elements that have the same
- * id reference.
- *
- * {@inheritDoc}
- */
- public void resolveIDRef(String id, List<PageViewport> pages) {
- if (id.equals(idRef)) {
- //Own ID has been resolved, so note the page
- pageRef = pages.get(0);
- //Note: Determining the placement inside the page is the renderer's job.
- }
-
- //Notify all child bookmarks
- List<Resolvable> refs = unresolvedIDRefs.get(id);
- if (refs != null) {
- for (Resolvable res : refs) {
- res.resolveIDRef(id, pages);
- }
- }
- unresolvedIDRefs.remove(id);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getName() {
- return "Bookmarks";
- }
-
- /**
- * Create and return the bookmark data for this bookmark
- * This creates a bookmark data with the destination
- * and adds all the data from child bookmarks
- *
- * @param bookmark the Bookmark object for which a bookmark entry should be
- * created
- * @return the new bookmark data
- */
- private BookmarkData createBookmarkData(Bookmark bookmark) {
- BookmarkData data = new BookmarkData(bookmark);
- for (int count = 0; count < bookmark.getChildBookmarks().size(); count++) {
- Bookmark bkmk = (Bookmark)(bookmark.getChildBookmarks()).get(count);
- data.addSubData(createBookmarkData(bkmk));
- }
- return data;
- }
-
-}
diff --git a/src/java/org/apache/fop/area/CTM.java b/src/java/org/apache/fop/area/CTM.java
deleted file mode 100644
index 80172be8b..000000000
--- a/src/java/org/apache/fop/area/CTM.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * 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.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.io.Serializable;
-
-import org.apache.fop.datatypes.FODimension;
-import org.apache.fop.traits.WritingMode;
-
-import static org.apache.fop.fo.Constants.EN_LR_TB;
-import static org.apache.fop.fo.Constants.EN_RL_TB;
-import static org.apache.fop.fo.Constants.EN_TB_LR;
-import static org.apache.fop.fo.Constants.EN_TB_RL;
-
-/**
- * Describe a PDF or PostScript style coordinate transformation matrix (CTM).
- * The matrix encodes translations, scaling and rotations of the coordinate
- * system used to render pages.
- */
-public class CTM implements Serializable {
-
- private static final long serialVersionUID = -8743287485623778341L;
-
- private double a;
- private double b;
- private double c;
- private double d;
- private double e;
- private double f;
-
- private static final CTM CTM_LRTB = new CTM(1, 0, 0, 1, 0, 0);
- private static final CTM CTM_RLTB = new CTM(1, 0, 0, 1, 0, 0);
- private static final CTM CTM_TBRL = new CTM(0, 1, -1, 0, 0, 0);
-
- /**
- * Create the identity matrix
- */
- public CTM() {
- a = 1;
- b = 0;
- c = 0;
- d = 1;
- e = 0;
- f = 0;
- }
-
- /**
- * Initialize a CTM from the passed arguments.
- *
- * @param a the x scale
- * @param b the x shear
- * @param c the y shear
- * @param d the y scale
- * @param e the x shift
- * @param f the y shift
- */
- public CTM(double a, double b, double c, double d, double e, double f) {
- this.a = a;
- this.b = b;
- this.c = c;
- this.d = d;
- this.e = e;
- this.f = f;
- }
-
- /**
- * Initialize a CTM to the identity matrix with a translation
- * specified by x and y
- *
- * @param x the x shift
- * @param y the y shift.
- */
- public CTM(double x, double y) {
- this.a = 1;
- this.b = 0;
- this.c = 0;
- this.d = 1;
- this.e = x;
- this.f = y;
- }
-
- /**
- * Initialize a CTM with the values of another CTM.
- *
- * @param ctm another CTM
- */
- protected CTM(CTM ctm) {
- this.a = ctm.a;
- this.b = ctm.b;
- this.c = ctm.c;
- this.d = ctm.d;
- this.e = ctm.e;
- this.f = ctm.f;
- }
-
- /**
- * Initialize a CTM with the values of an AffineTransform.
- *
- * @param at the transformation matrix
- */
- public CTM(AffineTransform at) {
- double[] matrix = new double[6];
- at.getMatrix(matrix);
- this.a = matrix[0];
- this.b = matrix[1];
- this.c = matrix[2];
- this.d = matrix[3];
- this.e = matrix[4];
- this.f = matrix[5];
- }
-
- /**
- * Return a CTM which will transform coordinates for a particular writing-mode
- * into normalized first quandrant coordinates.
- * @param wm A writing mode constant from fo.properties.WritingMode, ie.
- * one of LR_TB, RL_TB, TB_RL, TB_LR.
- * @param ipd The inline-progression dimension of the reference area whose
- * CTM is being set..
- * @param bpd The block-progression dimension of the reference area whose
- * CTM is being set.
- * @return a new CTM with the required transform
- */
- public static CTM getWMctm(WritingMode wm, int ipd, int bpd) {
- CTM wmctm;
- switch (wm.getEnumValue()) {
- case EN_LR_TB:
- return new CTM(CTM_LRTB);
- case EN_RL_TB:
- return new CTM(CTM_RLTB);
- case EN_TB_RL: // CJK
- case EN_TB_LR: // CJK
- wmctm = new CTM(CTM_TBRL);
- wmctm.e = bpd;
- return wmctm;
- default:
- return null;
- }
- }
-
- /**
- * Multiply new passed CTM with this one and generate a new result CTM.
- * @param premult The CTM to multiply with this one. The new one will be
- * the first multiplicand.
- * @return CTM The result of multiplying premult * this.
- */
- public CTM multiply(CTM premult) {
- return new CTM((premult.a * a) + (premult.b * c),
- (premult.a * b) + (premult.b * d),
- (premult.c * a) + (premult.d * c),
- (premult.c * b) + (premult.d * d),
- (premult.e * a) + (premult.f * c) + e,
- (premult.e * b) + (premult.f * d) + f);
- }
-
- /**
- * Rotate this CTM by "angle" radians and return a new result CTM.
- * This is used to account for reference-orientation.
- * @param angle The angle in radians. Positive angles are measured counter-
- * clockwise.
- * @return CTM The result of rotating this CTM.
- */
- public CTM rotate(double angle) {
- double cos;
- double sin;
- if (angle == 90.0 || angle == -270.0) {
- cos = 0.0;
- sin = 1.0;
- } else if (angle == 270.0 || angle == -90.0) {
- cos = 0.0;
- sin = -1.0;
- } else if (angle == 180.0 || angle == -180.0) {
- cos = -1.0;
- sin = 0.0;
- } else {
- double rad = Math.toRadians(angle);
- cos = Math.cos(rad);
- sin = Math.sin(rad);
- }
- CTM rotate = new CTM(cos, -sin, sin, cos, 0, 0);
- return multiply(rotate);
- }
-
- /**
- * Translate this CTM by the passed x and y values and return a new result CTM.
- * @param x The amount to translate along the x axis.
- * @param y The amount to translate along the y axis.
- * @return CTM The result of translating this CTM.
- */
- public CTM translate(double x, double y) {
- CTM translate = new CTM(1, 0, 0, 1, x, y);
- return multiply(translate);
- }
-
- /**
- * Scale this CTM by the passed x and y values and return a new result CTM.
- * @param x The amount to scale along the x axis.
- * @param y The amount to scale along the y axis.
- * @return CTM The result of scaling this CTM.
- */
- public CTM scale(double x, double y) {
- CTM scale = new CTM(x, 0, 0, y, 0, 0);
- return multiply(scale);
- }
-
- /**
- * Transform a rectangle by the CTM to produce a rectangle in the transformed
- * coordinate system.
- * @param inRect The rectangle in the original coordinate system
- * @return Rectangle2D The rectangle in the transformed coordinate system.
- */
- public Rectangle2D transform(Rectangle2D inRect) {
- // Store as 2 sets of 2 points and transform those, then
- // recalculate the width and height
- int x1t = (int)(inRect.getX() * a + inRect.getY() * c + e);
- int y1t = (int)(inRect.getX() * b + inRect.getY() * d + f);
- int x2t = (int)((inRect.getX() + inRect.getWidth()) * a
- + (inRect.getY() + inRect.getHeight()) * c + e);
- int y2t = (int)((inRect.getX() + inRect.getWidth()) * b
- + (inRect.getY() + inRect.getHeight()) * d + f);
- // Normalize with x1 < x2
- if (x1t > x2t) {
- int tmp = x2t;
- x2t = x1t;
- x1t = tmp;
- }
- if (y1t > y2t) {
- int tmp = y2t;
- y2t = y1t;
- y1t = tmp;
- }
- return new Rectangle(x1t, y1t, x2t - x1t, y2t - y1t);
- }
-
- /**
- * Get string for this transform.
- *
- * @return a string with the transform values
- */
- @Override
- public String toString() {
- return "[" + a + " " + b + " " + c + " " + d + " " + e + " "
- + f + "]";
- }
-
- /**
- * Get an array containing the values of this transform.
- * This creates and returns a new transform with the values in it.
- *
- * @return an array containing the transform values
- */
- public double[] toArray() {
- return new double[]{a, b, c, d, e, f};
- }
-
- /**
- * Returns this CTM as an AffineTransform object.
- * @return the AffineTransform representation
- */
- public AffineTransform toAffineTransform() {
- return new AffineTransform(toArray());
- }
-
- /**
- * Construct a coordinate transformation matrix (CTM).
- * @param absRefOrient absolute reference orientation
- * @param writingMode the writing mode
- * @param absVPrect absolute viewpoint rectangle
- * @param reldims relative dimensions
- * @return CTM the coordinate transformation matrix (CTM)
- */
- public static CTM getCTMandRelDims(int absRefOrient,
- WritingMode writingMode,
- Rectangle2D absVPrect,
- FODimension reldims) {
- int width;
- int height;
- // We will use the absolute reference-orientation to set up the CTM.
- // The value here is relative to its ancestor reference area.
- if (absRefOrient % 180 == 0) {
- width = (int) absVPrect.getWidth();
- height = (int) absVPrect.getHeight();
- } else {
- // invert width and height since top left are rotated by 90 (cl or ccl)
- height = (int) absVPrect.getWidth();
- width = (int) absVPrect.getHeight();
- }
- /* Set up the CTM for the content of this reference area.
- * This will transform region content coordinates in
- * writing-mode relative into absolute page-relative
- * which will then be translated based on the position of
- * the region viewport.
- * (Note: scrolling between region vp and ref area when
- * doing online content!)
- */
- CTM ctm = new CTM(absVPrect.getX(), absVPrect.getY());
-
- // First transform for rotation
- if (absRefOrient != 0) {
- // Rotation implies translation to keep the drawing area in the
- // first quadrant. Note: rotation is counter-clockwise
- switch (absRefOrient) {
- case 90:
- case -270:
- ctm = ctm.translate(0, width); // width = absVPrect.height
- break;
- case 180:
- case -180:
- ctm = ctm.translate(width, height);
- break;
- case 270:
- case -90:
- ctm = ctm.translate(height, 0); // height = absVPrect.width
- break;
- default:
- throw new RuntimeException();
- }
- ctm = ctm.rotate(absRefOrient);
- }
- /* Since we've already put adjusted width and height values for the
- * top and left positions implied by the reference-orientation, we
- * can set ipd and bpd appropriately based on the writing mode.
- */
-
- switch (writingMode.getEnumValue()) {
- case EN_TB_LR:
- case EN_TB_RL:
- reldims.ipd = height;
- reldims.bpd = width;
- break;
- case EN_LR_TB:
- case EN_RL_TB:
- default:
- reldims.ipd = width;
- reldims.bpd = height;
- break;
- }
- // Set a rectangle to be the writing-mode relative version???
- // Now transform for writing mode
- return ctm.multiply(CTM.getWMctm(writingMode, reldims.ipd, reldims.bpd));
- }
-
-}
diff --git a/src/java/org/apache/fop/area/CachedRenderPagesModel.java b/src/java/org/apache/fop/area/CachedRenderPagesModel.java
deleted file mode 100644
index e5c6f5b2b..000000000
--- a/src/java/org/apache/fop/area/CachedRenderPagesModel.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.xml.sax.SAXException;
-
-import org.apache.commons.io.IOUtils;
-
-import org.apache.xmlgraphics.io.TempResourceURIGenerator;
-
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.fonts.FontInfo;
-
-/**
- * A simple cached render pages model.
- * If the page is prepared for later rendering then this saves
- * the page contents to a file and once the page is resolved
- * the contents are reloaded.
- */
-public class CachedRenderPagesModel extends RenderPagesModel {
-
- private Map<PageViewport, URI> pageMap = new HashMap<PageViewport, URI>();
-
- /** Base directory to save temporary file in, typically points to the user's temp dir. */
- private final URI tempBaseURI;
- private static final TempResourceURIGenerator TEMP_URI_GENERATOR
- = new TempResourceURIGenerator("cached-pages");
-
- /**
- * Main Constructor
- * @param userAgent FOUserAgent object for process
- * @param outputFormat the MIME type of the output format to use (ex. "application/pdf").
- * @param fontInfo FontInfo object
- * @param stream OutputStream
- * @throws FOPException if the renderer cannot be properly initialized
- */
- public CachedRenderPagesModel(FOUserAgent userAgent, String outputFormat,
- FontInfo fontInfo, OutputStream stream) throws FOPException {
- super(userAgent, outputFormat, fontInfo, stream);
- tempBaseURI = TEMP_URI_GENERATOR.generate();
- }
-
- /** {@inheritDoc} */
- @Override
- protected boolean checkPreparedPages(PageViewport newpage, boolean renderUnresolved) {
- for (Iterator iter = prepared.iterator(); iter.hasNext();) {
- PageViewport pageViewport = (PageViewport)iter.next();
- if (pageViewport.isResolved() || renderUnresolved) {
- if (pageViewport != newpage) {
- try {
- // load page from cache
- URI tempURI = pageMap.get(pageViewport);
- log.debug("Loading page from: " + tempURI);
- InputStream inStream = renderer.getUserAgent().getResourceResolver().getResource(tempURI);
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(inStream));
- try {
- pageViewport.loadPage(in);
- } finally {
- IOUtils.closeQuietly(inStream);
- IOUtils.closeQuietly(in);
- }
- pageMap.remove(pageViewport);
- } catch (Exception e) {
- AreaEventProducer eventProducer = AreaEventProducer.Provider.get(
- renderer.getUserAgent().getEventBroadcaster());
- eventProducer.pageLoadError(this, pageViewport.getPageNumberString(), e);
- }
- }
-
- renderPage(pageViewport);
- pageViewport.clear();
- iter.remove();
- } else {
- if (!renderer.supportsOutOfOrder()) {
- break;
- }
- }
- }
- if (newpage != null && newpage.getPage() != null) {
- savePage(newpage);
- newpage.clear();
- }
- return renderer.supportsOutOfOrder() || prepared.isEmpty();
- }
-
- /**
- * Save a page.
- * It saves the contents of the page to a file.
- *
- * @param page the page to prepare
- */
- protected void savePage(PageViewport page) {
- try {
- // save page to cache
- ObjectOutputStream tempstream;
- String fname = "fop-page-" + page.getPageIndex() + ".ser";
- URI tempURI = tempBaseURI.resolve(fname);
- OutputStream outStream = renderer.getUserAgent().getResourceResolver().getOutputStream(tempURI);
- tempstream = new ObjectOutputStream(new BufferedOutputStream(outStream));
- try {
- page.savePage(tempstream);
- } finally {
- IOUtils.closeQuietly(tempstream);
- }
- pageMap.put(page, tempURI);
- if (log.isDebugEnabled()) {
- log.debug("Page saved to temporary file: " + tempURI);
- }
- } catch (IOException ioe) {
- AreaEventProducer eventProducer
- = AreaEventProducer.Provider.get(
- renderer.getUserAgent().getEventBroadcaster());
- eventProducer.pageSaveError(this, page.getPageNumberString(), ioe);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void endDocument() throws SAXException {
- super.endDocument();
- }
-}
-
diff --git a/src/java/org/apache/fop/area/DestinationData.java b/src/java/org/apache/fop/area/DestinationData.java
deleted file mode 100644
index 1dffb3b92..000000000
--- a/src/java/org/apache/fop/area/DestinationData.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.util.List;
-
-import org.apache.fop.fo.extensions.destination.Destination;
-/**
- * An instance of this class is named destination from fox:destination
- */
-public class DestinationData extends AbstractOffDocumentItem implements Resolvable {
-
- // ID Reference for this bookmark
- private String idRef;
-
- // String Array to satisfy getIDRefs method
- private String[] idRefs;
-
- // PageViewport that the idRef item refers to
- private PageViewport pageRef;
-
- /**
- * Create a new pdf destination data object.
- * This is used by the destination to create a data object
- * with a idref. During processing, this idref will be
- * subsequently resolved to a particular PageViewport.
- *
- * @param destination the fo:bookmark object
- */
- public DestinationData(Destination destination) {
- this(destination.getInternalDestination());
- }
-
- /**
- * Create a new named destination.
- * @param idRef the id reference of the destination
- */
- public DestinationData(String idRef) {
- this.idRef = idRef;
- this.idRefs = new String[] {idRef};
- }
-
- /**
- * Get the idref for this destination
- *
- * @return the idref for the destination
- */
- public String getIDRef() {
- return idRef;
- }
-
- /** {@inheritDoc} */
- public String[] getIDRefs() {
- return idRefs;
- }
-
- /**
- * Get the PageViewport object that this destination refers to
- *
- * @return the PageViewport that this destination points to
- */
- public PageViewport getPageViewport() {
- return pageRef;
- }
-
- /**
- * Check if this resolvable object has been resolved.
- * For now, just return true.
- * To do: Find a way to determine whether the destination has been resolved.
- *
- * @return true if this object has been resolved
- */
- public boolean isResolved() {
- return true;
- }
-
- /**
- * Resolves the idref of this object by getting the PageViewport
- * object that corresponds to the IDRef
- *
- * {@inheritDoc}
- * TODO check to make sure it works if multiple bookmark-items
- * have the same idref
- */
- public void resolveIDRef(String id, List<PageViewport> pages) {
- pageRef = pages.get(0);
- // TODO get rect area of id on page
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return "Destination";
- }
-
-}
-
diff --git a/src/java/org/apache/fop/area/Footnote.java b/src/java/org/apache/fop/area/Footnote.java
deleted file mode 100644
index cbf8f80fa..000000000
--- a/src/java/org/apache/fop/area/Footnote.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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;
-
-// may combine with before float into a conditional area
-
-/**
- * The footnote-reference-area optionally generated by an fo:region-body.
- * This areas holds footnote areas and an optional separator area.
- * See fo:region-body definition in the XSL Rec for more information.
- */
-public class Footnote extends BlockParent {
-
- private static final long serialVersionUID = -7907428219886367161L;
-
- private Block separator;
-
- // footnote has an optional separator
- // and a list of sub block areas that can be added/removed
-
- // this is the relative position of the footnote inside
- // the body region
- private int top;
-
- /**
- * Set the separator area for this footnote.
- *
- * @param sep the separator area
- */
- public void setSeparator(Block sep) {
- separator = sep;
- }
-
- /**
- * Get the separator area for this footnote area.
- *
- * @return the separator area
- */
- public Block getSeparator() {
- return separator;
- }
-
- /**
- * Set the relative position of the footnote inside the body region.
- *
- * @param top the relative position.
- */
- public void setTop(int top) {
- this.top = top;
- }
-
- /**
- * Get the relative position of the footnote inside the body region.
- *
- * @return the relative position.
- */
- public int getTop() {
- return top;
- }
-
- /**
- * Add a block area as child to the footnote area
- *
- * @param child the block area.
- */
- @Override
- public void addBlock(Block child) {
- addChildArea(child);
- setBPD(getBPD() + child.getAllocBPD());
- }
-
-}
-
diff --git a/src/java/org/apache/fop/area/IDTracker.java b/src/java/org/apache/fop/area/IDTracker.java
deleted file mode 100644
index 58d6a2e43..000000000
--- a/src/java/org/apache/fop/area/IDTracker.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * 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.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Used by the AreaTreeHandler to keep track of ID reference usage
- * on a PageViewport level.
- */
-public class IDTracker {
-
- private static final Log LOG = LogFactory.getLog(IDTracker.class);
-
- // Map of ID's whose area is located on one or more consecutive
- // PageViewports. Each ID has a list of PageViewports that
- // form the defined area of this ID
- private Map<String, List<PageViewport>> idLocations
- = new java.util.HashMap<String, List<PageViewport>>();
-
- // idref's whose target PageViewports have yet to be identified
- // Each idref has a HashSet of Resolvable objects containing that idref
- private Map<String, Set<Resolvable>> unresolvedIDRefs
- = new java.util.HashMap<String, Set<Resolvable>>();
-
- private Set<String> unfinishedIDs = new java.util.HashSet<String>();
-
- private Set<String> alreadyResolvedIDs = new java.util.HashSet<String>();
-
- /**
- * Tie a PageViewport with an ID found on a child area of the PV. Note that
- * an area with a given ID may be on more than one PV, hence an ID may have
- * more than one PV associated with it.
- *
- * @param id the property ID of the area
- * @param pv a page viewport that contains the area with this ID
- */
- public void associateIDWithPageViewport(String id, PageViewport pv) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("associateIDWithPageViewport(" + id + ", " + pv + ")");
- }
- List<PageViewport> pvList = idLocations.get(id);
- if (pvList == null) { // first time ID located
- pvList = new java.util.ArrayList<PageViewport>();
- idLocations.put(id, pvList);
- pvList.add(pv);
- // signal the PageViewport that it is the first PV to contain this id:
- pv.setFirstWithID(id);
- /*
- * See if this ID is in the unresolved idref list, if so resolve
- * Resolvable objects tied to it.
- */
- if (!unfinishedIDs.contains(id)) {
- tryIDResolution(id, pvList);
- }
- } else {
- /* TODO: The check is a quick-fix to avoid a waste
- * when adding inline-ids to the page */
- if (!pvList.contains(pv)) {
- pvList.add(pv);
- }
- }
- }
-
- /**
- * This method tie an ID to the areaTreeHandler until this one is ready to
- * be processed. This is used in page-number-citation-last processing so we
- * know when an id can be resolved.
- *
- * @param id the id of the object being processed
- */
- public void signalPendingID(String id) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("signalPendingID(" + id + ")");
- }
- unfinishedIDs.add(id);
- }
-
- /**
- * Signals that all areas for the formatting object with the given ID have
- * been generated. This is used to determine when page-number-citation-last
- * ref-ids can be resolved.
- *
- * @param id the id of the formatting object which was just finished
- */
- public void signalIDProcessed(String id) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("signalIDProcessed(" + id + ")");
- }
-
- alreadyResolvedIDs.add(id);
- if (!unfinishedIDs.contains(id)) {
- return;
- }
- unfinishedIDs.remove(id);
-
- List<PageViewport> idLocs = idLocations.get(id);
- Set<Resolvable> todo = unresolvedIDRefs.get(id);
- if (todo != null) {
- for (Resolvable res : todo) {
- res.resolveIDRef(id, idLocs);
- }
- unresolvedIDRefs.remove(id);
- }
- }
-
- /**
- * Check if an ID has already been resolved
- *
- * @param id the id to check
- * @return true if the ID has been resolved
- */
- public boolean alreadyResolvedID(String id) {
- return (alreadyResolvedIDs.contains(id));
- }
-
- /**
- * Tries to resolve all unresolved ID references on the given set of pages.
- *
- * @param id ID to resolve
- * @param pvList list of PageViewports
- */
- private void tryIDResolution(String id, List<PageViewport> pvList) {
- Set<Resolvable> todo = unresolvedIDRefs.get(id);
- if (todo != null) {
- for (Resolvable res : todo) {
- if (!unfinishedIDs.contains(id)) {
- res.resolveIDRef(id, pvList);
- } else {
- return;
- }
- }
- alreadyResolvedIDs.add(id);
- unresolvedIDRefs.remove(id);
- }
- }
-
- /**
- * Tries to resolve all unresolved ID references on the given page.
- *
- * @param pv page viewport whose ID refs to resolve
- */
- public void tryIDResolution(PageViewport pv) {
- String[] ids = pv.getIDRefs();
- if (ids != null) {
- for (String id : ids) {
- List<PageViewport> pvList = idLocations.get(id);
- if (!(pvList == null || pvList.isEmpty())) {
- tryIDResolution(id, pvList);
- }
- }
- }
- }
-
- /**
- * Get the list of page viewports that have an area with a given id.
- *
- * @param id the id to lookup
- * @return the list of PageViewports
- */
- public List<PageViewport> getPageViewportsContainingID(String id) {
- if (!(idLocations == null || idLocations.isEmpty())) {
- List<PageViewport> idLocs = idLocations.get(id);
- if (idLocs != null) {
- return idLocs;
- }
- }
- return Collections.emptyList();
- }
-
- /**
- * Get the first {@link PageViewport} containing content generated
- * by the FO with the given {@code id}.
- *
- * @param id the id
- * @return the first {@link PageViewport} for the id; {@code null} if
- * no matching {@link PageViewport} was found
- */
- public PageViewport getFirstPageViewportContaining(String id) {
- List<PageViewport> list = getPageViewportsContainingID(id);
- if (!(list == null || list.isEmpty())) {
- return list.get(0);
- }
- return null;
- }
-
- /**
- * Get the last {@link PageViewport} containing content generated
- * by the FO with the given {@code id}.
- *
- * @param id the id
- * @return the last {@link PageViewport} for the id; {@code null} if
- * no matching {@link PageViewport} was found
- */
- public PageViewport getLastPageViewportContaining(String id) {
- List<PageViewport> list = getPageViewportsContainingID(id);
- if (!(list == null || list.isEmpty())) {
- return list.get(list.size() - 1);
- }
- return null;
- }
-
- /**
- * Add an Resolvable object with an unresolved idref
- *
- * @param idref the idref whose target id has not yet been located
- * @param res the Resolvable object needing the idref to be resolved
- */
- public void addUnresolvedIDRef(String idref, Resolvable res) {
- Set<Resolvable> todo = unresolvedIDRefs.get(idref);
- if (todo == null) {
- todo = new java.util.HashSet<Resolvable>();
- unresolvedIDRefs.put(idref, todo);
- }
- // add Resolvable object to this HashSet
- todo.add(res);
- }
-
- /**
- * Replace all id locations pointing to the old page view port with a new one. This is
- * necessary when a layouted page is replaced with a new one (e.g. last page handling).
- * @param oldPageViewPort old page view port
- * @param newPageViewPort new page view port
- */
- public void replacePageViewPort(PageViewport oldPageViewPort, PageViewport newPageViewPort) {
-
- for (List<PageViewport> viewPortList : idLocations.values()) {
- for (int i = 0, len = viewPortList.size(); i < len; i++) {
- PageViewport currPV = viewPortList.get(i);
- if (currPV == oldPageViewPort) {
- viewPortList.set(i, newPageViewPort);
- }
- }
- }
- }
-}
diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java
deleted file mode 100644
index 8639b8201..000000000
--- a/src/java/org/apache/fop/area/LineArea.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * 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.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.fop.area.inline.InlineArea;
-
-import static org.apache.fop.fo.Constants.EN_CENTER;
-import static org.apache.fop.fo.Constants.EN_END;
-import static org.apache.fop.fo.Constants.EN_JUSTIFY;
-import static org.apache.fop.fo.Constants.EN_START;
-
-/**
- * The line area.
- * This is a line area that contains inline areas.
- */
-public class LineArea extends Area {
-
- private static final long serialVersionUID = 7670235908329290684L;
-
- /**
- * this class stores information about line width and potential adjustments
- * that can be used in order to re-compute adjustement and / or indents when a
- * page-number or a page-number-citation is resolved
- */
- // @SuppressFBWarnings("SE_INNER_CLASS")
- private final class LineAdjustingInfo implements Serializable {
-
- private static final long serialVersionUID = -6103629976229458273L;
-
- private int lineAlignment;
- private int difference;
- private int availableStretch;
- private int availableShrink;
- private double variationFactor;
- private boolean bAddedToAreaTree;
-
- private LineAdjustingInfo(int alignment, int diff,
- int stretch, int shrink) {
- lineAlignment = alignment;
- difference = diff;
- availableStretch = stretch;
- availableShrink = shrink;
- variationFactor = 1.0;
- bAddedToAreaTree = false;
- }
-
- /** {@inheritDoc} */
- public String toString() {
- return getClass().getSimpleName()
- + ": diff=" + difference
- + ", variation=" + variationFactor
- + ", stretch=" + availableStretch
- + ", shrink=" + availableShrink;
- }
- }
-
- private LineAdjustingInfo adjustingInfo;
-
- // this class can contain the dominant char styling info
- // this means that many renderers can optimise a bit
-
- private List<InlineArea> inlineAreas = new ArrayList<InlineArea>();
-
- /**
- * default constructor:
- * nothing to do
- */
- public LineArea() {
- }
-
- /**
- * constructor with extra parameters:
- * a new LineAdjustingInfo object is created
- * @param alignment alignment of this line
- * @param diff difference between content width and line width
- * @param stretch the available stretch for any adjustments
- * @param shrink the available shrink for any adjustments
- */
- public LineArea(int alignment, int diff,
- int stretch, int shrink) {
- adjustingInfo = new LineAdjustingInfo(alignment, diff, stretch, shrink);
- }
-
- /**
- * Add a child area to this line area.
- *
- * @param childArea the inline child area to add
- */
- @Override
- public void addChildArea(Area childArea) {
- if (childArea instanceof InlineArea) {
- addInlineArea((InlineArea)childArea);
- // set the parent area for the child area
- ((InlineArea)childArea).setParentArea(this);
- }
- }
-
- /**
- * Add an inline child area to this line area.
- *
- * @param area the inline child area to add
- */
- public void addInlineArea(InlineArea area) {
- inlineAreas.add(area);
- }
-
- /**
- * <p>Set (en masse) the inline child areas of this line area.</p>
- * <p> Used by bidirectional processing after line area consituent reordering.</p>
- * @param inlineAreas the list of inline areas
- */
- public void setInlineAreas(List inlineAreas) {
- for (Iterator<InlineArea> it = inlineAreas.iterator(); it.hasNext();) {
- InlineArea ia = it.next();
- Area pa = ia.getParentArea();
- if (pa == null) {
- ia.setParentArea(this);
- } else {
- assert pa == this;
- }
- }
- this.inlineAreas = inlineAreas;
- }
-
- /**
- * Get the inline child areas of this line area.
- *
- * @return the list of inline areas
- */
- public List getInlineAreas() {
- return inlineAreas;
- }
-
- /**
- * Get the start indent of this line area.
- * The start indent is used for offsetting the start of
- * the inline areas for alignment or other indents.
- *
- * @return the start indent value
- */
- public int getStartIndent() {
- if (hasTrait(Trait.START_INDENT)) {
- return getTraitAsInteger(Trait.START_INDENT);
- } else {
- return 0;
- }
- }
-
- /**
- * Get the end indent of this line area.
- * The end indent is used for offsetting the end of
- * the inline areas for alignment or other indents.
- *
- * @return the end indent value
- */
- public int getEndIndent() {
- if (hasTrait(Trait.END_INDENT)) {
- return getTraitAsInteger(Trait.END_INDENT);
- } else {
- return 0;
- }
- }
-
- /**
- * Updates the extents of the line area from its children.
- */
- public void updateExtentsFromChildren() {
- int ipd = 0;
- int bpd = 0;
- for (int i = 0, len = inlineAreas.size(); i < len; i++) {
- ipd = Math.max(ipd, inlineAreas.get(i).getAllocIPD());
- bpd += inlineAreas.get(i).getAllocBPD();
- }
- setIPD(ipd);
- setBPD(bpd);
- }
-
- /**
- * receive notification about the ipd variation of a descendant area
- * and perform the needed adjustment, according to the alignment;
- * in particular:
- * <ul>
- * <li>left-aligned text needs no adjustement;</li>
- * <li>right-aligned text and centered text are handled locally,
- * adjusting the indent of this LineArea;</li>
- * <li>justified text requires a more complex adjustment, as the
- * variation factor computed on the basis of the total
- * stretch and shrink of the line must be applied in every
- * descendant leaf areas (text areas and leader areas).</li>
- * </ul>
- * @param ipdVariation the difference between old and new ipd
- */
- public void handleIPDVariation(int ipdVariation) {
- int si = getStartIndent();
- int ei = getEndIndent();
- switch (adjustingInfo.lineAlignment) {
- case EN_START:
- // adjust end indent
- addTrait(Trait.END_INDENT, ei - ipdVariation);
- break;
- case EN_CENTER:
- // adjust start and end indents
- addTrait(Trait.START_INDENT, si - ipdVariation / 2);
- addTrait(Trait.END_INDENT, ei - ipdVariation / 2);
- break;
- case EN_END:
- // adjust start indent
- addTrait(Trait.START_INDENT, si - ipdVariation);
- break;
- case EN_JUSTIFY:
- // compute variation factor
- adjustingInfo.variationFactor *= (float) (adjustingInfo.difference - ipdVariation)
- / adjustingInfo.difference;
- adjustingInfo.difference -= ipdVariation;
- // if the LineArea has already been added to the area tree,
- // call finalize(); otherwise, wait for the LineLM to call it
- if (adjustingInfo.bAddedToAreaTree) {
- finish();
- }
- break;
- default:
- throw new RuntimeException();
- }
- }
-
- /**
- * apply the variation factor to all descendant areas
- * and destroy the AdjustingInfo object if there are
- * no UnresolvedAreas left
- */
- public void finish() {
- if (adjustingInfo.lineAlignment == EN_JUSTIFY) {
- if (log.isTraceEnabled()) {
- log.trace("Applying variation factor to justified line: " + adjustingInfo);
- }
- // justified line: apply the variation factor
- boolean bUnresolvedAreasPresent = false;
- // recursively apply variation factor to descendant areas
- for (int i = 0, len = inlineAreas.size(); i < len; i++) {
- bUnresolvedAreasPresent |= inlineAreas.get(i)
- .applyVariationFactor(adjustingInfo.variationFactor,
- adjustingInfo.availableStretch,
- adjustingInfo.availableShrink);
- }
- if (!bUnresolvedAreasPresent) {
- // there are no more UnresolvedAreas:
- // destroy the AdjustingInfo instance
- adjustingInfo = null;
- } else {
- // this method will be called again later:
- // the first time, it is called by the LineLM,
- // afterwards it must be called by the LineArea itself
- if (!adjustingInfo.bAddedToAreaTree) {
- adjustingInfo.bAddedToAreaTree = true;
- }
- // reset the variation factor
- adjustingInfo.variationFactor = 1.0;
- }
- } else {
- // the line is not justified: the ipd variation has already
- // been handled, modifying the line indent
- }
- }
-
- public int getEffectiveIPD() {
- int maxIPD = 0;
- if (inlineAreas != null) {
- for (Area area : inlineAreas) {
- int effectiveIPD = area.getEffectiveIPD();
- if (effectiveIPD > maxIPD) {
- maxIPD = effectiveIPD;
- }
- }
- }
- return maxIPD;
- }
-
-}
-
diff --git a/src/java/org/apache/fop/area/LinkResolver.java b/src/java/org/apache/fop/area/LinkResolver.java
deleted file mode 100644
index a300bffa9..000000000
--- a/src/java/org/apache/fop/area/LinkResolver.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Link resolving for resolving internal links.
- */
-public class LinkResolver implements Resolvable, Serializable {
-
- private static final long serialVersionUID = -7102134165192960718L;
-
- private boolean resolved;
- private String idRef;
- private Area area;
- private transient List<Resolvable> dependents;
-
- public LinkResolver() {
- this(null, null);
- }
-
- /**
- * Create a new link resolver.
- *
- * @param id the id to resolve
- * @param a the area that will have the link attribute
- */
- public LinkResolver(String id, Area a) {
- idRef = id;
- area = a;
- }
-
- private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- }
-
- /**
- * @return true if this link is resolved
- */
- public boolean isResolved() {
- return resolved;
- }
-
- /**
- * Get the references for this link.
- *
- * @return the String array of references.
- */
- public String[] getIDRefs() {
- return new String[] {idRef};
- }
-
- /**
- * Resolve by adding an internal link to the first PageViewport in the list.
- *
- * {@inheritDoc}
- */
- public void resolveIDRef(String id, List<PageViewport> pages) {
- resolveIDRef(id, pages.get(0));
- }
-
- /**
- * Resolve by adding an InternalLink trait to the area
- *
- * @param id the target id (should be equal to the object's idRef)
- * @param pv the PageViewport containing the first area with the given id
- */
- public void resolveIDRef(String id, PageViewport pv) {
- if (idRef.equals(id) && pv != null) {
- resolved = true;
- if (area != null) {
- Trait.InternalLink iLink = new Trait.InternalLink(pv.getKey(), idRef);
- area.addTrait(Trait.INTERNAL_LINK, iLink);
- area = null; // break circular reference from basic link area to this resolver
- }
- resolveDependents(id, pv);
- }
- }
-
- /**
- * Add dependent resolvable. Used to resolve second-order resolvables that
- * depend on resolution of this resolver.
- * @param dependent resolvable
- */
- public void addDependent(Resolvable dependent) {
- if (dependents == null) {
- dependents = new ArrayList<Resolvable>();
- }
- dependents.add(dependent);
- }
-
- private void resolveDependents(String id, PageViewport pv) {
- if (dependents != null) {
- List<PageViewport> pages = new ArrayList<PageViewport>();
- pages.add(pv);
- for (Resolvable r : dependents) {
- r.resolveIDRef(id, pages);
- }
- }
- }
-
-}
diff --git a/src/java/org/apache/fop/area/MainReference.java b/src/java/org/apache/fop/area/MainReference.java
deleted file mode 100644
index 9778db87f..000000000
--- a/src/java/org/apache/fop/area/MainReference.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.util.ArrayList;
-import java.util.List;
-
-import org.apache.fop.traits.WritingModeTraitsGetter;
-
-/**
- * The main-reference-area generated by an fo:region-body
- * This object holds one or more span-reference-areas (block-areas
- * stacked in the block progression direction)
- * See fo:region-body definition in the XSL Rec for more information.
- */
-public class MainReference extends Area {
-
- private static final long serialVersionUID = 7635126485620012448L;
-
- private BodyRegion parent;
- private List<Span> spanAreas = new java.util.ArrayList<Span>();
- private boolean isEmpty = true;
-
- /**
- * Constructor
- *
- * @param parent the body region this reference area is placed in.
- */
- public MainReference(BodyRegion parent) {
- this.parent = parent;
- addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
- }
-
- /**
- * Add a span area to this area.
- *
- * @param spanAll whether to make a single-column span
- * @return the created span area.
- */
- public Span createSpan(boolean spanAll) {
- if (spanAreas.size() > 0 && getCurrentSpan().isEmpty()) {
- //Remove the current one if it is empty
- spanAreas.remove(spanAreas.size() - 1);
- }
- Span newSpan = new Span(((spanAll) ? 1 : getColumnCount()),
- getColumnGap(), parent.getContentIPD());
- spanAreas.add(newSpan);
- return getCurrentSpan();
- }
-
- /**
- * Get the span areas from this area.
- *
- * @return the list of span areas
- */
- public List<Span> getSpans() {
- return spanAreas;
- }
-
- /**
- * Do not use. Used to handle special page-master for last page: transfer the content
- * that had already been added to a normal page to this main reference for the last
- * page. TODO this is hacky.
- *
- * @param spans content already laid out
- */
- public void setSpans(List<Span> spans) {
- spanAreas = new ArrayList<Span>(spans);
- }
-
- /**
- * Get the span area currently being filled (i.e., the last span created).
- * @return the active span.
- */
- public Span getCurrentSpan() {
- return spanAreas.get(spanAreas.size() - 1);
- }
-
- /**
- * Indicates whether any child areas have been added to this reference area.
- *
- * This is achieved by looping through each span.
- * @return true if no child areas have been added yet.
- */
- public boolean isEmpty() {
- if (isEmpty && spanAreas != null) {
- for (Span spanArea : spanAreas) {
- if (!spanArea.isEmpty()) {
- isEmpty = false;
- break;
- }
- }
- }
- return isEmpty;
- }
-
- /** @return the number of columns */
- public int getColumnCount() {
- return parent.getColumnCount();
- }
-
- /** @return the column gap in millipoints */
- public int getColumnGap() {
- return parent.getColumnGap();
- }
-
- /**
- * Sets the writing mode traits for the spans of this main
- * reference area.
- * @param wmtg a WM traits getter
- */
- public void setWritingModeTraits(WritingModeTraitsGetter wmtg) {
- for (Span s : getSpans()) {
- s.setWritingModeTraits(wmtg);
- }
- }
-
-}
-
diff --git a/src/java/org/apache/fop/area/NormalFlow.java b/src/java/org/apache/fop/area/NormalFlow.java
deleted file mode 100644
index 3daf2dafd..000000000
--- a/src/java/org/apache/fop/area/NormalFlow.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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;
-
-/**
- * The normal-flow-reference-area class.
- * Each span-reference-area contains one or more of these objects
- * See fo:region-body definition in the XSL Rec for more information.
- */
-public class NormalFlow extends BlockParent {
-
- private static final long serialVersionUID = -3753538631016929004L;
-
- /**
- * Constructor.
- * @param ipd of Normal flow object
- */
- public NormalFlow(int ipd) {
- addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
- setIPD(ipd);
- }
-
- /** {@inheritDoc} */
- public void addBlock(Block block) {
- super.addBlock(block);
- if (block.isStacked()) {
- bpd += block.getAllocBPD();
- }
- }
-}
-
diff --git a/src/java/org/apache/fop/area/OffDocumentExtensionAttachment.java b/src/java/org/apache/fop/area/OffDocumentExtensionAttachment.java
deleted file mode 100644
index c8d653bd0..000000000
--- a/src/java/org/apache/fop/area/OffDocumentExtensionAttachment.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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 org.apache.fop.fo.extensions.ExtensionAttachment;
-
-/**
- * This class wraps ExtensionAttachments which cannot be transported inside the area tree but
- * need to be handled in the AreaTreeHandler. These attachments are schedules for processing
- * before the first page-sequence, i.e. at the start of the document.
- */
-public class OffDocumentExtensionAttachment implements OffDocumentItem {
-
- private ExtensionAttachment attachment;
-
- /**
- * Main constructor
- * @param attachment the extension attachment to wrap.
- */
- public OffDocumentExtensionAttachment(ExtensionAttachment attachment) {
- this.attachment = attachment;
- }
-
- /** @return the extension attachment. */
- public ExtensionAttachment getAttachment() {
- return this.attachment;
- }
-
- /** {@inheritDoc} */
- public int getWhenToProcess() {
- return OffDocumentItem.IMMEDIATELY;
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return attachment.getCategory();
- }
-
-}
diff --git a/src/java/org/apache/fop/area/OffDocumentItem.java b/src/java/org/apache/fop/area/OffDocumentItem.java
deleted file mode 100644
index c2c0a3f68..000000000
--- a/src/java/org/apache/fop/area/OffDocumentItem.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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;
-
-/**
- * Interface for objects that are processed by the renderer outside
- * of the actual document.
- * An object implementing this interface can be handled by the renderer according to these
- * possibilities: IMMEDIATELY, AFTER_PAGE or END_OF_DOC.
- */
-public interface OffDocumentItem {
-
- /**
- * Process this extension immediately when
- * being handled by the area tree.
- */
- int IMMEDIATELY = 0;
-
- /**
- * Process this extension after the next page is rendered
- * or prepared when being handled by the area tree.
- */
- int AFTER_PAGE = 1;
-
- /**
- * Process this extension at the end of the document once
- * all pages have been fully rendered.
- */
- int END_OF_DOC = 2;
-
-
- /**
- * Get an indicator of when this item should be processed
- * @return int constant (IMMEDIATELY, AFTER_PAGE, END_OF_DOC)
- */
- int getWhenToProcess();
-
- /**
- * Return a human-readable name for this ODI (for error messages, etc.)
- * @return String name of ODI
- */
- String getName();
-
-}
diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java
deleted file mode 100644
index 71de13852..000000000
--- a/src/java/org/apache/fop/area/Page.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * 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;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.fop.datatypes.FODimension;
-import org.apache.fop.datatypes.LengthBase;
-import org.apache.fop.datatypes.SimplePercentBaseContext;
-import org.apache.fop.fo.pagination.Region;
-import org.apache.fop.fo.pagination.RegionBody;
-import org.apache.fop.fo.pagination.SimplePageMaster;
-import org.apache.fop.fo.properties.CommonMarginBlock;
-import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.traits.WritingModeTraitsGetter;
-
-import static org.apache.fop.fo.Constants.EN_ERROR_IF_OVERFLOW;
-import static org.apache.fop.fo.Constants.EN_HIDDEN;
-import static org.apache.fop.fo.Constants.FO_REGION_AFTER;
-import static org.apache.fop.fo.Constants.FO_REGION_BEFORE;
-import static org.apache.fop.fo.Constants.FO_REGION_BODY;
-import static org.apache.fop.fo.Constants.FO_REGION_END;
-import static org.apache.fop.fo.Constants.FO_REGION_START;
-
-/**
- * The page.
- * This holds the contents of the page. Each region is added.
- * The unresolved references area added so that if the page is
- * serialized then it will handle the resolving properly after
- * being reloaded.
- * This is serializable so it can be saved to cache to save
- * memory if there are forward references.
- * 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 {
-
- private static final long serialVersionUID = 6272157047421543866L;
-
- // contains before, start, body, end and after regions
- private RegionViewport regionBefore;
- private RegionViewport regionStart;
- private RegionViewport regionBody;
- private RegionViewport regionEnd;
- private RegionViewport regionAfter;
-
- // temporary map of unresolved objects used when serializing the page
- private Map<String, List<Resolvable>> unresolved;
-
- /** Set to true to make this page behave as if it were not empty. */
- private boolean fakeNonEmpty;
-
- /**
- * Empty constructor
- */
- public Page() { }
-
- /**
- * Constructor
- * @param spm SimplePageMaster containing the dimensions for this
- * page-reference-area
- */
- public Page(SimplePageMaster spm) {
- // Width and Height of the page view port
- FODimension pageViewPortDims = new FODimension(spm.getPageWidth().getValue()
- , spm.getPageHeight().getValue());
-
- // Get absolute margin properties (top, left, bottom, right)
- CommonMarginBlock mProps = spm.getCommonMarginBlock();
-
- /*
- * Create the page reference area rectangle (0,0 is at top left
- * of the "page media" and y increases
- * when moving towards the bottom of the page.
- * The media rectangle itself is (0,0,pageWidth,pageHeight).
- */
- /* Special rules apply to resolving margins in the page context.
- * Contrary to normal margins in this case top and bottom margin
- * are resolved relative to the height. In the property subsystem
- * all margin properties are configured to using BLOCK_WIDTH.
- * That's why we 'cheat' here and setup a context for the height but
- * use the LengthBase.BLOCK_WIDTH.
- */
- SimplePercentBaseContext pageWidthContext
- = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH
- , pageViewPortDims.ipd);
- SimplePercentBaseContext pageHeightContext
- = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH
- , pageViewPortDims.bpd);
-
- Rectangle pageRefRect
- = new Rectangle(mProps.marginLeft.getValue(pageWidthContext)
- , mProps.marginTop.getValue(pageHeightContext)
- , pageViewPortDims.ipd
- - mProps.marginLeft.getValue(pageWidthContext)
- - mProps.marginRight.getValue(pageWidthContext)
- , pageViewPortDims.bpd
- - mProps.marginTop.getValue(pageHeightContext)
- - mProps.marginBottom.getValue(pageHeightContext));
-
- // Set up the CTM on the page reference area based on writing-mode
- // and reference-orientation
- FODimension reldims = new FODimension(0, 0);
- CTM pageCTM = CTM.getCTMandRelDims(spm.getReferenceOrientation(),
- spm.getWritingMode(), pageRefRect, reldims);
-
- // Create a RegionViewport/ reference area pair for each page region
- RegionReference rr;
- for (Region r : spm.getRegions().values()) {
- RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM);
- if (r.getNameId() == FO_REGION_BODY) {
- rr = new BodyRegion((RegionBody) r, rvp);
- } else {
- rr = new RegionReference(r, rvp);
- }
- // set borders and padding traits
- // (a little extensions wrt what prescribed by the specs at 6.4.14)
- TraitSetter.addBorders(rr, r.getCommonBorderPaddingBackground(),
- false, false, false, false, null);
- TraitSetter.addPadding(rr, r.getCommonBorderPaddingBackground(),
- false, false, false, false, null);
- setRegionReferencePosition(rr, r, rvp.getViewArea());
- rvp.setRegionReference(rr);
- setRegionViewport(r.getNameId(), rvp);
- }
- }
-
- /**
- * Call this method to force this page to pretend not to be empty.
- */
- public void fakeNonEmpty() {
- this.fakeNonEmpty = true;
- }
-
- /**
- * Creates a RegionViewport Area object for this pagination Region.
- * @param r the region the viewport is to be created for
- * @param reldims relative dimensions
- * @param pageCTM page coordinate transformation matrix
- * @return the new region viewport
- */
- private static RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM) {
- Rectangle2D relRegionRect = r.getViewportRectangle(reldims);
- Rectangle2D absRegionRect = pageCTM.transform(relRegionRect);
- // Get the region viewport rectangle in absolute coords by
- // transforming it using the page CTM
- RegionViewport rv = new RegionViewport(absRegionRect);
- rv.setBPD((int)relRegionRect.getHeight());
- rv.setIPD((int)relRegionRect.getWidth());
- TraitSetter.addBackground(rv, r.getCommonBorderPaddingBackground(), null);
- rv.setClip(r.getOverflow() == EN_HIDDEN
- || r.getOverflow() == EN_ERROR_IF_OVERFLOW);
- return rv;
- }
-
- /**
- * Set the region reference position within the region viewport.
- * This sets the transform that is used to place the contents of
- * the region reference.
- *
- * @param rr the region reference area
- * @param r the region-xxx formatting object
- * @param absRegVPRect The region viewport rectangle in "absolute" coordinates
- * where x=distance from left, y=distance from bottom, width=right-left
- * height=top-bottom
- */
- private static void setRegionReferencePosition(RegionReference rr, Region r,
- Rectangle2D absRegVPRect) {
- FODimension reldims = new FODimension(0, 0);
- rr.setCTM(CTM.getCTMandRelDims(r.getReferenceOrientation(),
- r.getWritingMode(), absRegVPRect, reldims));
- rr.setIPD(reldims.ipd
- - rr.getBorderAndPaddingWidthStart()
- - rr.getBorderAndPaddingWidthEnd());
- rr.setBPD(reldims.bpd
- - rr.getBorderAndPaddingWidthBefore()
- - rr.getBorderAndPaddingWidthAfter());
- }
-
- /**
- * Set the region on this page.
- *
- * @param areaclass the area class of the region to set
- * @param port the region viewport to set
- */
- public void setRegionViewport(int areaclass, RegionViewport port) {
- if (areaclass == FO_REGION_BEFORE) {
- regionBefore = port;
- } else if (areaclass == FO_REGION_START) {
- regionStart = port;
- } else if (areaclass == FO_REGION_BODY) {
- regionBody = port;
- } else if (areaclass == FO_REGION_END) {
- regionEnd = port;
- } else if (areaclass == FO_REGION_AFTER) {
- regionAfter = port;
- }
- }
-
- /**
- * Get the region from this page.
- *
- * @param areaClass the region area class
- * @return the region viewport or null if none
- */
- public RegionViewport getRegionViewport(int areaClass) {
- switch (areaClass) {
- case FO_REGION_BEFORE:
- return regionBefore;
- case FO_REGION_START:
- return regionStart;
- case FO_REGION_BODY:
- return regionBody;
- case FO_REGION_END:
- return regionEnd;
- case FO_REGION_AFTER:
- return regionAfter;
- default:
- throw new IllegalArgumentException("No such area class with ID = " + areaClass);
- }
- }
-
- /**
- * Indicates whether any FOs have been added to the body region
- *
- * @return whether any FOs have been added to the body region
- */
- public boolean isEmpty() {
- if (fakeNonEmpty) {
- return false;
- } else if (regionBody == null) {
- return true;
- } else {
- return regionBody.getRegionReference().isEmpty();
- }
- }
-
- /** {@inheritDoc} */
- public Object clone() throws CloneNotSupportedException {
- Page p = (Page) super.clone();
- if (regionBefore != null) {
- p.regionBefore = (RegionViewport)regionBefore.clone();
- }
- if (regionStart != null) {
- p.regionStart = (RegionViewport)regionStart.clone();
- }
- if (regionBody != null) {
- p.regionBody = (RegionViewport)regionBody.clone();
- }
- if (regionEnd != null) {
- p.regionEnd = (RegionViewport)regionEnd.clone();
- }
- if (regionAfter != null) {
- p.regionAfter = (RegionViewport)regionAfter.clone();
- }
-
- return p;
- }
-
- /**
- * Set the unresolved references on this page for serializing.
- *
- * @param unres the Map of unresolved objects
- */
- public void setUnresolvedReferences(Map<String, List<Resolvable>> unres) {
- unresolved = unres;
- }
-
- /**
- * Get the map unresolved references from this page.
- * This should be called after deserializing to retrieve
- * the map of unresolved references that were serialized.
- *
- * @return the de-serialized HashMap of unresolved objects
- */
- public Map<String, List<Resolvable>> getUnresolvedReferences() {
- return unresolved;
- }
-
- /**
- * Sets the writing mode traits for the region viewports of
- * this page.
- * @param wmtg a WM traits getter
- */
- public void setWritingModeTraits(WritingModeTraitsGetter wmtg) {
- if (regionBefore != null) {
- regionBefore.setWritingModeTraits(wmtg);
- }
- if (regionStart != null) {
- regionStart.setWritingModeTraits(wmtg);
- }
- if (regionBody != null) {
- regionBody.setWritingModeTraits(wmtg);
- }
- if (regionEnd != null) {
- regionEnd.setWritingModeTraits(wmtg);
- }
- if (regionAfter != null) {
- regionAfter.setWritingModeTraits(wmtg);
- }
- }
-
-}
-
-
diff --git a/src/java/org/apache/fop/area/PageSequence.java b/src/java/org/apache/fop/area/PageSequence.java
deleted file mode 100644
index 124476602..000000000
--- a/src/java/org/apache/fop/area/PageSequence.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.util.List;
-import java.util.Locale;
-
-/**
- * Represents a page sequence in the area tree.
- */
-public class PageSequence extends AreaTreeObject {
-
- private List<PageViewport> pages = new java.util.ArrayList<PageViewport>();
- private LineArea title;
-
- private Locale locale;
-
- /**
- * Main constructor
- * @param title the title for the page-sequence, may be null
- */
- public PageSequence(LineArea title) {
- setTitle(title);
- }
-
- /**
- * @return the title of the page sequence in form of a line area, or null if there's no title
- */
- public LineArea getTitle() {
- return this.title;
- }
-
- /**
- * Sets the page sequence's title.
- * @param title the title
- */
- public void setTitle(LineArea title) {
- this.title = title;
- }
-
- /**
- * Adds a new page to the page sequence
- * @param page the page to be added
- */
- public void addPage(PageViewport page) {
- this.pages.add(page);
- }
-
- /**
- * @return the number of pages currently in this page sequence
- */
- public int getPageCount() {
- return this.pages.size();
- }
-
- /**
- * Returns the page at the given index.
- * @param idx the index of the requested page
- * @return the requested page or null if it was not found
- */
- public PageViewport getPage(int idx) {
- return this.pages.get(idx);
- }
-
- /**
- * Indicates whether a page is the first in this page sequence.
- * @param page the page to be inspected
- * @return true if the page is the first in this page sequence, false otherwise
- */
- public boolean isFirstPage(PageViewport page) {
- return page.equals(getPage(0));
- }
-
- /**
- * Sets the locale that applies to this page-sequence.
- *
- * @param locale the locale to set
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- /**
- * Returns the locale of this page-sequence.
- *
- * @return the locale, {@code null} if not set
- */
- public Locale getLocale() {
- return locale;
- }
-
-}
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java
deleted file mode 100644
index f1cd95721..000000000
--- a/src/java/org/apache/fop/area/PageViewport.java
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * 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.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-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.AbstractRetrieveMarker;
-import org.apache.fop.fo.flow.Marker;
-import org.apache.fop.fo.flow.Markers;
-import org.apache.fop.fo.pagination.SimplePageMaster;
-import org.apache.fop.traits.WritingModeTraitsGetter;
-
-import static org.apache.fop.fo.Constants.FO_REGION_BODY;
-
-/**
- * Page viewport that specifies the viewport area and holds the page contents.
- * This is the top level object for a page and remains valid for the life
- * of the document and the area tree.
- * This object may be used as a key to reference a page.
- * 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 {
-
- private Page page;
- private Rectangle viewArea;
- private String simplePageMasterName;
-
- /**
- * Unique key to identify the page. pageNumberString and pageIndex are both no option
- * for this.
- */
- private String pageKey;
-
- private int pageNumber = -1;
- private String pageNumberString;
- private int pageIndex = -1; //-1 = undetermined
- private boolean blank;
-
- private transient PageSequence pageSequence;
-
- // set of IDs that appear first (or exclusively) on this page:
- private Set<String> idFirsts = new java.util.HashSet<String>();
-
- // this keeps a list of currently unresolved areas or extensions
- // once an idref is resolved it is removed
- // when this is empty the page can be rendered
- private Map<String, List<Resolvable>> unresolvedIDRefs
- = new java.util.HashMap<String, List<Resolvable>>();
-
- private Map<String, List<PageViewport>> pendingResolved;
-
- private Markers pageMarkers;
-
- /**
- * logging instance
- */
- protected static final Log log = LogFactory.getLog(PageViewport.class);
-
- /**
- * Create a page viewport.
- * @param spm SimplePageMaster indicating the page and region dimensions
- * @param pageNumber the page number
- * @param pageStr String representation of the page number
- * @param blank true if this is a blank page
- * @param spanAll true if the first span area spans all columns
- */
- public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr,
- boolean blank, boolean spanAll) {
- this.simplePageMasterName = spm.getMasterName();
- setExtensionAttachments(spm.getExtensionAttachments());
- setForeignAttributes(spm.getForeignAttributes());
- this.blank = blank;
- int pageWidth = spm.getPageWidth().getValue();
- int pageHeight = spm.getPageHeight().getValue();
- this.pageNumber = pageNumber;
- this.pageNumberString = pageStr;
- this.viewArea = new Rectangle(0, 0, pageWidth, pageHeight);
- this.page = new Page(spm);
- createSpan(spanAll);
- }
-
- /**
- * Create a page viewport.
- * @param spm SimplePageMaster indicating the page and region dimensions
- * @param pageNumber the page number
- * @param pageStr String representation of the page number
- * @param blank true if this is a blank page
- */
- public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) {
- this(spm, pageNumber, pageStr, blank, false);
- }
-
- /**
- * Copy constructor.
- * @param original the original PageViewport to copy from
- * @throws FOPException when cloning of the page is not supported
- */
- public PageViewport(PageViewport original) throws FOPException {
- if (original.extensionAttachments != null) {
- setExtensionAttachments(original.extensionAttachments);
- }
- if (original.foreignAttributes != null) {
- setForeignAttributes(original.foreignAttributes);
- }
- this.pageIndex = original.pageIndex;
- this.pageNumber = original.pageNumber;
- this.pageNumberString = original.pageNumberString;
- 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;
- }
-
- /**
- * Constructor used by the area tree parser.
- * @param viewArea the view area
- * @param pageNumber the page number
- * @param pageStr String representation of the page number
- * @param simplePageMasterName name of the original simple-page-master that generated this page
- * @param blank true if this is a blank page
- */
- public PageViewport(Rectangle viewArea, int pageNumber, String pageStr,
- String simplePageMasterName, boolean blank) {
- this.viewArea = viewArea;
- this.pageNumber = pageNumber;
- this.pageNumberString = pageStr;
- this.simplePageMasterName = simplePageMasterName;
- this.blank = blank;
- }
-
- /**
- * Sets the page sequence this page belongs to
- * @param seq the page sequence
- */
- public void setPageSequence(PageSequence seq) {
- this.pageSequence = seq;
- }
-
- /** @return the page sequence this page belongs to */
- public PageSequence getPageSequence() {
- return this.pageSequence;
- }
-
- /**
- * Get the view area rectangle of this viewport.
- * @return the rectangle for this viewport
- */
- public Rectangle getViewArea() {
- return viewArea;
- }
-
- /**
- * Get the page reference area with the contents.
- * @return the page reference area
- */
- public Page getPage() {
- return page;
- }
-
- /**
- * Sets the page object for this PageViewport.
- * @param page the page
- */
- public void setPage(Page page) {
- this.page = page;
- }
-
- /**
- * Get the page number of this page.
- * @return the integer value that represents this page
- */
- public int getPageNumber() {
- return pageNumber;
- }
-
- /**
- * Get the page number of this page.
- * @return the string that represents this page
- */
- public String getPageNumberString() {
- return pageNumberString;
- }
-
- /**
- * Sets the page index of the page in this rendering run.
- * (This is not the same as the page number!)
- * @param index the page index (zero-based), -1 if it is undetermined
- */
- public void setPageIndex(int index) {
- this.pageIndex = index;
- }
-
- /**
- * @return the overall page index of the page in this rendering run (zero-based,
- * -1 if it is undetermined).
- */
- public int getPageIndex() {
- return this.pageIndex;
- }
-
- /**
- * Sets the unique key for this PageViewport that will be used to reference this page.
- * @param key the unique key.
- */
- public void setKey(String key) {
- this.pageKey = key;
- }
-
- /**
- * Get the key for this page viewport.
- * This is used so that a serializable key can be used to
- * lookup the page or some other reference.
- *
- * @return a unique page viewport key for this area tree
- */
- public String getKey() {
- if (this.pageKey == null) {
- throw new IllegalStateException("No page key set on the PageViewport: " + toString());
- }
- return this.pageKey;
- }
-
- /**
- * Add an "ID-first" to this page.
- * This is typically called by the {@link AreaTreeHandler} when associating
- * an ID with a {@link PageViewport}.
- *
- * @param id the id to be registered as first appearing on this page
- */
- public void setFirstWithID(String id) {
- if (id != null) {
- idFirsts.add(id);
- }
- }
-
- /**
- * Check whether a certain id first appears on this page
- *
- * @param id the id to be checked
- * @return true if this page is the first where the id appears
- */
- public boolean isFirstWithID(String id) {
- return idFirsts.contains(id);
- }
-
- /**
- * Replace the old view port. This copies all ID related fields from the old view port
- * to the current one.
- * @param oldViewPort old view port
- */
- public void replace(PageViewport oldViewPort) {
- this.idFirsts.addAll(oldViewPort.idFirsts);
- this.unresolvedIDRefs.putAll(oldViewPort.unresolvedIDRefs);
- if (oldViewPort.pendingResolved != null) {
- this.pendingResolved.putAll(oldViewPort.pendingResolved);
- }
- }
-
- /**
- * Add an idref to this page.
- * All idrefs found for child areas of this {@link PageViewport} are added
- * to unresolvedIDRefs, for subsequent resolution by {@link AreaTreeHandler}
- * calls to this object's {@code resolveIDRef()}.
- *
- * @param idref the idref
- * @param res the child element of this page that needs this
- * idref resolved
- */
- public void addUnresolvedIDRef(String idref, Resolvable res) {
- if (unresolvedIDRefs == null) {
- unresolvedIDRefs = new HashMap<String, List<Resolvable>>();
- }
- List<Resolvable> pageViewports = unresolvedIDRefs.get(idref);
- if (pageViewports == null) {
- pageViewports = new ArrayList<Resolvable>();
- unresolvedIDRefs.put(idref, pageViewports);
- }
- pageViewports.add(res);
- }
-
- /**
- * Check if this page has been fully resolved.
- * @return true if the page is resolved and can be rendered
- */
- public boolean isResolved() {
- return unresolvedIDRefs == null
- || unresolvedIDRefs.size() == 0;
- }
-
- /**
- * Get the unresolved idrefs for this page.
- * @return String array of idref's that still have not been resolved
- */
- public String[] getIDRefs() {
- return (unresolvedIDRefs == null) ? null
- : unresolvedIDRefs.keySet().toArray(
- new String[unresolvedIDRefs.keySet().size()]);
- }
-
- /** {@inheritDoc} */
- public void resolveIDRef(String id, List<PageViewport> pages) {
- if (page == null) {
- if (pendingResolved == null) {
- pendingResolved = new HashMap<String, List<PageViewport>>();
- }
- pendingResolved.put(id, pages);
- } else {
- if (unresolvedIDRefs != null) {
- List<Resolvable> todo = unresolvedIDRefs.get(id);
- if (todo != null) {
- for (Resolvable res : todo) {
- res.resolveIDRef(id, pages);
- }
- }
- }
- }
- if (unresolvedIDRefs != null && pages != null) {
- unresolvedIDRefs.remove(id);
- if (unresolvedIDRefs.isEmpty()) {
- unresolvedIDRefs = null;
- }
- }
- }
-
- /**
- * Register the markers for this page.
- *
- * @param marks the map of markers to add
- * @param starting if the area being added is starting or ending
- * @param isfirst if the area being added has is-first trait
- * @param islast if the area being added has is-last trait
- */
- public void registerMarkers(Map<String, Marker> marks, boolean starting, boolean isfirst, boolean islast) {
- if (pageMarkers == null) {
- pageMarkers = new Markers();
- }
- pageMarkers.register(marks, starting, isfirst, islast);
- }
-
-
- /**
- * Resolve a marker from this page.
- * This will retrieve a marker with the class name
- * and position.
- *
- * @param rm the retrieve-marker instance
- * @return Object the marker found or null
- */
- public Marker resolveMarker(AbstractRetrieveMarker rm) {
- if (pageMarkers == null) {
- return null;
- }
- return pageMarkers.resolve(rm);
- }
-
- /** Dumps the current marker data to the logger. */
- public void dumpMarkers() {
- if (pageMarkers != null) {
- pageMarkers.dump();
- }
- }
-
- /**
- * Save the page contents to an object stream.
- * The map of unresolved references are set on the page so that
- * the resolvers can be properly serialized and reloaded.
- * @param out the object output stream to write the contents
- * @throws IOException in case of an I/O error while serializing the page
- */
- public void savePage(ObjectOutputStream out) throws IOException {
- // set the unresolved references so they are serialized
- page.setUnresolvedReferences(unresolvedIDRefs);
- out.writeObject(page);
- page = null;
- }
-
- /**
- * Load the page contents from an object stream.
- * This loads the page contents from the stream and
- * if there are any unresolved references that were resolved
- * while saved they will be resolved on the page contents.
- * @param in the object input stream to read the page from
- * @throws ClassNotFoundException if a class was not found while loading the page
- * @throws IOException if an I/O error occurred while loading the page
- */
- public void loadPage(ObjectInputStream in) throws IOException, ClassNotFoundException {
- page = (Page) in.readObject();
- unresolvedIDRefs = page.getUnresolvedReferences();
- if (unresolvedIDRefs != null && pendingResolved != null) {
- for (Map.Entry<String, List<PageViewport>> e : pendingResolved.entrySet()) {
- resolveIDRef(e.getKey(), e.getValue());
- }
- pendingResolved = null;
- }
- }
-
- /** {@inheritDoc} */
- public Object clone() throws CloneNotSupportedException {
- PageViewport pvp = (PageViewport) super.clone();
- pvp.page = (Page) page.clone();
- pvp.viewArea = (Rectangle) viewArea.clone();
- return pvp;
- }
-
- /**
- * Clear the page contents to save memory.
- * This object is kept for the life of the area tree since
- * it holds id and marker information and is used as a key.
- */
- public void clear() {
- page = null;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer(64);
- sb.append("PageViewport: page=");
- sb.append(getPageNumberString());
- return sb.toString();
- }
-
- /** @return the name of the simple-page-master that created this page */
- public String getSimplePageMasterName() {
- return this.simplePageMasterName;
- }
-
- /** @return True if this is a blank page. */
- public boolean isBlank() {
- return this.blank;
- }
-
- /**
- * Convenience method to get BodyRegion of this PageViewport
- * @return BodyRegion object
- */
- public BodyRegion getBodyRegion() {
- RegionReference regionReference = getPage().getRegionViewport(FO_REGION_BODY).getRegionReference();
- assert (regionReference instanceof BodyRegion);
- return (BodyRegion) regionReference;
- }
-
- /**
- * Convenience method to create a new Span for this
- * this PageViewport.
- *
- * @param spanAll whether this is a single-column span
- * @return Span object created
- */
- public Span createSpan(boolean spanAll) {
- return getBodyRegion().getMainReference().createSpan(spanAll);
- }
-
- /**
- * Convenience method to get the span-reference-area currently
- * being processed
- *
- * @return span currently being processed.
- */
- public Span getCurrentSpan() {
- return getBodyRegion().getMainReference().getCurrentSpan();
- }
-
- /**
- * Convenience method to get the normal-flow-reference-area
- * currently being processed
- *
- * @return span currently being processed.
- */
- public NormalFlow getCurrentFlow() {
- return getCurrentSpan().getCurrentFlow();
- }
-
- /**
- * Convenience method to increment the Span to the
- * next NormalFlow to be processed, and to return that flow.
- *
- * @return the next NormalFlow in the Span.
- */
- public NormalFlow moveToNextFlow() {
- return getCurrentSpan().moveToNextFlow();
- }
-
- /**
- * Convenience method to return a given region-reference-area,
- * keyed by the Constants class identifier for the corresponding
- * formatting object (ie. Constants.FO_REGION_BODY, FO_REGION_START,
- * etc.)
- *
- * @param id the Constants class identifier for the region.
- * @return the corresponding region-reference-area for this page.
- */
- public RegionReference getRegionReference(int id) {
- return getPage().getRegionViewport(id).getRegionReference();
- }
-
- /**
- * Sets the writing mode traits for the page associated with this viewport.
- * @param wmtg a WM traits getter
- */
- public void setWritingModeTraits(WritingModeTraitsGetter wmtg) {
- if (page != null) {
- page.setWritingModeTraits(wmtg);
- }
- }
-
-}
diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java
deleted file mode 100644
index a22bb5b06..000000000
--- a/src/java/org/apache/fop/area/RegionReference.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.util.ArrayList;
-import java.util.List;
-
-import org.apache.fop.fo.pagination.Region;
-
-/**
- * This is a region reference area for a page regions.
- * 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 {
-
- private static final long serialVersionUID = -298980963268244238L;
-
- private int regionClass;
- private String regionName;
- private CTM ctm;
-
- // the list of block areas from the static flow
- private ArrayList<Area> blocks = new ArrayList<Area>();
-
- /** the parent {@link RegionViewport} for this object */
- protected RegionViewport regionViewport;
-
- /**
- * Create a new region reference area.
- *
- * @param regionFO the region.
- * @param parent the viewport for this region.
- */
- public RegionReference(Region regionFO, RegionViewport parent) {
- this(regionFO.getNameId(), regionFO.getRegionName(), parent);
- }
-
- /**
- * Create a new region reference area.
- *
- * @param regionClass the region class (as returned by Region.getNameId())
- * @param regionName the name of the region (as returned by Region.getRegionName())
- * @param parent the viewport for this region.
- */
- public RegionReference(int regionClass, String regionName, RegionViewport parent) {
- this.regionClass = regionClass;
- this.regionName = regionName;
- addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
- regionViewport = parent;
- }
-
- /** {@inheritDoc} */
- @Override
- public void addChildArea(Area child) {
- blocks.add(child);
- }
-
- /**
- * Set the Coordinate Transformation Matrix which transforms content
- * coordinates in this region reference area which are specified in
- * terms of "start" and "before" into coordinates in a system which
- * is positioned in "absolute" directions (with origin at lower left of
- * the region reference area.
- *
- * @param ctm the current transform to position this region
- */
- public void setCTM(CTM ctm) {
- this.ctm = ctm;
- }
-
- /**
- * @return Returns the parent RegionViewport.
- */
- public RegionViewport getRegionViewport() {
- return regionViewport;
- }
-
- /**
- * Get the current transform of this region.
- *
- * @return ctm the current transform to position this region
- */
- public CTM getCTM() {
- return this.ctm;
- }
-
- /**
- * Get the block in this region.
- *
- * @return the list of blocks in this region
- */
- public List<Area> getBlocks() {
- return blocks;
- }
-
- /**
- * Get the region class of this region.
- *
- * @return the region class
- */
- public int getRegionClass() {
- return this.regionClass;
- }
-
- /** @return the region name */
- public String getRegionName() {
- return this.regionName;
- }
-
- /**
- * Add a block area to this region reference area.
- *
- * @param block the block area to add
- */
- public void addBlock(Block block) {
- addChildArea(block);
- }
-
- /**
- * indicates whether the main reference area has any child areas added to it
- *
- * @return whether the main reference area has any child areas added to it
- */
- public boolean isEmpty() {
- return true;
- }
-
- /** {@inheritDoc} */
- public Object clone() throws CloneNotSupportedException {
- RegionReference rr = (RegionReference) super.clone();
- rr.blocks = (ArrayList) blocks.clone();
- return rr;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer(super.toString());
- sb.append(" {regionName=").append(regionName);
- sb.append(", regionClass=").append(regionClass);
- sb.append(", ctm=").append(ctm);
- sb.append("}");
- return sb.toString();
- }
-}
diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java
deleted file mode 100644
index 36984b610..000000000
--- a/src/java/org/apache/fop/area/RegionViewport.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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;
-import java.io.IOException;
-import java.util.TreeMap;
-
-import org.apache.fop.traits.WritingModeTraitsGetter;
-
-/**
- * Region Viewport area.
- * This object represents the region-viewport-area. It has a
- * 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 Viewport {
-
- private static final long serialVersionUID = 505781815165102572L;
-
- // this rectangle is relative to the page
- private RegionReference regionReference;
- private Rectangle2D viewArea;
- private boolean clip;
-
- /**
- * Create a new region-viewport-area
- *
- * @param viewArea the view area of this viewport
- */
- public RegionViewport(Rectangle2D viewArea) {
- this.viewArea = viewArea;
- addTrait(Trait.IS_VIEWPORT_AREA, Boolean.TRUE);
- }
-
- /**
- * Set the region-reference-area for this region viewport.
- *
- * @param reg the child region-reference-area inside this viewport
- */
- public void setRegionReference(RegionReference reg) {
- regionReference = reg;
- }
-
- /**
- * Get the region-reference-area for this region viewport.
- *
- * @return the child region-reference-area inside this viewport
- */
- public RegionReference getRegionReference() {
- return regionReference;
- }
-
- /**
- * Set the clipping for this region viewport.
- *
- * @param c the clipping value
- */
- public void setClip(boolean c) {
- clip = c;
- }
-
- /** {@inheritDoc} */
- public boolean hasClip() {
- return this.clip;
- }
-
- /** {@inheritDoc} */
- public Rectangle getClipRectangle() {
- if (clip) {
- return new Rectangle(getIPD(), getBPD());
- } else {
- return null;
- }
- }
-
- /**
- * Get the view area of this viewport.
- *
- * @return the viewport rectangle area
- */
- public Rectangle2D getViewArea() {
- return viewArea;
- }
-
- private void writeObject(java.io.ObjectOutputStream out)
- throws IOException {
- out.writeFloat((float) viewArea.getX());
- out.writeFloat((float) viewArea.getY());
- out.writeFloat((float) viewArea.getWidth());
- out.writeFloat((float) viewArea.getHeight());
- out.writeBoolean(clip);
- out.writeObject((TreeMap)traits);
- out.writeObject(regionReference);
- }
-
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException {
- viewArea = new Rectangle2D.Float(in.readFloat(), in.readFloat(),
- in.readFloat(), in.readFloat());
- clip = in.readBoolean();
- traits = (TreeMap)in.readObject();
- setRegionReference((RegionReference) in.readObject());
- }
-
- /** {@inheritDoc} */
- public Object clone() throws CloneNotSupportedException {
- RegionViewport rv = (RegionViewport) super.clone();
- rv.regionReference = (RegionReference) regionReference.clone();
- rv.viewArea = (Rectangle2D) viewArea.clone();
- return rv;
- }
-
- /**
- * Sets the writing mode traits for the region reference of
- * this region viewport
- * @param wmtg a WM traits getter
- */
- public void setWritingModeTraits(WritingModeTraitsGetter wmtg) {
- if (regionReference != null) {
- regionReference.setWritingModeTraits(wmtg);
- }
- }
-
-}
-
diff --git a/src/java/org/apache/fop/area/RenderPagesModel.java b/src/java/org/apache/fop/area/RenderPagesModel.java
deleted file mode 100644
index b94a32b4b..000000000
--- a/src/java/org/apache/fop/area/RenderPagesModel.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * 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;
-
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-
-import org.xml.sax.SAXException;
-
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererEventProducer;
-
-/**
- * This uses the AreaTreeModel to store the pages
- * Each page is either rendered if ready or prepared
- * for later rendering.
- * Once a page is rendered it is cleared to release the
- * contents but the PageViewport is retained. So even
- * though the pages are stored the contents are discarded.
- */
-public class RenderPagesModel extends AreaTreeModel {
- /**
- * The renderer that will render the pages.
- */
- protected Renderer renderer;
-
- /**
- * Pages that have been prepared but not rendered yet.
- */
- protected List<PageViewport> prepared = new java.util.ArrayList<PageViewport>();
-
- private List<OffDocumentItem> pendingODI = new java.util.ArrayList<OffDocumentItem>();
- private List<OffDocumentItem> endDocODI = new java.util.ArrayList<OffDocumentItem>();
-
- /**
- * Create a new render pages model with the given renderer.
- * @param userAgent FOUserAgent object for process
- * @param outputFormat the MIME type of the output format to use (ex. "application/pdf").
- * @param fontInfo FontInfo object
- * @param stream OutputStream
- * @throws FOPException if the renderer cannot be properly initialized
- */
- public RenderPagesModel(FOUserAgent userAgent, String outputFormat,
- FontInfo fontInfo, OutputStream stream) throws FOPException {
-
- super();
- this.renderer = userAgent.getRendererFactory().createRenderer(
- userAgent, outputFormat);
-
- try {
- renderer.setupFontInfo(fontInfo);
- // check that the "any,normal,400" font exists
- if (!fontInfo.isSetupValid()) {
- throw new FOPException(
- "No default font defined by OutputConverter");
- }
- renderer.startRenderer(stream);
- } catch (IOException e) {
- throw new FOPException(e);
- }
- }
-
- @Override
- public void setDocumentLocale(Locale locale) {
- renderer.setDocumentLocale(locale);
- }
-
- /** {@inheritDoc} */
- @Override
- public void startPageSequence(PageSequence pageSequence) {
- super.startPageSequence(pageSequence);
- if (renderer.supportsOutOfOrder()) {
- renderer.startPageSequence(getCurrentPageSequence());
- }
- }
-
- /**
- * Add a page to the render page model.
- * If the page is finished it can be rendered immediately.
- * If the page needs resolving then if the renderer supports
- * out of order rendering it can prepare the page. Otherwise
- * the page is added to a queue.
- * @param page the page to add to the model
- */
- @Override
- public void addPage(PageViewport page) {
- super.addPage(page);
-
- // for links the renderer needs to prepare the page
- // it is more appropriate to do this after queued pages but
- // it will mean that the renderer has not prepared a page that
- // could be referenced
- boolean ready = renderer.supportsOutOfOrder() && page.isResolved();
- if (ready) {
- if (!renderer.supportsOutOfOrder() && page.getPageSequence().isFirstPage(page)) {
- renderer.startPageSequence(getCurrentPageSequence());
- }
- try {
- renderer.renderPage(page);
- } catch (RuntimeException re) {
- String err = "Error while rendering page " + page.getPageNumberString();
- log.error(err, re);
- throw re;
- } catch (IOException ioe) {
- RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
- renderer.getUserAgent().getEventBroadcaster());
- eventProducer.ioError(this, ioe);
- } catch (FOPException e) {
- //TODO use error handler to handle this FOPException or propagate exception
- String err = "Error while rendering page " + page.getPageNumberString();
- log.error(err, e);
- throw new IllegalStateException("Fatal error occurred. Cannot continue. "
- + e.getClass().getName() + ": " + err);
- }
- page.clear();
- } else {
- preparePage(page);
- }
-
-
- // check prepared pages
- boolean cont = checkPreparedPages(page, false);
-
- if (cont) {
- processOffDocumentItems(pendingODI);
- pendingODI.clear();
- }
- }
-
- /**
- * Check prepared pages
- *
- * @param newPageViewport the new page being added
- * @param renderUnresolved render pages with unresolved idref's
- * (done at end-of-document processing)
- * @return true if the current page should be rendered
- * false if the renderer doesn't support out of order
- * rendering and there are pending pages
- */
- protected boolean checkPreparedPages(PageViewport newPageViewport,
- boolean renderUnresolved) {
-
- for (Iterator iter = prepared.iterator(); iter.hasNext();) {
- PageViewport pageViewport = (PageViewport)iter.next();
- if (pageViewport.isResolved() || renderUnresolved) {
- if (!renderer.supportsOutOfOrder()
- && pageViewport.getPageSequence().isFirstPage(pageViewport)) {
- renderer.startPageSequence(pageViewport.getPageSequence());
- }
- renderPage(pageViewport);
- pageViewport.clear();
- iter.remove();
- } else {
- // if keeping order then stop at first page not resolved
- if (!renderer.supportsOutOfOrder()) {
- break;
- }
- }
- }
- return renderer.supportsOutOfOrder() || prepared.isEmpty();
- }
-
- /**
- * Renders the given page and notified about unresolved IDs if any.
- * @param pageViewport the page to be rendered.
- */
- protected void renderPage(PageViewport pageViewport) {
- try {
- renderer.renderPage(pageViewport);
- if (!pageViewport.isResolved()) {
- String[] idrefs = pageViewport.getIDRefs();
- for (String idref : idrefs) {
- AreaEventProducer eventProducer = AreaEventProducer.Provider.get(
- renderer.getUserAgent().getEventBroadcaster());
- eventProducer.unresolvedIDReferenceOnPage(this,
- pageViewport.getPageNumberString(), idref);
- }
- }
- } catch (Exception e) {
- AreaEventProducer eventProducer = AreaEventProducer.Provider.get(
- renderer.getUserAgent().getEventBroadcaster());
- eventProducer.pageRenderingError(this,
- pageViewport.getPageNumberString(), e);
- if (e instanceof RuntimeException) {
- throw (RuntimeException)e;
- }
- }
- }
-
- /**
- * Prepare a page.
- * An unresolved page can be prepared if the renderer supports
- * it and the page will be rendered later.
- * @param page the page to prepare
- */
- protected void preparePage(PageViewport page) {
- if (renderer.supportsOutOfOrder()) {
- renderer.preparePage(page);
- }
- prepared.add(page);
- }
-
- /** {@inheritDoc} */
- @Override
- public void handleOffDocumentItem(OffDocumentItem oDI) {
- switch(oDI.getWhenToProcess()) {
- case OffDocumentItem.IMMEDIATELY:
- renderer.processOffDocumentItem(oDI);
- break;
- case OffDocumentItem.AFTER_PAGE:
- pendingODI.add(oDI);
- break;
- case OffDocumentItem.END_OF_DOC:
- endDocODI.add(oDI);
- break;
- default:
- throw new RuntimeException();
- }
- }
-
- private void processOffDocumentItems(List<OffDocumentItem> list) {
- for (OffDocumentItem oDI : list) {
- renderer.processOffDocumentItem(oDI);
- }
- }
-
- /**
- * End the document. Render any end document OffDocumentItems
- * {@inheritDoc}
- */
- @Override
- public void endDocument() throws SAXException {
- // render any pages that had unresolved ids
- checkPreparedPages(null, true);
-
- processOffDocumentItems(pendingODI);
- pendingODI.clear();
- processOffDocumentItems(endDocODI);
-
- try {
- renderer.stopRenderer();
- } catch (IOException ex) {
- throw new SAXException(ex);
- }
- }
-}
-
diff --git a/src/java/org/apache/fop/area/Resolvable.java b/src/java/org/apache/fop/area/Resolvable.java
deleted file mode 100644
index 3ab3ef309..000000000
--- a/src/java/org/apache/fop/area/Resolvable.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.util.List;
-
-/**
- * Resolvable Interface. Classes that implement this interface contain
- * idrefs (see Section 5.11 of spec for definition of <idref> datatype)
- * that are resolved when their target IDs are added to the area tree.
- */
-public interface Resolvable {
-
- /**
- * Check if this area has been resolved.
- *
- * @return true once this area is resolved
- */
- boolean isResolved();
-
- /**
- * Get the array of idrefs of this resolvable object.
- * If this object contains child resolvables that are
- * resolved through this then it should return the idref's of
- * the child also.
- *
- * @return the id references for resolving this object
- */
- String[] getIDRefs();
-
- /**
- * This method allows the Resolvable object to resolve one of
- * its unresolved idrefs with the actual set of PageViewports
- * containing the target ID. The Resolvable object initially
- * identifies to the AreaTreeHandler which idrefs it needs
- * resolved. After the idrefs are resolved, the ATH calls this
- * method to allow the Resolvable object to update itself with
- * the PageViewport information.
- *
- * @param id an ID matching one of the Resolvable object's
- * unresolved idref's.
- * @param pages the list of PageViewports with the given ID
- *
- */
- void resolveIDRef(String id, List<PageViewport> pages);
-}
diff --git a/src/java/org/apache/fop/area/SideFloat.java b/src/java/org/apache/fop/area/SideFloat.java
deleted file mode 100644
index af653efbf..000000000
--- a/src/java/org/apache/fop/area/SideFloat.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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;
-
-public class SideFloat extends Block {
-
- private static final long serialVersionUID = 2058594336594375047L;
-
- public SideFloat() {
- setAreaClass(Area.CLASS_SIDE_FLOAT);
- addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
- setPositioning(Block.ABSOLUTE);
- }
-}
diff --git a/src/java/org/apache/fop/area/Span.java b/src/java/org/apache/fop/area/Span.java
deleted file mode 100644
index e0f8633be..000000000
--- a/src/java/org/apache/fop/area/Span.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * 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.util.Iterator;
-import java.util.List;
-
-import org.apache.fop.fo.Constants;
-import org.apache.fop.traits.WritingModeTraitsGetter;
-
-/**
- * The span-reference-area.
- * This is a block-area with 0 border and padding that is stacked
- * within the main-reference-area
- * This object holds one or more normal-flow-reference-area children
- * based on the column-count trait in effect for this span.
- * See fo:region-body definition in the XSL Rec for more information.
- */
-public class Span extends Area {
-
- private static final long serialVersionUID = -5551430053660081549L;
-
- // the list of flow reference areas in this span area
- private List<NormalFlow> flowAreas;
- private int colCount;
- private int colGap;
- private int colWidth; // width for each normal flow, calculated value
- private int curFlowIdx; // n-f-r-a currently being processed, zero-based
-
- /**
- * Create a span area with the number of columns for this span area.
- *
- * @param colCount the number of columns in the span
- * @param colGap the column gap between each column
- * @param ipd the total ipd of the span
- */
- public Span(int colCount, int colGap, int ipd) {
- addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
- this.colCount = colCount;
- this.colGap = colGap;
- this.ipd = ipd;
- curFlowIdx = 0;
- createNormalFlows();
- }
-
- /**
- * Create the normal flows for this Span
- */
- private void createNormalFlows() {
- flowAreas = new java.util.ArrayList<NormalFlow>(colCount);
- colWidth = (ipd - ((colCount - 1) * colGap)) / colCount;
-
- for (int i = 0; i < colCount; i++) {
- NormalFlow newFlow = new NormalFlow(colWidth);
- flowAreas.add(newFlow);
- }
- }
-
- /**
- * Get the column count for this span area.
- *
- * @return the number of columns defined for this span area
- */
- public int getColumnCount() {
- return colCount;
- }
-
- /**
- * Get the width of a single column within this Span
- *
- * @return the width of a single column
- */
- public int getColumnWidth() {
- return colWidth;
- }
-
- /**
- * Get the height of this span area.
- *
- * @return the height of this span area
- */
- public int getHeight() {
- return getBPD();
- }
-
-
- /**
- * Get the normal flow area for a particular column.
- *
- * @param colRequested the zero-based column number of the flow
- * @return the flow area for the requested column
- */
- public NormalFlow getNormalFlow(int colRequested) {
- if (colRequested >= 0 && colRequested < colCount) {
- return flowAreas.get(colRequested);
- } else { // internal error
- throw new IllegalArgumentException("Invalid column number "
- + colRequested + " requested; only 0-" + (colCount - 1)
- + " available.");
- }
- }
-
- /**
- * Get the NormalFlow area currently being processed
- *
- * @return the current NormalFlow
- */
- public NormalFlow getCurrentFlow() {
- return getNormalFlow(curFlowIdx);
- }
-
- /** @return the index of the current normal flow */
- public int getCurrentFlowIndex() {
- return curFlowIdx;
- }
-
- /**
- * Indicate to the Span that the next column is being
- * processed.
- *
- * @return the new NormalFlow (in the next column)
- */
- public NormalFlow moveToNextFlow() {
- if (hasMoreFlows()) {
- curFlowIdx++;
- return getNormalFlow(curFlowIdx);
- } else {
- throw new IllegalStateException("(Internal error.) No more flows left in span.");
- }
- }
-
- /**
- * Indicates if the Span has unprocessed flows.
- *
- * @return true if Span can increment to the next flow,
- * false otherwise.
- */
- public boolean hasMoreFlows() {
- return (curFlowIdx < colCount - 1);
- }
-
- /**
- * Called to notify the span that all its flows have been fully generated so it can update
- * its own BPD extent.
- */
- public void notifyFlowsFinished() {
- int maxFlowBPD = Integer.MIN_VALUE;
- for (int i = 0; i < colCount; i++) {
- maxFlowBPD = Math.max(maxFlowBPD, getNormalFlow(i).getAllocBPD());
- }
- bpd = maxFlowBPD;
- }
-
- /**
- * Indicates whether any child areas have been added to this span area.
- *
- * This is achieved by looping through each flow.
- * @return true if no child areas have been added yet.
- */
- public boolean isEmpty() {
- int areaCount = 0;
- for (int i = 0; i < getColumnCount(); i++) {
- NormalFlow flow = getNormalFlow(i);
- if (flow != null) {
- if (flow.getChildAreas() != null) {
- areaCount += flow.getChildAreas().size();
- }
- }
- }
- return (areaCount == 0);
- }
-
- /**
- * Sets the writing mode traits for the main reference area of
- * this span area.
- * @param wmtg a WM traits getter
- */
- public void setWritingModeTraits(WritingModeTraitsGetter wmtg) {
- switch (wmtg.getColumnProgressionDirection().getEnumValue()) {
- case Constants.EN_RL:
- setBidiLevel(1);
- for (Iterator<NormalFlow> it = flowAreas.iterator(); it.hasNext();) {
- it.next().setBidiLevel(1);
- }
- break;
- default:
- resetBidiLevel();
- for (Iterator<NormalFlow> it = flowAreas.iterator(); it.hasNext();) {
- it.next().resetBidiLevel();
- }
- break;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer(super.toString());
- if (colCount > 1) {
- sb.append(" {colCount=").append(colCount);
- sb.append(", colWidth=").append(colWidth);
- sb.append(", curFlowIdx=").append(this.curFlowIdx);
- sb.append("}");
- }
- return sb.toString();
- }
-
-}
-
diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java
deleted file mode 100644
index 2d733022e..000000000
--- a/src/java/org/apache/fop/area/Trait.java
+++ /dev/null
@@ -1,689 +0,0 @@
-/*
- * 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.Color;
-import java.io.Serializable;
-
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-
-import org.apache.fop.fonts.FontTriplet;
-import org.apache.fop.traits.BorderProps;
-import org.apache.fop.traits.Direction;
-import org.apache.fop.traits.WritingMode;
-import org.apache.fop.util.ColorUtil;
-
-import static org.apache.fop.fo.Constants.EN_NOREPEAT;
-import static org.apache.fop.fo.Constants.EN_REPEAT;
-import static org.apache.fop.fo.Constants.EN_REPEATX;
-import static org.apache.fop.fo.Constants.EN_REPEATY;
-
-// properties should be serialized by the holder
-/**
- * Area traits used for rendering.
- * This class represents an area trait that specifies a value for rendering.
- */
-public final class Trait implements Serializable {
-
- private static final long serialVersionUID = 3234280285391611437L;
-
- private Trait() {
- }
-
- /** Id reference line, not resolved. (not sure if this is needed.) */
- //public static final Integer ID_LINK = new Integer(0);
-
- /**
- * Internal link trait.
- * Contains the PageViewport key and the PROD_ID of the target area
- */
- public static final Integer INTERNAL_LINK = 1;
-
- /** * External link. A URL link to an external resource. */
- public static final Integer EXTERNAL_LINK = 2;
-
- /** The font triplet for the current font. */
- public static final Integer FONT = 3;
-
- /** Font size for the current font. */
- public static final Integer FONT_SIZE = 4;
-
- /** The current color. */
- public static final Integer COLOR = 7;
-
- /** The ID of the FO that produced an area. */
- public static final Integer PROD_ID = 8;
-
- /** Background trait for an area. */
- public static final Integer BACKGROUND = 9;
-
- /** Underline trait used when rendering inline parent. */
- public static final Integer UNDERLINE = 10;
-
- /** Overline trait used when rendering inline parent. */
- public static final Integer OVERLINE = 11;
-
- /** Linethrough trait used when rendering inline parent. */
- public static final Integer LINETHROUGH = 12;
-
- /** Shadow offset. */
- //public static final Integer OFFSET = new Integer(13);
-
- /** The shadow for text. */
- //public static final Integer SHADOW = new Integer(14);
-
- /** The border start. */
- public static final Integer BORDER_START = 15;
-
- /** The border end. */
- public static final Integer BORDER_END = 16;
-
- /** The border before. */
- public static final Integer BORDER_BEFORE = 17;
-
- /** The border after. */
- public static final Integer BORDER_AFTER = 18;
-
- /** The padding start. */
- public static final Integer PADDING_START = 19;
-
- /** The padding end. */
- public static final Integer PADDING_END = 20;
-
- /** The padding before. */
- public static final Integer PADDING_BEFORE = 21;
-
- /** The padding after. */
- public static final Integer PADDING_AFTER = 22;
-
- /** The space start. */
- public static final Integer SPACE_START = 23;
-
- /** The space end. */
- public static final Integer SPACE_END = 24;
-
- /** break before */
- //public static final Integer BREAK_BEFORE = new Integer(25);
-
- /** break after */
- //public static final Integer BREAK_AFTER = new Integer(26);
-
- /** The start-indent trait. */
- public static final Integer START_INDENT = 27;
-
- /** The end-indent trait. */
- public static final Integer END_INDENT = 28;
-
- /** The space-before trait. */
- public static final Integer SPACE_BEFORE = 29;
-
- /** The space-after trait. */
- public static final Integer SPACE_AFTER = 30;
-
- /** The is-reference-area trait. */
- public static final Integer IS_REFERENCE_AREA = 31;
-
- /** The is-viewport-area trait. */
- public static final Integer IS_VIEWPORT_AREA = 32;
-
- /** Blinking trait used when rendering inline parent. */
- public static final Integer BLINK = 33;
-
- /** Trait for color of underline decorations when rendering inline parent. */
- public static final Integer UNDERLINE_COLOR = 34;
-
- /** Trait for color of overline decorations when rendering inline parent. */
- public static final Integer OVERLINE_COLOR = 35;
-
- /** Trait for color of linethrough decorations when rendering inline parent. */
- public static final Integer LINETHROUGH_COLOR = 36;
-
- /** For navigation in the document structure. */
- public static final Integer STRUCTURE_TREE_ELEMENT = 37;
-
- /** writing mode trait */
- public static final Integer WRITING_MODE = 38;
- /** inline progression direction trait */
- public static final Integer INLINE_PROGRESSION_DIRECTION = 39;
- /** block progression direction trait */
- public static final Integer BLOCK_PROGRESSION_DIRECTION = 40;
- /** column progression direction trait */
- public static final Integer COLUMN_PROGRESSION_DIRECTION = 41;
- /** shift direction trait */
- public static final Integer SHIFT_DIRECTION = 42;
-
- /** For optional content groups. */
- public static final Integer LAYER = 43;
-
- /** Maximum value used by trait keys */
- public static final int MAX_TRAIT_KEY = 43;
-
- private static final TraitInfo[] TRAIT_INFO = new TraitInfo[MAX_TRAIT_KEY + 1];
-
- private static class TraitInfo {
- private String name;
- private Class clazz; // Class of trait data
-
- public TraitInfo(String name, Class clazz) {
- this.name = name;
- this.clazz = clazz;
- }
-
- public String getName() {
- return this.name;
- }
-
- public Class getClazz() {
- return this.clazz;
- }
- }
-
- private static void put(Integer key, TraitInfo info) {
- TRAIT_INFO[key] = info;
- }
-
- static {
- // Create a hashmap mapping trait code to name for external representation
- //put(ID_LINK, new TraitInfo("id-link", String.class));
- put(STRUCTURE_TREE_ELEMENT, new TraitInfo("structure-tree-element", String.class));
- put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class));
- put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class));
- put(FONT, new TraitInfo("font", FontTriplet.class));
- put(FONT_SIZE, new TraitInfo("font-size", Integer.class));
- put(COLOR, new TraitInfo("color", Color.class));
- put(PROD_ID, new TraitInfo("prod-id", String.class));
- put(BACKGROUND, new TraitInfo("background", Background.class));
- put(UNDERLINE, new TraitInfo("underline-score", Boolean.class));
- put(UNDERLINE_COLOR, new TraitInfo("underline-score-color", Color.class));
- put(OVERLINE, new TraitInfo("overline-score", Boolean.class));
- put(OVERLINE_COLOR, new TraitInfo("overline-score-color", Color.class));
- put(LINETHROUGH, new TraitInfo("through-score", Boolean.class));
- put(LINETHROUGH_COLOR, new TraitInfo("through-score-color", Color.class));
- put(BLINK, new TraitInfo("blink", Boolean.class));
- //put(OFFSET, new TraitInfo("offset", Integer.class));
- //put(SHADOW, new TraitInfo("shadow", Integer.class));
- put(BORDER_START, new TraitInfo("border-start", BorderProps.class));
- put(BORDER_END, new TraitInfo("border-end", BorderProps.class));
- put(BORDER_BEFORE, new TraitInfo("border-before", BorderProps.class));
- put(BORDER_AFTER, new TraitInfo("border-after", BorderProps.class));
- put(PADDING_START, new TraitInfo("padding-start", Integer.class));
- put(PADDING_END, new TraitInfo("padding-end", Integer.class));
- put(PADDING_BEFORE, new TraitInfo("padding-before", Integer.class));
- put(PADDING_AFTER, new TraitInfo("padding-after", Integer.class));
- put(SPACE_START, new TraitInfo("space-start", Integer.class));
- put(SPACE_END, new TraitInfo("space-end", Integer.class));
- //put(BREAK_BEFORE, new TraitInfo("break-before", Integer.class));
- //put(BREAK_AFTER, new TraitInfo("break-after", Integer.class));
- put(START_INDENT, new TraitInfo("start-indent", Integer.class));
- put(END_INDENT, new TraitInfo("end-indent", Integer.class));
- put(SPACE_BEFORE, new TraitInfo("space-before", Integer.class));
- put(SPACE_AFTER, new TraitInfo("space-after", Integer.class));
- put(IS_REFERENCE_AREA, new TraitInfo("is-reference-area", Boolean.class));
- put(IS_VIEWPORT_AREA, new TraitInfo("is-viewport-area", Boolean.class));
- put(WRITING_MODE,
- new TraitInfo("writing-mode", WritingMode.class));
- put(INLINE_PROGRESSION_DIRECTION,
- new TraitInfo("inline-progression-direction", Direction.class));
- put(BLOCK_PROGRESSION_DIRECTION,
- new TraitInfo("block-progression-direction", Direction.class));
- put(SHIFT_DIRECTION,
- new TraitInfo("shift-direction", Direction.class));
- put(LAYER, new TraitInfo("layer", String.class));
-
- }
-
- /**
- * Get the trait name for a trait code.
- *
- * @param traitCode the trait code to get the name for
- * @return the trait name
- */
- public static String getTraitName(Object traitCode) {
- return TRAIT_INFO[(Integer)traitCode].getName();
- }
-
- /**
- * Get the data storage class for the trait.
- *
- * @param traitCode the trait code to lookup
- * @return the class type for the trait
- */
- public static Class getTraitClass(Object traitCode) {
- return TRAIT_INFO[(Integer)traitCode].getClazz();
- }
-
- /**
- * Class for internal link traits.
- * Stores PageViewport key and producer ID
- */
- public static class InternalLink implements Serializable {
-
- private static final long serialVersionUID = -8993505060996723039L;
-
- /** The unique key of the PageViewport. */
- private String pvKey;
-
- /** The PROD_ID of the link target */
- private String idRef;
-
- /**
- * Create an InternalLink to the given PageViewport and target ID
- *
- * @param pvKey the PageViewport key
- * @param idRef the target ID
- */
- public InternalLink(String pvKey, String idRef) {
- setPVKey(pvKey);
- setIDRef(idRef);
- }
-
- /**
- * Create an InternalLink based on the given XML attribute value.
- * This is typically called when data are read from an XML area tree.
- *
- * @param attrValue attribute value to be parsed by InternalLink.parseXMLAttribute
- */
- public InternalLink(String attrValue) {
- String[] values = parseXMLAttribute(attrValue);
- setPVKey(values[0]);
- setIDRef(values[1]);
- }
-
- /**
- * Sets the key of the targeted PageViewport.
- *
- * @param pvKey the PageViewport key
- */
- public void setPVKey(String pvKey) {
- this.pvKey = pvKey;
- }
-
- /**
- * Returns the key of the targeted PageViewport.
- *
- * @return the PageViewport key
- */
- public String getPVKey() {
- return pvKey;
- }
-
- /**
- * Sets the target ID.
- *
- * @param idRef the target ID
- */
- public void setIDRef(String idRef) {
- this.idRef = idRef;
- }
-
- /**
- * Returns the target ID.
- *
- * @return the target ID
- */
- public String getIDRef() {
- return idRef;
- }
-
- /**
- * Returns the attribute value for this object as
- * used in the area tree XML.
- *
- * @return a string of the type "(thisPVKey,thisIDRef)"
- */
- public String xmlAttribute() {
- return makeXMLAttribute(pvKey, idRef);
- }
-
- /**
- * Returns the XML attribute value for the given PV key and ID ref.
- * This value is used in the area tree XML.
- *
- * @param pvKey the PageViewport key of the link target
- * @param idRef the ID of the link target
- * @return a string of the type "(thisPVKey,thisIDRef)"
- */
- public static String makeXMLAttribute(String pvKey, String idRef) {
- return "(" + (pvKey == null ? "" : pvKey) + ","
- + (idRef == null ? "" : idRef) + ")";
- }
-
- /**
- * Parses XML attribute value from the area tree into
- * PageViewport key + IDRef strings. If the attribute value is
- * formatted like "(s1,s2)", then s1 and s2 are considered to be
- * the PV key and the IDRef, respectively.
- * Otherwise, the entire string is the PV key and the IDRef is null.
- *
- * @param attrValue the atribute value (PV key and possibly IDRef)
- * @return a 2-String array containing the PV key and the IDRef.
- * Both may be null.
- */
- public static String[] parseXMLAttribute(String attrValue) {
- String[] result = {null, null};
- if (attrValue != null) {
- int len = attrValue.length();
- if (len >= 2 && attrValue.charAt(0) == '(' && attrValue.charAt(len - 1) == ')'
- && attrValue.indexOf(',') != -1) {
- String value = attrValue.substring(1, len - 1); // remove brackets
- int delimIndex = value.indexOf(',');
- result[0] = value.substring(0, delimIndex).trim(); // PV key
- result[1] = value.substring(delimIndex + 1, value.length()).trim(); // IDRef
- } else {
- // PV key only, e.g. from old area tree XML:
- result[0] = attrValue;
- }
- }
- return result;
- }
-
- /**
- * Return the human-friendly string for debugging.
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("pvKey=").append(pvKey);
- sb.append(",idRef=").append(idRef);
- return sb.toString();
- }
- }
-
- /**
- * External Link trait structure
- */
- public static class ExternalLink implements Serializable {
-
- private static final long serialVersionUID = -3720707599232620946L;
-
- private String destination;
- private boolean newWindow;
-
- /**
- * Constructs an ExternalLink object with the given destination
- *
- * @param destination target of the link
- * @param newWindow true if the target should be opened in a new window
- */
- public ExternalLink(String destination, boolean newWindow) {
- this.destination = destination;
- this.newWindow = newWindow;
- }
-
- /**
- * Create an <code>ExternalLink</code> from a trait value/attribute value in the
- * area tree
- * @param traitValue the value to use (should match the result of {@link #toString()}
- * @return an <code>ExternalLink</code> instance corresponding to the given value
- */
- protected static ExternalLink makeFromTraitValue(String traitValue) {
- String dest = null;
- boolean newWindow = false;
- String[] values = traitValue.split(",");
- for (int i = 0, c = values.length; i < c; i++) {
- String v = values[i];
- if (v.startsWith("dest=")) {
- dest = v.substring(5);
- } else if (v.startsWith("newWindow=")) {
- newWindow = Boolean.valueOf(v.substring(10));
- } else {
- throw new IllegalArgumentException(
- "Malformed trait value for Trait.ExternalLink: " + traitValue);
- }
- }
- return new ExternalLink(dest, newWindow);
- }
-
- /**
- * Get the target/destination of the link
- * @return the destination of the link
- */
- public String getDestination() {
- return this.destination;
- }
-
- /**
- * Check if the target has to be displayed in a new window
- * @return <code>true</code> if the target has to be displayed in a new window
- */
- public boolean newWindow() {
- return this.newWindow;
- }
-
- /**
- * Return a String representation of the object.
- * @return a <code>String</code> of the form
- * "org.apache.fop.area.Trait.ExternalLink[dest=someURL,newWindow=false]"
- */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer(64);
- sb.append("newWindow=").append(newWindow);
- sb.append(",dest=").append(this.destination);
- return sb.toString();
- }
- }
-
- /**
- * Background trait structure.
- * Used for storing back trait information which are related.
- */
- public static class Background implements Serializable {
-
- private static final long serialVersionUID = 8452078676273242870L;
-
- /** The background color if any. */
- private Color color;
-
- /** The background image url if any. */
- private String url;
-
- /** The background image if any. */
- private ImageInfo imageInfo;
-
- /** Background repeat enum for images. */
- private int repeat;
-
- /** Background horizontal offset for images. */
- private int horiz;
-
- /** Background vertical offset for images. */
- private int vertical;
-
- private int imageTargetWidth;
-
- private int imageTargetHeight;
-
- /**
- * Returns the background color.
- * @return background color, null if n/a
- */
- public Color getColor() {
- return color;
- }
-
- /**
- * Returns the horizontal offset for images.
- * @return the horizontal offset
- */
- public int getHoriz() {
- return horiz;
- }
-
- /**
- * Returns the image repetition behaviour for images.
- * @return the image repetition behaviour
- */
- public int getRepeat() {
- return repeat;
- }
-
- /**
- * Returns the URL to the background image
- * @return URL to the background image, null if n/a
- */
- public String getURL() {
- return url;
- }
-
- /**
- * Returns the ImageInfo object representing the background image
- * @return the background image, null if n/a
- */
- public ImageInfo getImageInfo() {
- return imageInfo;
- }
-
- /**
- * Returns the vertical offset for images.
- * @return the vertical offset
- */
- public int getVertical() {
- return vertical;
- }
-
- /**
- * Sets the color.
- * @param color The color to set
- */
- public void setColor(Color color) {
- this.color = color;
- }
-
- /**
- * Sets the horizontal offset.
- * @param horiz The horizontal offset to set
- */
- public void setHoriz(int horiz) {
- this.horiz = horiz;
- }
-
- /**
- * Sets the image repetition behaviour for images.
- * @param repeat The image repetition behaviour to set
- */
- public void setRepeat(int repeat) {
- this.repeat = repeat;
- }
-
- /**
- * Sets the image repetition behaviour for images.
- * @param repeat The image repetition behaviour to set
- */
- public void setRepeat(String repeat) {
- setRepeat(getConstantForRepeat(repeat));
- }
-
- /**
- * Sets the URL to the background image.
- * @param url The URL to set
- */
- public void setURL(String url) {
- this.url = url;
- }
-
- /**
- * Sets the ImageInfo of the image to use as the background image.
- * @param info The background image's info object
- */
- public void setImageInfo(ImageInfo info) {
- this.imageInfo = info;
- }
-
- /**
- * Sets the vertical offset for images.
- * @param vertical The vertical offset to set
- */
- public void setVertical(int vertical) {
- this.vertical = vertical;
- }
-
- private String getRepeatString() {
- switch (getRepeat()) {
- case EN_REPEAT: return "repeat";
- case EN_REPEATX: return "repeat-x";
- case EN_REPEATY: return "repeat-y";
- case EN_NOREPEAT: return "no-repeat";
- default: throw new IllegalStateException("Illegal repeat style: " + getRepeat());
- }
- }
-
- private static int getConstantForRepeat(String repeat) {
- if ("repeat".equalsIgnoreCase(repeat)) {
- return EN_REPEAT;
- } else if ("repeat-x".equalsIgnoreCase(repeat)) {
- return EN_REPEATX;
- } else if ("repeat-y".equalsIgnoreCase(repeat)) {
- return EN_REPEATY;
- } else if ("no-repeat".equalsIgnoreCase(repeat)) {
- return EN_NOREPEAT;
- } else {
- throw new IllegalStateException("Illegal repeat style: " + repeat);
- }
- }
-
- /**
- * Return the string for debugging.
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- if (color != null) {
- sb.append("color=").append(ColorUtil.colorToString(color));
- }
- if (url != null) {
- if (color != null) {
- sb.append(",");
- }
- sb.append("url=").append(url);
- sb.append(",repeat=").append(getRepeatString());
- sb.append(",horiz=").append(horiz);
- sb.append(",vertical=").append(vertical);
- }
- if (imageTargetWidth != 0) {
- sb.append(",target-width=").append(Integer.toString(imageTargetWidth));
- }
- if (imageTargetHeight != 0) {
- sb.append(",target-height=").append(Integer.toString(imageTargetHeight));
- }
- return sb.toString();
- }
-
- public void setImageTargetWidth(int value) {
- imageTargetWidth = value;
- }
-
- public int getImageTargetWidth() {
- return imageTargetWidth;
- }
-
- public void setImageTargetHeight(int value) {
- imageTargetHeight = value;
- }
-
- public int getImageTargetHeight() {
- return imageTargetHeight;
- }
-
- }
-}
-
diff --git a/src/java/org/apache/fop/area/Viewport.java b/src/java/org/apache/fop/area/Viewport.java
deleted file mode 100644
index a92d826cc..000000000
--- a/src/java/org/apache/fop/area/Viewport.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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/AbstractTextArea.java b/src/java/org/apache/fop/area/inline/AbstractTextArea.java
deleted file mode 100644
index c2c4fe67b..000000000
--- a/src/java/org/apache/fop/area/inline/AbstractTextArea.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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;
-
-/**
- * Abstract base class for both TextArea and Character.
- */
-public abstract class AbstractTextArea extends InlineParent {
-
- private static final long serialVersionUID = -1246306443569094371L;
-
- /**
- * this class stores information about spaces and potential adjustments
- * that can be used in order to re-compute adjustments when a
- * page-number or a page-number-citation is resolved
- */
- // @SuppressFBWarnings("SE_INNER_CLASS")
- protected class TextAdjustingInfo extends InlineAdjustingInfo {
-
- private static final long serialVersionUID = -2412095162983479947L;
-
- /** difference between the optimal width of a space
- * and the default width of a space according to the font
- * (this is equivalent to the property word-spacing.optimum)
- */
- protected int spaceDifference;
-
- /**
- * Constructor
- *
- * @param stretch the available space for stretching
- * @param shrink the available space for shrinking
- * @param adj space adjustment type
- */
- protected TextAdjustingInfo(int stretch, int shrink, int adj) {
- super(stretch, shrink, adj);
- }
- }
-
- private int textWordSpaceAdjust;
- private int textLetterSpaceAdjust;
- private TextAdjustingInfo textAdjustingInfo;
- private int baselineOffset;
-
- /**
- * Default constructor
- */
- public AbstractTextArea() {
- }
-
- /**
- * Constructor with extra parameters:
- * create a TextAdjustingInfo object
- * @param stretch the available stretch of the text
- * @param shrink the available shrink of the text
- * @param adj the current adjustment of the area
- */
- public AbstractTextArea(int stretch, int shrink, int adj) {
- textAdjustingInfo = new TextAdjustingInfo(stretch, shrink, adj);
- }
-
- /**
- * Get text word space adjust.
- *
- * @return the text word space adjustment
- */
- public int getTextWordSpaceAdjust() {
- return textWordSpaceAdjust;
- }
-
- /**
- * Set text word space adjust.
- *
- * @param textWordSpaceAdjust the text word space adjustment
- */
- public void setTextWordSpaceAdjust(int textWordSpaceAdjust) {
- this.textWordSpaceAdjust = textWordSpaceAdjust;
- }
-
- /**
- * Get text letter space adjust.
- *
- * @return the text letter space adjustment
- */
- public int getTextLetterSpaceAdjust() {
- return textLetterSpaceAdjust;
- }
-
- /**
- * Set text letter space adjust.
- *
- * @param textLetterSpaceAdjust the text letter space adjustment
- */
- public void setTextLetterSpaceAdjust(int textLetterSpaceAdjust) {
- this.textLetterSpaceAdjust = textLetterSpaceAdjust;
- }
-
- /**
- * Set the difference between optimal width of a space and
- * default width of a space according to the font; this part
- * of the space adjustment is fixed and must not be
- * multiplied by the variation factor.
- * @param spaceDiff the space difference
- */
- public void setSpaceDifference(int spaceDiff) {
- textAdjustingInfo.spaceDifference = spaceDiff;
- }
-
- /**
- * recursively apply the variation factor to all descendant areas
- * @param variationFactor the variation factor that must be applied to adjustments
- * @param lineStretch the total stretch of the line
- * @param lineShrink the total shrink of the line
- * @return true if there is an UnresolvedArea descendant
- */
- public boolean applyVariationFactor(double variationFactor,
- int lineStretch, int lineShrink) {
- if (textAdjustingInfo != null) {
- // compute the new adjustments:
- // if the variation factor is negative, it means that before
- // the ipd variation the line had to stretch and now it has
- // to shrink (or vice versa);
- // in this case, if the stretch and shrink are not equally
- // divided among the inline areas, we must compute a
- // balancing factor
- double balancingFactor = 1.0;
- if (variationFactor < 0) {
- if (textWordSpaceAdjust < 0) {
- // from a negative adjustment to a positive one
- balancingFactor
- = ((double) textAdjustingInfo.availableStretch
- / textAdjustingInfo.availableShrink)
- * ((double) lineShrink / lineStretch);
- } else {
- // from a positive adjustment to a negative one
- balancingFactor
- = ((double) textAdjustingInfo.availableShrink
- / textAdjustingInfo.availableStretch)
- * ((double) lineStretch / lineShrink);
- }
- }
- textWordSpaceAdjust = (int) ((textWordSpaceAdjust - textAdjustingInfo.spaceDifference)
- * variationFactor * balancingFactor)
- + textAdjustingInfo.spaceDifference;
- textLetterSpaceAdjust *= variationFactor;
- // update the ipd of the area
- int oldAdjustment = textAdjustingInfo.adjustment;
- textAdjustingInfo.adjustment *= balancingFactor * variationFactor;
- ipd += textAdjustingInfo.adjustment - oldAdjustment;
- }
- return false;
- }
-
- /**
- * Get baseline offset, i.e. the distance from the before edge
- * of this area to the nominal baseline.
- *
- * @return the baseline offset
- */
- public int getBaselineOffset() {
- return baselineOffset;
- }
-
- /**
- * Set the baseline offset.
- *
- * @param baselineOffset the baseline offset
- */
- public void setBaselineOffset(int baselineOffset) {
- this.baselineOffset = baselineOffset;
- }
-
- @Override
- int getVirtualOffset() {
- return getBlockProgressionOffset();
- }
-
- @Override
- int getVirtualBPD() {
- /* Word and space areas don't have a properly set bpd; return this area's bpd instead. */
- return getBPD();
- }
-}
diff --git a/src/java/org/apache/fop/area/inline/Anchor.java b/src/java/org/apache/fop/area/inline/Anchor.java
deleted file mode 100644
index 8ad663111..000000000
--- a/src/java/org/apache/fop/area/inline/Anchor.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-/**
- * Anchor area for footnote or float.
- * Not sure if this is needed.
- */
-public class Anchor extends InlineArea {
-
- private static final long serialVersionUID = 5227798744787823499L;
-
- // has a keep with adjacent area
- // has reference to associated footnote or float out-of-line area
-
-}
-
diff --git a/src/java/org/apache/fop/area/inline/BasicLinkArea.java b/src/java/org/apache/fop/area/inline/BasicLinkArea.java
deleted file mode 100644
index 68af92319..000000000
--- a/src/java/org/apache/fop/area/inline/BasicLinkArea.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.Area;
-import org.apache.fop.area.LinkResolver;
-
-/**
- * An inline area produced by an fo:basic-link element. This class implements a different
- * behavior to what is prescribed by the XSL-FO 1.1 Recommendation. With the standard
- * behavior, there is no easy way to make a link cover e.g. a whole image.
- *
- * <p>See following bug report at W3C's:
- * http://www.w3.org/Bugs/Public/show_bug.cgi?id=11672</p>
- */
-public class BasicLinkArea extends InlineParent {
-
- private static final long serialVersionUID = 5183753430412208151L;
-
- private LinkResolver resolver;
-
- @Override
- public void setParentArea(Area parentArea) {
- super.setParentArea(parentArea);
- /*
- * Perform necessary modifications to make this area encompass all of its children
- * elements, so as to have a useful active area. We assume that this method is
- * called after all of the children areas have been added to this area.
- */
- /* Make this area start at its beforest child. */
- setBlockProgressionOffset(getBlockProgressionOffset() + minChildOffset);
- /* Update children offsets accordingly. */
- for (InlineArea inline : inlines) {
- inline.setBlockProgressionOffset(inline.getBlockProgressionOffset() - minChildOffset);
- }
- setBPD(getVirtualBPD());
- }
-
- /**
- * Establish (or remove) back-pointer to link resolver.
- * @param resolver the link resolver that will resolve this basic link or null
- */
- public void setResolver(LinkResolver resolver) {
- assert (resolver == null) || (this.resolver == null);
- this.resolver = resolver;
- }
-
- /**
- * Obtain back-pointer to link resolver.
- * @return resolver the link resolver that will resolve this basic link or null
- */
- public LinkResolver getResolver() {
- return this.resolver;
- }
-}
diff --git a/src/java/org/apache/fop/area/inline/Container.java b/src/java/org/apache/fop/area/inline/Container.java
deleted file mode 100644
index 3d0060007..000000000
--- a/src/java/org/apache/fop/area/inline/Container.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.List;
-
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
-
-/**
- * Container area for inline container.
- * This area should be placed in a viewport as a result of the
- * inline container formatting object.
- * This allows an inline area to have blocks as children.
- */
-public class Container extends Area {
-
- private static final long serialVersionUID = 5256423939348189260L;
-
- /**
- * The list of block areas stacked inside this container
- */
- protected List<Block> blocks = new ArrayList<Block>();
-
- /**
- * The width of this container
- */
- protected int width;
-
- /**
- * Create a new container area
- */
- public Container() {
- }
-
- @Override
- public void addChildArea(Area child) {
- if (!(child instanceof Block)) {
- throw new IllegalArgumentException("Container only accepts block areas");
- }
- blocks.add((Block) child);
- }
-
- /**
- * Get the block areas stacked inside this container area.
- *
- * @return the list of block areas
- */
- public List<Block> getBlocks() {
- return blocks;
- }
-
- /**
- * Get the width of this container area.
- *
- * @return the width
- */
- public int getWidth() {
- return width;
- }
-}
-
diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java
deleted file mode 100644
index 786b0265d..000000000
--- a/src/java/org/apache/fop/area/inline/FilledArea.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.List;
-
-/**
- * Filled area.
- * This inline area contains some inline areas.
- * When the renderer gets the child areas to render
- * the inline areas are repeated to fill the ipd of
- * this inline parent.
- * This extends InlineParent so that the renderer will render
- * this as a normal inline parent.
- */
-public class FilledArea extends InlineParent {
-
- private static final long serialVersionUID = 8586584705587017474L;
-
- private int unitWidth;
-
- /** Create a new filled area. */
- public FilledArea() {
- }
-
- /**
- * Set the offset of the descendant TextAreas,
- * instead of the offset of the FilledArea itself.
- *
- * @param v the offset
- */
- /*
- public void setBlockProgressionOffset(int v) {
- setChildOffset(inlines.listIterator(), v);
- }
-
- private void setChildOffset(ListIterator childrenIterator, int v) {
- while (childrenIterator.hasNext()) {
- InlineArea child = (InlineArea) childrenIterator.next();
- if (child instanceof InlineParent) {
- setChildOffset(((InlineParent) child).getChildAreas().listIterator(), v);
- } else if (child instanceof InlineViewport) {
- // nothing
- } else {
- child.setBlockProgressionOffset(v);
- }
- }
- }
- */
-
- /**
- * Set the unit width for the areas to fill the full width.
- *
- * @param width the unit width
- */
- public void setUnitWidth(int width) {
- this.unitWidth = width;
- }
-
- /**
- * Return the unit width for the areas to fill the full width.
- *
- * @return the unit width
- */
- public int getUnitWidth() {
- return this.unitWidth;
- }
-
- /** {@inheritDoc} */
- @Override
- public int getBPD() {
- int bpd = 0;
- for (InlineArea area : getChildAreas()) {
- if (bpd < area.getBPD()) {
- bpd = area.getBPD();
- }
- }
- return bpd;
- }
-
- /**
- * Get the child areas for this filled area.
- * This copies the references of the inline areas so that
- * it fills the total width of the area a whole number of times
- * for the unit width.
- *
- * @return the list of child areas copied to fill the width
- */
- @Override
- public List<InlineArea> getChildAreas() {
- int units = getIPD() / unitWidth;
- List<InlineArea> newList = new ArrayList<InlineArea>();
- for (int count = 0; count < units; count++) {
- newList.addAll(inlines);
- }
- return newList;
- }
-
- /**
- * Recursively apply the variation factor to all descendant areas
- * @param variationFactor the variation factor that must be applied to adjustments
- * @param lineStretch the total stretch of the line
- * @param lineShrink the total shrink of the line
- * @return true if there is an UnresolvedArea descendant
- */
- @Override
- public boolean applyVariationFactor(double variationFactor,
- int lineStretch, int lineShrink) {
- setIPD(getIPD() + adjustingInfo.applyVariationFactor(variationFactor));
- return false;
- }
-
-}
-
diff --git a/src/java/org/apache/fop/area/inline/ForeignObject.java b/src/java/org/apache/fop/area/inline/ForeignObject.java
deleted file mode 100644
index cc0e0b0ad..000000000
--- a/src/java/org/apache/fop/area/inline/ForeignObject.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.w3c.dom.Document;
-
-import org.apache.fop.area.Area;
-
-// cacheable object
-/**
- * Foreign object inline area.
- * This inline area represents an instream-foreign object.
- * This holds an xml document and the associated namespace.
- */
-public class ForeignObject extends Area {
-
- private static final long serialVersionUID = -214947698798577885L;
-
- private Document doc;
- private String namespace;
-
- /**
- * Create a new foreign object with the given dom and namespace.
- *
- * @param d the xml document
- * @param ns the namespace of the document
- */
- public ForeignObject(Document d, String ns) {
- doc = d;
- namespace = ns;
- }
-
- /**
- * Create a new empty foreign object for which the DOM Document will be set later.
- *
- * @param ns the namespace of the document
- */
- public ForeignObject(String ns) {
- namespace = ns;
- }
-
- /**
- * Sets the DOM document for this foreign object.
- * @param document the DOM document
- */
- public void setDocument(Document document) {
- this.doc = document;
- }
-
- /**
- * Get the document for this foreign object.
- *
- * @return the xml document
- */
- public Document getDocument() {
- return doc;
- }
-
- /**
- * Get the namespace of this foreign object.
- *
- * @return the namespace of this document
- */
- public String getNameSpace() {
- return namespace;
- }
-}
-
diff --git a/src/java/org/apache/fop/area/inline/Image.java b/src/java/org/apache/fop/area/inline/Image.java
deleted file mode 100644
index e6e355254..000000000
--- a/src/java/org/apache/fop/area/inline/Image.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.Area;
-
-/**
- * Image area for external-graphic.
- * This area holds information for rendering an image.
- * The url of the image is used as a key to reference the image cache.
- */
-public class Image extends Area {
-
- private static final long serialVersionUID = 4800834714349695386L;
-
- private String url;
-
- /**
- * Create a new image with the given url.
- *
- * @param url the url of the image
- */
- public Image(String url) {
- this.url = url;
- }
-
- /**
- * Get the url of this image.
- * This url is used as a key to locate the actual image data.
- *
- * @return the url of this image
- */
- public String getURL() {
- return this.url;
- }
-}
-
diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java
deleted file mode 100644
index 1733f7b3d..000000000
--- a/src/java/org/apache/fop/area/inline/InlineArea.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * 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 java.io.Serializable;
-import java.util.List;
-
-import org.apache.fop.area.Area;
-import org.apache.fop.area.LineArea;
-import org.apache.fop.area.Trait;
-import org.apache.fop.complexscripts.bidi.InlineRun;
-
-/**
- * Inline Area
- * This area is for all inline areas that can be placed
- * in a line area.
- */
-public class InlineArea extends Area {
-
- private static final long serialVersionUID = -8940066479810170980L;
-
- /**
- * this class stores information about potential adjustments
- * that can be used in order to re-compute adjustments when a
- * page-number or a page-number-citation is resolved
- */
- // @SuppressFBWarnings("SE_INNER_CLASS")
- protected class InlineAdjustingInfo implements Serializable {
-
- private static final long serialVersionUID = -5601387735459712149L;
-
- /** stretch of the inline area */
- protected int availableStretch;
- /** shrink of the inline area */
- protected int availableShrink;
- /** total adjustment (= ipd - width of fixed elements) */
- protected int adjustment;
-
- /**
- * Constructor
- *
- * @param stretch the available space for stretching
- * @param shrink the available space for shrinking
- * @param adj space adjustment type
- */
- protected InlineAdjustingInfo(int stretch, int shrink, int adj) {
- availableStretch = stretch;
- availableShrink = shrink;
- adjustment = adj;
- }
-
- /**
- * Apply the variation factor
- *
- * @param variationFactor the factor by which the adjustment is to be changed
- * @return the IPD increase
- */
- protected int applyVariationFactor(double variationFactor) {
- int oldAdjustment = adjustment;
- adjustment *= variationFactor;
- return adjustment - oldAdjustment;
- }
- }
-
- /**
- * offset position from before edge of parent area
- */
- protected int blockProgressionOffset;
-
- /**
- * parent area
- * it is needed in order to recompute adjust ratio and indents
- * when a page-number or a page-number-citation is resolved
- */
- private Area parentArea;
-
- /**
- * ipd variation of child areas: if this area has not already
- * been added and cannot notify its parent area, store the variation
- * and wait for the parent area to be set
- */
- private int storedIPDVariation;
-
- /**
- * The adjustment information object
- */
- protected InlineAdjustingInfo adjustingInfo;
-
- /**
- * Default constructor for inline area.
- */
- public InlineArea() {
- this (0, -1);
- }
-
- /**
- * Instantiate inline area.
- * @param blockProgressionOffset a block progression offset or zero
- * @param bidiLevel a resolved bidi level or -1
- */
- protected InlineArea(int blockProgressionOffset, int bidiLevel) {
- this.blockProgressionOffset = blockProgressionOffset;
- setBidiLevel(bidiLevel);
- }
-
- /**
- * @return the adjustment information object
- */
- public InlineAdjustingInfo getAdjustingInfo() {
- return adjustingInfo;
- }
-
- /**
- * Create a new adjustment information object
- * @param stretch the available space for stretching
- * @param shrink the available space for shrinking
- * @param adjustment space adjustment type
- */
- public void setAdjustingInfo(int stretch, int shrink, int adjustment) {
- adjustingInfo = new InlineAdjustingInfo(stretch, shrink, adjustment);
- }
-
- /**
- * Sets the adjustment information from an existing object
- * @param adjustingInfo the existing adjustment object
- */
- public void setAdjustingInfo(InlineAdjustingInfo adjustingInfo) {
- this.adjustingInfo = adjustingInfo;
- }
-
- /**
- * Modify the adjustment value in the adjustment information object
- * @param adjustment the new adjustment value
- */
- public void setAdjustment(int adjustment) {
- if (adjustingInfo != null) {
- adjustingInfo.adjustment = adjustment;
- }
- }
-
- /**
- * Increase the inline progression dimensions of this area.
- * This is used for inline parent areas that contain mulitple child areas.
- *
- * @param ipd the inline progression to increase by
- */
- public void increaseIPD(int ipd) {
- this.ipd += ipd;
- }
-
- /**
- * Set the block progression offset of this inline area.
- * This is used to set the offset of the inline area
- * which is relative to the before edge of the parent area.
- *
- * @param blockProgressionOffset the offset
- */
- public void setBlockProgressionOffset(int blockProgressionOffset) {
- this.blockProgressionOffset = blockProgressionOffset;
- }
-
- /**
- * Get the block progression offset of this inline area.
- * This returns the offset of the inline area
- * relative to the before edge of the parent area.
- *
- * @return the blockProgressionOffset
- */
- public int getBlockProgressionOffset() {
- return blockProgressionOffset;
- }
-
- /**
- * @param parentArea The parentArea to set.
- */
- public void setParentArea(Area parentArea) {
- this.parentArea = parentArea;
- }
-
- /**
- * @return Returns the parentArea.
- */
- public Area getParentArea() {
- return parentArea;
- }
-
- /**
- * Set the parent for the child area.
- *
- * {@inheritDoc}
- */
- @Override
- public void addChildArea(Area childArea) {
- super.addChildArea(childArea);
- if (childArea instanceof InlineArea) {
- ((InlineArea) childArea).setParentArea(this);
- }
- }
-
- /** @return true if the inline area is underlined. */
- public boolean hasUnderline() {
- return getTraitAsBoolean(Trait.UNDERLINE);
- }
-
- /** @return true if the inline area is overlined. */
- public boolean hasOverline() {
- return getTraitAsBoolean(Trait.OVERLINE);
- }
-
- /** @return true if the inline area has a line through. */
- public boolean hasLineThrough() {
- return getTraitAsBoolean(Trait.LINETHROUGH);
- }
-
- /** @return true if the inline area is blinking. */
- public boolean isBlinking() {
- return getTraitAsBoolean(Trait.BLINK);
- }
-
- /**
- * recursively apply the variation factor to all descendant areas
- * @param variationFactor the variation factor that must be applied to adjustments
- * @param lineStretch the total stretch of the line
- * @param lineShrink the total shrink of the line
- * @return true if there is an UnresolvedArea descendant
- */
- public boolean applyVariationFactor(double variationFactor,
- int lineStretch, int lineShrink) {
- // default behaviour: update the IPD and return false
- if (adjustingInfo != null) {
- setIPD(getIPD() + adjustingInfo.applyVariationFactor(variationFactor));
- }
- return false;
- }
-
- /**
- * Apply IPD variation.
- * @param ipdVariation the variation
- */
- public void handleIPDVariation(int ipdVariation) {
- if (log.isTraceEnabled()) {
- log.trace("Handling IPD variation for " + getClass().getSimpleName()
- + ": increase by " + ipdVariation + " mpt.");
- }
-
- if (ipdVariation != 0) {
- increaseIPD(ipdVariation);
- notifyIPDVariation(ipdVariation);
- }
- }
-
- /**
- * notify the parent area about the ipd variation of this area
- * or of a descendant area
- * @param ipdVariation the difference between new and old ipd
- */
- protected void notifyIPDVariation(int ipdVariation) {
- Area parentArea = getParentArea();
- if (parentArea instanceof InlineArea) {
- ((InlineArea) parentArea).handleIPDVariation(ipdVariation);
- } else if (parentArea instanceof LineArea) {
- ((LineArea) parentArea).handleIPDVariation(ipdVariation);
- } else if (parentArea == null) {
- // parent area not yet set: store the variations
- storedIPDVariation += ipdVariation;
- }
- }
-
- /**
- * Returns the offset that this area would have if its offset and size were taking
- * children areas into account. The bpd of an inline area is taken from its nominal
- * font and doesn't depend on the bpds of its children elements. However, in the case
- * of a basic-link element we want the active area to cover all of the children
- * elements.
- *
- * @return the offset that this area would have if the before-edge of its
- * content-rectangle were coinciding with the <q>beforest</q> before-edge of its
- * children allocation-rectangles.
- * @see #getVirtualBPD()
- * @see BasicLinkArea
- */
- int getVirtualOffset() {
- return getBlockProgressionOffset();
- }
-
- /**
- * Returns the block-progression-dimension that this area would have if it were taking
- * its children elements into account. See {@linkplain #getVirtualOffset()}.
- *
- * @return the bpd
- */
- int getVirtualBPD() {
- return getBPD();
- }
-
- /**
- * Collection bidi inline runs.
- * @param runs current list of inline runs
- * @return modified list of inline runs, having appended new run
- */
- public List collectInlineRuns(List runs) {
- assert runs != null;
- runs.add(new InlineRun(this, new int[] {getBidiLevel()}));
- return runs;
- }
-
- /**
- * Determine if inline area IA is an ancestor inline area or same as this area.
- * @param ia inline area to test
- * @return true if specified inline area is an ancestor or same as this area
- */
- public boolean isAncestorOrSelf(InlineArea ia) {
- return (ia == this) || isAncestor(ia);
- }
-
- /**
- * Determine if inline area IA is an ancestor inline area of this area.
- * @param ia inline area to test
- * @return true if specified inline area is an ancestor of this area
- */
- public boolean isAncestor(InlineArea ia) {
- for (Area p = getParentArea(); p != null;) {
- if (p == ia) {
- return true;
- } else if (p instanceof InlineArea) {
- p = ((InlineArea) p).getParentArea();
- } else {
- p = null;
- }
- }
- return false;
- }
-
-}
diff --git a/src/java/org/apache/fop/area/inline/InlineBlockParent.java b/src/java/org/apache/fop/area/inline/InlineBlockParent.java
deleted file mode 100644
index f2a7fecee..000000000
--- a/src/java/org/apache/fop/area/inline/InlineBlockParent.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.Area;
-import org.apache.fop.area.Block;
-
-
-/**
- * Inline block parent area.
- * This is an inline area that can have one block area as a child
- */
-public class InlineBlockParent extends InlineArea {
-
-
- private static final long serialVersionUID = -3661746143321407377L;
-
- /**
- * The list of inline areas added to this inline parent.
- */
- protected Block child;
-
- /**
- * Create a new inline block parent to add areas to.
- */
- public InlineBlockParent() {
- }
-
- /**
- * Override generic Area method.
- *
- * @param childArea the child area to add
- */
- @Override
- public void addChildArea(Area childArea) {
- if (child != null) {
- throw new IllegalStateException("InlineBlockParent may have only one child area.");
- }
- if (childArea instanceof Block) {
- child = (Block) childArea;
- //Update extents from the child
- setIPD(childArea.getAllocIPD());
- setBPD(childArea.getAllocBPD());
- } else {
- throw new IllegalArgumentException("The child of an InlineBlockParent must be a"
- + " Block area");
- }
- }
-
- /**
- * Get the child areas for this inline parent.
- *
- * @return the list of child areas
- */
- public Block getChildArea() {
- return child;
- }
-
-}
diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java
deleted file mode 100644
index 2e03f4d80..000000000
--- a/src/java/org/apache/fop/area/inline/InlineParent.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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 java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.fop.area.Area;
-
-/**
- * Inline parent area.
- * This is an inline area that can have other inlines as children.
- */
-public class InlineParent extends InlineArea {
-
- private static final long serialVersionUID = -3047168298770354813L;
-
- /**
- * The list of inline areas added to this inline parent.
- */
- protected List<InlineArea> inlines = new ArrayList<InlineArea>();
-
- /** Controls whether the IPD is automatically adjusted based on the area's children. */
- protected transient boolean autoSize;
-
- /** The offset of the <q>beforest</q> child area of this area. */
- protected int minChildOffset;
-
- /**
- * The offset of the <q>afterest</q> child area of this area. Offset from the
- * before-edge of this area's content-rectangle and the after-edge of the child area's
- * allocation-rectangle.
- */
- private int maxAfterEdge;
-
- private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- }
-
- @Override
- public void addChildArea(Area c) {
- assert c instanceof InlineArea;
- if (inlines.size() == 0) {
- autoSize = (getIPD() == 0);
- }
- InlineArea childArea = (InlineArea) c;
- inlines.add(childArea);
- // set the parent area for the child area
- childArea.setParentArea(this);
- if (autoSize) {
- increaseIPD(childArea.getAllocIPD());
- }
- updateLevel(childArea.getBidiLevel());
- int childOffset = childArea.getVirtualOffset();
- minChildOffset = Math.min(minChildOffset, childOffset);
- maxAfterEdge = Math.max(maxAfterEdge, childOffset + childArea.getVirtualBPD());
- }
-
- @Override
- int getVirtualOffset() {
- return getBlockProgressionOffset() + minChildOffset;
- }
-
- @Override
- int getVirtualBPD() {
- return maxAfterEdge - minChildOffset;
- }
-
- /**
- * Get the child areas for this inline parent.
- *
- * @return the list of child areas
- */
- public List<InlineArea> getChildAreas() {
- return inlines;
- }
-
- /**
- * recursively apply the variation factor to all descendant areas
- * @param variationFactor the variation factor that must be applied to adjustments
- * @param lineStretch the total stretch of the line
- * @param lineShrink the total shrink of the line
- * @return true if there is an UnresolvedArea descendant
- */
- @Override
- public boolean applyVariationFactor(double variationFactor,
- int lineStretch, int lineShrink) {
- boolean hasUnresolvedAreas = false;
- int cumulativeIPD = 0;
- // recursively apply variation factor to descendant areas
- for (int i = 0, len = inlines.size(); i < len; i++) {
- InlineArea inline = inlines.get(i);
- hasUnresolvedAreas |= inline.applyVariationFactor(
- variationFactor, lineStretch, lineShrink);
- cumulativeIPD += inline.getIPD(); //Update this area's IPD based on changes to children
- }
- setIPD(cumulativeIPD);
-
- return hasUnresolvedAreas;
- }
-
- @Override
- public List collectInlineRuns(List runs) {
- for (Iterator<InlineArea> it = getChildAreas().iterator(); it.hasNext();) {
- InlineArea ia = it.next();
- runs = ia.collectInlineRuns(runs);
- }
- return runs;
- }
-
- /**
- * Reset bidirectionality level of all children to default (-1),
- * signalling that they will inherit the level of their parent text area.
- */
- public void resetChildrenLevel() {
- for (Iterator it = inlines.iterator(); it.hasNext();) {
- ((InlineArea) it.next()) .resetBidiLevel();
- }
- }
-
- private void updateLevel(int newLevel) {
- if (newLevel >= 0) {
- int curLevel = getBidiLevel();
- if (curLevel >= 0) {
- if (newLevel < curLevel) {
- setBidiLevel(newLevel);
- }
- } else {
- setBidiLevel(newLevel);
- }
- }
- }
-
-
-}
diff --git a/src/java/org/apache/fop/area/inline/InlineViewport.java b/src/java/org/apache/fop/area/inline/InlineViewport.java
deleted file mode 100644
index e111bdd9d..000000000
--- a/src/java/org/apache/fop/area/inline/InlineViewport.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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 java.awt.Rectangle;
-import java.awt.geom.Rectangle2D;
-import java.io.IOException;
-import java.util.TreeMap;
-
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Viewport;
-
-/**
- * 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 InlineViewport extends InlineArea implements Viewport {
-
- private static final long serialVersionUID = 813338534627918689L;
-
- // contents could be container, foreign object or image
- private Area content;
- // clipping for the viewport
- private boolean clip;
- // position of the child area relative to this area
- private Rectangle2D contentPosition;
-
- /**
- * Create a new viewport area with the content area.
- *
- * @param child the child content area of this viewport
- */
- public InlineViewport(Area child) {
- this(child, -1);
- }
-
- /**
- * Create a new viewport area with the content area.
- *
- * @param child the child content area of this viewport
- * @param bidiLevel the bidirectional embedding level (or -1 if not defined)
- */
- public InlineViewport(Area child, int bidiLevel) {
- super(0, bidiLevel);
- this.content = child;
- }
-
- /**
- * Set the clip of this viewport.
- *
- * @param c true if this viewport should clip
- */
- public void setClip(boolean c) {
- this.clip = c;
- }
-
- /** {@inheritDoc} */
- public boolean hasClip() {
- return this.clip;
- }
-
- /** {@inheritDoc} */
- public Rectangle getClipRectangle() {
- if (clip) {
- return new Rectangle(getIPD(), getBPD());
- } else {
- return null;
- }
- }
-
- /**
- * Set the position and size of the content of this viewport.
- *
- * @param cp the position and size to place the content
- */
- public void setContentPosition(Rectangle2D cp) {
- this.contentPosition = cp;
- }
-
- /**
- * Get the position and size of the content of this viewport.
- *
- * @return the position and size to place the content
- */
- public Rectangle2D getContentPosition() {
- return this.contentPosition;
- }
-
- /**
- * Sets the content area.
- * @param content the content area
- */
- public void setContent(Area content) {
- this.content = content;
- }
-
- /**
- * Get the content area for this viewport.
- *
- * @return the content area
- */
- public Area getContent() {
- return this.content;
- }
-
- private void writeObject(java.io.ObjectOutputStream out)
- throws IOException {
- out.writeBoolean(contentPosition != null);
- if (contentPosition != null) {
- out.writeFloat((float) contentPosition.getX());
- out.writeFloat((float) contentPosition.getY());
- out.writeFloat((float) contentPosition.getWidth());
- out.writeFloat((float) contentPosition.getHeight());
- }
- out.writeBoolean(clip);
- out.writeObject((TreeMap)traits);
- out.writeObject(content);
- }
-
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException {
- if (in.readBoolean()) {
- contentPosition = new Rectangle2D.Float(in.readFloat(),
- in.readFloat(),
- in.readFloat(),
- in.readFloat());
- }
- this.clip = in.readBoolean();
- this.traits = (TreeMap) in.readObject();
- this.content = (Area) in.readObject();
- }
-
- public int getEffectiveIPD() {
- return getIPD();
- }
-}
diff --git a/src/java/org/apache/fop/area/inline/Leader.java b/src/java/org/apache/fop/area/inline/Leader.java
deleted file mode 100644
index ff8ba12b0..000000000
--- a/src/java/org/apache/fop/area/inline/Leader.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.fo.Constants;
-
-/**
- * This is a leader inline area.
- * This class is only used for leader with leader-pattern of rule.
- */
-public class Leader extends InlineArea {
-
- // in the case of use content or dots this is replaced
- // with the set of inline areas
- // if space replaced with a space
- // otherwise this is a holder for a line
-
-
- private static final long serialVersionUID = -8011373048313956301L;
-
- private int ruleStyle = Constants.EN_SOLID;
- private int ruleThickness = 1000;
-
- /**
- * Create a new leader area.
- */
- public Leader() {
- }
-
- /**
- * Set the rule style of this leader area.
- *
- * @param style the rule style for the leader line
- */
- public void setRuleStyle(int style) {
- ruleStyle = style;
- }
-
- /**
- * Set the rule style of this leader area.
- * @param style the rule style for the leader area (XSL enum values)
- */
- public void setRuleStyle(String style) {
- if ("dotted".equalsIgnoreCase(style)) {
- setRuleStyle(Constants.EN_DOTTED);
- } else if ("dashed".equalsIgnoreCase(style)) {
- setRuleStyle(Constants.EN_DASHED);
- } else if ("solid".equalsIgnoreCase(style)) {
- setRuleStyle(Constants.EN_SOLID);
- } else if ("double".equalsIgnoreCase(style)) {
- setRuleStyle(Constants.EN_DOUBLE);
- } else if ("groove".equalsIgnoreCase(style)) {
- setRuleStyle(Constants.EN_GROOVE);
- } else if ("ridge".equalsIgnoreCase(style)) {
- setRuleStyle(Constants.EN_RIDGE);
- } else if ("none".equalsIgnoreCase(style)) {
- setRuleStyle(Constants.EN_NONE);
- }
- }
-
- /**
- * Set the rule thickness of the rule in miilipoints.
- *
- * @param rt the rule thickness in millipoints
- */
- public void setRuleThickness(int rt) {
- ruleThickness = rt;
- }
-
- /**
- * Get the rule style of this leader.
- *
- * @return the rule style
- */
- public int getRuleStyle() {
- return ruleStyle;
- }
-
- /** @return the rule style as string */
- public String getRuleStyleAsString() {
- switch (getRuleStyle()) {
- case Constants.EN_DOTTED: return "dotted";
- case Constants.EN_DASHED: return "dashed";
- case Constants.EN_SOLID: return "solid";
- case Constants.EN_DOUBLE: return "double";
- case Constants.EN_GROOVE: return "groove";
- case Constants.EN_RIDGE: return "ridge";
- case Constants.EN_NONE: return "none";
- default:
- throw new IllegalStateException("Unsupported rule style: " + getRuleStyle());
- }
- }
-
- /**
- * Get the rule thickness of the rule in miilipoints.
- *
- * @return the rule thickness in millipoints
- */
- public int getRuleThickness() {
- return ruleThickness;
- }
-
-}
-
diff --git a/src/java/org/apache/fop/area/inline/ResolvedPageNumber.java b/src/java/org/apache/fop/area/inline/ResolvedPageNumber.java
deleted file mode 100644
index cbef88b7e..000000000
--- a/src/java/org/apache/fop/area/inline/ResolvedPageNumber.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 java.io.IOException;
-import java.io.ObjectInputStream;
-
-/**
- * Always (pre-) resolved page number area. Needed by BIDI code to distinguish
- * from UnresolvedPageNumber.
- */
-public class ResolvedPageNumber extends TextArea {
-
- private static final long serialVersionUID = -1758369835371647979L;
-
- private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- }
-
-}
diff --git a/src/java/org/apache/fop/area/inline/Space.java b/src/java/org/apache/fop/area/inline/Space.java
deleted file mode 100644
index b097e4349..000000000
--- a/src/java/org/apache/fop/area/inline/Space.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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;
-
-/**
- * Inline space area.
- * This is used for adding a inline space to the output.
- */
-public class Space extends InlineArea {
-
- private static final long serialVersionUID = -8748265505356839796L;
-
- /**
- * Default constructor.
- */
- public Space() {
- }
-
-}
diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java
deleted file mode 100644
index be7b61a9f..000000000
--- a/src/java/org/apache/fop/area/inline/SpaceArea.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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;
-
-/**
- * A space
- */
-public class SpaceArea extends InlineArea {
-
- private static final long serialVersionUID = 2218803009825411416L;
-
- /**
- * The space for this space area
- */
- protected char space;
-
- /**
- * Is this space adjustable?
- */
- protected boolean isAdjustable;
-
- /**
- * Create a space area
- * @param space the space character
- * @param blockProgressionOffset the offset for the next area
- * @param adjustable is this space adjustable?
- * @param bidiLevel the bidirectional embedding level (or -1 if not defined)
- */
- public SpaceArea(int blockProgressionOffset, int bidiLevel, char space, boolean adjustable) {
- super(blockProgressionOffset, bidiLevel);
- this.space = space;
- this.isAdjustable = adjustable;
- }
-
- /** @return Returns the space. */
- public String getSpace() {
- return String.valueOf(space);
- }
-
- /** @return true if the space is adjustable (WRT word-space processing) */
- public boolean isAdjustable() {
- return this.isAdjustable;
- }
-
-}
diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java
deleted file mode 100644
index 5a1b31c98..000000000
--- a/src/java/org/apache/fop/area/inline/TextArea.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * 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 java.util.Arrays;
-
-import org.apache.fop.util.CharUtilities;
-
-/**
- * A text inline area.
- */
-public class TextArea extends AbstractTextArea {
-
- private static final long serialVersionUID = 7315900267242540809L;
-
- private boolean isHyphenated;
-
- /**
- * Create a text inline area
- */
- public TextArea() {
- }
-
- /**
- * Constructor with extra parameters:
- * create a TextAdjustingInfo object
- * @param stretch the available stretch of the text
- * @param shrink the available shrink of the text
- * @param adj the current total adjustment
- */
- public TextArea(int stretch, int shrink, int adj) {
- super(stretch, shrink, adj);
- }
-
- /**
- * Remove the old text
- */
- public void removeText() {
- inlines.clear();
- }
-
- /**
- * Create and add a WordArea child to this TextArea.
- *
- * @param word the word string
- * @param offset the offset for the next area
- */
- public void addWord(String word, int offset) {
- addWord(word, 0, null, null, null, offset);
- }
-
- /**
- * Create and add a WordArea child to this TextArea.
- *
- * @param word the word string
- * @param offset the offset for the next area
- * @param level bidirectional level that applies to entire word
- */
- public void addWord(String word, int offset, int level) {
- addWord(word, 0, null, makeLevels(level, word.length()), null, offset);
- }
-
- /**
- * Create and add a WordArea child to this TextArea.
- *
- * @param word the word string
- * @param ipd the word's ipd
- * @param letterAdjust the letter adjustment array (may be null)
- * @param levels array of resolved bidirectional levels of word characters,
- * or null if default level
- * @param gposAdjustments array of general position adjustments or null if none apply
- * @param blockProgressionOffset the offset for the next area
- */
- public void addWord(
- String word, int ipd, int[] letterAdjust, int[] levels,
- int[][] gposAdjustments, int blockProgressionOffset) {
- int minWordLevel = findMinLevel(levels, getBidiLevel());
- WordArea wordArea = new WordArea(
- blockProgressionOffset, minWordLevel, word, letterAdjust, levels, gposAdjustments);
- wordArea.setIPD(ipd);
- addChildArea(wordArea);
- wordArea.setParentArea(this);
- updateLevel(minWordLevel);
- }
-
- /**
- * Create and add a SpaceArea child to this TextArea
- *
- * @param space the space character
- * @param ipd the space's ipd
- * @param blockProgressionOffset the offset for the next area
- * @param adjustable is this space adjustable?
- * @param level resolved bidirection level of space character
- */
- public void addSpace(
- char space, int ipd, boolean adjustable, int blockProgressionOffset, int level) {
- SpaceArea spaceArea = new SpaceArea(blockProgressionOffset, level, space, adjustable);
- spaceArea.setIPD(ipd);
- addChildArea(spaceArea);
- spaceArea.setParentArea(this);
- updateLevel(level);
- }
-
- /**
- * Records that the last word in this text area is hyphenated.
- */
- public void setHyphenated() {
- this.isHyphenated = true;
- }
-
- /**
- * Returns {@code true} if the last word in this area is hyphenated.
- */
- public boolean isHyphenated() {
- return isHyphenated;
- }
-
- /**
- * Get the whole text string.
- * Renderers whose space adjustment handling is not affected
- * by multi-byte characters can use this method to render the
- * whole TextArea at once; the other renderers (for example
- * PDFRenderer) have to implement renderWord(WordArea) and
- * renderSpace(SpaceArea) in order to correctly place each
- * text fragment.
- *
- * @return the text string
- */
- public String getText() {
- StringBuilder text = new StringBuilder();
- // assemble the text
- for (InlineArea inline : inlines) {
- if (inline instanceof WordArea) {
- text.append(((WordArea) inline).getWord());
- } else {
- assert (inline instanceof SpaceArea);
- text.append(((SpaceArea) inline).getSpace());
- }
- }
- return text.toString();
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer(super.toString());
- sb.append(" {text=\"");
- sb.append(CharUtilities.toNCRefs(getText()));
- sb.append("\"");
- sb.append("}");
- return sb.toString();
- }
-
- public void updateLevel(int newLevel) {
- if (newLevel >= 0) {
- int curLevel = getBidiLevel();
- if (curLevel >= 0) {
- if (newLevel < curLevel) {
- setBidiLevel(newLevel);
- }
- } else {
- setBidiLevel(newLevel);
- }
- }
- }
-
- private static int findMinLevel(int[] levels, int defaultLevel) {
- if (levels != null) {
- int lMin = Integer.MAX_VALUE;
- for (int i = 0, n = levels.length; i < n; i++) {
- int l = levels [ i ];
- if ((l >= 0) && (l < lMin)) {
- lMin = l;
- }
- }
- if (lMin == Integer.MAX_VALUE) {
- return -1;
- } else {
- return lMin;
- }
- } else {
- return defaultLevel;
- }
- }
-
- private int[] makeLevels(int level, int count) {
- if (level >= 0) {
- int[] levels = new int [ count ];
- Arrays.fill(levels, level);
- return levels;
- } else {
- return null;
- }
- }
-
- public int getEffectiveIPD() {
- return getIPD();
- }
-}
-
diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
deleted file mode 100644
index 2d5845718..000000000
--- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * 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 java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.List;
-
-import org.apache.fop.area.PageViewport;
-import org.apache.fop.area.Resolvable;
-import org.apache.fop.complexscripts.bidi.InlineRun;
-import org.apache.fop.fonts.Font;
-
-/**
- * Unresolvable page number area.
- * This is a word area that resolves itself to a page number
- * from an id reference.
- */
-public class UnresolvedPageNumber extends TextArea implements Resolvable {
-
-
- private static final long serialVersionUID = -1758090835371647980L;
-
- private boolean resolved;
- private String pageIDRef;
- private String text;
- private boolean pageType;
-
- /** Indicates that the reference refers to the first area generated by a formatting object. */
- public static final boolean FIRST = true;
- /** Indicates that the reference refers to the last area generated by a formatting object. */
- public static final boolean LAST = false;
-
- //Transient fields
- private transient Font font;
-
- public UnresolvedPageNumber() {
- this(null, null, FIRST);
- }
-
- /**
- * Create a new unresolved page number.
- *
- * @param id the id reference for resolving this
- * @param f the font for formatting the page number
- */
- public UnresolvedPageNumber(String id, Font f) {
- this(id, f, FIRST);
- }
-
- /**
- * Create a new unresolved page number.
- *
- * @param id the id reference for resolving this
- * @param f the font for formatting the page number
- * @param type indicates whether the reference refers to the first or last area generated by
- * a formatting object
- */
- public UnresolvedPageNumber(String id, Font f, boolean type) {
- pageIDRef = id;
- font = f;
- text = "?";
- pageType = type;
- }
-
- private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- }
-
- /**
- * Get the id references for this area.
- *
- * @return the id reference for this unresolved page number
- */
- public String[] getIDRefs() {
- return new String[] {pageIDRef};
- }
-
- /**
- * Get the (resolved or unresolved) text.
- *
- * @return the text
- */
- public String getText() {
- return text;
- }
-
- /**
- * Resolve the page number idref
- * This resolves the idref for this object by getting the page number
- * string from the first page in the list of pages that apply
- * for this ID. The page number text is then set to the String value
- * of the page number.
- *
- * TODO: [GA] May need to run bidi algorithm and script processor
- * on resolved page number.
- *
- * @param id an id whose PageViewports have been determined
- * @param pages the list of PageViewports associated with this ID
- */
- public void resolveIDRef(String id, List<PageViewport> pages) {
- if (!resolved && pageIDRef.equals(id) && pages != null) {
- if (log.isDebugEnabled()) {
- log.debug("Resolving pageNumber: " + id);
- }
- resolved = true;
- int pageIndex = pageType ? 0 : pages.size() - 1;
- PageViewport page = pages.get(pageIndex);
- // replace the text
- removeText();
- text = page.getPageNumberString();
- addWord(text, 0, getBidiLevel());
- // update ipd
- if (font != null) {
- handleIPDVariation(font.getWordWidth(text) - getIPD());
- // set the Font object to null, as we don't need it any more
- font = null;
- } else {
- log.warn("Cannot update the IPD of an unresolved page number."
- + " No font information available.");
- }
- }
- }
-
- /**
- * Check if this is resolved.
- *
- * @return true when this has been resolved
- */
- public boolean isResolved() {
- return resolved;
- }
-
- /**
- * recursively apply the variation factor to all descendant areas
- * @param variationFactor the variation factor that must be applied to adjustment ratios
- * @param lineStretch the total stretch of the line
- * @param lineShrink the total shrink of the line
- * @return true if there is an UnresolvedArea descendant
- */
- @Override
- public boolean applyVariationFactor(double variationFactor,
- int lineStretch, int lineShrink) {
- return true;
- }
-
- /**
- * Collection bidi inline runs.
- * Override of @{link InlineParent} implementation.
- *
- * N.B. [GA] without this override, the page-number-citation_writing_mode_rl
- * layout engine test will fail. It may be that the test needs to
- * be updated rather than using this override.
- * @param runs current list of inline runs
- * @return modified list of inline runs, having appended new run
- */
- @Override
- public List collectInlineRuns(List runs) {
- assert runs != null;
- runs.add(new InlineRun(this, new int[] {getBidiLevel()}));
- return runs;
- }
-}
diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java
deleted file mode 100644
index 24cc9478c..000000000
--- a/src/java/org/apache/fop/area/inline/WordArea.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * 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 java.util.Arrays;
-import java.util.List;
-
-import org.apache.fop.complexscripts.bidi.InlineRun;
-import org.apache.fop.complexscripts.util.CharMirror;
-
-/**
- * A string of characters without spaces
- */
-public class WordArea extends InlineArea {
-
- private static final long serialVersionUID = 6444644662158970942L;
-
- /** The text for this word area */
- protected String word;
-
- /** An array of width for adjusting the individual letters (optional) */
- protected int[] letterAdjust;
-
- /**
- * An array of resolved bidirectional levels corresponding to each character
- * in word (optional)
- */
- protected int[] levels;
-
- /**
- * An array of glyph positioning adjustments to apply to each glyph 'char' in word (optional)
- */
- protected int[][] gposAdjustments;
-
- /**
- * A flag indicating whether the content of word is reversed in relation to
- * its original logical order.
- */
- protected boolean reversed;
-
- /**
- * Create a word area
- * @param blockProgressionOffset the offset for this area
- * @param level the bidirectional embedding level (or -1 if not defined) for word as a group
- * @param word the word string
- * @param letterAdjust the letter adjust array (may be null)
- * @param levels array of per-character (glyph) bidirectional levels,
- * in case word area is heterogenously leveled
- * @param gposAdjustments array of general position adjustments or null if none apply
- * @param reversed true if word is known to be reversed at construction time
- */
- public WordArea(
- int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels,
- int[][] gposAdjustments, boolean reversed) {
- super(blockProgressionOffset, level);
- int length = (word != null) ? word.length() : 0;
- this.word = word;
- this.letterAdjust = maybeAdjustLength(letterAdjust, length);
- this.levels = maybePopulateLevels(levels, level, length);
- this.gposAdjustments = maybeAdjustLength(gposAdjustments, length);
- this.reversed = reversed;
- }
-
- /**
- * Create a word area
- * @param blockProgressionOffset the offset for this area
- * @param level the bidirectional embedding level (or -1 if not defined) for word as a group
- * @param word the word string
- * @param letterAdjust the letter adjust array (may be null)
- * @param levels array of per-character (glyph) bidirectional levels,
- * in case word area is heterogenously leveled
- * @param gposAdjustments array of general position adjustments or null if none apply
- */
- public WordArea(
- int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels,
- int[][] gposAdjustments) {
- this (blockProgressionOffset, level, word, letterAdjust, levels, gposAdjustments, false);
- }
-
- /** @return Returns the word. */
- public String getWord() {
- return word;
- }
-
- /** @return the array of letter adjust widths */
- public int[] getLetterAdjustArray() {
- return this.letterAdjust;
- }
-
- /**
- * Obtain per-character (glyph) bidi levels.
- * @return a (possibly empty) array of levels or null (if none resolved)
- */
- public int[] getBidiLevels() {
- return levels;
- }
-
- /**
- * <p>Obtain per-character (glyph) bidi levels over a specified subsequence.</p>
- * <p>If word has been reversed, then the subsequence is over the reversed word.</p>
- * @param start starting (inclusive) index of subsequence
- * @param end ending (exclusive) index of subsequence
- * @return a (possibly null) array of per-character (glyph) levels over the specified
- * sequence
- */
- public int[] getBidiLevels(int start, int end) {
- assert start <= end;
- if (this.levels != null) {
- int n = end - start;
- int[] levels = new int [ n ];
- for (int i = 0; i < n; i++) {
- levels[i] = this.levels [ start + i ];
- }
- return levels;
- } else {
- return null;
- }
- }
-
- /**
- * <p>Obtain per-character (glyph) level at a specified index position.</p>
- * <p>If word has been reversed, then the position is relative to the reversed word.</p>
- * @param position the index of the (possibly reversed) character from which to obtain the
- * level
- * @return a resolved bidirectional level or, if not specified, then -1
- */
- public int bidiLevelAt(int position) {
- if (position > word.length()) {
- throw new IndexOutOfBoundsException();
- } else if (levels != null) {
- return levels [ position ];
- } else {
- return -1;
- }
- }
-
- @Override
- public List collectInlineRuns(List runs) {
- assert runs != null;
- InlineRun r;
- int[] levels = getBidiLevels();
- if ((levels != null) && (levels.length > 0)) {
- r = new InlineRun(this, levels);
- } else {
- r = new InlineRun(this, getBidiLevel(), word.length());
- }
- runs.add(r);
- return runs;
- }
-
- /**
- * Obtain per-character (glyph) position adjustments.
- * @return a (possibly empty) array of adjustments, each having four elements, or null
- * if no adjustments apply
- */
- public int[][] getGlyphPositionAdjustments() {
- return gposAdjustments;
- }
-
- /**
- * <p>Obtain per-character (glyph) position adjustments at a specified index position.</p>
- * <p>If word has been reversed, then the position is relative to the reversed word.</p>
- * @param position the index of the (possibly reversed) character from which to obtain the
- * level
- * @return an array of adjustments or null if none applies
- */
- public int[] glyphPositionAdjustmentsAt(int position) {
- if (position > word.length()) {
- throw new IndexOutOfBoundsException();
- } else if (gposAdjustments != null) {
- return gposAdjustments [ position ];
- } else {
- return null;
- }
- }
-
- /**
- * <p>Reverse characters and corresponding per-character levels and glyph position
- * adjustments.</p>
- * @param mirror if true, then perform mirroring if mirrorred characters
- */
- public void reverse(boolean mirror) {
- if (word.length() > 0) {
- word = ((new StringBuffer(word)) .reverse()) .toString();
- if (levels != null) {
- reverse(levels);
- }
- if (gposAdjustments != null) {
- reverse(gposAdjustments);
- }
- reversed = !reversed;
- if (mirror) {
- word = CharMirror.mirror(word);
- }
- }
- }
-
- /**
- * <p>Perform mirroring on mirrorable characters.</p>
- */
- public void mirror() {
- if (word.length() > 0) {
- word = CharMirror.mirror(word);
- }
- }
-
- /**
- * <p>Determined if word has been reversed (in relation to original logical order).</p>
- * <p>If a word is reversed, then both its characters (glyphs) and corresponding per-character
- * levels are in reverse order.</p>
- * <p>Note: this information is used in order to process non-spacing marks during rendering as
- * well as provide hints for caret direction.</p>
- * @return true if word is reversed
- */
- public boolean isReversed() {
- return reversed;
- }
-
- /*
- * If int[] array is not of specified length, then create
- * a new copy of the first length entries.
- */
- private static int[] maybeAdjustLength(int[] ia, int length) {
- if (ia != null) {
- if (ia.length == length) {
- return ia;
- } else {
- int[] iaNew = new int [ length ];
- for (int i = 0, n = ia.length; i < n; i++) {
- if (i < length) {
- iaNew [ i ] = ia [ i ];
- } else {
- break;
- }
- }
- return iaNew;
- }
- } else {
- return ia;
- }
- }
-
- /*
- * If int[][] matrix is not of specified length, then create
- * a new shallow copy of the first length entries.
- */
- private static int[][] maybeAdjustLength(int[][] im, int length) {
- if (im != null) {
- if (im.length == length) {
- return im;
- } else {
- int[][] imNew = new int [ length ][];
- for (int i = 0, n = im.length; i < n; i++) {
- if (i < length) {
- imNew [ i ] = im [ i ];
- } else {
- break;
- }
- }
- return imNew;
- }
- } else {
- return im;
- }
- }
-
- private static int[] maybePopulateLevels(int[] levels, int level, int count) {
- if ((levels == null) && (level >= 0)) {
- levels = new int[count];
- Arrays.fill(levels, level);
- }
- return maybeAdjustLength(levels, count);
- }
-
- private static void reverse(int[] a) {
- for (int i = 0, n = a.length, m = n / 2; i < m; i++) {
- int k = n - i - 1;
- int t = a [ k ];
- a [ k ] = a [ i ];
- a [ i ] = t;
- }
- }
-
- private static void reverse(int[][] aa) {
- for (int i = 0, n = aa.length, m = n / 2; i < m; i++) {
- int k = n - i - 1;
- int[] t = aa [ k ];
- aa [ k ] = aa [ i ];
- aa [ i ] = t;
- }
- }
-
-}
diff --git a/src/java/org/apache/fop/area/inline/package.html b/src/java/org/apache/fop/area/inline/package.html
deleted file mode 100644
index 064a17d0c..000000000
--- a/src/java/org/apache/fop/area/inline/package.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- 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$ -->
-<HTML>
-<TITLE>org.apache.fop.area.inline Package</TITLE>
-<BODY>
-<P>FOP's area tree: inline-level areas</P>
-</BODY>
-</HTML> \ No newline at end of file
diff --git a/src/java/org/apache/fop/area/package.html b/src/java/org/apache/fop/area/package.html
deleted file mode 100644
index c0f096e11..000000000
--- a/src/java/org/apache/fop/area/package.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- 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$ -->
-<HTML>
-<TITLE>org.apache.fop.area Package</TITLE>
-<BODY>
-<P>FOP's area tree.</P>
-</BODY>
-</HTML> \ No newline at end of file