From: Simon Steiner Date: Wed, 20 Jun 2018 11:32:05 +0000 (+0000) Subject: FOP-2799: Only reduce penalty if there is a existing break X-Git-Tag: fop-2_4~54 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ee143ede26953cd06b1ac5ce7a49d38086c85e1c;p=xmlgraphics-fop.git FOP-2799: Only reduce penalty if there is a existing break git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1833908 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 69b78c9bc..9d9769a7c 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -448,12 +448,9 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage // add the original line where the float was but without the float now returnList.add(new KnuthBlockBox(boxHeight, footnoteList, stepPosition, false)); } - if (originalBodyPosition != null) { - LayoutManager lm = originalBodyPosition.getLM(); - if ((lm instanceof ListBlockLayoutManager || lm instanceof BlockLayoutManager) - && getKeepWithPrevious().isAuto()) { - stepPenalty++; - } + if (originalBodyPosition != null && getKeepWithPrevious().isAuto() + && shouldWeAvoidBreak(returnList, originalBodyPosition.getLM())) { + stepPenalty++; } if (addedBoxHeight < totalHeight) { Keep keep = keepWithNextActive.compare(getKeepTogether()); @@ -469,6 +466,26 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage return returnList; } + private boolean shouldWeAvoidBreak(List returnList, LayoutManager lm) { + if (lm instanceof BlockLayoutManager) { + return true; + } + if (lm instanceof ListBlockLayoutManager) { + int penaltyShootout = 0; + for (Object o : returnList) { + if (o instanceof BreakElement) { + if (((BreakElement) o).getPenaltyValue() > 0) { + penaltyShootout++; + } else { + penaltyShootout--; + } + } + } + return penaltyShootout > 0; + } + return false; + } + private int getNextStep(List[] elementLists, int[] start, int[] end, int[] partialHeights) { // backup of partial heights int[] backupHeights = {partialHeights[0], partialHeights[1]}; diff --git a/fop/test/layoutengine/standard-testcases/flow_changing-ipd_list2.xml b/fop/test/layoutengine/standard-testcases/flow_changing-ipd_list2.xml new file mode 100644 index 000000000..ad06e9410 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/flow_changing-ipd_list2.xml @@ -0,0 +1,232 @@ + + + + + +

+ This test checks that blocks of texts are re-laid out after a change of the flow ipd. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + 4. + + + + Property Not Covered + We do not cover: + + + a. + + + Articles separately described and specifically insured, regardless of the limit for which they are insured, in this or other insurance; + + + + + b. + + + Animals, birds or fish; + + + + + c. + + + "Motor vehicles". This includes a "motor vehicle's" equipment and parts. However, this Paragraph 4.c. does not apply to: + + + (1) + + + Portable electronic equipment that: + + + (a) + + + Reproduces, receives or transmits audio, visual or data signals; and + + + + + (b) + + + Is designed so that it may be operated from a power source other than a "motor vehicle's" electrical system. + + + + + + + + + (2) + + + "Motor vehicles" not required to be registered for use on public roads or property which are: + + + (a) + + + Used solely to service a residence; or + + + + + (b) + + + Designed to assist the handicapped; + + + + + + + + + + + + + d. + + + Aircraft, meaning any contrivance used or designed for flight, including any parts whether or not attached to the aircraft. We do cover model or hobby aircraft not used or designed to carry people or cargo; + + + + + e. + + + Hovercraft and parts. Hovercraft means a self-propelled motorized ground effect vehicle and includes, but is not limited to, flarecraft and air cushion vehicles; + + + + + f. + + + Property of roomers, boarders and other tenants, except property of roomers and boarders related to an "insured"; + + + + + g. + + + Property in an apartment regularly rented or held for rental to others by an "insured"; + + + + + h. + + + Property rented or held for rental to others off the "residence premises"; + + + + + i. + + + "Business" data, including such data stored in: + + + (1) + + + Books of account, drawings or other paper records; or + + + + + (2) + + + Computers and related equipment. We do cover the cost of blank recording or storage media and of prerecorded computer programs available on the retail market; + + + + + + + + + j. + + + Credit cards, electronic fund transfer cards or access devices used solely for deposit, withdrawal or transfer of funds except as provided in D.6. Credit Card, Electronic Fund Transfer Card Or Access Device, Forgery And Counterfeit Money under Section I – Property Coverages; or + + + + + k. + + + Water or steam. + + + + + + + + + + + + + + + + + +
diff --git a/fop/test/layoutengine/standard-testcases/list-2-columns.xml b/fop/test/layoutengine/standard-testcases/list-2-columns.xml new file mode 100644 index 000000000..87126c3b4 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/list-2-columns.xml @@ -0,0 +1,352 @@ + + + + + +

+ This test checks number of words in each column +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + AGREEMENT + . + + + + DEFINITIONS + . + + + + + + + + AGREEMENT + + We agree to provide the insurance described in this policy: + + + + 1. + + + based on your payment of premium, in a form acceptable to us, for the coverages you chose; + + + + + 2. + + + based on your compliance with all applicable provisions of this policy; and + + + + + 3. + + + based on the information you have given us and your statements in this agreement. + + + + + You agree, by acceptance of this policy, that: + + + + 1. + + + + you will pay premiums when due and comply with the provisions of the policy; + + + + + 2. + + + the statements in this agreement are your + statements and are true; + + + + + 3. + + + + we insure you on the basis your + statements are true; and + + + + + 4. + + + this policy contains all of the agreements between you and us. + + + + + + + + + When you request changes to this policy, or the information or factors used to calculate the premium for this policy changes during the policy period, we may adjust the premium in accordance with the change during the policy period and you must pay any additional premium due within the time we specify. + DEFINITIONS + We define the following words and phrases for use throughout the policy. These definitions apply to the singular, plural, and possessive forms of these words and phrases. Defined words and phrases are printed in bold italics. + + + + 1 + + + "actual cash value” means the value of the damaged part of the property at the time of loss, calculated as the estimated cost to repair or replace such property, less a deduction to account for pre-loss depreciation. For this calculation, all components of this estimated cost including, but not limited to: + + + a. + + + materials, including tax; + + + + + b. + + + labor, including tax; and + + + + + c. + + + overhead and profit + + + + + + + + are subject to depreciation. + The depreciation deduction may include such considerations as: + + + + + + + + + + a. + + + age; + + + + + b. + + + condition; + + + + + c. + + + reduction + + + + + d. + + + obsolescence; and + + + + + e. + + + any pre-loss damage including wear, tear, or deterioration; + dfhskdkdfgkdfg + + + + + + + of the damaged part of the property. + + + + 2. + + + “bodily injury” means physical injury, sickness, or disease to a person. This includes required care, loss of services and death resulting therefrom. + + Bodily injury does not include: + + + + + + + + + + + + + a. + + + any of the following which are communicable: disease, bacteria, parasite, virus, or other organism, any of which are transmitted by any insured to any other person; + + + + + b. + + + the actual or alleged exposure to any such disease, bacteria, parasite, virus, or other organism by any insured to any other person; or + + + + + c. + + + Line item 3 + + + + + d. + + + Line item 4 + + + + + e. + + + Line item 5 + + + + + f. + + + Line item 6 + + + + + g. + + + Line item 7 + + + + + h. + + + Line Item 8 + + + + + i. + + + Line Item 9 + + + + + j. + + + Line Item 10 + + + + + k. + + + Line Item 11 + + + + + + + + + + + + + + + +