keiron      2002/11/12 01:12:36

  Added:       src/documentation cocoon.diff forrest.diff
  Log:
  diffs to make fop cvs trunk work with cocoon and forrest better
  handles images, pdf bookmarks and some other changes
  
  Revision  Changes    Path
  1.1                  xml-fop/src/documentation/cocoon.diff
  
  Index: cocoon.diff
  ===================================================================
  Index: src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java
  ===================================================================
  RCS file: 
/home/cvspublic/xml-cocoon2/src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java,v
  retrieving revision 1.3
  diff -u -r1.3 FOPSerializer.java
  --- src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java    23 Sep 
2002 03:30:44 -0000      1.3
  +++ src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java    8 Nov 
2002 12:06:40 -0000
  @@ -62,18 +62,28 @@
   import org.apache.cocoon.components.url.URLFactory;
   import org.apache.cocoon.util.ClassUtils;
   import org.apache.cocoon.environment.URLFactorySourceResolver;
  -import org.apache.cocoon.environment.Source;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceResolver;
   import org.apache.excalibur.source.SourceValidity;
   import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.apache.fop.apps.Driver;
  -import org.apache.fop.apps.Options;
  -import org.apache.fop.messaging.MessageHandler;
   import org.apache.fop.render.Renderer;
  -import org.apache.fop.configuration.ConfigurationParser;
  +import org.apache.fop.fo.FOUserAgent;
  +import org.apache.cocoon.components.RequestLifecycleComponent;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.cocoon.ProcessingException;
  +import org.xml.sax.SAXException;
  +import org.apache.cocoon.components.RequestLifecycleComponent;
  +
  +import java.io.IOException;
  +import java.util.Map;
   
   import java.io.OutputStream;
   import java.io.File;
   import java.io.Serializable;
  +import java.io.InputStream;
  +import java.net.URL;
   import java.net.MalformedURLException;
   
   /**
  @@ -83,7 +93,7 @@
    */
   public class FOPSerializer
   extends AbstractSerializer
  -implements Composable, Configurable, CacheableProcessingComponent {
  +implements Composable, Configurable, CacheableProcessingComponent, 
RequestLifecycleComponent {
   
       /**
        * The Renderer Factory to use
  @@ -96,6 +106,11 @@
       protected Driver driver;
   
       /**
  +     * The current <code>FOUserAgent</code>.
  +     */
  +    protected FOUserAgent userAgent;
  +
  +    /**
        * The current <code>Renderer</code>.
        */
       protected Renderer renderer;
  @@ -144,24 +159,6 @@
       public void configure(Configuration conf) throws ConfigurationException {
   
           this.logger = getLogger().getChildLogger("fop");
  -        MessageHandler.setScreenLogger(this.logger);
  -
  -        // FIXME: VG: Initialize static FOP configuration with defaults, only once.
  -        // FOP has static config, but that's going to change in the near future.
  -        // Then this code should be reviewed.
  -        synchronized (FOPSerializer.class) {
  -            if (!configured) {
  -                try {
  -                    if (getLogger().isDebugEnabled()) {
  -                        getLogger().debug("Loading default configuration");
  -                    }
  -                    new Options();
  -                } catch (Exception e) {
  -                    getLogger().error("Cannot load default configuration. 
Proceeding.", e);
  -                }
  -                configured = true;
  -            }
  -        }
   
           this.setContentLength = 
conf.getChild("set-content-length").getValueAsBoolean(true);
   
  @@ -179,28 +176,6 @@
               // New syntax: Element user-config contains URL
               configUrl = conf.getChild("user-config").getValue(null);
           }
  -        if(configUrl != null) {
  -            URLFactory urlFactory = null;
  -            Source configSource = null;
  -            try {
  -                // FIXME: How to do without URLFactory but relative to context?
  -                urlFactory = (URLFactory)manager.lookup(URLFactory.ROLE);
  -                URLFactorySourceResolver urlResolver = new 
URLFactorySourceResolver(urlFactory, manager);
  -                configSource = urlResolver.resolve(configUrl);
  -                if (getLogger().isDebugEnabled()) {
  -                    getLogger().debug("Loading configuration from " + 
configSource.getSystemId());
  -                }
  -                configSource.toSAX(new ConfigurationParser());
  -            } catch (Exception e) {
  -                getLogger().warn("Cannot load configuration from " + configUrl);
  -                throw new ConfigurationException("Cannot load configuration from " 
+ configUrl, e);
  -            } finally {
  -                manager.release(urlFactory);
  -                if (configSource != null) {
  -                    configSource.recycle();
  -                }
  -            }
  -        }
   
           // Get the mime type.
           this.mimetype = conf.getAttribute("mime-type");
  @@ -232,6 +207,21 @@
                   + "no renderer was specified in the sitemap configuration."
               );
           }
  +
  +        userAgent = new FOUserAgent();
  +        userAgent.enableLogging(this.logger);
  +        //userAgent.setBaseURL(source.getSystemId());
  +
  +        // load the fop driver
  +        this.driver = new Driver();
  +        driver.enableLogging(this.logger);
  +        driver.setUserAgent(userAgent);
  +
  +        driver.setRenderer(this.renderer);
  +
  +        //driver.configure(conf);
  +        driver.initialize();
  +
       }
   
       /**
  @@ -241,27 +231,40 @@
           return mimetype;
       }
   
  +    public void setup(final org.apache.cocoon.environment.SourceResolver resolver, 
Map objectModel)
  +    throws ProcessingException, SAXException, IOException {
  +
  +        userAgent = new FOUserAgent() {
  +            public InputStream getStream(String uri) {
  +                try {
  +                    Environment env = (Environment) resolver;
  +                    org.apache.cocoon.environment.Source source = null;
  +                    org.apache.cocoon.components.source.CocoonSourceFactory ccf;
  +                    ccf = new 
org.apache.cocoon.components.source.CocoonSourceFactory(null, manager);
  +                    ccf.enableLogging(logger);
  +                    source = ccf.getSource(env, "/" + uri);
  +                    getLogger().error("Loading image from " + source.getSystemId());
  +                    InputStream is = source.getInputStream();
  +                    getLogger().error("input stream: " + is + ":" + is.available());
  +                    return is;
  +                } catch (Exception e) {
  +                    getLogger().error("Cannot load source", e);
  +                }
  +                return null;
  +            }
  +        };
  +        userAgent.enableLogging(this.logger);
  +        //userAgent.setBaseURL(source.getSystemId());
  +
  +        driver.setUserAgent(userAgent);
  +
  +    }
  +
       /**
        * Create the FOP driver
        * Set the <code>OutputStream</code> where the XML should be serialized.
        */
       public void setOutputStream(OutputStream out) {
  -        // load the fop driver
  -        this.driver = new Driver();
  -        this.driver.setLogger(this.logger);
  -        if (this.rendererName == null) {
  -            this.renderer = factory.createRenderer(mimetype);
  -        } else {
  -            try {
  -                this.renderer = (Renderer)ClassUtils.newInstance(this.rendererName);
  -            } catch (Exception e) {
  -                if (getLogger().isWarnEnabled()) {
  -                    getLogger().warn("Cannot load  class " + this.rendererName, e);
  -                }
  -                throw new RuntimeException("Cannot load class " + this.rendererName 
+ "(" + e + ")");
  -            }
  -        }
  -        this.driver.setRenderer(this.renderer);
           this.driver.setOutputStream(out);
           setContentHandler(this.driver.getContentHandler());
       }
  @@ -295,8 +298,7 @@
         */
       public void recycle() {
           super.recycle();
  -        this.driver = null;
  -        this.renderer = null;
  +        this.driver.reset();
       }
   
       /**
  @@ -306,3 +308,4 @@
           return this.setContentLength;
       }
   }
  +
  Index: src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
  ===================================================================
  RCS file: 
/home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
  retrieving revision 1.24
  diff -u -r1.24 AbstractProcessingPipeline.java
  --- src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java   
 11 Oct 2002 08:36:30 -0000      1.24
  +++ src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java   
 8 Nov 2002 12:06:40 -0000
  @@ -62,6 +62,7 @@
   import org.apache.cocoon.ConnectionResetException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.CocoonComponentManager;
  +import org.apache.cocoon.components.RequestLifecycleComponent;
   import org.apache.cocoon.components.treeprocessor.ProcessingNode;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ObjectModelHelper;
  @@ -392,6 +393,15 @@
                       environment.getObjectModel(),
                       (String)transformerSourceItt.next(),
                       (Parameters)transformerParamItt.next()
  +                );
  +            }
  +
  +            // WARNING: quick hack
  +            // setup the generator
  +            if(this.serializer instanceof RequestLifecycleComponent) {
  +                ((RequestLifecycleComponent)this.serializer).setup(
  +                    environment,
  +                    environment.getObjectModel()
                   );
               }
   
  
  
  
  1.1                  xml-fop/src/documentation/forrest.diff
  
  Index: forrest.diff
  ===================================================================
  Index: src/resources/skins/forrest-site/xslt/fo/document2fo.xsl
  ===================================================================
  RCS file: 
/home/cvspublic/xml-forrest/src/resources/skins/forrest-site/xslt/fo/document2fo.xsl,v
  retrieving revision 1.3
  diff -u -r1.3 document2fo.xsl
  --- src/resources/skins/forrest-site/xslt/fo/document2fo.xsl  1 Nov 2002 02:49:58 
-0000       1.3
  +++ src/resources/skins/forrest-site/xslt/fo/document2fo.xsl  8 Nov 2002 12:05:50 
-0000
  @@ -2,6 +2,7 @@
   
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                   xmlns:fo="http://www.w3.org/1999/XSL/Format";
  +                xmlns:fox="http://xml.apache.org/fop/extensions";
                   version="1.0">
   
     <xsl:output method="xml"/>
  @@ -80,14 +81,52 @@
             </fo:repeatable-page-master-alternatives>
           </fo:page-sequence-master>
         </fo:layout-master-set>
  -      
  +
  +      <fox:bookmarks>
  +        <xsl:apply-templates select="document/body/section" mode="bookmarks"/>
  +      </fox:bookmarks>
  +
         <fo:page-sequence master-reference="book">
           <xsl:apply-templates/>
         </fo:page-sequence>
         
       </fo:root>
     </xsl:template>
  -  
  +
  +  <xsl:template match="section" mode="bookmarks">
  +    <fox:outline internal-destination="{generate-id()}">
  +      <fox:label>
  +        <xsl:number format="1.1.1.1.1.1.1" count="section" level="multiple"/>
  +        <xsl:text> </xsl:text>
  +        <xsl:value-of select="title"/>
  +      </fox:label>
  +      <xsl:apply-templates mode="bookmarks"/>
  +    </fox:outline>
  +  </xsl:template>
  +
  +  <xsl:template match="*" mode="bookmarks">
  +    <xsl:apply-templates mode="bookmarks"/>
  +  </xsl:template>
  +
  +  <xsl:template name="info">
  +    <fo:block-container font-style="italic" absolute-position="absolute"
  +              left="0pt" top="0pt" right="6.25in" bottom="150pt"
  +              font-size="10pt">
  +      <fo:block text-align="center">
  +        <fo:basic-link color="lightgrey"
  +                       external-destination="http://xml.apache.org/fop/dev";>
  +          Created by: FOP 1.0dev
  +        </fo:basic-link>
  +      </fo:block>
  +      <fo:block text-align="center">
  +        <fo:basic-link color="lightgrey"
  +                       external-destination="http://xml.apache.org/fop/dev";>
  +          http://xml.apache.org/fop/dev
  +        </fo:basic-link>
  +      </fo:block>
  +    </fo:block-container>
  +  </xsl:template>
  +
     <xsl:template match="document">
       <fo:title><xsl:value-of select="header/title"/></fo:title>
       
  @@ -102,6 +141,7 @@
           text-align="start">
           Page <fo:page-number/>
         </fo:block>
  +      <xsl:call-template name="info"/>
       </fo:static-content>
   
       <fo:static-content flow-name="even-header">
  @@ -110,6 +150,7 @@
           font-style="italic">
           <xsl:value-of select="header/title"/>
         </fo:block>
  +      <xsl:call-template name="info"/>
       </fo:static-content>
   
       <fo:static-content flow-name="even-footer">
  @@ -131,6 +172,7 @@
           font-style="italic">
           <xsl:value-of select="header/title"/>
         </fo:block>
  +      <xsl:call-template name="info"/>
       </fo:static-content>
       
       <fo:static-content flow-name="odd-footer">
  @@ -191,7 +233,12 @@
         NOTICE: <xsl:apply-templates/>
       </fo:block>
     </xsl:template>
  -
  +<!--
  +  <xsl:template match="anchor">
  +    <fo:block id="{@id}"/>
  +    <xsl:apply-templates/>
  +  </xsl:template>
  +-->
     <xsl:template match="section">
       
       <xsl:param name="level">0</xsl:param>
  @@ -201,9 +248,15 @@
         font-family="serif"
         font-size="{$size}pt"
         font-weight="bold"
  -      space-before="12pt">
  +      space-before="12pt"
  +      id="{generate-id()}">
         <xsl:number format="1.1.1.1.1.1.1" count="section" level="multiple"/>
         <xsl:text> </xsl:text>
  +
  +      <xsl:if test="normalize-space(@id)!=''">
  +        <fo:block id="{@id}"/>
  +      </xsl:if>
  +
         <xsl:value-of select="title"/>
       </fo:block>
       <xsl:apply-templates>
  @@ -255,6 +308,9 @@
         font-size="10pt"
         background-color="#f0f0f0"
         white-space-collapse="false"
  +      linefeed-treatment="preserve"
  +      white-space-treatment="preserve"
  +      wrap-option="no-wrap"
         text-align="start">
         <xsl:apply-templates/>
       </fo:block>
  @@ -456,7 +512,14 @@
     </xsl:template>
   
     <xsl:template match="link">
  +    <xsl:choose>
  +      <xsl:when test="starts-with(@href, '#')">
  +    <fo:basic-link color="blue" text-decoration="underline" 
internal-destination="substring(@href,2)"><xsl:apply-templates/></fo:basic-link>
  +      </xsl:when>
  +      <xsl:otherwise>
       <fo:basic-link color="blue" text-decoration="underline" 
external-destination="{@href}"><xsl:apply-templates/></fo:basic-link>
  +      </xsl:otherwise>
  +    </xsl:choose>
     </xsl:template>
   
     <xsl:template match="figure">
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to