FOP-3082: NPE when using a link in a span with accessibility

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1902716 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fop-core/src/main/java/org/apache/fop/area/PageViewport.java b/fop-core/src/main/java/org/apache/fop/area/PageViewport.java
index f1cd957..a7353d3 100644
--- a/fop-core/src/main/java/org/apache/fop/area/PageViewport.java
+++ b/fop-core/src/main/java/org/apache/fop/area/PageViewport.java
@@ -284,7 +284,9 @@
      */
     public void replace(PageViewport oldViewPort) {
         this.idFirsts.addAll(oldViewPort.idFirsts);
-        this.unresolvedIDRefs.putAll(oldViewPort.unresolvedIDRefs);
+        if (oldViewPort.unresolvedIDRefs != null) {
+            this.unresolvedIDRefs.putAll(oldViewPort.unresolvedIDRefs);
+        }
         if (oldViewPort.pendingResolved != null) {
             this.pendingResolved.putAll(oldViewPort.pendingResolved);
         }
diff --git a/fop/test/intermediate/basic-link_span.xml b/fop/test/intermediate/basic-link_span.xml
new file mode 100644
index 0000000..8e28814
--- /dev/null
+++ b/fop/test/intermediate/basic-link_span.xml
@@ -0,0 +1,74 @@
+<?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 fo:basic-link in a span
+    </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="OnlyPage" margin-bottom="0.3in" margin-right="0.5in" margin-top="0.5in" margin-left="0.5in" page-width="8.5in" page-height="11in">
+          <fo:region-body column-gap="0.25in" column-count="2" margin-bottom="0in" margin-right="0in" margin-top="0.5in" margin-left="0in" region-name="letterPageBody"/>
+        </fo:simple-page-master>
+        <fo:page-sequence-master master-name="LetterPagesFile">
+          <fo:repeatable-page-master-alternatives>
+            <fo:conditional-page-master-reference page-position="only" master-reference="OnlyPage"/>
+            <fo:conditional-page-master-reference page-position="first" master-reference="OnlyPage"/>
+            <fo:conditional-page-master-reference page-position="rest" master-reference="OnlyPage"/>
+            <fo:conditional-page-master-reference page-position="last" master-reference="OnlyPage"/>
+          </fo:repeatable-page-master-alternatives>
+        </fo:page-sequence-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="LetterPagesFile">
+        <fo:flow flow-name="letterPageBody">
+          <fo:block span="all">
+            <fo:table border-collapse="separate" table-layout="fixed" width="100%">
+              <fo:table-column column-width="proportional-column-width(10.25)" column-number="1"/>
+              <fo:table-header>
+                <fo:table-row>
+                  <fo:table-cell>
+                    <fo:block>
+                      <fo:block>Cheque</fo:block>
+                    </fo:block>
+                  </fo:table-cell>
+                </fo:table-row>
+              </fo:table-header>
+              <fo:table-body>
+                <fo:table-row height="0.317499995231628cm">
+                  <fo:table-cell>
+                    <fo:block>
+                      <fo:basic-link internal-destination="mylink">abc</fo:basic-link>
+                    </fo:block>
+                  </fo:table-cell>
+                </fo:table-row>
+              </fo:table-body>
+            </fo:table>
+            <fo:block id="mylink"/>
+          </fo:block>
+          <fo:block/>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <if-checks xmlns:nav="http://xmlgraphics.apache.org/fop/intermediate/document-navigation">
+    <eval expected="0" xpath="//nav:link/nav:goto-xy/@page-index"/>
+  </if-checks>
+</testcase>