Browse Source

FOP-2394: Removed non-standard layout extensions


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1614306 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-2_0
Vincent Hennebert 10 years ago
parent
commit
cfee3a4ddb

+ 70
- 76
src/java/org/apache/fop/fo/Constants.java View File

@@ -760,74 +760,72 @@ public interface Constants {
int PR_XML_LANG = 268;
/** Property constant */
int PR_Z_INDEX = 269;
/** Property constant - FOP proprietary: Custom extension for line alignment */
int PR_X_BLOCK_PROGRESSION_UNIT = 270;
/** Property constant - FOP proprietary: limit for widow content in lists and tables */
int PR_X_WIDOW_CONTENT_LIMIT = 271;
int PR_X_WIDOW_CONTENT_LIMIT = 270;
/** Property constant - FOP proprietary: limit for orphan content in lists and tables */
int PR_X_ORPHAN_CONTENT_LIMIT = 272;
int PR_X_ORPHAN_CONTENT_LIMIT = 271;
/**
* Property constant - FOP proprietary: disable balancing of columns in
* multi-column layouts.
*/
int PR_X_DISABLE_COLUMN_BALANCING = 273;
int PR_X_DISABLE_COLUMN_BALANCING = 272;
/**
* Property constant - FOP proprietary: alternative text for e-g and i-f-o.
* Used for accessibility.
*/
int PR_X_ALT_TEXT = 274;
int PR_X_ALT_TEXT = 273;
/** Property constant - FOP proprietary prototype (in XSL-FO 2.0 Requirements) */
int PR_X_XML_BASE = 275;
int PR_X_XML_BASE = 274;

/** Property constant FOP proprietary*/
int PR_X_BORDER_BEFORE_RADIUS_START = 276;
int PR_X_BORDER_BEFORE_RADIUS_START = 275;
/** Property constant FOP proprietary*/
int PR_X_BORDER_BEFORE_RADIUS_END = 277;
int PR_X_BORDER_BEFORE_RADIUS_END = 276;
/** Property constant FOP proprietary*/
int PR_X_BORDER_AFTER_RADIUS_START = 278;
int PR_X_BORDER_AFTER_RADIUS_START = 277;
/** Property constant FOP proprietary*/
int PR_X_BORDER_AFTER_RADIUS_END = 279;
int PR_X_BORDER_AFTER_RADIUS_END = 278;
/** Property constant FOP proprietary*/
int PR_X_BORDER_START_RADIUS_BEFORE = 280;
int PR_X_BORDER_START_RADIUS_BEFORE = 279;
/** Property constant FOP proprietary*/
int PR_X_BORDER_START_RADIUS_AFTER = 281;
int PR_X_BORDER_START_RADIUS_AFTER = 280;
/** Property constant FOP proprietary*/
int PR_X_BORDER_END_RADIUS_BEFORE = 282;
int PR_X_BORDER_END_RADIUS_BEFORE = 281;
/** Property constant FOP proprietary*/
int PR_X_BORDER_END_RADIUS_AFTER = 283;
int PR_X_BORDER_END_RADIUS_AFTER = 282;
/** Property constant FOP proprietary*/
int PR_X_BORDER_RADIUS = 284;
int PR_X_BORDER_RADIUS = 283;
/** Property constant FOP proprietary*/
int PR_X_BORDER_BEFORE_START_RADIUS = 285;
int PR_X_BORDER_BEFORE_START_RADIUS = 284;
/** Property constant FOP proprietary*/
int PR_X_BORDER_BEFORE_END_RADIUS = 286;
int PR_X_BORDER_BEFORE_END_RADIUS = 285;
/** Property constant FOP proprietary*/
int PR_X_BORDER_AFTER_START_RADIUS = 287;
int PR_X_BORDER_AFTER_START_RADIUS = 286;
/** Property constant FOP proprietary*/
int PR_X_BORDER_AFTER_END_RADIUS = 288;
int PR_X_BORDER_AFTER_END_RADIUS = 287;

/**
* Property constant - FOP proprietary extension (see NumberConverter) used
* to perform additional control over number conversion when generating page
* numbers.
*/
int PR_X_NUMBER_CONVERSION_FEATURES = 289;
int PR_X_NUMBER_CONVERSION_FEATURES = 288;

/** Scope for table header */
int PR_X_HEADER_COLUMN = 290;
int PR_X_HEADER_COLUMN = 289;

/** For specifying PDF optional content group (layer) binding. */
int PR_X_LAYER = 291;
int PR_X_LAYER = 290;

/** Property constant */
int PR_X_AUTO_TOGGLE = 292;
int PR_X_AUTO_TOGGLE = 291;

/** Used for scaling of background images */
int PR_X_BACKGROUND_IMAGE_WIDTH = 293;
int PR_X_BACKGROUND_IMAGE_HEIGHT = 294;
int PR_X_BACKGROUND_IMAGE_WIDTH = 292;
int PR_X_BACKGROUND_IMAGE_HEIGHT = 293;

/** Number of property constants defined */
int PROPERTY_COUNT = 294;
int PROPERTY_COUNT = 293;

// compound property constants

@@ -1177,98 +1175,94 @@ public interface Constants {
int EN_WIDER = 160;
/** Enumeration constant */
int EN_WRAP = 161;
/** Enumeration constant - non-standard for display-align */
int EN_X_FILL = 162;
/** Enumeration constant - non-standard for display-align */
int EN_X_DISTRIBUTE = 163;
/** Enumeration constant */
int EN_ITALIC = 164;
int EN_ITALIC = 162;
/** Enumeration constant */
int EN_OBLIQUE = 165;
int EN_OBLIQUE = 163;
/** Enumeration constant */
int EN_BACKSLANT = 166;
int EN_BACKSLANT = 164;
/** Enumeration constant */
int EN_BOLDER = 167;
int EN_BOLDER = 165;
/** Enumeration constant */
int EN_LIGHTER = 168;
int EN_LIGHTER = 166;
/** Enumeration constant */
int EN_100 = 169;
int EN_100 = 167;
/** Enumeration constant */
int EN_200 = 170;
int EN_200 = 168;
/** Enumeration constant */
int EN_300 = 171;
int EN_300 = 169;
/** Enumeration constant */
int EN_400 = 172;
int EN_400 = 170;
/** Enumeration constant */
int EN_500 = 173;
int EN_500 = 171;
/** Enumeration constant */
int EN_600 = 174;
int EN_600 = 172;
/** Enumeration constant */
int EN_700 = 175;
int EN_700 = 173;
/** Enumeration constant */
int EN_800 = 176;
int EN_800 = 174;
/** Enumeration constant */
int EN_900 = 177;
int EN_900 = 175;
/** Enumeration constant -- page-break-shorthand */
int EN_AVOID = 178;
int EN_AVOID = 176;
/** Enumeration constant -- white-space shorthand */
int EN_PRE = 179;
int EN_PRE = 177;
/** Enumeration constant -- font shorthand */
int EN_CAPTION = 180;
int EN_CAPTION = 178;
/** Enumeration constant -- font shorthand */
int EN_ICON = 181;
int EN_ICON = 179;
/** Enumeration constant -- font shorthand */
int EN_MENU = 182;
int EN_MENU = 180;
/** Enumeration constant -- font shorthand */
int EN_MESSAGE_BOX = 183;
int EN_MESSAGE_BOX = 181;
/** Enumeration constant -- font shorthand */
int EN_SMALL_CAPTION = 184;
int EN_SMALL_CAPTION = 182;
/** Enumeration constant -- font shorthand */
int EN_STATUS_BAR = 185;
int EN_STATUS_BAR = 183;
/** Enumeration constant -- for page-position, XSL 1.1 */
int EN_ONLY = 186;
int EN_ONLY = 184;
/** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
int EN_SCALE_DOWN_TO_FIT = 187;
int EN_SCALE_DOWN_TO_FIT = 185;
/** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
int EN_SCALE_UP_TO_FIT = 188;
int EN_SCALE_UP_TO_FIT = 186;
/** Enumeration constant -- for fo:basic-link show-destination */
int EN_REPLACE = 189;
int EN_REPLACE = 187;
/** Enumeration constant -- for fo:basic-link show-destination */
int EN_NEW = 190;
int EN_NEW = 188;
/** Enumeration constant -- for fo:retrieve-table-marker */
int EN_FIRST_STARTING = 191;
int EN_FIRST_STARTING = 189;
/** Enumeration constant -- for fo:retrieve-table-marker */
int EN_LAST_STARTING = 192;
int EN_LAST_STARTING = 190;
/** Enumeration constant -- for fo:retrieve-table-marker */
int EN_LAST_ENDING = 193;
int EN_LAST_ENDING = 191;
/** Enumeration constant -- for fo:retrieve-table-marker */
int EN_TABLE = 194;
int EN_TABLE = 192;
/** Enumeration constant -- for fo:retrieve-table-marker */
int EN_TABLE_FRAGMENT = 195;
int EN_TABLE_FRAGMENT = 193;
/** Enumeration constant -- XSL 1.1 */
int EN_MERGE = 196;
int EN_MERGE = 194;
/** Enumeration constant -- XSL 1.1 */
int EN_LEAVE_SEPARATE = 197;
int EN_LEAVE_SEPARATE = 195;
/** Enumeration constant -- XSL 1.1 */
int EN_LINK = 198;
int EN_LINK = 196;
/** Enumeration constant -- XSL 1.1 */
int EN_NO_LINK = 199;
int EN_NO_LINK = 197;
/** Enumeration constant -- XSL 1.1 */
int EN_ALTERNATE = 200;
int EN_ALTERNATE = 198;
/** Enumeration constant -- for *-direction traits */
int EN_LR = 201; // left to right
int EN_LR = 199; // left to right
/** Enumeration constant -- for *-direction traits */
int EN_RL = 202; // right to left
int EN_RL = 200; // right to left
/** Enumeration constant -- for *-direction traits */
int EN_TB = 203; // top to bottom
int EN_TB = 201; // top to bottom
/** Enumeration constant -- for *-direction traits */
int EN_BT = 204; // bottom to top
int EN_BT = 202; // bottom to top
/** Enumeration constant */
int EN_TB_LR = 205; // for top-to-bottom, left-to-right writing mode
int EN_TB_LR = 203; // for top-to-bottom, left-to-right writing mode
/** Enumeration constant -- for fo:retrieve-table-marker */
int EN_FIRST_INCLUDING_CARRYOVER = 206;
int EN_FIRST_INCLUDING_CARRYOVER = 204;
/** Enumeration constant -- for auto-toggle */
int EN_SELECT_FIRST_FITTING = 207;
int EN_SELECT_FIRST_FITTING = 205;
/** Number of enumeration constants defined */
int ENUM_COUNT = 207;
int ENUM_COUNT = 205;
}

+ 0
- 8
src/java/org/apache/fop/fo/FOPropertyMapping.java View File

@@ -1300,8 +1300,6 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("after", getEnumProperty(EN_AFTER, "AFTER"));
m.addEnum("center", getEnumProperty(EN_CENTER, "CENTER"));
m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
/*LF*/ m.addEnum("distribute", getEnumProperty(EN_X_DISTRIBUTE, "DISTRIBUTE"));
/*LF*/ m.addEnum("fill", getEnumProperty(EN_X_FILL, "FILL"));
m.setDefault("auto");
addPropertyMaker("display-align", m);

@@ -1496,12 +1494,6 @@ public final class FOPropertyMapping implements Constants {
l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
l.setDefault("auto");
addPropertyMaker("width", l);

// fox:block-progression-unit (**CUSTOM EXTENSION**)
l = new LengthProperty.Maker(PR_X_BLOCK_PROGRESSION_UNIT);
l.setInherited(false);
l.setDefault("0pt");
addPropertyMaker("fox:block-progression-unit", l);
}

private Property calcWritingModeDependent(int pv, int wm) {

+ 11
- 333
src/java/org/apache/fop/layoutmgr/AbstractBreaker.java View File

@@ -161,18 +161,12 @@ public abstract class AbstractBreaker {
if (this.size() > ignoreAtStart) {
// 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,
false, breakPosition, false));
ignoreAtEnd = 1;
} else {
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,
false, breakPosition, false));
ignoreAtEnd = 3;
}
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,
false, breakPosition, false));
ignoreAtEnd = 3;
return this;
} else {
this.clear();
@@ -359,20 +353,8 @@ public abstract class AbstractBreaker {
public void doLayout(int flowBPD, boolean autoHeight) {
LayoutContext childLC = createLayoutContext();
childLC.setStackLimitBP(MinOptMax.getInstance(flowBPD));

if (getCurrentDisplayAlign() == Constants.EN_X_FILL) {
//EN_X_FILL is non-standard (by LF)
alignment = Constants.EN_JUSTIFY;
} else if (getCurrentDisplayAlign() == Constants.EN_X_DISTRIBUTE) {
//EN_X_DISTRIBUTE is non-standard (by LF)
alignment = Constants.EN_JUSTIFY;
} else {
alignment = Constants.EN_START;
}
alignment = Constants.EN_START;
alignmentLast = Constants.EN_START;
if (isSinglePartFavored() && alignment == Constants.EN_JUSTIFY) {
alignmentLast = Constants.EN_JUSTIFY;
}
childLC.setBPAlignment(alignment);

BlockSequence blockList;
@@ -409,32 +391,23 @@ public abstract class AbstractBreaker {
alignment, alignmentLast, footnoteSeparatorLength,
isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored());

BlockSequence effectiveList;
if (getCurrentDisplayAlign() == Constants.EN_X_FILL) {
/* justification */
effectiveList = justifyBoxes(blockList, alg, flowBPD);
} else {
/* no justification */
effectiveList = blockList;
}

alg.setConstantLineWidth(flowBPD);
int optimalPageCount = alg.findBreakingPoints(effectiveList, 1, true,
int optimalPageCount = alg.findBreakingPoints(blockList, 1, true,
BreakingAlgorithm.ALL_BREAKS);
if (Math.abs(alg.getIPDdifference()) > 1) {
addAreas(alg, optimalPageCount, blockList, effectiveList);
addAreas(alg, optimalPageCount, blockList, blockList);
// *** redo Phase 1 ***
log.trace("IPD changes after page " + optimalPageCount);
blockLists.clear();
nextSequenceStartsOn = getNextBlockListChangedIPD(childLC, alg,
effectiveList);
blockList);
blockListIndex = -1;
} else {
log.debug("PLM> optimalPageCount= " + optimalPageCount
+ " pageBreaks.size()= " + alg.getPageBreaks().size());

//*** Phase 3: Add areas ***
doPhase3(alg, optimalPageCount, blockList, effectiveList);
doPhase3(alg, optimalPageCount, blockList, blockList);
}
}
}
@@ -580,34 +553,7 @@ public abstract class AbstractBreaker {
childLC.setSpaceBefore(pbp.difference / 2);
} else if (pbp.difference != 0 && displayAlign == Constants.EN_AFTER) {
childLC.setSpaceBefore(pbp.difference);
} else if (pbp.difference != 0 && displayAlign == Constants.EN_X_DISTRIBUTE
&& p < (partCount - 1)) {
// count the boxes whose width is not 0
int boxCount = 0;
@SuppressWarnings("unchecked")
ListIterator<KnuthElement> effectiveListIterator = effectiveList
.listIterator(startElementIndex);
while (effectiveListIterator.nextIndex() <= endElementIndex) {
KnuthElement tempEl = effectiveListIterator.next();
if (tempEl.isBox() && tempEl.getWidth() > 0) {
boxCount++;
}
}
// split the difference
if (boxCount >= 2) {
childLC.setSpaceAfter(pbp.difference / (boxCount - 1));
}
}

/* *** *** non-standard extension *** *** */
if (displayAlign == Constants.EN_X_FILL) {
int averageLineLength = optimizeLineLength(effectiveList,
startElementIndex, endElementIndex);
if (averageLineLength != 0) {
childLC.setStackLimitBP(MinOptMax.getInstance(averageLineLength));
}
}
/* *** *** non-standard extension *** *** */

// Handle SpaceHandling(Break)Positions, see SpaceResolver!
SpaceResolver.performConditionalsNotification(effectiveList,
@@ -825,272 +771,4 @@ public abstract class AbstractBreaker {
return nextSequenceStartsOn;
}

/**
* Returns the average width of all the lines in the given range.
* @param effectiveList effective block list to work on
* @param startElementIndex index of the element starting the range
* @param endElementIndex index of the element ending the range
* @return the average line length, 0 if there's no content
*/
private int optimizeLineLength(KnuthSequence effectiveList, int startElementIndex,
int endElementIndex) {
ListIterator<KnuthElement> effectiveListIterator;
// optimize line length
int boxCount = 0;
int accumulatedLineLength = 0;
int greatestMinimumLength = 0;
effectiveListIterator = effectiveList.listIterator(startElementIndex);
while (effectiveListIterator.nextIndex() <= endElementIndex) {
KnuthElement tempEl = effectiveListIterator
.next();
if (tempEl instanceof KnuthBlockBox) {
KnuthBlockBox blockBox = (KnuthBlockBox) tempEl;
if (blockBox.getBPD() > 0) {
log.debug("PSLM> nominal length of line = " + blockBox.getBPD());
log.debug(" range = "
+ blockBox.getIPDRange());
boxCount++;
accumulatedLineLength += ((KnuthBlockBox) tempEl)
.getBPD();
}
if (blockBox.getIPDRange().getMin() > greatestMinimumLength) {
greatestMinimumLength = blockBox
.getIPDRange().getMin();
}
}
}
int averageLineLength = 0;
if (accumulatedLineLength > 0 && boxCount > 0) {
averageLineLength = accumulatedLineLength / boxCount;
log.debug("Average line length = " + averageLineLength);
if (averageLineLength < greatestMinimumLength) {
averageLineLength = greatestMinimumLength;
log.debug(" Correction to: " + averageLineLength);
}
}
return averageLineLength;
}

/**
* 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
* @return the effective list
*/
private BlockSequence justifyBoxes(
BlockSequence blockList, PageBreakingAlgorithm alg, int availableBPD) {
int optimalPageCount;
alg.setConstantLineWidth(availableBPD);
optimalPageCount = alg.findBreakingPoints(blockList, /*availableBPD,*/
1, true, BreakingAlgorithm.ALL_BREAKS);
log.debug("PLM> optimalPageCount= " + optimalPageCount);

//
ListIterator<KnuthElement> sequenceIterator = blockList.listIterator();
ListIterator<PageBreakPosition> breakIterator = alg.getPageBreaks().listIterator();
KnuthElement thisElement = null;
PageBreakPosition thisBreak;
int adjustedDiff; // difference already adjusted

while (breakIterator.hasNext()) {
thisBreak = breakIterator.next();
if (log.isDebugEnabled()) {
log.debug("| first page: break= "
+ thisBreak.getLeafPos() + " difference= "
+ thisBreak.difference + " ratio= "
+ thisBreak.bpdAdjust);
}
adjustedDiff = 0;

// glue and penalty items at the beginning of the page must
// be ignored:
// the first element returned by sequenceIterator.next()
// inside the
// while loop must be a box
KnuthElement firstElement;
while (sequenceIterator.hasNext()) {
firstElement = sequenceIterator.next();
if (!firstElement.isBox()) {
log.debug("PLM> ignoring glue or penalty element "
+ "at the beginning of the sequence");
if (firstElement.isGlue()) {
((BlockLevelLayoutManager) firstElement
.getLayoutManager())
.discardSpace((KnuthGlue) firstElement);
}
} else {
break;
}
}
sequenceIterator.previous();

// scan the sub-sequence representing a page,
// collecting information about potential adjustments
MinOptMax lineNumberMaxAdjustment = MinOptMax.ZERO;
MinOptMax spaceMaxAdjustment = MinOptMax.ZERO;
LinkedList<KnuthGlue> blockSpacesList = new LinkedList<KnuthGlue>();
LinkedList<KnuthGlue> unconfirmedList = new LinkedList<KnuthGlue>();
LinkedList<KnuthGlue> adjustableLinesList = new LinkedList<KnuthGlue>();
boolean bBoxSeen = false;
while (sequenceIterator.hasNext()
&& sequenceIterator.nextIndex() <= thisBreak.getLeafPos()) {
thisElement = sequenceIterator.next();
if (thisElement.isGlue()) {
// glue elements are used to represent adjustable
// lines
// and adjustable spaces between blocks
KnuthGlue thisGlue = (KnuthGlue) thisElement;
Adjustment adjustment = thisGlue.getAdjustmentClass();
if (adjustment.equals(Adjustment.SPACE_BEFORE_ADJUSTMENT)
|| adjustment.equals(Adjustment.SPACE_AFTER_ADJUSTMENT)) {
// potential space adjustment
// glue items before the first box or after the
// last one
// must be ignored
unconfirmedList.add(thisGlue);
} else if (adjustment.equals(Adjustment.LINE_NUMBER_ADJUSTMENT)) {
// potential line number adjustment
lineNumberMaxAdjustment
= lineNumberMaxAdjustment.plusMax(thisElement.getStretch());
lineNumberMaxAdjustment
= lineNumberMaxAdjustment.minusMin(thisElement.getShrink());
adjustableLinesList.add(thisGlue);
} else if (adjustment.equals(Adjustment.LINE_HEIGHT_ADJUSTMENT)) {
// potential line height adjustment
}
} else if (thisElement.isBox()) {
if (!bBoxSeen) {
// this is the first box met in this page
bBoxSeen = true;
} else {
while (!unconfirmedList.isEmpty()) {
// glue items in unconfirmedList were not after
// the last box
// in this page; they must be added to
// blockSpaceList
KnuthGlue blockSpace = unconfirmedList.removeFirst();
spaceMaxAdjustment
= spaceMaxAdjustment.plusMax(blockSpace.getStretch());
spaceMaxAdjustment
= spaceMaxAdjustment.minusMin(blockSpace.getShrink());
blockSpacesList.add(blockSpace);
}
}
}
}
log.debug("| line number adj= "
+ lineNumberMaxAdjustment);
log.debug("| space adj = "
+ spaceMaxAdjustment);

if (thisElement.isPenalty() && thisElement.getWidth() > 0) {
log.debug(" mandatory variation to the number of lines!");
((BlockLevelLayoutManager) thisElement
.getLayoutManager()).negotiateBPDAdjustment(
thisElement.getWidth(), thisElement);
}

if (thisBreak.bpdAdjust != 0
&& (thisBreak.difference > 0 && thisBreak.difference <= spaceMaxAdjustment
.getMax())
|| (thisBreak.difference < 0 && thisBreak.difference >= spaceMaxAdjustment
.getMin())) {
// modify only the spaces between blocks
adjustedDiff += adjustBlockSpaces(
blockSpacesList,
thisBreak.difference,
(thisBreak.difference > 0 ? spaceMaxAdjustment.getMax()
: -spaceMaxAdjustment.getMin()));
log.debug("single space: "
+ (adjustedDiff == thisBreak.difference
|| thisBreak.bpdAdjust == 0 ? "ok"
: "ERROR"));
} else if (thisBreak.bpdAdjust != 0) {
adjustedDiff += adjustLineNumbers(
adjustableLinesList,
thisBreak.difference,
(thisBreak.difference > 0 ? lineNumberMaxAdjustment.getMax()
: -lineNumberMaxAdjustment.getMin()));
adjustedDiff += adjustBlockSpaces(
blockSpacesList,
thisBreak.difference - adjustedDiff,
((thisBreak.difference - adjustedDiff) > 0 ? spaceMaxAdjustment.getMax()
: -spaceMaxAdjustment.getMin()));
log.debug("lines and space: "
+ (adjustedDiff == thisBreak.difference
|| thisBreak.bpdAdjust == 0 ? "ok"
: "ERROR"));

}
}

// 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(),
blockList.getDisplayAlign());
effectiveList.addAll(getCurrentChildLM().getChangedKnuthElements(
blockList.subList(0, blockList.size() - blockList.ignoreAtEnd),
/* 0, */0));
//effectiveList.add(new KnuthPenalty(0, -KnuthElement.INFINITE,
// false, new Position(this), false));
effectiveList.endSequence();

ElementListObserver.observe(effectiveList, "breaker-effective", null);

alg.getPageBreaks().clear(); //Why this?
return effectiveList;
}

private int adjustBlockSpaces(LinkedList<KnuthGlue> spaceList, int difference, int total) {
if (log.isDebugEnabled()) {
log.debug("AdjustBlockSpaces: difference " + difference + " / " + total
+ " on " + spaceList.size() + " spaces in block");
}
ListIterator<KnuthGlue> spaceListIterator = spaceList.listIterator();
int adjustedDiff = 0;
int partial = 0;
while (spaceListIterator.hasNext()) {
KnuthGlue blockSpace = spaceListIterator.next();
partial += (difference > 0 ? blockSpace.getStretch() : blockSpace.getShrink());
if (log.isDebugEnabled()) {
log.debug("available = " + partial + " / " + total);
log.debug("competenza = "
+ (((int)((float) partial * difference / total)) - adjustedDiff)
+ " / " + difference);
}
int newAdjust = ((BlockLevelLayoutManager) blockSpace.getLayoutManager())
.negotiateBPDAdjustment(
((int) ((float) partial * difference / total)) - adjustedDiff, blockSpace);
adjustedDiff += newAdjust;
}
return adjustedDiff;
}

private int adjustLineNumbers(LinkedList<KnuthGlue> lineList, int difference, int total) {
if (log.isDebugEnabled()) {
log.debug("AdjustLineNumbers: difference "
+ difference
+ " / "
+ total
+ " on "
+ lineList.size()
+ " elements");
}

ListIterator<KnuthGlue> lineListIterator = lineList.listIterator();
int adjustedDiff = 0;
int partial = 0;
while (lineListIterator.hasNext()) {
KnuthGlue line = lineListIterator.next();
partial += (difference > 0 ? line.getStretch() : line.getShrink());
int newAdjust = ((BlockLevelLayoutManager) line.getLayoutManager())
.negotiateBPDAdjustment(
((int) ((float) partial * difference / total)) - adjustedDiff, line);
adjustedDiff += newAdjust;
}
return adjustedDiff;
}

}

+ 0
- 109
test/layoutengine/standard-testcases/block-container_display-align_distribute.xml View File

@@ -1,109 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
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.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<testcase>
<info>
<p>
This test checks display-align="distribute" (The value "distribute" is a proprietary extension to XSL-FO).
</p>
</info>
<fo>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
<fo:layout-master-set>
<fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
<fo:region-body column-count="4" column-gap="5pt"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="normal" white-space-collapse="true">
<fo:flow flow-name="xsl-region-body">
<fo:block-container width="100%" height="4.2in" display-align="distribute" background-color="yellow">
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
"distribute" 4.2in
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
<!-- last -->
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
</fo:block-container>
<fo:block-container width="100%" height="4.8in" display-align="distribute" background-color="yellow">
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
"distribute" 4.8in
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
<!-- last -->
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
</fo:block-container>
<fo:block-container width="100%" height="3.85in" display-align="distribute" background-color="yellow">
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
"distribute" 3.85in
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
<!-- last -->
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
</fo:block-container>
<fo:block-container width="100%" height="4.2in" display-align="auto" background-color="orange">
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
"auto"
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
<fo:block space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
<!-- last -->
Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1 Text 1
</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
</fo:root>
</fo>
<checks>
<!-- check with 3 mpt tolerance -->
<eval expected="0" xpath="//flow[1]/block[1]/@bpd - //flow[1]/block[1]/block[1]/@bpd" tolerance="3"/>
<eval expected="14400" xpath="//flow[2]/block[1]/@bpd - //flow[2]/block[1]/block[1]/@bpd" tolerance="3"/>
<eval expected="0" xpath="//flow[3]/block[1]/@bpd - //flow[3]/block[1]/block[1]/@bpd" tolerance="3"/>
<eval expected="21600" xpath="//flow[4]/block[1]/@bpd - //flow[4]/block[1]/block[1]/@bpd" tolerance="3"/>
</checks>
</testcase>

Loading…
Cancel
Save