You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2012/04/05 18:20:17 UTC
svn commit: r1309921 [23/42] - in
/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./ examples/embedding/
examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/
examples/embedding/java/embedding/tools/ examples/plan/src/org/apa...
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Thu Apr 5 16:19:19 2012
@@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFac
import org.apache.fop.area.Area;
import org.apache.fop.area.BlockParent;
import org.apache.fop.fo.pagination.Flow;
+import org.apache.fop.util.ListUtil;
/**
* LayoutManager for an fo:flow object.
@@ -61,22 +62,9 @@ public class FlowLayoutManager extends B
}
/** {@inheritDoc} */
+ @Override
public List getNextKnuthElements(LayoutContext context, int alignment) {
-
- List elements = new LinkedList();
-
- LayoutManager currentChildLM;
- while ((currentChildLM = getChildLM()) != null) {
- if (addChildElements(elements, currentChildLM, context, alignment) != null) {
- return elements;
- }
- }
-
- SpaceResolver.resolveElementList(elements);
- setFinished(true);
-
- assert !elements.isEmpty();
- return elements;
+ return getNextKnuthElements(context, alignment, null, null);
}
/**
@@ -84,46 +72,58 @@ public class FlowLayoutManager extends B
* of the node assigned to the LM.
* @param context the LayoutContext used to store layout information
* @param alignment the desired text alignment
- * @param positionAtIPDChange position at ipd change
- * @param restartAtLM restart at this layout manager
+ * @param restartPosition {@link Position} to restart from
+ * @param restartLM {@link LayoutManager} to restart from
* @return the list of KnuthElements
* @see LayoutManager#getNextKnuthElements(LayoutContext,int)
*/
- public List getNextKnuthElements(LayoutContext context, int alignment,
- Position positionAtIPDChange, LayoutManager restartAtLM) {
+ List getNextKnuthElements(LayoutContext context, int alignment,
+ Position restartPosition, LayoutManager restartLM) {
- List elements = new LinkedList();
+ List<ListElement> elements = new LinkedList<ListElement>();
- LayoutManager currentChildLM = positionAtIPDChange.getLM();
- if (currentChildLM == null) {
- throw new IllegalStateException(
- "Cannot find layout manager from where to re-start layout after IPD change");
- }
- if (restartAtLM != null && restartAtLM.getParent() == this) {
- currentChildLM = restartAtLM;
- setCurrentChildLM(currentChildLM);
- currentChildLM.reset();
- if (addChildElements(elements, currentChildLM, context, alignment) != null) {
- return elements;
+ boolean isRestart = (restartPosition != null);
+ // always reset in case of restart (exception: see below)
+ boolean doReset = isRestart;
+ LayoutManager currentChildLM;
+ Stack<LayoutManager> lmStack = new Stack<LayoutManager>();
+ if (isRestart) {
+ currentChildLM = restartPosition.getLM();
+ if (currentChildLM == null) {
+ throw new IllegalStateException("Cannot find layout manager to restart from");
}
- } else {
- Stack lmStack = new Stack();
- while (currentChildLM.getParent() != this) {
- lmStack.push(currentChildLM);
- currentChildLM = currentChildLM.getParent();
+ if (restartLM != null && restartLM.getParent() == this) {
+ currentChildLM = restartLM;
+ } else {
+ while (currentChildLM.getParent() != this) {
+ lmStack.push(currentChildLM);
+ currentChildLM = currentChildLM.getParent();
+ }
+ doReset = false;
}
setCurrentChildLM(currentChildLM);
- if (addChildElements(elements, currentChildLM, context, alignment, lmStack,
- positionAtIPDChange, restartAtLM) != null) {
- return elements;
- }
+ } else {
+ currentChildLM = getChildLM();
}
- while ((currentChildLM = getChildLM()) != null) {
- currentChildLM.reset(); // TODO won't work with forced breaks
- if (addChildElements(elements, currentChildLM, context, alignment) != null) {
- return elements;
+ while (currentChildLM != null) {
+ if (!isRestart || doReset) {
+ if (doReset) {
+ currentChildLM.reset(); // TODO won't work with forced breaks
+ }
+ if (addChildElements(elements, currentChildLM, context, alignment,
+ null, null, null) != null) {
+ return elements;
+ }
+ } else {
+ if (addChildElements(elements, currentChildLM, context, alignment, lmStack,
+ restartPosition, restartLM) != null) {
+ return elements;
+ }
+ // restarted; force reset as of next child
+ doReset = true;
}
+ currentChildLM = getChildLM();
}
SpaceResolver.resolveElementList(elements);
@@ -133,31 +133,28 @@ public class FlowLayoutManager extends B
return elements;
}
- private List addChildElements(List elements, LayoutManager childLM, LayoutContext context,
- int alignment) {
- return addChildElements(elements, childLM, context, alignment, null, null, null);
- }
-
- private List addChildElements(List elements, LayoutManager childLM, LayoutContext context,
- int alignment, Stack lmStack, Position position, LayoutManager restartAtLM) {
- if (handleSpanChange(childLM, elements, context)) {
+ private List<ListElement> addChildElements(List<ListElement> elements,
+ LayoutManager childLM, LayoutContext context, int alignment,
+ Stack<LayoutManager> lmStack, Position position, LayoutManager restartAtLM) {
+ if (handleSpanChange(childLM, context)) {
SpaceResolver.resolveElementList(elements);
return elements;
}
- LayoutContext childLC = new LayoutContext(0);
- List childrenElements = getNextChildElements(childLM, context, childLC, alignment, lmStack,
- position, restartAtLM);
+ LayoutContext childLC = makeChildLayoutContext(context);
+ List<ListElement> childElements
+ = getNextChildElements(childLM, context, childLC, alignment, lmStack,
+ position, restartAtLM);
if (elements.isEmpty()) {
context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
}
if (!elements.isEmpty()
- && !ElementListUtils.startsWithForcedBreak(childrenElements)) {
+ && !ElementListUtils.startsWithForcedBreak(childElements)) {
addInBetweenBreak(elements, context, childLC);
}
context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
- elements.addAll(childrenElements);
+ elements.addAll(childElements);
if (ElementListUtils.endsWithForcedBreak(elements)) {
// a descendant of this flow has break-before or break-after
@@ -170,7 +167,7 @@ public class FlowLayoutManager extends B
return null;
}
- private boolean handleSpanChange(LayoutManager childLM, List elements, LayoutContext context) {
+ private boolean handleSpanChange(LayoutManager childLM, LayoutContext context) {
int span = EN_NONE;
int disableColumnBalancing = EN_FALSE;
if (childLM instanceof BlockLayoutManager) {
@@ -196,32 +193,47 @@ public class FlowLayoutManager extends B
}
}
- private List getNextChildElements(LayoutManager childLM, LayoutContext context,
- LayoutContext childLC, int alignment, Stack lmStack, Position restartPosition,
- LayoutManager restartLM) {
+ /**
+ * Overridden to take into account the current page-master's
+ * writing-mode
+ * {@inheritDoc}
+ */
+ @Override
+ protected LayoutContext makeChildLayoutContext(LayoutContext context) {
+ LayoutContext childLC = new LayoutContext(0);
childLC.setStackLimitBP(context.getStackLimitBP());
childLC.setRefIPD(context.getRefIPD());
childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode());
+ return childLC;
+ }
- List childrenElements;
+ /**
+ * Overridden to wrap the child positions before returning the list
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<ListElement> getNextChildElements(LayoutManager childLM, LayoutContext context,
+ LayoutContext childLC, int alignment, Stack<LayoutManager> lmStack,
+ Position restartPosition, LayoutManager restartLM) {
+
+ List<ListElement> childElements;
if (lmStack == null) {
- childrenElements = childLM.getNextKnuthElements(childLC, alignment);
+ childElements = childLM.getNextKnuthElements(childLC, alignment);
} else {
- childrenElements = childLM.getNextKnuthElements(childLC,
- alignment, lmStack, restartPosition, restartLM);
+ childElements = childLM.getNextKnuthElements(childLC, alignment,
+ lmStack, restartPosition, restartLM);
}
- assert !childrenElements.isEmpty();
+ assert !childElements.isEmpty();
// "wrap" the Position inside each element
- List tempList = childrenElements;
- childrenElements = new LinkedList();
- wrapPositionElements(tempList, childrenElements);
- return childrenElements;
+ List tempList = childElements;
+ childElements = new LinkedList<ListElement>();
+ wrapPositionElements(tempList, childElements);
+ return childElements;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
log.debug(" FLM.negotiateBPDAdjustment> " + adj);
@@ -239,9 +251,8 @@ public class FlowLayoutManager extends B
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public void discardSpace(KnuthGlue spaceGlue) {
log.debug(" FLM.discardSpace> ");
@@ -255,26 +266,30 @@ public class FlowLayoutManager extends B
}
/** {@inheritDoc} */
+ @Override
public Keep getKeepTogether() {
return Keep.KEEP_AUTO;
}
/** {@inheritDoc} */
+ @Override
public Keep getKeepWithNext() {
return Keep.KEEP_AUTO;
}
/** {@inheritDoc} */
+ @Override
public Keep getKeepWithPrevious() {
return Keep.KEEP_AUTO;
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/ int alignment) {
- ListIterator oldListIterator = oldList.listIterator();
+ @Override
+ public List<KnuthElement> getChangedKnuthElements(List oldList, int alignment) {
+ ListIterator<KnuthElement> oldListIterator = oldList.listIterator();
KnuthElement returnedElement;
- List returnedList = new LinkedList();
- List returnList = new LinkedList();
+ List<KnuthElement> returnedList = new LinkedList<KnuthElement>();
+ List<KnuthElement> returnList = new LinkedList<KnuthElement>();
KnuthElement prevElement = null;
KnuthElement currElement = null;
int fromIndex = 0;
@@ -282,7 +297,7 @@ public class FlowLayoutManager extends B
// "unwrap" the Positions stored in the elements
KnuthElement oldElement;
while (oldListIterator.hasNext()) {
- oldElement = (KnuthElement)oldListIterator.next();
+ oldElement = oldListIterator.next();
if (oldElement.getPosition() instanceof NonLeafPosition) {
// oldElement was created by a descendant of this FlowLM
oldElement.setPosition((oldElement.getPosition()).getPosition());
@@ -296,7 +311,7 @@ public class FlowLayoutManager extends B
while (oldListIterator.hasNext()) {
- currElement = (KnuthElement) oldListIterator.next();
+ currElement = oldListIterator.next();
if (prevElement != null
&& prevElement.getLayoutManager() != currElement.getLayoutManager()) {
// prevElement is the last element generated by the same LM
@@ -314,8 +329,7 @@ public class FlowLayoutManager extends B
// add an infinite penalty to forbid a break between blocks
returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
new Position(this), false));
- } else if (!((KnuthElement) returnedList.get(returnedList
- .size() - 1)).isGlue()) {
+ } else if (!ListUtil.getLast(returnedList).isGlue()) {
// add a null penalty to allow a break between blocks
returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
}
@@ -331,9 +345,9 @@ public class FlowLayoutManager extends B
// "wrap" the Position stored in each element of returnedList
// and add elements to returnList
- ListIterator listIter = returnedList.listIterator();
+ ListIterator<KnuthElement> listIter = returnedList.listIterator();
while (listIter.hasNext()) {
- returnedElement = (KnuthElement)listIter.next();
+ returnedElement = listIter.next();
if (returnedElement.getLayoutManager() != this) {
returnedElement.setPosition(
new NonLeafPosition(this, returnedElement.getPosition()));
@@ -344,9 +358,8 @@ public class FlowLayoutManager extends B
return returnList;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
AreaAdditionUtil.addAreas(this, parentIter, layoutContext);
flush();
@@ -359,15 +372,15 @@ public class FlowLayoutManager extends B
*
* @param childArea the area to add
*/
+ @Override
public void addChildArea(Area childArea) {
getParentArea(childArea);
addChildToArea(childArea,
this.currentAreas[childArea.getAreaClass()]);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public Area getParentArea(Area childArea) {
BlockParent parentArea = null;
int aclass = childArea.getAreaClass();
@@ -392,6 +405,7 @@ public class FlowLayoutManager extends B
* Returns the IPD of the content area
* @return the IPD of the content area
*/
+ @Override
public int getContentAreaIPD() {
return getCurrentPV().getCurrentSpan().getColumnWidth();
}
@@ -400,11 +414,13 @@ public class FlowLayoutManager extends B
* Returns the BPD of the content area
* @return the BPD of the content area
*/
+ @Override
public int getContentAreaBPD() {
return getCurrentPV().getBodyRegion().getBPD();
}
/** {@inheritDoc} */
+ @Override
public boolean isRestartable() {
return true;
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java Thu Apr 5 16:19:19 2012
@@ -38,38 +38,36 @@ public class FootnoteBodyLayoutManager e
}
/** {@inheritDoc} */
+ @Override
public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
- LayoutManager childLM = null;
+ LayoutManager childLM;
LayoutManager lastLM = null;
LayoutContext lc = new LayoutContext(0);
// "unwrap" the NonLeafPositions stored in parentIter
// and put them in a new list;
- LinkedList positionList = new LinkedList();
+ LinkedList<Position> positionList = new LinkedList<Position>();
Position pos;
while (parentIter.hasNext()) {
- pos = (Position) parentIter.next();
- //log.trace("pos = " + pos.getClass().getName() + "; " + pos);
- Position innerPosition = pos;
+ pos = parentIter.next();
+ Position innerPosition;
if (pos instanceof NonLeafPosition) {
- innerPosition = ((NonLeafPosition) pos).getPosition();
+ innerPosition = pos.getPosition();
if (innerPosition.getLM() == this) {
// pos was created by this LM and was inside a penalty
// allowing or forbidding a page break
// nothing to do
- //log.trace(" penalty");
} else {
// innerPosition was created by another LM
positionList.add(innerPosition);
lastLM = innerPosition.getLM();
- //log.trace(" " + innerPosition.getClass().getName());
}
}
}
// the Positions in positionList were inside the elements
// created by the LineLM
- StackingIter childPosIter = new StackingIter(positionList.listIterator());
+ PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
while ((childLM = childPosIter.getNextChildLM()) != null) {
// set last area flag
@@ -81,6 +79,7 @@ public class FootnoteBodyLayoutManager e
}
/** {@inheritDoc} */
+ @Override
public void addChildArea(Area childArea) {
childArea.setAreaClass(Area.CLASS_FOOTNOTE);
parentLayoutManager.addChildArea(childArea);
@@ -92,16 +91,19 @@ public class FootnoteBodyLayoutManager e
}
/** {@inheritDoc} */
+ @Override
public Keep getKeepTogether() {
return getParentKeepTogether();
}
/** {@inheritDoc} */
+ @Override
public Keep getKeepWithNext() {
return Keep.KEEP_AUTO;
}
/** {@inheritDoc} */
+ @Override
public Keep getKeepWithPrevious() {
return Keep.KEEP_AUTO;
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java Thu Apr 5 16:19:19 2012
@@ -70,7 +70,8 @@ public class InlineKnuthSequence extends
return false;
}
// does the first element of the first paragraph add to an existing word?
- ListElement lastOldElement, firstNewElement;
+ ListElement lastOldElement;
+ ListElement firstNewElement;
lastOldElement = getLast();
firstNewElement = sequence.getElement(0);
if (firstNewElement.isBox() && !((KnuthElement) firstNewElement).isAuxiliary()
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java Thu Apr 5 16:19:19 2012
@@ -19,8 +19,6 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.fo.Constants;
-
/**
* An instance of this class represents information about a feasible
* breaking point; it does not represent any piece of content.
@@ -43,6 +41,9 @@ public class KnuthPenalty extends KnuthE
/** Used for flagged penalties. See Knuth algorithm. */
public static final int FLAGGED_PENALTY = 50;
+ /** Dummy, zero-width penalty */
+ public static final KnuthPenalty DUMMY_ZERO_PENALTY
+ = new KnuthPenalty(0, 0, false, null, true);
private int penalty;
private boolean penaltyFlagged;
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java Thu Apr 5 16:19:19 2012
@@ -22,7 +22,8 @@ package org.apache.fop.layoutmgr;
import java.util.List;
/**
- * A Knuth element position iterator.
+ * A dedicated {@link PositionIterator} that is backed by an iterator
+ * over a list of {@link KnuthElement}s.
*/
public class KnuthPossPosIter extends PositionIterator {
@@ -50,6 +51,7 @@ public class KnuthPossPosIter extends Po
// Check position < endPos
/** {@inheritDoc} */
+ @Override
protected boolean checkNext() {
if (iterCount > 0) {
return super.checkNext();
@@ -60,7 +62,8 @@ public class KnuthPossPosIter extends Po
}
/** {@inheritDoc} */
- public Object next() {
+ @Override
+ public Position next() {
--iterCount;
return super.next();
}
@@ -74,11 +77,13 @@ public class KnuthPossPosIter extends Po
}
/** {@inheritDoc} */
+ @Override
protected LayoutManager getLM(Object nextObj) {
return ((ListElement) nextObj).getLayoutManager();
}
/** {@inheritDoc} */
+ @Override
protected Position getPos(Object nextObj) {
return ((ListElement) nextObj).getPosition();
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthSequence.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthSequence.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/KnuthSequence.java Thu Apr 5 16:19:19 2012
@@ -19,12 +19,12 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.util.ListUtil;
-
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
+import org.apache.fop.util.ListUtil;
+
/**
* Represents a list of {@link KnuthElement Knuth elements}.
*/
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LMiter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LMiter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LMiter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LMiter.java Thu Apr 5 16:19:19 2012
@@ -24,10 +24,10 @@ import java.util.ListIterator;
import java.util.NoSuchElementException;
/** An iterator for layout managers. */
-public class LMiter implements ListIterator {
+public class LMiter implements ListIterator<LayoutManager> {
/** list of layout managers */
- protected List listLMs;
+ protected List<LayoutManager> listLMs;
/** current position in iteration */
protected int curPos = 0;
/** The LayoutManager to which this LMiter is attached **/
@@ -44,7 +44,7 @@ public class LMiter implements ListItera
/** {@inheritDoc} */
public boolean hasNext() {
- return (curPos < listLMs.size()) ? true : lp.createNextChildLMs(curPos);
+ return (curPos < listLMs.size()) || lp.createNextChildLMs(curPos);
}
/** {@inheritDoc} */
@@ -53,7 +53,7 @@ public class LMiter implements ListItera
}
/** {@inheritDoc} */
- public Object previous() throws NoSuchElementException {
+ public LayoutManager previous() throws NoSuchElementException {
if (curPos > 0) {
return listLMs.get(--curPos);
} else {
@@ -62,7 +62,7 @@ public class LMiter implements ListItera
}
/** {@inheritDoc} */
- public Object next() throws NoSuchElementException {
+ public LayoutManager next() throws NoSuchElementException {
if (curPos < listLMs.size()) {
return listLMs.get(curPos++);
} else {
@@ -82,12 +82,12 @@ public class LMiter implements ListItera
/** {@inheritDoc} */
- public void add(Object o) throws UnsupportedOperationException {
+ public void add(LayoutManager lm) throws UnsupportedOperationException {
throw new UnsupportedOperationException("LMiter doesn't support add");
}
/** {@inheritDoc} */
- public void set(Object o) throws UnsupportedOperationException {
+ public void set(LayoutManager lm) throws UnsupportedOperationException {
throw new UnsupportedOperationException("LMiter doesn't support set");
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutContext.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutContext.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutContext.java Thu Apr 5 16:19:19 2012
@@ -26,6 +26,7 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.layoutmgr.inline.AlignmentContext;
import org.apache.fop.layoutmgr.inline.HyphContext;
import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.traits.WritingMode;
/**
@@ -92,7 +93,7 @@ public class LayoutContext {
//overlap with refIPD. Need to investigate how best to refactor that.
/** the writing mode established by the nearest ancestor reference area */
- private int writingMode = Constants.EN_LR_TB;
+ private WritingMode writingMode = WritingMode.LR_TB;
/** Current pending space-after or space-end from preceding area */
private SpaceSpecifier trailingSpace;
@@ -564,7 +565,7 @@ public class LayoutContext {
* Get the writing mode of the relevant reference area.
* @return the applicable writing mode
*/
- public int getWritingMode() {
+ public WritingMode getWritingMode() {
return writingMode;
}
@@ -572,7 +573,7 @@ public class LayoutContext {
* Set the writing mode.
* @param writingMode the writing mode
*/
- public void setWritingMode(int writingMode) {
+ public void setWritingMode(WritingMode writingMode) {
this.writingMode = writingMode;
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutException.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutException.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutException.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutException.java Thu Apr 5 16:19:19 2012
@@ -22,8 +22,8 @@ package org.apache.fop.layoutmgr;
import java.util.Locale;
import org.apache.fop.events.Event;
-import org.apache.fop.events.EventFormatter;
import org.apache.fop.events.EventExceptionManager.ExceptionFactory;
+import org.apache.fop.events.EventFormatter;
/**
* Exception thrown by FOP if an unrecoverable layout error occurs. An example: An area overflows
@@ -97,7 +97,7 @@ public class LayoutException extends Run
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<LayoutException> getExceptionClass() {
return LayoutException.class;
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java Thu Apr 5 16:19:19 2012
@@ -20,6 +20,9 @@
package org.apache.fop.layoutmgr;
import java.util.List;
+
+import org.apache.fop.area.AreaTreeHandler;
+import org.apache.fop.area.Block;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.extensions.ExternalDocument;
import org.apache.fop.fo.pagination.Flow;
@@ -28,8 +31,6 @@ import org.apache.fop.fo.pagination.Side
import org.apache.fop.fo.pagination.StaticContent;
import org.apache.fop.fo.pagination.Title;
import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
-import org.apache.fop.area.AreaTreeHandler;
-import org.apache.fop.area.Block;
/**
* The interface for all LayoutManager makers
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java Thu Apr 5 16:19:19 2012
@@ -67,6 +67,7 @@ import org.apache.fop.fo.pagination.Side
import org.apache.fop.fo.pagination.StaticContent;
import org.apache.fop.fo.pagination.Title;
import org.apache.fop.layoutmgr.inline.BasicLinkLayoutManager;
+import org.apache.fop.layoutmgr.inline.BidiLayoutManager;
import org.apache.fop.layoutmgr.inline.CharacterLayoutManager;
import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
import org.apache.fop.layoutmgr.inline.ExternalGraphicLayoutManager;
@@ -246,28 +247,9 @@ public class LayoutManagerMapping implem
public static class BidiOverrideLayoutManagerMaker extends Maker {
/** {@inheritDoc} */
public void make(FONode node, List lms) {
- /* [GA] remove broken code
- if (false) {
- // this is broken; it does nothing
- // it should make something like an InlineStackingLM
- super.make(node, lms);
- } else {
- ArrayList childList = new ArrayList();
- // this is broken; it does nothing
- // it should make something like an InlineStackingLM
- super.make(node, childList);
- for (int count = childList.size() - 1; count >= 0; count--) {
- LayoutManager lm = (LayoutManager) childList.get(count);
- if (lm instanceof InlineLevelLayoutManager) {
- LayoutManager blm = new BidiLayoutManager
- ((BidiOverride) node, (InlineLayoutManager) lm);
- lms.add(blm);
- } else {
- lms.add(lm);
- }
- }
+ if ( node instanceof BidiOverride ) {
+ lms.add(new BidiLayoutManager((BidiOverride) node));
}
- */
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreaker.java Thu Apr 5 16:19:19 2012
@@ -277,9 +277,8 @@ public class PageBreaker extends Abstrac
separatorArea.setIPD(
pslm.getCurrentPV().getRegionReference(Constants.FO_REGION_BODY).getIPD());
// create a StaticContentLM for the footnote separator
- footnoteSeparatorLM = (StaticContentLayoutManager)
- pslm.getLayoutManagerMaker().makeStaticContentLayoutManager(
- pslm, footnoteSeparator, separatorArea);
+ footnoteSeparatorLM = pslm.getLayoutManagerMaker().makeStaticContentLayoutManager(
+ pslm, footnoteSeparator, separatorArea);
footnoteSeparatorLM.doLayout();
}
@@ -367,7 +366,9 @@ public class PageBreaker extends Abstrac
// Handle special page-master for last page
BodyRegion currentBody = pageProvider.getPage(false, currentPageNum)
.getPageViewport().getBodyRegion();
- pageProvider.setLastPageIndex(currentPageNum);
+
+ setLastPageIndex(currentPageNum);
+
BodyRegion lastBody = pageProvider.getPage(false, currentPageNum)
.getPageViewport().getBodyRegion();
lastBody.getMainReference().setSpans(currentBody.getMainReference().getSpans());
@@ -410,8 +411,8 @@ public class PageBreaker extends Abstrac
//Add areas now...
addAreas(alg, restartPoint, partCount - restartPoint, originalList, effectiveList);
//...and add a blank last page
- pageProvider.setLastPageIndex(currentPageNum + 1);
- pslm.setCurrentPage(pslm.makeNewPage(true, true));
+ setLastPageIndex(currentPageNum + 1);
+ pslm.setCurrentPage(pslm.makeNewPage(true));
return;
}
}
@@ -419,6 +420,11 @@ public class PageBreaker extends Abstrac
addAreas(algRestart, optimalPageCount, originalList, effectiveList);
}
+ private void setLastPageIndex(int currentPageNum) {
+ int lastPageIndex = pslm.getForcedLastPageNum(currentPageNum);
+ pageProvider.setLastPageIndex(lastPageIndex);
+ }
+
/** {@inheritDoc} */
protected void startPart(BlockSequence list, int breakClass) {
AbstractBreaker.log.debug("startPart() breakClass=" + getBreakClassName(breakClass));
@@ -529,14 +535,14 @@ public class PageBreaker extends Abstrac
if (forceNewPageWithSpan) {
log.trace("Forcing new page with span");
- curPage = pslm.makeNewPage(false, false);
+ curPage = pslm.makeNewPage(false);
curPage.getPageViewport().createSpan(true);
} else if (pv.getCurrentSpan().hasMoreFlows()) {
log.trace("Moving to next flow");
pv.getCurrentSpan().moveToNextFlow();
} else {
log.trace("Making new page");
- /*curPage = */pslm.makeNewPage(false, false);
+ /*curPage = */pslm.makeNewPage(false);
}
return;
default:
@@ -544,11 +550,11 @@ public class PageBreaker extends Abstrac
+ " breakVal=" + getBreakClassName(breakVal));
if (needBlankPageBeforeNew(breakVal)) {
log.trace("Inserting blank page");
- /*curPage = */pslm.makeNewPage(true, false);
+ /*curPage = */pslm.makeNewPage(true);
}
if (needNewPage(breakVal)) {
log.trace("Making new page");
- /*curPage = */pslm.makeNewPage(false, false);
+ /*curPage = */pslm.makeNewPage(false);
}
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java Thu Apr 5 16:19:19 2012
@@ -20,7 +20,6 @@
package org.apache.fop.layoutmgr;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -43,16 +42,16 @@ class PageBreakingAlgorithm extends Brea
private PageProvider pageProvider;
private PageBreakingLayoutListener layoutListener;
/** List of PageBreakPosition elements. */
- private LinkedList pageBreaks = null;
+ private LinkedList<PageBreakPosition> pageBreaks = null;
/** Footnotes which are cited between the currently considered active node (previous
* break) and the current considered break. Its type is
* List<List<KnuthElement>>, it contains the sequences of KnuthElement
* representing the footnotes bodies.
*/
- private List footnotesList = null;
+ private List<List<KnuthElement>> footnotesList = null;
/** Cumulated bpd of unhandled footnotes. */
- private List lengthList = null;
+ private List<Integer> lengthList = null;
/** Length of all the footnotes which will be put on the current page. */
private int totalFootnotesLength = 0;
/**
@@ -64,13 +63,9 @@ class PageBreakingAlgorithm extends Brea
/** True if footnote citations have been met since the beginning of the page sequence. */
private boolean footnotesPending = false;
- /**
- * True if the elements met after the previous break point contain footnote citations.
- */
+ /** True if the elements met after the previous break point contain footnote citations. */
private boolean newFootnotes = false;
- /**
- * Index of the first footnote met after the previous break point.
- */
+ /** Index of the first footnote met after the previous break point. */
private int firstNewFootnoteIndex = 0;
/** Index of the last footnote inserted on the current page. */
private int footnoteListIndex = 0;
@@ -206,6 +201,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected void initialize() {
super.initialize();
insertedFootnotesLength = 0;
@@ -214,11 +210,12 @@ class PageBreakingAlgorithm extends Brea
}
/**
- * {@inheritDoc}
* Overridden to defer a part to the next page, if it
* must be kept within one page, but is too large to fit in
* the last column.
+ * {@inheritDoc}
*/
+ @Override
protected KnuthNode recoverFromTooLong(KnuthNode lastTooLong) {
if (log.isDebugEnabled()) {
@@ -256,6 +253,7 @@ class PageBreakingAlgorithm extends Brea
* @param node2 The other knuth node.
* @return the node with the least demerit.
*/
+ @Override
protected KnuthNode compareNodes(KnuthNode node1, KnuthNode node2) {
/* if either node is null, return the other one */
@@ -281,6 +279,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected KnuthNode createNode(int position, // CSOK: ParameterNumber
int line, int fitness,
int totalWidth, int totalStretch, int totalShrink,
@@ -294,6 +293,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected KnuthNode createNode(int position, int line, int fitness,
int totalWidth, int totalStretch, int totalShrink) {
return new KnuthPageNode(position, line, fitness,
@@ -307,11 +307,11 @@ class PageBreakingAlgorithm extends Brea
}
/**
- * {@inheritDoc}
* Page-breaking specific handling of the given box. Currently it adds the footnotes
* cited in the given box to the list of to-be-handled footnotes.
- * @param box a block-level element possibly containing foonotes citations
+ * {@inheritDoc}
*/
+ @Override
protected void handleBox(KnuthBox box) {
super.handleBox(box);
if (box instanceof KnuthBlockBox
@@ -325,11 +325,12 @@ class PageBreakingAlgorithm extends Brea
}
/**
- * {@inheritDoc}
* Overridden to consider penalties with value {@link KnuthElement#INFINITE}
* as legal break-points, if the current keep-context allows this
* (a keep-*.within-page="always" constraint still permits column-breaks)
+ * {@inheritDoc}
*/
+ @Override
protected void handlePenaltyAt(KnuthPenalty penalty, int position,
int allowedBreaks) {
super.handlePenaltyAt(penalty, position, allowedBreaks);
@@ -352,12 +353,12 @@ class PageBreakingAlgorithm extends Brea
* @param elementLists list of KnuthElement sequences corresponding to the footnotes
* bodies
*/
- private void handleFootnotes(List elementLists) {
+ private void handleFootnotes(List<List<KnuthElement>> elementLists) {
// initialization
if (!footnotesPending) {
footnotesPending = true;
- footnotesList = new ArrayList();
- lengthList = new ArrayList();
+ footnotesList = new ArrayList<List<KnuthElement>>();
+ lengthList = new ArrayList<Integer>();
totalFootnotesLength = 0;
}
if (!newFootnotes) {
@@ -366,9 +367,7 @@ class PageBreakingAlgorithm extends Brea
}
// compute the total length of the footnotes
- for (Iterator elementListsIterator = elementLists.iterator();
- elementListsIterator.hasNext();) {
- final List noteList = (List) elementListsIterator.next();
+ for (List<KnuthElement> noteList : elementLists) {
//Space resolution (Note: this does not respect possible stacking constraints
//between footnotes!)
@@ -376,23 +375,23 @@ class PageBreakingAlgorithm extends Brea
int noteLength = 0;
footnotesList.add(noteList);
- for (Iterator noteListIterator = noteList.iterator();
- noteListIterator.hasNext();) {
- final KnuthElement element = (KnuthElement) noteListIterator.next();
+ for (KnuthElement element : noteList) {
if (element.isBox() || element.isGlue()) {
noteLength += element.getWidth();
}
}
int prevLength = (lengthList == null || lengthList.isEmpty())
? 0
- : ((Integer) ListUtil.getLast(lengthList)).intValue();
- //TODO: replace with Integer.valueOf() once we switch to Java 5
- lengthList.add(new Integer(prevLength + noteLength));
+ : ListUtil.getLast(lengthList);
+ if (lengthList != null) {
+ lengthList.add(prevLength + noteLength);
+ }
totalFootnotesLength += noteLength;
}
}
/** {@inheritDoc} */
+ @Override
protected int restartFrom(KnuthNode restartingNode, int currentIndex) {
int returnValue = super.restartFrom(restartingNode, currentIndex);
newFootnotes = false;
@@ -410,14 +409,14 @@ class PageBreakingAlgorithm extends Brea
return returnValue;
}
- private void resetFootnotes(List elementLists) {
+ private void resetFootnotes(List<List<KnuthElement>> elementLists) {
for (int i = 0; i < elementLists.size(); i++) {
- /*LinkedList removedList = (LinkedList)*/ListUtil.removeLast(footnotesList);
+ ListUtil.removeLast(footnotesList);
ListUtil.removeLast(lengthList);
// update totalFootnotesLength
if (!lengthList.isEmpty()) {
- totalFootnotesLength = ((Integer) ListUtil.getLast(lengthList)).intValue();
+ totalFootnotesLength = ListUtil.getLast(lengthList);
} else {
totalFootnotesLength = 0;
}
@@ -429,6 +428,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected void considerLegalBreak(KnuthElement element, int elementIdx) {
if (element.isPenalty()) {
int breakClass = ((KnuthPenalty) element).getBreakClass();
@@ -457,6 +457,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected boolean elementCanEndLine(KnuthElement element, int line, int difference) {
if (!(element.isPenalty()) || pageProvider == null) {
return true;
@@ -489,11 +490,12 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected int computeDifference(KnuthNode activeNode, KnuthElement element,
int elementIndex) {
KnuthPageNode pageNode = (KnuthPageNode) activeNode;
int actualWidth = totalWidth - pageNode.totalWidth;
- int footnoteSplit = 0;
+ int footnoteSplit;
boolean canDeferOldFN;
if (element.isPenalty()) {
actualWidth += element.getWidth();
@@ -562,6 +564,7 @@ class PageBreakingAlgorithm extends Brea
* @param node active node for the preceding page break
* @param contentElementIndex index of the Knuth element considered for the
* current page break
+ * @return true if footnotes can be deferred
*/
private boolean canDeferOldFootnotes(KnuthPageNode node, int contentElementIndex) {
return (noBreakBetween(node.position, contentElementIndex)
@@ -668,8 +671,8 @@ class PageBreakingAlgorithm extends Brea
// together with all previous, not yet inserted footnotes;
// but if this is not possible, try adding as much content as possible
int splitLength = 0;
- ListIterator noteListIterator = null;
- KnuthElement element = null;
+ ListIterator<KnuthElement> noteListIterator;
+ KnuthElement element;
boolean somethingAdded = false;
// prevListIndex and prevElementIndex points to the last footnote element
@@ -687,16 +690,14 @@ class PageBreakingAlgorithm extends Brea
if (footnotesList.size() - 1 > listIndex) {
// add the previous footnotes: these cannot be broken or deferred
if (!canDeferOldFootnotes && newFootnotes && firstNewFootnoteIndex > 0) {
- splitLength = ((Integer) lengthList.get(firstNewFootnoteIndex - 1)).intValue()
- - prevLength;
+ splitLength = lengthList.get(firstNewFootnoteIndex - 1) - prevLength;
listIndex = firstNewFootnoteIndex;
elementIndex = 0;
}
// try adding the new footnotes
- while (((Integer) lengthList.get(listIndex)).intValue() - prevLength
+ while (lengthList.get(listIndex) - prevLength
<= availableLength) {
- splitLength = ((Integer) lengthList.get(listIndex)).intValue()
- - prevLength;
+ splitLength = lengthList.get(listIndex) - prevLength;
somethingAdded = true;
listIndex++;
elementIndex = 0;
@@ -727,7 +728,7 @@ class PageBreakingAlgorithm extends Brea
// all footnotes, and we have already tried (and failed) to insert
// this whole footnote, the while loop will never reach the end
// of the note sequence
- element = (KnuthElement) noteListIterator.next();
+ element = noteListIterator.next();
if (element.isBox()) {
// element is a box
splitLength += element.getWidth();
@@ -774,6 +775,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected double computeAdjustmentRatio(KnuthNode activeNode, int difference) {
// compute the adjustment ratio
if (difference > 0) {
@@ -804,6 +806,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected double computeDemerits(KnuthNode activeNode, KnuthElement element,
int fitnessClass, double r) {
double demerits = 0;
@@ -856,6 +859,8 @@ class PageBreakingAlgorithm extends Brea
return demerits;
}
+ /** {@inheritDoc} */
+ @Override
protected void finish() {
for (int i = startLine; i < endLine; i++) {
for (KnuthPageNode node = (KnuthPageNode) getNode(i);
@@ -880,7 +885,7 @@ class PageBreakingAlgorithm extends Brea
// create pages containing the remaining footnote bodies
while (insertedFootnotesLength < totalFootnotesLength) {
- final int tmpLength = ((Integer) lengthList.get(footnoteListIndex)).intValue();
+ final int tmpLength = lengthList.get(footnoteListIndex);
// try adding some more content
if ((tmpLength - insertedFootnotesLength) <= availableBPD) {
// add a whole footnote
@@ -925,7 +930,7 @@ class PageBreakingAlgorithm extends Brea
* @return a list of {@link PageBreakPosition} elements
* corresponding to the computed page- and column-breaks
*/
- public LinkedList getPageBreaks() {
+ public LinkedList<PageBreakPosition> getPageBreaks() {
return pageBreaks;
}
@@ -937,7 +942,7 @@ class PageBreakingAlgorithm extends Brea
*/
public void insertPageBreakAsFirst(PageBreakPosition pageBreak) {
if (pageBreaks == null) {
- pageBreaks = new LinkedList();
+ pageBreaks = new LinkedList<PageBreakPosition>();
}
pageBreaks.addFirst(pageBreak);
}
@@ -948,19 +953,19 @@ class PageBreakingAlgorithm extends Brea
* whole content should be painted as one part.
*/
public void removeAllPageBreaks() {
- if (pageBreaks == null) {
+ if (pageBreaks == null || pageBreaks.isEmpty()) {
return;
}
- while (pageBreaks.size() > 1) {
- pageBreaks.removeFirst();
- }
+ pageBreaks.subList(0, pageBreaks.size() - 1).clear();
}
/** {@inheritDoc} */
+ @Override
public void updateData1(int total, double demerits) {
}
/** {@inheritDoc} */
+ @Override
public void updateData2(KnuthNode bestActiveNode,
KnuthSequence sequence,
int total) {
@@ -1029,6 +1034,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected int filterActiveNodes() {
// leave only the active node with fewest total demerits
KnuthNode bestActiveNode = null;
@@ -1058,8 +1064,8 @@ class PageBreakingAlgorithm extends Brea
* @param index the index in the list of footnotes
* @return the element-list
*/
- protected final List getFootnoteList(int index) {
- return (List) footnotesList.get(index);
+ protected final List<KnuthElement> getFootnoteList(int index) {
+ return footnotesList.get(index);
}
/** @return the associated top-level formatting object. */
@@ -1068,6 +1074,7 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected int getLineWidth(int line) {
int bpd;
if (pageProvider != null) {
@@ -1097,11 +1104,13 @@ class PageBreakingAlgorithm extends Brea
}
/** {@inheritDoc} */
+ @Override
protected int getIPDdifference() {
return ipdDifference;
}
/** {@inheritDoc} */
+ @Override
protected int handleIpdChange() {
log.trace("Best node for ipd change:" + bestNodeForIPDChange);
// TODO finish()
@@ -1123,6 +1132,7 @@ class PageBreakingAlgorithm extends Brea
* @param line number of the line ending at the node's corresponding breakpoint
* @param node the active node to add
*/
+ @Override
protected void addNode(int line, KnuthNode node) {
if (node.position < par.size() - 1 && line > 0
&& (ipdDifference = compareIPDs(line - 1)) != 0) { // CSOK: InnerAssignment
@@ -1153,5 +1163,4 @@ class PageBreakingAlgorithm extends Brea
}
return pageProvider.compareIPDs(line);
}
-
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageProvider.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageProvider.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageProvider.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageProvider.java Thu Apr 5 16:19:19 2012
@@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFac
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.pagination.PageSequence;
-import org.apache.fop.fo.pagination.Region;
import org.apache.fop.fo.pagination.SimplePageMaster;
/**
@@ -52,7 +51,7 @@ public class PageProvider implements Con
private int startPageOfCurrentElementList;
private int startColumnOfCurrentElementList;
private boolean spanAllForCurrentElementList;
- private List cachedPages = new java.util.ArrayList();
+ private List<Page> cachedPages = new java.util.ArrayList<Page>();
private int lastPageIndex = -1;
private int indexOfCachedLastPage = -1;
@@ -298,7 +297,7 @@ public class PageProvider implements Con
}
cacheNextPage(index, isBlank, isLastPage, this.spanAllForCurrentElementList);
}
- Page page = (Page)cachedPages.get(intIndex);
+ Page page = cachedPages.get(intIndex);
boolean replace = false;
if (page.getPageViewport().isBlank() != isBlank) {
log.debug("blank condition doesn't match. Replacing PageViewport.");
@@ -331,20 +330,11 @@ public class PageProvider implements Con
boolean isFirstPage = (startPageOfPageSequence == index);
SimplePageMaster spm = pageSeq.getNextSimplePageMaster(
index, isFirstPage, isLastPage, isBlank);
-
- Region body = spm.getRegion(FO_REGION_BODY);
- if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) {
- // this is fine by the XSL Rec (fo:flow's flow-name can be mapped to
- // any region), but we don't support it yet.
- BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
- pageSeq.getUserAgent().getEventBroadcaster());
- eventProducer.flowNotMappingToRegionBody(this,
- pageSeq.getMainFlow().getFlowName(), spm.getMasterName(), spm.getLocator());
- }
Page page = new Page(spm, index, pageNumberString, isBlank, spanAll);
//Set unique key obtained from the AreaTreeHandler
page.getPageViewport().setKey(areaTreeHandler.generatePageViewportKey());
page.getPageViewport().setForeignAttributes(spm.getForeignAttributes());
+ page.getPageViewport().setWritingModeTraits(pageSeq);
cachedPages.add(page);
return page;
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java Thu Apr 5 16:19:19 2012
@@ -25,6 +25,8 @@ import org.apache.commons.logging.LogFac
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.AreaTreeModel;
import org.apache.fop.area.LineArea;
+import org.apache.fop.complexscripts.bidi.BidiResolver;
+import org.apache.fop.fo.Constants;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.PageSequenceMaster;
import org.apache.fop.fo.pagination.SideRegion;
@@ -77,12 +79,16 @@ public class PageSequenceLayoutManager e
public void activateLayout() {
initialize();
- LineArea title = null;
+ // perform step 5.8 of refinement process (Unicode BIDI Processing)
+ if ( areaTreeHandler.isComplexScriptFeaturesEnabled() ) {
+ BidiResolver.resolveInlineDirectionality(getPageSequence());
+ }
+ LineArea title = null;
if (getPageSequence().getTitleFO() != null) {
try {
- ContentLayoutManager clm = getLayoutManagerMaker().
- makeContentLayoutManager(this, getPageSequence().getTitleFO());
+ ContentLayoutManager clm = getLayoutManagerMaker()
+ .makeContentLayoutManager(this, getPageSequence().getTitleFO());
title = (LineArea) clm.getParentArea(null);
} catch (IllegalStateException e) {
// empty title; do nothing
@@ -100,7 +106,7 @@ public class PageSequenceLayoutManager e
log.debug("Starting layout");
}
- curPage = makeNewPage(false, false);
+ curPage = makeNewPage(false);
PageBreaker breaker = new PageBreaker(this);
int flowBPD = getCurrentPV().getBodyRegion().getRemainingBPD();
@@ -140,6 +146,24 @@ public class PageSequenceLayoutManager e
pageNumber, PageProvider.RELTO_PAGE_SEQUENCE);
}
+ @Override
+ protected Page makeNewPage(boolean isBlank) {
+ Page newPage = super.makeNewPage(isBlank);
+
+ // Empty pages (pages that have been generated from a SPM that has an un-mapped flow name)
+ // cannot layout areas from the main flow. Blank pages can be created from empty pages.
+
+ if (!isBlank) {
+ while (!getPageSequence().getMainFlow().getFlowName()
+ .equals(newPage.getSimplePageMaster()
+ .getRegion(FO_REGION_BODY).getRegionName())) {
+ newPage = super.makeNewPage(isBlank);
+ }
+ }
+
+ return newPage;
+ }
+
private void layoutSideRegion(int regionID) {
SideRegion reg = (SideRegion)curPage.getSimplePageMaster().getRegion(regionID);
if (reg == null) {
@@ -167,4 +191,24 @@ public class PageSequenceLayoutManager e
super.finishPage();
}
+ /**
+ * The last page number of the sequence may be incremented, as determined by the
+ * force-page-count formatting property semantics
+ * @param lastPageNum number of sequence
+ * @return the forced last page number of sequence
+ */
+ protected int getForcedLastPageNum(final int lastPageNum) {
+ int forcedLastPageNum = lastPageNum;
+ if ( lastPageNum % 2 != 0
+ && ( getPageSequence().getForcePageCount() == Constants.EN_EVEN
+ || getPageSequence().getForcePageCount() == Constants.EN_END_ON_EVEN )) {
+ forcedLastPageNum++;
+ } else if ( lastPageNum % 2 == 0 && (
+ getPageSequence().getForcePageCount() == Constants.EN_ODD
+ || getPageSequence().getForcePageCount() == Constants.EN_END_ON_ODD )) {
+ forcedLastPageNum++;
+ }
+ return forcedLastPageNum;
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/Position.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/Position.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/Position.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/Position.java Thu Apr 5 16:19:19 2012
@@ -48,14 +48,39 @@ public class Position {
}
/**
- * Overridden by NonLeafPosition to return the Position of its
- * child LM.
+ * @param depth the depth at which the LM in this position is found
+ * @return associated layout manager
+ */
+ public LayoutManager getLM(int depth) {
+ Position subPos = getPosition(depth);
+ if (subPos == null) {
+ return null;
+ } else {
+ return subPos.getLM();
+ }
+ }
+
+ /**
+ * Overridden by NonLeafPosition to return the Position of its child LM.
* @return a position or null
*/
public Position getPosition() {
return null;
}
+ /**
+ * Overridden by NonLeafPosition to return the Position of its child LM.
+ * @param depth the depth at which the position in this position is found
+ * @return a position or null
+ */
+ public Position getPosition(int depth) {
+ Position subPos = this;
+ for (int i = 0; i < depth && subPos != null; ++i, subPos = subPos.getPosition()) {
+ // no-op
+ }
+ return subPos;
+ }
+
/** @return true if generates areas */
public boolean generatesAreas() {
return false;
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PositionIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PositionIterator.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PositionIterator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/PositionIterator.java Thu Apr 5 16:19:19 2012
@@ -22,20 +22,29 @@ package org.apache.fop.layoutmgr;
import java.util.Iterator;
import java.util.NoSuchElementException;
-/** A position iterator. */
-public abstract class PositionIterator implements Iterator {
+/**
+ * An iterator over {@link Position} instances, that is wrapped around
+ * another 'parent' {@link Iterator}. The parent can be either another
+ * {@code PositionIterator}, or an iterator over {@link KnuthElement}s,
+ * for example.<br/>
+ * The {@link #next()} method always returns a {@link Position}. The
+ * {@link #getPos(Object)} method can be overridden in subclasses
+ * to take care of obtaining the {@link LayoutManager} or {@link Position}
+ * from the object returned by the parent iterator's {@code next()} method.
+ */
+public class PositionIterator implements Iterator<Position> {
private Iterator parentIter;
private Object nextObj;
private LayoutManager childLM;
- private boolean bHasNext;
+ private boolean hasNext;
/**
* Construct position iterator.
- * @param pIter an iterator to use as parent
+ * @param parentIter an iterator to use as parent
*/
- protected PositionIterator(Iterator pIter) {
- parentIter = pIter;
+ public PositionIterator(Iterator parentIter) {
+ this.parentIter = parentIter;
lookAhead();
//checkNext();
}
@@ -45,7 +54,7 @@ public abstract class PositionIterator i
// Move to next "segment" of iterator, ie: new childLM
if (childLM == null && nextObj != null) {
childLM = getLM(nextObj);
- bHasNext = true;
+ hasNext = true;
}
return childLM;
}
@@ -54,17 +63,29 @@ public abstract class PositionIterator i
* @param nextObj next object from which to obtain position
* @return layout manager
*/
- protected abstract LayoutManager getLM(Object nextObj);
+ protected LayoutManager getLM(Object nextObj) {
+ return getPos(nextObj).getLM();
+ }
/**
+ * Default implementation assumes that the passed
+ * {@code nextObj} is itself a {@link Position}, and just returns it.
+ * Subclasses for which this is not the case, <em>must</em> provide a
+ * suitable override this method.
* @param nextObj next object from which to obtain position
- * @return position of next object
+ * @return position of next object.
*/
- protected abstract Position getPos(Object nextObj);
+ protected Position getPos(Object nextObj) {
+ if (nextObj instanceof Position) {
+ return (Position)nextObj;
+ }
+ throw new IllegalArgumentException(
+ "Cannot obtain Position from the given object.");
+ }
private void lookAhead() {
if (parentIter.hasNext()) {
- bHasNext = true;
+ hasNext = true;
nextObj = parentIter.next();
} else {
endIter();
@@ -78,7 +99,7 @@ public abstract class PositionIterator i
childLM = lm;
} else if (childLM != lm && lm != null) {
// End of this sub-sequence with same child LM
- bHasNext = false;
+ hasNext = false;
childLM = null;
return false;
}
@@ -87,23 +108,23 @@ public abstract class PositionIterator i
/** end (reset) iterator */
protected void endIter() {
- bHasNext = false;
+ hasNext = false;
nextObj = null;
childLM = null;
}
/** {@inheritDoc} */
public boolean hasNext() {
- return (bHasNext && checkNext());
+ return (hasNext && checkNext());
}
/** {@inheritDoc} */
- public Object next() throws NoSuchElementException {
- if (bHasNext) {
- Object retObj = getPos(nextObj);
+ public Position next() throws NoSuchElementException {
+ if (hasNext) {
+ Position retPos = getPos(nextObj);
lookAhead();
- return retObj;
+ return retPos;
} else {
throw new NoSuchElementException("PosIter");
}
@@ -119,4 +140,3 @@ public abstract class PositionIterator i
throw new UnsupportedOperationException("PositionIterator doesn't support remove");
}
}
-
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/SpaceResolver.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/SpaceResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/SpaceResolver.java Thu Apr 5 16:19:19 2012
@@ -136,7 +136,7 @@ public final class SpaceResolver {
private String toString(Object[] arr1, Object[] arr2) {
if (arr1.length != arr2.length) {
- new IllegalArgumentException("The length of both arrays must be equal");
+ throw new IllegalArgumentException("The length of both arrays must be equal");
}
StringBuffer sb = new StringBuffer("[");
for (int i = 0; i < arr1.length; i++) {
@@ -647,7 +647,7 @@ public final class SpaceResolver {
}
}
//last = !iter.hasNext();
- if (breakPoss == null && unresolvedSecond.size() == 0 && !last) {
+ if (breakPoss == null && unresolvedSecond.isEmpty() && !last) {
LOG.trace("Swap first and second parts in no-break condition,"
+ " second part is empty.");
//The first list is reversed, so swap if this shouldn't happen
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java Thu Apr 5 16:19:19 2012
@@ -19,10 +19,11 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.traits.SpaceVal;
import java.util.ArrayList;
import java.util.List;
+
import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.traits.SpaceVal;
/**
* Accumulate a sequence of space-specifiers (XSL space type) on
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java Thu Apr 5 16:19:19 2012
@@ -47,4 +47,4 @@ public interface TopLevelLayoutManager {
*/
void finishPageSequence();
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/TraitSetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/TraitSetter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/TraitSetter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/TraitSetter.java Thu Apr 5 16:19:19 2012
@@ -22,6 +22,7 @@ package org.apache.fop.layoutmgr;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.accessibility.StructureTreeElement;
import org.apache.fop.area.Area;
import org.apache.fop.area.Trait;
import org.apache.fop.datatypes.LengthBase;
@@ -29,9 +30,9 @@ import org.apache.fop.datatypes.PercentB
import org.apache.fop.datatypes.SimplePercentBaseContext;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
import org.apache.fop.fo.properties.CommonMarginBlock;
import org.apache.fop.fo.properties.CommonTextDecoration;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
import org.apache.fop.fonts.Font;
import org.apache.fop.traits.BorderProps;
import org.apache.fop.traits.MinOptMax;
@@ -52,36 +53,36 @@ public final class TraitSetter {
*
* @param area area to set the traits on
* @param bpProps border and padding properties
- * @param bNotFirst True if the area is not the first area
- * @param bNotLast True if the area is not the last area
+ * @param isNotFirst True if the area is not the first area
+ * @param isNotLast True if the area is not the last area
* @param context Property evaluation context
*/
public static void setBorderPaddingTraits(Area area,
- CommonBorderPaddingBackground bpProps, boolean bNotFirst, boolean bNotLast,
+ CommonBorderPaddingBackground bpProps, boolean isNotFirst, boolean isNotLast,
PercentBaseContext context) {
- int iBP;
- iBP = bpProps.getPadding(CommonBorderPaddingBackground.START, bNotFirst, context);
- if (iBP > 0) {
- area.addTrait(Trait.PADDING_START, new Integer(iBP));
+ int padding;
+ padding = bpProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, context);
+ if (padding > 0) {
+ area.addTrait(Trait.PADDING_START, padding);
}
- iBP = bpProps.getPadding(CommonBorderPaddingBackground.END, bNotLast, context);
- if (iBP > 0) {
- area.addTrait(Trait.PADDING_END, new Integer(iBP));
+ padding = bpProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, context);
+ if (padding > 0) {
+ area.addTrait(Trait.PADDING_END, padding);
}
- iBP = bpProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, context);
- if (iBP > 0) {
- area.addTrait(Trait.PADDING_BEFORE, new Integer(iBP));
+ padding = bpProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, context);
+ if (padding > 0) {
+ area.addTrait(Trait.PADDING_BEFORE, padding);
}
- iBP = bpProps.getPadding(CommonBorderPaddingBackground.AFTER, false, context);
- if (iBP > 0) {
- area.addTrait(Trait.PADDING_AFTER, new Integer(iBP));
+ padding = bpProps.getPadding(CommonBorderPaddingBackground.AFTER, false, context);
+ if (padding > 0) {
+ area.addTrait(Trait.PADDING_AFTER, padding);
}
- addBorderTrait(area, bpProps, bNotFirst,
+ addBorderTrait(area, bpProps, isNotFirst,
CommonBorderPaddingBackground.START,
BorderProps.SEPARATE, Trait.BORDER_START);
- addBorderTrait(area, bpProps, bNotLast,
+ addBorderTrait(area, bpProps, isNotLast,
CommonBorderPaddingBackground.END,
BorderProps.SEPARATE, Trait.BORDER_END);
@@ -94,7 +95,7 @@ public final class TraitSetter {
BorderProps.SEPARATE, Trait.BORDER_AFTER);
}
- /**
+ /*
* Sets border traits on an area.
*
* @param area area to set the traits on
@@ -103,13 +104,13 @@ public final class TraitSetter {
*/
private static void addBorderTrait(Area area,
CommonBorderPaddingBackground bpProps,
- boolean bDiscard, int iSide, int mode,
- Object oTrait) {
- int iBP = bpProps.getBorderWidth(iSide, bDiscard);
- if (iBP > 0) {
- area.addTrait(oTrait,
- new BorderProps(bpProps.getBorderStyle(iSide),
- iBP, bpProps.getBorderColor(iSide),
+ boolean discard, int side, int mode,
+ Integer trait) {
+ int borderWidth = bpProps.getBorderWidth(side, discard);
+ if (borderWidth > 0) {
+ area.addTrait(trait,
+ new BorderProps(bpProps.getBorderStyle(side),
+ borderWidth, bpProps.getBorderColor(side),
mode));
}
}
@@ -119,30 +120,30 @@ public final class TraitSetter {
* Layout managers that create areas with borders can use this to
* add the borders to the area.
* @param area the area to set the traits on.
- * @param bordProps border properties
+ * @param borderProps border properties
* @param context Property evaluation context
* @deprecated Call the other addBorders() method and addPadding separately.
*/
- public static void addBorders(Area area, CommonBorderPaddingBackground bordProps,
+ public static void addBorders(Area area, CommonBorderPaddingBackground borderProps,
PercentBaseContext context) {
- BorderProps bps = getBorderProps(bordProps, CommonBorderPaddingBackground.BEFORE);
+ BorderProps bps = getBorderProps(borderProps, CommonBorderPaddingBackground.BEFORE);
if (bps != null) {
area.addTrait(Trait.BORDER_BEFORE, bps);
}
- bps = getBorderProps(bordProps, CommonBorderPaddingBackground.AFTER);
+ bps = getBorderProps(borderProps, CommonBorderPaddingBackground.AFTER);
if (bps != null) {
area.addTrait(Trait.BORDER_AFTER, bps);
}
- bps = getBorderProps(bordProps, CommonBorderPaddingBackground.START);
+ bps = getBorderProps(borderProps, CommonBorderPaddingBackground.START);
if (bps != null) {
area.addTrait(Trait.BORDER_START, bps);
}
- bps = getBorderProps(bordProps, CommonBorderPaddingBackground.END);
+ bps = getBorderProps(borderProps, CommonBorderPaddingBackground.END);
if (bps != null) {
area.addTrait(Trait.BORDER_END, bps);
}
- addPadding(area, bordProps, context);
+ addPadding(area, borderProps, context);
}
/**
@@ -150,30 +151,31 @@ public final class TraitSetter {
* Layout managers that create areas with borders can use this to
* add the borders to the area.
* @param area the area to set the traits on.
- * @param bordProps border properties
+ * @param borderProps border properties
* @param discardBefore true if the before border should be discarded
* @param discardAfter true if the after border should be discarded
* @param discardStart true if the start border should be discarded
* @param discardEnd true if the end border should be discarded
* @param context Property evaluation context
*/
- public static void addBorders(Area area, CommonBorderPaddingBackground bordProps,
+ //TODO: remove evaluation context; unused, since border-widths are always absolute lengths
+ public static void addBorders(Area area, CommonBorderPaddingBackground borderProps,
boolean discardBefore, boolean discardAfter,
boolean discardStart, boolean discardEnd,
PercentBaseContext context) {
- BorderProps bps = getBorderProps(bordProps, CommonBorderPaddingBackground.BEFORE);
+ BorderProps bps = getBorderProps(borderProps, CommonBorderPaddingBackground.BEFORE);
if (bps != null && !discardBefore) {
area.addTrait(Trait.BORDER_BEFORE, bps);
}
- bps = getBorderProps(bordProps, CommonBorderPaddingBackground.AFTER);
+ bps = getBorderProps(borderProps, CommonBorderPaddingBackground.AFTER);
if (bps != null && !discardAfter) {
area.addTrait(Trait.BORDER_AFTER, bps);
}
- bps = getBorderProps(bordProps, CommonBorderPaddingBackground.START);
+ bps = getBorderProps(borderProps, CommonBorderPaddingBackground.START);
if (bps != null && !discardStart) {
area.addTrait(Trait.BORDER_START, bps);
}
- bps = getBorderProps(bordProps, CommonBorderPaddingBackground.END);
+ bps = getBorderProps(borderProps, CommonBorderPaddingBackground.END);
if (bps != null && !discardEnd) {
area.addTrait(Trait.BORDER_END, bps);
}
@@ -237,25 +239,25 @@ public final class TraitSetter {
int padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE,
discardBefore, context);
if (padding != 0) {
- area.addTrait(Trait.PADDING_BEFORE, new java.lang.Integer(padding));
+ area.addTrait(Trait.PADDING_BEFORE, padding);
}
padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER,
discardAfter, context);
if (padding != 0) {
- area.addTrait(Trait.PADDING_AFTER, new java.lang.Integer(padding));
+ area.addTrait(Trait.PADDING_AFTER, padding);
}
padding = bordProps.getPadding(CommonBorderPaddingBackground.START,
discardStart, context);
if (padding != 0) {
- area.addTrait(Trait.PADDING_START, new java.lang.Integer(padding));
+ area.addTrait(Trait.PADDING_START, padding);
}
padding = bordProps.getPadding(CommonBorderPaddingBackground.END,
discardEnd, context);
if (padding != 0) {
- area.addTrait(Trait.PADDING_END, new java.lang.Integer(padding));
+ area.addTrait(Trait.PADDING_END, padding);
}
}
@@ -278,9 +280,8 @@ public final class TraitSetter {
assert borderInfo != null;
int width = borderInfo.getRetainedWidth();
if (width != 0) {
- BorderProps bps = new BorderProps(borderInfo.getStyle(), width, borderInfo.getColor(),
+ return new BorderProps(borderInfo.getStyle(), width, borderInfo.getColor(),
(outer ? BorderProps.COLLAPSE_OUTER : BorderProps.COLLAPSE_INNER));
- return bps;
} else {
return null;
}
@@ -460,24 +461,24 @@ public final class TraitSetter {
int startIndent, int endIndent,
PercentBaseContext context) {
if (startIndent != 0) {
- area.addTrait(Trait.START_INDENT, new Integer(startIndent));
+ area.addTrait(Trait.START_INDENT, startIndent);
}
int spaceStart = startIndent
- bpProps.getBorderStartWidth(false)
- bpProps.getPaddingStart(false, context);
if (spaceStart != 0) {
- area.addTrait(Trait.SPACE_START, new Integer(spaceStart));
+ area.addTrait(Trait.SPACE_START, spaceStart);
}
if (endIndent != 0) {
- area.addTrait(Trait.END_INDENT, new Integer(endIndent));
+ area.addTrait(Trait.END_INDENT, endIndent);
}
int spaceEnd = endIndent
- bpProps.getBorderEndWidth(false)
- bpProps.getPaddingEnd(false, context);
if (spaceEnd != 0) {
- area.addTrait(Trait.SPACE_END, new Integer(spaceEnd));
+ area.addTrait(Trait.SPACE_END, spaceEnd);
}
}
@@ -537,7 +538,7 @@ public final class TraitSetter {
MinOptMax space, double adjust) {
int effectiveSpace = getEffectiveSpace(adjust, space);
if (effectiveSpace != 0) {
- area.addTrait(spaceTrait, new Integer(effectiveSpace));
+ area.addTrait(spaceTrait, effectiveSpace);
}
}
@@ -561,7 +562,7 @@ public final class TraitSetter {
*/
public static void addFontTraits(Area area, Font font) {
area.addTrait(Trait.FONT, font.getFontTriplet());
- area.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize()));
+ area.addTrait(Trait.FONT_SIZE, font.getFontSize());
}
/**
@@ -591,13 +592,15 @@ public final class TraitSetter {
}
/**
- * Adds the ptr trait to the area.
+ * Sets the structure tree element associated to the given area.
+ *
* @param area the area to set the traits on
- * @param ptr string
+ * @param structureTreeElement the element the area is associated to in the document structure
*/
- public static void addPtr(Area area, String ptr) {
- if (ptr != null && ptr.length() > 0) {
- area.addTrait(Trait.PTR, ptr);
+ public static void addStructureTreeElement(Area area,
+ StructureTreeElement structureTreeElement) {
+ if (structureTreeElement != null) {
+ area.addTrait(Trait.STRUCTURE_TREE_ELEMENT, structureTreeElement);
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java Thu Apr 5 16:19:19 2012
@@ -21,6 +21,7 @@ package org.apache.fop.layoutmgr;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.traits.MinOptMax;
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org