From ccea3d332e7ff9a0f7b9ff60bf8a760b9214b0a9 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Tue, 12 Nov 2002 09:12:36 +0000 Subject: [PATCH] diffs to make fop cvs trunk work with cocoon and forrest better handles images, pdf bookmarks and some other changes git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195507 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/cocoon.diff | 240 +++++++++++++++++++++++++++++++++ src/documentation/forrest.diff | 150 +++++++++++++++++++++ 2 files changed, 390 insertions(+) create mode 100644 src/documentation/cocoon.diff create mode 100644 src/documentation/forrest.diff diff --git a/src/documentation/cocoon.diff b/src/documentation/cocoon.diff new file mode 100644 index 000000000..9757fe3a4 --- /dev/null +++ b/src/documentation/cocoon.diff @@ -0,0 +1,240 @@ +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 FOUserAgent. ++ */ ++ protected FOUserAgent userAgent; ++ ++ /** + * The current Renderer. + */ + 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 OutputStream 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() + ); + } + diff --git a/src/documentation/forrest.diff b/src/documentation/forrest.diff new file mode 100644 index 000000000..45c4d9f7d --- /dev/null +++ b/src/documentation/forrest.diff @@ -0,0 +1,150 @@ +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 @@ + + + + +@@ -80,14 +81,52 @@ + + + +- ++ ++ ++ ++ ++ + + + + + + +- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Created by: FOP 1.0dev ++ ++ ++ ++ ++ http://xml.apache.org/fop/dev ++ ++ ++ ++ ++ + + + +@@ -102,6 +141,7 @@ + text-align="start"> + Page + ++ + + + +@@ -110,6 +150,7 @@ + font-style="italic"> + + ++ + + + +@@ -131,6 +172,7 @@ + font-style="italic"> + + ++ + + + +@@ -191,7 +233,12 @@ + NOTICE: + + +- ++ + + + 0 +@@ -201,9 +248,15 @@ + font-family="serif" + font-size="{$size}pt" + font-weight="bold" +- space-before="12pt"> ++ space-before="12pt" ++ id="{generate-id()}"> + + ++ ++ ++ ++ ++ + + + +@@ -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"> + + +@@ -456,7 +512,14 @@ + + + ++ ++ ++ ++ ++ + ++ ++ + + + -- 2.39.5