cziegeler    01/10/12 05:34:40

  Modified:    .        build.xml
  Added:       src/org/apache/cocoon/serialization RTFSerializer.java
  Log:
  Enclosed is a patch (contributed to jfor by Gianugo Rabellino), that allows
  jfor to be integrated with Cocoon 2 for RTF serialization of XSL-FO
   documents.
  Submitted by: Bertrand Delacretaz [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.79      +20 -1     xml-cocoon2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/build.xml,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- build.xml 2001/10/11 14:51:13     1.78
  +++ build.xml 2001/10/12 12:34:40     1.79
  @@ -126,8 +126,11 @@
                       <map:serializer name="fo2ps" 
src="org.apache.cocoon.serialization.FOPSerializer" 
mime-type="application/postscript"/>
   - fo2pcl serializer : Requires the FOP package (included in the dist)
                       <map:serializer name="fo2pcl" 
src="org.apache.cocoon.serialization.FOPSerializer" 
mime-type="application/vnd.hp-PCL"/>
  +- fo2rtf serializer : Requires the JFOR package (not included in the dist)
  +                    <map:serializer name="fo2rtf" 
src="org.apache.cocoon.serialization.RTFSerializer" 
mime-type="application/msword"/>
   
   
  +
                                 Happy hacking from the Apache Cocoon 2 Dev 
Team :)
   
   ============================================================================ 
-->
  @@ -299,6 +302,9 @@
       <available property="jaxen.present" classname="org.jaxen.dom.XPath">
         <classpath refid="classpath"/>
       </available>
  +    <available property="jfor.present" 
classname="org.jfor.jfor.converter.Converter">
  +      <classpath refid="classpath"/>
  +    </available>
     </target>
   
     <!-- =================================================================== 
-->
  @@ -322,6 +328,7 @@
           <exclude name="**/LDAPTransformer*.java" unless="naming.present"/>
           <exclude name="**/JSPEngineImplWLS.java" unless="weblogic.present"/>
           <exclude name="**/XMLDB*.java" unless="xmldb.present"/>
  +        <exclude name="**/RTFSerializer.java" unless="jfor.present"/>
           <exclude name="**/browser/*.x*"/>
           <exclude name="**/samples/parentcm/*.java" unless="naming.present"/>
         </fileset>
  @@ -658,6 +665,18 @@
     </target>
   
     <!-- =================================================================== 
-->
  +  <!-- Prepares the webapp sitemap if JFOR is available                  -->
  +  <!-- =================================================================== 
-->
  +  <target name="prepare-webapp-jfor" depends="copy-webapp" if="jfor.present">
  +    <java classname="st">
  +        <arg line="-i ${build.war}/sitemap.xmap -o ${build.war}/sitemap.xmap 
-a serializers fo2rtf org.apache.cocoon.serialization.RTFSerializer"/>
  +        <classpath>
  +          <pathelement location="${bin.dir}"/>
  +        </classpath>
  +    </java>
  +  </target>
  +
  +  <!-- =================================================================== 
-->
     <!-- Prepares the webapp sitemap if jtidy is available                     
-->
     <!-- =================================================================== 
-->
     <target name="prepare-webapp-tidy" depends="copy-webapp" if="tidy.present">
  @@ -710,7 +729,7 @@
     <!-- =================================================================== 
-->
     <!-- Prepares the webapp directories                                     
-->
     <!-- =================================================================== 
-->
  -  <target name="prepare-webapp" depends="copy-webapp, prepare-webapp-php, 
prepare-webapp-xt, prepare-webapp-fop, prepare-webapp-tidy, 
prepare-webapp-naming, prepare-webapp-xmldb">
  +  <target name="prepare-webapp" depends="copy-webapp, prepare-webapp-php, 
prepare-webapp-xt, prepare-webapp-fop, prepare-webapp-tidy, 
prepare-webapp-naming, prepare-webapp-xmldb, prepare-webapp-jfor">
         <!-- Simply do nothing, just invoke all dependencies -->
     </target>
   
  
  
  
  1.1                  
xml-cocoon2/src/org/apache/cocoon/serialization/RTFSerializer.java
  
  Index: RTFSerializer.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   
*****************************************************************************/
  package org.apache.cocoon.serialization;
  
  import java.net.URL;
  import java.net.MalformedURLException;
  import org.apache.avalon.excalibur.pool.Poolable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  
  import org.apache.cocoon.components.url.URLFactory;
  
  import org.apache.log.Priority;
  import org.apache.log.util.OutputStreamLogger;
  
  import org.jfor.jfor.converter.Converter;
  
  import javax.xml.transform.OutputKeys;
  import javax.xml.transform.sax.TransformerHandler;
  import javax.xml.transform.stream.StreamResult;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.Writer;
  import java.io.BufferedWriter;
  
  import org.xml.sax.SAXException;
  import org.xml.sax.Attributes;
  import org.xml.sax.helpers.AttributesImpl;
  
  /**
   * This class uses the <a href="http://www.jfor.org";>jfor</a> library
   * to serialize XSL:FO documents to RTF streams.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Gianugo Rabellino</a>
   */
  
  public class RTFSerializer extends AbstractTextSerializer
    implements Poolable, Composable {
  
      private Writer rtfWriter = null;
      private Converter handler = null;
      private OutputStreamLogger cocoonLogger = null;
      private ComponentManager manager = null;
  
  
      public RTFSerializer() {
      }
  
      /**
       * Set the current <code>ComponentManager</code> instance used by this
       * <code>Composable</code>.
       */
      public void compose(ComponentManager manager) {
        this.manager = manager;
      }
  
      /**
       * Set the OutputStream where the serializer will write to.
       *
       * @param out the OutputStream
       */
  
  
      public void setOutputStream(OutputStream out) {
          try {
            cocoonLogger =
              new OutputStreamLogger(this.getLogger(), Priority.DEBUG);
  
            rtfWriter =
              new BufferedWriter(new OutputStreamWriter(out));
            handler = new Converter(rtfWriter,
              Converter.createConverterOption(cocoonLogger));
            super.setContentHandler(handler);
  
          } catch (Exception e) {
              getLogger().error("RTFSerializer.setOutputStream()", e);
              throw new RuntimeException(e.toString());
          }
      }
  
      /**
       * Recycle the serializer. GC instance variables
       */
      public void recycle() {
          super.recycle();
          rtfWriter = null;
          handler = null;
          cocoonLogger = null;
      }
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to