]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2348:
authorLuca Furini <lfurini@apache.org>
Sat, 14 Feb 2015 10:55:13 +0000 (10:55 +0000)
committerLuca Furini <lfurini@apache.org>
Sat, 14 Feb 2015 10:55:13 +0000 (10:55 +0000)
  - fixing inconsistencies in attribute names when serializing / deserializing extension data, which caused data loss
  - adding testcase to avoid unsignalled regressions

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1659776 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileAttachment.java
src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java
test/layoutengine/standard-testcases/pdf-embedded-file-extension.xml [new file with mode: 0644]

index f00fc26355fba9f950b59a1d5c20979ef320f1c1..8a6e76ba92173ccab08f36c481e2204077292799 100644 (file)
@@ -40,7 +40,7 @@ public class PDFEmbeddedFileAttachment extends PDFExtensionAttachment {
     private static final String ATT_SRC = "src";
 
     /** a description of the file to be embedded */
-    private static final String ATT_DESC = "desc";
+    private static final String ATT_DESC = "description";
 
     /** filename attribute */
     private String filename;
index fb0647fd58376fcaf61166dfa5f068cdcf278612..2d53c33bf035ef3ad4be3b2932241dc88f95822e 100644 (file)
@@ -154,7 +154,7 @@ public class PDFExtensionHandler extends DefaultHandler implements ContentHandle
     public void endElement(String uri, String localName, String qName) throws SAXException {
         if (PDFExtensionAttachment.CATEGORY.equals(uri)) {
             if (PDFEmbeddedFileAttachment.ELEMENT.equals(localName)) {
-                String name = lastAttributes.getValue("name");
+                String name = lastAttributes.getValue("filename");
                 String src = lastAttributes.getValue("src");
                 String desc = lastAttributes.getValue("description");
                 this.lastAttributes = null;
diff --git a/test/layoutengine/standard-testcases/pdf-embedded-file-extension.xml b/test/layoutengine/standard-testcases/pdf-embedded-file-extension.xml
new file mode 100644 (file)
index 0000000..43ffd31
--- /dev/null
@@ -0,0 +1,58 @@
+<?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 the PDF embedded file extension,
+      and a link to an embedded file.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="simple">
+          <fo:region-body />
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:declarations>
+        <pdf:embedded-file filename="test.png" description="This is just a png image" src="../resources/images/arrow_down_large.png"/>
+      </fo:declarations>
+      <fo:page-sequence master-reference="simple">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            See the 
+            <fo:basic-link external-destination="url(embedded-file:test.png)">attached file</fo:basic-link>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks xmlns:pdf="apache:fop:extensions:pdf">
+    <eval expected="test.png" xpath="//extension-attachments/pdf:embedded-file/@filename"/>
+    <eval expected="This is just a png image" xpath="//extension-attachments/pdf:embedded-file/@description"/>
+    <eval expected="../resources/images/arrow_down_large.png" xpath="//extension-attachments/pdf:embedded-file/@src"/>
+    <eval expected="newWindow=false,dest=embedded-file:test.png" xpath="//inlineparent/@external-link"/>
+  </checks>
+  <if-checks xmlns:if="http://xmlgraphics.apache.org/fop/intermediate" xmlns:nav="http://xmlgraphics.apache.org/fop/intermediate/document-navigation" xmlns:pdf="apache:fop:extensions:pdf">
+    <eval expected="test.png" xpath="//if:header/pdf:embedded-file/@filename"/>
+    <eval expected="This is just a png image" xpath="//if:header/pdf:embedded-file/@description"/>
+    <eval expected="../resources/images/arrow_down_large.png" xpath="//if:header/pdf:embedded-file/@src"/>
+    <eval expected="embedded-file:test.png" xpath="//if:page-trailer/nav:link/nav:goto-uri/@uri"/>
+  </if-checks>
+</testcase>
\ No newline at end of file