]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2898: Only use zero glue for change ipd
authorSimon Steiner <ssteiner@apache.org>
Thu, 2 Jan 2020 16:28:29 +0000 (16:28 +0000)
committerSimon Steiner <ssteiner@apache.org>
Thu, 2 Jan 2020 16:28:29 +0000 (16:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1872250 13f79535-47bb-0310-9956-ffa450edef68

fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java
fop/test/layoutengine/standard-testcases/table_border_padding_8.xml [new file with mode: 0755]
fop/test/layoutengine/standard-testcases/table_border_padding_9.xml [new file with mode: 0755]

index 6069dbcc3087504db8029c3e7c121bbcf9af3674..3e8bd992b38ef1d96406c425be830aeb51a16605 100644 (file)
@@ -88,6 +88,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     private Position auxiliaryPosition;
 
     private int contentAreaIPD;
+    private boolean isRestartAtLM;
 
     /**
      * @param node the fo this LM deals with
@@ -244,6 +245,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     @Override
     public List getNextKnuthElements(LayoutContext context, int alignment,
             Stack lmStack, Position restartPosition, LayoutManager restartAtLM) {
+        isRestartAtLM = restartAtLM != null;
         referenceIPD = context.getRefIPD();
         updateContentAreaIPDwithOverconstrainedAdjust();
 
@@ -1257,5 +1259,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
         }
         return false;
     }
+
+    public boolean isRestartAtLM() {
+        return isRestartAtLM;
+    }
 }
 
index 3bcec5e9a8130b4526b7d3e2873ee123ba62e818..3261a0afbd4c50a1f214bba5b0e763b116eca74e 100644 (file)
@@ -30,14 +30,15 @@ import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
+import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
 import org.apache.fop.layoutmgr.Keep;
 import org.apache.fop.layoutmgr.KnuthBlockBox;
 import org.apache.fop.layoutmgr.KnuthBox;
-import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthGlue;
 import org.apache.fop.layoutmgr.KnuthPenalty;
 import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.util.BreakUtil;
 
@@ -278,13 +279,10 @@ public class TableStepper {
                 int shrink = 0;
                 int stretch = 0;
                 int width = -penaltyOrGlueLen;
-                if (keep.getPenalty() == KnuthElement.INFINITE) {
-                    width = (boxLen + -penaltyOrGlueLen) / 2;
-                    if (-penaltyOrGlueLen > maxRemainingHeight) {
-                        width = 0;
-                    }
-                    stretch = Math.max(boxLen, -penaltyOrGlueLen);
-                    shrink = Math.min(boxLen, -penaltyOrGlueLen);
+                LayoutManager bslm = getTableLM().getParent();
+                if (bslm instanceof BlockStackingLayoutManager && ((BlockStackingLayoutManager)bslm).isRestartAtLM()
+                        && keep.getPenalty() == KnuthPenalty.INFINITE) {
+                    width = 0;
                 }
                 returnList.add(new KnuthGlue(width, stretch, shrink, new Position(null), true));
             }
diff --git a/fop/test/layoutengine/standard-testcases/table_border_padding_8.xml b/fop/test/layoutengine/standard-testcases/table_border_padding_8.xml
new file mode 100755 (executable)
index 0000000..d0ab0e7
--- /dev/null
@@ -0,0 +1,148 @@
+<?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 border and padding conditionality on table.
+    </p>
+  </info>
+  <fo>
+
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="BlankPage" page-width="210mm" page-height="297mm" margin-bottom="0mm" margin-right="0mm" margin-top="0mm" margin-left="0mm">
+      <fo:region-body margin-bottom="0mm" margin-right="0mm" margin-top="0mm" margin-left="0mm" region-name="Body"/>
+    </fo:simple-page-master>
+    <fo:simple-page-master master-name="FirstPage" page-width="210mm" page-height="297mm" margin-bottom="0mm" margin-right="0mm" margin-top="0mm" margin-left="0mm">
+      <fo:region-body margin-bottom="19.5mm" margin-right="65mm" margin-top="20mm" margin-left="20mm" region-name="Body"/>
+
+
+    </fo:simple-page-master>
+    <fo:simple-page-master master-name="SecondPage" page-width="210mm" page-height="297mm" margin-bottom="0mm" margin-right="0mm" margin-top="0mm" margin-left="0mm">
+      <fo:region-body margin-bottom="19.5mm" margin-right="65mm" margin-top="20mm" margin-left="20mm" region-name="Body"/>
+
+    </fo:simple-page-master>
+    <fo:simple-page-master master-name="RestPage" page-width="210mm" page-height="297mm" margin-bottom="0mm" margin-right="0mm" margin-top="0mm" margin-left="0mm">
+      <fo:region-body margin-bottom="19.5mm" margin-right="65mm" margin-top="20mm" margin-left="20mm" region-name="Body"/>
+
+    </fo:simple-page-master>
+    <fo:page-sequence-master master-name="PackPages">
+      <fo:repeatable-page-master-reference maximum-repeats="1" master-reference="FirstPage"/>
+      <fo:repeatable-page-master-reference maximum-repeats="1" master-reference="SecondPage"/>
+      <fo:repeatable-page-master-reference maximum-repeats="no-limit" master-reference="RestPage"/>
+      <fo:repeatable-page-master-alternatives>
+        <fo:conditional-page-master-reference blank-or-not-blank="blank" master-reference="BlankPage"/>
+      </fo:repeatable-page-master-alternatives>
+    </fo:page-sequence-master>
+  </fo:layout-master-set>
+  <fo:page-sequence format="1" id="th_default_sequence1" master-reference="PackPages">
+
+    <fo:flow flow-name="Body">
+
+      <fo:block>
+
+        <fo:table  table-layout="fixed" width="125mm">
+          <fo:table-column column-width="3mm" column-number="1"/>
+          <fo:table-column column-width="25mm" column-number="2"/>
+          <fo:table-column column-width="95mm" column-number="3"/>
+          <fo:table-column column-width="2mm" column-number="4"/>
+          <fo:table-body>
+            <fo:table-row keep-together.within-page="always" keep-with-next.within-page="always">
+              <fo:table-cell>
+                <fo:block>
+                  <fo:block font-size="1mm">
+                    <fo:leader/>
+                  </fo:block>
+                </fo:block>
+              </fo:table-cell>
+              <fo:table-cell>
+                <fo:block>
+                  <fo:block font-size="8.5pt" line-height="13pt" space-before="10pt">
+                    <fo:inline>What you've got left to pay</fo:inline>
+                  </fo:block>
+                </fo:block>
+              </fo:table-cell>
+              <fo:table-cell>
+                <fo:block>
+              
+                  <fo:table table-layout="fixed" width="95mm">
+                    <fo:table-column column-width="95mm" column-number="1"/>
+                    <fo:table-body>
+                      <fo:table-row>
+                        <fo:table-cell>
+                          <fo:block>
+                            <fo:block font-size="8.5pt" line-height="13pt" space-before="10pt">
+                              <fo:inline font-size="9pt" space-before="10pt" line-height="13pt">You're paying by monthly Direct Debit</fo:inline>
+                            </fo:block>
+                            <fo:list-block font-size="9pt" space-before="2.5pt" line-height="13pt" keep-together.within-page="always" keep-with-previous.within-page="always">
+                              <fo:list-item space-after="3pt" space-before="3pt">
+                                <fo:list-item-label end-indent="label-end()">
+                                  <fo:block>&gt;</fo:block>
+                                </fo:list-item-label>
+                                <fo:list-item-body start-indent="2.5mm">
+                                  <fo:block>We'll take a first Direct Debit of £146.50 on or just after 1 September 2016.</fo:block>
+                                </fo:list-item-body>
+                              </fo:list-item>
+    
+                            </fo:list-block>
+                            <fo:block font-size="9pt" line-height="13pt">
+                              <fo:inline>&gt;</fo:inline> More on page [[P;1057000239;1;1]]</fo:block>
+                          </fo:block>
+                        </fo:table-cell>
+                      </fo:table-row>
+                    </fo:table-body>
+                  </fo:table>
+                </fo:block>
+              </fo:table-cell>
+              <fo:table-cell>
+                <fo:block>
+                  <fo:block font-size="1mm">
+                    <fo:leader/>
+                  </fo:block>
+                </fo:block>
+              </fo:table-cell>
+            </fo:table-row>
+          </fo:table-body>
+        </fo:table>
+        <fo:table border-right="0.5pt solid rgb-icc(220, 7, 116, #CMYK, 0.11, 0.97, 0.53, 0.03)"  fox:border-end-radius-after="2.5mm" border-bottom="0.5pt solid rgb-icc(220, 7, 116, #CMYK, 0.11, 0.97, 0.53, 0.03)" fox:border-start-radius-after="2.5mm" fox:border-after-radius-end="2.5mm" fox:border-after-radius-start="2.5mm" table-layout="fixed" width="125mm">
+          <fo:table-column column-width="125mm" column-number="1"/>
+          <fo:table-body>
+            <fo:table-row keep-together.within-page="always" keep-with-next.within-page="always" height="4mm">
+              <fo:table-cell>
+                <fo:block>
+                  <fo:block>
+                    <fo:leader/>
+                  </fo:block>
+                </fo:block>
+              </fo:table-cell>
+            </fo:table-row>
+          </fo:table-body>
+        </fo:table>
+       
+
+      </fo:block>
+
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>
+  </fo>
+  <checks>
+    <eval expected="73113" xpath="//span/@bpd"/>
+  </checks>
+</testcase>
diff --git a/fop/test/layoutengine/standard-testcases/table_border_padding_9.xml b/fop/test/layoutengine/standard-testcases/table_border_padding_9.xml
new file mode 100755 (executable)
index 0000000..517ef8b
--- /dev/null
@@ -0,0 +1,124 @@
+<?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 border and padding conditionality on table.
+    </p>
+  </info>
+  <fo>
+
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="first-page" page-width="210mm" page-height="297mm" margin-bottom="0mm" margin-right="0mm" margin-top="0mm" margin-left="0mm">
+
+      <fo:region-body margin-top="110mm" background-repeat="no-repeat" background-position="center center" margin-bottom="30mm" margin-right="28mm" margin-left="28mm" region-name="body" background-color="yellow"/>
+
+    </fo:simple-page-master>
+    <fo:simple-page-master master-name="continuation-page" margin="0mm" page-width="210mm" page-height="297mm">
+
+      <fo:region-body margin-top="20mm" background-position="center center" background-repeat="no-repeat" margin-right="28mm" margin-left="28mm" region-name="body" margin-bottom="31.75mm"/>
+
+    </fo:simple-page-master>
+    <fo:page-sequence-master master-name="x-page-sequence">
+      <fo:repeatable-page-master-alternatives>
+        <fo:conditional-page-master-reference master-reference="first-page" page-position="first"/>
+        <fo:conditional-page-master-reference master-reference="continuation-page" page-position="rest"/>
+        <fo:conditional-page-master-reference master-reference="continuation-page" page-position="last"/>
+      </fo:repeatable-page-master-alternatives>
+    </fo:page-sequence-master>
+  </fo:layout-master-set>
+
+  <fo:page-sequence format="1" id="th_default_sequence1" master-reference="x-page-sequence" initial-page-number="auto" force-page-count="auto">
+
+    <fo:flow flow-name="body">
+     
+      
+      <fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" space-after="11pt">Mr.Test Fop3</fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" space-after="11pt" text-align="justify">Thank you for your recent application for X recognition.</fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" space-after="11pt" text-align="justify">I am pleased to confirm that we will recognise you as a complementary medicine practitioner in the field of    String from &lt;&lt;&lt;Date&gt;&gt;&gt; on GP referral. We will allow benefit towards any eligible treatment provided to X members on or after this date. As a recognised practitioner you will receive claims payment directly from us. </fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" space-after="11pt" text-align="justify">Your X Provider Number is 999999 and should be quoted on accounts and in all correspondence. Please note that for claims to be eligible the patient must have been referred to you by their GP or a recognised X Consultant. May I remind you that it is a condition of your recognition that you maintain your professional indemnity insurance.</fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" space-after="11pt" text-align="justify">Finally, our Provider Services team are available to answer any queries you may have about working with X. Their telephone number is 08457 55 33 33*. Calls will be automatically directed to the first available assistant. It is important that we maintain accurate and up to date records in order to ensure the speedy settlement of claims made by your patients who are X members. It would help us therefore, if you would inform us of any changes in your address or your professional circumstances by contacting our Provider Services team directly.</fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" keep-with-next.within-page="always" space-after="11pt">If you have any further queries regarding recognition, please do not hesitate to contact me.</fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" keep-with-next.within-page="always">
+          <fo:table table-layout="fixed" width="100%">
+            <fo:table-column column-width="proportional-column-width(100)" column-number="1"/>
+            <fo:table-body>
+              <fo:table-row>
+                <fo:table-cell>
+                  <fo:block>
+                    <fo:block  font-size="11pt" keep-together.within-page="always" keep-with-next.within-page="always" space-after="22mm">Yours sincerely</fo:block>
+                    <fo:block  font-size="11pt" keep-together.within-page="always" keep-with-next.within-page="always">Mrs.FOP HOP</fo:block>
+                    <fo:block  font-size="11pt" keep-together.within-page="always" keep-with-next.within-page="always">Healthcare Consultant</fo:block>
+                  </fo:block>
+                </fo:table-cell>
+              </fo:table-row>
+            </fo:table-body>
+          </fo:table>
+        </fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" keep-with-next.within-page="always">Provider Recognition Team</fo:block>
+        <fo:block  font-size="11pt" keep-together.within-page="always" keep-with-next.within-page="always" space-after="11pt">01400654800**<fo:block/> </fo:block>
+        <fo:table table-layout="fixed" width="100%">
+          <fo:table-column column-width="proportional-column-width(1.89)" column-number="1"/>
+          <fo:table-column column-width="proportional-column-width(98.11)" column-number="2"/>
+          <fo:table-body>
+            <fo:table-row height="0.396874994039536cm">
+              <fo:table-cell>
+                <fo:block>
+                  <fo:block  font-size="8pt" keep-together.within-page="always" keep-with-next.within-page="always">*</fo:block>
+                </fo:block>
+              </fo:table-cell>
+              <fo:table-cell>
+                <fo:block>
+                  <fo:block  font-size="8pt" keep-together.within-page="always" keep-with-next.within-page="always">Lines are open 8.00am - 6.00pm  Monday to Friday and 8.00am - 1.00pm each Saturday.  <fo:block/>Calls may be recorded and may be monitored.</fo:block>
+                  <fo:block  font-size="6pt">
+                    <fo:leader/>
+                  </fo:block>
+                </fo:block>
+              </fo:table-cell>
+            </fo:table-row>
+            <fo:table-row>
+              <fo:table-cell>
+                <fo:block>
+                  <fo:block  font-size="8pt" keep-together.within-page="always" keep-with-previous.within-page="always">**</fo:block>
+                </fo:block>
+              </fo:table-cell>
+              <fo:table-cell>
+                <fo:block>
+                  <fo:block  font-size="8pt" keep-together.within-page="always" keep-with-previous.within-page="always">Lines are open 9.00am - 5.00pm Monday to Friday. <fo:block/>Calls may be recorded and may be monitored.</fo:block>
+                  <fo:block  font-size="6pt">
+                    <fo:leader/>
+                  </fo:block>
+                </fo:block>
+              </fo:table-cell>
+            </fo:table-row>
+          </fo:table-body>
+        </fo:table>
+        <fo:block break-before="page" font-family="Helvetica" font-size="0pt" line-height="0pt">Break Before</fo:block>  
+      </fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>
+
+  </fo>
+  <checks>
+    <eval expected="If" xpath="//pageViewport[2]//word[1]"/>
+  </checks>
+</testcase>