aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2003-02-19 05:49:29 +0000
committerKeiron Liddle <keiron@apache.org>2003-02-19 05:49:29 +0000
commitbbb1c238b55f01dda202df574c7ad06b53fb795f (patch)
tree75b0ed90e91275478287a282536ee1153e278e5e
parent2376cbe94f417b0216ab13b40d9ac7e2826359bf (diff)
downloadxmlgraphics-fop-bbb1c238b55f01dda202df574c7ad06b53fb795f.tar.gz
xmlgraphics-fop-bbb1c238b55f01dda202df574c7ad06b53fb795f.zip
add and retrive markers
use trait setter for area traits some style cleanups git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195971 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/org/apache/fop/layoutmgr/AbstractLayoutManager.java86
-rw-r--r--src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java29
-rw-r--r--src/org/apache/fop/layoutmgr/BlockLayoutManager.java10
-rw-r--r--src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java3
-rw-r--r--src/org/apache/fop/layoutmgr/BreakPossPosIter.java2
-rw-r--r--src/org/apache/fop/layoutmgr/ContentLayoutManager.java9
-rw-r--r--src/org/apache/fop/layoutmgr/FlowLayoutManager.java16
-rw-r--r--src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java4
-rw-r--r--src/org/apache/fop/layoutmgr/LayoutManager.java57
-rw-r--r--src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java1
-rw-r--r--src/org/apache/fop/layoutmgr/LineLayoutManager.java10
-rw-r--r--src/org/apache/fop/layoutmgr/MinOptMax.java15
-rw-r--r--src/org/apache/fop/layoutmgr/PageLayoutManager.java18
-rw-r--r--src/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java123
-rw-r--r--src/org/apache/fop/layoutmgr/StaticContentLayoutManager.java1
-rw-r--r--src/org/apache/fop/layoutmgr/TextLayoutManager.java7
-rw-r--r--src/org/apache/fop/layoutmgr/TraitSetter.java57
-rw-r--r--src/org/apache/fop/layoutmgr/list/Item.java6
-rw-r--r--src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java6
-rw-r--r--src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java1
-rw-r--r--src/org/apache/fop/layoutmgr/table/Body.java4
-rw-r--r--src/org/apache/fop/layoutmgr/table/Caption.java1
-rw-r--r--src/org/apache/fop/layoutmgr/table/Cell.java6
-rw-r--r--src/org/apache/fop/layoutmgr/table/Column.java3
-rw-r--r--src/org/apache/fop/layoutmgr/table/Row.java4
-rw-r--r--src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java1
-rw-r--r--src/org/apache/fop/layoutmgr/table/TableLayoutManager.java6
27 files changed, 336 insertions, 150 deletions
diff --git a/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java
index 24165c597..33b7feaca 100644
--- a/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java
@@ -9,18 +9,16 @@ package org.apache.fop.layoutmgr;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOUserAgent;
+import org.apache.fop.fo.flow.Marker;
import org.apache.fop.area.Area;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.PropertyManager;
-import org.apache.fop.area.Trait;
-import org.apache.fop.layout.BorderAndPadding;
-import org.apache.fop.layout.BackgroundProps;
-import org.apache.fop.traits.BorderProps;
import org.apache.avalon.framework.logger.Logger;
import java.util.ListIterator;
+import java.util.Map;
/**
* The base class for all LayoutManagers.
@@ -30,6 +28,7 @@ public abstract class AbstractLayoutManager implements LayoutManager {
protected LayoutManager parentLM = null;
protected FObj fobj;
protected String foID = null;
+ protected Map markers = null;
/** True if this LayoutManager has handled all of its content. */
private boolean bFinished = false;
@@ -37,7 +36,6 @@ public abstract class AbstractLayoutManager implements LayoutManager {
protected ListIterator childLMiter;
protected boolean bInited = false;
-
/**
* Abstract layout manager.
*/
@@ -52,6 +50,7 @@ public abstract class AbstractLayoutManager implements LayoutManager {
public void setFObj(FObj fo) {
this.fobj = fo;
foID = fobj.getID();
+ markers = fobj.getMarkers();
childLMiter = new LMiter(fobj.getChildren());
}
@@ -64,6 +63,11 @@ public abstract class AbstractLayoutManager implements LayoutManager {
userAgent = ua;
}
+ /**
+ * Get the user agent.
+ *
+ * @see org.apache.fop.layoutmgr.LayoutManager#getUserAgent()
+ */
public FOUserAgent getUserAgent() {
return userAgent;
}
@@ -318,12 +322,22 @@ public abstract class AbstractLayoutManager implements LayoutManager {
}
/**
+ * Add the markers when adding an area.
+ */
+ protected void addMarkers(boolean start) {
+ // add markers
+ if (markers != null) {
+ addMarkerMap(markers, start);
+ }
+ }
+
+ /**
* Delegate adding marker to the parent layout manager.
*
* @see org.apache.fop.layoutmgr.LayoutManager
*/
- public void addMarker(String name, LayoutManager lm, boolean start) {
- parentLM.addMarker(name, lm, start);
+ public void addMarkerMap(Map marks, boolean start) {
+ parentLM.addMarkerMap(marks, start);
}
/**
@@ -331,65 +345,9 @@ public abstract class AbstractLayoutManager implements LayoutManager {
*
* @see org.apache.fop.layoutmgr.LayoutManager
*/
- public LayoutManager retrieveMarker(String name, int pos, int boundary) {
+ public Marker retrieveMarker(String name, int pos, int boundary) {
return parentLM.retrieveMarker(name, pos, boundary);
}
- /**
- * Add borders to an area.
- * Layout managers that create areas with borders can use this to
- * add the borders to the area.
- */
- public static void addBorders(Area curBlock, BorderAndPadding bordProps) {
- BorderProps bps = getBorderProps(bordProps, BorderAndPadding.TOP);
- if(bps.width != 0) {
- curBlock.addTrait(Trait.BORDER_BEFORE, bps);
- }
- bps = getBorderProps(bordProps, BorderAndPadding.BOTTOM);
- if(bps.width != 0) {
- curBlock.addTrait(Trait.BORDER_AFTER, bps);
- }
- bps = getBorderProps(bordProps, BorderAndPadding.LEFT);
- if(bps.width != 0) {
- curBlock.addTrait(Trait.BORDER_START, bps);
- }
- bps = getBorderProps(bordProps, BorderAndPadding.RIGHT);
- if(bps.width != 0) {
- curBlock.addTrait(Trait.BORDER_END, bps);
- }
- }
-
- private static BorderProps getBorderProps(BorderAndPadding bordProps, int side) {
- BorderProps bps;
- bps = new BorderProps(bordProps.getBorderStyle(side),
- bordProps.getBorderWidth(side, false),
- bordProps.getBorderColor(side));
- return bps;
- }
-
- /**
- * Add background to an area.
- * Layout managers that create areas with a background can use this to
- * add the background to the area.
- */
- public static void addBackground(Area curBlock, BackgroundProps backProps) {
- Trait.Background back = new Trait.Background();
- back.color = backProps.backColor;
-
- if(backProps.backImage != null) {
- back.url = backProps.backImage;
- back.repeat = backProps.backRepeat;
- if(backProps.backPosHorizontal != null) {
- back.horiz = backProps.backPosHorizontal.mvalue();
- }
- if(backProps.backPosVertical != null) {
- back.vertical = backProps.backPosVertical.mvalue();
- }
- }
-
- if(back.color != null || back.url != null) {
- curBlock.addTrait(Trait.BACKGROUND, back);
- }
- }
}
diff --git a/src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index 47074efe4..af0837d2c 100644
--- a/src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -7,13 +7,9 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.TextInfo;
import org.apache.fop.area.Area;
-import org.apache.fop.area.BlockParent;
import org.apache.fop.area.BlockViewport;
import org.apache.fop.area.Block;
-import org.apache.fop.area.LineArea;
import org.apache.fop.fo.PropertyManager;
import org.apache.fop.layout.AbsolutePositionProps;
import org.apache.fop.fo.properties.AbsolutePosition;
@@ -22,9 +18,9 @@ import org.apache.fop.fo.PropertyList;
import org.apache.fop.area.CTM;
import org.apache.fop.datatypes.FODimension;
-import java.util.ListIterator;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.awt.geom.Rectangle2D;
@@ -45,6 +41,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
int overflow;
PropertyManager propManager;
+ /**
+ * Create a new block container layout manager.
+ */
public BlockContainerLayoutManager() {
}
@@ -203,6 +202,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
LayoutContext layoutContext) {
getParentArea(null);
+ addID();
+ addMarkers(true);
+
LayoutManager childLM ;
int iStartPos = 0;
LayoutContext lc = new LayoutContext(0);
@@ -225,6 +227,13 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
curBlockArea = null;
}
+ /**
+ * Get the parent area for children of this block container.
+ * This returns the current block container area
+ * and creates it if required.
+ *
+ * @see org.apache.fop.layoutmgr.LayoutManager#getParentArea(Area)
+ */
public Area getParentArea(Area childArea) {
if (curBlockArea == null) {
viewportBlockArea = new BlockViewport();
@@ -272,7 +281,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
return curBlockArea;
}
-
+ /**
+ * Add the child to the block container.
+ *
+ * @see org.apache.fop.layoutmgr.LayoutManager#addChild(Area)
+ */
public void addChild(Area childArea) {
if (curBlockArea != null) {
curBlockArea.addBlock((Block) childArea);
@@ -285,8 +298,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
}
}
- public void addMarker(String name, LayoutManager lm, boolean start) {
- parentLM.addMarker(name, lm, start);
+ public void addMarkerMap(Map marks, boolean start) {
+ parentLM.addMarkerMap(marks, start);
}
}
diff --git a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
index 080321b21..3d83e5d20 100644
--- a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
@@ -11,15 +11,11 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.fo.TextInfo;
import org.apache.fop.fo.PropertyManager;
import org.apache.fop.area.Area;
-import org.apache.fop.area.BlockParent;
import org.apache.fop.area.Block;
import org.apache.fop.area.LineArea;
-import org.apache.fop.area.Trait;
import org.apache.fop.traits.LayoutProps;
import org.apache.fop.layout.BorderAndPadding;
import org.apache.fop.layout.BackgroundProps;
-import org.apache.fop.traits.SpaceVal;
-import org.apache.fop.traits.BorderProps;
import java.util.ListIterator;
import java.util.ArrayList;
@@ -80,6 +76,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
inlines.add(firstlm);
while (proxy.hasNext()) {
lm = (LayoutManager) proxy.next();
+ lm.setParentLM(BlockLayoutManager.this);
if (lm.generatesInlineAreas()) {
inlines.add(lm);
} else {
@@ -222,6 +219,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
addBlockSpacing(adjust, layoutProps.spaceBefore.space);
addID();
+ addMarkers(true);
LayoutManager childLM ;
LayoutContext lc = new LayoutContext(0);
@@ -265,8 +263,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
curBlockArea = new Block();
// set traits
- addBorders(curBlockArea, borderProps);
- addBackground(curBlockArea, backgroundProps);
+ TraitSetter.addBorders(curBlockArea, borderProps);
+ TraitSetter.addBackground(curBlockArea, backgroundProps);
// Set up dimensions
// Must get dimensions from parent area
diff --git a/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index fd0b50e04..36dcac7db 100644
--- a/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -7,13 +7,10 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.fo.FObj;
import org.apache.fop.area.Area;
import org.apache.fop.area.BlockParent;
import org.apache.fop.area.Block;
-import java.util.Iterator;
-
/**
* Base LayoutManager class for all areas which stack their child
* areas in the block-progression direction, such as Flow, Block, ListBlock.
diff --git a/src/org/apache/fop/layoutmgr/BreakPossPosIter.java b/src/org/apache/fop/layoutmgr/BreakPossPosIter.java
index 9d9eaf5d5..1e1465794 100644
--- a/src/org/apache/fop/layoutmgr/BreakPossPosIter.java
+++ b/src/org/apache/fop/layoutmgr/BreakPossPosIter.java
@@ -1,6 +1,6 @@
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
diff --git a/src/org/apache/fop/layoutmgr/ContentLayoutManager.java b/src/org/apache/fop/layoutmgr/ContentLayoutManager.java
index e41c15ca6..639e35986 100644
--- a/src/org/apache/fop/layoutmgr/ContentLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/ContentLayoutManager.java
@@ -8,6 +8,7 @@ package org.apache.fop.layoutmgr;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOUserAgent;
+import org.apache.fop.fo.flow.Marker;
import org.apache.fop.area.Area;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.PageViewport;
@@ -15,9 +16,9 @@ import org.apache.fop.area.PageViewport;
import org.apache.avalon.framework.logger.Logger;
import java.util.List;
+import java.util.Map;
import java.util.ArrayList;
-
/**
* Content Layout Manager.
* For use with objects that contain inline areas such as
@@ -213,12 +214,12 @@ public class ContentLayoutManager implements LayoutManager {
}
/** @see org.apache.fop.layoutmgr.LayoutManager */
- public void addMarker(String name, LayoutManager lm, boolean start) {
- parentLM.addMarker(name, lm, start);
+ public void addMarkerMap(Map marks, boolean start) {
+ parentLM.addMarkerMap(marks, start);
}
/** @see org.apache.fop.layoutmgr.LayoutManager */
- public LayoutManager retrieveMarker(String name, int pos, int boundary) {
+ public Marker retrieveMarker(String name, int pos, int boundary) {
return parentLM.retrieveMarker(name, pos, boundary);
}
}
diff --git a/src/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/org/apache/fop/layoutmgr/FlowLayoutManager.java
index 7a6e24cf8..63947e49a 100644
--- a/src/org/apache/fop/layoutmgr/FlowLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/FlowLayoutManager.java
@@ -1,16 +1,15 @@
/*
* $Id$
- * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.layoutmgr;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.properties.Constants;
-import org.apache.fop.area.*;
+import org.apache.fop.fo.flow.Marker;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.BlockParent;
import java.util.ArrayList;
import java.util.List;
@@ -28,6 +27,8 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
/** Array of areas currently being filled stored by area class */
private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX];
+ int iStartPos = 0;
+
/**
* This is the top level layout manager.
* It is created by the PageSequence FO.
@@ -90,8 +91,6 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
return null;
}
- int iStartPos = 0;
-
public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
LayoutManager childLM;
@@ -111,7 +110,6 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
flush();
}
-
/**
* Add child area to a the correct container, depending on its
* area class. A Flow can fill at most one area container of any class
@@ -143,7 +141,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
*
* @see org.apache.fop.layoutmgr.LayoutManager
*/
- public LayoutManager retrieveMarker(String name, int pos, int boundary) {
+ public Marker retrieveMarker(String name, int pos, int boundary) {
// error cannot retrieve markers in flow
getLogger().error("Cannot retrieve a marker from the flow");
return null;
diff --git a/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java b/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
index 5377935d3..b1522bfa9 100644
--- a/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
@@ -509,10 +509,10 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
borderProps, bAreaCreated, !bIsLast);
if(borderProps != null) {
- addBorders(getCurrentArea(), borderProps);
+ TraitSetter.addBorders(getCurrentArea(), borderProps);
}
if(backgroundProps != null) {
- addBackground(getCurrentArea(), backgroundProps);
+ TraitSetter.addBackground(getCurrentArea(), backgroundProps);
}
parentLM.addChild(getCurrentArea());
diff --git a/src/org/apache/fop/layoutmgr/LayoutManager.java b/src/org/apache/fop/layoutmgr/LayoutManager.java
index 58a0adf73..771c36048 100644
--- a/src/org/apache/fop/layoutmgr/LayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/LayoutManager.java
@@ -9,11 +9,14 @@ package org.apache.fop.layoutmgr;
import org.apache.fop.fo.FOUserAgent;
import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.flow.Marker;
import org.apache.fop.area.Area;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.PageViewport;
+import java.util.Map;
+
/**
* The interface for all LayoutManagers.
*/
@@ -29,7 +32,8 @@ public interface LayoutManager {
public void setFObj(FObj obj);
/**
- * Set the user agent.
+ * Set the user agent. For resolving user agent values
+ * and getting logger.
*
* @param ua the user agent
*/
@@ -50,6 +54,9 @@ public interface LayoutManager {
*/
public void setParentLM(LayoutManager lm);
+ /**
+ * Initialise this layout manager.
+ */
public void init();
/**
@@ -64,27 +71,47 @@ public interface LayoutManager {
/**
* Return true if the next area which would be generated by this
* LayoutManager could start a new line (or flow for block-level FO).
+ *
+ * @param lc the layout context
+ * @return true if can break before
*/
public boolean canBreakBefore(LayoutContext lc);
/**
* Generate and return the next break possibility.
+ *
* @param context The layout context contains information about pending
* space specifiers from ancestor areas or previous areas, reference
* area inline-progression-dimension and various other layout-related
* information.
+ * @return the next break position
*/
public BreakPoss getNextBreakPoss(LayoutContext context);
-
+ /**
+ * Reset to the position.
+ *
+ * @param position
+ */
public void resetPosition(Position position);
+ /**
+ * Get the word chars between two positions and
+ * append to the string buffer. The positions could
+ * span multiple layout managers.
+ *
+ * @param sbChars the string buffer to append the word chars
+ * @param bp1 the start position
+ * @param bp2 the end position
+ */
public void getWordChars(StringBuffer sbChars, Position bp1,
Position bp2);
/**
* Return a value indicating whether this LayoutManager has laid out
* all its content (or generated BreakPossibilities for all content.)
+ *
+ * @return true if this layout manager is finished
*/
public boolean isFinished();
@@ -92,16 +119,37 @@ public interface LayoutManager {
* Set a flag indicating whether the LayoutManager has laid out all
* its content. This is generally called by the LM itself, but can
* be called by a parentLM when backtracking.
+ *
+ * @param isFinished the value to set the finished flag to
*/
public void setFinished(boolean isFinished);
+ /**
+ * Get the parent area for an area.
+ * This should get the parent depending on the class of the
+ * area passed in.
+ *
+ * @param childArea the child area to get the parent for
+ * @return the parent Area
+ */
public Area getParentArea(Area childArea);
+
+ /**
+ * Add the area as a child of the current area.
+ * This is called by child layout managers to add their
+ * areas as children of the current area.
+ *
+ * @param childArea the child area to add
+ */
public void addChild(Area childArea);
/**
* Tell the layout manager to add all the child areas implied
* by Position objects which will be returned by the
* Iterator.
+ *
+ * @param posIter the position iterator
+ * @param context the context
*/
public void addAreas(PositionIterator posIter, LayoutContext context);
@@ -148,7 +196,7 @@ public interface LayoutManager {
* @param lm the layout manager of the marker child
* @param start true if the formatting object is starting false is finishing
*/
- public void addMarker(String name, LayoutManager lm, boolean start);
+ public void addMarkerMap(Map marks, boolean start);
/**
* Retrieve a marker.
@@ -159,7 +207,6 @@ public interface LayoutManager {
* @param boundary the boundary for retrieving the marker
* @return the layout manaager of the retrieved marker if any
*/
- public LayoutManager retrieveMarker(String name, int pos, int boundary);
+ public Marker retrieveMarker(String name, int pos, int boundary);
}
-
diff --git a/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java b/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java
index 2b7631e8e..836460466 100644
--- a/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java
@@ -7,7 +7,6 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.fo.FObj;
import org.apache.fop.area.Area;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.fo.properties.VerticalAlign;
diff --git a/src/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/org/apache/fop/layoutmgr/LineLayoutManager.java
index bbcf29436..3b91ea810 100644
--- a/src/org/apache/fop/layoutmgr/LineLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/LineLayoutManager.java
@@ -7,31 +7,21 @@
package org.apache.fop.layoutmgr;
-
-import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.TextInfo;
import org.apache.fop.fo.PropertyManager;
import org.apache.fop.layout.MarginProps;
import org.apache.fop.layout.HyphenationProps;
import org.apache.fop.layout.hyphenation.Hyphenation;
import org.apache.fop.layout.hyphenation.Hyphenator;
import org.apache.fop.traits.BlockProps;
-import org.apache.fop.area.Area;
import org.apache.fop.area.LineArea;
-import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.Resolveable;
import org.apache.fop.fo.properties.TextAlign;
-import org.apache.fop.area.inline.Word;
-import org.apache.fop.area.inline.Space;
-import org.apache.fop.area.inline.Character;
-
import java.util.ListIterator;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
-
/**
* LayoutManager for lines. It builds one or more lines containing
* inline areas generated by its sub layout managers.
diff --git a/src/org/apache/fop/layoutmgr/MinOptMax.java b/src/org/apache/fop/layoutmgr/MinOptMax.java
index c9c02467f..2bba4021d 100644
--- a/src/org/apache/fop/layoutmgr/MinOptMax.java
+++ b/src/org/apache/fop/layoutmgr/MinOptMax.java
@@ -20,14 +20,29 @@ public class MinOptMax implements java.io.Serializable, Cloneable {
public int opt;
public int max;
+ /**
+ * New min/opt/max with zero values.
+ */
public MinOptMax() {
this(0);
}
+ /**
+ * New min/opt/max with one fixed value.
+ *
+ * @param val the value for min, opt and max
+ */
public MinOptMax(int val) {
this(val, val, val);
}
+ /**
+ * New min/opt/max with the three values.
+ *
+ * @param min the minimum value
+ * @param opt the optimum value
+ * @param max the maximum value
+ */
public MinOptMax(int min, int opt, int max) {
this.min = min;
this.opt = opt;
diff --git a/src/org/apache/fop/layoutmgr/PageLayoutManager.java b/src/org/apache/fop/layoutmgr/PageLayoutManager.java
index b0c407d6b..56cfd51ab 100644
--- a/src/org/apache/fop/layoutmgr/PageLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/PageLayoutManager.java
@@ -20,6 +20,7 @@ import org.apache.fop.area.Span;
import org.apache.fop.area.BeforeFloat;
import org.apache.fop.area.Footnote;
import org.apache.fop.area.Resolveable;
+import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.flow.StaticContent;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.Region;
@@ -29,6 +30,7 @@ import org.apache.fop.fo.properties.Constants;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
/**
* LayoutManager for a PageSequence and its flow.
@@ -264,12 +266,10 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
* @param lm the layout manager for the marker contents
* @param start true if starting marker area, false for ending
*/
- public void addMarker(String name, LayoutManager lm, boolean start) {
- if (start) {
- // add marker to page on area tree
- } else {
- // add end marker to page on area tree
- }
+ public void addMarkerMap(Map marks, boolean start) {
+ getLogger().debug("adding markers: " + marks + ":" + start);
+ // add markers to page on area tree
+ curPage.addMarkers(marks, start);
}
/**
@@ -280,9 +280,10 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
* @param boundary the boundary for locating the marker
* @return the layout manager for the marker contents
*/
- public LayoutManager retrieveMarker(String name, int pos, int boundary) {
+ public Marker retrieveMarker(String name, int pos, int boundary) {
// get marker from the current markers on area tree
- return null;
+ Marker mark = (Marker)curPage.getMarker(name, pos);
+ return mark;
}
/**
@@ -343,7 +344,6 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
protected void placeBeforeFloat(Area area) {
}
-
protected void placeSideFloat(Area area) {
}
diff --git a/src/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java b/src/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java
new file mode 100644
index 000000000..73bc4b02a
--- /dev/null
+++ b/src/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java
@@ -0,0 +1,123 @@
+/*
+ * $Id$
+ * Copyright (C) 2003 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
+package org.apache.fop.layoutmgr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.fop.area.Area;
+import org.apache.fop.fo.flow.Marker;
+
+/**
+ * LayoutManager for a block FO.
+ */
+public class RetrieveMarkerLayoutManager extends AbstractLayoutManager {
+ private LayoutManager replaceLM = null;
+ private boolean loaded = false;
+ private String name;
+
+ /**
+ * Create a new block container layout manager.
+ */
+ public RetrieveMarkerLayoutManager(String n, int pos, int bound) {
+ name = n;
+ }
+
+ public boolean generatesInlineAreas() {
+ loadLM();
+ if (replaceLM == null) {
+ return true;
+ }
+ return replaceLM.generatesInlineAreas();
+ }
+
+ public BreakPoss getNextBreakPoss(LayoutContext context) {
+ loadLM();
+ if (replaceLM == null) {
+ return null;
+ }
+ getLogger().debug("getting breaks");
+ return replaceLM.getNextBreakPoss(context);
+ }
+
+ public void addAreas(PositionIterator parentIter,
+ LayoutContext layoutContext) {
+
+ loadLM();
+ addID();
+ replaceLM.addAreas(parentIter, layoutContext);
+
+ }
+
+ public boolean isFinished() {
+ if (replaceLM == null) {
+ return true;
+ }
+ return replaceLM.isFinished();
+ }
+
+ public void setFinished(boolean fin) {
+ if (replaceLM != null) {
+ replaceLM.setFinished(fin);
+ }
+ }
+
+ protected void loadLM() {
+ if (loaded) {
+ return;
+ }
+ loaded = true;
+ if (replaceLM == null) {
+ List list = new ArrayList();
+ Marker marker = retrieveMarker(name, 0, 0);
+ marker.addLayoutManager(list);
+ if (list.size() > 0) {
+ replaceLM = (LayoutManager)list.get(0);
+ replaceLM.setParentLM(this);
+ replaceLM.init();
+ getLogger().debug("retrieved: " + replaceLM + ":" + list.size());
+ } else {
+ getLogger().debug("found no marker with name: " + name);
+ }
+ }
+ }
+
+ /**
+ * Get the parent area for children of this block container.
+ * This returns the current block container area
+ * and creates it if required.
+ *
+ * @see org.apache.fop.layoutmgr.LayoutManager#getParentArea(Area)
+ */
+ public Area getParentArea(Area childArea) {
+ return parentLM.getParentArea(childArea);
+ }
+
+ /**
+ * Add the child to the block container.
+ *
+ * @see org.apache.fop.layoutmgr.LayoutManager#addChild(Area)
+ */
+ public void addChild(Area childArea) {
+ parentLM.addChild(childArea);
+ }
+
+ public void resetPosition(Position resetPos) {
+ loadLM();
+ if (resetPos == null) {
+ reset(null);
+ }
+ if (replaceLM != null) {
+ replaceLM.resetPosition(resetPos);
+ }
+ loaded = false;
+ replaceLM = null;
+ }
+
+}
+
diff --git a/src/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
index afc1be872..25ce1ecd1 100644
--- a/src/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
@@ -7,7 +7,6 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.fo.FObj;
import org.apache.fop.area.RegionReference;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
diff --git a/src/org/apache/fop/layoutmgr/TextLayoutManager.java b/src/org/apache/fop/layoutmgr/TextLayoutManager.java
index acdf6715f..7223dc5df 100644
--- a/src/org/apache/fop/layoutmgr/TextLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/TextLayoutManager.java
@@ -7,22 +7,15 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.fo.FObj;
import org.apache.fop.fo.TextInfo;
import org.apache.fop.traits.SpaceVal;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.LineArea;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.Word;
import org.apache.fop.area.inline.Space;
import org.apache.fop.util.CharUtilities;
-import org.apache.fop.fo.properties.VerticalAlign;
-
-//import org.apache.fop.fo.properties.*;
import java.util.ArrayList;
-import java.util.List;
/**
* LayoutManager for text (a sequence of characters) which generates one
diff --git a/src/org/apache/fop/layoutmgr/TraitSetter.java b/src/org/apache/fop/layoutmgr/TraitSetter.java
index 0e2cb4f53..e21820664 100644
--- a/src/org/apache/fop/layoutmgr/TraitSetter.java
+++ b/src/org/apache/fop/layoutmgr/TraitSetter.java
@@ -11,6 +11,7 @@ import org.apache.fop.layout.BorderAndPadding;
import org.apache.fop.traits.BorderProps;
import org.apache.fop.area.Area;
import org.apache.fop.area.Trait;
+import org.apache.fop.layout.BackgroundProps;
public class TraitSetter {
@@ -66,4 +67,60 @@ public class TraitSetter {
}
}
+ /**
+ * Add borders to an area.
+ * Layout managers that create areas with borders can use this to
+ * add the borders to the area.
+ */
+ public static void addBorders(Area curBlock, BorderAndPadding bordProps) {
+ BorderProps bps = getBorderProps(bordProps, BorderAndPadding.TOP);
+ if(bps.width != 0) {
+ curBlock.addTrait(Trait.BORDER_BEFORE, bps);
+ }
+ bps = getBorderProps(bordProps, BorderAndPadding.BOTTOM);
+ if(bps.width != 0) {
+ curBlock.addTrait(Trait.BORDER_AFTER, bps);
+ }
+ bps = getBorderProps(bordProps, BorderAndPadding.LEFT);
+ if(bps.width != 0) {
+ curBlock.addTrait(Trait.BORDER_START, bps);
+ }
+ bps = getBorderProps(bordProps, BorderAndPadding.RIGHT);
+ if(bps.width != 0) {
+ curBlock.addTrait(Trait.BORDER_END, bps);
+ }
+ }
+
+ private static BorderProps getBorderProps(BorderAndPadding bordProps, int side) {
+ BorderProps bps;
+ bps = new BorderProps(bordProps.getBorderStyle(side),
+ bordProps.getBorderWidth(side, false),
+ bordProps.getBorderColor(side));
+ return bps;
+ }
+
+ /**
+ * Add background to an area.
+ * Layout managers that create areas with a background can use this to
+ * add the background to the area.
+ */
+ public static void addBackground(Area curBlock, BackgroundProps backProps) {
+ Trait.Background back = new Trait.Background();
+ back.color = backProps.backColor;
+
+ if(backProps.backImage != null) {
+ back.url = backProps.backImage;
+ back.repeat = backProps.backRepeat;
+ if(backProps.backPosHorizontal != null) {
+ back.horiz = backProps.backPosHorizontal.mvalue();
+ }
+ if(backProps.backPosVertical != null) {
+ back.vertical = backProps.backPosVertical.mvalue();
+ }
+ }
+
+ if(back.color != null || back.url != null) {
+ curBlock.addTrait(Trait.BACKGROUND, back);
+ }
+ }
}
diff --git a/src/org/apache/fop/layoutmgr/list/Item.java b/src/org/apache/fop/layoutmgr/list/Item.java
index c4ef485d4..1d59a210d 100644
--- a/src/org/apache/fop/layoutmgr/list/Item.java
+++ b/src/org/apache/fop/layoutmgr/list/Item.java
@@ -16,7 +16,7 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
@@ -169,10 +169,10 @@ public class Item extends BlockStackingLayoutManager {
}
if (borderProps != null) {
- addBorders(curBlockArea, borderProps);
+ TraitSetter.addBorders(curBlockArea, borderProps);
}
if (backgroundProps != null) {
- addBackground(curBlockArea, backgroundProps);
+ TraitSetter.addBackground(curBlockArea, backgroundProps);
}
flush();
diff --git a/src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
index 818f085d8..d22deee0f 100644
--- a/src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
@@ -16,7 +16,7 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
@@ -162,10 +162,10 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
}
if(borderProps != null) {
- addBorders(curBlockArea, borderProps);
+ TraitSetter.addBorders(curBlockArea, borderProps);
}
if(backgroundProps != null) {
- addBackground(curBlockArea, backgroundProps);
+ TraitSetter.addBackground(curBlockArea, backgroundProps);
}
flush();
diff --git a/src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
index b23455468..4eb983d71 100644
--- a/src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
@@ -16,7 +16,6 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
diff --git a/src/org/apache/fop/layoutmgr/table/Body.java b/src/org/apache/fop/layoutmgr/table/Body.java
index f4094460c..39a4111fc 100644
--- a/src/org/apache/fop/layoutmgr/table/Body.java
+++ b/src/org/apache/fop/layoutmgr/table/Body.java
@@ -16,7 +16,7 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
@@ -258,7 +258,7 @@ public class Body extends BlockStackingLayoutManager {
Area curBlockArea = new Block();
if(backgroundProps != null) {
- addBackground(curBlockArea, backgroundProps);
+ TraitSetter.addBackground(curBlockArea, backgroundProps);
}
return curBlockArea;
}
diff --git a/src/org/apache/fop/layoutmgr/table/Caption.java b/src/org/apache/fop/layoutmgr/table/Caption.java
index 0ddca6ac7..f795ed9d8 100644
--- a/src/org/apache/fop/layoutmgr/table/Caption.java
+++ b/src/org/apache/fop/layoutmgr/table/Caption.java
@@ -15,7 +15,6 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
diff --git a/src/org/apache/fop/layoutmgr/table/Cell.java b/src/org/apache/fop/layoutmgr/table/Cell.java
index 09541ca83..790f9eef2 100644
--- a/src/org/apache/fop/layoutmgr/table/Cell.java
+++ b/src/org/apache/fop/layoutmgr/table/Cell.java
@@ -16,7 +16,7 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
@@ -189,10 +189,10 @@ public class Cell extends BlockStackingLayoutManager {
}
if(borderProps != null) {
- addBorders(curBlockArea, borderProps);
+ TraitSetter.addBorders(curBlockArea, borderProps);
}
if(backgroundProps != null) {
- addBackground(curBlockArea, backgroundProps);
+ TraitSetter.addBackground(curBlockArea, backgroundProps);
}
curBlockArea.setHeight(height);
diff --git a/src/org/apache/fop/layoutmgr/table/Column.java b/src/org/apache/fop/layoutmgr/table/Column.java
index f49bf9de4..fac622e64 100644
--- a/src/org/apache/fop/layoutmgr/table/Column.java
+++ b/src/org/apache/fop/layoutmgr/table/Column.java
@@ -13,6 +13,7 @@ import org.apache.fop.layoutmgr.AbstractLayoutManager;
import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.fo.flow.TableColumn;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -103,7 +104,7 @@ public class Column extends AbstractLayoutManager {
Area curBlockArea = new Block();
if(backgroundProps != null) {
- addBackground(curBlockArea, backgroundProps);
+ TraitSetter.addBackground(curBlockArea, backgroundProps);
}
return curBlockArea;
}
diff --git a/src/org/apache/fop/layoutmgr/table/Row.java b/src/org/apache/fop/layoutmgr/table/Row.java
index a62b38654..c703a29e0 100644
--- a/src/org/apache/fop/layoutmgr/table/Row.java
+++ b/src/org/apache/fop/layoutmgr/table/Row.java
@@ -16,7 +16,7 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
@@ -367,7 +367,7 @@ public class Row extends BlockStackingLayoutManager {
public Area getRowArea() {
Area block = new Block();
if(backgroundProps != null) {
- addBackground(block, backgroundProps);
+ TraitSetter.addBackground(block, backgroundProps);
}
return block;
}
diff --git a/src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
index 2af0dea6b..d96273434 100644
--- a/src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
@@ -15,7 +15,6 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
diff --git a/src/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/org/apache/fop/layoutmgr/table/TableLayoutManager.java
index 7322d90b9..d3985ea35 100644
--- a/src/org/apache/fop/layoutmgr/table/TableLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/table/TableLayoutManager.java
@@ -16,7 +16,7 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.fo.FObj;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.MinOptMax;
@@ -288,10 +288,10 @@ public class TableLayoutManager extends BlockStackingLayoutManager {
curBlockArea.setHeight(tableHeight);
if(borderProps != null) {
- addBorders(curBlockArea, borderProps);
+ TraitSetter.addBorders(curBlockArea, borderProps);
}
if(backgroundProps != null) {
- addBackground(curBlockArea, backgroundProps);
+ TraitSetter.addBackground(curBlockArea, backgroundProps);
}
flush();