You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by jg...@apache.org on 2026/10/06 17:56:30 UTC

(xmlgraphics-fop) 01/02: FOP-3349: A line that overflows on the float re-layout pass is reported, not a NullPointerException by Jason Harrop

This is an automated email from the ASF dual-hosted git repository.

joao12021996 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-fop.git

commit a36b42fab9828beb72e7f7b5b8a44c873f964f23
Author: Joao Goncalves <an...@gmail.com>
AuthorDate: Mon Oct 5 12:58:31 2026 -0500

    FOP-3349: A line that overflows on the float re-layout pass is reported, not a NullPointerException by Jason Harrop
---
 .../fop/layoutmgr/inline/LineLayoutManager.java    |  3 +-
 .../standard-testcases/float_overflow_relayout.xml | 46 ++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index 2c595d6bd..fb9753302 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -400,7 +400,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                 InlineLevelEventProducer eventProducer
                     = InlineLevelEventProducer.Provider.get(
                         getFObj().getUserAgent().getEventBroadcaster());
-                if (curChildLM.getFObj() == null) {
+                // curChildLM is null on the float re-layout pass (PageBreaker.handleFloatLayout)
+                if (curChildLM == null || curChildLM.getFObj() == null) {
                     eventProducer.lineOverflows(this, getFObj().getName(), bestActiveNode.line,
                             -lack, getFObj().getLocator());
                 } else {
diff --git a/fop/test/layoutengine/standard-testcases/float_overflow_relayout.xml b/fop/test/layoutengine/standard-testcases/float_overflow_relayout.xml
new file mode 100644
index 000000000..b8ce1be0a
--- /dev/null
+++ b/fop/test/layoutengine/standard-testcases/float_overflow_relayout.xml
@@ -0,0 +1,46 @@
+<?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 a line that overflows beside a float wider than the measure. On the float
+            re-layout pass the line breaking algorithm reported the overflow through curChildLM, which
+            is null there, and FOP threw a NullPointerException instead of reporting it.
+        </p>
+    </info>
+    <fo>
+        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+            <fo:layout-master-set>
+                <fo:simple-page-master master-name="page" page-width="595pt" page-height="842pt" margin="85pt">
+                    <fo:region-body/>
+                </fo:simple-page-master>
+            </fo:layout-master-set>
+            <fo:page-sequence master-reference="page">
+                <fo:flow flow-name="xsl-region-body">
+                    <fo:block><fo:float float="start"><fo:block-container width="480pt" height="200pt"><fo:block> </fo:block></fo:block-container></fo:float></fo:block>
+                    <fo:block><fo:block>block child</fo:block><fo:inline>Overflowing ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ</fo:inline></fo:block>
+                </fo:flow>
+            </fo:page-sequence>
+        </fo:root>
+    </fo>
+    <checks>
+        <eval expected="1" xpath="count(//pageViewport)"/>
+        <true xpath="boolean(//word[starts-with(., 'ABCDEFGHIJ')])"/>
+    </checks>
+</testcase>
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org