[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fop-cvs
Subject:    svn commit: r1844636 - in /xmlgraphics/fop/trunk: fop-core/src/main/java/org/apache/fop/render/inter
From:       ssteiner () apache ! org
Date:       2018-10-23 11:56:21
Message-ID: 20181023115622.4ECB33A1041 () svn01-us-west ! apache ! org
[Download RAW message or body]

Author: ssteiner
Date: Tue Oct 23 11:56:21 2018
New Revision: 1844636

URL: http://svn.apache.org/viewvc?rev=1844636&view=rev
Log:
FOP-2823: page-index-relative not added when forwards link used to same location

Added:
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/PageIndexContext.java \
(with props)  xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/basic-link_internal-desination-forwards-backwards.xml \
(with props) Modified:
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFContext.java
  xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java
  xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
  xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java


Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFContext.java
                
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apa \
che/fop/render/intermediate/IFContext.java?rev=1844636&r1=1844635&r2=1844636&view=diff
 ==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFContext.java \
                (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFContext.java \
Tue Oct 23 11:56:21 2018 @@ -38,7 +38,7 @@ import org.apache.fop.apps.FOUserAgent;
  * implementations will just ignore all foreign attributes for most elements. That's \
                why the
  * main IF interfaces are not burdened with this.
  */
-public class IFContext {
+public class IFContext implements PageIndexContext {
 
     private FOUserAgent userAgent;
 

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java
                
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apa \
che/fop/render/intermediate/IFRenderer.java?rev=1844636&r1=1844635&r2=1844636&view=diff
 ==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java \
                (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java \
Tue Oct 23 11:56:21 2018 @@ -396,7 +396,7 @@ public class IFRenderer extends Abstract
         this.documentMetadata = metadata.getMetadata();
     }
 
-    private GoToXYAction getGoToActionForID(String targetID, final int pageIndex) {
+    private GoToXYAction getGoToActionForID(String targetID, int pageIndex) {
         // Already a GoToXY present for this target? If not, create.
         GoToXYAction action = (GoToXYAction)actionSet.get(targetID);
         //GoToXYAction action = (GoToXYAction)idGoTos.get(targetID);
@@ -407,14 +407,10 @@ public class IFRenderer extends Abstract
             Point position = (Point)idPositions.get(targetID);
             // can the GoTo already be fully filled in?
             if (pageIndex >= 0 && position != null) {
-                action = new GoToXYAction(targetID, pageIndex, position, new \
                GoToXYAction.PageIndexRelative() {
-                    public int getPageIndexRelative() {
-                        return pageIndex - \
                documentHandler.getContext().getPageIndex();
-                    }
-                });
+                action = new GoToXYAction(targetID, pageIndex, position, \
documentHandler.getContext());  } else {
                 // Not complete yet, can't use getPDFGoTo:
-                action = new GoToXYAction(targetID, pageIndex, null, null);
+                action = new GoToXYAction(targetID, pageIndex, null, \
documentHandler.getContext());  unfinishedGoTos.add(action);
             }
             action = (GoToXYAction)actionSet.put(action);

Added: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/PageIndexContext.java
                
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/PageIndexContext.java?rev=1844636&view=auto
 ==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/PageIndexContext.java \
                (added)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/PageIndexContext.java \
Tue Oct 23 11:56:21 2018 @@ -0,0 +1,26 @@
+/*
+ * 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$ */
+package org.apache.fop.render.intermediate;
+
+/**
+ * Interface to get the page index
+ */
+public interface PageIndexContext {
+    int getPageIndex();
+}

Propchange: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/PageIndexContext.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
                
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apa \
che/fop/render/intermediate/extensions/DocumentNavigationHandler.java?rev=1844636&r1=1844635&r2=1844636&view=diff
 ==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java \
                (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java \
Tue Oct 23 11:56:21 2018 @@ -35,6 +35,7 @@ import org.apache.fop.accessibility.Stru
 import org.apache.fop.fo.extensions.InternalElementMapping;
 import org.apache.fop.render.intermediate.IFDocumentNavigationHandler;
 import org.apache.fop.render.intermediate.IFException;
+import org.apache.fop.render.intermediate.PageIndexContext;
 import org.apache.fop.util.XMLUtil;
 
 /**
@@ -119,7 +120,7 @@ public class DocumentNavigationHandler e
                 } else {
                     String id = attributes.getValue("id");
                     int pageIndex = XMLUtil.getAttributeAsInt(attributes, \
                "page-index");
-                    final int pageIndexRelative = \
XMLUtil.getAttributeAsInt(attributes, "page-index-relative", 0); +                    \
int pageIndexRelative = XMLUtil.getAttributeAsInt(attributes, "page-index-relative", \
0);  final Point location;
                     if (pageIndex < 0) {
                         location = null;
@@ -136,11 +137,8 @@ public class DocumentNavigationHandler e
                                 .getAttributeAsInt(attributes, "y");
                         location = new Point(x, y);
                     }
-                    action = new GoToXYAction(id, pageIndex, location, new \
                GoToXYAction.PageIndexRelative() {
-                        public int getPageIndexRelative() {
-                            return pageIndexRelative;
-                        }
-                    });
+                    action = new GoToXYAction(id, pageIndex, location,
+                            new PageIndexRelative(pageIndex, pageIndexRelative));
                 }
                 if (structureTreeElement != null) {
                     action.setStructureTreeElement(structureTreeElement);
@@ -175,6 +173,16 @@ public class DocumentNavigationHandler e
         }
     }
 
+    static class PageIndexRelative implements PageIndexContext {
+        private int pageIndex;
+        PageIndexRelative(int pageIndex, int pageIndexRelative) {
+            this.pageIndex = (pageIndexRelative * -1) + pageIndex;
+        }
+        public int getPageIndex() {
+            return pageIndex;
+        }
+    }
+
     private boolean inBookmark() {
         return !objectStack.empty() && objectStack.peek() instanceof Bookmark;
     }

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java
                
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apa \
che/fop/render/intermediate/extensions/GoToXYAction.java?rev=1844636&r1=1844635&r2=1844636&view=diff
 ==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java \
                (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java \
Tue Oct 23 11:56:21 2018 @@ -25,6 +25,7 @@ import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 
+import org.apache.fop.render.intermediate.PageIndexContext;
 import org.apache.fop.util.XMLUtil;
 
 /**
@@ -33,7 +34,7 @@ import org.apache.fop.util.XMLUtil;
 public class GoToXYAction extends AbstractAction implements \
DocumentNavigationExtensionConstants {  
     private int pageIndex = -1;
-    private PageIndexRelative pageIndexRelative;
+    private PageIndexContext ifContext;
     private Point targetLocation;
 
     /**
@@ -52,7 +53,7 @@ public class GoToXYAction extends Abstra
      * @param targetLocation the absolute location on the page (coordinates in \
                millipoints),
      *                  or null, if the position isn't known, yet
      */
-    public GoToXYAction(String id, int pageIndex, Point targetLocation, \
PageIndexRelative pageIndexRelative) { +    public GoToXYAction(String id, int \
pageIndex, Point targetLocation, PageIndexContext ifContext) {  setID(id);
         if (pageIndex < 0 && targetLocation != null) {
             throw new IllegalArgumentException(
@@ -60,11 +61,7 @@ public class GoToXYAction extends Abstra
         }
         setPageIndex(pageIndex);
         setTargetLocation(targetLocation);
-        this.pageIndexRelative = pageIndexRelative;
-    }
-
-    public interface PageIndexRelative {
-        int getPageIndexRelative();
+        this.ifContext = ifContext;
     }
 
     /**
@@ -153,11 +150,11 @@ public class GoToXYAction extends Abstra
             atts.addAttribute("", "id", "id", XMLUtil.CDATA, getID());
             atts.addAttribute("", "page-index", "page-index",
                     XMLUtil.CDATA, Integer.toString(pageIndex));
-            if (pageIndexRelative != null) {
-                int pageIndexRelativeInt = pageIndexRelative.getPageIndexRelative();
-                if (pageIndexRelativeInt < 0) {
+            if (ifContext != null && pageIndex >= 0) {
+                int pageIndexRelative = pageIndex - ifContext.getPageIndex();
+                if (pageIndexRelative < 0) {
                     atts.addAttribute("", "page-index-relative", \
                "page-index-relative",
-                            XMLUtil.CDATA, Integer.toString(pageIndexRelativeInt));
+                            XMLUtil.CDATA, Integer.toString(pageIndexRelative));
                 }
             }
             atts.addAttribute("", "x", "x", XMLUtil.CDATA,

Added: xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/basic-link_internal-desination-forwards-backwards.xml
                
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop/test/layoutengine/standard \
-testcases/basic-link_internal-desination-forwards-backwards.xml?rev=1844636&view=auto
 ==============================================================================
--- xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/basic-link_internal-desination-forwards-backwards.xml \
                (added)
+++ xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/basic-link_internal-desination-forwards-backwards.xml \
Tue Oct 23 11:56:21 2018 @@ -0,0 +1,54 @@
+<?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 same page internal-destination on a fo:basic-link which \
references a prior block. +    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+      <fo:layout-master-set>
+        <fo:simple-page-master margin-right="1cm" margin-left="1cm" \
margin-bottom="0.3cm" margin-top="1cm" page-width="21cm" page-height="29.7cm" \
master-name="all"> +          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence format="1" id="th_default_sequence1" master-reference="all">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            <fo:block>
+              <fo:basic-link internal-destination="N1004A">1 Cross-references \
</fo:basic-link> +            </fo:block>
+            <fo:block id="N1004A">
+              <fo:block id="c1001"/>1 Cross-references</fo:block>
+            <fo:block break-before="page">
+              <fo:basic-link color="blue" internal-destination="c1001">STATIC \
SECTION 1 reference </fo:basic-link> +            </fo:block>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <if-checks xmlns:if="http://xmlgraphics.apache.org/fop/intermediate" \
xmlns:n="http://xmlgraphics.apache.org/fop/intermediate/document-navigation"> +    \
<eval expected="0" xpath="//if:page[@index=0]/if:page-trailer/n:link/n:goto-xy/@page-index"/>
 +    <eval expected="" \
xpath="//if:page[@index=0]/if:page-trailer/n:link/n:goto-xy/@page-index-relative"/> + \
<eval expected="0" xpath="//if:page[@index=1]/if:page-trailer/n:link/n:goto-xy/@page-index"/>
 +    <eval expected="-1" \
xpath="//if:page[@index=1]/if:page-trailer/n:link/n:goto-xy/@page-index-relative"/> + \
</if-checks> +</testcase>

Propchange: xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/basic-link_internal-desination-forwards-backwards.xml
                
------------------------------------------------------------------------------
    svn:eol-style = native



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic