瀏覽代碼

Merged revisions 706319,706570,707083 via svnmerge from

https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk

........
  r706319 | jeremias | 2008-10-20 16:11:08 +0100 (Mon, 20 Oct 2008) | 2 lines
  
  Bugzilla #45956:
  Minimal support for leader-pattern="rule" for PCL output.
........
  r706570 | jeremias | 2008-10-21 11:13:27 +0100 (Tue, 21 Oct 2008) | 1 line
  
  Reluctantly added a note about how to clear the image cache.
........
  r707083 | acumiskey | 2008-10-22 15:05:56 +0100 (Wed, 22 Oct 2008) | 2 lines
  
  Been hanging around here unused since 2002 and no longer relevant as far as I can tell.
........


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@707084 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_0
Adrian Cumiskey 15 年之前
父節點
當前提交
967e74f75c

+ 0
- 240
src/documentation/cocoon.diff 查看文件

@@ -1,240 +0,0 @@
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.4
diff -u -r1.4 FOPSerializer.java
--- src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java 21 Nov 2002 18:18:48 -0000 1.4
+++ src/blocks/fop/java/org/apache/cocoon/serialization/FOPSerializer.java 5 Dec 2002 09:21:13 -0000
@@ -63,18 +63,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;
/**
@@ -84,7 +94,7 @@
*/
public class FOPSerializer
extends AbstractSerializer
-implements Composable, Configurable, CacheableProcessingComponent {
+implements Composable, Configurable, CacheableProcessingComponent, RequestLifecycleComponent {
/**
* The Renderer Factory to use
@@ -97,6 +107,11 @@
protected Driver driver;
/**
+ * The current <code>FOUserAgent</code>.
+ */
+ protected FOUserAgent userAgent;
+
+ /**
* The current <code>Renderer</code>.
*/
protected Renderer renderer;
@@ -145,24 +160,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);
@@ -180,28 +177,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");
@@ -233,6 +208,22 @@
+ "no renderer was specified in the sitemap configuration."
);
}
+ this.renderer.setCreator("Cocoon");
+
+ 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();
+
}
/**
@@ -242,27 +233,39 @@
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().debug("Loading image from " + source.getSystemId());
+ InputStream is = source.getInputStream();
+ getLogger().debug("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 CascadingRuntimeException("Cannot load class " + this.rendererName, e);
- }
- }
- this.driver.setRenderer(this.renderer);
this.driver.setOutputStream(out);
setContentHandler(this.driver.getContentHandler());
}
@@ -296,8 +299,7 @@
*/
public void recycle() {
super.recycle();
- this.driver = null;
- this.renderer = null;
+ this.driver.reset();
}
/**
@@ -307,3 +309,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 5 Dec 2002 09:21:13 -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 serializer
+ if(this.serializer instanceof RequestLifecycleComponent) {
+ ((RequestLifecycleComponent)this.serializer).setup(
+ environment,
+ environment.getObjectModel()
);
}

+ 6
- 2
src/documentation/content/xdocs/0.95/graphics.xml 查看文件

@@ -554,10 +554,14 @@
changing dummy parameter on the URI to avoid caching.
</p>
<p>
The image cache has been improved considerably in the redesigned code. Therefore, a
resetCache() method like in earlier versions of FOP has become unnecessary. If you
The image cache has been improved considerably in the redesigned code. Therefore,
resetting the image cache should be a thing of the past. If you
still experience OutOfMemoryErrors, please notify us.
</p>
<p>
If all else fails, the image cache can be cleared like this:
<code>fopFactory.getImageManager().getCache().clearCache();</code>
</p>
</section>
</body>
</document>

+ 6
- 2
src/documentation/content/xdocs/trunk/graphics.xml 查看文件

@@ -554,10 +554,14 @@
changing dummy parameter on the URI to avoid caching.
</p>
<p>
The image cache has been improved considerably in the redesigned code. Therefore, a
resetCache() method like in earlier versions of FOP has become unnecessary. If you
The image cache has been improved considerably in the redesigned code. Therefore,
resetting the image cache should be a thing of the past. If you
still experience OutOfMemoryErrors, please notify us.
</p>
<p>
If all else fails, the image cache can be cleared like this:
<code>fopFactory.getImageManager().getCache().clearCache();</code>
</p>
</section>
</body>
</document>

+ 33
- 1
src/java/org/apache/fop/render/pcl/PCLRenderer.java 查看文件

@@ -59,6 +59,7 @@ import org.apache.xmlgraphics.image.loader.util.ImageUtil;
import org.apache.xmlgraphics.java2d.GraphicContext;
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.xmlgraphics.util.QName;
import org.apache.xmlgraphics.util.UnitConv;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;
@@ -74,6 +75,7 @@ import org.apache.fop.area.inline.AbstractTextArea;
import org.apache.fop.area.inline.ForeignObject;
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.Leader;
import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.Viewport;
@@ -97,7 +99,6 @@ import org.apache.fop.render.java2d.InstalledFontCollection;
import org.apache.fop.render.java2d.Java2DRenderer;
import org.apache.fop.render.pcl.extensions.PCLElementMapping;
import org.apache.fop.traits.BorderProps;
import org.apache.xmlgraphics.util.UnitConv;

/* Note:
* There are some commonalities with AbstractPathOrientedRenderer but it's not possible
@@ -1658,6 +1659,37 @@ public class PCLRenderer extends PrintRenderer {
}
}

/** {@inheritDoc} */
public void renderLeader(Leader area) {
renderInlineAreaBackAndBorders(area);

saveGraphicsState();
int style = area.getRuleStyle();
float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f;
float starty = (currentBPPosition + area.getOffset()) / 1000f;
float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
+ area.getIPD()) / 1000f;
float ruleThickness = area.getRuleThickness() / 1000f;
Color col = (Color)area.getTrait(Trait.COLOR);

switch (style) {
case EN_SOLID:
case EN_DASHED: //TODO Improve me and following (this is just a quick-fix ATM)
case EN_DOUBLE:
case EN_DOTTED:
case EN_GROOVE:
case EN_RIDGE:
updateFillColor(col);
fillRect(startx, starty, endx - startx, ruleThickness);
break;
default:
throw new UnsupportedOperationException("rule style not supported");
}

restoreGraphicsState();
super.renderLeader(area);
}

/**
* Controls whether all text should be generated as bitmaps or only text for which there's
* no native font.

Loading…
取消
儲存