]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Merge from trunk.
authorGlenn Adams <gadams@apache.org>
Mon, 28 May 2012 04:00:59 +0000 (04:00 +0000)
committerGlenn Adams <gadams@apache.org>
Mon, 28 May 2012 04:00:59 +0000 (04:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-1_1@1343135 13f79535-47bb-0310-9956-ffa450edef68

12 files changed:
src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd
src/java/org/apache/fop/render/intermediate/IFSerializer.java
src/java/org/apache/fop/render/ps/PSDocumentHandler.java
src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
src/java/org/apache/fop/render/ps/extensions/PSPageTrailerCodeBefore.java [new file with mode: 0644]
src/java/org/apache/fop/render/ps/extensions/PSPageTrailerCodeBeforeElement.java [new file with mode: 0644]
src/java/org/apache/fop/render/xml/XMLRenderer.java
status.xml
test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java [new file with mode: 0644]
test/layoutengine/standard-testcases/bidi_propagation_1.xml
test/layoutengine/standard-testcases/character_writing-mode_rl.xml

index bea5275a5b42bc63b0f77bf8cbd8ded1d7a50812..6e17c793bfe4898b33fa9192c0535469493c148c 100644 (file)
@@ -34,6 +34,7 @@
         <xs:element ref="mf:page-sequence" minOccurs="1" maxOccurs="unbounded"/>
         <xs:element ref="mf:trailer"/>
       </xs:sequence>
+      <xs:attribute name="version" type="xs:string"/>
     </xs:complexType>
   </xs:element>
   <xs:element name="header">
index f8f286cb31c01ff3a8e9b0004badff026ffba2af..7114f51e36580e12878f6fde14741b9006a8f564 100644 (file)
@@ -64,6 +64,15 @@ import org.apache.fop.util.XMLUtil;
 public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
         implements IFConstants, IFPainter, IFDocumentNavigationHandler {
 
+    /**
+     * Intermediate Format (IF) version, used to express an @version attribute
+     * in the root element of the IF document, the initial value of which
+     * is set to '2.0' to signify that something preceded it (but didn't
+     * happen to be marked as such), and that this version is not necessarily
+     * backwards compatible with the unmarked (<2.0) version.
+     */
+    public static final String VERSION = "2.0";
+
     private IFDocumentHandler mimicHandler;
     private int pageSequenceIndex; // used for accessibility
 
@@ -167,7 +176,9 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
                     DocumentNavigationExtensionConstants.NAMESPACE);
             handler.startPrefixMapping(InternalElementMapping.STANDARD_PREFIX,
                     InternalElementMapping.URI);
-            handler.startElement(EL_DOCUMENT);
+            AttributesImpl atts = new AttributesImpl();
+            addAttribute(atts, "version", VERSION);
+            handler.startElement(EL_DOCUMENT, atts);
         } catch (SAXException e) {
             throw new IFException("SAX error in startDocument()", e);
         }
index 490e42b2d3792dcd7e568d2fb70d98a3c83e51c5..95647d820088beda18a98f56da940aaa4a53c1f1 100644 (file)
@@ -26,6 +26,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -57,6 +58,7 @@ import org.apache.fop.render.intermediate.IFException;
 import org.apache.fop.render.intermediate.IFPainter;
 import org.apache.fop.render.ps.extensions.PSCommentAfter;
 import org.apache.fop.render.ps.extensions.PSCommentBefore;
+import org.apache.fop.render.ps.extensions.PSPageTrailerCodeBefore;
 import org.apache.fop.render.ps.extensions.PSSetPageDevice;
 import org.apache.fop.render.ps.extensions.PSSetupCode;
 
@@ -98,10 +100,11 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
     private PSPageDeviceDictionary pageDeviceDictionary;
 
     /** This is a collection holding all document header comments */
-    private Collection[] comments = new Collection[3];
+    private Collection[] comments = new Collection[4];
     private static final int COMMENT_DOCUMENT_HEADER = 0;
     private static final int COMMENT_DOCUMENT_TRAILER = 1;
     private static final int COMMENT_PAGE_TRAILER = 2;
+    private static final int PAGE_TRAILER_CODE_BEFORE = 3;
 
     /**
      * Default constructor.
@@ -443,8 +446,9 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
 
     /** {@inheritDoc} */
     public void startPageTrailer() throws IFException {
-        super.startPageTrailer();
         try {
+            writeExtensions(PAGE_TRAILER_CODE_BEFORE);
+            super.startPageTrailer();
             gen.writeDSCComment(DSCConstants.PAGE_TRAILER);
         } catch (IOException ioe) {
             throw new IFException("I/O error in startPageTrailer()", ioe);
@@ -526,6 +530,11 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
                     comments[targetCollection] = new java.util.ArrayList();
                 }
                 comments[targetCollection].add(extension);
+            } else if (extension instanceof PSPageTrailerCodeBefore) {
+                if (comments[PAGE_TRAILER_CODE_BEFORE] == null) {
+                    comments[PAGE_TRAILER_CODE_BEFORE] = new ArrayList();
+                }
+                comments[PAGE_TRAILER_CODE_BEFORE].add(extension);
             }
         } catch (IOException ioe) {
             throw new IFException("I/O error in handleExtensionObject()", ioe);
index 00d0594f29ca8884e08af444fc8b8370dc160571..5721afaf63d40bc997c83fe2e3de0929e7ee26e1 100644 (file)
@@ -41,6 +41,7 @@ public class PSExtensionElementMapping extends ElementMapping {
             foObjs = new java.util.HashMap<String, Maker>();
             foObjs.put(PSSetupCodeElement.ELEMENT, new PSSetupCodeMaker());
             foObjs.put(PSPageSetupCodeElement.ELEMENT, new PSPageSetupCodeMaker());
+            foObjs.put(PSPageTrailerCodeBefore.ELEMENT, new PSPageTrailerCodeBeforeMaker());
             foObjs.put(PSSetPageDeviceElement.ELEMENT, new PSSetPageDeviceMaker());
             foObjs.put(PSCommentBefore.ELEMENT, new PSCommentBeforeMaker());
             foObjs.put(PSCommentAfter.ELEMENT, new PSCommentAfterMaker());
@@ -59,6 +60,12 @@ public class PSExtensionElementMapping extends ElementMapping {
         }
     }
 
+    static class PSPageTrailerCodeBeforeMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new PSPageTrailerCodeBeforeElement(parent);
+        }
+    }
+
     static class PSSetPageDeviceMaker extends ElementMapping.Maker {
         public FONode make(FONode parent) {
             return new PSSetPageDeviceElement(parent);
index d499ef6ab6834e3f8fae4f61ffc52a061e53e62b..b520d87364006b6806e15e5b157f2751a75b4e05 100644 (file)
@@ -53,6 +53,7 @@ public class PSExtensionHandler extends DefaultHandler
             lastAttributes = new AttributesImpl(attributes);
             handled = false;
             if (localName.equals(PSSetupCode.ELEMENT)
+                    || localName.equals(PSPageTrailerCodeBefore.ELEMENT)
                     || localName.equals(PSSetPageDevice.ELEMENT)
                     || localName.equals(PSCommentBefore.ELEMENT)
                     || localName.equals(PSCommentAfter.ELEMENT)) {
@@ -84,6 +85,8 @@ public class PSExtensionHandler extends DefaultHandler
                 this.returnedObject = new PSCommentBefore(content.toString());
             } else if (PSCommentAfter.ELEMENT.equals(localName)) {
                 this.returnedObject = new PSCommentAfter(content.toString());
+            } else if (PSPageTrailerCodeBefore.ELEMENT.equals(localName)) {
+                this.returnedObject = new PSPageTrailerCodeBefore(content.toString());
             }
         }
         content.setLength(0); //Reset text buffer (see characters())
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSPageTrailerCodeBefore.java b/src/java/org/apache/fop/render/ps/extensions/PSPageTrailerCodeBefore.java
new file mode 100644 (file)
index 0000000..f28f000
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.ps.extensions;
+
+
+public class PSPageTrailerCodeBefore extends PSExtensionAttachment {
+
+    /** The element name */
+    protected static final String ELEMENT = "ps-page-trailer-code-before";
+
+    /**
+     * Default constructor
+     * @param content the actual comment
+     */
+    public PSPageTrailerCodeBefore(String content) {
+        super(content);
+    }
+
+    /**
+     * Constructor
+     */
+    public PSPageTrailerCodeBefore() {
+        super();
+    }
+
+    /**
+     * @return element name
+     */
+    protected String getElement() {
+        return ELEMENT;
+    }
+
+}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSPageTrailerCodeBeforeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSPageTrailerCodeBeforeElement.java
new file mode 100644 (file)
index 0000000..65a22ea
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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.ps.extensions;
+
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * Comment before element
+ */
+public class PSPageTrailerCodeBeforeElement extends AbstractPSCommentElement {
+
+    /** the element name */
+    protected static final String ELEMENT = "ps-page-trailer-code-before";
+
+    /**
+     * Main constructor
+     * @param parent parent node
+     */
+    public PSPageTrailerCodeBeforeElement(FONode parent) {
+        super(parent);
+    }
+
+    /**
+     * @return local name
+     * @see org.apache.fop.fo.FONode#getLocalName()
+     */
+    public String getLocalName() {
+        return PSPageTrailerCodeBefore.ELEMENT;
+    }
+
+    /**
+     * @return instance of its extension attachment object
+     */
+    protected ExtensionAttachment instantiateExtensionAttachment() {
+        return new PSPageTrailerCodeBefore();
+    }
+}
index 4ac6502692d24c9dfc78086b51f9aaf27f323fe6..cf3cbe5a2ae46fe8eca0c3c0ede2cace9c13401a 100644 (file)
@@ -97,6 +97,15 @@ import org.apache.fop.util.XMLUtil;
  */
 public class XMLRenderer extends AbstractXMLRenderer {
 
+    /**
+     * Area Tree  (AT) version, used to express an @version attribute
+     * in the root element of the AT document, the initial value of which
+     * is set to '2.0' to signify that something preceded it (but didn't
+     * happen to be marked as such), and that this version is not necessarily
+     * backwards compatible with the unmarked (<2.0) version.
+     */
+    public static final String VERSION = "2.0";
+
     /** XML MIME type */
     public static final String XML_MIME_TYPE = MimeConstants.MIME_FOP_AREA_TREE;
 
@@ -365,7 +374,9 @@ public class XMLRenderer extends AbstractXMLRenderer {
         if (userAgent.getProducer() != null) {
             comment("Produced by " + userAgent.getProducer());
         }
-        startElement("areaTree");
+        atts.clear();
+        addAttribute("version", VERSION);
+        startElement("areaTree", atts);
     }
 
     /** {@inheritDoc} */
@@ -825,11 +836,10 @@ public class XMLRenderer extends AbstractXMLRenderer {
         }
         maybeAddLevelAttribute(word);
         maybeAddPositionAdjustAttribute(word);
-        if ( word.isReversed() ) {
-            addAttribute("reversed", "true");
-        }
+        String text = word.getWord();
+        maybeAddReversedAttribute(word, text);
         startElement("word", atts);
-        characters(word.getWord());
+        characters(text);
         endElement("word");
         super.renderWord(word);
     }
@@ -917,5 +927,11 @@ public class XMLRenderer extends AbstractXMLRenderer {
         }
     }
 
+    private void maybeAddReversedAttribute ( WordArea w, String text ) {
+        if ( w.isReversed() && ( text.length() > 1 )  ) {
+            addAttribute("reversed", "true");
+        }
+    }
+
 
 }
index 693bc95fdeeec68be001e20a70dc4550407c852b..23ad7456e8e4d30b4a0e091f6e02599384619c8f 100644 (file)
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="1.1" date="DD Month 2012">
+      <action context="Renderers" dev="GA" type="fix" fixes-bug="53304,53306">
+        Add version attribute to AT and IF intermediate formats. Also eliminate redundant use of reversed attribute in AT format.
+      </action>
+      <action context="Renderers" dev="GA" type="fix" fixes-bug="53295" due-to="Luis Bernardo" importance="high">
+        Add extension to place code just before PostScript %PageTrailer.
+      </action>
       <action context="Renderers" dev="GA" type="fix" fixes-bug="53294" due-to="Robert Meyer">
         Fix invalid PostScript file being created when font-size is 0.
       </action>
diff --git a/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java b/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java
new file mode 100644 (file)
index 0000000..3f1088f
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.ps;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+import org.apache.fop.render.ps.extensions.PSPageTrailerCodeBefore;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class PSRenderingUtilTestCase {
+
+    private final String content = "<< /MyEntry 0 >> command";
+    private final PSPageTrailerCodeBefore ptcb = new PSPageTrailerCodeBefore(content);
+    private final PSGenerator gen = mock(PSGenerator.class);
+
+    @Test
+    public void testWriteEnclosedExtensionAttachment() throws IOException {
+        PSRenderingUtil.writeEnclosedExtensionAttachment(gen, ptcb);
+        verify(gen).writeln(content);
+    }
+
+}
index 947d9dac504da7941a0f1794b1a96ded47f9c0f2..587bc6d2f684e95e7c31c41ff0abd81c988ae145 100644 (file)
@@ -66,7 +66,7 @@
                           <fo:table-cell margin-left="0" text-align="right">
                             <fo:block>
                               <fo:inline>
-                                <fo:inline><fo:bidi-override unicode-bidi="bidi-override" direction="rtl">X</fo:bidi-override></fo:inline>
+                                <fo:inline><fo:bidi-override unicode-bidi="bidi-override" direction="rtl">XY</fo:bidi-override></fo:inline>
                               </fo:inline>
                             </fo:block>
                           </fo:table-cell>
@@ -93,7 +93,7 @@
                           <fo:table-cell margin-left="0" text-align="right">
                             <fo:block>
                               <fo:inline>
-                                <fo:inline><fo:bidi-override unicode-bidi="bidi-override" direction="rtl">X</fo:bidi-override></fo:inline>
+                                <fo:inline><fo:bidi-override unicode-bidi="bidi-override" direction="rtl">XY</fo:bidi-override></fo:inline>
                               </fo:inline>
                             </fo:block>
                           </fo:table-cell>
index adc126ec8732401809e1a30eb5d08b9d71c86d76..db65238c01c330fb5c55282f590aa2702e95ad91 100644 (file)
     <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/@ipd"/>
     <eval expected="4" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]"/>
     <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@level"/>
-    <true xpath="boolean(//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@reversed)"/>
+    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@reversed"/>
     <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/@ipd"/>
     <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]"/>
-    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@level"/>
-    <true xpath="boolean(//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@reversed)"/>
+    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]/@level"/>
+    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]/@reversed"/>
     <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/@ipd"/>
     <eval expected="2" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]"/>
     <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]/@level"/>
-    <true xpath="boolean(//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]/@reversed)"/>
+    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]/@reversed"/>
     <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/@ipd"/>
     <eval expected="1" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]"/>
     <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]/@level"/>
-    <true xpath="boolean(//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]/@reversed)"/>
+    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]/@reversed"/>
   </checks>
 </testcase>