Browse Source

Add fix for NPE related to FOP-3098 by Jeremias Maerki

tags/2_9
Chris Bowditch 1 year ago
parent
commit
2a73338d34

+ 1
- 0
fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java View File

@@ -498,6 +498,7 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage
&& position.getLM() instanceof ListItemContentLayoutManager) {
position = position.getPosition();
if (position != null
&& position.getPosition() != null
&& position.getLM() instanceof BlockLayoutManager) {
retval = new LeafPosition(position.getPosition().getLM(), 0);
}

+ 57
- 0
fop/test/layoutengine/standard-testcases/list-block_npe_bug_empty_2nd_block.xml View File

@@ -0,0 +1,57 @@
<?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 triggered a NPE in
in ListItemLayoutManager.extractBlock() on a null Position due to an empty second block.
</p>
</info>
<fo>
<root xmlns="http://www.w3.org/1999/XSL/Format">
<layout-master-set>
<simple-page-master master-name="a4" page-height="29.7cm" page-width="21cm">
<region-body/>
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="a4">
<flow flow-name="xsl-region-body">
<list-block provisional-distance-between-starts="20mm" provisional-label-separation="4mm">
<list-item>
<list-item-label end-indent="label-end()">
<block>1.1.</block>
</list-item-label>
<list-item-body start-indent="body-start()">
<block>blah blah</block>
<block/> <!-- Empty block here caused NPE in ListItemLayoutManager.extractBlock() on a null Position -->
</list-item-body>
</list-item>
</list-block>
</flow>
</page-sequence>
</root>
</fo>
<checks>
<eval expected="1" xpath="count(//pageViewport)"/>
<eval expected="1.1." xpath="//pageViewport[@nr=1]/descendant::text[1]"/>
</checks>
</testcase>


Loading…
Cancel
Save