aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2007-11-04 10:48:30 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2007-11-04 10:48:30 +0000
commitbb838976f6f2fabd42c8c5d0f99523008c83488f (patch)
tree310e7c1fe6bd5fd83c0592844a7a786999d2c7a5 /src/java/org/apache
parentb4539a24234a1a79e64dcf8e360f67b6109283b9 (diff)
downloadxmlgraphics-fop-bb838976f6f2fabd42c8c5d0f99523008c83488f.tar.gz
xmlgraphics-fop-bb838976f6f2fabd42c8c5d0f99523008c83488f.zip
Added support for fo:markers on fo:inline and fo:basic-link.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@591756 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java30
-rw-r--r--src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java21
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java11
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java9
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java3
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java2
-rwxr-xr-xsrc/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java15
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java8
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java8
11 files changed, 70 insertions, 53 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
index 3bff264ee..64aec3d73 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
@@ -52,7 +52,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
/** Iterator for child LayoutManagers */
protected ListIterator fobjIter = null;
/** Marker map for markers related to this LayoutManager */
- protected Map markers = null;
+ private Map markers = null;
/** True if this LayoutManager has handled all of its content. */
private boolean bFinished = false;
@@ -352,8 +352,8 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
*/
public boolean isFirst(Position pos) {
//log.trace("isFirst() smallestPosNumberChecked=" + smallestPosNumberChecked + " " + pos);
- if (pos.getIndex() < 0) {
- throw new IllegalArgumentException("Only Positions with an index can be checked");
+ if (pos == null || pos.getIndex() < 0) {
+ throw new IllegalArgumentException("Only non-null Positions with an index can be checked");
}
if (pos.getIndex() == this.smallestPosNumberChecked) {
return true;
@@ -372,8 +372,8 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
*/
public boolean isLast(Position pos) {
//log.trace("isLast() lastGenPos=" + lastGeneratedPosition + " " + pos);
- if (pos.getIndex() < 0) {
- throw new IllegalArgumentException("Only Positions with an index can be checked");
+ if (pos == null || pos.getIndex() < 0) {
+ throw new IllegalArgumentException("Only non-null Positions with an index can be checked");
}
return (pos.getIndex() == this.lastGeneratedPosition
&& isFinished());
@@ -387,4 +387,24 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
Map atts = getFObj().getForeignAttributes();
targetArea.setForeignAttributes(atts);
}
+
+ /**
+ * Registers the FO's markers on the current PageViewport
+ */
+ protected void addMarkersToPage(boolean isStarting, boolean isFirst, boolean isLast) {
+ if (this.markers != null) {
+ getCurrentPV().addMarkers(
+ this.markers,
+ isStarting,
+ isFirst,
+ isLast);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return (super.toString() + "[fobj=" + fobj.toString() + "]");
+ }
+
+
}
diff --git a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
index aed12a687..80e0b74cc 100644
--- a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
+++ b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
@@ -57,7 +57,7 @@ public class AreaAdditionUtil {
LayoutManager lastLM = null;
Position firstPos = null;
Position lastPos = null;
-
+
// "unwrap" the NonLeafPositions stored in parentIter
// and put them in a new list;
LinkedList positionList = new LinkedList();
@@ -94,12 +94,15 @@ public class AreaAdditionUtil {
//doesn't give us that info.
}
- if (bslm != null && bslm.markers != null) {
- bslm.getCurrentPV().addMarkers(bslm.markers, true,
- bslm.isFirst(firstPos), bslm.isLast(lastPos));
+ if (bslm != null) {
+ bslm.addMarkersToPage(
+ true,
+ bslm.isFirst(firstPos),
+ bslm.isLast(lastPos));
}
StackingIter childPosIter = new StackingIter(positionList.listIterator());
+
while ((childLM = childPosIter.getNextChildLM()) != null) {
// TODO vh: the test above might be problematic in some cases. See comment in
// the TableCellLM.getNextKnuthElements method
@@ -117,10 +120,14 @@ public class AreaAdditionUtil {
lc.setStackLimit(layoutContext.getStackLimit());
childLM.addAreas(childPosIter, lc);
}
- if (bslm != null && bslm.markers != null) {
- bslm.getCurrentPV().addMarkers(bslm.markers, false,
- bslm.isFirst(firstPos), bslm.isLast(lastPos));
+
+ if (bslm != null) {
+ bslm.addMarkersToPage(
+ false,
+ bslm.isFirst(firstPos),
+ bslm.isLast(lastPos));
}
+
}
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index 9f2c7d8ac..9c3c8ce59 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -751,10 +751,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
getPSLM().addIDToPage(getBlockContainerFO().getId());
- if (markers != null) {
- getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
- }
-
+
+ addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
+
if (bcpos == null) {
if (bpUnit == 0) {
// the Positions in positionList were inside the elements
@@ -842,9 +841,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
bcpos.getBreaker().addContainedAreas();
}
- if (markers != null) {
- getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
- }
+ addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
TraitSetter.addSpaceBeforeAfter(viewportBlockArea, layoutContext.getSpaceAdjust(),
effSpaceBefore, effSpaceAfter);
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
index 597f41ad0..62e41ac16 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
@@ -309,9 +309,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
}
getPSLM().addIDToPage(getBlockFO().getId());
- if (markers != null) {
- getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
- }
+
+ addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
if (bpUnit == 0) {
// the Positions in positionList were inside the elements
@@ -395,9 +394,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
childLM.addAreas(childPosIter, lc);
}
- if (markers != null) {
- getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
- }
+ addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(),
effSpaceBefore, effSpaceAfter);
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index d4b332a18..dbc66b02a 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -381,7 +381,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
if (contentList.size() > 0) {
wrapPositionElements(contentList, returnList);
} else {
- //Empty fo:block, zero-length box makes sure the IDs are registered.
+ // Empty fo:block, zero-length box makes sure the IDs and/or markers
+ // are registered.
returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true));
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
index 0ec5dc180..22a01f9fb 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
@@ -369,7 +369,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
return holder instanceof LineArea;
}
- /* (non-Javadoc)
+ /**
* {@inheritDoc}
*/
public Position notifyPos(Position pos) {
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
index ec7734377..b10e41132 100755
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
@@ -450,6 +450,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
lastLM = pos.getPosition().getLM();
}*/
+ addMarkersToPage(
+ true,
+ !areaCreated,
+ lastPos == null || isLast(lastPos));
+
InlineArea parent = createArea(lastLM == null
|| lastLM instanceof InlineLevelLayoutManager);
parent.setBPD(alignmentContext.getHeight());
@@ -479,6 +484,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
prevLM = childLM;
}
+
/* If this LM has a trailing fence, resolve trailing space
* specs from descendants. Otherwise, propagate any trailing
* space specs to the parent LM via the layout context. If
@@ -487,6 +493,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
* must be the last area for the current LM too.
*/
boolean isLast = (getContext().isLastArea() && prevLM == lastChildLM);
+
if (hasTrailingFence(isLast)) {
addSpace(getCurrentArea(),
getContext().getTrailingSpace().resolve(false),
@@ -506,6 +513,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
setTraits(areaCreated, lastPos == null || !isLast(lastPos));
parentLM.addChildArea(getCurrentArea());
+ addMarkersToPage(
+ false,
+ !areaCreated,
+ lastPos == null || isLast(lastPos));
+
context.setFlags(LayoutContext.LAST_AREA, isLast);
areaCreated = true;
}
@@ -576,7 +588,4 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
getPSLM().addIDToPage(fobj.getId());
}
- public String toString() {
- return (this.getClass().getName() + "[fobj=" + fobj.toString() + "]");
- }
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
index fbeb61aa3..72dae25c3 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
@@ -48,8 +48,7 @@ public class WrapperLayoutManager extends LeafNodeLayoutManager {
// be called. The area must also be added to the tree, because
// determination of the X,Y position is done in the renderer.
InlineArea area = new InlineArea();
- String id = fobj.getId();
- if (id != null && id.length() > 0) {
+ if (fobj.hasId()) {
TraitSetter.setProducerID(area, fobj.getId());
}
return area;
@@ -64,8 +63,7 @@ public class WrapperLayoutManager extends LeafNodeLayoutManager {
* @param context the layout context for adding the area
*/
public void addAreas(PositionIterator posIter, LayoutContext context) {
- String id = fobj.getId();
- if (id != null && id.length() > 0) {
+ if (fobj.hasId()) {
addId();
InlineArea area = getEffectiveArea();
parentLM.addChildArea(area);
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
index 49e8b0df8..acd9bf718 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
@@ -191,9 +191,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager
}
}
- if (markers != null) {
- getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
- }
+ addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
StackingIter childPosIter = new StackingIter(positionList.listIterator());
while ((childLM = childPosIter.getNextChildLM()) != null) {
@@ -206,9 +204,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager
childLM.addAreas(childPosIter, lc);
}
- if (markers != null) {
- getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
- }
+ addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
// We are done with this area add the background
TraitSetter.addBackground(curBlockArea,
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
index a60fa17b7..e1171d6fd 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
@@ -153,9 +153,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager {
}
}
- if (markers != null) {
- getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
- }
+ addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
StackingIter childPosIter = new StackingIter(positionList.listIterator());
while ((childLM = childPosIter.getNextChildLM()) != null) {
@@ -168,10 +166,8 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager {
childLM.addAreas(childPosIter, lc);
}
- if (markers != null) {
- getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
- }
-
+ addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
+
flush();
curBlockArea = null;
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
index 41738ff62..7b7cb52b0 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
@@ -482,9 +482,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
}
}
- if (markers != null) {
- getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
- }
+ addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
// use the first and the last ListItemPosition to determine the
// corresponding indexes in the original labelList and bodyList
@@ -542,9 +540,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
curBlockArea.setBPD(savedBPD);
}
- if (markers != null) {
- getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
- }
+ addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
// We are done with this area add the background
TraitSetter.addBackground(curBlockArea,