Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jfor/jfor/cocoon1/Cocoon1Formatter.java


1   package org.jfor.jfor.cocoon1;
2   
3   import java.io.Writer;
4   import java.util.Dictionary;
5   
6   import org.w3c.dom.Document;
7   
8   import org.apache.cocoon.formatter.AbstractFormatter;
9   import org.apache.cocoon.formatter.Formatter;
10  import org.apache.cocoon.framework.Configurations;
11  
12  import org.jfor.jfor.main.JForVersionInfo;
13  import org.jfor.jfor.converter.Converter;
14  
15  /*-----------------------------------------------------------------------------
16   * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
17   *
18   * ====================================================================
19   * jfor Apache-Style Software License.
20   * Copyright (c) 2002 by the jfor project. All rights reserved.
21   *
22   * Redistribution and use in source and binary forms, with or without
23   * modification, are permitted provided that the following conditions
24   * are met:
25   *
26   * 1. Redistributions of source code must retain the above copyright
27   * notice, this list of conditions and the following disclaimer.
28   *
29   * 2. Redistributions in binary form must reproduce the above copyright
30   * notice, this list of conditions and the following disclaimer in
31   * the documentation and/or other materials provided with the
32   * distribution.
33   *
34   * 3. The end-user documentation included with the redistribution,
35   * if any, must include the following acknowledgment:
36   * "This product includes software developed
37   * by the jfor project (http://www.jfor.org)."
38   * Alternately, this acknowledgment may appear in the software itself,
39   * if and wherever such third-party acknowledgments normally appear.
40   *
41   * 4. The name "jfor" must not be used to endorse
42   * or promote products derived from this software without prior written
43   * permission.  For written permission, please contact info@jfor.org.
44   *
45   * 5. Products derived from this software may not be called "jfor",
46   * nor may "jfor" appear in their name, without prior written
47   * permission of info@jfor.org.
48   *
49   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
50   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
52   * DISCLAIMED.  IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
53   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
54   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
55   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
56   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
57   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58   * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
59   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60   * ====================================================================
61   * Contributor(s):
62   *  @author Andreas Putz a.putz@skynamics.com
63  -----------------------------------------------------------------------------*/
64  
65  /**  Formatter for Cocoon 1.8 that takes an XSL:FO document as input and converts
66   *  it to RTF using the jfor Converter.
67   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
68   */
69  
70  //------------------------------------------------------------------------------
71  // $Id: Cocoon1Formatter.java,v 1.3 2002/07/12 08:08:31 bdelacretaz Exp $
72  // $Log: Cocoon1Formatter.java,v $
73  // Revision 1.3  2002/07/12 08:08:31  bdelacretaz
74  // License changed to jfor Apache-style license
75  //
76  // Revision 1.2  2001/08/31 07:51:00  bdelacretaz
77  // MPL license text added + javadoc class comments corrected
78  //
79  // Revision 1.1  2001/08/29 13:27:51  bdelacretaz
80  // V0.4.1 - base package name changed to org.jfor.jfor
81  //
82  // Revision 1.2  2001/08/27 20:35:05  putzi
83  // Bigfix in external graphic, insert alignment in paragraph, Converter option.
84  //
85  // Revision 1.1.1.1  2001/08/02 12:53:44  bdelacretaz
86  // initial SourceForge checkin of V0.1 code
87  //
88  //------------------------------------------------------------------------------
89  
90  public class Cocoon1Formatter extends AbstractFormatter {
91    /** TODO is this correct, or use text/richtext or something? */
92    public static final String RTF_MIME_TYPE = "application/msword";
93  
94    public Cocoon1Formatter() {
95      super.MIMEtype = RTF_MIME_TYPE;
96      super.statusMessage = "RTF Formatter using " + JForVersionInfo.getShortVersionInfo();
97    }
98  
99    /** called by cocoon before format() */
100   public void init(Configurations conf) {
101     super.init(conf);
102     //TODO set "binary" method? what's the value?
103     //format.setMethod(Method.TEXT);
104     format.setOmitXMLDeclaration(true);
105   }
106 
107   /** format the given Document and write results to given Writer */
108   public void format(Document document, Writer writer, Dictionary p)
109   throws Exception {
110     // TODO have Converter log write to the Cocoon log?
111     new Converter(document,writer,Converter.createConverterOption ());
112   }
113 }