diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2008-07-25 10:55:49 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2008-07-25 10:55:49 +0000 |
commit | d058e870151a49af34ec1e7204edd0ffc64aaefc (patch) | |
tree | 14c346af79c0d2207f98b17e1e9f0212c8c32f44 /src/java/org/apache/fop/layoutmgr | |
parent | cc5d6604bde87fca098633ceccd66fc92808bddc (diff) | |
download | xmlgraphics-fop-d058e870151a49af34ec1e7204edd0ffc64aaefc.tar.gz xmlgraphics-fop-d058e870151a49af34ec1e7204edd0ffc64aaefc.zip |
Merged revisions 679052-679352 via svnmerge from
https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r679060 | acumiskey | 2008-07-23 11:39:11 +0100 (Wed, 23 Jul 2008) | 2 lines
My bad.. copy paste error I introduced which broke forrest.
........
r679164 | jeremias | 2008-07-23 20:33:24 +0100 (Wed, 23 Jul 2008) | 1 line
Only update the generated files if any source file is newer than the generated ones.
........
r679326 | vhennebert | 2008-07-24 10:35:34 +0100 (Thu, 24 Jul 2008) | 2 lines
Fed up with all those trailing whitespaces. Let's remove them all (once... and for all?)
........
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@679758 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr')
105 files changed, 1665 insertions, 1665 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java index 27189bf86..f7acf3eb5 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,9 +31,9 @@ import org.apache.fop.fo.FObj; * and the {@link org.apache.fop.datatypes.PercentBaseContext} interfaces * into a common base class for all higher LayoutManagers. */ -public abstract class AbstractBaseLayoutManager +public abstract class AbstractBaseLayoutManager implements LayoutManager, PercentBaseContext { - + /** Indicator if this LM generates reference areas. */ protected boolean generatesReferenceArea = false; /** Indicator if this LM generates block areas. */ @@ -67,7 +67,7 @@ public abstract class AbstractBaseLayoutManager } // --------- Property Resolution related functions --------- // - + /** {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobjx) { if (fobjx == this.fobj) { @@ -201,7 +201,7 @@ public abstract class AbstractBaseLayoutManager throw new UnsupportedOperationException( "getContentAreaIPD() called when it should have been overridden"); } - + /** * {@inheritDoc} * <i>NOTE: Should be overridden by subclasses. @@ -211,27 +211,27 @@ public abstract class AbstractBaseLayoutManager throw new UnsupportedOperationException( "getContentAreaBPD() called when it should have been overridden"); } - + /** {@inheritDoc} */ public boolean getGeneratesReferenceArea() { return generatesReferenceArea; } - + /** * Lets implementing LM set the flag indicating if they * generate reference areas. - * @param generatesReferenceArea if true the areas generates by this LM are + * @param generatesReferenceArea if true the areas generates by this LM are * reference areas. */ protected void setGeneratesReferenceArea(boolean generatesReferenceArea) { this.generatesReferenceArea = generatesReferenceArea; } - + /** {@inheritDoc} */ public boolean getGeneratesBlockArea() { return generatesBlockArea; } - + /** * Lets implementing LM set the flag indicating if they * generate block areas. @@ -240,17 +240,17 @@ public abstract class AbstractBaseLayoutManager protected void setGeneratesBlockArea(boolean generatesBlockArea) { this.generatesBlockArea = generatesBlockArea; } - + /** {@inheritDoc} */ public boolean getGeneratesLineArea() { return false; } - + /** * {@inheritDoc} */ public FObj getFObj() { return fobj; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index c830220e7..624bc907a 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -61,7 +61,7 @@ public abstract class AbstractBreaker { public class BlockSequence extends BlockKnuthSequence { - /** Number of elements to ignore at the beginning of the list. */ + /** Number of elements to ignore at the beginning of the list. */ public int ignoreAtStart = 0; /** Number of elements to ignore at the end of the list. */ public int ignoreAtEnd = 0; @@ -69,17 +69,17 @@ public abstract class AbstractBreaker { /** * startOn represents where on the page/which page layout * should start for this BlockSequence. Acceptable values: - * Constants.EN_ANY (can continue from finished location - * of previous BlockSequence?), EN_COLUMN, EN_ODD_PAGE, - * EN_EVEN_PAGE. + * Constants.EN_ANY (can continue from finished location + * of previous BlockSequence?), EN_COLUMN, EN_ODD_PAGE, + * EN_EVEN_PAGE. */ private int startOn; private int displayAlign; - + /** * Creates a new BlockSequence. - * @param iStartOn the kind of page the sequence should start on. One of EN_ANY, EN_COLUMN, + * @param iStartOn the kind of page the sequence should start on. One of EN_ANY, EN_COLUMN, * EN_ODD_PAGE, EN_EVEN_PAGE. * @param displayAlign the value for the display-align property */ @@ -88,9 +88,9 @@ public abstract class AbstractBreaker { startOn = iStartOn; this.displayAlign = displayAlign; } - + /** - * @return the kind of page the sequence should start on. One of EN_ANY, EN_COLUMN, + * @return the kind of page the sequence should start on. One of EN_ANY, EN_COLUMN, * EN_ODD_PAGE, EN_EVEN_PAGE. */ public int getStartOn() { @@ -108,7 +108,7 @@ public abstract class AbstractBreaker { public KnuthSequence endSequence() { return endSequence(null); } - + /** * Finalizes a Knuth sequence. * @param breakPosition a Position instance for the last penalty (may be null) @@ -124,14 +124,14 @@ public abstract class AbstractBreaker { // add the elements representing the space at the end of the last line // and the forced break if (getDisplayAlign() == Constants.EN_X_DISTRIBUTE && isSinglePartFavored()) { - this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, + this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, breakPosition, false)); ignoreAtEnd = 1; } else { - this.add(new KnuthPenalty(0, KnuthElement.INFINITE, + this.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false)); this.add(new KnuthGlue(0, 10000000, 0, null, false)); - this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, + this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, breakPosition, false)); ignoreAtEnd = 3; } @@ -171,10 +171,10 @@ public abstract class AbstractBreaker { protected abstract void addAreas(PositionIterator posIter, LayoutContext context); protected abstract LayoutManager getTopLevelLM(); protected abstract LayoutManager getCurrentChildLM(); - + /** * Controls the behaviour of the algorithm in cases where the first element of a part - * overflows a line/page. + * overflows a line/page. * @return true if the algorithm should try to send the element to the next line/page. */ protected boolean isPartOverflowRecoveryActivated() { @@ -187,7 +187,7 @@ public abstract class AbstractBreaker { protected boolean isSinglePartFavored() { return false; } - + /** * Returns the PageProvider if any. PageBreaker overrides this method because each * page may have a different available BPD which needs to be accessible to the breaking @@ -197,7 +197,7 @@ public abstract class AbstractBreaker { protected PageProvider getPageProvider() { return null; } - + /** * Creates and returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to * notify about layout problems. @@ -206,11 +206,11 @@ public abstract class AbstractBreaker { protected PageBreakingAlgorithm.PageBreakingLayoutListener createLayoutListener() { return null; } - + /* * This method is to contain the logic to determine the LM's - * getNextKnuthElements() implementation(s) that are to be called. - * @return LinkedList of Knuth elements. + * getNextKnuthElements() implementation(s) that are to be called. + * @return LinkedList of Knuth elements. */ protected abstract List getNextKnuthElements(LayoutContext context, int alignment); @@ -218,18 +218,18 @@ public abstract class AbstractBreaker { public boolean isEmpty() { return (this.blockLists.isEmpty()); } - + protected void startPart(BlockSequence list, int breakClass) { //nop } - + /** * This method is called when no content is available for a part. Used to force empty pages. */ protected void handleEmptyContent() { - //nop + //nop } - + protected abstract void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp); /** @@ -239,7 +239,7 @@ public abstract class AbstractBreaker { protected LayoutContext createLayoutContext() { return new LayoutContext(0); } - + /** * Used to update the LayoutContext in subclasses prior to starting a new element list. * @param context the LayoutContext to update @@ -247,7 +247,7 @@ public abstract class AbstractBreaker { protected void updateLayoutContext(LayoutContext context) { //nop } - + /** * Used for debugging purposes. Notifies all registered observers about the element list. * Override to set different parameters. @@ -256,7 +256,7 @@ public abstract class AbstractBreaker { protected void observeElementList(List elementList) { ElementListObserver.observe(elementList, "breaker", null); } - + /** * Starts the page breaking process. * @param flowBPD the constant available block-progression-dimension (used for every part) @@ -264,7 +264,7 @@ public abstract class AbstractBreaker { public void doLayout(int flowBPD) { doLayout(flowBPD, false); } - + /** * Starts the page breaking process. * @param flowBPD the constant available block-progression-dimension (used for every part) @@ -294,7 +294,7 @@ public abstract class AbstractBreaker { this.blockLists = new java.util.ArrayList(); log.debug("PLM> flow BPD =" + flowBPD); - + //*** Phase 1: Get Knuth elements *** int nextSequenceStartsOn = Constants.EN_ANY; while (hasMoreContent()) { @@ -306,7 +306,7 @@ public abstract class AbstractBreaker { log.debug("PLM> blockLists.size() = " + blockLists.size()); for (blockListIndex = 0; blockListIndex < blockLists.size(); blockListIndex++) { blockList = (BlockSequence) blockLists.get(blockListIndex); - + //debug code start if (log.isDebugEnabled()) { log.debug(" blockListIndex = " + blockListIndex); @@ -318,7 +318,7 @@ public abstract class AbstractBreaker { observeElementList(blockList); //debug code end - log.debug("PLM> start of algorithm (" + this.getClass().getName() + log.debug("PLM> start of algorithm (" + this.getClass().getName() + "), flow BPD =" + flowBPD); PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(), getPageProvider(), createLayoutListener(), @@ -342,7 +342,7 @@ public abstract class AbstractBreaker { log.debug("PLM> iOptPageCount= " + iOptPageCount + " pageBreaks.size()= " + alg.getPageBreaks().size()); - + //*** Phase 3: Add areas *** doPhase3(alg, iOptPageCount, blockList, effectiveList); } @@ -351,36 +351,36 @@ public abstract class AbstractBreaker { } /** - * Phase 3 of Knuth algorithm: Adds the areas + * Phase 3 of Knuth algorithm: Adds the areas * @param alg PageBreakingAlgorithm instance which determined the breaks * @param partCount number of parts (pages) to be rendered * @param originalList original Knuth element list * @param effectiveList effective Knuth element list (after adjustments) */ - protected abstract void doPhase3(PageBreakingAlgorithm alg, int partCount, + protected abstract void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList); - + /** - * Phase 3 of Knuth algorithm: Adds the areas + * Phase 3 of Knuth algorithm: Adds the areas * @param alg PageBreakingAlgorithm instance which determined the breaks * @param partCount number of parts (pages) to be rendered * @param originalList original Knuth element list * @param effectiveList effective Knuth element list (after adjustments) */ - protected void addAreas(PageBreakingAlgorithm alg, int partCount, + protected void addAreas(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { addAreas(alg, 0, partCount, originalList, effectiveList); } - + /** - * Phase 3 of Knuth algorithm: Adds the areas + * Phase 3 of Knuth algorithm: Adds the areas * @param alg PageBreakingAlgorithm instance which determined the breaks * @param startPart index of the first part (page) to be rendered * @param partCount number of parts (pages) to be rendered * @param originalList original Knuth element list * @param effectiveList effective Knuth element list (after adjustments) */ - protected void addAreas(PageBreakingAlgorithm alg, int startPart, int partCount, + protected void addAreas(PageBreakingAlgorithm alg, int startPart, int partCount, BlockSequence originalList, BlockSequence effectiveList) { LayoutContext childLC; // add areas @@ -404,13 +404,13 @@ public abstract class AbstractBreaker { lastBreakClass = Constants.EN_COLUMN; } } - + //the end of the new part endElementIndex = pbp.getLeafPos(); // ignore the first elements added by the // PageSequenceLayoutManager - startElementIndex += (startElementIndex == 0) + startElementIndex += (startElementIndex == 0) ? effectiveList.ignoreAtStart : 0; @@ -420,16 +420,16 @@ public abstract class AbstractBreaker { + ", break class = " + lastBreakClass); startPart(effectiveList, lastBreakClass); - + int displayAlign = getCurrentDisplayAlign(); - + //The following is needed by SpaceResolver.performConditionalsNotification() //further down as there may be important Position elements in the element list trailer int notificationEndElementIndex = endElementIndex; // ignore the last elements added by the // PageSequenceLayoutManager - endElementIndex -= (endElementIndex == (originalList.size() - 1)) + endElementIndex -= (endElementIndex == (originalList.size() - 1)) ? effectiveList.ignoreAtEnd : 0; @@ -493,7 +493,7 @@ public abstract class AbstractBreaker { /* *** *** non-standard extension *** *** */ if (displayAlign == Constants.EN_X_FILL) { - int averageLineLength = optimizeLineLength(effectiveList, + int averageLineLength = optimizeLineLength(effectiveList, startElementIndex, endElementIndex); if (averageLineLength != 0) { childLC.setStackLimitBP(new MinOptMax(averageLineLength)); @@ -502,9 +502,9 @@ public abstract class AbstractBreaker { /* *** *** non-standard extension *** *** */ // Handle SpaceHandling(Break)Positions, see SpaceResolver! - SpaceResolver.performConditionalsNotification(effectiveList, + SpaceResolver.performConditionalsNotification(effectiveList, startElementIndex, notificationEndElementIndex, lastBreak); - + // Add areas now! addAreas(new KnuthPossPosIter(effectiveList, startElementIndex, endElementIndex + 1), childLC); @@ -528,7 +528,7 @@ public abstract class AbstractBreaker { * @param lastBreak index of the last break element */ /** - * Handles span changes reported through the <code>LayoutContext</code>. + * Handles span changes reported through the <code>LayoutContext</code>. * Only used by the PSLM and called by <code>getNextBlockList()</code>. * @param childLC the LayoutContext * @param nextSequenceStartsOn previous value for break handling @@ -543,12 +543,12 @@ public abstract class AbstractBreaker { * @param nextSequenceStartsOn indicates on what page the next sequence should start * @return the page on which the next content should appear after a hard break */ - protected int getNextBlockList(LayoutContext childLC, + protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn) { updateLayoutContext(childLC); //Make sure the span change signal is reset childLC.signalSpanChange(Constants.NOT_SET); - + BlockSequence blockList; List returnedList = getNextKnuthElements(childLC, alignment); if (returnedList != null) { @@ -557,10 +557,10 @@ public abstract class AbstractBreaker { return nextSequenceStartsOn; } blockList = new BlockSequence(nextSequenceStartsOn, getCurrentDisplayAlign()); - + //Only implemented by the PSLM nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn); - + Position breakPosition = null; if (((KnuthElement) ListUtil.getLast(returnedList)).isForcedBreak()) { KnuthPenalty breakPenalty = (KnuthPenalty) ListUtil @@ -585,7 +585,7 @@ public abstract class AbstractBreaker { nextSequenceStartsOn = Constants.EN_EVEN_PAGE; break; default: - throw new IllegalStateException("Invalid break class: " + throw new IllegalStateException("Invalid break class: " + breakPenalty.getBreakClass()); } } @@ -649,7 +649,7 @@ public abstract class AbstractBreaker { * Justifies the boxes and returns them as a new KnuthSequence. * @param blockList block list to justify * @param alg reference to the algorithm instance - * @param availableBPD the available BPD + * @param availableBPD the available BPD * @return the effective list */ private BlockSequence justifyBoxes(BlockSequence blockList, PageBreakingAlgorithm alg, int availableBPD) { @@ -659,7 +659,7 @@ public abstract class AbstractBreaker { 1, true, BreakingAlgorithm.ALL_BREAKS); log.debug("PLM> iOptPageNumber= " + iOptPageNumber); - // + // ListIterator sequenceIterator = blockList.listIterator(); ListIterator breakIterator = alg.getPageBreaks().listIterator(); KnuthElement thisElement = null; @@ -687,7 +687,7 @@ public abstract class AbstractBreaker { KnuthElement firstElement; while (!(firstElement = (KnuthElement) sequenceIterator .next()).isBox()) { - // + // log.debug("PLM> ignoring glue or penalty element " + "at the beginning of the sequence"); if (firstElement.isGlue()) { @@ -811,7 +811,7 @@ public abstract class AbstractBreaker { // create a new sequence: the new elements will contain the // Positions // which will be used in the addAreas() phase - BlockSequence effectiveList = new BlockSequence(blockList.getStartOn(), + BlockSequence effectiveList = new BlockSequence(blockList.getStartOn(), blockList.getDisplayAlign()); effectiveList.addAll(getCurrentChildLM().getChangedKnuthElements( blockList.subList(0, blockList.size() - blockList.ignoreAtEnd), @@ -828,7 +828,7 @@ public abstract class AbstractBreaker { private int adjustBlockSpaces(LinkedList spaceList, int difference, int total) { if (log.isDebugEnabled()) { - log.debug("AdjustBlockSpaces: difference " + difference + " / " + total + log.debug("AdjustBlockSpaces: difference " + difference + " / " + total + " on " + spaceList.size() + " spaces in block"); } ListIterator spaceListIterator = spaceList.listIterator(); @@ -839,8 +839,8 @@ public abstract class AbstractBreaker { partial += (difference > 0 ? blockSpace.getY() : blockSpace.getZ()); if (log.isDebugEnabled()) { log.debug("available = " + partial + " / " + total); - log.debug("competenza = " - + (((int)((float) partial * difference / total)) - adjustedDiff) + log.debug("competenza = " + + (((int)((float) partial * difference / total)) - adjustedDiff) + " / " + difference); } int newAdjust = ((BlockLevelLayoutManager) blockSpace.getLayoutManager()).negotiateBPDAdjustment(((int) ((float) partial * difference / total)) - adjustedDiff, blockSpace); @@ -888,5 +888,5 @@ public abstract class AbstractBreaker { } return adjustedDiff; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index 13ea66d1f..a5393ced2 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -294,7 +294,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager if (pos.getIndex() >= 0) { throw new IllegalStateException("Position already got its index"); } - + lastGeneratedPosition++; pos.setIndex(lastGeneratedPosition); return pos; @@ -383,27 +383,27 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager * Checks to see if the incoming {@link Position} * is the last one for this LM, and if so, calls * {@link #notifyEndOfLayout()} and cleans up. - * + * * @param pos the {@link Position} to check */ protected void checkEndOfLayout(Position pos) { if (pos != null && pos.getLM() == this && this.isLast(pos)) { - + notifyEndOfLayout(); - + /* References to the child LMs are no longer needed */ childLMs = null; curChildLM = null; childLMiter = null; - + /* markers that qualify have been transferred to the page */ markers = null; - - /* References to the FO's children can be released if the + + /* References to the FO's children can be released if the * LM is a descendant of the FlowLM. For static-content * the FO may still be needed on following pages. */ @@ -418,7 +418,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager } } } - + /** {@inheritDoc} */ public String toString() { return (super.toString() + (fobj != null ? "[fobj=" + fobj.toString() + "]" : "")); diff --git a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java index 2b61fb6c6..758761303 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java @@ -43,15 +43,15 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa private static Log log = LogFactory.getLog(AbstractPageSequenceLayoutManager.class); - /** + /** * AreaTreeHandler which activates the PSLM and controls * the rendering of its pages. */ protected AreaTreeHandler areaTreeHandler; - + /** ID tracker supplied by the AreaTreeHandler */ protected IDTracker idTracker; - + /** page sequence formatting object being processed by this class */ protected AbstractPageSequence pageSeq; @@ -62,7 +62,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa protected int currentPageNum = 0; /** The stating page number */ protected int startPageNum = 0; - + /** * Constructor * @@ -112,12 +112,12 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa startPageNum = pageSeq.getStartingPageNumber(); currentPageNum = startPageNum - 1; } - + /** * This returns the first PageViewport that contains an id trait * matching the idref argument, or null if no such PV exists. * - * @param idref the idref trait needing to be resolved + * @param idref the idref trait needing to be resolved * @return the first PageViewport that contains the ID trait */ public PageViewport getFirstPVWithID(String idref) { @@ -132,7 +132,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa * This returns the last PageViewport that contains an id trait * matching the idref argument, or null if no such PV exists. * - * @param idref the idref trait needing to be resolved + * @param idref the idref trait needing to be resolved * @return the last PageViewport that contains the ID trait */ public PageViewport getLastPVWithID(String idref) { @@ -142,7 +142,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa } return null; } - + /** * Add an ID reference to the current page. * When adding areas the area adds its ID reference. @@ -156,7 +156,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa idTracker.associateIDWithPageViewport(id, curPage.getPageViewport()); } } - + /** * Add an id reference of the layout manager in the AreaTreeHandler, * if the id hasn't been resolved yet @@ -175,7 +175,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa return true; } } - + /** * Notify the areaTreeHandler that the LayoutManagers containing * idrefs have finished creating areas @@ -184,16 +184,16 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa public void notifyEndOfLayout(String id) { idTracker.signalIDProcessed(id); } - + /** - * Identify an unresolved area (one needing an idref to be + * Identify an unresolved area (one needing an idref to be * resolved, e.g. the internal-destination of an fo:basic-link) * for both the AreaTreeHandler and PageViewport object. - * + * * The IDTracker keeps a document-wide list of idref's - * and the PV's needing them to be resolved. It uses this to + * and the PV's needing them to be resolved. It uses this to * send notifications to the PV's when an id has been resolved. - * + * * The PageViewport keeps lists of id's needing resolving, along * with the child areas (page-number-citation, basic-link, etc.) * of the PV needing their resolution. @@ -216,7 +216,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa * then the containing page does not have a qualifying area, * and all qualifying areas have ended. * Therefore we use last-ending-within-page (Constants.EN_LEWP) - * as the position. + * as the position. * * @param rm the RetrieveMarker instance whose properties are to * used to find the matching Marker. @@ -227,8 +227,8 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa AreaTreeModel areaTreeModel = areaTreeHandler.getAreaTreeModel(); String name = rm.getRetrieveClassName(); int pos = rm.getRetrievePosition(); - int boundary = rm.getRetrieveBoundary(); - + int boundary = rm.getRetrieveBoundary(); + // get marker from the current markers on area tree Marker mark = (Marker)getCurrentPV().getMarker(name, pos); if (mark == null && boundary != EN_PAGE) { @@ -271,10 +271,10 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa * @return the newly created page */ protected abstract Page createPage(int pageNumber, boolean isBlank); - + /** * Makes a new page - * + * * @param bIsBlank whether this page is blank or not * @param bIsLast whether this page is the last page or not * @return a new page @@ -289,14 +289,14 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa curPage = createPage(currentPageNum, isBlank); if (log.isDebugEnabled()) { - log.debug("[" + curPage.getPageViewport().getPageNumberString() + log.debug("[" + curPage.getPageViewport().getPageNumberString() + (isBlank ? "*" : "") + "]"); } - + addIDToPage(pageSeq.getId()); return curPage; } - + /** * Finishes a page in preparation for a new page. */ @@ -304,19 +304,19 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa if (log.isTraceEnabled()) { curPage.getPageViewport().dumpMarkers(); } - + // Try to resolve any unresolved IDs for the current page. - // + // idTracker.tryIDResolution(curPage.getPageViewport()); // Queue for ID resolution and rendering areaTreeHandler.getAreaTreeModel().addPage(curPage.getPageViewport()); if (log.isDebugEnabled()) { - log.debug("page finished: " + curPage.getPageViewport().getPageNumberString() + log.debug("page finished: " + curPage.getPageViewport().getPageNumberString() + ", current num: " + currentPageNum); } curPage = null; } - + /** {@inheritDoc} */ public void doForcePageCount(Numeric nextPageSeqInitialPageNumber) { @@ -325,14 +325,14 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa // xsl-spec version 1.0 (15.oct 2001) // auto | even | odd | end-on-even | end-on-odd | no-force | inherit // auto: - // Force the last page in this page-sequence to be an odd-page - // if the initial-page-number of the next page-sequence is even. - // Force it to be an even-page - // if the initial-page-number of the next page-sequence is odd. - // If there is no next page-sequence + // Force the last page in this page-sequence to be an odd-page + // if the initial-page-number of the next page-sequence is even. + // Force it to be an even-page + // if the initial-page-number of the next page-sequence is odd. + // If there is no next page-sequence // or if the value of its initial-page-number is "auto" do not force any page. - - // if force-page-count is auto then set the value of forcePageCount + + // if force-page-count is auto then set the value of forcePageCount // depending on the initial-page-number of the next page-sequence if (nextPageSeqInitialPageNumber != null && forcePageCount == Constants.EN_AUTO) { if (nextPageSeqInitialPageNumber.getEnum() != 0) { @@ -381,5 +381,5 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa finishPage(); } } - + } diff --git a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java index 1b0d02639..a429359ad 100644 --- a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java +++ b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java @@ -49,7 +49,7 @@ public class AreaAdditionUtil { * @param parentIter the position iterator * @param layoutContext the layout context */ - public static void addAreas(BlockStackingLayoutManager bslm, + public static void addAreas(BlockStackingLayoutManager bslm, PositionIterator parentIter, LayoutContext layoutContext) { LayoutManager childLM = null; LayoutContext lc = new LayoutContext(0); @@ -57,9 +57,9 @@ public class AreaAdditionUtil { LayoutManager lastLM = null; Position firstPos = null; Position lastPos = null; - + // "unwrap" the NonLeafPositions stored in parentIter - // and put them in a new list; + // and put them in a new list; LinkedList positionList = new LinkedList(); Position pos; while (parentIter.hasNext()) { @@ -93,11 +93,11 @@ public class AreaAdditionUtil { //correctly determine first and last conditions. The Iterator //doesn't give us that info. } - + if (bslm != null) { bslm.addMarkersToPage( - true, - bslm.isFirst(firstPos), + true, + bslm.isFirst(firstPos), bslm.isLast(lastPos)); } @@ -120,15 +120,15 @@ public class AreaAdditionUtil { lc.setStackLimitsFrom(layoutContext); childLM.addAreas(childPosIter, lc); } - + if (bslm != null) { bslm.addMarkersToPage( - false, - bslm.isFirst(firstPos), + false, + bslm.isFirst(firstPos), bslm.isLast(lastPos)); } - + } - + } diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java index a28fdbfbc..2bb499a36 100644 --- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java @@ -30,11 +30,11 @@ import org.apache.fop.traits.MinOptMax; public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { private Log log = LogFactory.getLog(BalancingColumnBreakingAlgorithm.class); - + private int columnCount; private int fullLen; private int idealPartLen; - + public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM, PageProvider pageProvider, PageBreakingLayoutListener layoutListener, @@ -43,18 +43,18 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { boolean partOverflowRecovery, int columnCount) { super(topLevelLM, pageProvider, layoutListener, - alignment, alignmentLast, + alignment, alignmentLast, footnoteSeparatorLength, partOverflowRecovery, false, false); this.columnCount = columnCount; this.considerTooShort = true; //This is important! } - + /** {@inheritDoc} */ protected double computeDemerits(KnuthNode activeNode, KnuthElement element, int fitnessClass, double r) { double dem = super.computeDemerits(activeNode, element, fitnessClass, r); if (log.isTraceEnabled()) { - log.trace("original demerit=" + dem + " " + totalWidth + log.trace("original demerit=" + dem + " " + totalWidth + " line=" + activeNode.line + "/" + columnCount + " pos=" + activeNode.position + "/" + (par.size() - 1)); } @@ -71,7 +71,7 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { avgRestLen = restLen / remParts; } if (log.isTraceEnabled()) { - log.trace("remaining parts: " + remParts + " rest len: " + restLen + log.trace("remaining parts: " + remParts + " rest len: " + restLen + " avg=" + avgRestLen); } double balance = (idealPartLen - partLen) / 1000f; @@ -92,9 +92,9 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { dem = dem * 1.2f; } } - //Step 2: This helps keep the trailing parts shorter than the previous ones + //Step 2: This helps keep the trailing parts shorter than the previous ones dem += (avgRestLen) / 1000f; - + if (activeNode.line >= columnCount) { //We don't want more columns than available dem = Double.MAX_VALUE; diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index 4aa73cc37..17eb44049 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,14 +44,14 @@ import org.apache.fop.util.ListUtil; /** * LayoutManager for a block-container FO. */ -public class BlockContainerLayoutManager extends BlockStackingLayoutManager +public class BlockContainerLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** * logging instance */ private static Log log = LogFactory.getLog(BlockContainerLayoutManager.class); - + private BlockViewport viewportBlockArea; private Block referenceArea; @@ -62,11 +62,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager private Length height; //private int vpContentIPD; private int vpContentBPD; - + // When viewport should grow with the content. private boolean autoHeight = true; private boolean inlineElementList = false; - + /* holds the (one-time use) fo:block space-before and -after properties. Large fo:blocks are split into multiple Area.Blocks to accomodate the subsequent @@ -78,7 +78,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager //TODO space-before|after: handle space-resolution rules private MinOptMax foBlockSpaceBefore; private MinOptMax foBlockSpaceAfter; - + private boolean discardBorderBefore; private boolean discardBorderAfter; private boolean discardPaddingBefore; @@ -86,7 +86,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager private MinOptMax effSpaceBefore; private MinOptMax effSpaceAfter; - + /** * Create a new block container layout manager. * @param node block-container node to create the layout manager for. @@ -94,7 +94,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager public BlockContainerLayoutManager(BlockContainer node) { super(node); } - + /** {@inheritDoc} */ public void initialize() { abProps = getBlockContainerFO().getCommonAbsolutePosition(); @@ -103,7 +103,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock() .spaceAfter, this).getSpace(); startIndent = getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this); + endIndent = getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this); boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); if (rotated) { @@ -117,7 +117,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager width = getBlockContainerFO().getInlineProgressionDimension() .getOptimum(this).getLength(); } - + bpUnit = 0; //layoutProps.blockProgressionUnit; if (bpUnit == 0) { // use optimum space values @@ -133,11 +133,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .spaceAfter.getSpace().getMinimum(this).getLength().getValue(this); } } - + private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; @@ -153,11 +153,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager int overflow = getBlockContainerFO().getOverflow(); return (overflow == EN_HIDDEN || overflow == EN_ERROR_IF_OVERFLOW); } - + private int getSpaceBefore() { return foBlockSpaceBefore.opt; } - + private int getBPIndents() { int indents = 0; /* TODO This is wrong isn't it? @@ -170,16 +170,16 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .getBPPaddingAndBorder(false, this); return indents; } - + private boolean isAbsoluteOrFixed() { - return (abProps.absolutePosition == EN_ABSOLUTE) + return (abProps.absolutePosition == EN_ABSOLUTE) || (abProps.absolutePosition == EN_FIXED); } private boolean isFixed() { return (abProps.absolutePosition == EN_FIXED); } - + /** {@inheritDoc} */ public int getContentAreaBPD() { if (autoHeight) { @@ -188,26 +188,26 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager return this.vpContentBPD; } } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { resetSpaces(); if (isAbsoluteOrFixed()) { return getNextKnuthElementsAbsolute(context, alignment); } - + autoHeight = false; //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); int maxbpd = context.getStackLimitBP().opt; int allocBPD; - if (height.getEnum() == EN_AUTO + if (height.getEnum() == EN_AUTO || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) { - //auto height when height="auto" or "if that dimension is not specified explicitly + //auto height when height="auto" or "if that dimension is not specified explicitly //(i.e., it depends on content's block-progression-dimension)" (XSL 1.0, 7.14.1) allocBPD = maxbpd; autoHeight = true; if (getBlockContainerFO().getReferenceOrientation() == 0) { - //Cannot easily inline element list when ref-or="180" + //Cannot easily inline element list when ref-or="180" inlineElementList = true; } } else { @@ -223,7 +223,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager int contentWidth = width.getValue(this); updateContentAreaIPDwithOverconstrainedAdjust(contentWidth); } - + double contentRectOffsetX = 0; contentRectOffsetX += getBlockContainerFO() .getCommonMarginBlock().startIndent.getValue(this); @@ -232,7 +232,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .getCommonBorderPaddingBackground().getBorderBeforeWidth(false); contentRectOffsetY += getBlockContainerFO() .getCommonBorderPaddingBackground().getPaddingBefore(false, this); - + updateRelDims(contentRectOffsetX, contentRectOffsetY, autoHeight); int availableIPD = referenceIPD - getIPIndents(); @@ -243,13 +243,13 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager getContentAreaIPD(), context.getRefIPD(), getBlockContainerFO().getLocator()); } - + MinOptMax stackLimit = new MinOptMax(relDims.bpd); List returnedList; List contentList = new LinkedList(); List returnList = new LinkedList(); - + if (!breakBeforeServed) { try { if (addKnuthElementsForBreakBefore(returnList, context)) { @@ -264,7 +264,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager addKnuthElementsForSpaceBefore(returnList, alignment); context.updateKeepWithPreviousPending(getKeepWithPreviousStrength()); } - + addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); firstVisibleMarkServed = true; @@ -366,7 +366,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager returnList.add(new KnuthBox(vpContentBPD, notifyPos(bcPosition), false)); //TODO Handle min/opt/max for block-progression-dimension /* These two elements will be used to add stretchability to the above box - returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, + returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, returnPosition, false)); returnList.add(new KnuthGlue(0, 1 * constantLineHeight, 0, LINE_NUMBER_ADJUSTMENT, returnPosition, false)); @@ -375,7 +375,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (contentOverflows) { BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( getBlockContainerFO().getUserAgent().getEventBroadcaster()); - boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW); + boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW); eventProducer.viewportOverflow(this, getBlockContainerFO().getName(), breaker.getOverflowAmount(), needClip(), canRecover, getBlockContainerFO().getLocator()); @@ -384,7 +384,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); - //All child content is processed. Only break-after can occur now, so... + //All child content is processed. Only break-after can occur now, so... context.clearPendingMarks(); addKnuthElementsForBreakAfter(returnList, context); @@ -393,7 +393,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager setFinished(true); return returnList; } - + private List getNextKnuthElementsAbsolute(LayoutContext context, int alignment) { autoHeight = false; @@ -403,7 +403,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager int allocBPD, allocIPD; if (height.getEnum() == EN_AUTO || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) { - //auto height when height="auto" or "if that dimension is not specified explicitly + //auto height when height="auto" or "if that dimension is not specified explicitly //(i.e., it depends on content's blockprogression-dimension)" (XSL 1.0, 7.14.1) allocBPD = 0; if (abProps.bottom.getEnum() != EN_AUTO) { @@ -411,7 +411,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (isFixed()) { availHeight = (int)getCurrentPV().getViewArea().getHeight(); } else { - availHeight = context.getStackLimitBP().opt; + availHeight = context.getStackLimitBP().opt; } allocBPD = availHeight; allocBPD -= offset.y; @@ -456,7 +456,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (width.getEnum() == EN_AUTO) { int availWidth; if (isFixed()) { - availWidth = (int)getCurrentPV().getViewArea().getWidth(); + availWidth = (int)getCurrentPV().getViewArea().getWidth(); } else { availWidth = context.getRefIPD(); } @@ -500,7 +500,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager vpContentBPD = allocBPD - getBPIndents(); setContentAreaIPD(allocIPD - getIPIndents()); - + updateRelDims(0, 0, autoHeight); MinOptMax range = new MinOptMax(relDims.ipd); @@ -521,12 +521,12 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (!breaker.isEmpty()) { Position bcPosition = new BlockContainerPosition(this, breaker); returnList.add(new KnuthBox(0, notifyPos(bcPosition), false)); - + //TODO Maybe check for page overflow when autoHeight=true if (!autoHeight & (contentOverflows)) { BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( getBlockContainerFO().getUserAgent().getEventBroadcaster()); - boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW); + boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW); eventProducer.viewportOverflow(this, getBlockContainerFO().getName(), breaker.getOverflowAmount(), needClip(), canRecover, getBlockContainerFO().getLocator()); @@ -539,16 +539,16 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager private void updateRelDims(double xOffset, double yOffset, boolean skipAutoHeight) { Rectangle2D rect = new Rectangle2D.Double( - xOffset, yOffset, + xOffset, yOffset, getContentAreaIPD(), this.vpContentBPD); relDims = new FODimension(0, 0); absoluteCTM = CTM.getCTMandRelDims( getBlockContainerFO().getReferenceOrientation(), - getBlockContainerFO().getWritingMode(), + getBlockContainerFO().getWritingMode(), rect, relDims); } - + private class BlockContainerPosition extends NonLeafPosition { private BlockContainerBreaker breaker; @@ -557,23 +557,23 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager super(lm, null); this.breaker = breaker; } - + public BlockContainerBreaker getBreaker() { return this.breaker; } - + } - + private class BlockContainerBreaker extends AbstractBreaker { - + private BlockContainerLayoutManager bclm; private MinOptMax ipd; - + //Info for deferred adding of areas private PageBreakingAlgorithm deferredAlg; private BlockSequence deferredOriginalList; private BlockSequence deferredEffectiveList; - + public BlockContainerBreaker(BlockContainerLayoutManager bclm, MinOptMax ipd) { this.bclm = bclm; this.ipd = ipd; @@ -581,10 +581,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ protected void observeElementList(List elementList) { - ElementListObserver.observe(elementList, "block-container", + ElementListObserver.observe(elementList, "block-container", bclm.getBlockContainerFO().getId()); } - + /** {@inheritDoc} */ protected boolean isPartOverflowRecoveryActivated() { //For block-containers, this must be disabled because of wanted overflow. @@ -600,19 +600,19 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager PageBreakPosition pbp = (PageBreakPosition)this.deferredAlg.getPageBreaks().getFirst(); return pbp.difference; } - + public boolean isOverflow() { return !isEmpty() && ((deferredAlg.getPageBreaks().size() > 1) || (deferredAlg.totalWidth - deferredAlg.totalShrink) > deferredAlg.getLineWidth()); } - + public int getOverflowAmount() { - return (deferredAlg.totalWidth - deferredAlg.totalShrink) + return (deferredAlg.totalWidth - deferredAlg.totalShrink) - deferredAlg.getLineWidth(); } - + protected LayoutManager getTopLevelLM() { return bclm; } @@ -623,7 +623,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager lc.setWritingMode(getBlockContainerFO().getWritingMode()); return lc; } - + protected List getNextKnuthElements(LayoutContext context, int alignment) { LayoutManager curLM; // currently active LM List returnList = new LinkedList(); @@ -633,7 +633,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(context.getRefIPD()); childLC.setWritingMode(getBlockContainerFO().getWritingMode()); - + List returnedList = null; if (!curLM.isFinished()) { returnedList = curLM.getNextKnuthElements(childLC, alignment); @@ -650,45 +650,45 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager protected int getCurrentDisplayAlign() { return getBlockContainerFO().getDisplayAlign(); } - + protected boolean hasMoreContent() { return !isFinished(); } - + protected void addAreas(PositionIterator posIter, LayoutContext context) { - AreaAdditionUtil.addAreas(bclm, posIter, context); + AreaAdditionUtil.addAreas(bclm, posIter, context); } - - protected void doPhase3(PageBreakingAlgorithm alg, int partCount, + + protected void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { //Defer adding of areas until addAreas is called by the parent LM this.deferredAlg = alg; this.deferredOriginalList = originalList; this.deferredEffectiveList = effectiveList; } - + protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) { //nop for bclm } - + protected LayoutManager getCurrentChildLM() { return curChildLM; } - + public void addContainedAreas() { if (isEmpty()) { return; } - //Rendering all parts (not just the first) at once for the case where the parts that + //Rendering all parts (not just the first) at once for the case where the parts that //overflow should be visible. this.deferredAlg.removeAllPageBreaks(); - this.addAreas(this.deferredAlg, - this.deferredAlg.getPageBreaks().size(), + this.addAreas(this.deferredAlg, + this.deferredAlg.getPageBreaks().size(), this.deferredOriginalList, this.deferredEffectiveList); } - + } - + private Point getAbsOffset() { int x = 0; int y = 0; @@ -696,7 +696,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager x = abProps.left.getValue(this); } else if (abProps.right.getEnum() != EN_AUTO && width.getEnum() != EN_AUTO) { - x = getReferenceAreaIPD() + x = getReferenceAreaIPD() - abProps.right.getValue(this) - width.getValue(this); } if (abProps.top.getEnum() != EN_AUTO) { @@ -708,7 +708,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } return new Point(x, y); } - + /** {@inheritDoc} */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { @@ -755,7 +755,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (bcpos != null) { throw new IllegalStateException("Only one BlockContainerPosition allowed"); } - bcpos = (BlockContainerPosition)pos; + bcpos = (BlockContainerPosition)pos; //Add child areas inside the reference area //bcpos.getBreaker().addContainedAreas(); } else if (innerPosition == null) { @@ -786,9 +786,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } addId(); - + addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); - + if (bcpos == null) { if (bpUnit == 0) { // the Positions in positionList were inside the elements @@ -831,7 +831,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager //log.debug("Adding areas from " + iFirst + " to " + iLast); //log.debug("splitLength= " + splitLength // + " (" + neededUnits(splitLength) + " units') " - // + (neededUnits(splitLength) * bpUnit - splitLength) + // + (neededUnits(splitLength) * bpUnit - splitLength) // + " spacing"); // add space before and / or after the paragraph // to reach a multiple of bpUnit @@ -864,7 +864,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .size()); //} } - + while ((childLM = childPosIter.getNextChildLM()) != null) { // set last area flag lc.setFlags(LayoutContext.LAST_AREA, @@ -880,7 +880,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); - TraitSetter.addSpaceBeforeAfter(viewportBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(viewportBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); @@ -890,7 +890,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager notifyEndOfLayout(); } - + /** * Get the parent area for children of this block container. * This returns the current block container area @@ -906,7 +906,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager viewportBlockArea = new BlockViewport(allowBPDUpdate); viewportBlockArea.addTrait(Trait.IS_VIEWPORT_AREA, Boolean.TRUE); - + viewportBlockArea.setIPD(getContentAreaIPD()); if (allowBPDUpdate) { viewportBlockArea.setBPD(0); @@ -914,22 +914,22 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager viewportBlockArea.setBPD(this.vpContentBPD); } transferForeignAttributes(viewportBlockArea); - + TraitSetter.setProducerID(viewportBlockArea, getBlockContainerFO().getId()); - TraitSetter.addBorders(viewportBlockArea, - getBlockContainerFO().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(viewportBlockArea, + getBlockContainerFO().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(viewportBlockArea, - getBlockContainerFO().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(viewportBlockArea, + getBlockContainerFO().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); - // TraitSetter.addBackground(viewportBlockArea, + // TraitSetter.addBackground(viewportBlockArea, // getBlockContainerFO().getCommonBorderPaddingBackground(), // this); - TraitSetter.addMargins(viewportBlockArea, + TraitSetter.addMargins(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground(), startIndent, endIndent, this); - + viewportBlockArea.setCTM(absoluteCTM); viewportBlockArea.setClip(needClip()); /* @@ -940,7 +940,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager viewportBlockArea.addTrait(Trait.SPACE_AFTER, new Integer(foBlockSpaceAfter.opt)); }*/ - if (abProps.absolutePosition == EN_ABSOLUTE + if (abProps.absolutePosition == EN_ABSOLUTE || abProps.absolutePosition == EN_FIXED) { Point offset = getAbsOffset(); viewportBlockArea.setXOffset(offset.x); @@ -981,17 +981,17 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } } - /** + /** * Force current area to be added to parent area. * {@inheritDoc} */ protected void flush() { viewportBlockArea.addBlock(referenceArea, autoHeight); - TraitSetter.addBackground(viewportBlockArea, + TraitSetter.addBackground(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground(), this); - + super.flush(); } @@ -1004,7 +1004,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public void discardSpace(KnuthGlue spaceGlue) { // TODO Auto-generated method stub - + } /** {@inheritDoc} */ @@ -1032,15 +1032,15 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager */ protected BlockContainer getBlockContainerFO() { return (BlockContainer) fobj; - } + } // --------- Property Resolution related functions --------- // - + /** {@inheritDoc} */ public boolean getGeneratesReferenceArea() { return true; } - + /** {@inheritDoc} */ public boolean getGeneratesBlockArea() { return true; @@ -1050,13 +1050,13 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; diff --git a/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java index d3365b10f..fac5bf075 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java @@ -26,16 +26,16 @@ import java.util.List; * Represents a list of block level Knuth elements. */ public class BlockKnuthSequence extends KnuthSequence { - + private boolean isClosed = false; - + /** * Creates a new and empty list. */ public BlockKnuthSequence() { super(); } - + /** * Creates a new list from an existing list. * @param list The list from which to create the new list. @@ -59,7 +59,7 @@ public class BlockKnuthSequence extends KnuthSequence { // log.debug("Cannot append a sequence without a BreakElement"); return false; } - + /** {@inheritDoc} */ public boolean appendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement) { diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index b6b6f921f..c641c3e69 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -42,14 +42,14 @@ import org.apache.fop.traits.SpaceVal; /** * LayoutManager for a block FO. */ -public class BlockLayoutManager extends BlockStackingLayoutManager +public class BlockLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** * logging instance */ private static Log log = LogFactory.getLog(BlockLayoutManager.class); - + private Block curBlockArea; /** Iterator over the child layout managers. */ @@ -59,7 +59,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager private Length lineHeight; private int follow = 2000; //private int middleShift = 0; - + private boolean discardBorderBefore; private boolean discardBorderAfter; private boolean discardPaddingBefore; @@ -91,7 +91,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager //middleShift = -fs.getXHeight() / 2; lineHeight = getBlockFO().getLineHeight().getOptimum(this).getLength(); startIndent = getBlockFO().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getBlockFO().getCommonMarginBlock().endIndent.getValue(this); + endIndent = getBlockFO().getCommonMarginBlock().endIndent.getValue(this); foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore, this) .getSpace(); foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter, this) @@ -114,19 +114,19 @@ public class BlockLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - resetSpaces(); + resetSpaces(); return super.getNextKnuthElements(context, alignment); } - + private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; } - + /** * Proxy iterator for Block LM. * This iterator creates and holds the complete list @@ -216,7 +216,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KeepUtil.getCombinedBlockLevelKeepStrength(getBlockFO().getKeepWithNext()); @@ -298,7 +298,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } addId(); - + addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); if (bpUnit == 0) { @@ -340,7 +340,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager //log.debug("Adding areas from " + iFirst + " to " + iLast); //log.debug("splitLength= " + splitLength // + " (" + neededUnits(splitLength) + " units') " - // + (neededUnits(splitLength) * bpUnit - splitLength) + // + (neededUnits(splitLength) * bpUnit - splitLength) // + " spacing"); // add space before and / or after the paragraph // to reach a multiple of bpUnit @@ -385,13 +385,13 @@ public class BlockLayoutManager extends BlockStackingLayoutManager addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); - TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); curBlockArea = null; resetSpaces(); - + //Notify end of block layout manager to the PSLM checkEndOfLayout(lastPos); } @@ -414,7 +414,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager curBlockArea.setIPD(super.getContentAreaIPD()); - TraitSetter.addBreaks(curBlockArea, + TraitSetter.addBreaks(curBlockArea, getBlockFO().getBreakBefore(), getBlockFO().getBreakAfter()); // Must get dimensions from parent area @@ -423,14 +423,14 @@ public class BlockLayoutManager extends BlockStackingLayoutManager // set traits TraitSetter.setProducerID(curBlockArea, getBlockFO().getId()); - TraitSetter.addBorders(curBlockArea, - getBlockFO().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(curBlockArea, + getBlockFO().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(curBlockArea, - getBlockFO().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(curBlockArea, + getBlockFO().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); TraitSetter.addMargins(curBlockArea, - getBlockFO().getCommonBorderPaddingBackground(), + getBlockFO().getCommonBorderPaddingBackground(), startIndent, endIndent, this); @@ -458,7 +458,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager */ protected void flush() { if (curBlockArea != null) { - TraitSetter.addBackground(curBlockArea, + TraitSetter.addBackground(curBlockArea, getBlockFO().getCommonBorderPaddingBackground(), this); super.flush(); @@ -472,9 +472,9 @@ public class BlockLayoutManager extends BlockStackingLayoutManager protected org.apache.fop.fo.flow.Block getBlockFO() { return (org.apache.fop.fo.flow.Block) fobj; } - + // --------- Property Resolution related functions --------- // - + /** * Returns the IPD of the content area * @return the IPD of the content area @@ -485,7 +485,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } return super.getContentAreaIPD(); } - + /** * Returns the BPD of the content area @@ -497,7 +497,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } return -1; } - + /** * {@inheritDoc} */ @@ -509,13 +509,13 @@ public class BlockLayoutManager extends BlockStackingLayoutManager public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; diff --git a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java index b1dd7ef5d..222ce277e 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java @@ -34,7 +34,7 @@ public interface BlockLevelEventProducer extends EventProducer { * Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -56,7 +56,7 @@ public interface BlockLevelEventProducer extends EventProducer { * @event.severity WARN */ void rowTooTall(Object source, int row, int effCellBPD, int maxCellBPD, Locator loc); - + /** * Auto-table layout is not supported, yet. * @param source the event source @@ -64,28 +64,28 @@ public interface BlockLevelEventProducer extends EventProducer { * @event.severity INFO */ void tableFixedAutoWidthNotSupported(Object source, Locator loc); - + /** * An formatting object is too wide. * @param source the event source - * @param elementName the formatting object + * @param elementName the formatting object * @param effIPD the effective extent in inline-progression direction of the table contents * @param maxIPD the maximum extent in inline-progression direction available * @param loc the location of the error or null * @event.severity WARN */ void objectTooWide(Object source, String elementName, int effIPD, int maxIPD, Locator loc); - + /** * An overconstrained geometry adjustment rule was triggered (5.3.4, XSL 1.0). * @param source the event source - * @param elementName the formatting object + * @param elementName the formatting object * @param amount the amount of the adjustment (in mpt) * @param loc the location of the error or null * @event.severity INFO */ void overconstrainedAdjustEndIndent(Object source, String elementName, int amount, Locator loc); - + /** * Contents overflow a viewport. * @param source the event source @@ -97,10 +97,10 @@ public interface BlockLevelEventProducer extends EventProducer { * @throws LayoutException the layout error provoked by the method call * @event.severity FATAL */ - void viewportOverflow(Object source, String elementName, + void viewportOverflow(Object source, String elementName, int amount, boolean clip, boolean canRecover, Locator loc) throws LayoutException; - + /** * Contents overflow a region viewport. * @param source the event source @@ -117,7 +117,7 @@ public interface BlockLevelEventProducer extends EventProducer { String page, int amount, boolean clip, boolean canRecover, Locator loc) throws LayoutException; - + /** * Indicates that FOP doesn't support flows that are not mapped to region-body, yet. * @param source the event source @@ -129,7 +129,7 @@ public interface BlockLevelEventProducer extends EventProducer { */ void flowNotMappingToRegionBody(Object source, String flowName, String masterName, Locator loc) throws UnsupportedOperationException; - + /** * A page sequence master is exhausted. * @param source the event source @@ -152,7 +152,7 @@ public interface BlockLevelEventProducer extends EventProducer { */ void missingSubsequencesInPageSequenceMaster(Object source, String pageSequenceMasterName, Locator loc) throws PageProductionException; - + /** * No single-page-master matching in page sequence master. * @param source the event source @@ -164,5 +164,5 @@ public interface BlockLevelEventProducer extends EventProducer { */ void noMatchingPageMaster(Object source, String pageSequenceMasterName, String pageMasterName, Locator loc) throws PageProductionException; - + } diff --git a/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java index 765bb1086..9163193a2 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; /** @@ -39,7 +39,7 @@ public interface BlockLevelLayoutManager extends LayoutManager { int KEEP_AUTO = Integer.MIN_VALUE; /** The integer value for "always" keep strength */ int KEEP_ALWAYS = Integer.MAX_VALUE; - + int negotiateBPDAdjustment(int adj, KnuthElement lastElement); void discardSpace(KnuthGlue spaceGlue); @@ -60,7 +60,7 @@ public interface BlockLevelLayoutManager extends LayoutManager { * @return the keep-with-previous strength */ int getKeepWithPreviousStrength(); - + /** * @return true if this element must be kept with the previous element. */ @@ -71,7 +71,7 @@ public interface BlockLevelLayoutManager extends LayoutManager { * @return the keep-with-next strength */ int getKeepWithNextStrength(); - + /** * @return true if this element must be kept with the next element. */ diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index 4360f62e9..1d6662cb2 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -91,7 +91,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager private Position auxiliaryPosition; private int contentAreaIPD = 0; - + /** * @param node the fo this LM deals with */ @@ -100,7 +100,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager setGeneratesBlockArea(true); } - /** + /** * @return current area being filled */ protected BlockParent getCurrentArea() { @@ -181,7 +181,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } return this.auxiliaryPosition; } - + /** * @param len length in millipoints to span with bp units * @return the minimum integer n such that n * bpUnit >= len @@ -194,7 +194,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * Determines and sets the content area IPD based on available reference area IPD, start- and * end-indent properties. * end-indent is adjusted based on overconstrained geometry rules, if necessary. - * + * * @return the resulting content area IPD */ protected int updateContentAreaIPDwithOverconstrainedAdjust() { @@ -213,9 +213,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager setContentAreaIPD(ipd); return ipd; } - + /** - * Sets the content area IPD by directly supplying the value. + * Sets the content area IPD by directly supplying the value. * end-indent is adjusted based on overconstrained geometry rules, if necessary. * @param contentIPD the IPD of the content * @return the resulting content area IPD @@ -234,7 +234,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager setContentAreaIPD(contentIPD); return contentIPD; } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { //log.debug("BLM.getNextKnuthElements> keep-together = " @@ -247,7 +247,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager BlockLevelLayoutManager prevLM = null; // previously active LM referenceIPD = context.getRefIPD(); - + updateContentAreaIPDwithOverconstrainedAdjust(); List returnedList = null; @@ -268,16 +268,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager addKnuthElementsForSpaceBefore(returnList, alignment); context.updateKeepWithPreviousPending(getKeepWithPreviousStrength()); } - + addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); firstVisibleMarkServed = true; //Spaces, border and padding to be repeated at each break addPendingMarks(context); - + //Used to indicate a special break-after case when all content has already been generated. BreakElement forcedBreakAfterLast = null; - + while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) { LayoutContext childLC = new LayoutContext(0); childLC.copyPendingMarksFrom(context); @@ -314,13 +314,13 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } if (contentList.isEmpty()) { - // Empty fo:block, zero-length box makes sure the IDs and/or markers + // Empty fo:block, zero-length box makes sure the IDs and/or markers // are registered and borders/padding are painted. returnList.add(new KnuthBox(0, notifyPos(new Position(this)), false)); } // a descendant of this block has break-before contentList.addAll(returnedList); - + /* extension: conversione di tutta la sequenza fin'ora ottenuta */ if (bpUnit > 0) { storedList = contentList; @@ -350,7 +350,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // a descendant of this block has break-after if (curLM.isFinished() && !hasNextChildLM()) { forcedBreakAfterLast = (BreakElement) ListUtil - .removeLast(contentList); + .removeLast(contentList); context.clearPendingMarks(); break; } @@ -385,15 +385,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (!contentList.isEmpty()) { wrapPositionElements(contentList, returnList); } else if (forcedBreakAfterLast == null) { - // Empty fo:block, zero-length box makes sure the IDs and/or markers + // Empty fo:block, zero-length box makes sure the IDs and/or markers // are registered. returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true)); } addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); - - //All child content is processed. Only break-after can occur now, so... + + //All child content is processed. Only break-after can occur now, so... context.clearPendingMarks(); if (forcedBreakAfterLast == null) { addKnuthElementsForBreakAfter(returnList, context); @@ -403,9 +403,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager forcedBreakAfterLast.clearPendingMarks(); wrapPositionElement(forcedBreakAfterLast, returnList, false); } - + context.updateKeepWithNextPending(getKeepWithNextStrength()); - + setFinished(true); return returnList; @@ -419,20 +419,20 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager */ protected void addInBetweenBreak(List contentList, LayoutContext context, LayoutContext childLC) { - if (mustKeepTogether() + if (mustKeepTogether() || context.isKeepWithNextPending() || childLC.isKeepWithPreviousPending()) { - + int strength = getKeepTogetherStrength(); - + //Handle pending keep-with-next strength = Math.max(strength, context.getKeepWithNextPending()); context.clearKeepWithNextPending(); - + //Handle pending keep-with-previous from child LM strength = Math.max(strength, childLC.getKeepWithPreviousPending()); childLC.clearKeepWithPreviousPending(); - + int penalty = KeepUtil.getPenaltyForKeep(strength); // add a penalty to forbid or discourage a break between blocks @@ -440,7 +440,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager new Position(this), penalty, context)); return; } - + ListElement last = (ListElement) ListUtil.getLast(contentList); if (last.isGlue()) { // the last element in contentList is a glue; @@ -465,7 +465,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // areas for following Positions. The above test aims at preventing // such a situation from occurring. add a null penalty to allow a break // between blocks - + // add a null penalty to allow a break between blocks contentList.add(new BreakElement( new Position(this), 0, context)); @@ -473,11 +473,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { /*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> " + adj); -/*LF*/ //log.debug(" lastElement e' " + (lastElement.isPenalty() +/*LF*/ //log.debug(" lastElement e' " + (lastElement.isPenalty() // ? "penalty" : (lastElement.isGlue() ? "glue" : "box" ))); /*LF*/ //log.debug(" position e' " + lastElement.getPosition().getClass().getName()); /*LF*/ //log.debug(" " + (bpUnit > 0 ? "unit" : "")); @@ -497,9 +497,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return adj; } else if (innerPosition instanceof MappingPosition) { // this block has block-progression-unit > 0: the adjustment can concern - // - the space-before or space-after of this block, + // - the space-before or space-after of this block, // - the line number of a descendant of this block - MappingPosition mappingPos = (MappingPosition)innerPosition; + MappingPosition mappingPos = (MappingPosition)innerPosition; if (lastElement.isGlue()) { // lastElement is a glue /*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> bpunit con glue"); @@ -512,7 +512,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager newAdjustment += ((BlockLevelLayoutManager)storedElement .getLayoutManager()).negotiateBPDAdjustment( adj - newAdjustment, storedElement); -/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> (progressivo) righe: " +/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> (progressivo) righe: " // + newAdjustment); } } @@ -530,7 +530,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // the original penalty has width > 0 /*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> chiamata passata"); return ((BlockLevelLayoutManager)storedPenalty.getLayoutManager()) - .negotiateBPDAdjustment(storedPenalty.getW(), + .negotiateBPDAdjustment(storedPenalty.getW(), (KnuthElement)storedPenalty); } else { // the original penalty has width = 0 @@ -586,11 +586,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { /*LF*/ //log.debug(""); -/*LF*/ //log.debug(" BLM.getChangedKnuthElements> inizio: oldList.size() = " +/*LF*/ //log.debug(" BLM.getChangedKnuthElements> inizio: oldList.size() = " // + oldList.size()); ListIterator oldListIterator = oldList.listIterator(); KnuthElement returnedElement; @@ -605,10 +605,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager while (oldListIterator.hasNext()) { oldElement = (KnuthElement)oldListIterator.next(); Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition(); - //log.debug(" BLM> unwrapping: " - // + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) + //log.debug(" BLM> unwrapping: " + // + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) // + " creato da " + oldElement.getLayoutManager().getClass().getName()); - //log.debug(" BLM> unwrapping: " + //log.debug(" BLM> unwrapping: " // + oldElement.getPosition().getClass().getName()); if (innerPosition != null) { // oldElement was created by a descendant of this BlockLM @@ -645,18 +645,18 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } int iLast = ((MappingPosition) el.getPosition()).getLastIndex(); - //log-debug(" si usa storedList da " + iFirst + " a " + iLast + //log-debug(" si usa storedList da " + iFirst + " a " + iLast // + " compresi su " + storedList.size() + " elementi totali"); workList = storedList.subList(iFirst, iLast + 1); } ListIterator workListIterator = workList.listIterator(); - //log.debug(" BLM.getChangedKnuthElements> workList.size() = " + //log.debug(" BLM.getChangedKnuthElements> workList.size() = " // + workList.size() + " da 0 a " + (workList.size() - 1)); while (workListIterator.hasNext()) { currElement = (KnuthElement) workListIterator.next(); - //log.debug("elemento n. " + workListIterator.previousIndex() + //log.debug("elemento n. " + workListIterator.previousIndex() // + " nella workList"); if (prevElement != null && prevElement.getLayoutManager() != currElement.getLayoutManager()) { @@ -667,8 +667,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager currElement.getLayoutManager(); boolean bSomethingAdded = false; if (prevLM != this) { - //log.debug(" BLM.getChangedKnuthElements> chiamata da " - // + fromIndex + " a " + workListIterator.previousIndex() + " su " + //log.debug(" BLM.getChangedKnuthElements> chiamata da " + // + fromIndex + " a " + workListIterator.previousIndex() + " su " // + prevLM.getClass().getName()); returnedList.addAll(prevLM.getChangedKnuthElements(workList.subList( fromIndex, workListIterator.previousIndex()), alignment)); @@ -677,7 +677,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // prevLM == this // do nothing //log.debug(" BLM.getChangedKnuthElements> elementi propri, " - // + "ignorati, da " + fromIndex + " a " + workListIterator.previousIndex() + // + "ignorati, da " + fromIndex + " a " + workListIterator.previousIndex() // + " su " + prevLM.getClass().getName()); } fromIndex = workListIterator.previousIndex(); @@ -692,7 +692,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager || prevLM.mustKeepWithNext() || currLM.mustKeepWithPrevious())) { // add an infinite penalty to forbid a break between blocks - returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, + returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new Position(this), false)); } else if (bSomethingAdded && !((KnuthElement) ListUtil.getLast(returnedList)) @@ -707,7 +707,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager BlockLevelLayoutManager currLM = (BlockLevelLayoutManager) currElement.getLayoutManager(); if (currLM != this) { - //log.debug(" BLM.getChangedKnuthElements> chiamata da " + fromIndex + //log.debug(" BLM.getChangedKnuthElements> chiamata da " + fromIndex // + " a " + oldList.size() + " su " + currLM.getClass().getName()); returnedList.addAll(currLM.getChangedKnuthElements( workList.subList(fromIndex, workList.size()), alignment)); @@ -718,7 +718,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (!returnedList.isEmpty()) { ListUtil.removeLast(returnedList); } - //log.debug(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " + //log.debug(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " // + fromIndex + " a " + workList.size()); } } @@ -747,7 +747,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } - //log.debug(" BLM.getChangedKnuthElements> intermedio: returnedList.size() = " + //log.debug(" BLM.getChangedKnuthElements> intermedio: returnedList.size() = " // + returnedList.size()); /* estensione: conversione complessiva */ @@ -774,18 +774,18 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } if (bpUnit > 0 || adjustedSpaceAfter != 0) { if (!spaceAfterIsConditional) { - returnList.add(new KnuthPenalty(0, + returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new NonLeafPosition(this, null), false)); } if (bpUnit > 0) { returnList.add(new KnuthGlue(0, 0, 0, - SPACE_AFTER_ADJUSTMENT, + SPACE_AFTER_ADJUSTMENT, new NonLeafPosition(this, null), (!spaceAfterIsConditional) ? false : true)); } else { returnList.add(new KnuthGlue(adjustedSpaceAfter, 0, 0, - SPACE_AFTER_ADJUSTMENT, + SPACE_AFTER_ADJUSTMENT, new NonLeafPosition(this, null), (!spaceAfterIsConditional) ? false : true)); } @@ -795,7 +795,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } - //log.debug(" BLM.getChangedKnuthElements> finished: returnList.size() = " + //log.debug(" BLM.getChangedKnuthElements> finished: returnList.size() = " // + returnList.size()); return returnList; } @@ -807,7 +807,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected int getParentKeepTogetherStrength() { int strength = KEEP_AUTO; if (getParent() instanceof BlockLevelLayoutManager) { - strength = ((BlockLevelLayoutManager)getParent()).getKeepTogetherStrength(); + strength = ((BlockLevelLayoutManager)getParent()).getKeepTogetherStrength(); } else if (getParent() instanceof InlineLayoutManager) { if (((InlineLayoutManager) getParent()).mustKeepTogether()) { strength = KEEP_ALWAYS; @@ -817,7 +817,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } return strength; } - + /** {@inheritDoc} */ public boolean mustKeepTogether() { return getKeepTogetherStrength() > KEEP_AUTO; @@ -843,7 +843,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (borderAndPadding != null) { if (borderAndPadding.getBorderBeforeWidth(false) > 0) { context.addPendingBeforeMark(new BorderElement( - getAuxiliaryPosition(), + getAuxiliaryPosition(), borderAndPadding.getBorderInfo( CommonBorderPaddingBackground.BEFORE).getWidth(), RelSide.BEFORE, @@ -854,15 +854,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager getAuxiliaryPosition(), borderAndPadding.getPaddingLengthProperty( CommonBorderPaddingBackground.BEFORE), - RelSide.BEFORE, + RelSide.BEFORE, false, false, this)); } if (borderAndPadding.getBorderAfterWidth(false) > 0) { context.addPendingAfterMark(new BorderElement( - getAuxiliaryPosition(), + getAuxiliaryPosition(), borderAndPadding.getBorderInfo( CommonBorderPaddingBackground.AFTER).getWidth(), - RelSide.AFTER, + RelSide.AFTER, false, false, this)); } if (borderAndPadding.getPaddingAfter(false, this) > 0) { @@ -870,12 +870,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager getAuxiliaryPosition(), borderAndPadding.getPaddingLengthProperty( CommonBorderPaddingBackground.AFTER), - RelSide.AFTER, + RelSide.AFTER, false, false, this)); } } } - + /** @return the border, padding and background info structure */ private CommonBorderPaddingBackground getBorderPaddingBackground() { if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -897,7 +897,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return null; } } - + /** @return the space-before property */ private SpaceProperty getSpaceBeforeProperty() { if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -919,7 +919,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return null; } } - + /** @return the space-after property */ private SpaceProperty getSpaceAfterProperty() { if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -941,11 +941,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return null; } } - + /** * Creates Knuth elements for before border padding and adds them to the return list. * @param returnList return list to add the additional elements to - * @param isFirst true if this is the first time a layout manager instance needs to generate + * @param isFirst true if this is the first time a layout manager instance needs to generate * border and padding */ protected void addKnuthElementsForBorderPaddingBefore(List returnList, boolean isFirst) { @@ -954,7 +954,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (borderAndPadding != null) { if (borderAndPadding.getBorderBeforeWidth(false) > 0) { returnList.add(new BorderElement( - getAuxiliaryPosition(), + getAuxiliaryPosition(), borderAndPadding.getBorderInfo(CommonBorderPaddingBackground.BEFORE) .getWidth(), RelSide.BEFORE, isFirst, false, this)); @@ -963,7 +963,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager returnList.add(new PaddingElement( getAuxiliaryPosition(), borderAndPadding.getPaddingLengthProperty( - CommonBorderPaddingBackground.BEFORE), + CommonBorderPaddingBackground.BEFORE), RelSide.BEFORE, isFirst, false, this)); } } @@ -972,7 +972,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for after border padding and adds them to the return list. * @param returnList return list to add the additional elements to - * @param isLast true if this is the last time a layout manager instance needs to generate + * @param isLast true if this is the last time a layout manager instance needs to generate * border and padding */ protected void addKnuthElementsForBorderPaddingAfter(List returnList, boolean isLast) { @@ -988,7 +988,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } if (borderAndPadding.getBorderAfterWidth(false) > 0) { returnList.add(new BorderElement( - getAuxiliaryPosition(), + getAuxiliaryPosition(), borderAndPadding.getBorderInfo(CommonBorderPaddingBackground.AFTER) .getWidth(), RelSide.AFTER, false, isLast, this)); @@ -1002,7 +1002,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * @param context the layout context * @return true if an element has been added due to a break-before. */ - protected boolean addKnuthElementsForBreakBefore(List returnList, + protected boolean addKnuthElementsForBreakBefore(List returnList, LayoutContext context) { int breakBefore = -1; if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -1017,11 +1017,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager breakBefore = ((org.apache.fop.fo.flow.table.Table) fobj).getBreakBefore(); } if (breakBefore == EN_PAGE - || breakBefore == EN_COLUMN - || breakBefore == EN_EVEN_PAGE + || breakBefore == EN_COLUMN + || breakBefore == EN_EVEN_PAGE || breakBefore == EN_ODD_PAGE) { // return a penalty element, representing a forced page break - returnList.add(new BreakElement(getAuxiliaryPosition(), + returnList.add(new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakBefore, context)); return true; } else { @@ -1035,7 +1035,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * @param context the layout context * @return true if an element has been added due to a break-after. */ - protected boolean addKnuthElementsForBreakAfter(List returnList, + protected boolean addKnuthElementsForBreakAfter(List returnList, LayoutContext context) { int breakAfter = -1; if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -1054,7 +1054,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager || breakAfter == EN_EVEN_PAGE || breakAfter == EN_ODD_PAGE) { // add a penalty element, representing a forced page break - returnList.add(new BreakElement(getAuxiliaryPosition(), + returnList.add(new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakAfter, context)); return true; } else { @@ -1067,21 +1067,21 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * @param returnList return list to add the additional elements to * @param alignment vertical alignment */ - protected void addKnuthElementsForSpaceBefore(List returnList/*, + protected void addKnuthElementsForSpaceBefore(List returnList/*, Position returnPosition*/, int alignment) { SpaceProperty spaceBefore = getSpaceBeforeProperty(); // append elements representing space-before if (spaceBefore != null - && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 + && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 && spaceBefore.getMaximum(this).getLength().getValue(this) == 0)) { returnList.add(new SpaceElement(getAuxiliaryPosition(), spaceBefore, - RelSide.BEFORE, + RelSide.BEFORE, true, false, this)); } /* if (bpUnit > 0 || spaceBefore != null - && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 + && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 && spaceBefore.getMaximum(this).getLength().getValue(this) == 0)) { if (spaceBefore != null && !spaceBefore.getSpace().isDiscard()) { // add elements to prevent the glue to be discarded @@ -1091,7 +1091,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } if (bpUnit > 0) { returnList.add(new KnuthGlue(0, 0, 0, - BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, + BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, getAuxiliaryPosition(), true)); } else { //if (alignment == EN_JUSTIFY) { returnList.add(new KnuthGlue( @@ -1100,11 +1100,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager - spaceBefore.getOptimum(this).getLength().getValue(this), spaceBefore.getOptimum(this).getLength().getValue(this) - spaceBefore.getMinimum(this).getLength().getValue(this), - BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, + BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, getAuxiliaryPosition(), true)); // } else { // returnList.add(new KnuthGlue( -// spaceBefore.getOptimum().getLength().getValue(this), +// spaceBefore.getOptimum().getLength().getValue(this), // 0, 0, BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, // returnPosition, true)); } @@ -1116,28 +1116,28 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * @param returnList return list to add the additional elements to * @param alignment vertical alignment */ - protected void addKnuthElementsForSpaceAfter(List returnList/*, Position returnPosition*/, + protected void addKnuthElementsForSpaceAfter(List returnList/*, Position returnPosition*/, int alignment) { SpaceProperty spaceAfter = getSpaceAfterProperty(); // append elements representing space-after if (spaceAfter != null - && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 + && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 && spaceAfter.getMaximum(this).getLength().getValue(this) == 0)) { returnList.add(new SpaceElement(getAuxiliaryPosition(), spaceAfter, - RelSide.AFTER, + RelSide.AFTER, false, true, this)); } /* if (bpUnit > 0 || spaceAfter != null - && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 + && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 && spaceAfter.getMaximum(this).getLength().getValue(this) == 0)) { if (spaceAfter != null && !spaceAfter.getSpace().isDiscard()) { returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, getAuxiliaryPosition(), false)); } if (bpUnit > 0) { - returnList.add(new KnuthGlue(0, 0, 0, + returnList.add(new KnuthGlue(0, 0, 0, BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, getAuxiliaryPosition(), true)); } else { //if (alignment == EN_JUSTIFY) { @@ -1162,7 +1162,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } protected List createUnitElements(List oldList) { - //log.debug("Start conversion: " + oldList.size() + //log.debug("Start conversion: " + oldList.size() // + " elements, space-before.min=" + layoutProps.spaceBefore.getSpace().min // + " space-after.min=" + layoutProps.spaceAfter.getSpace().min); // add elements at the beginning and at the end of oldList @@ -1192,15 +1192,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager KnuthElement element = (KnuthElement) oldListIterator.next(); if (element.isBox()) { totalLength.add(new MinOptMax(element.getW())); - //log.debug("box " + element.getW()); + //log.debug("box " + element.getW()); } else if (element.isGlue()) { totalLength.min -= ((KnuthGlue) element).getZ(); totalLength.max += ((KnuthGlue) element).getY(); //leafValue = ((LeafPosition) element.getPosition()).getLeafPos(); - //log.debug("glue " + element.getW() + " + " + //log.debug("glue " + element.getW() + " + " // + ((KnuthGlue) element).getY() + " - " + ((KnuthGlue) element).getZ()); } else { - //log.debug((((KnuthPenalty)element).getP() == KnuthElement.INFINITE + //log.debug((((KnuthPenalty)element).getP() == KnuthElement.INFINITE // ? "PENALTY " : "penalty ") + element.getW()); } } @@ -1294,12 +1294,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager int uNewShrink = (unitsBeforeBreak.opt - unitsBeforeBreak.min) - (unsuppressibleUnits.opt - unsuppressibleUnits.min); - //log.debug("(" - // + unsuppressibleUnits.min + "-" + unsuppressibleUnits.opt + "-" + //log.debug("(" + // + unsuppressibleUnits.min + "-" + unsuppressibleUnits.opt + "-" // + unsuppressibleUnits.max + ") " - // + " -> " + unitsBeforeBreak.min + "-" + unitsBeforeBreak.opt + "-" + // + " -> " + unitsBeforeBreak.min + "-" + unitsBeforeBreak.opt + "-" // + unitsBeforeBreak.max - // + " + " + unitsAfterBreak.min + "-" + unitsAfterBreak.opt + "-" + // + " + " + unitsAfterBreak.min + "-" + unitsAfterBreak.opt + "-" // + unitsAfterBreak.max // + (uLengthChange != 0 ? " [length " + uLengthChange + "] " : "") // + (uStretchChange != 0 ? " [stretch " + uStretchChange + "] " : "") @@ -1332,9 +1332,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // new infinite penalty, glue and box, if necessary if (uNewStretch - uStretchChange > 0 || uNewShrink - uShrinkChange > 0) { - int iStretchUnits = (uNewStretch - uStretchChange > 0 + int iStretchUnits = (uNewStretch - uStretchChange > 0 ? (uNewStretch - uStretchChange) : 0); - int iShrinkUnits = (uNewShrink - uShrinkChange > 0 + int iShrinkUnits = (uNewShrink - uShrinkChange > 0 ? (uNewShrink - uShrinkChange) : 0); newList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, mappingPos, @@ -1381,7 +1381,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager //log.debug(" PENALTY"); //log.debug(" glue 0 " + uStretchChange + " " + uShrinkChange); //log.debug(" penalty " + uLengthChange + " * unit"); - //log.debug(" glue 0 " + (- uStretchChange) + " " + //log.debug(" glue 0 " + (- uStretchChange) + " " // + (- uShrinkChange)); } else if (oldListIterator.hasNext()) { // new penalty @@ -1483,11 +1483,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager StackingIter(Iterator parentIter) { super(parentIter); } - + protected LayoutManager getLM(Object nextObj) { return ((Position) nextObj).getLM(); } - + protected Position getPos(Object nextObj) { return ((Position) nextObj); } @@ -1496,24 +1496,24 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected static class MappingPosition extends Position { private int iFirstIndex; private int iLastIndex; - + public MappingPosition(LayoutManager lm, int first, int last) { super(lm); iFirstIndex = first; iLastIndex = last; } - + public int getFirstIndex() { return iFirstIndex; } - + public int getLastIndex() { return iLastIndex; } } /** - * "wrap" the Position inside each element moving the elements from + * "wrap" the Position inside each element moving the elements from * SourceList to targetList * @param sourceList source list * @param targetList target list receiving the wrapped position elements @@ -1521,16 +1521,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected void wrapPositionElements(List sourceList, List targetList) { wrapPositionElements(sourceList, targetList, false); } - + /** - * "wrap" the Position inside each element moving the elements from + * "wrap" the Position inside each element moving the elements from * SourceList to targetList * @param sourceList source list * @param targetList target list receiving the wrapped position elements * @param force if true, every Position is wrapped regardless of its LM of origin */ protected void wrapPositionElements(List sourceList, List targetList, boolean force) { - + ListIterator listIter = sourceList.listIterator(); Object tempElement; while (listIter.hasNext()) { @@ -1542,7 +1542,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager force); } else if (tempElement instanceof List) { wrapPositionElements( - (List) tempElement, + (List) tempElement, targetList, force); } @@ -1563,12 +1563,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager targetList.add(el); } - + /** @return the sum of start-indent and end-indent */ protected int getIPIndents() { return startIndent + endIndent; } - + /** * Returns the IPD of the content area * @return the IPD of the content area @@ -1576,7 +1576,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager public int getContentAreaIPD() { return contentAreaIPD; } - + /** * Sets the IPD of the content area * @param contentAreaIPD the IPD of the content area @@ -1584,7 +1584,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected void setContentAreaIPD(int contentAreaIPD) { this.contentAreaIPD = contentAreaIPD; } - + /** * Returns the BPD of the content area * @return the BPD of the content area @@ -1592,6 +1592,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager public int getContentAreaBPD() { return -1; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/BorderElement.java b/src/java/org/apache/fop/layoutmgr/BorderElement.java index 410ba7ebb..67026a4c0 100644 --- a/src/java/org/apache/fop/layoutmgr/BorderElement.java +++ b/src/java/org/apache/fop/layoutmgr/BorderElement.java @@ -42,7 +42,7 @@ public class BorderElement extends BorderOrPaddingElement { boolean isFirst, boolean isLast, PercentBaseContext context) { super(position, condLength, side, isFirst, isLast, context); } - + /** {@inheritDoc} */ public void notifyLayoutManager(MinOptMax effectiveLength) { LayoutManager lm = getOriginatingLayoutManager(); @@ -54,7 +54,7 @@ public class BorderElement extends BorderOrPaddingElement { + lm.getClass().getName()); } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer("Border["); @@ -62,5 +62,5 @@ public class BorderElement extends BorderOrPaddingElement { sb.append("]"); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java b/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java index d78a92610..28820224a 100644 --- a/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java +++ b/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java @@ -41,11 +41,11 @@ public abstract class BorderOrPaddingElement extends UnresolvedListElementWithLe RelSide side, boolean isFirst, boolean isLast, PercentBaseContext context) { super(position, - new MinOptMax(condLength.getLength().getValue(context)), side, + new MinOptMax(condLength.getLength().getValue(context)), side, condLength.isDiscard(), isFirst, isLast); } - + /** {@inheritDoc} */ public abstract void notifyLayoutManager(MinOptMax effectiveLength); - + } diff --git a/src/java/org/apache/fop/layoutmgr/BreakElement.java b/src/java/org/apache/fop/layoutmgr/BreakElement.java index 3ccfbf616..98e31dbf8 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakElement.java +++ b/src/java/org/apache/fop/layoutmgr/BreakElement.java @@ -33,7 +33,7 @@ public class BreakElement extends UnresolvedListElement { private int breakClass = -1; private List pendingBeforeMarks; private List pendingAfterMarks; - + /** * Main constructor * @param position the Position instance needed by the addAreas stage of the LMs. @@ -43,10 +43,10 @@ public class BreakElement extends UnresolvedListElement { public BreakElement(Position position, int penaltyValue, LayoutContext context) { this(position, 0, penaltyValue, -1, context); } - + /** * Constructor for hard breaks. - * + * * @param position the Position instance needed by the addAreas stage of the LMs. * @param penaltyWidth the penalty width * @param penaltyValue the penalty value for the penalty element to be constructed @@ -55,7 +55,7 @@ public class BreakElement extends UnresolvedListElement { * {@link Constants#EN_EVEN_PAGE}, {@link Constants#EN_ODD_PAGE}) * @param context the layout context which contains the pending conditional elements */ - public BreakElement(Position position, int penaltyWidth, int penaltyValue, + public BreakElement(Position position, int penaltyWidth, int penaltyValue, int breakClass, LayoutContext context) { super(position); this.penaltyWidth = penaltyWidth; @@ -64,7 +64,7 @@ public class BreakElement extends UnresolvedListElement { this.pendingBeforeMarks = context.getPendingBeforeMarks(); this.pendingAfterMarks = context.getPendingAfterMarks(); } - + /** {@inheritDoc} */ public boolean isConditional() { return false; //Does not really apply here @@ -80,12 +80,12 @@ public class BreakElement extends UnresolvedListElement { public int getPenaltyWidth() { return this.penaltyWidth; } - + /** @return the penalty value */ public int getPenaltyValue() { return this.penaltyValue; } - + /** * Sets the penalty value. * @param p the new penalty value @@ -93,15 +93,15 @@ public class BreakElement extends UnresolvedListElement { public void setPenaltyValue(int p) { this.penaltyValue = p; } - + /** {@inheritDoc} */ public boolean isForcedBreak() { return penaltyValue == -KnuthElement.INFINITE; } - + /** * Returns the break class of this penalty. - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, * {@link Constants#EN_ODD_PAGE} @@ -109,10 +109,10 @@ public class BreakElement extends UnresolvedListElement { public int getBreakClass() { return breakClass; } - + /** * Sets the break class. - * + * * @param breakClass one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, * {@link Constants#EN_ODD_PAGE} @@ -120,17 +120,17 @@ public class BreakElement extends UnresolvedListElement { public void setBreakClass(int breakClass) { this.breakClass = breakClass; } - + /** @return the pending border and padding elements at the before edge */ public List getPendingBeforeMarks() { return this.pendingBeforeMarks; } - + /** @return the pending border and padding elements at the after edge */ public List getPendingAfterMarks() { return this.pendingAfterMarks; } - + /** * Clears all pending marks associated with this break element. This is used in break * cases where we only know very late if the break is actually after all the content @@ -140,7 +140,7 @@ public class BreakElement extends UnresolvedListElement { this.pendingBeforeMarks = null; this.pendingAfterMarks = null; } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java index df4bb1d47..0bf228e7e 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,24 +26,24 @@ import org.apache.fop.fo.FONode; /** * The set of nodes is sorted into lines indexed into activeLines. - * The nodes in each line are linked together in a single linked list by the + * The nodes in each line are linked together in a single linked list by the * KnuthNode.next field. The activeLines array contains a link to the head of * the linked list in index 'line*2' and a link to the tail at index 'line*2+1'. * <p> - * The set of active nodes can be traversed by + * The set of active nodes can be traversed by * <pre> * for (int line = startLine; line < endLine; line++) { * for (KnuthNode node = getNode(line); node != null; node = node.next) { * // Do something with 'node' * } * } - * </pre> + * </pre> */ public abstract class BreakingAlgorithm { /** the logger for the class */ protected static Log log = LogFactory.getLog(BreakingAlgorithm.class); - + /** Maximum adjustment ration */ protected static final int INFINITE_RATIO = 1000; @@ -79,7 +79,7 @@ public abstract class BreakingAlgorithm { * The paragraph of KnuthElements. */ protected KnuthSequence par; - + /** * The width of a line (or height of a column in page-breaking mode). * -1 indicates that the line widths are different for each line. @@ -118,12 +118,12 @@ public abstract class BreakingAlgorithm { * line number l corresponds to the number of the line ending at the node's breakpoint. */ protected KnuthNode[] activeLines; - + /** * The number of active nodes. */ protected int activeNodeCount; - + /** * The lowest available line in the set of active nodes. */ @@ -218,7 +218,7 @@ public abstract class BreakingAlgorithm { /** best node for the preceding breakpoint */ public KnuthNode previous; - /** next possible node in the same line */ + /** next possible node in the same line */ public KnuthNode next; /** @@ -226,7 +226,7 @@ public abstract class BreakingAlgorithm { * into a line. */ public int fitRecoveryCounter = 0; - + public KnuthNode(int position, int line, int fitness, int totalWidth, int totalStretch, int totalShrink, double adjustRatio, int availableShrink, int availableStretch, @@ -249,7 +249,7 @@ public abstract class BreakingAlgorithm { return "<KnuthNode at " + position + " " + totalWidth + "+" + totalStretch + "-" + totalShrink + " line:" + line + " prev:" + (previous != null ? previous.position : -1) - + " dem:" + totalDemerits + ">"; + + " dem:" + totalDemerits + ">"; } } @@ -363,10 +363,10 @@ public abstract class BreakingAlgorithm { protected int getMaxRecoveryAttempts() { return MAX_RECOVERY_ATTEMPTS; } - + /** * Controls the behaviour of the algorithm in cases where the first element of a part - * overflows a line/page. + * overflows a line/page. * @return true if the algorithm should try to send the element to the next line/page. */ protected boolean isPartOverflowRecoveryActivated() { @@ -397,13 +397,13 @@ public abstract class BreakingAlgorithm { } /** @see #findBreakingPoints(KnuthSequence, int, double, boolean, int) */ - public int findBreakingPoints(KnuthSequence par, - double threshold, + public int findBreakingPoints(KnuthSequence par, + double threshold, boolean force, int allowedBreaks) { return findBreakingPoints(par, 0, threshold, force, allowedBreaks); } - + /** Finds an optimal set of breakpoints for the given paragraph. * @param par the paragraph to break * @param startIndex index of the Knuth element at which the breaking must start @@ -425,7 +425,7 @@ public abstract class BreakingAlgorithm { // reset lastTooShort and lastTooLong, as they could be not null // because of previous calls to findBreakingPoints - lastTooShort = lastTooLong = null; + lastTooShort = lastTooLong = null; // reset startLine and endLine startLine = endLine = 0; // current element in the paragraph @@ -449,7 +449,7 @@ public abstract class BreakingAlgorithm { if (log.isTraceEnabled()) { log.trace("Looping over " + (par.size() - startIndex) + " elements"); } - + KnuthNode lastForced = getNode(0); // main loop @@ -478,9 +478,9 @@ public abstract class BreakingAlgorithm { // consider all penalties, non-flagged penalties or non-forcing penalties // according to the value of allowedBreaks if (((KnuthPenalty) thisElement).getP() < KnuthElement.INFINITE - && (!(allowedBreaks == NO_FLAGGED_PENALTIES) + && (!(allowedBreaks == NO_FLAGGED_PENALTIES) || !(((KnuthPenalty) thisElement).isFlagged())) - && (!(allowedBreaks == ONLY_FORCED_BREAKS) + && (!(allowedBreaks == ONLY_FORCED_BREAKS) || ((KnuthPenalty) thisElement).getP() == -KnuthElement.INFINITE)) { considerLegalBreak(thisElement, i); } @@ -491,9 +491,9 @@ public abstract class BreakingAlgorithm { log.debug("Could not find a set of breaking points " + threshold); return 0; } - // lastDeactivated was a "good" break, while lastTooShort and lastTooLong + // lastDeactivated was a "good" break, while lastTooShort and lastTooLong // were "bad" breaks since the beginning; - // if it is not the node we just restarted from, lastDeactivated can + // if it is not the node we just restarted from, lastDeactivated can // replace either lastTooShort or lastTooLong if (lastDeactivated != null && lastDeactivated != lastForced) { if (lastDeactivated.adjustRatio > 0) { @@ -519,7 +519,7 @@ public abstract class BreakingAlgorithm { lastForced = node; node.fitRecoveryCounter = lastTooLong.previous.fitRecoveryCounter + 1; if (log.isDebugEnabled()) { - log.debug("first part doesn't fit into line, recovering: " + log.debug("first part doesn't fit into line, recovering: " + node.fitRecoveryCounter); } if (node.fitRecoveryCounter > getMaxRecoveryAttempts()) { @@ -621,7 +621,7 @@ public abstract class BreakingAlgorithm { * @param difference difference between target and actual line width * @param totalDemerits minimum total demerits up to the breakpoint * @param previous active node for the preceding breakpoint - */ + */ protected KnuthNode createNode(int position, int line, int fitness, int totalWidth, int totalStretch, int totalShrink, double adjustRatio, int availableShrink, int availableStretch, @@ -680,8 +680,8 @@ public abstract class BreakingAlgorithm { protected void considerLegalBreak(KnuthElement element, int elementIdx) { if (log.isTraceEnabled()) { - log.trace("considerLegalBreak() at " + elementIdx - + " (" + totalWidth + "+" + totalStretch + "-" + totalShrink + log.trace("considerLegalBreak() at " + elementIdx + + " (" + totalWidth + "+" + totalStretch + "-" + totalShrink + "), parts/lines: " + startLine + "-" + endLine); log.trace("\tCurrent active node list: " + activeNodeCount + " " + this.toString("\t")); } @@ -711,17 +711,17 @@ public abstract class BreakingAlgorithm { removeNode(line, node); lastDeactivated = compareNodes(lastDeactivated, node); } - + // The line is within the available shrink and the threshold. if (r >= -1 && r <= threshold) { int fitnessClass = computeFitness(r); double demerits = computeDemerits(node, element, fitnessClass, r); - + if (log.isTraceEnabled()) { log.trace("\tDemerits=" + demerits); log.trace("\tFitness class=" + fitnessClass); } - + if (demerits < best.getDemerits(fitnessClass)) { // updates best demerits data best.addRecord(demerits, node, r, availableShrink, availableStretch, @@ -729,7 +729,7 @@ public abstract class BreakingAlgorithm { lastTooShort = null; } } - + // The line is way too short, but we are in forcing mode, so a node is // calculated and stored in lastValidNode. if (force && (r <= -1 || r > threshold)) { @@ -739,7 +739,7 @@ public abstract class BreakingAlgorithm { int newStretch = totalStretch; int newShrink = totalShrink; - // add the width, stretch and shrink of glue elements after + // add the width, stretch and shrink of glue elements after // the break // this does not affect the dimension of the line / page, only // the values stored in the node; these would be as if the break @@ -772,7 +772,7 @@ public abstract class BreakingAlgorithm { if (lastTooShort == null || demerits <= lastTooShort.totalDemerits) { if (considerTooShort) { //consider possibilities which are too short - best.addRecord(demerits, node, r, + best.addRecord(demerits, node, r, availableShrink, availableStretch, difference, fitnessClass); } @@ -805,7 +805,7 @@ public abstract class BreakingAlgorithm { int newStretch = totalStretch; int newShrink = totalShrink; - // add the width, stretch and shrink of glue elements after + // add the width, stretch and shrink of glue elements after // the break // this does not affect the dimension of the line / page, only // the values stored in the node; these would be as if the break @@ -831,7 +831,7 @@ public abstract class BreakingAlgorithm { // the nodes in activeList must be ordered // by line number and position; if (log.isTraceEnabled()) { - log.trace("\tInsert new break in list of " + activeNodeCount + log.trace("\tInsert new break in list of " + activeNodeCount + " from fitness class " + i); } KnuthNode newNode = createNode(elementIdx, line + 1, i, @@ -849,7 +849,7 @@ public abstract class BreakingAlgorithm { * @param activeNode node for the previous breakpoint * @param element currently considered breakpoint * @return The difference in width. Positive numbers mean extra space in the line, - * negative number that the line overflows. + * negative number that the line overflows. */ protected int computeDifference(KnuthNode activeNode, KnuthElement element, int elementIndex) { @@ -862,14 +862,14 @@ public abstract class BreakingAlgorithm { } /** - * Return the adjust ration needed to make up for the difference. A ration of + * Return the adjust ration needed to make up for the difference. A ration of * <ul> * <li>0 means that the break has the exact right width</li> - * <li>>= -1 && < 0 means that the break is wider than the line, - * but within the minimim values of the glues.</li> - * <li>>0 && < 1 means that the break is smaller than the line width, + * <li>>= -1 && < 0 means that the break is wider than the line, + * but within the minimim values of the glues.</li> + * <li>>0 && < 1 means that the break is smaller than the line width, * but within the maximum values of the glues.</li> - * <li>> 1 means that the break is too small to make up for the glues.</li> + * <li>> 1 means that the break is too small to make up for the glues.</li> * </ul> * @param activeNode * @param difference @@ -895,11 +895,11 @@ public abstract class BreakingAlgorithm { return 0; } } - + /** * Figure out the fitness class of this line (tight, loose, * very tight or very loose). - * See the section on "More Bells and Whistles" in Knuth's + * See the section on "More Bells and Whistles" in Knuth's * "Breaking Paragraphs Into Lines". * @param r * @return the fitness class @@ -923,11 +923,11 @@ public abstract class BreakingAlgorithm { * node and ending at the given element. * @param activeNode considered preceding line break * @param element considered current line break - * @param fitnessClass fitness of the current line + * @param fitnessClass fitness of the current line * @param r adjustment ratio for the current line * @return the demerit of the current line */ - protected double computeDemerits(KnuthNode activeNode, KnuthElement element, + protected double computeDemerits(KnuthNode activeNode, KnuthElement element, int fitnessClass, double r) { double demerits = 0; // compute demerits @@ -942,14 +942,14 @@ public abstract class BreakingAlgorithm { } else { demerits = f * f; } - + if (element.isPenalty() && ((KnuthPenalty) element).isFlagged() && getElement(activeNode.position).isPenalty() && ((KnuthPenalty) getElement(activeNode.position)).isFlagged()) { // add demerit for consecutive breaks at flagged penalties demerits += repeatedFlaggedDemerit; // there are at least two consecutive lines ending with a flagged penalty; - // check if the previous line end with a flagged penalty too, + // check if the previous line end with a flagged penalty too, // and if this situation is allowed int flaggedPenaltiesCount = 2; for (KnuthNode prevNode = activeNode.previous; @@ -1084,18 +1084,18 @@ public abstract class BreakingAlgorithm { */ protected int getLineWidth(int line) { if (this.lineWidth < 0) { - throw new IllegalStateException("lineWidth must be set" + throw new IllegalStateException("lineWidth must be set" + (this.lineWidth != 0 ? " and positive, but it is: " + this.lineWidth : "")); } else { return this.lineWidth; } } - + /** @return the constant line/part width or -1 if there is no such value */ protected int getLineWidth() { return this.lineWidth; } - + /** * Creates a string representation of the active nodes. Used for debugging. * @param prepend a string to prepend on each entry @@ -1130,7 +1130,7 @@ public abstract class BreakingAlgorithm { bestActiveNode = bestActiveNode.previous; } } - + /** @return the alignment for normal lines/parts */ public int getAlignment() { return this.alignment; diff --git a/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java b/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java index 50fdc54b0..9124cf997 100644 --- a/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java +++ b/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java @@ -49,5 +49,5 @@ public interface ConditionalElementListener { * (null means zero length) */ void notifyPadding(RelSide side, MinOptMax effectiveLength); - + } diff --git a/src/java/org/apache/fop/layoutmgr/ElementListObserver.java b/src/java/org/apache/fop/layoutmgr/ElementListObserver.java index d4f23b1ee..73a6d5be4 100644 --- a/src/java/org/apache/fop/layoutmgr/ElementListObserver.java +++ b/src/java/org/apache/fop/layoutmgr/ElementListObserver.java @@ -28,9 +28,9 @@ import java.util.List; * Please see the subclass within the test code. */ public class ElementListObserver { - + private static List activeObservers = null; - + /** * Adds a new Observer to the list. * @param observer the observer implementation @@ -41,7 +41,7 @@ public class ElementListObserver { } activeObservers.add(observer); } - + /** * Removes an Observer from the list. This call simply returns if the observer was not on * the list and does nothing. @@ -52,7 +52,7 @@ public class ElementListObserver { activeObservers.remove(observer); } } - + /** * Notifies all registered observers about the element list. * @param elementList the Knuth element list @@ -70,7 +70,7 @@ public class ElementListObserver { } } } - + /** @return true if observation is active, i.e. Observers are registered. */ public static boolean isObservationActive() { return activeObservers != null; @@ -80,7 +80,7 @@ public class ElementListObserver { * Implement this interface to receive notifications on element lists. */ public interface Observer { - + /** * Notifies the observer about the element list. * @param elementList the Knuth element list @@ -89,7 +89,7 @@ public class ElementListObserver { * @param id ID for the element list (may be null) */ void observe(List elementList, String category, String id); - + } - + } diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java index c04d197e4..d7f854a42 100644 --- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java +++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java @@ -29,14 +29,14 @@ import org.apache.fop.util.ListUtil; * Utilities for Knuth element lists. */ public final class ElementListUtils { - + private ElementListUtils() { // Utility class. } /** * Removes legal breaks in an element list. A constraint can be specified to limit the - * range in which the breaks are removed. Legal breaks occuring before at least + * range in which the breaks are removed. Legal breaks occuring before at least * constraint.opt space is filled will be removed. * @param elements the element list * @param constraint min/opt/max value to restrict the range in which the breaks are removed. @@ -48,7 +48,7 @@ public final class ElementListUtils { /** * Removes legal breaks in an element list. A constraint can be specified to limit the - * range in which the breaks are removed. Legal breaks occuring before at least + * range in which the breaks are removed. Legal breaks occuring before at least * constraint space is filled will be removed. * @param elements the element list * @param constraint value to restrict the range in which the breaks are removed. diff --git a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java index 086d91c31..4dcb5e14c 100644 --- a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java @@ -61,8 +61,8 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan private static Log log = LogFactory.getLog(ExternalDocumentLayoutManager.class); - private ImageLayout imageLayout; - + private ImageLayout imageLayout; + /** * Constructor * @@ -74,7 +74,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan } /** - * @return the ExternalDocument being managed by this layout manager + * @return the ExternalDocument being managed by this layout manager */ protected ExternalDocument getExternalDocument() { return (ExternalDocument)pageSeq; @@ -84,24 +84,24 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan public PageSequenceLayoutManager getPSLM() { throw new IllegalStateException("getPSLM() is illegal for " + getClass().getName()); } - + /** {@inheritDoc} */ public void activateLayout() { initialize(); FOUserAgent userAgent = pageSeq.getUserAgent(); ImageManager imageManager = userAgent.getFactory().getImageManager(); - + String uri = getExternalDocument().getSrc(); Integer firstPageIndex = ImageUtil.getPageIndexFromURI(uri); boolean hasPageIndex = (firstPageIndex != null); - + try { ImageInfo info = imageManager.getImageInfo(uri, userAgent.getImageSessionContext()); - + Object moreImages = info.getCustomObjects().get(ImageInfo.HAS_MORE_IMAGES); boolean hasMoreImages = moreImages != null && !Boolean.FALSE.equals(moreImages); - + Dimension intrinsicSize = info.getSize().getDimensionMpt(); ImageLayout layout = new ImageLayout(getExternalDocument(), this, intrinsicSize); @@ -111,7 +111,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan } makePageForImage(info, layout); - + if (!hasPageIndex && hasMoreImages) { if (log.isTraceEnabled()) { log.trace("Starting multi-page processing..."); @@ -129,16 +129,16 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan } ImageInfo subinfo = imageManager.getImageInfo( tempURI.toASCIIString(), userAgent.getImageSessionContext()); - + moreImages = subinfo.getCustomObjects().get(ImageInfo.HAS_MORE_IMAGES); hasMoreImages = moreImages != null && !Boolean.FALSE.equals(moreImages); - + intrinsicSize = subinfo.getSize().getDimensionMpt(); layout = new ImageLayout( getExternalDocument(), this, intrinsicSize); - + makePageForImage(subinfo, layout); - + pageIndex++; } } catch (URISyntaxException e) { @@ -170,15 +170,15 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan fillPage(info.getOriginalURI()); finishPage(); } - + private void fillPage(String uri) { Dimension imageSize = this.imageLayout.getViewportSize(); - + Block blockArea = new Block(); blockArea.setIPD(imageSize.width); LineArea lineArea = new LineArea(); - + Image imageArea = new Image(uri); TraitSetter.setProducerID(imageArea, fobj.getId()); transferForeignAttributes(imageArea); @@ -189,7 +189,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan vp.setBPD(imageSize.height); vp.setContentPosition(imageLayout.getPlacement()); vp.setOffset(0); - + //Link them all together... lineArea.addInlineArea(vp); lineArea.updateExtentsFromChildren(); @@ -197,7 +197,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan curPage.getPageViewport().getCurrentFlow().addBlock(blockArea); curPage.getPageViewport().getCurrentSpan().notifyFlowsFinished(); } - + /** {@inheritDoc} */ public void finishPageSequence() { if (pageSeq.hasId()) { @@ -208,7 +208,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan (currentPageNum - startPageNum) + 1); areaTreeHandler.notifyPageSequenceFinished(pageSeq, (currentPageNum - startPageNum) + 1); - + if (log.isDebugEnabled()) { log.debug("Ending layout"); } @@ -217,9 +217,9 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan /** {@inheritDoc} */ protected Page createPage(int pageNumber, boolean isBlank) { String pageNumberString = pageSeq.makeFormattedPageNumber(pageNumber); - + Dimension imageSize = this.imageLayout.getViewportSize(); - + // Set up the CTM on the page reference area based on writing-mode // and reference-orientation Rectangle referenceRect; @@ -231,10 +231,10 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan FODimension reldims = new FODimension(0, 0); CTM pageCTM = CTM.getCTMandRelDims(pageSeq.getReferenceOrientation(), Constants.EN_LR_TB, referenceRect, reldims); - + Page page = new Page(referenceRect, pageNumber, pageNumberString, isBlank); - - PageViewport pv = page.getPageViewport(); + + PageViewport pv = page.getPageViewport(); org.apache.fop.area.Page pageArea = new org.apache.fop.area.Page(); pv.setPage(pageArea); @@ -242,8 +242,8 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan rv.setIPD(referenceRect.width); rv.setBPD(referenceRect.height); rv.setClip(true); - - BodyRegion body = new BodyRegion(Constants.FO_REGION_BODY, + + BodyRegion body = new BodyRegion(Constants.FO_REGION_BODY, "fop-image-region", rv, 1, 0); body.setIPD(imageSize.width); body.setBPD(imageSize.height); @@ -256,7 +256,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan //Also creates first normal flow region pv.createSpan(false); - + return page; } diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java index 1c8fb679f..293d6dbe0 100644 --- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,12 +46,12 @@ public class FlowLayoutManager extends BlockStackingLayoutManager * logging instance */ private static Log log = LogFactory.getLog(FlowLayoutManager.class); - + /** Array of areas currently being filled stored by area class */ private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX]; private int currentSpan = EN_NONE; - + /** * This is the top level layout manager. * It is created by the PageSequence FO. @@ -96,7 +96,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager SpaceResolver.resolveElementList(returnList); return returnList; } - + // Set up a LayoutContext //MinOptMax bpd = context.getStackLimit(); @@ -104,7 +104,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(context.getRefIPD()); childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode()); - + // get elements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); //log.debug("FLM.getNextKnuthElements> returnedList.size() = " + returnedList.size()); @@ -148,7 +148,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager //Propagate and clear context.updateKeepWithNextPending(childLC.getKeepWithNextPending()); childLC.clearKeepWithNextPending(); - + context.updateKeepWithNextPending(getKeepWithNextStrength()); } @@ -201,7 +201,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager public int getKeepTogetherStrength() { return KEEP_AUTO; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; @@ -211,7 +211,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + /** {@inheritDoc} */ public List getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/ int alignment) { ListIterator oldListIterator = oldList.listIterator(); @@ -255,7 +255,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager if (prevLM.mustKeepWithNext() || currLM.mustKeepWithPrevious()) { // add an infinite penalty to forbid a break between blocks - returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, + returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new Position(this), false)); } else if (!((KnuthElement) returnedList.get(returnedList .size() - 1)).isGlue()) { @@ -288,7 +288,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { AreaAdditionUtil.addAreas(this, parentIter, layoutContext); @@ -299,7 +299,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager * Add child area to a the correct container, depending on its * area class. A Flow can fill at most one area container of any class * at any one time. The actual work is done by BlockStackingLM. - * + * * @param childArea the area to add */ public void addChildArea(Area childArea) { @@ -314,7 +314,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager public Area getParentArea(Area childArea) { BlockParent parentArea = null; int aclass = childArea.getAreaClass(); - + if (aclass == Area.CLASS_NORMAL) { parentArea = getCurrentPV().getCurrentFlow(); } else if (aclass == Area.CLASS_BEFORE_FLOAT) { @@ -325,7 +325,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager throw new IllegalStateException("(internal error) Invalid " + "area class (" + aclass + ") requested."); } - + this.currentAreas[aclass] = parentArea; setCurrentArea(parentArea); return parentArea; @@ -338,7 +338,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager public int getContentAreaIPD() { return getCurrentPV().getCurrentSpan().getColumnWidth(); } - + /** * Returns the BPD of the content area * @return the BPD of the content area diff --git a/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java index 34b931c03..791008aec 100644 --- a/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -95,7 +95,7 @@ public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager { public int getKeepTogetherStrength() { return getParentKeepTogetherStrength(); } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; @@ -105,5 +105,5 @@ public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager { public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java index e9973c14f..6d11a3c24 100644 --- a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java @@ -35,12 +35,12 @@ public class InlineKnuthSequence extends KnuthSequence { private boolean isClosed = false; /** - * Creates a new and empty list. + * Creates a new and empty list. */ public InlineKnuthSequence() { super(); } - + /** * Creates a new list from an existing list. * @param list The list from which to create the new list. @@ -84,14 +84,14 @@ public class InlineKnuthSequence extends KnuthSequence { } /* (non-Javadoc) - * {@inheritDoc} + * {@inheritDoc} */ public boolean appendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement) { return appendSequence(sequence); } - + /* (non-Javadoc) * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/layoutmgr/KeepUtil.java b/src/java/org/apache/fop/layoutmgr/KeepUtil.java index 8c80a1b10..5cc33533f 100644 --- a/src/java/org/apache/fop/layoutmgr/KeepUtil.java +++ b/src/java/org/apache/fop/layoutmgr/KeepUtil.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,7 +46,7 @@ public class KeepUtil { return keep.getNumber().intValue(); } } - + /** * Returns the combined block-level keep strength from a keep property. * <p> @@ -60,7 +60,7 @@ public class KeepUtil { getKeepStrength(keep.getWithinPage()), getKeepStrength(keep.getWithinColumn())); } - + /** * Indicates whether a keep strength indicates a keep constraint. * @param strength the keep strength @@ -69,7 +69,7 @@ public class KeepUtil { public static boolean hasKeep(int strength) { return strength > BlockLevelLayoutManager.KEEP_AUTO; } - + /** * Returns the penalty value to be used for a certain keep strength. * <ul> @@ -90,7 +90,7 @@ public class KeepUtil { } return penalty; } - + /** * Returns a string representation of a keep strength value. * @param keepStrength the keep strength @@ -105,5 +105,5 @@ public class KeepUtil { return Integer.toString(keepStrength); } } - + } diff --git a/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java b/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java index 364c896ad..1aa22ea3e 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ import org.apache.fop.traits.MinOptMax; * Knuth box used to represent a line in block-progression-dimension (i.e. the width is its height). */ public class KnuthBlockBox extends KnuthBox { - + private MinOptMax ipdRange; /** * Natural width of the line represented by this box. In addition to ipdRange because @@ -58,7 +58,7 @@ public class KnuthBlockBox extends KnuthBox { * Creates a new box. * @param w block progression dimension of this box * @param list footnotes cited by elements in this box. The list contains the - * corresponding FootnoteBodyLayoutManagers + * corresponding FootnoteBodyLayoutManagers * @param pos the Position stored in this box * @param bAux is this box auxiliary? */ diff --git a/src/java/org/apache/fop/layoutmgr/KnuthBox.java b/src/java/org/apache/fop/layoutmgr/KnuthBox.java index a465ca8da..7c3df61fa 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthBox.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthBox.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,11 +23,11 @@ package org.apache.fop.layoutmgr; * An instance of this class represents an unbreakable piece of content with * fixed width: for example an image, a syllable (but only if letter spacing * is constant), ... - * + * * A KnuthBox is never a feasible breaking point. - * + * * The represented piece of content is never suppressed. - * + * * Besides the inherited methods and attributes, this class has some more * attributes to store information about the content height and its vertical * positioning, and the methods used to get them. @@ -61,5 +61,5 @@ public class KnuthBox extends KnuthElement { sb.append(getW()); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/KnuthElement.java b/src/java/org/apache/fop/layoutmgr/KnuthElement.java index 71f3b3ce9..41c813010 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthElement.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthElement.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,7 @@ package org.apache.fop.layoutmgr; /** * This is the super class for KnuthBox, KnuthGlue and KnuthPenalty. - * + * * It stores information common to all sub classes, and the methods to get it: * the width, a Position and a boolean marking KnuthElements used for some * special feature (for example, the additional elements used to represent @@ -59,21 +59,21 @@ public abstract class KnuthElement extends ListElement { return width; } - /** @return the penalty value of this element, if applicable. */ + /** @return the penalty value of this element, if applicable. */ public int getP() { throw new RuntimeException("Element is not a penalty"); } - /** @return the stretch value of this element, if applicable. */ + /** @return the stretch value of this element, if applicable. */ public int getY() { throw new RuntimeException("Element is not a glue"); } - /** @return the shrink value of this element, if applicable. */ + /** @return the shrink value of this element, if applicable. */ public int getZ() { throw new RuntimeException("Element is not a glue"); } - + /** {@inheritDoc} */ public boolean isUnresolvedElement() { return false; diff --git a/src/java/org/apache/fop/layoutmgr/KnuthGlue.java b/src/java/org/apache/fop/layoutmgr/KnuthGlue.java index 0b6706c4b..fbb291f6b 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthGlue.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthGlue.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,16 +20,16 @@ package org.apache.fop.layoutmgr; /** - * An instance of this class represents a piece of content with adjustable + * An instance of this class represents a piece of content with adjustable * width: for example a space between words of justified text. - * + * * A KnuthGlue is a feasible breaking point only if it immediately follows * a KnuthBox. - * + * * The represented piece of content is suppressed if either the KnuthGlue * is a chosen breaking point or there isn't any KnuthBox between the * previous breaking point and the KnuthGlue itself. - * + * * So, an unsuppressible piece of content with adjustable width, for example * a leader or a word with adjustable letter space, cannot be represented * by a single KnuthGlue; it can be represented using the sequence: @@ -39,14 +39,14 @@ package org.apache.fop.layoutmgr; * KnuthBox(width = 0) * where the infinity penalty avoids choosing the KnuthGlue as a breaking point * and the 0-width KnuthBoxes prevent suppression. - * + * * Besides the inherited methods and attributes, this class has two attributes * used to store the stretchability (difference between max and opt width) and * the shrinkability (difference between opt and min width), and the methods * to get these values. */ public class KnuthGlue extends KnuthElement { - + private int stretchability; private int shrinkability; private int adjustmentClass = -1; @@ -88,12 +88,12 @@ public class KnuthGlue extends KnuthElement { public int getZ() { return shrinkability; } - + /** @return the adjustment class (or role) of this glue. */ public int getAdjustmentClass() { return adjustmentClass; } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(64); @@ -109,5 +109,5 @@ public class KnuthGlue extends KnuthElement { } return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java b/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java index ecaeac627..6c13fba8a 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,15 +24,15 @@ 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. - * + * * A KnuthPenalty is a feasible breaking point unless its value is infinity; * a KnuthPenalty whose value is -infinity represents a forced break. - * + * * A KnuthPenalty is suppressed, and its width is ignored, if it is not a * chosen breaking point; for example, a KnuthPenalty representing a * hyphenation point has a width (the "-" width), which must be ignored if * that point is not chosen as a breaking point. - * + * * Besides the inherited methods and attributes, this class has two more * attributes and the methods used to get them: the penalty value, which is * a kind of "aesthetic cost" (the higher the value, the more unsightly the @@ -45,7 +45,7 @@ public class KnuthPenalty extends KnuthElement { public static final int FLAGGED_PENALTY = 50; private int penalty; - private boolean bFlagged; + private boolean bFlagged; private int breakClass = -1; /** @@ -65,7 +65,7 @@ public class KnuthPenalty extends KnuthElement { /** * Create a new KnuthPenalty. - * + * * @param w the width of this penalty * @param p the penalty value of this penalty * @param f is this penalty flagged? @@ -102,7 +102,7 @@ public class KnuthPenalty extends KnuthElement { public void setP(int p) { this.penalty = p; } - + /** @return true is this penalty is a flagged one. */ public boolean isFlagged() { return bFlagged; @@ -112,7 +112,7 @@ public class KnuthPenalty extends KnuthElement { public boolean isForcedBreak() { return penalty == -KnuthElement.INFINITE; } - + /** * @return the break class of this penalty (EN_AUTO, EN_COLUMN, EN_PAGE, EN_EVEN_PAGE, * EN_ODD_PAGE) @@ -120,7 +120,7 @@ public class KnuthPenalty extends KnuthElement { public int getBreakClass() { return breakClass; } - + /** * Sets the break class for this penalty. * @param cl the break class (EN_AUTO, EN_COLUMN, EN_PAGE, EN_EVEN_PAGE, EN_ODD_PAGE) @@ -128,7 +128,7 @@ public class KnuthPenalty extends KnuthElement { public void setBreakClass(int cl) { this.breakClass = cl; } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(64); @@ -171,5 +171,5 @@ public class KnuthPenalty extends KnuthElement { } return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java b/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java index 3f334f4be..e7397babb 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ public class KnuthPossPosIter extends PositionIterator { super(elementList.listIterator(startPos)); iterCount = endPos - startPos; } - + /** * Auxiliary constructor * @param elementList List of Knuth elements @@ -45,7 +45,7 @@ public class KnuthPossPosIter extends PositionIterator { } // Check position < endPos - + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/layoutmgr/KnuthSequence.java b/src/java/org/apache/fop/layoutmgr/KnuthSequence.java index 4467a397b..fe9a01498 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthSequence.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,7 +27,7 @@ import java.util.ListIterator; * Represents a list of Knuth elements. */ /** - * + * */ public abstract class KnuthSequence extends ArrayList { /** @@ -68,19 +68,19 @@ public abstract class KnuthSequence extends ArrayList { * Append sequence to this sequence if it can be appended. * @param sequence The sequence that is to be appended. * @param keepTogether Whether the two sequences must be kept together. - * @param breakElement The BreakElement that may be inserted between the two sequences. + * @param breakElement The BreakElement that may be inserted between the two sequences. * @return whether the sequence was succesfully appended to this sequence. */ public abstract boolean appendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement); - + /** * Append sequence to this sequence if it can be appended. * @param sequence The sequence that is to be appended. * @return whether the sequence was succesfully appended to this sequence. */ public abstract boolean appendSequence(KnuthSequence sequence); - + /** * Append sequence to this sequence if it can be appended. * If that is not possible, close this sequence. @@ -95,13 +95,13 @@ public abstract class KnuthSequence extends ArrayList { return true; } } - + /** * Append sequence to this sequence if it can be appended. * If that is not possible, close this sequence. * @param sequence The sequence that is to be appended. * @param keepTogether Whether the two sequences must be kept together. - * @param breakElement The BreakElement that may be inserted between the two sequences. + * @param breakElement The BreakElement that may be inserted between the two sequences. * @return whether the sequence was succesfully appended to this sequence. */ public boolean appendSequenceOrClose(KnuthSequence sequence, boolean keepTogether, @@ -113,7 +113,7 @@ public abstract class KnuthSequence extends ArrayList { return true; } } - + /** * Wrap the Positions of the elements of this sequence in a Position for LayoutManager lm. * @param lm The LayoutManager for the Positions that will be created. @@ -127,14 +127,14 @@ public abstract class KnuthSequence extends ArrayList { (lm.notifyPos(new NonLeafPosition(lm, element.getPosition()))); } } - + /** * @return the last element of this sequence. */ public ListElement getLast() { int idx = size(); if (idx == 0) { - return null; + return null; } return (ListElement) get(idx - 1); } @@ -146,7 +146,7 @@ public abstract class KnuthSequence extends ArrayList { public ListElement removeLast() { int idx = size(); if (idx == 0) { - return null; + return null; } return (ListElement) remove(idx - 1); } diff --git a/src/java/org/apache/fop/layoutmgr/LMiter.java b/src/java/org/apache/fop/layoutmgr/LMiter.java index 9e812a8b7..4fa5590dc 100644 --- a/src/java/org/apache/fop/layoutmgr/LMiter.java +++ b/src/java/org/apache/fop/layoutmgr/LMiter.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/java/org/apache/fop/layoutmgr/LayoutContext.java b/src/java/org/apache/fop/layoutmgr/LayoutContext.java index 5ac9808f2..1be89304b 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutContext.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutContext.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -106,15 +106,15 @@ public class LayoutContext { /** Current pending space-before or space-start from ancestor areas */ private SpaceSpecifier leadingSpace; - + /** - * A list of pending marks (border and padding) on the after edge when a page break occurs. + * A list of pending marks (border and padding) on the after edge when a page break occurs. * May be null. */ private List pendingAfterMarks; - + /** - * A list of pending marks (border and padding) on the before edge when a page break occurs. + * A list of pending marks (border and padding) on the before edge when a page break occurs. * May be null. */ private List pendingBeforeMarks; @@ -124,7 +124,7 @@ public class LayoutContext { /** Alignment in BP direction */ private int bpAlignment = Constants.EN_START; - + /** Stretch or shrink value when making areas. */ private double ipdAdjust = 0.0; @@ -132,12 +132,12 @@ public class LayoutContext { private double dSpaceAdjust = 0.0; private AlignmentContext alignmentContext = null; - + /** Amount of space before / start */ private int spaceBefore = 0; /** Amount of space after / end */ private int spaceAfter = 0; - + /** Amount of space to reserve at the beginning of each line */ private int lineStartBorderAndPaddingWidth = 0; /** Amount of space to reserve at the end of each line */ @@ -146,9 +146,9 @@ public class LayoutContext { private int breakBefore; private int breakAfter; - private int pendingKeepWithNext = BlockLevelLayoutManager.KEEP_AUTO; - private int pendingKeepWithPrevious = BlockLevelLayoutManager.KEEP_AUTO; - + private int pendingKeepWithNext = BlockLevelLayoutManager.KEEP_AUTO; + private int pendingKeepWithPrevious = BlockLevelLayoutManager.KEEP_AUTO; + /** * Copy constructor for creating child layout contexts. * @param parentLC the parent layout context to copy from @@ -188,13 +188,13 @@ public class LayoutContext { public void copyPendingMarksFrom(LayoutContext source) { if (source.pendingAfterMarks != null) { - this.pendingAfterMarks = new java.util.ArrayList(source.pendingAfterMarks); + this.pendingAfterMarks = new java.util.ArrayList(source.pendingAfterMarks); } if (source.pendingBeforeMarks != null) { - this.pendingBeforeMarks = new java.util.ArrayList(source.pendingBeforeMarks); + this.pendingBeforeMarks = new java.util.ArrayList(source.pendingBeforeMarks); } } - + public void setFlags(int flags) { setFlags(flags, true); } @@ -238,7 +238,7 @@ public class LayoutContext { public int getKeepWithNextPending() { return this.pendingKeepWithNext; } - + /** * Returns the strength of a keep-with-previous currently pending. * @return the keep-with-previous strength @@ -246,7 +246,7 @@ public class LayoutContext { public int getKeepWithPreviousPending() { return this.pendingKeepWithPrevious; } - + /** * Clears any pending keep-with-next strength. */ @@ -260,7 +260,7 @@ public class LayoutContext { public void clearKeepWithPreviousPending() { this.pendingKeepWithPrevious = BlockLevelLayoutManager.KEEP_AUTO; } - + /** * Clears both keep-with-previous and keep-with-next strengths. */ @@ -292,7 +292,7 @@ public class LayoutContext { public boolean isKeepWithNextPending() { return getKeepWithNextPending() != BlockLevelLayoutManager.KEEP_AUTO; } - + /** * Indicates whether a keep-with-previous constraint is pending. * @return true if a keep-with-previous constraint is pending @@ -300,7 +300,7 @@ public class LayoutContext { public boolean isKeepWithPreviousPending() { return getKeepWithPreviousPending() != BlockLevelLayoutManager.KEEP_AUTO; } - + public void setLeadingSpace(SpaceSpecifier space) { leadingSpace = space; } @@ -333,7 +333,7 @@ public class LayoutContext { } this.pendingAfterMarks.add(element); } - + /** * @return the pending border and padding elements at the after edge * @see #addPendingAfterMark(UnresolvedListElementWithLength) @@ -345,7 +345,7 @@ public class LayoutContext { return null; } } - + /** * Clears all pending marks on the LayoutContext. */ @@ -353,7 +353,7 @@ public class LayoutContext { this.pendingBeforeMarks = null; this.pendingAfterMarks = null; } - + /** * Adds a border or padding element to the pending list which will be used to generate * the right element list for break possibilities. Conditionality resolution will be done @@ -366,7 +366,7 @@ public class LayoutContext { } this.pendingBeforeMarks.add(element); } - + /** * @return the pending border and padding elements at the before edge * @see #addPendingBeforeMark(UnresolvedListElementWithLength) @@ -378,7 +378,7 @@ public class LayoutContext { return null; } } - + /** * Sets the stack limit in block-progression-dimension. * @param limit the stack limit @@ -419,7 +419,7 @@ public class LayoutContext { setStackLimitBP(context.getStackLimitBP()); setStackLimitIP(context.getStackLimitIP()); } - + /** * Sets the inline-progression-dimension of the nearest ancestor reference area. */ @@ -429,7 +429,7 @@ public class LayoutContext { /** * Returns the inline-progression-dimension of the nearest ancestor reference area. - * + * * @return the inline-progression-dimension of the nearest ancestor reference area */ public int getRefIPD() { @@ -455,12 +455,12 @@ public class LayoutContext { public void setBPAlignment(int alignment) { this.bpAlignment = alignment; } - + /** @return the currently applicable alignment in BP direction (EN_START, EN_JUSTIFY...) */ public int getBPAlignment() { return this.bpAlignment; } - + public void setSpaceAdjust(double adjust) { dSpaceAdjust = adjust; } @@ -480,7 +480,7 @@ public class LayoutContext { public void setAlignmentContext(AlignmentContext alignmentContext) { this.alignmentContext = alignmentContext; } - + public AlignmentContext getAlignmentContext() { return this.alignmentContext; } @@ -490,7 +490,7 @@ public class LayoutContext { this.alignmentContext = this.alignmentContext.getParentAlignmentContext(); } } - + /** * Get the width to be reserved for border and padding at the start of the line. * @return the width to be reserved @@ -498,7 +498,7 @@ public class LayoutContext { public int getLineStartBorderAndPaddingWidth() { return lineStartBorderAndPaddingWidth; } - + /** * Set the width to be reserved for border and padding at the start of the line. * @param lineStartBorderAndPaddingWidth the width to be reserved @@ -506,7 +506,7 @@ public class LayoutContext { public void setLineStartBorderAndPaddingWidth(int lineStartBorderAndPaddingWidth) { this.lineStartBorderAndPaddingWidth = lineStartBorderAndPaddingWidth; } - + /** * Get the width to be reserved for border and padding at the end of the line. * @return the width to be reserved @@ -514,7 +514,7 @@ public class LayoutContext { public int getLineEndBorderAndPaddingWidth() { return lineEndBorderAndPaddingWidth; } - + /** * Set the width to be reserved for border and padding at the end of the line. * @param lineEndBorderAndPaddingWidth the width to be reserved @@ -522,7 +522,7 @@ public class LayoutContext { public void setLineEndBorderAndPaddingWidth(int lineEndBorderAndPaddingWidth) { this.lineEndBorderAndPaddingWidth = lineEndBorderAndPaddingWidth; } - + /** * @return true if the current element list ends early because of a span change * in multi-column layout. @@ -530,7 +530,7 @@ public class LayoutContext { public int getNextSpan() { return nextSpan; } - + /** * Used to signal the PSLM that the element list ends early because of a span change in * multi-column layout. @@ -544,8 +544,8 @@ public class LayoutContext { + span); } } - - /** + + /** * Get the writing mode of the relevant reference area. * @return the applicable writing mode */ @@ -553,7 +553,7 @@ public class LayoutContext { return writingMode; } - /** + /** * Set the writing mode. * @param writingMode the writing mode */ @@ -597,7 +597,7 @@ public class LayoutContext { * Returns the value of the break before the element whose * {@link LayoutManager#getNextKnuthElements(LayoutContext, int)} method has just been * called. - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, or * {@link Constants#EN_ODD_PAGE} @@ -608,7 +608,7 @@ public class LayoutContext { /** * Sets the value of the break before the current element. - * + * * @param breakBefore the value of the break-before * @see #getBreakBefore() */ @@ -620,7 +620,7 @@ public class LayoutContext { * Returns the value of the break after the element whose * {@link LayoutManager#getNextKnuthElements(LayoutContext, int)} method has just been * called. - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, or * {@link Constants#EN_ODD_PAGE} @@ -632,7 +632,7 @@ public class LayoutContext { /** * Sets the value of the break after the current element. - * + * * @param breakAfter the value of the break-after * @see #getBreakAfter() */ @@ -650,7 +650,7 @@ public class LayoutContext { + "\nTrailing Space: \t" + (getTrailingSpace() == null ? "null" : getTrailingSpace().toString()) + "\nLeading Space: \t" - + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) + + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) + "\nReference IPD: \t" + getRefIPD() + "\nSpace Adjust: \t" + getSpaceAdjust() + "\nIPD Adjust: \t" + getIPDAdjust() @@ -663,7 +663,7 @@ public class LayoutContext { + "\nKeeps: \t[keep-with-next=" + KeepUtil.keepStrengthToString(getKeepWithNextPending()) + "][keep-with-previous=" + KeepUtil.keepStrengthToString(getKeepWithPreviousPending()) + "] pending" - + "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" + + "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" + (breakAfter != Constants.EN_AUTO ? "break-after" : "") + "]"; } diff --git a/src/java/org/apache/fop/layoutmgr/LayoutException.java b/src/java/org/apache/fop/layoutmgr/LayoutException.java index 350cc758a..822607020 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutException.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutException.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,13 +28,13 @@ import org.apache.fop.events.EventExceptionManager.ExceptionFactory; /** * Exception thrown by FOP if an unrecoverable layout error occurs. An example: An area overflows * a viewport that has overflow="error-if-overflow". - * + * * @todo Discuss if this should become a checked exception. */ public class LayoutException extends RuntimeException { private static final long serialVersionUID = 5157080040923740433L; - + private String localizedMessage; private LayoutManager layoutManager; @@ -80,7 +80,7 @@ public class LayoutException extends RuntimeException { public LayoutManager getLayoutManager() { return this.layoutManager; } - + /** Exception factory for {@link LayoutException}. */ public static class LayoutExceptionFactory implements ExceptionFactory { @@ -95,11 +95,11 @@ public class LayoutException extends RuntimeException { } return ex; } - + /** {@inheritDoc} */ public Class getExceptionClass() { return LayoutException.class; } - - } + + } } diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManager.java b/src/java/org/apache/fop/layoutmgr/LayoutManager.java index ad0d9f69c..f19588a77 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; import java.util.List; @@ -45,11 +45,11 @@ public interface LayoutManager extends PercentBaseContext { LayoutManager getParent(); /** - * initialize the layout manager. Allows each layout manager + * initialize the layout manager. Allows each layout manager * to calculate often used values. */ void initialize(); - + /** * Get the active PageSequenceLayoutManager instance for this * layout process. @@ -130,9 +130,9 @@ public interface LayoutManager extends PercentBaseContext { void addChildLMs(List newLMs); /** - * Get a sequence of KnuthElements representing the content + * Get a sequence of KnuthElements representing the content * of the node assigned to the LM - * + * * @param context the LayoutContext used to store layout information * @param alignment the desired text alignment * @return the list of KnuthElements @@ -140,54 +140,54 @@ public interface LayoutManager extends PercentBaseContext { List getNextKnuthElements(LayoutContext context, int alignment); /** - * Get a sequence of KnuthElements representing the content + * Get a sequence of KnuthElements representing the content * of the node assigned to the LM, after changes have been applied * * In the context of line breaking, this method is called after hyphenation has - * been performed, in order to receive the sequence of elements representing the + * been performed, in order to receive the sequence of elements representing the * text together with all possible hyphenation points. * For example, if the text "representation" originates a single box element * when getNextKnuthElements() is called, it will be now split in syllables * (rep-re-sen-ta-tion) each one originating a box and divided by additional * elements allowing a line break. - * + * * In the context of page breaking, this method is called only if the pages need * to be "vertically justified" modifying (also) the quantity of lines created by * the paragraphs, and after a first page breaking has been performed. * According to the result of the first page breaking, each paragraph now knows - * how many lines it must create (among the existing layout possibilities) and + * how many lines it must create (among the existing layout possibilities) and * has to create a sequence of elements representing this layout; in particular, * each box, representing a line, will contain a LineBreakPositions that will be * used in the addAreas() phase. - * + * * LMs having children look at the old list of elements in order to know which * ones they must get the new elements from, as break conditions of preserved - * linefeeds can divide children into smaller groups (page sequences or + * linefeeds can divide children into smaller groups (page sequences or * paragraphs). * LMs having no children can simply return the old elements if they have nothing * to change. * * Inline LMs need to know the text alignment because it affects the elements * representing feasible breaks between syllables. - * + * * @param oldList the elements to replace * @param alignment the desired text alignment * @return the updated list of KnuthElements */ List getChangedKnuthElements(List oldList, int alignment); - + /** * Returns the IPD of the content area * @return the IPD of the content area */ int getContentAreaIPD(); - + /** * Returns the BPD of the content area * @return the BPD of the content area */ int getContentAreaBPD(); - + /** * Returns an indication if the layout manager generates a reference area. * @return True if the layout manager generates a reference area @@ -205,13 +205,13 @@ public interface LayoutManager extends PercentBaseContext { * @return True if the layout manager generates a line area */ boolean getGeneratesLineArea(); - + /** * Returns the fo this layout manager is associated with. * @return The fo for this layout manager or null. */ FObj getFObj(); - + /** * Adds a Position to the Position participating in the first|last determination by assigning * it a unique position index. diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java index abb7f0f04..8efe5ce65 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ import org.apache.fop.area.Block; * The interface for all LayoutManager makers */ public interface LayoutManagerMaker { - + /** * Make LayoutManagers for the node and add them to the list lms. * @param node the FO node for which the LayoutManagers are made diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java index 862c0a4be..26933ee4c 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -145,7 +145,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void makeLayoutManagers(FONode node, List lms) { Maker maker = (Maker) makers.get(node.getClass()); @@ -175,7 +175,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } else if (lms.size() > 1) { throw new IllegalStateException("Duplicate LayoutManagers for class " + node.getClass() - + " found, only one may be declared."); + + " found, only one may be declared."); } return (LayoutManager) lms.get(0); } @@ -186,7 +186,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } /* - * {@inheritDoc} + * {@inheritDoc} */ public FlowLayoutManager makeFlowLayoutManager( PageSequenceLayoutManager pslm, Flow flow) { @@ -194,21 +194,21 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } /* - * {@inheritDoc} + * {@inheritDoc} */ public ContentLayoutManager makeContentLayoutManager(PageSequenceLayoutManager pslm, Title title) { return new ContentLayoutManager(pslm, title); } - + /* - * {@inheritDoc} + * {@inheritDoc} */ public StaticContentLayoutManager makeStaticContentLayoutManager( PageSequenceLayoutManager pslm, StaticContent sc, SideRegion reg) { return new StaticContentLayoutManager(pslm, sc, reg); } - + /** {@inheritDoc} */ public StaticContentLayoutManager makeStaticContentLayoutManager( PageSequenceLayoutManager pslm, StaticContent sc, org.apache.fop.area.Block block) { @@ -321,7 +321,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { public static class ListItemLayoutManagerMaker extends Maker { public void make(FONode node, List lms) { lms.add(new ListItemLayoutManager((ListItem) node)); - } + } } public static class ListBlockLayoutManagerMaker extends Maker { @@ -353,7 +353,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { lms.add(new PageNumberCitationLastLayoutManager((PageNumberCitationLast) node)); } } - + public static class TableLayoutManagerMaker extends Maker { public void make(FONode node, List lms) { Table table = (Table) node; @@ -361,7 +361,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { lms.add(tlm); } } - + public class RetrieveMarkerLayoutManagerMaker extends Maker { public void make(FONode node, List lms) { Iterator baseIter; @@ -373,7 +373,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { FONode child = (FONode) baseIter.next(); makeLayoutManagers(child, lms); } - } + } } public class WrapperLayoutManagerMaker extends Maker { @@ -390,7 +390,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { FONode child = (FONode) baseIter.next(); makeLayoutManagers(child, lms); } - } + } } public ExternalDocumentLayoutManager makeExternalDocumentLayoutManager( diff --git a/src/java/org/apache/fop/layoutmgr/LeafPosition.java b/src/java/org/apache/fop/layoutmgr/LeafPosition.java index c43bb05c0..ed8cc94e2 100644 --- a/src/java/org/apache/fop/layoutmgr/LeafPosition.java +++ b/src/java/org/apache/fop/layoutmgr/LeafPosition.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; public class LeafPosition extends Position { @@ -31,11 +31,11 @@ public class LeafPosition extends Position { public int getLeafPos() { return iLeafPos; } - + public boolean generatesAreas() { return getLM() != null; } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/layoutmgr/ListElement.java b/src/java/org/apache/fop/layoutmgr/ListElement.java index de08a1e1e..74d8a666b 100644 --- a/src/java/org/apache/fop/layoutmgr/ListElement.java +++ b/src/java/org/apache/fop/layoutmgr/ListElement.java @@ -23,12 +23,12 @@ package org.apache.fop.layoutmgr; * This class is the base class for all kinds of elements that are added to element lists. There * are basically two kinds of list elements: Knuth elements and unresolved elements like spaces, * border and padding elements which are converted to Knuth elements prior to the breaking - * process. + * process. */ public abstract class ListElement { private Position position; - + /** * Main constructor * @param position the Position instance needed by the addAreas stage of the LMs. @@ -36,14 +36,14 @@ public abstract class ListElement { public ListElement(Position position) { this.position = position; } - + /** * @return the Position instance for this element. */ public Position getPosition() { return this.position; } - + /** * Change the Position stored in this element. * @param position the Position instance @@ -78,14 +78,14 @@ public abstract class ListElement { return false; } - /** @return true if the element is a penalty and represents a forced break. */ + /** @return true if the element is a penalty and represents a forced break. */ public boolean isForcedBreak() { return false; } - /** @return true if the element is an unresolved element such as a space or a border. */ + /** @return true if the element is an unresolved element such as a space or a border. */ public boolean isUnresolvedElement() { return true; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java b/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java index b58af1cfe..155abcd39 100644 --- a/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java +++ b/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java @@ -35,7 +35,7 @@ public class MinOptMaxUtil { * @param lr restricting source * @param context Percentage evaluation context */ - public static void restrict(MinOptMax mom, LengthRangeProperty lr, + public static void restrict(MinOptMax mom, LengthRangeProperty lr, PercentBaseContext context) { if (lr.getEnum() != Constants.EN_AUTO) { if (lr.getMinimum(context).getEnum() != Constants.EN_AUTO) { @@ -70,7 +70,7 @@ public class MinOptMaxUtil { /** * Extends the minimum length to the given length if necessary, and adjusts opt and * max accordingly. - * + * * @param mom the min/opt/max trait * @param len the new minimum length */ @@ -81,7 +81,7 @@ public class MinOptMaxUtil { mom.max = Math.max(mom.opt, mom.max); } } - + /** * After a calculation on a MinOptMax, this can be called to set opt to * a new effective value. @@ -95,7 +95,7 @@ public class MinOptMaxUtil { } } } - + /** * Converts a LengthRangeProperty to a MinOptMax. * @param prop LengthRangeProperty @@ -104,14 +104,14 @@ public class MinOptMaxUtil { */ public static MinOptMax toMinOptMax(LengthRangeProperty prop, PercentBaseContext context) { MinOptMax mom = new MinOptMax( - (prop.getMinimum(context).isAuto() + (prop.getMinimum(context).isAuto() ? 0 : prop.getMinimum(context).getLength().getValue(context)), - (prop.getOptimum(context).isAuto() + (prop.getOptimum(context).isAuto() ? 0 : prop.getOptimum(context).getLength().getValue(context)), - (prop.getMaximum(context).isAuto() - ? Integer.MAX_VALUE + (prop.getMaximum(context).isAuto() + ? Integer.MAX_VALUE : prop.getMaximum(context).getLength().getValue(context))); return mom; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java b/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java index 9edb425c1..7089dabda 100644 --- a/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java +++ b/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; public class NonLeafPosition extends Position { @@ -31,11 +31,11 @@ public class NonLeafPosition extends Position { public Position getPosition() { return subPos; } - + public boolean generatesAreas() { return (subPos != null ? subPos.generatesAreas() : false); } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/layoutmgr/PaddingElement.java b/src/java/org/apache/fop/layoutmgr/PaddingElement.java index ee0edcc38..3ec0c5054 100644 --- a/src/java/org/apache/fop/layoutmgr/PaddingElement.java +++ b/src/java/org/apache/fop/layoutmgr/PaddingElement.java @@ -42,10 +42,10 @@ public class PaddingElement extends BorderOrPaddingElement { boolean isFirst, boolean isLast, PercentBaseContext context) { super(position, condLength, side, isFirst, isLast, context); } - + /** {@inheritDoc} */ public void notifyLayoutManager(MinOptMax effectiveLength) { - LayoutManager lm = getOriginatingLayoutManager(); + LayoutManager lm = getOriginatingLayoutManager(); if (lm instanceof ConditionalElementListener) { ((ConditionalElementListener)lm).notifyPadding( getSide(), effectiveLength); @@ -62,5 +62,5 @@ public class PaddingElement extends BorderOrPaddingElement { sb.append("]"); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/Page.java b/src/java/org/apache/fop/layoutmgr/Page.java index 6d6dbb233..7e22cef67 100644 --- a/src/java/org/apache/fop/layoutmgr/Page.java +++ b/src/java/org/apache/fop/layoutmgr/Page.java @@ -34,39 +34,39 @@ public class Page { private SimplePageMaster spm; private PageViewport pageViewport; - + /** * Main constructor * @param spm the simple-page-master used for this page * @param pageNumber the page number (as an int) - * @param pageNumberStr the page number (as a String) + * @param pageNumberStr the page number (as a String) * @param blank true if this is a blank page */ public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr, boolean blank) { this.spm = spm; this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank); } - + /** * Auxiliary constructor used when there's no SimplePageMaster. * @param viewArea the view area of the page * @param pageNumber the page number (as an int) - * @param pageNumberStr the page number (as a String) + * @param pageNumberStr the page number (as a String) * @param blank true if this is a blank page */ public Page(Rectangle2D viewArea, int pageNumber, String pageNumberStr, boolean blank) { this.spm = null; this.pageViewport = new PageViewport(viewArea, pageNumber, pageNumberStr, null, blank); } - + /** @return the simple-page-master that created this page */ public SimplePageMaster getSimplePageMaster() { return this.spm; } - + /** @return the page viewport representing this page in the area tree */ public PageViewport getPageViewport() { return this.pageViewport; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java index b25e4bd4f..9ff520804 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,14 +39,14 @@ import org.apache.fop.traits.MinOptMax; * Handles the breaking of pages in an fo:flow */ public class PageBreaker extends AbstractBreaker { - + private PageSequenceLayoutManager pslm; private boolean firstPart = true; private boolean pageBreakHandled; private boolean needColumnBalancing; private PageProvider pageProvider; private Block separatorArea; - + /** * The FlowLayoutManager object, which processes * the single fo:flow of the fo:page-sequence @@ -61,23 +61,23 @@ public class PageBreaker extends AbstractBreaker { this.childFLM = pslm.getLayoutManagerMaker().makeFlowLayoutManager( pslm, pslm.getPageSequence().getMainFlow()); } - + /** {@inheritDoc} */ protected void updateLayoutContext(LayoutContext context) { int flowIPD = pslm.getCurrentPV().getCurrentSpan().getColumnWidth(); context.setRefIPD(flowIPD); } - + /** {@inheritDoc} */ protected LayoutManager getTopLevelLM() { return pslm; } - + /** {@inheritDoc} */ protected PageProvider getPageProvider() { return pslm.getPageProvider(); } - + /** {@inheritDoc} */ protected PageBreakingLayoutListener createLayoutListener() { return new PageBreakingLayoutListener() { @@ -98,7 +98,7 @@ public class PageBreaker extends AbstractBreaker { amount, needClip, canRecover, body.getLocator()); } - + }; } @@ -118,7 +118,7 @@ public class PageBreaker extends AbstractBreaker { } /** {@inheritDoc} */ - protected int getNextBlockList(LayoutContext childLC, + protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn) { if (!firstPart) { // if this is the first page that will be created by @@ -129,15 +129,15 @@ public class PageBreaker extends AbstractBreaker { } firstPart = false; pageBreakHandled = true; - pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), + pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); return super.getNextBlockList(childLC, nextSequenceStartsOn); } - + /** {@inheritDoc} */ protected List getNextKnuthElements(LayoutContext context, int alignment) { List contentList = null; - + while (!childFLM.isFinished() && contentList == null) { contentList = childFLM.getNextKnuthElements(context, alignment); } @@ -161,7 +161,7 @@ public class PageBreaker extends AbstractBreaker { // store the lists of elements representing the footnote bodies // in the box representing the line containing their references while (footnoteBodyIterator.hasNext()) { - FootnoteBodyLayoutManager fblm + FootnoteBodyLayoutManager fblm = (FootnoteBodyLayoutManager) footnoteBodyIterator.next(); fblm.setParent(childFLM); fblm.initialize(); @@ -178,7 +178,7 @@ public class PageBreaker extends AbstractBreaker { footnoteSeparator = pslm.getPageSequence().getStaticContent("xsl-footnote-separator"); if (footnoteSeparator != null) { // the footnote separator can contain page-dependent content such as - // page numbers or retrieve markers, so its areas cannot simply be + // page numbers or retrieve markers, so its areas cannot simply be // obtained now and repeated in each page; // we need to know in advance the separator bpd: the actual separator // could be different from page to page, but its bpd would likely be @@ -199,7 +199,7 @@ public class PageBreaker extends AbstractBreaker { } return contentList; } - + /** * @return current display alignment */ @@ -207,14 +207,14 @@ public class PageBreaker extends AbstractBreaker { return pslm.getCurrentPage().getSimplePageMaster().getRegion( Constants.FO_REGION_BODY).getDisplayAlign(); } - + /** * @return whether or not this flow has more page break opportunities */ protected boolean hasMoreContent() { return !childFLM.isFinished(); } - + /** * Adds an area to the flow layout manager * @param posIter the position iterator @@ -235,18 +235,18 @@ public class PageBreaker extends AbstractBreaker { footnoteSeparatorLM.doLayout(); } - childFLM.addAreas(posIter, context); + childFLM.addAreas(posIter, context); } - + /** * Performs phase 3 operation - * + * * @param alg page breaking algorithm * @param partCount part count * @param originalList the block sequence original list * @param effectiveList the block sequence effective list */ - protected void doPhase3(PageBreakingAlgorithm alg, int partCount, + protected void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { if (needColumnBalancing) { doPhase3WithColumnBalancing(alg, partCount, originalList, effectiveList); @@ -261,7 +261,7 @@ public class PageBreaker extends AbstractBreaker { } } - private void doPhase3WithLastPage(PageBreakingAlgorithm alg, int partCount, + private void doPhase3WithLastPage(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { int newStartPos; int restartPoint = pageProvider.getStartingPartIndexForLastPage(partCount); @@ -281,13 +281,13 @@ public class PageBreaker extends AbstractBreaker { } AbstractBreaker.log.debug("Last page handling now!!!"); AbstractBreaker.log.debug("==================================================="); - AbstractBreaker.log.debug("Restarting at " + restartPoint + AbstractBreaker.log.debug("Restarting at " + restartPoint + ", new start position: " + newStartPos); pageBreakHandled = true; //Update so the available BPD is reported correctly int currentPageNum = pslm.getCurrentPageNum(); - pageProvider.setStartOfNextElementList(currentPageNum, + pageProvider.setStartOfNextElementList(currentPageNum, pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); pageProvider.setLastPageIndex(currentPageNum); @@ -295,7 +295,7 @@ public class PageBreaker extends AbstractBreaker { PageBreakingAlgorithm algRestart = new PageBreakingAlgorithm( getTopLevelLM(), getPageProvider(), createLayoutListener(), - alg.getAlignment(), alg.getAlignmentLast(), + alg.getAlignment(), alg.getAlignmentLast(), footnoteSeparatorLength, isPartOverflowRecoveryActivated(), false, false); //alg.setConstantLineWidth(flowBPD); @@ -304,8 +304,8 @@ public class PageBreaker extends AbstractBreaker { 1, true, BreakingAlgorithm.ALL_BREAKS); AbstractBreaker.log.debug("restart: iOptPageCount= " + iOptPageCount + " pageBreaks.size()= " + algRestart.getPageBreaks().size()); - boolean replaceLastPage - = iOptPageCount <= pslm.getCurrentPV().getBodyRegion().getColumnCount(); + boolean replaceLastPage + = iOptPageCount <= pslm.getCurrentPV().getBodyRegion().getColumnCount(); if (replaceLastPage) { //Replace last page pslm.setCurrentPage(pageProvider.getPage(false, currentPageNum)); @@ -322,7 +322,7 @@ public class PageBreaker extends AbstractBreaker { AbstractBreaker.log.debug("==================================================="); } - private void doPhase3WithColumnBalancing(PageBreakingAlgorithm alg, int partCount, + private void doPhase3WithColumnBalancing(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { AbstractBreaker.log.debug("Column balancing now!!!"); AbstractBreaker.log.debug("==================================================="); @@ -342,12 +342,12 @@ public class PageBreaker extends AbstractBreaker { } else { newStartPos = 0; } - AbstractBreaker.log.debug("Restarting at " + restartPoint + AbstractBreaker.log.debug("Restarting at " + restartPoint + ", new start position: " + newStartPos); pageBreakHandled = true; //Update so the available BPD is reported correctly - pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), + pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); //Restart last page @@ -376,15 +376,15 @@ public class PageBreaker extends AbstractBreaker { addAreas(algRestart, iOptPageCount, originalList, effectiveList); AbstractBreaker.log.debug("==================================================="); } - + protected void startPart(BlockSequence list, int breakClass) { AbstractBreaker.log.debug("startPart() breakClass=" + breakClass); if (pslm.getCurrentPage() == null) { throw new IllegalStateException("curPage must not be null"); } if (!pageBreakHandled) { - - //firstPart is necessary because we need the first page before we start the + + //firstPart is necessary because we need the first page before we start the //algorithm so we have a BPD and IPD. This may subject to change later when we //start handling more complex cases. if (!firstPart) { @@ -394,7 +394,7 @@ public class PageBreaker extends AbstractBreaker { // otherwise, we may simply need a new page handleBreakTrait(breakClass); } - pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), + pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); } pageBreakHandled = false; @@ -402,12 +402,12 @@ public class PageBreaker extends AbstractBreaker { // finish page and add to area tree firstPart = false; } - + /** {@inheritDoc} */ protected void handleEmptyContent() { pslm.getCurrentPV().getPage().fakeNonEmpty(); } - + protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) { // add footnote areas if (pbp.footnoteFirstListIndex < pbp.footnoteLastListIndex @@ -415,16 +415,16 @@ public class PageBreaker extends AbstractBreaker { // call addAreas() for each FootnoteBodyLM for (int i = pbp.footnoteFirstListIndex; i <= pbp.footnoteLastListIndex; i++) { LinkedList elementList = alg.getFootnoteList(i); - int firstIndex = (i == pbp.footnoteFirstListIndex + int firstIndex = (i == pbp.footnoteFirstListIndex ? pbp.footnoteFirstElementIndex : 0); - int lastIndex = (i == pbp.footnoteLastListIndex + int lastIndex = (i == pbp.footnoteLastListIndex ? pbp.footnoteLastElementIndex : elementList.size() - 1); - SpaceResolver.performConditionalsNotification(elementList, + SpaceResolver.performConditionalsNotification(elementList, firstIndex, lastIndex, -1); LayoutContext childLC = new LayoutContext(0); - AreaAdditionUtil.addAreas(null, - new KnuthPossPosIter(elementList, firstIndex, lastIndex + 1), + AreaAdditionUtil.addAreas(null, + new KnuthPossPosIter(elementList, firstIndex, lastIndex + 1), childLC); } // set the offset from the top margin @@ -438,20 +438,20 @@ public class PageBreaker extends AbstractBreaker { } pslm.getCurrentPV().getCurrentSpan().notifyFlowsFinished(); } - + /** * @return the current child flow layout manager */ protected LayoutManager getCurrentChildLM() { return childFLM; } - + /** {@inheritDoc} */ protected void observeElementList(List elementList) { - ElementListObserver.observe(elementList, "breaker", + ElementListObserver.observe(elementList, "breaker", ((PageSequence)pslm.getFObj()).getId()); } - + /** * Depending on the kind of break condition, move to next column * or page. May need to make an empty page if next page would @@ -471,17 +471,17 @@ public class PageBreaker extends AbstractBreaker { || breakVal <= 0 || breakVal == Constants.EN_AUTO) { PageViewport pv = curPage.getPageViewport(); - + //Check if previous page was spanned boolean forceNewPageWithSpan = false; RegionBody rb = (RegionBody)curPage.getSimplePageMaster().getRegion( Constants.FO_REGION_BODY); - if (breakVal < 0 - && rb.getColumnCount() > 1 + if (breakVal < 0 + && rb.getColumnCount() > 1 && pv.getCurrentSpan().getColumnCount() == 1) { forceNewPageWithSpan = true; } - + if (forceNewPageWithSpan) { curPage = pslm.makeNewPage(false, false); curPage.getPageViewport().createSpan(true); @@ -492,7 +492,7 @@ public class PageBreaker extends AbstractBreaker { } return; } - log.debug("handling break-before after page " + pslm.getCurrentPageNum() + log.debug("handling break-before after page " + pslm.getCurrentPageNum() + " breakVal=" + breakVal); if (needBlankPageBeforeNew(breakVal)) { curPage = pslm.makeNewPage(true, false); @@ -501,7 +501,7 @@ public class PageBreaker extends AbstractBreaker { curPage = pslm.makeNewPage(false, false); } } - + /** * Check if a blank page is needed to accomodate * desired even or odd page number. @@ -520,7 +520,7 @@ public class PageBreaker extends AbstractBreaker { } } } - + /** * See if need to generate a new page * @param breakVal - value of break-before or break-after trait. diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java index 9e0b42ecb..8095feba1 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java @@ -73,13 +73,13 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { /** Index of the last element of the last footnote inserted on the current page. */ private int footnoteElementIndex = -1; - // demerits for a page break that splits a footnote + // demerits for a page break that splits a footnote private int splitFootnoteDemerits = 5000; - // demerits for a page break that defers a whole footnote to the following page + // demerits for a page break that defers a whole footnote to the following page private int deferredFootnoteDemerits = 10000; private MinOptMax footnoteSeparatorLength = null; - // the method noBreakBetween(int, int) uses these variables + // the method noBreakBetween(int, int) uses these variables // to store parameters and result of the last call, in order // to reuse them and take less time private int storedPrevBreakIndex = -1; @@ -88,10 +88,10 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { //Controls whether overflows should be warned about or not private boolean autoHeight = false; - + //Controls whether a single part should be forced if possible (ex. block-container) private boolean favorSinglePart = false; - + public PageBreakingAlgorithm(LayoutManager topLevelLM, PageProvider pageProvider, PageBreakingLayoutListener layoutListener, @@ -202,7 +202,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { totalWidth, totalStretch, totalShrink, ((BestPageRecords) best).getFootnotesLength(fitness), ((BestPageRecords) best).getFootnoteListIndex(fitness), - ((BestPageRecords) best).getFootnoteElementIndex(fitness), + ((BestPageRecords) best).getFootnoteElementIndex(fitness), best.getAdjust(fitness), best.getAvailableShrink(fitness), best.getAvailableStretch(fitness), best.getDifference(fitness), best.getDemerits(fitness), best.getNode(fitness)); @@ -247,11 +247,11 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { ListIterator elementListsIterator = elementLists.listIterator(); while (elementListsIterator.hasNext()) { LinkedList noteList = (LinkedList) elementListsIterator.next(); - - //Space resolution (Note: this does not respect possible stacking constraints + + //Space resolution (Note: this does not respect possible stacking constraints //between footnotes!) SpaceResolver.resolveElementList(noteList); - + int noteLength = 0; footnotesList.add(noteList); ListIterator noteListIterator = noteList.listIterator(); @@ -261,8 +261,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { noteLength += element.getW(); } } - int prevLength = (lengthList.size() == 0 - ? 0 + int prevLength = (lengthList.size() == 0 + ? 0 : ((Integer) lengthList.get(lengthList.size() - 1)).intValue()); lengthList.add(new Integer(prevLength + noteLength)); totalFootnotesLength += noteLength; @@ -423,7 +423,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { index < breakIndex; index++) { if (par.getElement(index).isGlue() && par.getElement(index - 1).isBox() - || par.getElement(index).isPenalty() + || par.getElement(index).isPenalty() && ((KnuthElement) par.getElement(index)).getP() < KnuthElement.INFINITE) { // break found break; @@ -520,7 +520,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } // as this method is called only if it is not possible to insert // all footnotes, at this point listIndex and elementIndex points to - // an existing element, the next one we will try to insert + // an existing element, the next one we will try to insert } // try adding a split of the next note @@ -582,7 +582,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { // prevIndex is -1 if we have added only some whole footnotes footnoteListIndex = (prevIndex != -1) ? listIndex : listIndex - 1; footnoteElementIndex = (prevIndex != -1) - ? prevIndex + ? prevIndex : ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1; } return prevSplitLength; @@ -618,7 +618,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } } - protected double computeDemerits(KnuthNode activeNode, KnuthElement element, + protected double computeDemerits(KnuthNode activeNode, KnuthElement element, int fitnessClass, double r) { double demerits = 0; // compute demerits @@ -649,11 +649,11 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { if (footnotesPending) { if (footnoteListIndex < footnotesList.size() - 1) { // add demerits for the deferred footnotes - demerits += (footnotesList.size() - 1 - footnoteListIndex) + demerits += (footnotesList.size() - 1 - footnoteListIndex) * deferredFootnoteDemerits; } if (footnoteListIndex < footnotesList.size()) { - if (footnoteElementIndex + if (footnoteElementIndex < ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1) { // add demerits for the footnote split between pages demerits += splitFootnoteDemerits; @@ -710,7 +710,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { // cannot add any content: create a new node and start again KnuthPageNode node = (KnuthPageNode) createNode(lastNode.position, prevNode.line + 1, 1, - insertedFootnotesLength - prevNode.totalFootnotes, + insertedFootnotesLength - prevNode.totalFootnotes, 0, 0, 0, 0, 0, 0, 0, prevNode); @@ -744,7 +744,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } pageBreaks.addFirst(pageBreak); } - + /** * Removes all page breaks from the result list. This is used by block-containers and * static-content when it is only desired to know where there is an overflow but later the @@ -758,14 +758,14 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { pageBreaks.removeFirst(); } } - + public void updateData1(int total, double demerits) { } public void updateData2(KnuthNode bestActiveNode, KnuthSequence sequence, int total) { - //int difference = (bestActiveNode.line < total) + //int difference = (bestActiveNode.line < total) // ? bestActiveNode.difference : bestActiveNode.difference + fillerMinWidth; int difference = bestActiveNode.difference; if (difference + bestActiveNode.availableShrink < 0) { @@ -818,10 +818,10 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { // add nodes at the beginning of the list, as they are found // backwards, from the last one to the first one if (log.isDebugEnabled()) { - log.debug("BBA> difference=" + difference + " ratio=" + ratio + log.debug("BBA> difference=" + difference + " ratio=" + ratio + " position=" + bestActiveNode.position); } - insertPageBreakAsFirst(new PageBreakPosition(this.topLevelLM, + insertPageBreakAsFirst(new PageBreakPosition(this.topLevelLM, bestActiveNode.position, firstListIndex, firstElementIndex, ((KnuthPageNode) bestActiveNode).footnoteListIndex, @@ -834,8 +834,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { KnuthNode bestActiveNode = null; for (int i = startLine; i < endLine; i++) { for (KnuthNode node = getNode(i); node != null; node = node.next) { - if (favorSinglePart - && node.line > 1 + if (favorSinglePart + && node.line > 1 && bestActiveNode != null && Math.abs(bestActiveNode.difference) < bestActiveNode.availableShrink) { //favor current best node, so just skip the current node because it would @@ -854,12 +854,12 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { public LinkedList getFootnoteList(int index) { return (LinkedList) footnotesList.get(index); } - + /** @return the associated top-level formatting object. */ public FObj getFObj() { return topLevelLM.getFObj(); } - + /** {@inheritDoc} */ protected int getLineWidth(int line) { int bpd; @@ -873,7 +873,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } return bpd; } - + /** * Interface to notify about layout events during page breaking. */ @@ -886,7 +886,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { * @param obj the root FO object where this happens */ void notifyOverflow(int part, int amount, FObj obj); - + } - + } diff --git a/src/java/org/apache/fop/layoutmgr/PageProvider.java b/src/java/org/apache/fop/layoutmgr/PageProvider.java index a7918db6e..55c78ba52 100644 --- a/src/java/org/apache/fop/layoutmgr/PageProvider.java +++ b/src/java/org/apache/fop/layoutmgr/PageProvider.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,38 +35,38 @@ import org.apache.fop.fo.pagination.SimplePageMaster; * </p> * <p>Additional functionality makes sure that surplus instances that are requested by the * page breaker are properly discarded, especially in situations where hard breaks cause - * blank pages. The reason for that: The page breaker sometimes needs to preallocate + * blank pages. The reason for that: The page breaker sometimes needs to preallocate * additional pages since it doesn't know exactly until the end how many pages it really needs. * </p> */ public class PageProvider implements Constants { - + private Log log = LogFactory.getLog(PageProvider.class); /** Indices are evaluated relative to the first page in the page-sequence. */ public static final int RELTO_PAGE_SEQUENCE = 0; /** Indices are evaluated relative to the first page in the current element list. */ public static final int RELTO_CURRENT_ELEMENT_LIST = 1; - + private int startPageOfPageSequence; private int startPageOfCurrentElementList; private int startColumnOfCurrentElementList; private List cachedPages = new java.util.ArrayList(); - + private int lastPageIndex = -1; private int indexOfCachedLastPage = -1; - + //Cache to optimize getAvailableBPD() calls private int lastRequestedIndex = -1; private int lastReportedBPD = -1; - /** + /** * AreaTreeHandler which activates the PSLM and controls * the rendering of its pages. */ private AreaTreeHandler areaTreeHandler; - /** + /** * fo:page-sequence formatting object being * processed by this class */ @@ -82,12 +82,12 @@ public class PageProvider implements Constants { this.pageSeq = ps; this.startPageOfPageSequence = ps.getStartingPageNumber(); } - + /** * The page breaker notifies the provider about the page number an element list starts * on so it can later retrieve PageViewports relative to this first page. * @param startPage the number of the first page for the element list. - * @param startColumn the starting column number for the element list. + * @param startColumn the starting column number for the element list. */ public void setStartOfNextElementList(int startPage, int startColumn) { log.debug("start of the next element list is:" @@ -98,7 +98,7 @@ public class PageProvider implements Constants { this.lastRequestedIndex = -1; this.lastReportedBPD = -1; } - + /** * Sets the index of the last page. This is done as soon as the position of the last page * is known or assumed. @@ -107,7 +107,7 @@ public class PageProvider implements Constants { public void setLastPageIndex(int index) { this.lastPageIndex = index; } - + /** * Returns the available BPD for the part/page indicated by the index parameter. * The index is the part/page relative to the start of the current element list. @@ -145,9 +145,9 @@ public class PageProvider implements Constants { } return this.lastReportedBPD; } - + /** - * Returns the part index (0<x<partCount) which denotes the first part on the last page + * Returns the part index (0<x<partCount) which denotes the first part on the last page * generated by the current element list. * @param partCount Number of parts determined by the breaking algorithm * @return the requested part index @@ -177,7 +177,7 @@ public class PageProvider implements Constants { * Returns a Page. * @param isBlank true if this page is supposed to be blank. * @param index Index of the page (see relativeTo) - * @param relativeTo Defines which value the index parameter should be evaluated relative + * @param relativeTo Defines which value the index parameter should be evaluated relative * to. (One of PageProvider.RELTO_*) * @return the requested Page */ @@ -193,7 +193,7 @@ public class PageProvider implements Constants { "Illegal value for relativeTo: " + relativeTo); } } - + /** * Returns a Page. * @param isBlank true if the Page should be a blank one @@ -203,7 +203,7 @@ public class PageProvider implements Constants { protected Page getPage(boolean isBlank, int index) { boolean isLastPage = (lastPageIndex >= 0) && (index == lastPageIndex); if (log.isTraceEnabled()) { - log.trace("getPage(" + index + " " + (isBlank ? "blank" : "non-blank") + log.trace("getPage(" + index + " " + (isBlank ? "blank" : "non-blank") + (isLastPage ? " <LAST>" : "") + ")"); } int intIndex = index - startPageOfPageSequence; @@ -248,12 +248,12 @@ public class PageProvider implements Constants { } } } - + private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage) { String pageNumberString = pageSeq.makeFormattedPageNumber(index); SimplePageMaster spm = pageSeq.getNextSimplePageMaster( index, (startPageOfPageSequence == index), isLastPage, false, 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 diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index c5a3bdeec..f9517554f 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -57,9 +57,9 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager public PageProvider getPageProvider() { return this.pageProvider; } - + /** - * @return the PageSequence being managed by this layout manager + * @return the PageSequence being managed by this layout manager */ protected PageSequence getPageSequence() { return (PageSequence)pageSeq; @@ -72,7 +72,7 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager public PageSequenceLayoutManager getPSLM() { return this; } - + /** {@inheritDoc} */ public void activateLayout() { initialize(); @@ -100,7 +100,7 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager } curPage = makeNewPage(false, false); - + PageBreaker breaker = new PageBreaker(this); int flowBPD = getCurrentPV().getBodyRegion().getRemainingBPD(); breaker.doLayout(flowBPD); @@ -118,7 +118,7 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager areaTreeHandler.notifyPageSequenceFinished(pageSeq, (currentPageNum - startPageNum) + 1); getPageSequence().releasePageSequence(); - + // If this sequence has a page sequence master so we must reset // it in preparation for the next sequence String masterReference = getPageSequence().getMasterReference(); @@ -132,13 +132,13 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager log.debug("Ending layout"); } } - + /** {@inheritDoc} */ protected Page createPage(int pageNumber, boolean isBlank) { return pageProvider.getPage(isBlank, pageNumber, PageProvider.RELTO_PAGE_SEQUENCE); } - + private void layoutSideRegion(int regionID) { SideRegion reg = (SideRegion)curPage.getSimplePageMaster().getRegion(regionID); if (reg == null) { @@ -158,12 +158,12 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager /** {@inheritDoc} */ protected void finishPage() { // Layout side regions - layoutSideRegion(FO_REGION_BEFORE); + layoutSideRegion(FO_REGION_BEFORE); layoutSideRegion(FO_REGION_AFTER); layoutSideRegion(FO_REGION_START); layoutSideRegion(FO_REGION_END); - + super.finishPage(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/Position.java b/src/java/org/apache/fop/layoutmgr/Position.java index 197970403..42034cab4 100644 --- a/src/java/org/apache/fop/layoutmgr/Position.java +++ b/src/java/org/apache/fop/layoutmgr/Position.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,11 +16,11 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; public class Position { - + private LayoutManager layoutManager; private int index = -1; @@ -39,14 +39,14 @@ public class Position { public Position getPosition() { return null; } - + public boolean generatesAreas() { return false; } /** * Sets the index of this position in the sequence of Position elements. - * + * * @param value this position's index */ public void setIndex(int value) { @@ -55,13 +55,13 @@ public class Position { /** * Returns the index of this position in the sequence of Position elements. - * + * * @return the index of this position in the sequence of Position elements */ public int getIndex() { return this.index; } - + public String getShortLMName() { if (getLM() != null) { String lm = getLM().toString(); @@ -75,7 +75,7 @@ public class Position { return "null"; } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/layoutmgr/PositionIterator.java b/src/java/org/apache/fop/layoutmgr/PositionIterator.java index cd0f92b78..b50035313 100644 --- a/src/java/org/apache/fop/layoutmgr/PositionIterator.java +++ b/src/java/org/apache/fop/layoutmgr/PositionIterator.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; import java.util.Iterator; import java.util.NoSuchElementException; public abstract class PositionIterator implements Iterator { - + private Iterator parentIter; private Object nextObj; private LayoutManager childLM; diff --git a/src/java/org/apache/fop/layoutmgr/RelSide.java b/src/java/org/apache/fop/layoutmgr/RelSide.java index 26650e0b1..38e4ab9ec 100644 --- a/src/java/org/apache/fop/layoutmgr/RelSide.java +++ b/src/java/org/apache/fop/layoutmgr/RelSide.java @@ -30,7 +30,7 @@ public final class RelSide { public static final RelSide START = new RelSide("start"); /** the end side */ public static final RelSide END = new RelSide("end"); - + private String name; /** @@ -45,10 +45,10 @@ public final class RelSide { public String getName() { return this.name; } - + /** {@inheritDoc} */ public String toString() { return "RelSide:" + name; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/SpaceElement.java b/src/java/org/apache/fop/layoutmgr/SpaceElement.java index 558621529..820cf6506 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceElement.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceElement.java @@ -30,7 +30,7 @@ import org.apache.fop.traits.MinOptMax; public class SpaceElement extends UnresolvedListElementWithLength { private int precedence; - + /** * Main constructor * @param position the Position instance needed by the addAreas stage of the LMs. @@ -40,21 +40,21 @@ public class SpaceElement extends UnresolvedListElementWithLength { * @param isLast true if this is a space-after of the last area generated. * @param context the property evaluation context */ - public SpaceElement(Position position, SpaceProperty space, RelSide side, + public SpaceElement(Position position, SpaceProperty space, RelSide side, boolean isFirst, boolean isLast, PercentBaseContext context) { - super(position, + super(position, MinOptMaxUtil.toMinOptMax( - space.getSpace().getLengthRange(), + space.getSpace().getLengthRange(), context), side, space.isDiscard(), isFirst, isLast); int en = space.getSpace().getPrecedence().getEnum(); if (en == Constants.EN_FORCE) { this.precedence = Integer.MAX_VALUE; } else { - this.precedence = space.getSpace().getPrecedence().getNumber().intValue(); + this.precedence = space.getSpace().getPrecedence().getNumber().intValue(); } } - + /** @return true if the space is forcing. */ public boolean isForcing() { return this.precedence == Integer.MAX_VALUE; @@ -64,7 +64,7 @@ public class SpaceElement extends UnresolvedListElementWithLength { public int getPrecedence() { return this.precedence; } - + /** {@inheritDoc} */ public void notifyLayoutManager(MinOptMax effectiveLength) { LayoutManager lm = getOriginatingLayoutManager(); @@ -72,11 +72,11 @@ public class SpaceElement extends UnresolvedListElementWithLength { ((ConditionalElementListener)lm).notifySpace( getSide(), effectiveLength); } else { - log.warn("Cannot notify LM. It does not implement ConditionalElementListener:" + log.warn("Cannot notify LM. It does not implement ConditionalElementListener:" + lm.getClass().getName()); } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer("Space["); diff --git a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java index 051f76d7f..416ee924d 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java @@ -37,19 +37,19 @@ public class SpaceResolver { /** Logger instance */ protected static Log log = LogFactory.getLog(SpaceResolver.class); - + private UnresolvedListElementWithLength[] firstPart; private BreakElement breakPoss; private UnresolvedListElementWithLength[] secondPart; private UnresolvedListElementWithLength[] noBreak; - + private MinOptMax[] firstPartLengths; private MinOptMax[] secondPartLengths; private MinOptMax[] noBreakLengths; - + private boolean isFirst; private boolean isLast; - + /** * Main constructor. * @param first Element list before a break (optional) @@ -58,7 +58,7 @@ public class SpaceResolver { * @param isFirst Resolution at the beginning of a (full) element list * @param isLast Resolution at the end of a (full) element list */ - private SpaceResolver(List first, BreakElement breakPoss, List second, + private SpaceResolver(List first, BreakElement breakPoss, List second, boolean isFirst, boolean isLast) { this.isFirst = isFirst; this.isLast = isLast; @@ -95,14 +95,14 @@ public class SpaceResolver { if (breakPoss != null) { if (breakPoss.getPendingAfterMarks() != null) { if (log.isTraceEnabled()) { - log.trace(" adding pending before break: " + log.trace(" adding pending before break: " + breakPoss.getPendingAfterMarks()); } first.addAll(0, breakPoss.getPendingAfterMarks()); } if (breakPoss.getPendingBeforeMarks() != null) { if (log.isTraceEnabled()) { - log.trace(" adding pending after break: " + log.trace(" adding pending after break: " + breakPoss.getPendingBeforeMarks()); } second.addAll(0, breakPoss.getPendingBeforeMarks()); @@ -134,7 +134,7 @@ public class SpaceResolver { } resolve(); } - + private String toString(Object[] arr1, Object[] arr2) { if (arr1.length != arr2.length) { new IllegalArgumentException("The length of both arrays must be equal"); @@ -151,7 +151,7 @@ public class SpaceResolver { sb.append("]"); return sb.toString(); } - + private void removeConditionalBorderAndPadding( UnresolvedListElement[] elems, MinOptMax[] lengths, boolean reverse) { for (int i = 0; i < elems.length; i++) { @@ -175,7 +175,7 @@ public class SpaceResolver { log.trace("-->Resulting list: " + toString(elems, lengths)); } } - + private void performSpaceResolutionRule1(UnresolvedListElement[] elems, MinOptMax[] lengths, boolean reverse) { for (int i = 0; i < elems.length; i++) { @@ -204,14 +204,14 @@ public class SpaceResolver { } } - private void performSpaceResolutionRules2to3(UnresolvedListElement[] elems, + private void performSpaceResolutionRules2to3(UnresolvedListElement[] elems, MinOptMax[] lengths, int start, int end) { if (log.isTraceEnabled()) { log.trace("rule 2-3: " + start + "-" + end); } SpaceElement space; int remaining; - + //Rule 2 (4.3.1, XSL 1.0) boolean hasForcing = false; remaining = 0; @@ -237,7 +237,7 @@ public class SpaceResolver { space = (SpaceElement)elems[i]; if (!space.isForcing()) { if (log.isDebugEnabled()) { - log.debug("Nulling non-forcing space-specifier using 4.3.1, rule 2: " + log.debug("Nulling non-forcing space-specifier using 4.3.1, rule 2: " + elems[i]); } lengths[i] = null; @@ -245,7 +245,7 @@ public class SpaceResolver { } return; //If rule is triggered skip rule 3 } - + //Rule 3 (4.3.1, XSL 1.0) //Determine highes precedence int highestPrecedence = Integer.MIN_VALUE; @@ -269,8 +269,8 @@ public class SpaceResolver { space = (SpaceElement)elems[i]; if (space.getPrecedence() != highestPrecedence) { if (log.isDebugEnabled()) { - log.debug("Nulling space-specifier with precedence " - + space.getPrecedence() + " using 4.3.1, rule 3: " + log.debug("Nulling space-specifier with precedence " + + space.getPrecedence() + " using 4.3.1, rule 3: " + elems[i]); } lengths[i] = null; @@ -295,7 +295,7 @@ public class SpaceResolver { if (space.getLength().opt < greatestOptimum) { if (log.isDebugEnabled()) { log.debug("Nulling space-specifier with smaller optimum length " - + "using 4.3.1, rule 3: " + + "using 4.3.1, rule 3: " + elems[i]); } lengths[i] = null; @@ -318,7 +318,7 @@ public class SpaceResolver { max = Math.min(max, space.getLength().max); if (remaining > 1) { if (log.isDebugEnabled()) { - log.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: " + log.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: " + elems[i]); } lengths[i] = null; @@ -334,7 +334,7 @@ public class SpaceResolver { log.trace("-->Resulting list: " + toString(elems, lengths)); } } - + private void performSpaceResolutionRules2to3(UnresolvedListElement[] elems, MinOptMax[] lengths) { int start = 0; @@ -354,15 +354,15 @@ public class SpaceResolver { start = i; } } - + private boolean hasFirstPart() { return firstPart != null && firstPart.length > 0; } - + private boolean hasSecondPart() { return secondPart != null && secondPart.length > 0; } - + private void resolve() { if (breakPoss != null) { if (hasFirstPart()) { @@ -387,7 +387,7 @@ public class SpaceResolver { removeConditionalBorderAndPadding(firstPart, firstPartLengths, true); performSpaceResolutionRule1(firstPart, firstPartLengths, true); } - + if (hasFirstPart()) { //Now that we've handled isFirst/isLast conditions, we need to look at the //active part in its normal order so swap it back. @@ -408,7 +408,7 @@ public class SpaceResolver { performSpaceResolutionRules2to3(secondPart, secondPartLengths); } } - + private MinOptMax sum(MinOptMax[] lengths) { MinOptMax sum = new MinOptMax(); for (int i = 0; i < lengths.length; i++) { @@ -418,7 +418,7 @@ public class SpaceResolver { } return sum; } - + private void generate(ListIterator iter) { MinOptMax noBreakLength = new MinOptMax(); MinOptMax glue1; //space before break possibility if break occurs @@ -427,12 +427,12 @@ public class SpaceResolver { glue1 = sum(firstPartLengths); glue3 = sum(secondPartLengths); noBreakLength = sum(noBreakLengths); - + //This doesn't produce the right glue2 //glue2 = new MinOptMax(noBreakLength); //glue2.subtract(glue1); //glue2.subtract(glue3); - + int glue2w = noBreakLength.opt - glue1.opt - glue3.opt; int glue2stretch = (noBreakLength.max - noBreakLength.opt); int glue2shrink = (noBreakLength.opt - noBreakLength.min); @@ -440,34 +440,34 @@ public class SpaceResolver { glue2stretch -= glue3.max - glue3.opt; glue2shrink -= glue1.opt - glue1.min; glue2shrink -= glue3.opt - glue3.min; - + boolean hasPrecedingNonBlock = false; if (log.isDebugEnabled()) { - log.debug("noBreakLength=" + noBreakLength - + ", glue1=" + glue1 - + ", glue2=" + glue2w + "+" + glue2stretch + "-" + glue2shrink + log.debug("noBreakLength=" + noBreakLength + + ", glue1=" + glue1 + + ", glue2=" + glue2w + "+" + glue2stretch + "-" + glue2shrink + ", glue3=" + glue3); } if (breakPoss != null) { boolean forcedBreak = breakPoss.isForcedBreak(); if (glue1.isNonZero()) { - iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, + iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, (Position)null, true)); - iter.add(new KnuthGlue(glue1.opt, glue1.max - glue1.opt, glue1.opt - glue1.min, + iter.add(new KnuthGlue(glue1.opt, glue1.max - glue1.opt, glue1.opt - glue1.min, (Position)null, true)); if (forcedBreak) { //Otherwise, the preceding penalty and glue will be cut off iter.add(new KnuthBox(0, (Position)null, true)); } } - iter.add(new KnuthPenalty(breakPoss.getPenaltyWidth(), breakPoss.getPenaltyValue(), - false, breakPoss.getBreakClass(), + iter.add(new KnuthPenalty(breakPoss.getPenaltyWidth(), breakPoss.getPenaltyValue(), + false, breakPoss.getBreakClass(), new SpaceHandlingBreakPosition(this, breakPoss), false)); if (breakPoss.getPenaltyValue() <= -KnuthPenalty.INFINITE) { return; //return early. Not necessary (even wrong) to add additional elements } if (glue2w != 0 || glue2stretch != 0 || glue2shrink != 0) { - iter.add(new KnuthGlue(glue2w, glue2stretch, glue2shrink, + iter.add(new KnuthGlue(glue2w, glue2stretch, glue2shrink, (Position)null, true)); } } else { @@ -483,9 +483,9 @@ public class SpaceResolver { iter.add(new KnuthBox(0, pos, true)); } if (glue3.isNonZero()) { - iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, + iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, (Position)null, true)); - iter.add(new KnuthGlue(glue3.opt, glue3.max - glue3.opt, glue3.opt - glue3.min, + iter.add(new KnuthGlue(glue3.opt, glue3.max - glue3.opt, glue3.opt - glue3.min, (Position)null, true)); hasPrecedingNonBlock = true; } @@ -494,7 +494,7 @@ public class SpaceResolver { iter.add(new KnuthBox(0, (Position)null, true)); } } - + /** * Position class for break possibilities. It is used to notify layout manager about the * effective spaces and conditional lengths. @@ -503,11 +503,11 @@ public class SpaceResolver { private SpaceResolver resolver; private Position originalPosition; - + /** * Main constructor. * @param resolver the space resolver that provides the info about the actual situation - * @param breakPoss the original break possibility that creates this Position + * @param breakPoss the original break possibility that creates this Position */ public SpaceHandlingBreakPosition(SpaceResolver resolver, BreakElement breakPoss) { super(null); @@ -518,18 +518,18 @@ public class SpaceResolver { this.originalPosition = this.originalPosition.getPosition(); } } - + /** @return the space resolver */ public SpaceResolver getSpaceResolver() { return this.resolver; } - + /** * Notifies all affected layout managers about the current situation in the part to be * handled for area generation. * @param isBreakSituation true if this is a break situation. * @param side defines to notify about the situation whether before or after the break. - * May be null if isBreakSituation is null. + * May be null if isBreakSituation is null. */ public void notifyBreakSituation(boolean isBreakSituation, RelSide side) { if (isBreakSituation) { @@ -548,7 +548,7 @@ public class SpaceResolver { } } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); @@ -558,7 +558,7 @@ public class SpaceResolver { return sb.toString(); } - /** + /** * @return the original Position instance set at the BreakElement that this Position was * created for. */ @@ -566,7 +566,7 @@ public class SpaceResolver { return this.originalPosition; } } - + /** * Position class for no-break situations. It is used to notify layout manager about the * effective spaces and conditional lengths. @@ -574,7 +574,7 @@ public class SpaceResolver { public static class SpaceHandlingPosition extends Position { private SpaceResolver resolver; - + /** * Main constructor. * @param resolver the space resolver that provides the info about the actual situation @@ -583,12 +583,12 @@ public class SpaceResolver { super(null); this.resolver = resolver; } - + /** @return the space resolver */ public SpaceResolver getSpaceResolver() { return this.resolver; } - + /** * Notifies all affected layout managers about the current situation in the part to be * handled for area generation. @@ -601,7 +601,7 @@ public class SpaceResolver { resolver.secondPart[i].notifyLayoutManager(resolver.secondPartLengths[i]); } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); @@ -609,7 +609,7 @@ public class SpaceResolver { return sb.toString(); } } - + /** * Resolves unresolved elements applying the space resolution rules defined in 4.3.1. * @param elems the element list @@ -673,7 +673,7 @@ public class SpaceResolver { unresolvedSecond = unresolvedFirst; unresolvedFirst = swapList; } - + log.debug("----start space resolution (first=" + first + ", last=" + last + ")..."); SpaceResolver resolver = new SpaceResolver( unresolvedFirst, breakPoss, unresolvedSecond, first, last); @@ -689,7 +689,7 @@ public class SpaceResolver { first = false; } } - + /** * Inspects an effective element list and notifies all layout managers about the state of * the spaces and conditional lengths. @@ -699,7 +699,7 @@ public class SpaceResolver { * @param prevBreak index of the the break possibility just before this part (used to * identify a break condition, lastBreak <= 0 represents a no-break condition) */ - public static void performConditionalsNotification(List effectiveList, + public static void performConditionalsNotification(List effectiveList, int startElementIndex, int endElementIndex, int prevBreak) { KnuthElement el = null; if (prevBreak > 0) { @@ -710,7 +710,7 @@ public class SpaceResolver { if (el != null && el.isPenalty()) { Position pos = el.getPosition(); if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { - beforeBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; + beforeBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; beforeBreak.notifyBreakSituation(true, RelSide.BEFORE); } } @@ -718,7 +718,7 @@ public class SpaceResolver { if (el != null && el.isPenalty()) { Position pos = el.getPosition(); if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { - afterBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; + afterBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; afterBreak.notifyBreakSituation(true, RelSide.AFTER); } } @@ -735,7 +735,7 @@ public class SpaceResolver { } } } - - + + } diff --git a/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java b/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java index c6c47fd35..62a066121 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,7 +52,7 @@ public class SpaceSpecifier implements Cloneable { try { SpaceSpecifier ss = (SpaceSpecifier) super.clone(); ss.startsReferenceArea = startsReferenceArea; - ss.hasForcing = hasForcing; + ss.hasForcing = hasForcing; // Clone the vector, but share the objects in it! ss.spaceVals = new ArrayList(); ss.spaceVals.addAll(spaceVals); @@ -152,7 +152,7 @@ public class SpaceSpecifier implements Cloneable { } return resolvedSpace; } - + public String toString() { return "Space Specifier (resolved at begin/end of ref. area:):\n" + resolve(false).toString() + "\n" + diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java index 44e0cc476..b4941d418 100644 --- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; import java.util.LinkedList; @@ -66,7 +66,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { * @param node static-content FO * @param reg side region to layout into */ - public StaticContentLayoutManager(PageSequenceLayoutManager pslm, + public StaticContentLayoutManager(PageSequenceLayoutManager pslm, StaticContent node, SideRegion reg) { super(node); setParent(pslm); @@ -80,11 +80,11 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { * @param node static-content FO * @param block the block to layout into */ - public StaticContentLayoutManager(PageSequenceLayoutManager pslm, + public StaticContentLayoutManager(PageSequenceLayoutManager pslm, StaticContent node, Block block) { super(node); setParent(pslm); - targetBlock = block; + targetBlock = block; } /** {@inheritDoc} */ @@ -98,7 +98,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { setContentAreaIPD(context.getRefIPD()); setContentAreaBPD(context.getStackLimitBP().opt); - //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. + //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. // currently active LM BlockLevelLayoutManager curLM; BlockLevelLayoutManager prevLM = null; @@ -122,7 +122,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { // get elements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); - //log.debug("FLM.getNextKnuthElements> returnedList.size() = " + //log.debug("FLM.getNextKnuthElements> returnedList.size() = " // + returnedList.size()); // "wrap" the Position inside each element @@ -148,8 +148,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { if (prevLM.mustKeepWithNext() || curLM.mustKeepWithPrevious()) { // add an infinite penalty to forbid a break between blocks - returnList.add(new KnuthPenalty(0, - KnuthElement.INFINITE, false, + returnList.add(new KnuthPenalty(0, + KnuthElement.INFINITE, false, new Position(this), false)); } else if (!((KnuthElement) ListUtil.getLast(returnList)) .isGlue()) { @@ -180,9 +180,9 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { return returnList; } } - + /** - * {@inheritDoc} + * {@inheritDoc} */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { AreaAdditionUtil.addAreas(this, parentIter, layoutContext); @@ -246,10 +246,10 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { if (breaker.isOverflow()) { if (!autoHeight) { String page = getPSLM().getCurrentPage().getPageViewport().getPageNumberString(); - + BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( getStaticContentFO().getUserAgent().getEventBroadcaster()); - boolean canRecover = (regionFO.getOverflow() != EN_ERROR_IF_OVERFLOW); + boolean canRecover = (regionFO.getOverflow() != EN_ERROR_IF_OVERFLOW); boolean needClip = (regionFO.getOverflow() == Constants.EN_HIDDEN || regionFO.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW); eventProducer.regionOverflow(this, regionFO.getName(), @@ -259,7 +259,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { } } } - + /** * Convenience method that returns the Static Content node. * @return the static content node @@ -268,13 +268,13 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { return (StaticContent) fobj; } - private class StaticContentBreaker extends AbstractBreaker { + private class StaticContentBreaker extends AbstractBreaker { private StaticContentLayoutManager lm; private int displayAlign; private int ipd; private int overflow = 0; - - public StaticContentBreaker(StaticContentLayoutManager lm, int ipd, + + public StaticContentBreaker(StaticContentLayoutManager lm, int ipd, int displayAlign) { this.lm = lm; this.ipd = ipd; @@ -290,7 +290,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { } ElementListObserver.observe(elementList, "static-content", elementListID); } - + /** {@inheritDoc} */ protected boolean isPartOverflowRecoveryActivated() { //For side regions, this must be disabled because of wanted overflow. @@ -300,11 +300,11 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { public boolean isOverflow() { return (this.overflow != 0); } - + public int getOverflowAmount() { return this.overflow; } - + /** {@inheritDoc} */ protected PageBreakingLayoutListener createLayoutListener() { return new PageBreakingLayoutListener() { @@ -314,7 +314,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { StaticContentBreaker.this.overflow = amount; } } - + }; } @@ -327,7 +327,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { lc.setRefIPD(ipd); return lc; } - + protected List getNextKnuthElements(LayoutContext context, int alignment) { LayoutManager curLM; // currently active LM List returnList = new LinkedList(); @@ -339,7 +339,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { childLC.setWritingMode(context.getWritingMode()); List returnedList = null; - //The following is a HACK! Ignore leading and trailing white space + //The following is a HACK! Ignore leading and trailing white space boolean ignore = curLM instanceof TextLayoutManager; if (!curLM.isFinished()) { returnedList = curLM.getNextKnuthElements(childLC, alignment); @@ -356,39 +356,39 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { protected int getCurrentDisplayAlign() { return displayAlign; } - + protected boolean hasMoreContent() { return !lm.isFinished(); } - + protected void addAreas(PositionIterator posIter, LayoutContext context) { - AreaAdditionUtil.addAreas(lm, posIter, context); + AreaAdditionUtil.addAreas(lm, posIter, context); } - - protected void doPhase3(PageBreakingAlgorithm alg, int partCount, + + protected void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { if (partCount > 1) { PageBreakPosition pos = (PageBreakPosition)alg.getPageBreaks().getFirst(); int firstPartLength = ElementListUtils.calcContentLength(effectiveList, effectiveList.ignoreAtStart, pos.getLeafPos()); - overflow += alg.totalWidth - firstPartLength; - } - //Rendering all parts (not just the first) at once for the case where the parts that + overflow += alg.totalWidth - firstPartLength; + } + //Rendering all parts (not just the first) at once for the case where the parts that //overflow should be visible. alg.removeAllPageBreaks(); //Directly add areas after finding the breaks this.addAreas(alg, 1, originalList, effectiveList); } - + protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) { //nop for static content } - + protected LayoutManager getCurrentChildLM() { return null; //TODO NYI } - } - + } + /** * Returns the IPD of the content area * @return the IPD of the content area @@ -396,12 +396,12 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { public int getContentAreaIPD() { return contentAreaIPD; } - + /** {@inheritDoc} */ protected void setContentAreaIPD(int contentAreaIPD) { this.contentAreaIPD = contentAreaIPD; } - + /** * Returns the BPD of the content area * @return the BPD of the content area @@ -409,16 +409,16 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { public int getContentAreaBPD() { return contentAreaBPD; } - + private void setContentAreaBPD(int contentAreaBPD) { this.contentAreaBPD = contentAreaBPD; } - + /** {@inheritDoc} */ public int getKeepTogetherStrength() { return KEEP_AUTO; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; @@ -428,6 +428,6 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java index 63c8ac158..72fddf199 100644 --- a/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ public interface TopLevelLayoutManager { /** * Activate the layout of this page sequence. - * PageViewports corresponding to each page generated by this + * PageViewports corresponding to each page generated by this * page sequence will be created and sent to the AreaTreeModel * for rendering. */ diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java index dfc8c99f2..d1146375e 100644 --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -43,7 +43,7 @@ public class TraitSetter { /** logger */ protected static Log log = LogFactory.getLog(TraitSetter.class); - + /** * Sets border and padding traits on areas. * @param area area to set the traits on @@ -74,18 +74,18 @@ public class TraitSetter { } addBorderTrait(area, bpProps, bNotFirst, - CommonBorderPaddingBackground.START, + CommonBorderPaddingBackground.START, BorderProps.SEPARATE, Trait.BORDER_START); - addBorderTrait(area, bpProps, bNotLast, + addBorderTrait(area, bpProps, bNotLast, CommonBorderPaddingBackground.END, BorderProps.SEPARATE, Trait.BORDER_END); - addBorderTrait(area, bpProps, false, + addBorderTrait(area, bpProps, false, CommonBorderPaddingBackground.BEFORE, BorderProps.SEPARATE, Trait.BORDER_BEFORE); - addBorderTrait(area, bpProps, false, + addBorderTrait(area, bpProps, false, CommonBorderPaddingBackground.AFTER, BorderProps.SEPARATE, Trait.BORDER_AFTER); } @@ -183,7 +183,7 @@ public class TraitSetter { * @param borderAfter the resolved after border * @param borderStart the resolved start border * @param borderEnd the resolved end border - * @param outer 4 boolean values indicating if the side represents the + * @param outer 4 boolean values indicating if the side represents the * table's outer border. Order: before, after, start, end */ public static void addCollapsingBorders(Area area, @@ -208,7 +208,7 @@ public class TraitSetter { } } - private static void addPadding(Area area, CommonBorderPaddingBackground bordProps, + private static void addPadding(Area area, CommonBorderPaddingBackground bordProps, PercentBaseContext context) { addPadding(area, bordProps, false, false, false, false, context); } @@ -229,32 +229,32 @@ public class TraitSetter { boolean discardBefore, boolean discardAfter, boolean discardStart, boolean discardEnd, PercentBaseContext context) { - int padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE, + int padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE, discardBefore, context); if (padding != 0) { area.addTrait(Trait.PADDING_BEFORE, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER, + padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER, discardAfter, context); if (padding != 0) { area.addTrait(Trait.PADDING_AFTER, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.START, + padding = bordProps.getPadding(CommonBorderPaddingBackground.START, discardStart, context); if (padding != 0) { area.addTrait(Trait.PADDING_START, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.END, + padding = bordProps.getPadding(CommonBorderPaddingBackground.END, discardEnd, context); if (padding != 0) { area.addTrait(Trait.PADDING_END, new java.lang.Integer(padding)); } } - + private static BorderProps getBorderProps(CommonBorderPaddingBackground bordProps, int side) { int width = bordProps.getBorderWidth(side, false); if (width != 0) { @@ -290,17 +290,17 @@ public class TraitSetter { * background-position-horizontal/vertical to ensure the background images are * correctly placed. Indeed the placement of images must be made WRT the * column/body/row and not the cell. - * + * * <p>Note: The area's IPD and BPD must be set before calling this method.</p> - * + * * <p>TODO the regular * {@link #addBackground(Area, CommonBorderPaddingBackground, PercentBaseContext)} * method should be used instead, and a means to retrieve the original area's * dimensions must be found.</p> - * + * * <p>TODO the placement of images in the x- or y-direction will be incorrect if * background-repeat is set for that direction.</p> - * + * * @param area the area to set the traits on * @param backProps the background properties * @param context Property evaluation context @@ -311,7 +311,7 @@ public class TraitSetter { * @param referenceIPD value to use as a reference for percentage calculation * @param referenceBPD value to use as a reference for percentage calculation */ - public static void addBackground(Area area, + public static void addBackground(Area area, CommonBorderPaddingBackground backProps, PercentBaseContext context, int ipdShift, int bpdShift, int referenceIPD, int referenceBPD) { @@ -326,7 +326,7 @@ public class TraitSetter { back.setImageInfo(backProps.getImageInfo()); back.setRepeat(backProps.backgroundRepeat); if (backProps.backgroundPositionHorizontal != null) { - if (back.getRepeat() == Constants.EN_NOREPEAT + if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATY) { if (area.getIPD() > 0) { PercentBaseContext refContext = new SimplePercentBaseContext(context, @@ -344,7 +344,7 @@ public class TraitSetter { } } if (backProps.backgroundPositionVertical != null) { - if (back.getRepeat() == Constants.EN_NOREPEAT + if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATX) { if (area.getBPD() > 0) { PercentBaseContext refContext = new SimplePercentBaseContext(context, @@ -374,7 +374,7 @@ public class TraitSetter { * @param backProps the background properties * @param context Property evaluation context */ - public static void addBackground(Area area, + public static void addBackground(Area area, CommonBorderPaddingBackground backProps, PercentBaseContext context) { if (!backProps.hasBackground()) { @@ -388,14 +388,14 @@ public class TraitSetter { back.setImageInfo(backProps.getImageInfo()); back.setRepeat(backProps.backgroundRepeat); if (backProps.backgroundPositionHorizontal != null) { - if (back.getRepeat() == Constants.EN_NOREPEAT + if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATY) { if (area.getIPD() > 0) { int width = area.getIPD(); width += backProps.getPaddingStart(false, context); width += backProps.getPaddingEnd(false, context); back.setHoriz(backProps.backgroundPositionHorizontal.getValue( - new SimplePercentBaseContext(context, + new SimplePercentBaseContext(context, LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL, (width - back.getImageInfo().getSize().getWidthMpt()) ) @@ -409,14 +409,14 @@ public class TraitSetter { } } if (backProps.backgroundPositionVertical != null) { - if (back.getRepeat() == Constants.EN_NOREPEAT + if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATX) { if (area.getBPD() > 0) { int height = area.getBPD(); height += backProps.getPaddingBefore(false, context); height += backProps.getPaddingAfter(false, context); back.setVertical(backProps.backgroundPositionVertical.getValue( - new SimplePercentBaseContext(context, + new SimplePercentBaseContext(context, LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL, (height - back.getImageInfo().getSize().getHeightMpt()) ) @@ -451,7 +451,7 @@ public class TraitSetter { if (startIndent != 0) { area.addTrait(Trait.START_INDENT, new Integer(startIndent)); } - + int spaceStart = startIndent - bpProps.getBorderStartWidth(false) - bpProps.getPaddingStart(false, context); @@ -489,7 +489,7 @@ public class TraitSetter { } /** - * Returns the effective space length of a resolved space specifier based on the adjustment + * Returns the effective space length of a resolved space specifier based on the adjustment * value. * @param adjust the adjustment value * @param space the space specifier @@ -507,7 +507,7 @@ public class TraitSetter { } return sp; } - + /** * Adds traits for space-before and space-after to an area. * @param area the target area @@ -515,7 +515,7 @@ public class TraitSetter { * @param spaceBefore the space-before space specifier * @param spaceAfter the space-after space specifier */ - public static void addSpaceBeforeAfter(Area area, double adjust, + public static void addSpaceBeforeAfter(Area area, double adjust, MinOptMax spaceBefore, MinOptMax spaceAfter) { int space; space = getEffectiveSpace(adjust, spaceBefore); @@ -527,7 +527,7 @@ public class TraitSetter { area.addTrait(Trait.SPACE_AFTER, new Integer(space)); } } - + /** * Sets the traits for breaks on an area. * @param area the area to set the traits on. @@ -540,7 +540,7 @@ public class TraitSetter { area.addTrait(Trait.BREAK_BEFORE, new Integer(breakBefore)); */ } - + /** * Adds font traits to an area * @param area the target are @@ -550,7 +550,7 @@ public class TraitSetter { area.addTrait(Trait.FONT, font.getFontTriplet()); area.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize())); } - + /** * Adds the text-decoration traits to the area. * @param area the area to set the traits on @@ -576,9 +576,9 @@ public class TraitSetter { } } } - + /** - * Sets the producer's ID as a trait on the area. This can be used to track back the + * Sets the producer's ID as a trait on the area. This can be used to track back the * generating FO node. * @param area the area to set the traits on * @param id the ID to set diff --git a/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java b/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java index 2e014ef08..89baca9c6 100644 --- a/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java +++ b/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java @@ -31,10 +31,10 @@ public abstract class UnresolvedListElement extends ListElement { public UnresolvedListElement(Position position) { super(position); } - + /** @return true if the element is conditional (conditionality="discard") */ public abstract boolean isConditional(); - + /** @return the layout manager that created this ListElement */ protected LayoutManager getOriginatingLayoutManager() { Position pos = getPosition(); @@ -43,5 +43,5 @@ public abstract class UnresolvedListElement extends ListElement { } return pos.getLM(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java b/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java index f3c613202..d1b16a523 100644 --- a/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java +++ b/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java @@ -31,13 +31,13 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem /** Logger instance */ protected static Log log = LogFactory.getLog(UnresolvedListElementWithLength.class); - + private MinOptMax length; private boolean conditional; private RelSide side; private boolean isFirst; private boolean isLast; - + /** * Main constructor * @param position the Position instance needed by the addAreas stage of the LMs. @@ -47,7 +47,7 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem * @param isFirst true if this is a space-before of the first area generated. * @param isLast true if this is a space-after of the last area generated. */ - public UnresolvedListElementWithLength(Position position, MinOptMax length, + public UnresolvedListElementWithLength(Position position, MinOptMax length, RelSide side, boolean conditional, boolean isFirst, boolean isLast) { super(position); @@ -57,32 +57,32 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem this.isFirst = isFirst; this.isLast = isLast; } - + /** {@inheritDoc} */ public boolean isConditional() { return this.conditional; } - + /** @return the space as resolved MinOptMax instance */ public MinOptMax getLength() { return this.length; } - + /** @return the side this element was generated for */ public RelSide getSide() { return this.side; } - + /** @return true if this is a space-before of the first area generated. */ public boolean isFirst() { return this.isFirst; } - + /** @return true if this is a space-after of the last area generated. */ public boolean isLast() { return this.isLast; } - + /** * Called to notify the affected layout manager about the effective length after resolution. * This method is called once before each call to the layout manager's addAreas() method. @@ -90,7 +90,7 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem * zero effective length) */ public abstract void notifyLayoutManager(MinOptMax effectiveLength); - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); @@ -109,5 +109,5 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem } return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java index 76002da2f..00c628a40 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,14 +34,14 @@ import org.apache.fop.layoutmgr.TraitSetter; /** - * LayoutManager handling the common tasks for the fo:instream-foreign-object + * LayoutManager handling the common tasks for the fo:instream-foreign-object * and fo:external-graphics formatting objects */ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManager { - + /** * Constructor. - * + * * @param node * the formatting object that creates this area */ @@ -67,17 +67,17 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage Rectangle placement = imageLayout.getPlacement(); CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground(); - + //Determine extra BPD from borders and padding int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this); beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, false); - + placement.y += beforeBPD; - + //Determine extra IPD from borders and padding int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START, false, this); startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, false); - + placement.x += startIPD; Area viewportArea = getChildArea(); @@ -101,7 +101,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage return vp; } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { @@ -109,7 +109,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage setCurrentArea(areaCurrent); return super.getNextKnuthElements(context, alignment); } - + /** {@inheritDoc} */ protected AlignmentContext makeAlignmentContext(LayoutContext context) { final AbstractGraphics fobj = (AbstractGraphics)this.fobj; @@ -129,11 +129,11 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage * @return the appropriate area */ protected abstract Area getChildArea(); - + // --------- Property Resolution related functions --------- // - + /** - * {@inheritDoc} + * {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { switch (lengthBase) { diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java index c92bdb6fc..b65978453 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,10 +43,10 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa protected AbstractPageNumberCitation fobj; /** Font for the page-number-citation */ protected Font font; - + /** Indicates whether the page referred to by the citation has been resolved yet */ protected boolean resolved = false; - + /** * Constructor * @@ -57,7 +57,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa super(node); fobj = node; } - + /** {@inheritDoc} */ public void initialize() { FontInfo fi = fobj.getFOEventHandler().getFontInfo(); @@ -86,10 +86,10 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa curArea = getPageNumberCitationInlineArea(); return curArea; } - + /** * {@inheritDoc} - * , LayoutContext) + * , LayoutContext) */ public void addAreas(PositionIterator posIter, LayoutContext context) { super.addAreas(posIter, context); @@ -97,7 +97,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa getPSLM().addUnresolvedArea(fobj.getRefId(), (Resolvable) curArea); } } - + /** * If id can be resolved then simply return a word, otherwise * return a resolvable area @@ -124,12 +124,12 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa text.setIPD(width); } updateTextAreaTraits(text); - + return text; } - + /** - * Updates the traits for the generated text area. + * Updates the traits for the generated text area. * @param text the text area */ protected void updateTextAreaTraits(TextArea text) { @@ -140,7 +140,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa text.addTrait(Trait.COLOR, fobj.getColor()); TraitSetter.addTextDecoration(text, fobj.getTextDecoration()); } - + /** * @param str string to be measured * @return width (in millipoints ??) of the string diff --git a/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java b/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java index 14172a479..4eb0abd64 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,9 +47,9 @@ public class AlignmentContext implements Constants { private ScaledBaselineTable scaledBaselineTable = null; private ScaledBaselineTable actualBaselineTable = null; private AlignmentContext parentAlignmentContext = null; - + /** - * Creates a new instance of AlignmentContext + * Creates a new instance of AlignmentContext * for graphics areas. * @param height the total height of the area * @param alignmentAdjust the alignment-adjust property @@ -64,7 +64,7 @@ public class AlignmentContext implements Constants { , Length baselineShift , int dominantBaseline , AlignmentContext parentAlignmentContext) { - + this.areaHeight = height; this.lineHeight = height; this.xHeight = height; @@ -95,18 +95,18 @@ public class AlignmentContext implements Constants { break; } actualBaselineTable = ScaledBaselineTableFactory.makeGraphicsScaledBaselineTable( - height, - dominantBaselineIdentifier, + height, + dominantBaselineIdentifier, scaledBaselineTable.getWritingMode()); if (newScaledBaselineTableRequired) { scaledBaselineTable = ScaledBaselineTableFactory.makeGraphicsScaledBaselineTable( - height, - dominantBaselineIdentifier, + height, + dominantBaselineIdentifier, scaledBaselineTable.getWritingMode()); } setAlignmentAdjust(alignmentAdjust); } - + /** * Creates a new instance of AlignmentContext * @param font the font @@ -153,17 +153,17 @@ public class AlignmentContext implements Constants { dominantBaselineIdentifier = dominantBaseline; break; } - actualBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, - dominantBaselineIdentifier, + actualBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, + dominantBaselineIdentifier, scaledBaselineTable.getWritingMode()); if (newScaledBaselineTableRequired) { - scaledBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, - dominantBaselineIdentifier, + scaledBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, + dominantBaselineIdentifier, scaledBaselineTable.getWritingMode()); } setAlignmentAdjust(alignmentAdjust); } - + /** * Creates a new instance of AlignmentContext based simply * on the font and the writing mode. @@ -176,14 +176,14 @@ public class AlignmentContext implements Constants { this.lineHeight = lineHeight; this.xHeight = font.getXHeight(); this.parentAlignmentContext = null; - this.scaledBaselineTable + this.scaledBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, writingMode); this.actualBaselineTable = scaledBaselineTable; this.alignmentBaselineIdentifier = getDominantBaselineIdentifier(); this.alignmentPoint = font.getAscender(); this.baselineShiftValue = 0; } - + /** * Returns the alignment point for this context. * This is the point on the start edge of the area this context @@ -251,7 +251,7 @@ public class AlignmentContext implements Constants { int beforeEdge = actualBaselineTable.getBaseline(EN_BEFORE_EDGE); switch (alignmentAdjust.getEnum()) { case EN_AUTO: - alignmentPoint = beforeEdge + alignmentPoint = beforeEdge - actualBaselineTable.getBaseline(alignmentBaselineIdentifier); break; case EN_BASELINE: @@ -267,7 +267,7 @@ public class AlignmentContext implements Constants { case EN_ALPHABETIC: case EN_HANGING: case EN_MATHEMATICAL: - alignmentPoint = beforeEdge + alignmentPoint = beforeEdge - actualBaselineTable.getBaseline(alignmentAdjust.getEnum()); break; default: @@ -294,7 +294,7 @@ public class AlignmentContext implements Constants { public int getDominantBaselineIdentifier() { return scaledBaselineTable.getDominantBaselineIdentifier(); } - + /** * Return the writing mode. * @return the writing mode @@ -302,7 +302,7 @@ public class AlignmentContext implements Constants { public int getWritingMode() { return scaledBaselineTable.getWritingMode(); } - + /** * Calculates the baseline shift value based on the baseline-shift * property value. @@ -392,11 +392,11 @@ public class AlignmentContext implements Constants { public int getTotalAlignmentBaselineOffset(int alignmentBaselineId) { int offset = baselineShiftValue; if (parentAlignmentContext != null) { - offset = parentAlignmentContext.getTotalBaselineOffset() + offset = parentAlignmentContext.getTotalBaselineOffset() + parentAlignmentContext.getScaledBaselineTable() .getBaseline(alignmentBaselineId) + baselineShiftValue; - } + } return offset; } @@ -432,7 +432,7 @@ public class AlignmentContext implements Constants { public int getHeight() { return areaHeight; } - + /** * Return the line height of the context. * @return the height @@ -440,7 +440,7 @@ public class AlignmentContext implements Constants { public int getLineHeight() { return lineHeight; } - + /** * The altitude of the context that is the height above the * alignment point. @@ -458,7 +458,7 @@ public class AlignmentContext implements Constants { public int getDepth() { return getHeight() - alignmentPoint; } - + /** * The x height of the context. * @return the x height @@ -466,7 +466,7 @@ public class AlignmentContext implements Constants { public int getXHeight() { return this.xHeight; } - + /** * Resizes the line as specified. Assumes that the new alignment point * is on the dominant baseline, that is this function should be called for @@ -480,7 +480,7 @@ public class AlignmentContext implements Constants { scaledBaselineTable.setBeforeAndAfterBaselines(alignmentPoint , alignmentPoint - areaHeight); } - + /** * Returns the offset from the before-edge of the parent to * this context. @@ -495,7 +495,7 @@ public class AlignmentContext implements Constants { } return offset; } - + /** * Returns an indication if we still use the initial baseline table. * The initial baseline table is the table generated by the Line LM. @@ -506,11 +506,11 @@ public class AlignmentContext implements Constants { || (scaledBaselineTable == parentAlignmentContext.getScaledBaselineTable() && parentAlignmentContext.usesInitialBaselineTable()); } - + private boolean isHorizontalWritingMode() { return (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB); } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(64); @@ -521,5 +521,5 @@ public class AlignmentContext implements Constants { sb.append(" bs=" + baselineShiftValue); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java index b8979e187..c369df82b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java b/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java index 606500a56..73f414bf7 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,12 +44,12 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants private int dominantBaselineOffset; private int beforeEdgeOffset; private int afterEdgeOffset; - + private static final float HANGING_BASELINE_FACTOR = 0.8f; private static final float MATHEMATICAL_BASELINE_FACTOR = 0.5f; /** - * + * * Creates a new instance of BasicScaledBaselineTable for the given * altitude, depth, xHeight, baseline and writingmode. * @param altitude the height of the box or the font ascender @@ -72,7 +72,7 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants this.beforeEdgeOffset = altitude - dominantBaselineOffset; this.afterEdgeOffset = depth - dominantBaselineOffset; } - + /** * Return the dominant baseline for this baseline table. * @return the dominant baseline @@ -80,7 +80,7 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants public int getDominantBaselineIdentifier() { return this.dominantBaselineIdentifier; } - + /** * Return the writing mode for this baseline table. * @return the writing mode @@ -132,11 +132,11 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants } return offset; } - + private boolean isHorizontalWritingMode() { return writingMode == EN_LR_TB || writingMode == EN_RL_TB; } - + /** * Return the baseline offset measured from the font's default * baseline for the given baseline. @@ -171,9 +171,9 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants } return offset; } - + /** - * {@inheritDoc} + * {@inheritDoc} */ public void setBeforeAndAfterBaselines(int beforeBaseline, int afterBaseline) { beforeEdgeOffset = beforeBaseline; @@ -184,7 +184,7 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants * {@inheritDoc} */ public ScaledBaselineTable deriveScaledBaselineTable(int baselineIdentifier) { - BasicScaledBaselineTable bac + BasicScaledBaselineTable bac = new BasicScaledBaselineTable(altitude, depth, xHeight , baselineIdentifier, this.writingMode); return bac; diff --git a/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java index f82cd7f41..d5b2e5803 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java index c81a23a9c..383ca0105 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -57,10 +57,10 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { public CharacterLayoutManager(Character node) { super(node); } - + /** {@inheritDoc} */ public void initialize() { - Character fobj = (Character)this.fobj; + Character fobj = (Character)this.fobj; font = FontSelector.selectFontForCharacter(fobj, this); SpaceVal ls = SpaceVal.makeLetterSpacing(fobj.getLetterSpacing()); letterSpaceIPD = ls.getSpace(); @@ -101,7 +101,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { } Character fobj = (Character)this.fobj; - + ipd = new MinOptMax(font.getCharWidth(fobj.getCharacter())); curArea.setIPD(ipd.opt); @@ -120,7 +120,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { , context.getAlignmentContext()); addKnuthElementsForBorderPaddingStart(seq); - + // create the AreaInfo object to store the computed values areaInfo = new AreaInfo((short) 0, ipd, false, alignmentContext); diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java index b43c4c841..a5247d652 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -176,7 +176,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager return holder; } - /** + /** * {@inheritDoc} **/ public void addChildArea(Area childArea) { @@ -315,13 +315,13 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager int alignment) { return null; } - + public PageSequenceLayoutManager getPSLM() { return parentLM.getPSLM(); } // --------- Property Resolution related functions --------- // - + /** * Returns the IPD of the content area * @return the IPD of the content area @@ -329,7 +329,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager public int getContentAreaIPD() { return holder.getIPD(); } - + /** * Returns the BPD of the content area * @return the BPD of the content area @@ -337,7 +337,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager public int getContentAreaBPD() { return holder.getBPD(); } - + /** * {@inheritDoc} */ @@ -351,7 +351,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager public boolean getGeneratesBlockArea() { return getGeneratesLineArea() || holder instanceof Block; } - + /** * {@inheritDoc} */ @@ -365,6 +365,6 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager public Position notifyPos(Position pos) { return pos; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java index d7bff5a5c..2719d5c96 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,10 +28,10 @@ import org.apache.fop.fo.flow.ExternalGraphic; * LayoutManager for the fo:external-graphic formatting object */ public class ExternalGraphicLayoutManager extends AbstractGraphicsLayoutManager { - + /** * Constructor. - * + * * @param node * the fo:external-graphic formatting object that creates the * area @@ -44,6 +44,6 @@ public class ExternalGraphicLayoutManager extends AbstractGraphicsLayoutManager protected Area getChildArea() { return new Image(((ExternalGraphic) fobj).getSrc()); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java index a02cfee89..2cdc7a6fc 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -60,7 +60,7 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager { super(node); footnote = node; } - + /** {@inheritDoc} */ public void initialize() { // create an InlineStackingLM handling the fo:inline child of fo:footnote @@ -120,7 +120,7 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager { } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { @@ -131,7 +131,7 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager { /** - * {@inheritDoc} + * {@inheritDoc} */ public void addAreas(PositionIterator posIter, LayoutContext context) { // "Unwrap" the NonLeafPositions stored in posIter and put @@ -144,11 +144,11 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager { positionList.add(pos.getPosition()); } } - - // FootnoteLM does not create any area, + + // FootnoteLM does not create any area, // so the citationLM child will add directly to the FootnoteLM parent area citationLM.setParent(getParent()); - + // make the citationLM add its areas LayoutContext childContext = new LayoutContext(context); StackingIter childPosIter = new StackingIter(positionList.listIterator()); diff --git a/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java b/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java index 3c438ee7e..881608e08 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java +++ b/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr.inline; /** diff --git a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java index 7ca9e0d5e..c47a7e682 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java index 9f9339f44..bacf43dbc 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,10 +35,10 @@ import org.apache.fop.fo.properties.LengthRangeProperty; * Helper class which calculates the size and position in the viewport of an image. */ public class ImageLayout implements Constants { - + /** logging instance */ protected static Log log = LogFactory.getLog(ImageLayout.class); - + //Input private GraphicsProperties props; private PercentBaseContext percentBaseContext; @@ -48,7 +48,7 @@ public class ImageLayout implements Constants { private Rectangle placement; private Dimension viewportSize = new Dimension(-1, -1); private boolean clip; - + /** * Main constructor * @param props the properties for the image @@ -60,7 +60,7 @@ public class ImageLayout implements Constants { this.props = props; this.percentBaseContext = percentBaseContext; this.intrinsicSize = intrinsicSize; - + doLayout(); } @@ -72,7 +72,7 @@ public class ImageLayout implements Constants { int bpd = -1; int ipd = -1; - + len = props.getBlockProgressionDimension().getOptimum(percentBaseContext).getLength(); if (len.getEnum() != EN_AUTO) { bpd = len.getValue(percentBaseContext); @@ -155,7 +155,7 @@ public class ImageLayout implements Constants { } else { constrainedIntrinsicSize = intrinsicSize; } - + //Derive content extents where not explicit Dimension adjustedDim = adjustContentSize(cwidth, cheight, constrainedIntrinsicSize); cwidth = adjustedDim.width; @@ -190,10 +190,10 @@ public class ImageLayout implements Constants { this.viewportSize.setSize(ipd, bpd); this.placement = new Rectangle(xoffset, yoffset, cwidth, cheight); } - + private int constrainExtent(int extent, LengthRangeProperty range, Length contextExtent) { - boolean mayScaleUp = (contextExtent.getEnum() != EN_SCALE_DOWN_TO_FIT); - boolean mayScaleDown = (contextExtent.getEnum() != EN_SCALE_UP_TO_FIT); + boolean mayScaleUp = (contextExtent.getEnum() != EN_SCALE_DOWN_TO_FIT); + boolean mayScaleDown = (contextExtent.getEnum() != EN_SCALE_UP_TO_FIT); Length len; len = range.getMaximum(percentBaseContext).getLength(); if (len.getEnum() != EN_AUTO) { @@ -211,7 +211,7 @@ public class ImageLayout implements Constants { } return extent; } - + private Dimension constrain(Dimension size) { Dimension adjusted = new Dimension(size); int effWidth = constrainExtent(size.width, @@ -235,7 +235,7 @@ public class ImageLayout implements Constants { } return adjusted; } - + private Dimension adjustContentSize( final int cwidth, final int cheight, Dimension defaultSize) { @@ -249,14 +249,14 @@ public class ImageLayout implements Constants { if (defaultSize.height == 0) { dim.width = 0; } else { - dim.width = (int)(defaultSize.width * (double)cheight + dim.width = (int)(defaultSize.width * (double)cheight / defaultSize.height); } } else if (cheight == -1) { if (defaultSize.width == 0) { dim.height = 0; } else { - dim.height = (int)(defaultSize.height * (double)cwidth + dim.height = (int)(defaultSize.height * (double)cwidth / defaultSize.width); } } else { @@ -278,7 +278,7 @@ public class ImageLayout implements Constants { } return dim; } - + /** * Given the ipd and the content width calculates the * required x offset based on the text-align property @@ -336,7 +336,7 @@ public class ImageLayout implements Constants { public Rectangle getPlacement() { return this.placement; } - + /** * Returns the size of the image's viewport. * @return the viewport size (in millipoints) @@ -344,7 +344,7 @@ public class ImageLayout implements Constants { public Dimension getViewportSize() { return this.viewportSize; } - + /** * Returns the size of the image's intrinsic (natural) size. * @return the intrinsic size (in millipoints) @@ -352,7 +352,7 @@ public class ImageLayout implements Constants { public Dimension getIntrinsicSize() { return this.intrinsicSize; } - + /** * Indicates whether the image is clipped. * @return true if the image shall be clipped @@ -360,5 +360,5 @@ public class ImageLayout implements Constants { public boolean isClipped() { return this.clip; } - + }
\ No newline at end of file diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java index 589fb2645..0c332281f 100755 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -92,7 +92,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { protected SpaceProperty lineHeight; /** The keep-together property */ //private KeepProperty keepTogether; - + private AlignmentContext alignmentContext = null; /** @@ -106,26 +106,26 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { public InlineLayoutManager(InlineLevel node) { super(node); } - + private Inline getInlineFO() { return (Inline) fobj; } - + /** {@inheritDoc} */ public void initialize() { InlineLevel fobj = (InlineLevel) this.fobj; int padding = 0; - + FontInfo fi = fobj.getFOEventHandler().getFontInfo(); CommonFont commonFont = fobj.getCommonFont(); FontTriplet[] fontkeys = commonFont.getFontState(fi); font = fi.getFontInstance(fontkeys[0], commonFont.fontSize.getValue(this)); - + lineHeight = fobj.getLineHeight(); borderProps = fobj.getCommonBorderPaddingBackground(); inlineProps = fobj.getCommonMarginInline(); - + if (fobj instanceof Inline) { alignmentAdjust = ((Inline)fobj).getAlignmentAdjust(); alignmentBaseline = ((Inline)fobj).getAlignmentBaseline(); @@ -152,13 +152,13 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) { int borderAndPadding = 0; if (borderProps != null) { - borderAndPadding + borderAndPadding = borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this); - borderAndPadding + borderAndPadding += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, isNotFirst); - borderAndPadding + borderAndPadding += borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this); - borderAndPadding + borderAndPadding += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast); } return new MinOptMax(borderAndPadding); @@ -189,11 +189,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { protected SpaceProperty getSpaceEnd() { return inlineProps != null ? inlineProps.spaceEnd : null; } - - /** - * Create and initialize an <code>InlineArea</code> - * - * @param hasInlineParent true if the parent is an inline + + /** + * Create and initialize an <code>InlineArea</code> + * + * @param hasInlineParent true if the parent is an inline * @return the area */ protected InlineArea createArea(boolean hasInlineParent) { @@ -209,7 +209,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { } return area; } - + /** {@inheritDoc} */ protected void setTraits(boolean isNotFirst, boolean isNotLast) { if (borderProps != null) { @@ -232,7 +232,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { return ((BlockLevelLayoutManager) lm).mustKeepTogether(); } else if (lm instanceof InlineLayoutManager) { return ((InlineLayoutManager) lm).mustKeepTogether(); - } else { + } else { return mustKeepTogether(lm.getParent()); } } @@ -249,12 +249,12 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { KnuthSequence lastSequence = null; SpaceSpecifier leadingSpace = context.getLeadingSpace(); - + if (fobj instanceof Title) { alignmentContext = new AlignmentContext(font, lineHeight.getOptimum(this).getLength().getValue(this), context.getWritingMode()); - + } else { alignmentContext = new AlignmentContext(font , lineHeight.getOptimum(this).getLength().getValue(this) @@ -264,7 +264,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { , dominantBaseline , context.getAlignmentContext()); } - + childLC = new LayoutContext(context); childLC.setAlignmentContext(alignmentContext); @@ -300,9 +300,9 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { + borderProps.getBorderEndWidth(true) ); } - + while ((curLM = getChildLM()) != null) { - + if (!(curLM instanceof InlineLevelLayoutManager)) { // A block LM // Leave room for start/end border and padding @@ -314,7 +314,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { - borderProps.getBorderEndWidth(hasNextChildLM())); } } - + // get KnuthElements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); if (returnList.isEmpty() && childLC.isKeepWithPreviousPending()) { @@ -326,7 +326,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { // just iterate once more to see if there is another child continue; } - + if (curLM instanceof InlineLevelLayoutManager) { context.clearKeepWithNextPending(); // "wrap" the Position stored in each element of returnedList @@ -375,31 +375,31 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { lastSequence = (KnuthSequence) ListUtil.getLast(returnList); lastChildLM = curLM; } - + if (lastSequence != null) { addKnuthElementsForBorderPaddingEnd(lastSequence); } setFinished(true); log.trace(trace); - + if (returnList.isEmpty()) { /* - * if the FO itself is empty, but has an id specified + * if the FO itself is empty, but has an id specified * or associated fo:markers, then we still need a dummy * sequence to register its position in the area tree */ if (fobj.hasId() || fobj.hasMarkers()) { InlineKnuthSequence emptySeq = new InlineKnuthSequence(); emptySeq.add(new KnuthInlineBox( - 0, - alignmentContext, - notifyPos(getAuxiliaryPosition()), + 0, + alignmentContext, + notifyPos(getAuxiliaryPosition()), true)); returnList.add(emptySeq); } } - + return returnList.isEmpty() ? null : returnList; } @@ -414,7 +414,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { */ public void addAreas(PositionIterator parentIter, LayoutContext context) { - + addId(); setChildContext(new LayoutContext(context)); // Store current value @@ -454,11 +454,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { }*/ addMarkersToPage( - true, - !areaCreated, + true, + !areaCreated, lastPos == null || isLast(lastPos)); - - InlineArea parent = createArea(lastLM == null + + InlineArea parent = createArea(lastLM == null || lastLM instanceof InlineLevelLayoutManager); parent.setBPD(alignmentContext.getHeight()); if (parent instanceof InlineParent) { @@ -472,7 +472,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { } } setCurrentArea(parent); - + StackingIter childPosIter = new StackingIter(positionList.listIterator()); @@ -487,7 +487,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { prevLM = childLM; } - + /* If this LM has a trailing fence, resolve trailing space * specs from descendants. Otherwise, propagate any trailing * space specs to the parent LM via the layout context. If @@ -496,7 +496,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { * must be the last area for the current LM too. */ boolean isLast = (getContext().isLastArea() && prevLM == lastChildLM); - + if (hasTrailingFence(isLast)) { addSpace(getCurrentArea(), getContext().getTrailingSpace().resolve(false), @@ -510,17 +510,17 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { if (context.getTrailingSpace() != null && getSpaceEnd() != null) { context.getTrailingSpace().addSpace(new SpaceVal(getSpaceEnd(), this)); } - + // Not sure if lastPos can legally be null or if that masks a different problem. // But it seems to fix bug 38053. setTraits(areaCreated, lastPos == null || !isLast(lastPos)); parentLM.addChildArea(getCurrentArea()); addMarkersToPage( - false, - !areaCreated, + false, + !areaCreated, lastPos == null || isLast(lastPos)); - + context.setFlags(LayoutContext.LAST_AREA, isLast); areaCreated = true; checkEndOfLayout(lastPos); @@ -545,7 +545,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { addKnuthElementsForBorderPaddingEnd(returnedList); return returnedList; } - + /** * Creates Knuth elements for start border padding and adds them to the return list. * @param returnList return list to add the additional elements to @@ -604,5 +604,5 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { //} return this.auxiliaryPosition; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java index 51d2720cb..c9c65e769 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java @@ -33,7 +33,7 @@ public interface InlineLevelEventProducer extends EventProducer { * Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -52,7 +52,7 @@ public interface InlineLevelEventProducer extends EventProducer { * @event.severity ERROR */ void leaderWithoutContent(Object source, Locator loc); - + /** * A line overflows. * @param source the event source @@ -62,5 +62,5 @@ public interface InlineLevelEventProducer extends EventProducer { * @event.severity WARN */ void lineOverflows(Object source, int line, int overflowLength, Locator loc); - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java index 80a74ffc4..b080f926b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr.inline; import java.util.List; @@ -30,7 +30,7 @@ import org.apache.fop.layoutmgr.Position; public interface InlineLevelLayoutManager extends LayoutManager { /** - * Tell the LM to modify its data, adding a letter space + * Tell the LM to modify its data, adding a letter space * to the word fragment represented by the given elements, * and returning the corrected elements * @@ -40,7 +40,7 @@ public interface InlineLevelLayoutManager extends LayoutManager { List addALetterSpaceTo(List oldList); /** - * Tell the LM to modify its data, removing the word space + * Tell the LM to modify its data, removing the word space * represented by the given elements * * @param oldList the elements representing the word space diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java index 81fc7901d..a27fc6516 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,7 +43,7 @@ import org.apache.fop.traits.MinOptMax; * which stack children in the inline direction, such as Inline or * Line. It should not be instantiated directly. */ -public abstract class InlineStackingLayoutManager extends AbstractLayoutManager +public abstract class InlineStackingLayoutManager extends AbstractLayoutManager implements InlineLevelLayoutManager { @@ -103,7 +103,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager } /** - * Returns the extra IPD needed for any leading or trailing fences for the + * Returns the extra IPD needed for any leading or trailing fences for the * current area. * @param bNotFirst true if not the first area for this layout manager * @param bNotLast true if not the last area for this layout manager @@ -139,7 +139,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager protected SpaceProperty getSpaceStart() { return null; } - + /** * Get the space at the end of the inline area. * @return the space property describing the space @@ -246,7 +246,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager // The last element may not have a layout manager (its position == null); // this may happen if it is a padding box; see bug 39571. - InlineLevelLayoutManager LM = + InlineLevelLayoutManager LM = (InlineLevelLayoutManager) element.getLayoutManager(); if (LM != null) { oldList = LM.addALetterSpaceTo(oldList); @@ -362,7 +362,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { // "unwrap" the Positions stored in the elements diff --git a/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java b/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java index 5f9365f83..4a54f582d 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,10 +28,10 @@ import org.apache.fop.fo.flow.InstreamForeignObject; * LayoutManager for the fo:instream-foreign-object formatting object */ public class InstreamForeignObjectLM extends AbstractGraphicsLayoutManager { - + /** * Constructor. - * + * * @param node * the formatting object that creates this area */ @@ -48,6 +48,6 @@ public class InstreamForeignObjectLM extends AbstractGraphicsLayoutManager { return new ForeignObject(doc, ns); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java b/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java index 856fab051..6c8c7354b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java +++ b/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.Position; public class KnuthInlineBox extends KnuthBox { - + private FootnoteBodyLayoutManager footnoteBodyLM = null; private AlignmentContext alignmentContext = null; @@ -69,8 +69,8 @@ public class KnuthInlineBox extends KnuthBox { public boolean isAnchor() { return (footnoteBodyLM != null); } - - + + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(super.toString()); diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index 3bb82aa11..1e163bef8 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,10 +51,10 @@ import org.apache.fop.traits.MinOptMax; public class LeaderLayoutManager extends LeafNodeLayoutManager { private Leader fobj; private Font font = null; - + private List contentList = null; private ContentLayoutManager clm = null; - + private int contentAreaIPD = 0; /** @@ -66,7 +66,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { super(node); fobj = node; } - + /** {@inheritDoc} */ public void initialize() { FontInfo fi = fobj.getFOEventHandler().getFontInfo(); @@ -117,7 +117,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { if (fobj.getLeaderPattern() == EN_RULE) { if (fobj.getRuleStyle() != EN_NONE) { - org.apache.fop.area.inline.Leader leader + org.apache.fop.area.inline.Leader leader = new org.apache.fop.area.inline.Leader(); leader.setRuleStyle(fobj.getRuleStyle()); leader.setRuleThickness(fobj.getRuleThickness().getValue(this)); @@ -167,7 +167,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { // child FOs are assigned to the InlineStackingLM fobjIter = null; - + // get breaks then add areas to FilledArea FilledArea fa = new FilledArea(); @@ -262,7 +262,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { curArea.setAdjustingInfo(ipd.max - ipd.opt, ipd.opt - ipd.min, 0); addKnuthElementsForBorderPaddingStart(seq); - + // node is a fo:Leader seq.add(new KnuthInlineBox(0, alignmentContext, new LeafPosition(this, -1), true)); @@ -272,20 +272,20 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { seq.add (new KnuthGlue(areaInfo.ipdArea.opt, areaInfo.ipdArea.max - areaInfo.ipdArea.opt, - areaInfo.ipdArea.opt - areaInfo.ipdArea.min, + areaInfo.ipdArea.opt - areaInfo.ipdArea.min, new LeafPosition(this, 0), false)); } else { seq.add (new KnuthGlue(areaInfo.ipdArea.opt, 0, - 0, + 0, new LeafPosition(this, 0), false)); } seq.add(new KnuthInlineBox(0, alignmentContext, new LeafPosition(this, -1), true)); addKnuthElementsForBorderPaddingEnd(seq); - + LinkedList returnList = new LinkedList(); returnList.add(seq); setFinished(true); @@ -314,7 +314,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { List returnList = new LinkedList(); addKnuthElementsForBorderPaddingStart(returnList); - + returnList.add(new KnuthInlineBox(0, areaInfo.alignmentContext, new LeafPosition(this, -1), true)); returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, @@ -323,20 +323,20 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { returnList.add (new KnuthGlue(areaInfo.ipdArea.opt, areaInfo.ipdArea.max - areaInfo.ipdArea.opt, - areaInfo.ipdArea.opt - areaInfo.ipdArea.min, + areaInfo.ipdArea.opt - areaInfo.ipdArea.min, new LeafPosition(this, 0), false)); } else { returnList.add (new KnuthGlue(areaInfo.ipdArea.opt, 0, - 0, + 0, new LeafPosition(this, 0), false)); } returnList.add(new KnuthInlineBox(0, areaInfo.alignmentContext, new LeafPosition(this, -1), true)); addKnuthElementsForBorderPaddingEnd(returnList); - + setFinished(true); return returnList; } @@ -353,9 +353,9 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { public int getContentAreaIPD() { return contentAreaIPD; } - + private void setContentAreaIPD(int contentAreaIPD) { this.contentAreaIPD = contentAreaIPD; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java index 19a8cdf2d..ac501abb7 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -48,7 +48,7 @@ import org.apache.fop.traits.MinOptMax; * This class can be extended to handle the creation and adding of the * inline area. */ -public abstract class LeafNodeLayoutManager extends AbstractLayoutManager +public abstract class LeafNodeLayoutManager extends AbstractLayoutManager implements InlineLevelLayoutManager { /** @@ -64,7 +64,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager protected CommonBorderPaddingBackground commonBorderPaddingBackground = null; /** The alignment context applying to this area */ protected AlignmentContext alignmentContext = null; - + /** Flag to indicate if something was changed as part of the getChangeKnuthElements sequence */ protected boolean isSomethingChanged = false; /** Our area info for the Knuth elements */ @@ -86,7 +86,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager bHyphenated = bHyph; this.alignmentContext = alignmentContext; } - + } @@ -201,7 +201,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager protected InlineArea getEffectiveArea() { return curArea; } - + /** * Offset this area. * Offset the inline area in the bpd direction when adding the @@ -247,18 +247,18 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager area.setIPD(width); area.setAdjustment(width - areaInfo.ipdArea.opt); } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { curArea = get(context); - + if (curArea == null) { setFinished(true); return null; } alignmentContext = makeAlignmentContext(context); - + MinOptMax ipd = getAllocationIPD(context.getRefIPD()); // create the AreaInfo object to store the computed values @@ -269,12 +269,12 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager KnuthSequence seq = new InlineKnuthSequence(); addKnuthElementsForBorderPaddingStart(seq); - + seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, alignmentContext, notifyPos(new LeafPosition(this, 0)), false)); addKnuthElementsForBorderPaddingEnd(seq); - + LinkedList returnList = new LinkedList(); returnList.add(seq); @@ -322,18 +322,18 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager LinkedList returnList = new LinkedList(); addKnuthElementsForBorderPaddingStart(returnList); - + // fobj is a fo:ExternalGraphic, fo:InstreamForeignObject, // fo:PageNumber or fo:PageNumberCitation - returnList.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext, + returnList.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext, notifyPos(new LeafPosition(this, 0)), true)); addKnuthElementsForBorderPaddingEnd(returnList); - + setFinished(true); return returnList; } - + /** * Creates Knuth elements for start border padding and adds them to the return list. * @param returnList return list to add the additional elements to @@ -345,7 +345,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager + commonBorderPaddingBackground.getPaddingStart(false, this); if (ipStart > 0) { // Add a non breakable glue - returnList.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, + returnList.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, new LeafPosition(this, -1), true)); returnList.add(new KnuthGlue(ipStart, 0, 0, new LeafPosition(this, -1), true)); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 87077ee77..3a0672f4e 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -75,7 +75,7 @@ import org.apache.fop.traits.MinOptMax; * creates a line area to contain the inline areas added by the * child layout managers. */ -public class LineLayoutManager extends InlineStackingLayoutManager +public class LineLayoutManager extends InlineStackingLayoutManager implements BlockLevelLayoutManager { /** @@ -85,7 +85,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager private Block fobj; private boolean isFirstInBlock; - + /** {@inheritDoc} */ public void initialize() { textAlignment = fobj.getTextAlign(); @@ -108,7 +108,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager return textAlignment; } } - + /** * Private class to store information about inline breaks. * Each value holds the start and end indexes into a List of @@ -148,7 +148,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager spaceAfter = sa; baseline = bl; } - + } @@ -181,7 +181,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager /** * this constant is used to create elements when text-align is center: - * every TextLM descendant of LineLM must use the same value, + * every TextLM descendant of LineLM must use the same value, * otherwise the line breaking algorithm does not find the right * break point */ @@ -205,7 +205,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // this class represents a paragraph private class Paragraph extends InlineKnuthSequence { - /** Number of elements to ignore at the beginning of the list. */ + /** Number of elements to ignore at the beginning of the list. */ private int ignoreAtStart = 0; /** Number of elements to ignore at the end of the list. */ private int ignoreAtEnd = 0; @@ -233,11 +233,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager // set the minimum amount of empty space at the end of the // last line if (textAlignment == EN_CENTER) { - lineFiller = new MinOptMax(lastLineEndIndent); + lineFiller = new MinOptMax(lastLineEndIndent); } else { - lineFiller = new MinOptMax(lastLineEndIndent, - lastLineEndIndent, - layoutManager.iLineWidth); + lineFiller = new MinOptMax(lastLineEndIndent, + lastLineEndIndent, + layoutManager.iLineWidth); } // add auxiliary elements at the beginning of the paragraph @@ -251,7 +251,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // at the beginning of the first paragraph if (isFirstInBlock && knuthParagraphs.size() == 0 && textIndent != 0) { - this.add(new KnuthInlineBox(textIndent, null, + this.add(new KnuthInlineBox(textIndent, null, null, false)); ignoreAtStart++; } @@ -277,10 +277,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager // add the elements representing the space // at the end of the last line // and the forced break - this.add(new KnuthPenalty(0, KnuthElement.INFINITE, + this.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false)); - this.add(new KnuthGlue(0, - lineFiller.max - lineFiller.opt, + this.add(new KnuthGlue(0, + lineFiller.max - lineFiller.opt, lineFiller.opt - lineFiller.min, null, false)); this.add(new KnuthPenalty(lineFiller.opt, -KnuthElement.INFINITE, false, null, false)); @@ -339,7 +339,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager follow = fl; thisLLM = llm; activePossibility = -1; - maxDiff = fobj.getWidows() >= fobj.getOrphans() + maxDiff = fobj.getWidows() >= fobj.getOrphans() ? fobj.getWidows() : fobj.getOrphans(); } @@ -382,7 +382,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } if (log.isWarnEnabled()) { - int lack = difference + bestActiveNode.availableShrink; + int lack = difference + bestActiveNode.availableShrink; if (lack < 0) { InlineLevelEventProducer eventProducer = InlineLevelEventProducer.Provider.get( @@ -391,15 +391,15 @@ public class LineLayoutManager extends InlineStackingLayoutManager -lack, getFObj().getLocator()); } } - - //log.debug("LLM> (" + (lineLayouts.getLineNumber(activePossibility) - addedPositions) + + //log.debug("LLM> (" + (lineLayouts.getLineNumber(activePossibility) - addedPositions) // + ") difference = " + difference + " ratio = " + ratio); lineLayouts.addBreakPosition(makeLineBreakPosition(par, (bestActiveNode.line > 1 ? bestActiveNode.previous.position + 1 : 0), bestActiveNode.position, - bestActiveNode.availableShrink - (addedPositions > 0 - ? 0 : ((Paragraph)par).lineFiller.opt - ((Paragraph)par).lineFiller.min), - bestActiveNode.availableStretch, + bestActiveNode.availableShrink - (addedPositions > 0 + ? 0 : ((Paragraph)par).lineFiller.opt - ((Paragraph)par).lineFiller.min), + bestActiveNode.availableStretch, difference, ratio, indent), activePossibility); addedPositions++; } @@ -413,8 +413,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager private LineBreakPosition makeLineBreakPosition(KnuthSequence par, int firstElementIndex, int lastElementIndex, - int availableShrink, - int availableStretch, + int availableShrink, + int availableStretch, int difference, double ratio, int indent) { @@ -424,7 +424,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager int spaceAfter = lineHeight - lead - follow - spaceBefore; // height before the main baseline int lineLead = lead; - // maximum follow + // maximum follow int lineFollow = follow; // true if this line contains only zero-height, auxiliary boxes // and the actual line width is 0; in this case, the line "collapses" @@ -492,7 +492,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager firstElementIndex, lastElementIndex, availableShrink, availableStretch, difference, ratio, 0, indent, - lineLead + lineFollow, + lineLead + lineFollow, iLineWidth, spaceBefore, spaceAfter, lineLead); } @@ -501,7 +501,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager public int findBreakingPoints(Paragraph par, /*int lineWidth,*/ double threshold, boolean force, int allowedBreaks) { - return super.findBreakingPoints(par, /*lineWidth,*/ + return super.findBreakingPoints(par, /*lineWidth,*/ threshold, force, allowedBreaks); } @@ -548,9 +548,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } - + private int constantLineHeight = 12000; - + /** * Create a new Line Layout Manager. @@ -641,19 +641,19 @@ public class LineLayoutManager extends InlineStackingLayoutManager */ private void collectInlineKnuthElements(LayoutContext context) { LayoutContext inlineLC = new LayoutContext(context); - + InlineLevelLayoutManager curLM; List returnedList = null; iLineWidth = context.getStackLimitIP().opt; - + // convert all the text in a sequence of paragraphs made // of KnuthBox, KnuthGlue and KnuthPenalty objects boolean bPrevWasKnuthBox = false; - + StringBuffer trace = new StringBuffer("LineLM:"); - + Paragraph lastPar = null; - + while ((curLM = (InlineLevelLayoutManager) getChildLM()) != null) { returnedList = curLM.getNextKnuthElements(inlineLC, effectiveAlignment); if (returnedList == null @@ -663,10 +663,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager * so just iterate once more to see if there are other children */ continue; } - + if (lastPar != null) { KnuthSequence firstSeq = (KnuthSequence) returnedList.get(0); - + // finish last paragraph before a new block sequence if (!firstSeq.isInlineSequence()) { lastPar.endParagraph(); @@ -677,7 +677,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } bPrevWasKnuthBox = false; } - + // does the first element of the first paragraph add to an existing word? if (lastPar != null) { KnuthElement thisElement; @@ -688,28 +688,28 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } } - + // loop over the KnuthSequences (and single KnuthElements) in returnedList ListIterator iter = returnedList.listIterator(); while (iter.hasNext()) { KnuthSequence sequence = (KnuthSequence) iter.next(); // the sequence contains inline Knuth elements if (sequence.isInlineSequence()) { - // look at the last element + // look at the last element ListElement lastElement = sequence.getLast(); if (lastElement == null) { throw new NullPointerException( "Sequence was empty! lastElement is null"); } - bPrevWasKnuthBox = lastElement.isBox() - && !((KnuthElement) lastElement).isAuxiliary() + bPrevWasKnuthBox = lastElement.isBox() + && !((KnuthElement) lastElement).isAuxiliary() && ((KnuthElement) lastElement).getW() != 0; - + // if last paragraph is open, add the new elements to the paragraph // else this is the last paragraph - if (lastPar == null) { - lastPar = new Paragraph(this, - textAlignment, textAlignmentLast, + if (lastPar == null) { + lastPar = new Paragraph(this, + textAlignment, textAlignmentLast, textIndent.getValue(this), lastLineEndIndent.getValue(this)); lastPar.startSequence(); @@ -725,7 +725,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager if (log.isTraceEnabled()) { trace.append(" I"); } - + // finish last paragraph if it was closed with a linefeed if (lastElement.isPenalty() && ((KnuthPenalty) lastElement).getP() @@ -735,7 +735,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // which forces a line break lastPar.removeLast(); if (!lastPar.containsBox()) { - //only a forced linefeed on this line + //only a forced linefeed on this line //-> compensate with an auxiliary glue lastPar.add(new KnuthGlue(iLineWidth, 0, iLineWidth, null, true)); } @@ -765,11 +765,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager } log.trace(trace); } - + /** * Find a set of breaking points. - * This method is called only once by getNextBreakPoss, and it - * subsequently calls the other findBreakingPoints() method with + * This method is called only once by getNextBreakPoss, and it + * subsequently calls the other findBreakingPoints() method with * different parameters, until a set of breaking points is found. * * @param par the list of elements that must be parted @@ -805,7 +805,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } } - + private boolean findBreakingPoints(Paragraph par, int lineWidth, double threshold, boolean force) { KnuthParagraph knuthPara = new KnuthParagraph(par); @@ -813,11 +813,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager if (lines == 0) { return false; } - + for (int i = lines-1; i >= 0; i--) { int line = i+1; if (log.isTraceEnabled()) { - log.trace("Making line from " + knuthPara.getStart(i) + " to " + + log.trace("Making line from " + knuthPara.getStart(i) + " to " + knuthPara.getEnd(i)); } // compute indent and adjustment ratio, according to @@ -826,7 +826,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager int difference = knuthPara.getDifference(i); if (line == lines) { difference += par.lineFillerWidth; - } + } int textAlign = (line < lines) ? textAlignment : textAlignmentLast; int indent = (textAlign == EN_CENTER) @@ -841,7 +841,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager int end = knuthPara.getEnd(i); makeLineBreakPosition(par, start, end, 0, ratio, indent); } - return true; + return true; } private void makeLineBreakPosition(Paragraph par, @@ -893,7 +893,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineLead)); }*/ - + /** * Phase 2 of Knuth algorithm: find optimal break points. * @param alignment alignment in BP direction of the paragraph @@ -918,9 +918,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager } lineLayoutsList.add(0, llPoss); } - + setFinished(true); - + //Post-process the line breaks found return postProcessLineBreaks(alignment, context); } @@ -944,12 +944,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager hyphenationLadderCount.getEnum() == EN_NO_LIMIT ? 0 : hyphenationLadderCount.getValue(), this); - - if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE + + if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE && fobj.getWrapOption() != EN_NO_WRAP) { findHyphenationPoints(currPar); } - + // first try int allowedBreaks; if (wrapOption == EN_NO_WRAP) { @@ -969,7 +969,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // the first try failed log.debug("No set of breaking points found with maxAdjustment = " + maxAdjustment); } - + // now try something different log.debug("Hyphenation possible? " + (hyphenationProperties.hyphenate.getEnum() == EN_TRUE)); if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE @@ -980,7 +980,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // try with a higher threshold maxAdjustment = 5; } - + if ((iBPcount = alg.findBreakingPoints(currPar, maxAdjustment, false, allowedBreaks)) == 0) { @@ -998,12 +998,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager = alg.findBreakingPoints(currPar, maxAdjustment, true, allowedBreaks); } - + // use non-hyphenated breaks, when possible lineLayouts.restorePossibilities(); - + /* extension (not in the XSL FO recommendation): if vertical alignment - is justify and the paragraph has only one layout, try using + is justify and the paragraph has only one layout, try using shorter or longer lines */ //TODO This code snippet is disabled. Reenable? if (false && alignment == EN_JUSTIFY && textAlignment == EN_JUSTIFY) { @@ -1048,9 +1048,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager * @return the newly built element list */ private List postProcessLineBreaks(int alignment, LayoutContext context) { - + List returnList = new LinkedList(); - + for (int p = 0; p < knuthParagraphs.size(); p++) { // penalty between paragraphs if (p > 0) { @@ -1061,7 +1061,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager new Position(this), penalty, context)); } } - + LineLayoutPossibilities llPoss; llPoss = (LineLayoutPossibilities) lineLayoutsList.get(p); KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(p); @@ -1078,10 +1078,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager } targetList.add(tempElement); } - returnList.addAll(targetList); + returnList.addAll(targetList); } else if (seq.isInlineSequence() && alignment == EN_JUSTIFY) { /* justified vertical alignment (not in the XSL FO recommendation): - create a multi-layout sequence whose elements will contain + create a multi-layout sequence whose elements will contain a conventional Position */ Position returnPosition = new LeafPosition(this, p); createElements(returnList, llPoss, returnPosition); @@ -1107,7 +1107,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } int endIndex = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos(); - // create a list of the FootnoteBodyLM handling footnotes + // create a list of the FootnoteBodyLM handling footnotes // whose citations are in this line List footnoteList = new LinkedList(); ListIterator elementIterator = seq.listIterator(startIndex); @@ -1138,7 +1138,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } } - + return returnList; } @@ -1286,7 +1286,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager public int getKeepTogetherStrength() { return ((BlockLevelLayoutManager) getParent()).getKeepTogetherStrength(); } - + /** {@inheritDoc} */ public boolean mustKeepWithPrevious() { return getKeepWithPreviousStrength() > KEEP_AUTO; @@ -1306,7 +1306,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + /** {@inheritDoc} */ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { LeafPosition pos = (LeafPosition)lastElement.getPosition(); @@ -1331,7 +1331,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { List returnList = new LinkedList(); @@ -1354,8 +1354,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager MinOptMax contentIPD; if (alignment == EN_JUSTIFY) { contentIPD = new MinOptMax( - lbp.lineWidth - lbp.difference - lbp.availableShrink, - lbp.lineWidth - lbp.difference, + lbp.lineWidth - lbp.difference - lbp.availableShrink, + lbp.lineWidth - lbp.difference, lbp.lineWidth - lbp.difference + lbp.availableStretch); } else if (alignment == EN_CENTER) { contentIPD = new MinOptMax(lbp.lineWidth - 2 * lbp.startIndent); @@ -1397,10 +1397,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager // find all hyphenation points while (currParIterator.hasNext()) { firstElement = (KnuthElement) currParIterator.next(); - // + // if (firstElement.getLayoutManager() != currLM) { currLM = (InlineLevelLayoutManager) firstElement.getLayoutManager(); - if (currLM != null) { + if (currLM != null) { updateList.add(new Update(currLM, currParIterator.previousIndex())); } else { break; @@ -1409,7 +1409,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager break; } //TODO Something's not right here. See block_hyphenation_linefeed_preserve.xml - + // collect word fragments, ignoring auxiliary elements; // each word fragment was created by a different TextLM if (firstElement.isBox() && !firstElement.isAuxiliary()) { @@ -1432,7 +1432,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } else if (!nextElement.isAuxiliary()) { // a non-auxiliary non-box KnuthElement: stop // go back to the last box or auxiliary element - currParIterator.previous(); + currParIterator.previous(); break; } else { if (currLM != nextElement.getLayoutManager()) { @@ -1475,7 +1475,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager //int iRemovedElements = 0; while (updateListIterator.hasNext()) { - // ask the LMs to apply the changes and return + // ask the LMs to apply the changes and return // the new KnuthElements to replace the old ones currUpdate = (Update) updateListIterator.next(); int fromIndex = currUpdate.iFirstIndex; @@ -1584,11 +1584,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager } else if ((pos instanceof NonLeafPosition) && pos.generatesAreas()) { addBlockArea(context, pos, isLastPosition); } else { - /* + /* * pos was the Position inside a penalty item, nothing to do; * or Pos does not generate an area, * i.e. it stand for spaces, borders and padding. - */ + */ } } setCurrentArea(null); // ?? necessary @@ -1605,14 +1605,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager KnuthElement tempElement = null; // the TLM which created the last KnuthElement in this line LayoutManager lastLM = null; - + LineBreakPosition lbp = (LineBreakPosition) pos; int iCurrParIndex; iCurrParIndex = lbp.iParIndex; KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(iCurrParIndex); int iStartElement = lbp.iStartIndex; int iEndElement = lbp.getLeafPos(); - + LineArea lineArea = new LineArea((lbp.getLeafPos() < seq.size() - 1 ? textAlignment : textAlignmentLast), @@ -1625,12 +1625,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.addTrait(Trait.SPACE_BEFORE, new Integer(lbp.spaceBefore)); lineArea.addTrait(Trait.SPACE_AFTER, new Integer(lbp.spaceAfter)); alignmentContext.resizeLine(lbp.lineHeight, lbp.baseline); - + if (seq instanceof Paragraph) { Paragraph currPar = (Paragraph) seq; // ignore the first elements added by the LineLayoutManager iStartElement += (iStartElement == 0) ? currPar.ignoreAtStart : 0; - + // if this is the last line area that for this paragraph, // ignore the last elements added by the LineLayoutManager and // subtract the last-line-end-indent from the area ipd @@ -1639,10 +1639,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.setIPD(lineArea.getIPD() - lastLineEndIndent.getValue(this)); } } - + // Remove trailing spaces if allowed so if (whiteSpaceTreament == EN_IGNORE_IF_SURROUNDING_LINEFEED - || whiteSpaceTreament == EN_IGNORE + || whiteSpaceTreament == EN_IGNORE || whiteSpaceTreament == EN_IGNORE_IF_BEFORE_LINEFEED) { // ignore the last element in the line if it is a KnuthGlue object seqIterator = seq.listIterator(iEndElement); @@ -1661,10 +1661,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager lastLM = tempElement.getLayoutManager(); } } - + // Remove leading spaces if allowed so if (whiteSpaceTreament == EN_IGNORE_IF_SURROUNDING_LINEFEED - || whiteSpaceTreament == EN_IGNORE + || whiteSpaceTreament == EN_IGNORE || whiteSpaceTreament == EN_IGNORE_IF_AFTER_LINEFEED) { // ignore KnuthGlue and KnuthPenalty objects // at the beginning of the line @@ -1678,13 +1678,13 @@ public class LineLayoutManager extends InlineStackingLayoutManager // Add the inline areas to lineArea PositionIterator inlinePosIter = new KnuthPossPosIter(seq, iStartElement, iEndElement + 1); - + iStartElement = lbp.getLeafPos() + 1; if (iStartElement == seq.size()) { // advance to next paragraph iStartElement = 0; } - + LayoutContext lc = new LayoutContext(0); lc.setAlignmentContext(alignmentContext); lc.setSpaceAdjust(lbp.dAdjust); @@ -1692,7 +1692,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager lc.setLeadingSpace(new SpaceSpecifier(true)); lc.setTrailingSpace(new SpaceSpecifier(false)); lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true); - + /* * extension (not in the XSL FO recommendation): if the left and right margins * have been optimized, recompute indents and / or adjust ratio, according @@ -1718,11 +1718,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent)); } else if (false && textAlignment == EN_END) { // re-compute indent - int updatedIndent = lbp.startIndent + int updatedIndent = lbp.startIndent + (context.getStackLimitIP().opt - lbp.lineWidth); lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent)); } - + setCurrentArea(lineArea); setChildContext(lc); LayoutManager childLM; @@ -1732,9 +1732,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager lc.setLeadingSpace(lc.getTrailingSpace()); lc.setTrailingSpace(new SpaceSpecifier(false)); } - + // when can this be null? - // if display-align is distribute, add space after + // if display-align is distribute, add space after if (context.getSpaceAfter() > 0 && (!context.isLastArea() || !isLastPosition)) { lineArea.setBPD(lineArea.getBPD() + context.getSpaceAfter()); @@ -1742,7 +1742,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.finalise(); parentLM.addChildArea(lineArea); } - + /** * Add a line with block content * @param context the context for adding areas @@ -1766,13 +1766,13 @@ public class LineLayoutManager extends InlineStackingLayoutManager if (isLastPosition) { lastLM = innerPosition.getLM(); } - + LineArea lineArea = new LineArea(); setCurrentArea(lineArea); LayoutContext lc = new LayoutContext(0); lc.setAlignmentContext(alignmentContext); setChildContext(lc); - + PositionIterator childPosIter = new StackingIter(positionList.listIterator()); LayoutContext blocklc = new LayoutContext(0); blocklc.setLeadingSpace(new SpaceSpecifier(true)); @@ -1810,14 +1810,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager } // --------- Property Resolution related functions --------- // - + /** * {@inheritDoc} */ public boolean getGeneratesBlockArea() { return true; } - + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java index 59dd9c3c4..c1b81c4ab 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java @@ -29,7 +29,7 @@ public class LineLayoutPossibilities { /** logger instance */ protected static Log log = LogFactory.getLog(LineLayoutPossibilities.class); - + private class Possibility { private int lineCount; private double demerits; @@ -50,8 +50,8 @@ public class LineLayoutPossibilities { } private void addBreakPosition(Position pos) { - // Positions are always added with index 0 because - // they are created backward, from the last one to + // Positions are always added with index 0 because + // they are created backward, from the last one to // the first one breakPositions.add(0, pos); } @@ -74,7 +74,7 @@ public class LineLayoutPossibilities { savedPossibilities = new java.util.ArrayList(); optimumIndex = -1; } - + public void addPossibility(int ln, double dem) { possibilitiesList.add(new Possibility(ln, dem)); if (possibilitiesList.size() == 1) { @@ -145,8 +145,8 @@ public class LineLayoutPossibilities { } else { // this should not happen log.error("LineLayoutPossibilities restorePossibilities()," - + " min= " + getMinLineCount() - + " max= " + getMaxLineCount() + + " min= " + getMinLineCount() + + " max= " + getMaxLineCount() + " restored= " + restoredPossibility.getLineCount()); return; } @@ -158,7 +158,7 @@ public class LineLayoutPossibilities { chosenIndex = optimumIndex; } } - //log.debug(">> minLineCount = " + getMinLineCount() + //log.debug(">> minLineCount = " + getMinLineCount() // + " optLineCount = " + getOptLineCount() + " maxLineCount() = " + getMaxLineCount()); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java index 331d48b75..d33f2cca1 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,13 +43,13 @@ public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitat super(node); fobj = node; } - + /** {@inheritDoc} */ public InlineArea get(LayoutContext context) { curArea = getPageNumberCitationLastInlineArea(parentLM); return curArea; } - + /** * if id can be resolved then simply return a word, otherwise * return a resolvable area @@ -71,12 +71,12 @@ public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitat int width = getStringWidth(str); text.addWord(str, 0); text.setIPD(width); - + resolved = true; } - + updateTextAreaTraits(text); - + return text; } } diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java index 8e6633ab8..583f73d24 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,13 +41,13 @@ public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationL public PageNumberCitationLayoutManager(PageNumberCitation node) { super(node); } - + /** {@inheritDoc} */ public InlineArea get(LayoutContext context) { curArea = getPageNumberCitationInlineArea(); return curArea; } - + /** * if id can be resolved then simply return a word, otherwise * return a resolvable area @@ -71,9 +71,9 @@ public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationL text.setIPD(width); } updateTextAreaTraits(text); - + return text; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java index 1aaaaf527..6b0e88cbb 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,10 +34,10 @@ import org.apache.fop.traits.MinOptMax; * LayoutManager for the fo:page-number formatting object */ public class PageNumberLayoutManager extends LeafNodeLayoutManager { - + private PageNumber fobj; private Font font; - + /** * Constructor * @@ -48,7 +48,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { super(node); fobj = node; } - + /** {@inheritDoc} */ public void initialize() { FontInfo fi = fobj.getFOEventHandler().getFontInfo(); @@ -84,13 +84,13 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { text.setBPD(font.getAscender() - font.getDescender()); text.setBaselineOffset(font.getAscender()); TraitSetter.addFontTraits(text, font); - text.addTrait(Trait.COLOR, fobj.getColor()); + text.addTrait(Trait.COLOR, fobj.getColor()); TraitSetter.addTextDecoration(text, fobj.getTextDecoration()); return text; } - + /** {@inheritDoc} */ protected InlineArea getEffectiveArea() { TextArea baseArea = (TextArea)curArea; @@ -108,7 +108,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { updateContent(ta); return ta; } - + private void updateContent(TextArea area) { // get the page number of the page actually being built area.removeText(); @@ -130,6 +130,6 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { } return width; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java index 25bcb7d0e..a2a1dce27 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,19 +23,19 @@ import org.apache.fop.datatypes.Length; /** * The FOP specific incarnation of the XSL-FO scaled baseline table. - * All baseline tables are scaled to the font size of the font they - * apply to. This interface uses a coordinate system with its origin + * All baseline tables are scaled to the font size of the font they + * apply to. This interface uses a coordinate system with its origin * where the dominant baseline intersects the start edge of the box. * All measurements are in mpt. */ public interface ScaledBaselineTable { - + /** * Return the dominant baseline identifer for this alignment context. * @return the dominant baseline identifier */ int getDominantBaselineIdentifier(); - + /** * Return the writing mode for this aligment context. * @return the writing mode @@ -49,7 +49,7 @@ public interface ScaledBaselineTable { * @return the baseline offset */ int getBaseline(int baselineIdentifier); - + /** * Sets the position of the before and after baselines. * This is usually only done for line areas. For other @@ -59,7 +59,7 @@ public interface ScaledBaselineTable { * @param afterBaseline the offset of the after-edge baseline from the dominant baseline */ void setBeforeAndAfterBaselines(int beforeBaseline, int afterBaseline); - + /** * Return a new baseline table for the given baseline based * on the current baseline table. diff --git a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java index e47f107e3..1536552c4 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ public class ScaledBaselineTableFactory implements Constants { return new BasicScaledBaselineTable(font.getAscender(), font.getDescender() , font.getXHeight(), dominantBaselineIdentifier, writingMode); } - + /** * Creates a new instance of BasicScaledBaselineTable for the given * font and writingmode. It assumes an alphabetic baseline. @@ -55,7 +55,7 @@ public class ScaledBaselineTableFactory implements Constants { public static ScaledBaselineTable makeFontScaledBaselineTable(Font font, int writingMode) { return makeFontScaledBaselineTable(font, EN_ALPHABETIC, writingMode); } - + /** * Creates a new instance of BasicScaledBaselineTable for the given * height, baseline and writingmode. This is used for non font based areas like @@ -71,5 +71,5 @@ public class ScaledBaselineTableFactory implements Constants { return new BasicScaledBaselineTable(height, 0, height , dominantBaselineIdentifier, writingMode); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index c6210edce..459bce0e8 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -203,7 +203,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { public void initialize() { this.foText.resetBuffer(); - + this.spaceFont = FontSelector.selectFontForCharacterInText(' ', this.foText, this); // With CID fonts, space isn't neccesary currentFontState.width(32) diff --git a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java index 342e0a6f1..97f07da54 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ import java.util.LinkedList; * This is the layout manager for the fo:wrapper formatting object. */ public class WrapperLayoutManager extends LeafNodeLayoutManager { - + /** * Creates a new LM for fo:wrapper. * @param node the fo:wrapper diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index 11e69970e..1cd3ab9d2 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr.list; import java.util.Iterator; @@ -48,7 +48,7 @@ import org.apache.fop.traits.SpaceVal; * A list block contains list items which are stacked within * the list block area.. */ -public class ListBlockLayoutManager extends BlockStackingLayoutManager +public class ListBlockLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** @@ -102,38 +102,38 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager foSpaceAfter = new SpaceVal( getListBlockFO().getCommonMarginBlock().spaceAfter, this).getSpace(); startIndent = getListBlockFO().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getListBlockFO().getCommonMarginBlock().endIndent.getValue(this); + endIndent = getListBlockFO().getCommonMarginBlock().endIndent.getValue(this); } private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - resetSpaces(); + resetSpaces(); List returnList = super.getNextKnuthElements(context, alignment); //fox:widow-content-limit - int widowRowLimit = getListBlockFO().getWidowContentLimit().getValue(); + int widowRowLimit = getListBlockFO().getWidowContentLimit().getValue(); if (widowRowLimit != 0) { ElementListUtils.removeLegalBreaks(returnList, widowRowLimit); } //fox:orphan-content-limit - int orphanRowLimit = getListBlockFO().getOrphanContentLimit().getValue(); + int orphanRowLimit = getListBlockFO().getOrphanContentLimit().getValue(); if (orphanRowLimit != 0) { ElementListUtils.removeLegalBreaksFromEnd(returnList, orphanRowLimit); } return returnList; } - + /** {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { //log.debug("LBLM.getChangedKnuthElements>"); @@ -169,7 +169,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager Position lastPos = null; // "unwrap" the NonLeafPositions stored in parentIter - // and put them in a new list; + // and put them in a new list; LinkedList positionList = new LinkedList(); Position pos; while (parentIter.hasNext()) { @@ -208,17 +208,17 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); // We are done with this area add the background - TraitSetter.addBackground(curBlockArea, + TraitSetter.addBackground(curBlockArea, getListBlockFO().getCommonBorderPaddingBackground(), this); - TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); curBlockArea = null; resetSpaces(); - + checkEndOfLayout(lastPos); } @@ -238,30 +238,30 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager public Area getParentArea(Area childArea) { if (curBlockArea == null) { curBlockArea = new Block(); - + // Set up dimensions // Must get dimensions from parent area /*Area parentArea =*/ parentLM.getParentArea(curBlockArea); // set traits TraitSetter.setProducerID(curBlockArea, getListBlockFO().getId()); - TraitSetter.addBorders(curBlockArea, - getListBlockFO().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(curBlockArea, + getListBlockFO().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(curBlockArea, - getListBlockFO().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(curBlockArea, + getListBlockFO().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); TraitSetter.addMargins(curBlockArea, - getListBlockFO().getCommonBorderPaddingBackground(), + getListBlockFO().getCommonBorderPaddingBackground(), getListBlockFO().getCommonMarginBlock(), this); - TraitSetter.addBreaks(curBlockArea, - getListBlockFO().getBreakBefore(), + TraitSetter.addBreaks(curBlockArea, + getListBlockFO().getBreakBefore(), getListBlockFO().getBreakAfter()); - + int contentIPD = referenceIPD - getIPIndents(); curBlockArea.setIPD(contentIPD); - + setCurrentArea(curBlockArea); } return curBlockArea; @@ -285,7 +285,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KeepUtil.getCombinedBlockLevelKeepStrength(getListBlockFO().getKeepWithNext()); @@ -300,13 +300,13 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java index 124827976..0a2dec945 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr.list; import java.util.Iterator; @@ -85,7 +85,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { protected AbstractListItemPart getPartFO() { return (AbstractListItemPart)fobj; } - + /** * Set the x offset of this list item. * This offset is used to set the absolute position @@ -114,7 +114,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - + addId(); LayoutManager childLM; @@ -125,7 +125,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { Position lastPos = null; // "unwrap" the NonLeafPositions stored in parentIter - // and put them in a new list; + // and put them in a new list; LinkedList positionList = new LinkedList(); Position pos; while (parentIter.hasNext()) { @@ -154,7 +154,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { } addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); - + StackingIter childPosIter = new StackingIter(positionList.listIterator()); while ((childLM = childPosIter.getNextChildLM()) != null) { // Add the block areas to Area @@ -167,11 +167,11 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { } addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); - + flush(); curBlockArea = null; - + checkEndOfLayout(lastPos); } @@ -198,7 +198,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { //curBlockArea.setHeight(); TraitSetter.setProducerID(curBlockArea, getPartFO().getId()); - + // Set up dimensions Area parentArea = parentLM.getParentArea(curBlockArea); int referenceIPD = parentArea.getIPD(); @@ -226,7 +226,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 37ec4964d..f027922f7 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -59,7 +59,7 @@ import org.apache.fop.traits.SpaceVal; * LayoutManager for a list-item FO. * The list item contains a list item label and a list item body. */ -public class ListItemLayoutManager extends BlockStackingLayoutManager +public class ListItemLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** @@ -81,19 +81,19 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager private boolean discardPaddingAfter; private MinOptMax effSpaceBefore; private MinOptMax effSpaceAfter; - + private int keepWithNextPendingOnLabel; private int keepWithNextPendingOnBody; private int listItemHeight; - + private class ListItemPosition extends Position { private int iLabelFirstIndex; private int iLabelLastIndex; private int iBodyFirstIndex; private int iBodyLastIndex; - public ListItemPosition(LayoutManager lm, int labelFirst, int labelLast, + public ListItemPosition(LayoutManager lm, int labelFirst, int labelLast, int bodyFirst, int bodyLast) { super(lm); iLabelFirstIndex = labelFirst; @@ -101,11 +101,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager iBodyFirstIndex = bodyFirst; iBodyLastIndex = bodyLast; } - + public int getLabelFirstIndex() { return iLabelFirstIndex; } - + public int getLabelLastIndex() { return iLabelLastIndex; } @@ -113,11 +113,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager public int getBodyFirstIndex() { return iBodyFirstIndex; } - + public int getBodyLastIndex() { return iBodyLastIndex; } - + /** {@inheritDoc} */ public boolean generatesAreas() { return true; @@ -166,7 +166,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager * @param node the fo:list-item-body FO */ public void setBody(ListItemBody node) { - body = new ListItemContentLayoutManager(node); + body = new ListItemContentLayoutManager(node); body.setParent(this); } @@ -177,25 +177,25 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager foSpaceAfter = new SpaceVal( getListItemFO().getCommonMarginBlock().spaceAfter, this).getSpace(); startIndent = getListItemFO().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getListItemFO().getCommonMarginBlock().endIndent.getValue(this); + endIndent = getListItemFO().getCommonMarginBlock().endIndent.getValue(this); } private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { referenceIPD = context.getRefIPD(); LayoutContext childLC; - + List returnList = new LinkedList(); - + if (!breakBeforeServed) { try { if (addKnuthElementsForBreakBefore(returnList, context)) { @@ -207,7 +207,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } addKnuthElementsForSpaceBefore(returnList, alignment); - + addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); firstVisibleMarkServed = true; @@ -219,12 +219,12 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager childLC.setRefIPD(context.getRefIPD()); label.initialize(); labelList = label.getNextKnuthElements(childLC, alignment); - + //Space resolution as if the contents were placed in a new reference area //(see 6.8.3, XSL 1.0, section on Constraints, last paragraph) SpaceResolver.resolveElementList(labelList); ElementListObserver.observe(labelList, "list-item-label", label.getPartFO().getId()); - + context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending()); this.keepWithNextPendingOnLabel = childLC.getKeepWithNextPending(); @@ -238,7 +238,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager //(see 6.8.3, XSL 1.0, section on Constraints, last paragraph) SpaceResolver.resolveElementList(bodyList); ElementListObserver.observe(bodyList, "list-item-body", body.getPartFO().getId()); - + context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending()); this.keepWithNextPendingOnBody = childLC.getKeepWithNextPending(); @@ -247,7 +247,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // "wrap" the Position inside each element wrapPositionElements(returnedList, returnList, true); - + addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); addKnuthElementsForBreakAfter(returnList, context); @@ -280,7 +280,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager LinkedList returnList = new LinkedList(); while ((step = getNextStep(elementLists, start, end, partialHeights)) > 0) { - + if (end[0] + 1 == elementLists[0].size()) { keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnLabel); } @@ -289,10 +289,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } // compute penalty height and box height - int penaltyHeight = step - + getMaxRemainingHeight(fullHeights, partialHeights) + int penaltyHeight = step + + getMaxRemainingHeight(fullHeights, partialHeights) - totalHeight; - + //Additional penalty height from penalties in the source lists int additionalPenaltyHeight = 0; int stepPenalty = 0; @@ -307,7 +307,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager additionalPenaltyHeight, endEl.getW()); stepPenalty = Math.max(stepPenalty, endEl.getP()); } - + int boxHeight = step - addedBoxHeight - penaltyHeight; penaltyHeight += additionalPenaltyHeight; //Add AFTER calculating boxHeight! @@ -330,7 +330,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // add the new elements addedBoxHeight += boxHeight; - ListItemPosition stepPosition = new ListItemPosition(this, + ListItemPosition stepPosition = new ListItemPosition(this, start[0], end[0], start[1], end[1]); if (footnoteList == null) { returnList.add(new KnuthBox(boxHeight, stepPosition, false)); @@ -394,7 +394,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager if (seqCount == 0) { return 0; } - + // determine next step int step; if (backupHeights[0] == 0 && backupHeights[1] == 0) { @@ -426,7 +426,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { //log.debug(" LILM.getChanged> label"); @@ -441,10 +441,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager while (oldListIterator.hasNext()) { oldElement = (KnuthElement)oldListIterator.next(); Position innerPosition = oldElement.getPosition().getPosition(); - //log.debug(" BLM> unwrapping: " + (oldElement.isBox() - // ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) + //log.debug(" BLM> unwrapping: " + (oldElement.isBox() + // ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) // + " creato da " + oldElement.getLayoutManager().getClass().getName()); - //log.debug(" BLM> unwrapping: " + //log.debug(" BLM> unwrapping: " // + oldElement.getPosition().getClass().getName()); if (innerPosition != null) { // oldElement was created by a descendant of this BlockLM @@ -508,7 +508,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); - // use the first and the last ListItemPosition to determine the + // use the first and the last ListItemPosition to determine the // corresponding indexes in the original labelList and bodyList int labelFirstIndex = ((ListItemPosition) positionList.getFirst()).getLabelFirstIndex(); int labelLastIndex = ((ListItemPosition) positionList.getLast()).getLabelLastIndex(); @@ -517,17 +517,17 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager //Determine previous break if any int previousBreak = ElementListUtils.determinePreviousBreak(labelList, labelFirstIndex); - SpaceResolver.performConditionalsNotification(labelList, + SpaceResolver.performConditionalsNotification(labelList, labelFirstIndex, labelLastIndex, previousBreak); //Determine previous break if any previousBreak = ElementListUtils.determinePreviousBreak(bodyList, bodyFirstIndex); - SpaceResolver.performConditionalsNotification(bodyList, + SpaceResolver.performConditionalsNotification(bodyList, bodyFirstIndex, bodyLastIndex, previousBreak); - + // add label areas if (labelFirstIndex <= labelLastIndex) { - KnuthPossPosIter labelIter = new KnuthPossPosIter(labelList, + KnuthPossPosIter labelIter = new KnuthPossPosIter(labelList, labelFirstIndex, labelLastIndex + 1); lc.setFlags(LayoutContext.FIRST_AREA, layoutContext.isFirstArea()); lc.setFlags(LayoutContext.LAST_AREA, layoutContext.isLastArea()); @@ -548,7 +548,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // add body areas if (bodyFirstIndex <= bodyLastIndex) { - KnuthPossPosIter bodyIter = new KnuthPossPosIter(bodyList, + KnuthPossPosIter bodyIter = new KnuthPossPosIter(bodyList, bodyFirstIndex, bodyLastIndex + 1); lc.setFlags(LayoutContext.FIRST_AREA, layoutContext.isFirstArea()); lc.setFlags(LayoutContext.LAST_AREA, layoutContext.isLastArea()); @@ -567,17 +567,17 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); // We are done with this area add the background - TraitSetter.addBackground(curBlockArea, + TraitSetter.addBackground(curBlockArea, getListItemFO().getCommonBorderPaddingBackground(), this); - TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); curBlockArea = null; resetSpaces(); - + checkEndOfLayout(lastPos); } @@ -610,22 +610,22 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // Set up dimensions /*Area parentArea =*/ parentLM.getParentArea(curBlockArea); - + // set traits TraitSetter.setProducerID(curBlockArea, getListItemFO().getId()); - TraitSetter.addBorders(curBlockArea, - getListItemFO().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(curBlockArea, + getListItemFO().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(curBlockArea, - getListItemFO().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(curBlockArea, + getListItemFO().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); TraitSetter.addMargins(curBlockArea, - getListItemFO().getCommonBorderPaddingBackground(), + getListItemFO().getCommonBorderPaddingBackground(), getListItemFO().getCommonMarginBlock(), this); - TraitSetter.addBreaks(curBlockArea, - getListItemFO().getBreakBefore(), + TraitSetter.addBreaks(curBlockArea, + getListItemFO().getBreakBefore(), getListItemFO().getBreakAfter()); - + int contentIPD = referenceIPD - getIPIndents(); curBlockArea.setIPD(contentIPD); @@ -669,13 +669,13 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; @@ -710,6 +710,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } } - + } diff --git a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java index 4012b0c00..a9da7a3ca 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java +++ b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java @@ -173,7 +173,7 @@ class ActiveCell { * Returns the actual length of the content represented by the given element. In the * case where this element is used as a filler to match a row's fixed height, the * value returned by the getW() method will be higher than the actual content. - * + * * @param el an element * @return the actual content length corresponding to the element */ @@ -226,7 +226,7 @@ class ActiveCell { /** * Modifies the cell's element list by putting filler elements, so that the cell's or * row's explicit height is always reached. - * + * * TODO this will work properly only for the first break. Then the limitation * explained on http://wiki.apache.org/xmlgraphics-fop/TableLayout/KnownProblems * occurs. The list of elements needs to be re-adjusted after each break. @@ -269,7 +269,7 @@ class ActiveCell { /** * Returns true if this cell ends on the given row. - * + * * @param rowIndex index of a row in the row-group, zero-based * @return true if this cell ends on the given row */ @@ -280,7 +280,7 @@ class ActiveCell { /** * Returns the length of this cell's content not yet included in the steps, plus the * cell's borders and paddings if applicable. - * + * * @return the remaining length, zero if the cell is finished */ int getRemainingLength() { @@ -341,12 +341,12 @@ class ActiveCell { afterNextStep.end = knuthIter.nextIndex() - 1; afterNextStep.totalLength = bpBeforeNormal + afterNextStep.contentLength + afterNextStep.penaltyLength - + bpAfterTrailing; + + bpAfterTrailing; } /** * Returns the minimal step that is needed for this cell to contribute some content. - * + * * @return the step for this cell's first legal break */ int getFirstStep() { @@ -363,7 +363,7 @@ class ActiveCell { * infinite penalty, plus the cell's content won't be taken into account since the * final step will be smaller than the current one (see {@link #signalNextStep(int)}). * This actually means that the content will be swallowed. - * + * * @return the length of last step */ int getLastStep() { @@ -377,7 +377,7 @@ class ActiveCell { /** * Increases the next step up to the given limit. - * + * * @param limit the length up to which the next step is allowed to increase * @see #signalRowFirstStep(int) * @see #signalRowLastStep(int) @@ -398,7 +398,7 @@ class ActiveCell { * Gets the selected first step for the current row. If this cell's first step is * smaller, then it may be able to add some more of its content, since there will be * no break before the given step anyway. - * + * * @param firstStep the current row's first step */ void signalRowFirstStep(int firstStep) { @@ -418,7 +418,7 @@ class ActiveCell { /** * Returns the total length up to the next legal break, not yet included in the steps. - * + * * @return the total length up to the next legal break (-1 signals no further step) */ int getNextStep() { @@ -446,7 +446,7 @@ class ActiveCell { /** * Signals the length of the chosen next step, so that this cell determines whether * its own step may be included or not. - * + * * @param minStep length of the chosen next step * @return the break class of the step, if any. One of {@link Constants#EN_AUTO}, * {@link Constants#EN_COLUMN}, {@link Constants#EN_PAGE}, @@ -487,7 +487,7 @@ class ActiveCell { /** * Receives indication that the current row is ending, and that (collapse) borders * must be updated accordingly. - * + * * @param rowIndex the index of the ending row */ void endRow(int rowIndex) { @@ -508,7 +508,7 @@ class ActiveCell { /** * Returns true if this cell would be finished after the given step. That is, it would * be included in the step and the end of its content would be reached. - * + * * @param step the next step * @return true if this cell finishes at the given step */ @@ -519,7 +519,7 @@ class ActiveCell { /** * Creates and returns a CellPart instance for the content of this cell which * is included in the next step. - * + * * @return a CellPart instance */ CellPart createCellPart() { @@ -557,7 +557,7 @@ class ActiveCell { /** * Adds the footnotes (if any) that are part of the next step, if this cell * contributes content to the next step. - * + * * @param footnoteList the list to which this cell must add its footnotes */ void addFootnotes(List footnoteList) { diff --git a/src/java/org/apache/fop/layoutmgr/table/CellPart.java b/src/java/org/apache/fop/layoutmgr/table/CellPart.java index 560b70344..7dd2bc201 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CellPart.java +++ b/src/java/org/apache/fop/layoutmgr/table/CellPart.java @@ -44,7 +44,7 @@ class CellPart { /** * Creates a new CellPart. - * + * * @param pgu Primary grid unit * @param start starting element * @param end ending element diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java index c3df74800..ede6210ca 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java +++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java @@ -131,7 +131,7 @@ public abstract class CollapsingBorderModel { /** * Compares the two given styles (see {@link Constants}). - * + * * @param style1 a style constant * @param style2 another style constant * @return a value < 0 if style1 has less priority than style2, 0 if both are @@ -161,7 +161,7 @@ public abstract class CollapsingBorderModel { /** * Compares the two given FO ids ({@link Constants}.FO*) in terms of border * declaration. - * + * * @param id1 a FO id ({@link Constants#FO_TABLE}, {@link Constants#FO_TABLE_BODY}, * etc.) * @param id2 another FO id @@ -178,7 +178,7 @@ public abstract class CollapsingBorderModel { * Returns the border which wins the border conflict resolution. In case the two * borders are equivalent (identical, or only the color is different), null is * returned. - * + * * @param border1 a border specification * @param border2 another border specification * @param discard true if the .conditionality component of the border width must be @@ -192,7 +192,7 @@ public abstract class CollapsingBorderModel { * Returns the border which wins the border conflict resolution. Same as * {@link #determineWinner(BorderSpecification, BorderSpecification, boolean) * determineWinner(border1, border2, false)}. - * + * * @param border1 a border specification * @param border2 another border specification * @return the winning border, null if the two borders are equivalent diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java index c1a9380a3..7aed158de 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java +++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java @@ -26,7 +26,7 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; /** * Implements the normal "collapse" border model defined in 6.7.10 in XSL 1.0. - * + * * TODO Column groups are not yet checked in this algorithm! */ public class CollapsingBorderModelEyeCatching extends CollapsingBorderModel { diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index 9dbd31653..c32c6eb3d 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -45,9 +45,9 @@ public class ColumnSetup { private Table table; private List columns = new java.util.ArrayList(); private List colWidths = new java.util.ArrayList(); - + private int maxColIndexReferenced = 0; - + /** * Main Constructor. * @param table the table to construct this column setup for @@ -57,7 +57,7 @@ public class ColumnSetup { prepareColumns(); initializeColumnWidths(); } - + private void prepareColumns() { List rawCols = table.getColumns(); if (rawCols != null) { @@ -124,7 +124,7 @@ public class ColumnSetup { return (TableColumn) columns.get(index - 1); } } - + /** {@inheritDoc} */ public String toString() { return columns.toString(); @@ -138,15 +138,15 @@ public class ColumnSetup { return columns.size(); } } - + /** @return an Iterator over all columns */ public Iterator iterator() { return this.columns.iterator(); } - + /* private void createColumnsFromFirstRow() { - //TODO Create oldColumns from first row here + //TODO Create oldColumns from first row here //--> rule 2 in "fixed table layout", see CSS2, 17.5.2 //Alternative: extend oldColumns on-the-fly, but in this case we need the //new property evaluation context so proportional-column-width() works @@ -159,13 +159,13 @@ public class ColumnSetup { /** * Initializes the column's widths - * + * */ private void initializeColumnWidths() { - + TableColumn col; Length colWidth; - + for (int i = columns.size(); --i >= 0;) { if (columns.get(i) != null) { col = (TableColumn) columns.get(i); @@ -175,21 +175,21 @@ public class ColumnSetup { } colWidths.add(0, null); } - + /** * Works out the base unit for resolving proportional-column-width() * [p-c-w(x) = x * base_unit_ipd] - * + * * @param tlm the TableLayoutManager * @return the computed base unit (in millipoint) */ protected double computeTableUnit(TableLayoutManager tlm) { - + int sumCols = 0; float factors = 0; double unit = 0; - - /* calculate the total width (specified absolute/percentages), + + /* calculate the total width (specified absolute/percentages), * and work out the total number of factors to use to distribute * the remaining space (if any) */ @@ -204,9 +204,9 @@ public class ColumnSetup { } } } - - /* distribute the remaining space over the accumulated - * factors (if any) + + /* distribute the remaining space over the accumulated + * factors (if any) */ if (factors > 0) { if (sumCols < tlm.getContentAreaIPD()) { @@ -215,10 +215,10 @@ public class ColumnSetup { log.warn("No space remaining to distribute over columns."); } } - + return unit; } - + /** * @param col column index (1 is first column) * @param context the context for percentage based calculations @@ -258,5 +258,5 @@ public class ColumnSetup { } return sum; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java index 7f91808d0..54cb1ebfe 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -66,7 +66,7 @@ class RowGroupLayoutManager { int breakBefore = Constants.EN_AUTO; TableRow firstRow = rowGroup[0].getTableRow(); if (firstRow != null) { - breakBefore = firstRow.getBreakBefore(); + breakBefore = firstRow.getBreakBefore(); } context.setBreakBefore(BreakUtil.compareBreakClasses(breakBefore, rowGroup[0].getBreakBefore())); @@ -74,7 +74,7 @@ class RowGroupLayoutManager { int breakAfter = Constants.EN_AUTO; TableRow lastRow = rowGroup[rowGroup.length - 1].getTableRow(); if (lastRow != null) { - breakAfter = lastRow.getBreakAfter(); + breakAfter = lastRow.getBreakAfter(); } context.setBreakAfter(BreakUtil.compareBreakClasses(breakAfter, rowGroup[rowGroup.length - 1].getBreakAfter())); @@ -89,7 +89,7 @@ class RowGroupLayoutManager { * @param bodyType Indicates what kind of body is being processed (BODY, HEADER or FOOTER) * @param returnList List to received the generated elements */ - private void createElementsForRowGroup(LayoutContext context, int alignment, + private void createElementsForRowGroup(LayoutContext context, int alignment, int bodyType, LinkedList returnList) { log.debug("Handling row group with " + rowGroup.length + " rows..."); EffRow row; @@ -113,7 +113,7 @@ class RowGroupLayoutManager { LayoutContext childLC = new LayoutContext(0); childLC.setStackLimitBP(context.getStackLimitBP()); //necessary? childLC.setRefIPD(spanWidth); - + //Get the element list for the cell contents List elems = primary.getCellLM().getNextKnuthElements( childLC, alignment); @@ -131,7 +131,7 @@ class RowGroupLayoutManager { /** * Calculate the heights of the rows in the row group, see CSS21, 17.5.3 Table height * algorithms. - * + * * TODO this method will need to be adapted once clarification has been made by the * W3C regarding whether borders or border-separation must be included or not */ @@ -174,7 +174,7 @@ class RowGroupLayoutManager { int borderWidths = primary.getBeforeAfterBorderWidth(); int padding = 0; CommonBorderPaddingBackground cbpb = primary.getCell() - .getCommonBorderPaddingBackground(); + .getCommonBorderPaddingBackground(); padding += cbpb.getPaddingBefore(false, primary.getCellLM()); padding += cbpb.getPaddingAfter(false, primary.getCellLM()); int effRowHeight = effectiveCellBPD + padding + borderWidths; @@ -195,13 +195,13 @@ class RowGroupLayoutManager { // if (maxCellBPD > row.getExplicitHeight().max) { //old: // log.warn(FONode.decorateWithContextInfo( -// "The contents of row " + (row.getIndex() + 1) +// "The contents of row " + (row.getIndex() + 1) // + " are taller than they should be (there is a" // + " block-progression-dimension or height constraint // + " on the indicated row)." // + " Due to its contents the row grows" // + " to " + maxCellBPD + " millipoints, but the row shouldn't get" -// + " any taller than " + row.getExplicitHeight() + " millipoints.", +// + " any taller than " + row.getExplicitHeight() + " millipoints.", // row.getTableRow())); //new (with events): // BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create( diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java index 38f1a7b30..b2851c39f 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java @@ -107,7 +107,7 @@ class RowPainter { /** * Signals that the end of the current table part is reached. - * + * * @param lastInBody true if the part is the last table-body element to be displayed * on the current page. In which case all the cells must be flushed even if they * aren't finished, plus the proper collapsed borders must be selected (trailing @@ -118,7 +118,7 @@ class RowPainter { */ void endTablePart(boolean lastInBody, boolean lastOnPage) { addAreasAndFlushRow(lastInBody, lastOnPage); - + if (tablePartBackground != null) { TableLayoutManager tableLM = tclm.getTableLM(); for (Iterator iter = tablePartBackgroundAreas.iterator(); iter.hasNext();) { @@ -139,7 +139,7 @@ class RowPainter { /** * Records the fragment of row represented by the given position. If it belongs to * another (grid) row than the current one, that latter is painted and flushed first. - * + * * @param tcpos a position representing the row fragment */ void handleTableContentPosition(TableContentPosition tcpos) { @@ -173,7 +173,7 @@ class RowPainter { firstCellParts[colIndex] = cellPart; cellHeights[colIndex] = cellPart.getBorderPaddingBefore(firstCellOnPage[colIndex]); } else { - assert firstCellParts[colIndex].pgu == cellPart.pgu; + assert firstCellParts[colIndex].pgu == cellPart.pgu; cellHeights[colIndex] += cellPart.getConditionalBeforeContentLength(); } cellHeights[colIndex] += cellPart.getLength(); @@ -185,7 +185,7 @@ class RowPainter { * Creates the areas corresponding to the last row. That is, an area with background * for the row, plus areas for all the cells that finish on the row (not spanning over * further rows). - * + * * @param lastInPart true if the row is the last from its table part to be displayed * on the current page. In which case all the cells must be flushed even if they * aren't finished, plus the proper collapsed borders must be selected (trailing @@ -204,7 +204,7 @@ class RowPainter { // Need to compute the actual row height first int actualRowHeight = 0; for (int i = 0; i < colCount; i++) { - GridUnit currentGU = currentRow.getGridUnit(i); + GridUnit currentGU = currentRow.getGridUnit(i); if (!currentGU.isEmpty() && currentGU.getColSpanIndex() == 0 && (lastInPart || currentGU.isLastGridUnitRowSpan()) && firstCellParts[i] != null) { @@ -396,7 +396,7 @@ class RowPainter { * set when the areas for the cell are created since at that moment this bpd is yet * unknown. So they will instead be set in * {@link #addAreasAndFlushRow(boolean, boolean)}. - * + * * @param backgroundArea the block of the cell's dimensions that will hold the part * background */ @@ -407,7 +407,7 @@ class RowPainter { /** * Records the y-offset of the row with the given index. - * + * * @param rowIndex index of the row * @param offset y-offset of the row on the page */ @@ -419,7 +419,7 @@ class RowPainter { * considered as finished, since it contains no cell ending on this row. Thus no * TableContentPosition will be created for this row. Thus its index will never be * recorded by the #handleTableContentPosition method. - * + * * The offset of such a row is the same as the next non-empty row. It's needed * to correctly offset blocks for cells starting on this row. Hence the loop * below. @@ -431,7 +431,7 @@ class RowPainter { /** * Returns the offset of the row with the given index. - * + * * @param rowIndex index of the row * @return its y-offset on the page */ diff --git a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java index c20060723..4cf68b97b 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr.table; import org.apache.fop.area.Area; @@ -55,7 +55,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { public TableAndCaption getTableAndCaptionFO() { return (TableAndCaption)this.fobj; } - + /** * Get the next break possibility. * @@ -199,7 +199,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { curBlockArea.addBlock((Block) childArea); } } - + /** {@inheritDoc} */ public int getKeepTogetherStrength() { int strength = KEEP_AUTO; @@ -209,8 +209,8 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { */ strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; - } - + } + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java index 615145fa1..071082624 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr.table; import org.apache.fop.area.Area; @@ -50,7 +50,7 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { public TableCaption getTableCaptionFO() { return (TableCaption)this.fobj; } - + /** * Get the next break position for the caption. * @@ -195,7 +195,7 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { curBlockArea.addBlock((Block) childArea); } } - + /** {@inheritDoc} */ public int getKeepTogetherStrength() { int strength = KEEP_AUTO; @@ -208,7 +208,7 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index 52915c008..ba5e232e9 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -240,7 +240,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager /** * Sets the total height of this cell on the current page. That is, the cell's bpd * plus before and after borders and paddings, plus the table's border-separation. - * + * * @param h the height of cell */ public void setTotalHeight(int h) { @@ -250,12 +250,12 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager /** * Add the areas for the break points. The cell contains block stacking layout * managers that add block areas. - * + * * <p>In the collapsing-border model, the borders of a cell that spans over several * rows or columns are drawn separately for each grid unit. Therefore we must know the * height of each grid row spanned over by the cell. Also, if the cell is broken over * two pages we must know which spanned grid rows are present on the current page.</p> - * + * * @param parentIter the iterator of the break positions * @param layoutContext the layout context for adding the areas * @param spannedGridRowHeights in collapsing-border model for a spanning cell, height @@ -296,7 +296,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager CommonBorderPaddingBackground padding = primaryGridUnit.getCell() .getCommonBorderPaddingBackground(); - int paddingRectBPD = totalHeight - borderBeforeWidth - borderAfterWidth; + int paddingRectBPD = totalHeight - borderBeforeWidth - borderAfterWidth; int cellBPD = paddingRectBPD; cellBPD -= padding.getPaddingBefore(borderBeforeWhich == ConditionalBorder.REST, this); cellBPD -= padding.getPaddingAfter(borderAfterWhich == ConditionalBorder.REST, this); @@ -488,7 +488,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager CommonBorderPaddingBackground padding = getTableCell().getCommonBorderPaddingBackground(); int paddingStart = padding.getPaddingStart(false, this); int paddingEnd = padding.getPaddingEnd(false, this); - + Block block = new Block(); TraitSetter.setProducerID(block, getTable().getId()); block.setPositioning(Block.ABSOLUTE); @@ -567,7 +567,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; //TODO FIX ME (table-cell has no keep-with-next!) diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 80e904f8f..ad8bec715 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -69,9 +69,9 @@ public class TableContentLayoutManager implements PercentBaseContext { private int startXOffset; private int usedBPD; - + private TableStepper stepper; - + /** * Main constructor * @param parent Parent layout manager @@ -88,19 +88,19 @@ public class TableContentLayoutManager implements PercentBaseContext { } stepper = new TableStepper(this); } - + /** * @return the table layout manager */ TableLayoutManager getTableLM() { return this.tableLM; } - + /** @return true if the table uses the separate border model. */ boolean isSeparateBorderModel() { return getTableLM().getTable().isSeparateBorderModel(); } - + /** * @return the column setup of this table */ @@ -142,14 +142,14 @@ public class TableContentLayoutManager implements PercentBaseContext { this.headerNetHeight = ElementListUtils.calcContentLength(this.headerList); if (log.isDebugEnabled()) { - log.debug("==> Header: " + log.debug("==> Header: " + headerNetHeight + " - " + this.headerList); } TableHeaderFooterPosition pos = new TableHeaderFooterPosition( getTableLM(), true, this.headerList); KnuthBox box = new KnuthBox(headerNetHeight, pos, false); if (getTableLM().getTable().omitHeaderAtBreak()) { - //We can simply add the table header at the start + //We can simply add the table header at the start //of the whole list headerAsFirst = box; } else { @@ -162,7 +162,7 @@ public class TableContentLayoutManager implements PercentBaseContext { this.footerNetHeight = ElementListUtils.calcContentLength(this.footerList); if (log.isDebugEnabled()) { - log.debug("==> Footer: " + log.debug("==> Footer: " + footerNetHeight + " - " + this.footerList); } //We can simply add the table footer at the end of the whole list @@ -195,17 +195,17 @@ public class TableContentLayoutManager implements PercentBaseContext { } return returnList; } - + /** * Creates Knuth elements by iterating over a TableRowIterator. * @param iter TableRowIterator instance to fetch rows from * @param context Active LayoutContext * @param alignment alignment indicator - * @param bodyType Indicates what kind of body is being processed + * @param bodyType Indicates what kind of body is being processed * (BODY, HEADER or FOOTER) * @return An element list */ - private LinkedList getKnuthElementsForRowIterator(TableRowIterator iter, + private LinkedList getKnuthElementsForRowIterator(TableRowIterator iter, LayoutContext context, int alignment, int bodyType) { LinkedList returnList = new LinkedList(); EffRow[] rowGroup = iter.getNextRowGroup(); @@ -225,12 +225,12 @@ public class TableContentLayoutManager implements PercentBaseContext { returnList.addAll(nextRowGroupElems); while ((rowGroup = iter.getNextRowGroup()) != null) { rowGroupLM = new RowGroupLayoutManager(getTableLM(), rowGroup, stepper); - + //Note previous pending keep-with-next and clear the strength //(as the layout context is reused) int keepWithNextPending = context.getKeepWithNextPending(); context.clearKeepWithNextPending(); - + //Get elements for next row group nextRowGroupElems = rowGroupLM.getNextKnuthElements(context, alignment, bodyType); /* @@ -238,13 +238,13 @@ public class TableContentLayoutManager implements PercentBaseContext { * group) may be used to represent the break between the two row groups. * Its penalty value and break class must just be overridden by the * characteristics of the keep or break between the two. - * + * * However, we mustn't forget that if the after border of the last row of * the row group is thicker in the normal case than in the trailing case, * an additional glue will be appended to the element list. So we may have * to go two steps backwards in the list. */ - + //Determine keep constraints int penaltyStrength = BlockLevelLayoutManager.KEEP_AUTO; penaltyStrength = Math.max(penaltyStrength, keepWithNextPending); @@ -252,7 +252,7 @@ public class TableContentLayoutManager implements PercentBaseContext { context.clearKeepWithPreviousPending(); penaltyStrength = Math.max(penaltyStrength, getTableLM().getKeepTogetherStrength()); int penaltyValue = KeepUtil.getPenaltyForKeep(penaltyStrength); - + breakBetween = BreakUtil.compareBreakClasses(breakBetween, context.getBreakBefore()); if (breakBetween != Constants.EN_AUTO) { @@ -291,16 +291,16 @@ public class TableContentLayoutManager implements PercentBaseContext { context.setBreakBefore(breakBefore); //fox:widow-content-limit - int widowContentLimit = getTableLM().getTable().getWidowContentLimit().getValue(); + int widowContentLimit = getTableLM().getTable().getWidowContentLimit().getValue(); if (widowContentLimit != 0 && bodyType == TableRowIterator.BODY) { ElementListUtils.removeLegalBreaks(returnList, widowContentLimit); } //fox:orphan-content-limit - int orphanContentLimit = getTableLM().getTable().getOrphanContentLimit().getValue(); + int orphanContentLimit = getTableLM().getTable().getOrphanContentLimit().getValue(); if (orphanContentLimit != 0 && bodyType == TableRowIterator.BODY) { ElementListUtils.removeLegalBreaksFromEnd(returnList, orphanContentLimit); } - + return returnList; } @@ -313,7 +313,7 @@ public class TableContentLayoutManager implements PercentBaseContext { int col = gu.getColIndex(); return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM()); } - + /** * Adds the areas generated by this layout manager to the area tree. * @param parentIter the position iterator @@ -358,7 +358,7 @@ public class TableContentLayoutManager implements PercentBaseContext { } } else if (pos instanceof TableHFPenaltyPosition) { //ignore for now, see special handling below if break is at a penalty - //Only if the last position in this part/page us such a position it will be used + //Only if the last position in this part/page us such a position it will be used } else if (pos instanceof TableContentPosition) { tablePositions.add(pos); } else { @@ -376,23 +376,23 @@ public class TableContentLayoutManager implements PercentBaseContext { headerElements = penaltyPos.headerElements; } if (penaltyPos.footerElements != null) { - footerElements = penaltyPos.footerElements; + footerElements = penaltyPos.footerElements; } } Map markers = getTableLM().getTable().getMarkers(); if (markers != null) { - getTableLM().getCurrentPV().addMarkers(markers, + getTableLM().getCurrentPV().addMarkers(markers, true, getTableLM().isFirst(firstPos), getTableLM().isLast(lastCheckPos)); } - + if (headerElements != null) { //header positions for the last part are the second-to-last element and need to //be handled first before all other TableContentPositions addHeaderFooterAreas(headerElements, tableLM.getTable().getTableHeader(), painter, false); } - + if (tablePositions.isEmpty()) { // TODO make sure this actually never happens log.error("tablePositions empty." @@ -407,11 +407,11 @@ public class TableContentLayoutManager implements PercentBaseContext { addHeaderFooterAreas(footerElements, tableLM.getTable().getTableFooter(), painter, true); } - + this.usedBPD += painter.getAccumulatedBPD(); if (markers != null) { - getTableLM().getCurrentPV().addMarkers(markers, + getTableLM().getCurrentPV().addMarkers(markers, false, getTableLM().isFirst(firstPos), getTableLM().isLast(lastCheckPos)); } } @@ -435,7 +435,7 @@ public class TableContentLayoutManager implements PercentBaseContext { /** * Iterates over the positions corresponding to the table's body (which may contain * several table-body elements!) and adds the corresponding areas. - * + * * @param iterator iterator over TableContentPosition elements. Those positions * correspond to the elements of the body present on the current page * @param painter @@ -472,13 +472,13 @@ public class TableContentLayoutManager implements PercentBaseContext { */ private void addTablePartAreas(List positions, RowPainter painter, TablePart body, boolean isFirstPos, boolean isLastPos, boolean lastInBody, boolean lastOnPage) { - getTableLM().getCurrentPV().addMarkers(body.getMarkers(), + getTableLM().getCurrentPV().addMarkers(body.getMarkers(), true, isFirstPos, isLastPos); painter.startTablePart(body); for (Iterator iter = positions.iterator(); iter.hasNext();) { painter.handleTableContentPosition((TableContentPosition) iter.next()); } - getTableLM().getCurrentPV().addMarkers(body.getMarkers(), + getTableLM().getCurrentPV().addMarkers(body.getMarkers(), false, isFirstPos, isLastPos); painter.endTablePart(lastInBody, lastOnPage); } @@ -501,7 +501,7 @@ public class TableContentLayoutManager implements PercentBaseContext { // --------- Property Resolution related functions --------- // /** - * {@inheritDoc} + * {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { return tableLM.getBaseLength(lengthBase, fobj); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java index 62d25fcb1..457cfaef3 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java @@ -64,7 +64,7 @@ class TableContentPosition extends Position { * Sets the row corresponding to this position if it starts a new page. In which case, * if the delay mechanism is on, this is the delayed row that starts the page, and not * the current row being extended. - * + * * @param newPageRow the row that will start the page if this position is the first * one on that page */ diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index d370dc37f..143c63bb9 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -59,15 +59,15 @@ import org.apache.fop.util.BreakUtil; * The table then creates areas for the columns, bodies and rows * the render background. */ -public class TableLayoutManager extends BlockStackingLayoutManager +public class TableLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** * logging instance */ private static Log log = LogFactory.getLog(TableLayoutManager.class); - - private TableContentLayoutManager contentLM; + + private TableContentLayoutManager contentLM; private ColumnSetup columns = null; private Block curBlockArea; @@ -81,7 +81,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager private boolean discardPaddingAfter; private MinOptMax effSpaceBefore; private MinOptMax effSpaceAfter; - + private int halfBorderSeparationBPD; private int halfBorderSeparationIPD; @@ -90,7 +90,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** * Temporary holder of column background informations for a table-cell's area. - * + * * @see TableLayoutManager#registerColumnBackgroundArea(TableColumn, Block, int) */ private static final class ColumnBackgroundInfo { @@ -118,14 +118,14 @@ public class TableLayoutManager extends BlockStackingLayoutManager public Table getTable() { return (Table)this.fobj; } - + /** * @return the column setup for this table. */ public ColumnSetup getColumns() { return this.columns; } - + /** {@inheritDoc} */ public void initialize() { foSpaceBefore = new SpaceVal( @@ -133,8 +133,8 @@ public class TableLayoutManager extends BlockStackingLayoutManager foSpaceAfter = new SpaceVal( getTable().getCommonMarginBlock().spaceAfter, this).getSpace(); startIndent = getTable().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getTable().getCommonMarginBlock().endIndent.getValue(this); - + endIndent = getTable().getCommonMarginBlock().endIndent.getValue(this); + if (getTable().isSeparateBorderModel()) { this.halfBorderSeparationBPD = getTable().getBorderSeparation().getBPD().getLength() .getValue(this) / 2; @@ -144,23 +144,23 @@ public class TableLayoutManager extends BlockStackingLayoutManager this.halfBorderSeparationBPD = 0; this.halfBorderSeparationIPD = 0; } - - if (!getTable().isAutoLayout() - && getTable().getInlineProgressionDimension().getOptimum(this).getEnum() + + if (!getTable().isAutoLayout() + && getTable().getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) { autoLayout = false; } } private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; } - + /** * @return half the value of border-separation.block-progression-dimension, or 0 if * border-collapse="collapse". @@ -179,7 +179,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - + List returnList = new LinkedList(); /* @@ -201,7 +201,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager int sumOfColumns = columns.getSumOfColumnWidths(this); if (!autoLayout && sumOfColumns > getContentAreaIPD()) { log.debug(FONode.decorateWithContextInfo( - "The sum of all column widths is larger than the specified table width.", + "The sum of all column widths is larger than the specified table width.", getTable())); updateContentAreaIPDwithOverconstrainedAdjust(sumOfColumns); } @@ -213,7 +213,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager getContentAreaIPD(), context.getRefIPD(), getTable().getLocator()); } - + /* initialize unit to determine computed values * for proportional-column-width() */ @@ -224,7 +224,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager if (!firstVisibleMarkServed) { addKnuthElementsForSpaceBefore(returnList, alignment); } - + if (getTable().isSeparateBorderModel()) { addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); firstVisibleMarkServed = true; @@ -279,7 +279,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager int breakAfter = BreakUtil.compareBreakClasses(getTable().getBreakAfter(), childLC.getBreakAfter()); if (breakAfter != Constants.EN_AUTO) { - returnList.add(new BreakElement(getAuxiliaryPosition(), + returnList.add(new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakAfter, context)); } @@ -295,7 +295,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager * be known. The traits can't then be set when the areas for the cell are created * since at that moment this bpd is yet unknown. So they will instead be set in * TableLM's {@link #addAreas(PositionIterator, LayoutContext)} method. - * + * * @param column the table-column element from which the cell gets background * informations * @param backgroundArea the block of the cell's dimensions that will hold the column @@ -329,7 +329,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager } int startXOffset = getTable().getCommonMarginBlock().startIndent.getValue(this); - + // add column, body then row areas // BPD of the table, i.e., height of its content; table's borders and paddings not counted @@ -357,30 +357,30 @@ public class TableLayoutManager extends BlockStackingLayoutManager } if (getTable().isSeparateBorderModel()) { - TraitSetter.addBorders(curBlockArea, - getTable().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(curBlockArea, + getTable().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(curBlockArea, - getTable().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(curBlockArea, + getTable().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); } - TraitSetter.addBackground(curBlockArea, + TraitSetter.addBackground(curBlockArea, getTable().getCommonBorderPaddingBackground(), this); TraitSetter.addMargins(curBlockArea, - getTable().getCommonBorderPaddingBackground(), + getTable().getCommonBorderPaddingBackground(), startIndent, endIndent, this); - TraitSetter.addBreaks(curBlockArea, + TraitSetter.addBreaks(curBlockArea, getTable().getBreakBefore(), getTable().getBreakAfter()); - TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); resetSpaces(); curBlockArea = null; - + notifyEndOfLayout(); } @@ -403,11 +403,11 @@ public class TableLayoutManager extends BlockStackingLayoutManager // Set up dimensions // Must get dimensions from parent area /*Area parentArea =*/ parentLM.getParentArea(curBlockArea); - + TraitSetter.setProducerID(curBlockArea, getTable().getId()); curBlockArea.setIPD(getContentAreaIPD()); - + setCurrentArea(curBlockArea); } return curBlockArea; @@ -426,7 +426,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** * Adds the given area to this layout manager's area, without updating the used bpd. - * + * * @param background an area */ void addBackgroundArea(Block background) { @@ -442,7 +442,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public void discardSpace(KnuthGlue spaceGlue) { // TODO Auto-generated method stub - + } /** {@inheritDoc} */ @@ -451,7 +451,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KeepUtil.getCombinedBlockLevelKeepStrength(getTable().getKeepWithNext()); @@ -465,7 +465,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager // --------- Property Resolution related functions --------- // /** - * {@inheritDoc} + * {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { // Special handler for TableColumn width specifications @@ -488,18 +488,18 @@ public class TableLayoutManager extends BlockStackingLayoutManager } } } - + /** {@inheritDoc} */ public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 6aa619368..a3fba279e 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -83,7 +83,7 @@ public class TableStepper { /** * Flag used to produce an infinite penalty if the height of the current row is * smaller than the first step for that row (may happen with row-spanning cells). - * + * * @see #considerRowLastStep(int) */ private boolean rowHeightSmallerThanFirstStep; @@ -107,7 +107,7 @@ public class TableStepper { /** * Initializes the fields of this instance to handle a new row group. - * + * * @param rows the new row group to handle */ private void setup(EffRow[] rows) { @@ -151,7 +151,7 @@ public class TableStepper { /** * Creates ActiveCell instances for cells starting on the row at the given index. - * + * * @param activeCellList the list that will hold the active cells * @param rowIndex the index of the row from which cells must be activated */ @@ -289,7 +289,7 @@ public class TableStepper { /** * Returns the first step for the current row group. - * + * * @return the first step for the current row group */ private int getFirstStep() { @@ -302,7 +302,7 @@ public class TableStepper { /** * Returns the next break possibility. - * + * * @return the next step */ private int getNextStep() { @@ -342,7 +342,7 @@ public class TableStepper { /** * Computes the minimal necessary step to make the next row fit. That is, so such as * cell on the next row can contribute some content. - * + * * @param cells the cells occupying the next row (may include cells starting on * previous rows and spanning over this one) */ @@ -355,7 +355,7 @@ public class TableStepper { /** * Computes the next minimal step. - * + * * @return the minimal step from the active cells, < 0 if there is no such step */ private int computeMinStep() { @@ -379,7 +379,7 @@ public class TableStepper { /** * Signals the first step to the active cells, to allow them to add more content to * the step if possible. - * + * * @see ActiveCell#signalRowFirstStep(int) */ private void signalRowFirstStep() { @@ -391,7 +391,7 @@ public class TableStepper { /** * Signals the next selected step to the active cells. - * + * * @param step the next step */ private void signalNextStep(int step) { @@ -416,7 +416,7 @@ public class TableStepper { * infinite penalty for this step. This will prevent the breaking algorithm from * choosing this break, but still allow to create the appropriate TableContentPosition * for the cells ending on the current row.</p> - * + * * @param step the next step * @return the updated step if any */ @@ -445,7 +445,7 @@ public class TableStepper { } for (Iterator iter = activeCells.iterator(); iter.hasNext();) { ActiveCell activeCell = (ActiveCell) iter.next(); - activeCell.endRow(activeRowIndex); + activeCell.endRow(activeRowIndex); if (!activeCell.endsOnRow(activeRowIndex)) { activeCell.signalRowLastStep(maxStep); } |