protected String foID = null;
/** True if this LayoutManager has handled all of its content. */
- private boolean m_bFinished = false;
- protected LayoutManager m_curChildLM = null;
- protected ListIterator m_childLMiter;
- protected boolean m_bInited = false;
+ private boolean bFinished = false;
+ protected LayoutManager curChildLM = null;
+ protected ListIterator childLMiter;
+ protected boolean bInited = false;
protected LayoutPos curPos = new LayoutPos();
this.fobj = fobj;
foID = fobj.getID();
this.parentLM = null;
- m_childLMiter = lmIter;
+ childLMiter = lmIter;
}
public void setParentLM(LayoutManager lm) {
* and print a warning.
*/
protected LayoutManager getChildLM() {
- if (m_curChildLM != null && !m_curChildLM.isFinished()) {
- return m_curChildLM;
+ if (curChildLM != null && !curChildLM.isFinished()) {
+ return curChildLM;
}
- while (m_childLMiter.hasNext()) {
- m_curChildLM = (LayoutManager) m_childLMiter.next();
- m_curChildLM.setParentLM(this);
- m_curChildLM.init();
- return m_curChildLM;
+ while (childLMiter.hasNext()) {
+ curChildLM = (LayoutManager) childLMiter.next();
+ curChildLM.setParentLM(this);
+ curChildLM.init();
+ return curChildLM;
}
return null;
}
protected boolean hasMoreLM(LayoutManager prevLM) {
- // prevLM should = m_curChildLM
- if (prevLM != m_curChildLM) {
+ // prevLM should = curChildLM
+ if (prevLM != curChildLM) {
//log.debug("AbstractLayoutManager.peekNextLM: " +
// "passed LM is not current child LM!");
return false;
}
- return !m_childLMiter.hasNext();
+ return !childLMiter.hasNext();
}
protected void reset(Position pos) {
//if (lm == null) return;
LayoutManager lm = (pos != null) ? pos.getLM() : null;
- if (m_curChildLM != lm) {
- // ASSERT m_curChildLM == (LayoutManager)m_childLMiter.previous()
- if (m_childLMiter.hasPrevious() && m_curChildLM !=
- (LayoutManager) m_childLMiter.previous()) {
+ if (curChildLM != lm) {
+ // ASSERT curChildLM == (LayoutManager)childLMiter.previous()
+ if (childLMiter.hasPrevious() && curChildLM !=
+ (LayoutManager) childLMiter.previous()) {
//log.error("LMiter problem!");
}
- while (m_curChildLM != lm && m_childLMiter.hasPrevious()) {
- m_curChildLM.resetPosition(null);
- m_curChildLM = (LayoutManager) m_childLMiter.previous();
+ while (curChildLM != lm && childLMiter.hasPrevious()) {
+ curChildLM.resetPosition(null);
+ curChildLM = (LayoutManager) childLMiter.previous();
}
- m_childLMiter.next(); // Otherwise next returns same object
+ childLMiter.next(); // Otherwise next returns same object
}
- if(m_curChildLM != null) {
- m_curChildLM.resetPosition(pos);
+ if(curChildLM != null) {
+ curChildLM.resetPosition(pos);
}
if (isFinished()) {
setFinished(false);
* for the areas it will create, based on Properties set on its FO.
*/
public void init() {
- if (fobj != null && m_bInited == false) {
+ if (fobj != null && bInited == false) {
initProperties(fobj.getPropertyManager());
- m_bInited = true;
+ bInited = true;
}
}
* ie. the last one returned represents the end of the content.
*/
public boolean isFinished() {
- return m_bFinished;
+ return bFinished;
}
- public void setFinished(boolean bFinished) {
- m_bFinished = bFinished;
+ public void setFinished(boolean fin) {
+ bFinished = fin;
}
return null;
}
- protected boolean flush() {
- return false;
+ protected void flush() {
}
- public boolean addChild(Area childArea) {
- return false;
+ public void addChild(Area childArea) {
}
/**
private BlockViewport viewportBlockArea;
private Block curBlockArea;
- ArrayList childBreaks = new ArrayList();
+ List childBreaks = new ArrayList();
AbsolutePositionProps abProps;
FODimension relDims;
}
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
curBlockArea.addBlock((Block) childArea);
- //return super.addChild(childArea);
}
- return false;
}
public void resetPosition(Position resetPos) {
int lineHeight = 14000;
int follow = 2000;
- ArrayList childBreaks = new ArrayList();
+ protected List childBreaks = new ArrayList();
/**
* Iterator for Block layout.
LayoutManager lm = (LayoutManager) proxy.next();
if(lm.generatesInlineAreas()) {
LineLayoutManager lineLM = createLineManager(lm);
- m_listLMs.add(lineLM);
+ listLMs.add(lineLM);
} else {
- m_listLMs.add(lm);
+ listLMs.add(lm);
}
- if (m_curPos < m_listLMs.size()) {
+ if (curPos < listLMs.size()) {
return true;
}
}
protected LineLayoutManager createLineManager(
LayoutManager firstlm) {
LayoutManager lm;
- ArrayList inlines = new ArrayList();
+ List inlines = new ArrayList();
inlines.add(firstlm);
while (proxy.hasNext()) {
lm = (LayoutManager) proxy.next();
public BlockLayoutManager(FObj fobj) {
super(fobj);
- m_childLMiter = new BlockLMiter(m_childLMiter);
+ childLMiter = new BlockLMiter(childLMiter);
}
public void setBlockTextInfo(TextInfo ti) {
}
public BreakPoss getNextBreakPoss(LayoutContext context) {
- LayoutManager curLM ; // currently active LM
+ LayoutManager curLM; // currently active LM
+
+ int ipd = context.getRefIPD();
MinOptMax stackSize = new MinOptMax();
// if starting add space before
while ((curLM = getChildLM()) != null) {
// Make break positions and return blocks!
// Set up a LayoutContext
- int ipd = context.getRefIPD();
BreakPoss bp;
LayoutContext childLC = new LayoutContext(0);
// line LM actually generates a LineArea which is a block
if (curLM.generatesInlineAreas()) {
// set stackLimit for lines
- childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents - m_iTextIndent*/));
+ childLC.setStackLimit(new MinOptMax(ipd/* - iIndents - iTextIndent*/));
childLC.setRefIPD(ipd);
} else {
childLC.setStackLimit(
stackSize));
childLC.setRefIPD(ipd);
}
-
+ boolean over = false;
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
stackSize.add(bp.getStackingSize());
} else {
curLM.resetPosition(null);
}
+ over = true;
break;
}
lastPos = bp;
if (curLM.generatesInlineAreas()) {
// Reset stackLimit for non-first lines
- childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents*/));
+ childLC.setStackLimit(new MinOptMax(ipd/* - iIndents*/));
} else {
- childLC.setStackLimit( MinOptMax.subtract(
+ childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
}
}
- if(getChildLM() == null) {
- stackSize.add(layoutProps.spaceAfter.space);
- }
- BreakPoss breakPoss = new BreakPoss(
+ if(getChildLM() == null || over) {
+ if(getChildLM() == null) {
+ setFinished(true);
+ stackSize.add(layoutProps.spaceAfter.space);
+ }
+ BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, childBreaks.size() - 1));
- breakPoss.setStackingSize(stackSize);
- return breakPoss;
+ breakPoss.setStackingSize(stackSize);
+ return breakPoss;
+ }
}
setFinished(true);
- return null;
+ BreakPoss breakPoss = new BreakPoss(new LeafPosition(this, -2));
+ breakPoss.setStackingSize(stackSize);
+ return breakPoss;
}
public void addAreas(PositionIterator parentIter,
LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
LeafPosition lfp = (LeafPosition) parentIter.next();
+ if (lfp.getLeafPos() == -2) {
+ childBreaks.clear();
+ curBlockArea = null;
+ flush();
+ return;
+ }
// Add the block areas to Area
PositionIterator breakPosIter =
new BreakPossPosIter(childBreaks, iStartPos,
return curBlockArea;
}
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
if (childArea instanceof LineArea) {
curBlockArea.addLineArea((LineArea) childArea);
-
- return false;
} else {
curBlockArea.addBlock((Block) childArea);
-
- return false;
}
}
- return false;
}
public void resetPosition(Position resetPos) {
if (resetPos == null) {
reset(null);
+ childBreaks.clear();
+ } else {
+ //reset(resetPos);
+ LayoutManager lm = resetPos.getLM();
}
}
}
* @param childArea the area to add: will be some block-stacked Area.
* @param parentArea the area in which to add the childArea
*/
- protected boolean addChildToArea(Area childArea,
+ protected void addChildToArea(Area childArea,
BlockParent parentArea) {
// This should be a block-level Area (Block in the generic sense)
if (!(childArea instanceof Block)) {
//log.error("Child not a Block in BlockStackingLM!");
- return false;
}
MinOptMax spaceBefore = resolveSpaceSpecifier(childArea);
parentArea.addBlock((Block) childArea);
flush(); // hand off current area to parent
-
- return true;
}
* If so, add it. Otherwise initiate breaking.
* @param childArea the area to add: will be some block-stacked Area.
*/
- public boolean addChild(Area childArea) {
- return addChildToArea(childArea, getCurrentArea());
+ public void addChild(Area childArea) {
+ addChildToArea(childArea, getCurrentArea());
}
/**
* Force current area to be added to parent area.
*/
- protected boolean flush() {
+ protected void flush() {
if (getCurrentArea() != null) {
- return parentLM.addChild(getCurrentArea());
+ parentLM.addChild(getCurrentArea());
}
- return false;
}
}
* in the lowest level text LM will be suppressed.
*/
public static final int REST_ARE_SUPPRESS_AT_LB = 0x200;
+ /**
+ * Next area for LM overflows
+ */
+ public static final int NEXT_OVERFLOWS = 0x400;
/** The opaque position object used by m_lm to record its
* break position.
*/
package org.apache.fop.layoutmgr;
-import java.util.List;
-
import org.apache.fop.area.Area;
import org.apache.fop.area.MinOptMax;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.PageViewport;
+import java.util.List;
+import java.util.ArrayList;
+
+
/**
* Content Layout Manager.
* For use with objects that contain inline areas such as
public void fillArea(LayoutManager curLM) {
- List childBreaks = new java.util.ArrayList();
+ List childBreaks = new ArrayList();
MinOptMax stack = new MinOptMax();
int ipd = 1000000;
BreakPoss bp;
}
/** @see org.apache.fop.layoutmgr.LayoutManager */
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
holder.addChild(childArea);
- return true;
}
/** @see org.apache.fop.layoutmgr.LayoutManager */
*/
public class FlowLayoutManager extends BlockStackingLayoutManager {
- ArrayList blockBreaks = new ArrayList();
+ protected List blockBreaks = new ArrayList();
/** Array of areas currently being filled stored by area class */
private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX];
* area class. A Flow can fill at most one area container of any class
* at any one time. The actual work is done by BlockStackingLM.
*/
- public boolean addChild(Area childArea) {
- return addChildToArea(childArea,
- this.currentAreas[childArea.getAreaClass()]);
+ public void addChild(Area childArea) {
+ addChildToArea(childArea,
+ this.currentAreas[childArea.getAreaClass()]);
}
public Area getParentArea(Area childArea) {
currentArea = area;
}
-
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
// Make sure childArea is inline area
if (childArea instanceof InlineArea) {
Area parent = getCurrentArea();
}
parent.addChild(childArea);
}
- return false;
}
protected void setChildContext(LayoutContext lc) {
import org.apache.fop.fo.FObj;
import java.util.ArrayList;
+import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
public class LMiter implements ListIterator {
- private ListIterator m_baseIter;
- private FObj m_curFO;
- protected ArrayList m_listLMs;
- protected int m_curPos = 0;
+ private ListIterator baseIter;
+ private FObj curFO;
+ protected List listLMs;
+ protected int curPos = 0;
- public LMiter(ListIterator baseIter) {
- m_baseIter = baseIter;
- m_listLMs = new ArrayList(10);
+ public LMiter(ListIterator bIter) {
+ baseIter = bIter;
+ listLMs = new ArrayList(10);
}
public boolean hasNext() {
- return (m_curPos < m_listLMs.size()) ? true : preLoadNext();
+ return (curPos < listLMs.size()) ? true : preLoadNext();
}
protected boolean preLoadNext() {
// skip over child FObj's that don't add lms
- while (m_baseIter.hasNext()) {
- Object theobj = m_baseIter.next();
+ while (baseIter.hasNext()) {
+ Object theobj = baseIter.next();
if(theobj instanceof FObj) {
FObj fobj = (FObj) theobj;
- //m_listLMs.add(fobj.getLayoutManager());
- fobj.addLayoutManager(m_listLMs);
- if(m_curPos < m_listLMs.size()) {
+ //listLMs.add(fobj.getLayoutManager());
+ fobj.addLayoutManager(listLMs);
+ if(curPos < listLMs.size()) {
return true;
}
}
}
public boolean hasPrevious() {
- return (m_curPos > 0);
+ return (curPos > 0);
}
public Object previous() throws NoSuchElementException {
- if (m_curPos > 0) {
- return m_listLMs.get(--m_curPos);
+ if (curPos > 0) {
+ return listLMs.get(--curPos);
} else
throw new NoSuchElementException();
}
public Object next() throws NoSuchElementException {
- if (m_curPos < m_listLMs.size()) {
- return m_listLMs.get(m_curPos++);
+ if (curPos < listLMs.size()) {
+ return listLMs.get(curPos++);
} else
throw new NoSuchElementException();
}
public void remove() throws NoSuchElementException {
- if (m_curPos > 0) {
- m_listLMs.remove(--m_curPos);
+ if (curPos > 0) {
+ listLMs.remove(--curPos);
// Note: doesn't actually remove it from the base!
} else
throw new NoSuchElementException();
}
public int nextIndex() {
- return m_curPos;
+ return curPos;
}
public int previousIndex() {
- return m_curPos - 1;
+ return curPos - 1;
}
}
* These LM <b>may</b> wish to pass this information down to lower
* level LM to allow them to optimize returned break possibilities.
*/
- MinOptMax m_stackLimit;
+ MinOptMax stackLimit;
/** True if current top-level reference area is spanning. */
int refIPD;
/** Current pending space-after or space-end from preceding area */
- SpaceSpecifier m_trailingSpace;
+ SpaceSpecifier trailingSpace;
/** Current pending space-before or space-start from ancestor areas */
- SpaceSpecifier m_leadingSpace;
+ SpaceSpecifier leadingSpace;
/** Current hyphenation context. May be null. */
- private HyphContext m_hyphContext = null;
+ private HyphContext hyphContext = null;
/** Stretch or shrink value when making areas. */
private double ipdAdjust = 0.0;
/** Stretch or shrink value when adding spaces. */
- private double m_dSpaceAdjust = 0.0;
+ private double dSpaceAdjust = 0.0;
- private int m_iLineHeight;
- private int m_iBaseline;
+ private int iLineHeight;
+ private int iBaseline;
public LayoutContext(LayoutContext parentLC) {
this.flags = parentLC.flags;
this.refIPD = parentLC.refIPD;
- this.m_stackLimit = null; // Don't reference parent MinOptMax!
- this.m_leadingSpace = parentLC.m_leadingSpace; //???
- this.m_trailingSpace = parentLC.m_trailingSpace; //???
- this.m_hyphContext = parentLC.m_hyphContext;
- this.m_dSpaceAdjust = parentLC.m_dSpaceAdjust;
- this.m_iLineHeight = parentLC.m_iLineHeight;
- this.m_iBaseline = parentLC.m_iBaseline;
+ this.stackLimit = null; // Don't reference parent MinOptMax!
+ this.leadingSpace = parentLC.leadingSpace; //???
+ this.trailingSpace = parentLC.trailingSpace; //???
+ this.hyphContext = parentLC.hyphContext;
+ this.dSpaceAdjust = parentLC.dSpaceAdjust;
+ this.iLineHeight = parentLC.iLineHeight;
+ this.iBaseline = parentLC.iBaseline;
// Copy other fields as necessary. Use clone???
}
public LayoutContext(int flags) {
this.flags = flags;
this.refIPD = 0;
- m_stackLimit = new MinOptMax(0);
- m_leadingSpace = null;
- m_trailingSpace = null;
+ stackLimit = new MinOptMax(0);
+ leadingSpace = null;
+ trailingSpace = null;
}
public void setFlags(int flags) {
}
public boolean startsNewArea() {
- return ((this.flags & NEW_AREA) != 0 && m_leadingSpace != null);
+ return ((this.flags & NEW_AREA) != 0 && leadingSpace != null);
}
public boolean isFirstArea() {
}
public void setLeadingSpace(SpaceSpecifier space) {
- m_leadingSpace = space;
+ leadingSpace = space;
}
public SpaceSpecifier getLeadingSpace() {
- return m_leadingSpace;
+ return leadingSpace;
}
public boolean resolveLeadingSpace() {
}
public void setTrailingSpace(SpaceSpecifier space) {
- m_trailingSpace = space;
+ trailingSpace = space;
}
public SpaceSpecifier getTrailingSpace() {
- return m_trailingSpace;
+ return trailingSpace;
}
- public void setStackLimit(MinOptMax stackLimit) {
- m_stackLimit = stackLimit;
+ public void setStackLimit(MinOptMax limit) {
+ stackLimit = limit;
}
public MinOptMax getStackLimit() {
- return m_stackLimit;
+ return stackLimit;
}
public void setRefIPD(int ipd) {
return refIPD;
}
- public void setHyphContext(HyphContext hyphContext) {
- m_hyphContext = hyphContext;
+ public void setHyphContext(HyphContext hyph) {
+ hyphContext = hyph;
}
public HyphContext getHyphContext() {
- return m_hyphContext;
+ return hyphContext;
}
public boolean tryHyphenate() {
return ((this.flags & TRY_HYPHENATE) != 0);
}
- public void setSpaceAdjust(double dSpaceAdjust) {
- m_dSpaceAdjust = dSpaceAdjust ;
+ public void setSpaceAdjust(double adjust) {
+ dSpaceAdjust = adjust;
}
public double getSpaceAdjust() {
- return m_dSpaceAdjust;
+ return dSpaceAdjust;
}
public void setIPDAdjust(double ipdA) {
}
public void setLineHeight(int lh) {
- m_iLineHeight = lh;
+ iLineHeight = lh;
}
public int getLineHeight() {
- return m_iLineHeight;
+ return iLineHeight;
}
public void setBaseline(int bl) {
- m_iBaseline = bl;
+ iBaseline = bl;
}
public int getBaseline() {
- return m_iBaseline;
+ return iBaseline;
}
}
public interface LayoutManager {
public boolean generatesInlineAreas();
public Area getParentArea (Area childArea);
- public boolean addChild (Area childArea);
+ public void addChild (Area childArea);
public void setParentLM(LayoutManager lm);
/**
* @param childArea the childArea to add
* @return not used
*/
- public boolean addChild(Area childArea) {
- return false;
+ public void addChild(Area childArea) {
}
/**
public class LeafPosition extends Position {
- private int m_iLeafPos;
+ private int iLeafPos;
- public LeafPosition(LayoutManager lm, int iLeafPos) {
+ public LeafPosition(LayoutManager lm, int pos) {
super(lm);
- m_iLeafPos = iLeafPos;
+ iLeafPos = pos;
}
public int getLeafPos() {
- return m_iLeafPos;
+ return iLeafPos;
}
}
* inline break positions.
*/
private static class LineBreakPosition extends LeafPosition {
- // int m_iPos;
- double m_dAdjust; // Percentage to adjust (stretch or shrink)
+ // int iPos;
+ double dAdjust; // Percentage to adjust (stretch or shrink)
double ipdAdjust; // Percentage to adjust (stretch or shrink)
int startIndent;
int lineHeight;
int baseline;
LineBreakPosition(LayoutManager lm, int iBreakIndex,
- double ipdA, double dAdjust, int ind, int lh, int bl) {
+ double ipdA, double adjust, int ind, int lh, int bl) {
super(lm, iBreakIndex);
- // m_iPos = iBreakIndex;
+ // iPos = iBreakIndex;
ipdAdjust = ipdA;
- m_dAdjust = dAdjust;
+ dAdjust = adjust;
startIndent = ind;
lineHeight = lh;
baseline = bl;
/** Break positions returned by inline content. */
- private ArrayList m_vecInlineBreaks = new ArrayList();
+ private List vecInlineBreaks = new ArrayList();
- private BreakPoss m_prevBP = null; // Last confirmed break position
+ private BreakPoss prevBP = null; // Last confirmed break position
private int bTextAlignment = TextAlign.JUSTIFY;
- private int m_iTextIndent = 0;
- private int m_iIndents = 0;
- private HyphenationProps m_hyphProps;
+ private int iTextIndent = 0;
+ private int iIndents = 0;
+ private HyphenationProps hyphProps;
private int lineHeight;
private int lead;
*/
protected void initProperties(PropertyManager propMgr) {
MarginProps marginProps = propMgr.getMarginProps();
- m_iIndents = marginProps.startIndent + marginProps.endIndent;
+ iIndents = marginProps.startIndent + marginProps.endIndent;
BlockProps blockProps = propMgr.getBlockProps();
bTextAlignment = blockProps.textAlign;
- m_iTextIndent = blockProps.firstIndent;
- m_hyphProps = propMgr.getHyphenationProps();
+ iTextIndent = blockProps.firstIndent;
+ hyphProps = propMgr.getHyphenationProps();
}
/**
// Set up constraints for inline level managers
LayoutManager curLM ; // currently active LM
- BreakPoss prevBP = null;
+ BreakPoss prev = null;
BreakPoss bp = null; // proposed BreakPoss
ArrayList vecPossEnd = new ArrayList();
LayoutContext inlineLC = new LayoutContext(context);
clearPrevIPD();
- int iPrevLineEnd = m_vecInlineBreaks.size();
+ int iPrevLineEnd = vecInlineBreaks.size();
- m_prevBP = null;
+ prevBP = null;
while ((curLM = getChildLM()) != null) {
// INITIALIZE LAYOUT CONTEXT FOR CALL TO CHILD LM
// First break for the child LM in each of its areas
- boolean bFirstBPforLM = (m_vecInlineBreaks.isEmpty() ||
- (((BreakPoss) m_vecInlineBreaks.get(m_vecInlineBreaks.size() - 1)).
+ boolean bFirstBPforLM = (vecInlineBreaks.isEmpty() ||
+ (((BreakPoss) vecInlineBreaks.get(vecInlineBreaks.size() - 1)).
getLayoutManager() != curLM));
// Need previous breakpoint! ATTENTION when backing up for hyphenation!
- prevBP = (m_vecInlineBreaks.isEmpty()) ? null :
- (BreakPoss) m_vecInlineBreaks.get(m_vecInlineBreaks.size() - 1);
- initChildLC(inlineLC, prevBP,
- (m_vecInlineBreaks.size() == iPrevLineEnd),
+ prev = (vecInlineBreaks.isEmpty()) ? null :
+ (BreakPoss) vecInlineBreaks.get(vecInlineBreaks.size() - 1);
+ initChildLC(inlineLC, prev,
+ (vecInlineBreaks.size() == iPrevLineEnd),
bFirstBPforLM, new SpaceSpecifier(true));
* then set the SUPPRESS_LEADING_SPACE flag.
*/
inlineLC.setFlags(LayoutContext.SUPPRESS_LEADING_SPACE,
- (m_vecInlineBreaks.size() == iPrevLineEnd &&
- !m_vecInlineBreaks.isEmpty() &&
- ((BreakPoss) m_vecInlineBreaks.get(m_vecInlineBreaks.size() - 1)).
+ (vecInlineBreaks.size() == iPrevLineEnd &&
+ !vecInlineBreaks.isEmpty() &&
+ ((BreakPoss) vecInlineBreaks.get(vecInlineBreaks.size() - 1)).
isForcedBreak() == false));
// GET NEXT POSSIBLE BREAK FROM CHILD LM
// prevBP = bp;
if ((bp = curLM.getNextBreakPoss(inlineLC)) != null) {
// Add any space before and previous content dimension
- MinOptMax prevIPD = updatePrevIPD(bp, prevBP,
- (m_vecInlineBreaks.size() == iPrevLineEnd),
+ MinOptMax prevIPD = updatePrevIPD(bp, prev,
+ (vecInlineBreaks.size() == iPrevLineEnd),
inlineLC.isFirstArea());
MinOptMax bpDim =
MinOptMax.add(bp.getStackingSize(), prevIPD);
// This break position doesn't fit
// TODO: If we are in nowrap, we use it as is!
- if (bTextAlignment == TextAlign.JUSTIFY || m_prevBP == null) {
+ if (bTextAlignment == TextAlign.JUSTIFY || prevBP == null) {
// If we are already in a hyphenation loop, then stop.
if (inlineLC.tryHyphenate()) {
// Otherwise, prepare to try hyphenation
if (!bBreakOK) {
// Make sure we collect the entire word!
- m_vecInlineBreaks.add(bp);
+ vecInlineBreaks.add(bp);
continue;
}
inlineLC.setHyphContext(
- getHyphenContext(m_prevBP, bp));
+ getHyphenContext(prevBP, bp));
if (inlineLC.getHyphContext() == null)
break;
inlineLC.setFlags(LayoutContext.TRY_HYPHENATE,
}
} else {
// Add the BP to the list whether or not we can break
- m_vecInlineBreaks.add(bp);
+ vecInlineBreaks.add(bp);
// Handle end of this LM's areas
if (bBreakOK) {
- m_prevBP = bp; // Save reference to this BP
+ prevBP = bp; // Save reference to this BP
if (bp.isForcedBreak()) {
break;
}
if (bp == null)
return null;
- if (m_prevBP == null)
- m_prevBP = bp;
+ if (prevBP == null)
+ prevBP = bp;
// Choose the best break
if (!bp.isForcedBreak() && vecPossEnd.size() > 0) {
- m_prevBP = getBestBP(vecPossEnd);
+ prevBP = getBestBP(vecPossEnd);
}
// Backup child LM if necessary
- if (bp != m_prevBP && !bp.couldEndLine()) {
+ if (bp != prevBP && !bp.couldEndLine()) {
reset();
}
// Don't justify last line in the sequence or if forced line-end
int talign = bTextAlignment;
if ((bTextAlignment == TextAlign.JUSTIFY
- && (m_prevBP.isForcedBreak()
+ && (prevBP.isForcedBreak()
|| isFinished()))) {
talign = TextAlign.START;
}
private void reset() {
- while (m_vecInlineBreaks.get(m_vecInlineBreaks.size() - 1) != m_prevBP) {
- m_vecInlineBreaks.remove(m_vecInlineBreaks.size() - 1);
+ while (vecInlineBreaks.get(vecInlineBreaks.size() - 1) != prevBP) {
+ vecInlineBreaks.remove(vecInlineBreaks.size() - 1);
}
- reset(m_prevBP.getPosition());
+ reset(prevBP.getPosition());
}
protected boolean couldEndLine(BreakPoss bp) {
return true;
}
- private HyphContext getHyphenContext(BreakPoss prevBP,
+ private HyphContext getHyphenContext(BreakPoss prev,
BreakPoss newBP) {
// Get a "word" to hyphenate by getting characters from all
- // pending break poss which are in m_vecInlineBreaks, starting
- // with the position just AFTER prevBP.getPosition()
+ // pending break poss which are in vecInlineBreaks, starting
+ // with the position just AFTER prev.getPosition()
- m_vecInlineBreaks.add(newBP);
+ vecInlineBreaks.add(newBP);
ListIterator bpIter =
- m_vecInlineBreaks. listIterator(m_vecInlineBreaks.size());
- while (bpIter.hasPrevious() && bpIter.previous() != prevBP)
- ;
- if (bpIter.next() != prevBP) {
+ vecInlineBreaks. listIterator(vecInlineBreaks.size());
+ while (bpIter.hasPrevious() && bpIter.previous() != prev) {
+ }
+ if (bpIter.next() != prev) {
//log.error("findHyphenPoss: problem!");
return null;
}
StringBuffer sbChars = new StringBuffer(30);
while (bpIter.hasNext()) {
BreakPoss bp = (BreakPoss) bpIter.next();
- if (bp.getLayoutManager() == prevBP.getLayoutManager()) {
+ if (bp.getLayoutManager() == prev.getLayoutManager()) {
bp.getLayoutManager().getWordChars(sbChars,
- prevBP.getPosition(), bp.getPosition());
+ prev.getPosition(), bp.getPosition());
} else {
bp.getLayoutManager().getWordChars(sbChars, null,
bp.getPosition());
}
- prevBP = bp;
+ prev = bp;
}
- m_vecInlineBreaks.remove(m_vecInlineBreaks.size() - 1); // remove last
+ vecInlineBreaks.remove(vecInlineBreaks.size() - 1); // remove last
//log.debug("Word to hyphenate: " + sbChars.toString());
// Now find all hyphenation points in this word (get in an array of offsets)
// TextLM which generate the hyphenation buffer, since these properties
// inherit and could be specified on an inline or wrapper below the block
// level.
- Hyphenation hyph = Hyphenator.hyphenate(m_hyphProps.language,
- m_hyphProps.country, sbChars.toString(),
- m_hyphProps.hyphenationRemainCharacterCount,
- m_hyphProps.hyphenationPushCharacterCount);
+ Hyphenation hyph = Hyphenator.hyphenate(hyphProps.language,
+ hyphProps.country, sbChars.toString(),
+ hyphProps.hyphenationRemainCharacterCount,
+ hyphProps.hyphenationPushCharacterCount);
// They hyph structure contains the information we need
- // Now start from prevBP: reset to that position, ask that LM to get
+ // Now start from prev: reset to that position, ask that LM to get
// a Position for the first hyphenation offset. If the offset isn't in
// its characters, it returns null, but must tell how many chars it had.
// Keep looking at currentBP using next hyphenation point until the
MinOptMax actual = new MinOptMax();
BreakPoss lastBP = null;
LayoutManager lastLM = null;
- for(Iterator iter = m_vecInlineBreaks.listIterator(prevLineEnd);
+ for(Iterator iter = vecInlineBreaks.listIterator(prevLineEnd);
iter.hasNext(); ) {
BreakPoss bp = (BreakPoss)iter.next();
if (bp.getLead() > lineLead) {
LineBreakPosition lbp;
lbp = new LineBreakPosition(this,
- m_vecInlineBreaks.size() - 1,
+ vecInlineBreaks.size() - 1,
ipdAdjust, dAdjust, indent,
lineLead + middlefollow, lineLead);
BreakPoss curLineBP = new BreakPoss(lbp);
if (resetPos == null) {
iStartPos = 0;
reset(null);
- m_vecInlineBreaks.clear();
- m_prevBP = null;
+ vecInlineBreaks.clear();
+ prevBP = null;
} else {
- m_prevBP = (BreakPoss)m_vecInlineBreaks.get(((LineBreakPosition)resetPos).getLeafPos());
- while (m_vecInlineBreaks.get(m_vecInlineBreaks.size() - 1) != m_prevBP)
+ prevBP = (BreakPoss)vecInlineBreaks.get(((LineBreakPosition)resetPos).getLeafPos());
+ while (vecInlineBreaks.get(vecInlineBreaks.size() - 1) != prevBP)
{
- m_vecInlineBreaks.remove(m_vecInlineBreaks.size() - 1);
+ vecInlineBreaks.remove(vecInlineBreaks.size() - 1);
}
- reset(m_prevBP.getPosition());
+ reset(prevBP.getPosition());
}
}
LayoutContext context) {
addAreas(parentIter, 0.0);
- //m_vecInlineBreaks.clear();
- m_prevBP = null;
+ //vecInlineBreaks.clear();
+ prevBP = null;
}
// Generate and add areas to parent area
setCurrentArea(lineArea);
// Add the inline areas to lineArea
PositionIterator inlinePosIter =
- new BreakPossPosIter(m_vecInlineBreaks, iStartPos,
+ new BreakPossPosIter(vecInlineBreaks, iStartPos,
lbp.getLeafPos() + 1);
iStartPos = lbp.getLeafPos() + 1;
- lc.setSpaceAdjust(lbp.m_dAdjust);
+ lc.setSpaceAdjust(lbp.dAdjust);
lc.setIPDAdjust(lbp.ipdAdjust);
lc.setLeadingSpace(new SpaceSpecifier(true));
lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
public class NonLeafPosition extends Position {
- private Position m_subPos ;
+ private Position subPos;
- public NonLeafPosition(LayoutManager lm, Position subPos) {
+ public NonLeafPosition(LayoutManager lm, Position sub) {
super(lm);
- m_subPos = subPos;
+ subPos = sub;
}
public Position getPosition() {
- return m_subPos;
+ return subPos;
}
}
*
* @param childArea the child area to add
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (childArea == null) {
- return false;
+ return;
}
if (childArea.getAreaClass() == Area.CLASS_NORMAL) {
placeFlowRefArea(childArea);
} else {
; // todo: all the others!
}
- return false;
}
/**
while (!lm.isFinished()) {
BreakPoss bp = lm.getNextBreakPoss(childLC);
if (bp != null) {
- ArrayList vecBreakPoss = new ArrayList();
+ List vecBreakPoss = new ArrayList();
vecBreakPoss.add(bp);
lm.addAreas(new BreakPossPosIter(vecBreakPoss, 0,
vecBreakPoss.size()), null);
}
// See finishPage...
- protected boolean flush() {
+ protected void flush() {
finishPage();
- return false;
}
}
package org.apache.fop.layoutmgr;
public class Position {
- private LayoutManager m_lm;
+ private LayoutManager layoutManager;
public Position(LayoutManager lm) {
- m_lm = lm;
+ layoutManager = lm;
}
public LayoutManager getLM() {
- return m_lm;
+ return layoutManager;
}
/**
import java.util.NoSuchElementException;
public abstract class PositionIterator implements Iterator {
- Iterator m_parentIter;
- Object m_nextObj;
- LayoutManager m_childLM;
- boolean m_bHasNext;
+ Iterator parentIter;
+ Object nextObj;
+ LayoutManager childLM;
+ boolean bHasNext;
- PositionIterator(Iterator parentIter) {
- m_parentIter = parentIter;
+ PositionIterator(Iterator pIter) {
+ parentIter = pIter;
lookAhead();
//checkNext();
}
public LayoutManager getNextChildLM() {
// Move to next "segment" of iterator, ie: new childLM
- if (m_childLM == null && m_nextObj != null) {
- m_childLM = getLM(m_nextObj);
- m_bHasNext = true;
+ if (childLM == null && nextObj != null) {
+ childLM = getLM(nextObj);
+ bHasNext = true;
}
- return m_childLM;
+ return childLM;
}
protected abstract LayoutManager getLM(Object nextObj);
protected abstract Position getPos(Object nextObj);
private void lookAhead() {
- if (m_parentIter.hasNext()) {
- m_bHasNext = true;
- m_nextObj = m_parentIter.next();
+ if (parentIter.hasNext()) {
+ bHasNext = true;
+ nextObj = parentIter.next();
} else {
endIter();
}
}
protected boolean checkNext() {
- LayoutManager lm = getLM(m_nextObj);
- if (m_childLM == null) {
- m_childLM = lm;
- } else if (m_childLM != lm) {
+ LayoutManager lm = getLM(nextObj);
+ if (childLM == null) {
+ childLM = lm;
+ } else if (childLM != lm) {
// End of this sub-sequence with same child LM
- m_bHasNext = false;
- m_childLM = null;
+ bHasNext = false;
+ childLM = null;
return false;
}
return true;
}
protected void endIter() {
- m_bHasNext = false;
- m_nextObj = null;
- m_childLM = null;
+ bHasNext = false;
+ nextObj = null;
+ childLM = null;
}
public boolean hasNext() {
- return (m_bHasNext && checkNext());
+ return (bHasNext && checkNext());
}
public Object next() throws NoSuchElementException {
- if (m_bHasNext) {
- Object retObj = getPos(m_nextObj);
+ if (bHasNext) {
+ Object retObj = getPos(nextObj);
lookAhead();
return retObj;
} else {
}
protected Object peekNext() {
- return m_nextObj;
+ return nextObj;
}
public void remove() throws UnsupportedOperationException {
import org.apache.fop.area.MinOptMax;
import org.apache.fop.traits.SpaceVal;
import java.util.ArrayList;
+import java.util.List;
/**
* Accumulate a sequence of space-specifiers (XSL space type) on
public class SpaceSpecifier implements Cloneable {
- private boolean m_bStartsRefArea;
- private boolean m_bHasForcing = false;
- private ArrayList m_vecSpaceVals = new ArrayList();
+ private boolean bStartsRefArea;
+ private boolean bHasForcing = false;
+ private List vecSpaceVals = new ArrayList();
- public SpaceSpecifier(boolean bStartsRefArea) {
- m_bStartsRefArea = bStartsRefArea;
+ public SpaceSpecifier(boolean bStarts) {
+ bStartsRefArea = bStarts;
}
public Object clone() {
try {
SpaceSpecifier ss = (SpaceSpecifier) super.clone();
// Clone the vector, but share the objects in it!
- ss.m_vecSpaceVals = new ArrayList();
- ss.m_vecSpaceVals.addAll(this.m_vecSpaceVals);
+ ss.vecSpaceVals = new ArrayList();
+ ss.vecSpaceVals.addAll(this.vecSpaceVals);
return ss;
} catch (CloneNotSupportedException cnse) {
return null;
* Clear all space specifiers
*/
public void clear() {
- m_bHasForcing = false;
- m_vecSpaceVals.clear();
+ bHasForcing = false;
+ vecSpaceVals.clear();
}
/** Return true if any space-specifiers have been added. */
public boolean hasSpaces() {
- return (m_vecSpaceVals.size() > 0);
+ return (vecSpaceVals.size() > 0);
}
/**
* add it to the sequence.
*/
public void addSpace(SpaceVal moreSpace) {
- if (!m_bStartsRefArea || !moreSpace.bConditional ||
- !m_vecSpaceVals.isEmpty()) {
+ if (!bStartsRefArea || !moreSpace.bConditional ||
+ !vecSpaceVals.isEmpty()) {
if (moreSpace.bForcing) {
- if (m_bHasForcing == false) {
+ if (bHasForcing == false) {
// Remove all other values (must all be non-forcing)
- m_vecSpaceVals.clear();
- m_bHasForcing = true;
+ vecSpaceVals.clear();
+ bHasForcing = true;
}
- m_vecSpaceVals.add(moreSpace);
- } else if (m_bHasForcing == false) {
+ vecSpaceVals.add(moreSpace);
+ } else if (bHasForcing == false) {
// Don't bother adding all 0 space-specifier if not forcing
if (moreSpace.space.min != 0 || moreSpace.space.opt != 0 ||
moreSpace.space.max != 0) {
- m_vecSpaceVals.add(moreSpace);
+ vecSpaceVals.add(moreSpace);
}
}
}
* @return The resolved value as a min/opt/max triple.
*/
public MinOptMax resolve(boolean bEndsReferenceArea) {
- int lastIndex = m_vecSpaceVals.size();
+ int lastIndex = vecSpaceVals.size();
if (bEndsReferenceArea) {
// Start from the end and count conditional specifiers
// Stop at first non-conditional
for (; lastIndex > 0; --lastIndex) {
- SpaceVal sval = (SpaceVal) m_vecSpaceVals.get(
+ SpaceVal sval = (SpaceVal) vecSpaceVals.get(
lastIndex - 1);
if (!sval.bConditional) {
break;
MinOptMax resSpace = new MinOptMax(0);
int iMaxPrec = -1;
for (int index = 0; index < lastIndex; index++) {
- SpaceVal sval = (SpaceVal) m_vecSpaceVals.get(index);
- if (m_bHasForcing) {
+ SpaceVal sval = (SpaceVal) vecSpaceVals.get(index);
+ if (bHasForcing) {
resSpace.add(sval.space);
} else if (sval.iPrecedence > iMaxPrec) {
iMaxPrec = sval.iPrecedence;
import org.apache.fop.area.Block;
import java.util.ArrayList;
+import java.util.List;
/**
* LayoutManager for an fo:flow object.
public class StaticContentLayoutManager extends BlockStackingLayoutManager {
private RegionReference region;
- private ArrayList blockBreaks = new ArrayList();
+ private List blockBreaks = new ArrayList();
public StaticContentLayoutManager(FObj fobj) {
super(fobj);
* area class. A Flow can fill at most one area container of any class
* at any one time. The actual work is done by BlockStackingLM.
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
region.addBlock((Block)childArea);
- return true;
}
public Area getParentArea(Area childArea) {
//import org.apache.fop.fo.properties.*;
import java.util.ArrayList;
+import java.util.List;
/**
* LayoutManager for text (a sequence of characters) which generates one
* Number of word-spaces?
*/
private class AreaInfo {
- short m_iStartIndex;
- short m_iBreakIndex;
- short m_iWScount;
- MinOptMax m_ipdArea;
- AreaInfo(short iStartIndex, short iBreakIndex, short iWScount,
- MinOptMax ipdArea) {
- m_iStartIndex = iStartIndex;
- m_iBreakIndex = iBreakIndex;
- m_iWScount = iWScount;
- m_ipdArea = ipdArea;
+ short iStartIndex;
+ short iBreakIndex;
+ short iWScount;
+ MinOptMax ipdArea;
+ AreaInfo(short iSIndex, short iBIndex, short iWS,
+ MinOptMax ipd) {
+ iStartIndex = iSIndex;
+ iBreakIndex = iBIndex;
+ iWScount = iWS;
+ ipdArea = ipd;
}
}
// Hold all possible breaks for the text in this LM's FO.
- private ArrayList m_vecAreaInfo;
+ private ArrayList vecAreaInfo;
/** Non-space characters on which we can end a line. */
private static final String s_breakChars = "-/" ;
private static final char ZERO_WIDTH_NOBREAK_SPACE = '\uFEFF';
/** Start index of first character in this parent Area */
- private short m_iAreaStart = 0;
+ private short iAreaStart = 0;
/** Start index of next "word" */
- private short m_iNextStart = 0;
+ private short iNextStart = 0;
/** Size since last makeArea call, except for last break */
- private MinOptMax m_ipdTotal ;
+ private MinOptMax ipdTotal;
/** Size including last break possibility returned */
- // private MinOptMax m_nextIPD= new MinOptMax(0);
+ // private MinOptMax nextIPD = new MinOptMax(0);
/** size of a space character (U+0020) glyph in current font */
- private int m_spaceIPD;
+ private int spaceCharIPD;
/** size of the hyphen character glyph in current font */
- private int m_hyphIPD;
+ private int hyphIPD;
/** 1/2 of word-spacing value */
- private SpaceVal m_halfWS;
+ private SpaceVal halfWS;
/** Number of space characters after previous possible break position. */
- private int m_iNbSpacesPending;
+ private int iNbSpacesPending;
/**
* Create a Text layout manager.
super(fobj);
this.chars = chars;
this.textInfo = textInfo;
- this.m_vecAreaInfo = new ArrayList();
+ this.vecAreaInfo = new ArrayList();
// With CID fonts, space isn't neccesary currentFontState.width(32)
- m_spaceIPD = CharUtilities.getCharWidth(' ', textInfo.fs);
+ spaceCharIPD = CharUtilities.getCharWidth(' ', textInfo.fs);
// Use hyphenationChar property
- m_hyphIPD = CharUtilities.getCharWidth('-', textInfo.fs);
+ hyphIPD = CharUtilities.getCharWidth('-', textInfo.fs);
// Make half-space: <space> on either side of a word-space)
SpaceVal ws = textInfo.wordSpacing;
- m_halfWS = new SpaceVal(MinOptMax.multiply(ws.space, 0.5),
+ halfWS = new SpaceVal(MinOptMax.multiply(ws.space, 0.5),
ws.bConditional, ws.bForcing, ws.iPrecedence);
}
Position bp2) {
LeafPosition endPos = (LeafPosition) bp2;
AreaInfo ai =
- (AreaInfo) m_vecAreaInfo.get(endPos.getLeafPos());
+ (AreaInfo) vecAreaInfo.get(endPos.getLeafPos());
// Skip all leading spaces for hyphenation
int i;
- for (i = ai.m_iStartIndex; i < ai.m_iBreakIndex &&
+ for (i = ai.iStartIndex; i < ai.iBreakIndex &&
CharUtilities.isAnySpace(chars[i]) == true ; i++)
;
- sbChars.append(new String(chars, i, ai.m_iBreakIndex - i));
+ sbChars.append(new String(chars, i, ai.iBreakIndex - i));
}
/**
* @return true if can break before this text
*/
public boolean canBreakBefore(LayoutContext context) {
- char c = chars[m_iNextStart];
+ char c = chars[iNextStart];
return ((c == NEWLINE) || (textInfo.bWrap &&
(CharUtilities.isSpace(c) ||
s_breakChars.indexOf(c) >= 0)));
}
LeafPosition tbp = (LeafPosition) prevPos;
AreaInfo ai =
- (AreaInfo) m_vecAreaInfo.get(tbp.getLeafPos());
- if (ai.m_iBreakIndex != m_iNextStart) {
- m_iNextStart = ai.m_iBreakIndex;
- m_vecAreaInfo.ensureCapacity(tbp.getLeafPos() + 1);
+ (AreaInfo) vecAreaInfo.get(tbp.getLeafPos());
+ if (ai.iBreakIndex != iNextStart) {
+ iNextStart = ai.iBreakIndex;
+ vecAreaInfo.ensureCapacity(tbp.getLeafPos() + 1);
// TODO: reset or recalculate total IPD = sum of all word IPD
// up to the break position
- m_ipdTotal = ai.m_ipdArea;
+ ipdTotal = ai.ipdArea;
setFinished(false);
}
} else {
// Reset to beginning!
- m_vecAreaInfo.clear();
- m_iNextStart = 0;
+ vecAreaInfo.clear();
+ iNextStart = 0;
setFinished(false);
}
}
private boolean getHyphenIPD(HyphContext hc, MinOptMax hyphIPD) {
// Skip leading word-space before calculating count?
boolean bCanHyphenate = true;
- int iStopIndex = m_iNextStart + hc.getNextHyphPoint();
+ int iStopIndex = iNextStart + hc.getNextHyphPoint();
if (chars.length < iStopIndex || textInfo.bCanHyphenate == false) {
iStopIndex = chars.length;
bCanHyphenate = false;
}
- hc.updateOffset(iStopIndex - m_iNextStart);
+ hc.updateOffset(iStopIndex - iNextStart);
- for (; m_iNextStart < iStopIndex; m_iNextStart++) {
- char c = chars[m_iNextStart];
+ for (; iNextStart < iStopIndex; iNextStart++) {
+ char c = chars[iNextStart];
hyphIPD.opt += CharUtilities.getCharWidth(c, textInfo.fs);
// letter-space?
}
/* This could be first call on this LM, or the first call
* in a new (possible) LineArea.
*/
- m_ipdTotal = new MinOptMax(0);
+ ipdTotal = new MinOptMax(0);
iFlags |= BreakPoss.ISFIRST;
}
* retained.
*/
if (context.suppressLeadingSpace()) {
- for (; m_iNextStart < chars.length &&
- chars[m_iNextStart] == SPACE; m_iNextStart++)
- ;
+ for (; iNextStart < chars.length
+ && chars[iNextStart] == SPACE; iNextStart++) {
+ }
// If now at end, nothing to compose here!
- if (m_iNextStart >= chars.length) {
+ if (iNextStart >= chars.length) {
setFinished(true);
return null; // Or an "empty" BreakPoss?
}
*/
SpaceSpecifier pendingSpace = new SpaceSpecifier(false);
- short iThisStart = m_iNextStart; // Index of first character counted
+ short iThisStart = iNextStart; // Index of first character counted
MinOptMax spaceIPD = new MinOptMax(0); // Extra IPD from word-spacing
// Sum of glyph IPD of all characters in a word, inc. leading space
int wordIPD = 0;
short iWScount = 0; // Count of word spaces
boolean bSawNonSuppressible = false;
- for (; m_iNextStart < chars.length; m_iNextStart++) {
- char c = chars[m_iNextStart];
+ for (; iNextStart < chars.length; iNextStart++) {
+ char c = chars[iNextStart];
if (CharUtilities.isAnySpace(c) == false)
break;
if (c == SPACE || c == NBSPACE) {
++iWScount;
// Counted as word-space
- if (m_iNextStart == iThisStart &&
+ if (iNextStart == iThisStart &&
(iFlags & BreakPoss.ISFIRST) != 0) {
// If possible, treat as normal inter-word space
if (context.getLeadingSpace().hasSpaces()) {
- context.getLeadingSpace().addSpace(m_halfWS);
+ context.getLeadingSpace().addSpace(halfWS);
} else {
// Doesn't combine with any other leading spaces
// from ancestors
- spaceIPD.add(m_halfWS.space);
+ spaceIPD.add(halfWS.space);
}
} else {
- pendingSpace.addSpace(m_halfWS);
+ pendingSpace.addSpace(halfWS);
spaceIPD.add(pendingSpace.resolve(false));
}
- wordIPD += m_spaceIPD; // Space glyph IPD
+ wordIPD += spaceCharIPD; // Space glyph IPD
pendingSpace.clear();
- pendingSpace.addSpace(m_halfWS);
+ pendingSpace.addSpace(halfWS);
if (c == NBSPACE) {
bSawNonSuppressible = true;
}
}
}
- if (m_iNextStart < chars.length) {
+ if (iNextStart < chars.length) {
spaceIPD.add(pendingSpace.resolve(false));
} else {
// This FO ended with spaces. Return the BP
// Look for a legal line-break: breakable white-space and certain
// characters such as '-' which can serve as word breaks.
// Don't look for hyphenation points here though
- for (; m_iNextStart < chars.length; m_iNextStart++) {
- char c = chars[m_iNextStart];
+ for (; iNextStart < chars.length; iNextStart++) {
+ char c = chars[iNextStart];
if ((c == NEWLINE) || // Include any breakable white-space as break char
// even if fixed width
(textInfo.bWrap && (CharUtilities.isSpace(c) ||
s_breakChars.indexOf(c) >= 0))) {
iFlags |= BreakPoss.CAN_BREAK_AFTER;
if (c != SPACE) {
- m_iNextStart++;
+ iNextStart++;
if (c != NEWLINE) {
wordIPD += CharUtilities.getCharWidth(c,
textInfo.fs);
// If all remaining characters would be suppressed at
// line-end, set a flag for parent LM.
int iLastChar;
- for (iLastChar = m_iNextStart;
+ for (iLastChar = iNextStart;
iLastChar < chars.length &&
chars[iLastChar] == SPACE; iLastChar++)
;
int flags, short iWScount) {
MinOptMax ipd = new MinOptMax(wordDim);
ipd.add(spaceIPD);
- if (m_ipdTotal != null) {
- ipd.add(m_ipdTotal); // sum of all words so far in line
+ if (ipdTotal != null) {
+ ipd.add(ipdTotal); // sum of all words so far in line
}
// Note: break position now stores total size to here
// Position is the index of the info for this word in the vector
- m_vecAreaInfo.add(
- new AreaInfo(iWordStart, m_iNextStart, iWScount, ipd));
+ vecAreaInfo.add(
+ new AreaInfo(iWordStart, iNextStart, iWScount, ipd));
BreakPoss bp = new BreakPoss(
- new LeafPosition(this, m_vecAreaInfo.size() - 1));
- m_ipdTotal = ipd;
+ new LeafPosition(this, vecAreaInfo.size() - 1));
+ ipdTotal = ipd;
if ((flags & BreakPoss.HYPHENATED) != 0) {
// Add the hyphen size, but don't change total IPD!
bp.setStackingSize(
- MinOptMax.add(ipd, new MinOptMax(m_hyphIPD)));
+ MinOptMax.add(ipd, new MinOptMax(hyphIPD)));
} else {
bp.setStackingSize(ipd);
}
*/
//bp.setDescender(textInfo.fs.getDescender());
//bp.setAscender(textInfo.fs.getAscender());
- if (m_iNextStart == chars.length) {
+ if (iNextStart == chars.length) {
flags |= BreakPoss.ISLAST;
setFinished(true);
}
*/
while (posIter.hasNext()) {
LeafPosition tbpNext = (LeafPosition) posIter.next();
- ai = (AreaInfo) m_vecAreaInfo.get(tbpNext.getLeafPos());
+ ai = (AreaInfo) vecAreaInfo.get(tbpNext.getLeafPos());
if (iStart == -1) {
- iStart = ai.m_iStartIndex;
+ iStart = ai.iStartIndex;
}
- iWScount += ai.m_iWScount;
+ iWScount += ai.iWScount;
}
if(ai == null) {
return;
if (dSpaceAdjust > 0.0) {
// Stretch by factor
// System.err.println("Potential stretch = " +
- // (ai.m_ipdArea.max - ai.m_ipdArea.opt));
- iAdjust = (int)((double)(ai.m_ipdArea.max -
- ai.m_ipdArea.opt) * dSpaceAdjust);
+ // (ai.ipdArea.max - ai.ipdArea.opt));
+ iAdjust = (int)((double)(ai.ipdArea.max -
+ ai.ipdArea.opt) * dSpaceAdjust);
} else if (dSpaceAdjust < 0.0) {
// Shrink by factor
// System.err.println("Potential shrink = " +
- // (ai.m_ipdArea.opt - ai.m_ipdArea.min));
- iAdjust = (int)((double)(ai.m_ipdArea.opt -
- ai.m_ipdArea.min) * dSpaceAdjust);
+ // (ai.ipdArea.opt - ai.ipdArea.min));
+ iAdjust = (int)((double)(ai.ipdArea.opt -
+ ai.ipdArea.min) * dSpaceAdjust);
}
// System.err.println("Text adjustment factor = " + dSpaceAdjust +
// " total=" + iAdjust);
Word word = null;
int adjust = 0;
// ingnore newline character
- if(chars[ai.m_iBreakIndex - 1] == NEWLINE) {
+ if(chars[ai.iBreakIndex - 1] == NEWLINE) {
adjust = 1;
}
- String str = new String(chars, iStart, ai.m_iBreakIndex - iStart - adjust);
+ String str = new String(chars, iStart, ai.iBreakIndex - iStart - adjust);
//if(!"".equals(str.trim())) {
word = createWord(
str,
- ai.m_ipdArea.opt + iAdjust, context.getBaseline());
+ ai.ipdArea.opt + iAdjust, context.getBaseline());
if (iWScount > 0) {
//log.error("Adjustment per word-space= " +
// iAdjust / iWScount);
//}
if ((chars[iStart] == SPACE || chars[iStart] == NBSPACE) &&
context.getLeadingSpace().hasSpaces()) {
- context.getLeadingSpace().addSpace(m_halfWS);
+ context.getLeadingSpace().addSpace(halfWS);
}
// Set LAST flag if done making characters
int iLastChar;
- for (iLastChar = ai.m_iBreakIndex;
+ for (iLastChar = ai.iBreakIndex;
iLastChar < chars.length && chars[iLastChar] == SPACE;
iLastChar++)
;
// Can we have any trailing space? Yes, if last char was a space!
context.setTrailingSpace(new SpaceSpecifier(false));
- if (chars[ai.m_iBreakIndex - 1] == SPACE ||
- chars[ai.m_iBreakIndex - 1] == NBSPACE) {
- context.getTrailingSpace().addSpace(m_halfWS);
+ if (chars[ai.iBreakIndex - 1] == SPACE ||
+ chars[ai.iBreakIndex - 1] == NBSPACE) {
+ context.getTrailingSpace().addSpace(halfWS);
}
if(word != null) {
parentLM.addChild(word);
import org.apache.fop.layout.BackgroundProps;
import java.util.ArrayList;
+import java.util.List;
/**
* LayoutManager for a table-cell FO.
private Block curBlockArea;
- private ArrayList childBreaks = new ArrayList();
+ private List childBreaks = new ArrayList();
private int xoffset;
private int itemIPD;
* @param childArea the child to add to the cell
* @return unused
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
curBlockArea.addBlock((Block) childArea);
- return false;
}
- return false;
}
/**
import java.util.List;
/**
- * LayoutManager for a table FO.
- * A table consists of columns, table header, table footer and multiple
- * table bodies.
- * The header, footer and body add the areas created from the table cells.
- * The table then creates areas for the columns, bodies and rows
- * the render background.
+ * LayoutManager for a list-block FO.
+ * A list block contains list items which are stacked within
+ * the list block area..
*/
public class ListBlockLayoutManager extends BlockStackingLayoutManager {
- private List columns = null;
-
private BorderAndPadding borderProps = null;
private BackgroundProps backgroundProps;
private Block curBlockArea;
- private ArrayList bodyBreaks = new ArrayList();
+ private List bodyBreaks = new ArrayList();
private class SectionPosition extends LeafPosition {
protected List list;
* @return the next break possibility
*/
public BreakPoss getNextBreakPoss(LayoutContext context) {
- ListItemLayoutManager curLM; // currently active LM
+ LayoutManager curLM; // currently active LM
MinOptMax stackSize = new MinOptMax();
// if starting add space before
// stackSize.add(spaceBefore);
BreakPoss lastPos = null;
- while ((curLM = (ListItemLayoutManager)getChildLM()) != null) {
+ while ((curLM = (LayoutManager)getChildLM()) != null) {
// Make break positions
// Set up a LayoutContext
int ipd = context.getRefIPD();
int listHeight = 0;
- ListItemLayoutManager childLM;
+ LayoutManager childLM;
int iStartPos = 0;
LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
new BreakPossPosIter(bodyBreaks, iStartPos,
lfp.getLeafPos() + 1);
iStartPos = lfp.getLeafPos() + 1;
- while ((childLM = (ListItemLayoutManager)breakPosIter.getNextChildLM()) != null) {
+ while ((childLM = (LayoutManager)breakPosIter.getNextChildLM()) != null) {
childLM.addAreas(breakPosIter, lc);
- listHeight += childLM.getListItemHeight();
}
}
- // add footer areas
-
- curBlockArea.setHeight(listHeight);
-
if(borderProps != null) {
addBorders(curBlockArea, borderProps);
}
* @param childArea the child area to add
* @return unused
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
- curBlockArea.addBlock((Block) childArea);
-
- return false;
+ curBlockArea.addBlock((Block) childArea);
}
- return false;
}
/**
*/
public void resetPosition(Position resetPos) {
if (resetPos == null) {
+ bodyBreaks.clear();
reset(null);
}
}
Item curLM; // currently active LM
BreakPoss lastPos = null;
- ArrayList breakList = new ArrayList();
+ List breakList = new ArrayList();
int min = 0;
int opt = 0;
} else {
break;
}
- ArrayList childBreaks = new ArrayList();
+ List childBreaks = new ArrayList();
MinOptMax stackSize = new MinOptMax();
// Set up a LayoutContext
* @param childArea the child area
* @return unused
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
curBlockArea.addBlock((Block) childArea);
- return false;
}
- return false;
}
/**
private Block curBlockArea;
- private ArrayList childBreaks = new ArrayList();
+ private List childBreaks = new ArrayList();
/**
* Create a new body layout manager.
* @param childArea the child area to add
* @return unused
*/
- public boolean addChild(Area childArea) {
- return parentLM.addChild(childArea);
+ public void addChild(Area childArea) {
+ parentLM.addChild(childArea);
}
/**
import org.apache.fop.area.MinOptMax;
import java.util.ArrayList;
+import java.util.List;
/**
* LayoutManager for a table-caption FO.
private Block curBlockArea;
- private ArrayList childBreaks = new ArrayList();
+ private List childBreaks = new ArrayList();
/**
* Create a new Caption layout manager.
* @param childArea the child area to add
* @return unused
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
curBlockArea.addBlock((Block) childArea);
- //return super.addChild(childArea);
-
- return false;
}
- return false;
}
/**
import org.apache.fop.layout.BackgroundProps;
import java.util.ArrayList;
+import java.util.List;
/**
* LayoutManager for a table-cell FO.
private Block curBlockArea;
- private ArrayList childBreaks = new ArrayList();
+ private List childBreaks = new ArrayList();
private int xoffset;
private int yoffset;
* @param childArea the child to add to the cell
* @return unused
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
curBlockArea.addBlock((Block) childArea);
- return false;
}
- return false;
}
/**
private void setupCells() {
cellList = new ArrayList();
// add cells to list
- while (m_childLMiter.hasNext()) {
- m_curChildLM = (LayoutManager) m_childLMiter.next();
- m_curChildLM.setParentLM(this);
- m_curChildLM.init();
- cellList.add(m_curChildLM);
+ while (childLMiter.hasNext()) {
+ curChildLM = (LayoutManager) childLMiter.next();
+ curChildLM.setParentLM(this);
+ curChildLM.init();
+ cellList.add(curChildLM);
}
}
LayoutManager curLM; // currently active LM
BreakPoss lastPos = null;
- ArrayList breakList = new ArrayList();
+ List breakList = new ArrayList();
int min = 0;
int opt = 0;
int cellcount = 0;
while ((curLM = getCellLM(cellcount++)) != null) {
- ArrayList childBreaks = new ArrayList();
+ List childBreaks = new ArrayList();
MinOptMax stackSize = new MinOptMax();
// Set up a LayoutContext
* @param childArea the child area
* @return unused
*/
- public boolean addChild(Area childArea) {
- return parentLM.addChild(childArea);
+ public void addChild(Area childArea) {
+ parentLM.addChild(childArea);
}
/**
import org.apache.fop.area.MinOptMax;
import java.util.ArrayList;
+import java.util.List;
/**
* LayoutManager for a table-and-caption FO.
private Block curBlockArea;
- private ArrayList childBreaks = new ArrayList();
+ private List childBreaks = new ArrayList();
/**
* Create a new table and caption layout manager.
* @param childArea the area to add
* @return unused
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
- curBlockArea.addBlock((Block) childArea);
- //return super.addChild(childArea);
-
- return false;
+ curBlockArea.addBlock((Block) childArea);
}
- return false;
}
/**
private Block curBlockArea;
- private ArrayList bodyBreaks = new ArrayList();
+ private List bodyBreaks = new ArrayList();
private BreakPoss headerBreak;
private BreakPoss footerBreak;
lm.setColumns(columns);
- ArrayList breaks = new ArrayList();
+ List breaks = new ArrayList();
while (!lm.isFinished()) {
if ((bp = lm.getNextBreakPoss(childLC)) != null) {
stackSize.add(bp.getStackingSize());
* @param childArea the child area to add
* @return unused
*/
- public boolean addChild(Area childArea) {
+ public void addChild(Area childArea) {
if (curBlockArea != null) {
- curBlockArea.addBlock((Block) childArea);
-
- return false;
+ curBlockArea.addBlock((Block) childArea);
}
- return false;
}
/**