Author: ssteiner
Date: Tue Nov 30 15:46:24 2021
New Revision: 1895426

URL: http://svn.apache.org/viewvc?rev=1895426&view=rev
Log:
FOP-3028: Set values in fopFactoryBuilder setConfiguration

Modified:
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java?rev=1895426&r1=1895425&r2=1895426&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java
 Tue Nov 30 15:46:24 2021
@@ -154,10 +154,15 @@ public class FopConfParser {
             throw new FOPException(e);
         }
         // The default base URI is taken from the directory in which the 
fopConf resides
-        fopFactoryBuilder = new 
FopFactoryBuilder(enviro).setConfiguration(cfg);
+        fopFactoryBuilder = new 
FopFactoryBuilder(enviro).setConfiguration(cfg, false);
         configure(baseURI, enviro.getResourceResolver(), cfg);
     }
 
+    public FopConfParser(Configuration cfg, FopFactoryBuilder 
fopFactoryBuilder) throws SAXException {
+        this.fopFactoryBuilder = fopFactoryBuilder;
+        configure(fopFactoryBuilder.getBaseURI(), 
ResourceResolverFactory.createDefaultResourceResolver(), cfg);
+    }
+
     private void configure(final URI baseURI, final ResourceResolver 
resourceResolver,
             Configuration cfg) throws FOPException {
         if (log.isDebugEnabled()) {

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java?rev=1895426&r1=1895425&r2=1895426&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java
 Tue Nov 30 15:46:24 2021
@@ -26,6 +26,8 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
+import org.xml.sax.SAXException;
+
 import org.apache.xmlgraphics.image.loader.ImageContext;
 import org.apache.xmlgraphics.image.loader.ImageManager;
 import 
org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
@@ -301,7 +303,18 @@ public final class FopFactoryBuilder {
      * @return <code>this</code>
      */
     public FopFactoryBuilder setConfiguration(Configuration cfg) {
+        return setConfiguration(cfg, true);
+    }
+
+    protected FopFactoryBuilder setConfiguration(Configuration cfg, boolean 
parse) {
         fopFactoryConfigBuilder.setConfiguration(cfg);
+        if (parse) {
+            try {
+                new FopConfParser(cfg, this);
+            } catch (SAXException e) {
+                throw new RuntimeException(e);
+            }
+        }
         return this;
     }
 

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java?rev=1895426&r1=1895425&r2=1895426&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java
 Tue Nov 30 15:46:24 2021
@@ -19,6 +19,8 @@
 
 package org.apache.fop.apps;
 
+import java.io.ByteArrayInputStream;
+import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -36,6 +38,8 @@ import static org.junit.Assert.fail;
 import org.apache.fop.apps.io.ResourceResolverFactory;
 import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.area.Block;
+import org.apache.fop.configuration.Configuration;
+import org.apache.fop.configuration.DefaultConfigurationBuilder;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.extensions.ExternalDocument;
 import org.apache.fop.fo.pagination.Flow;
@@ -288,4 +292,14 @@ public class FopFactoryBuilderTestCase {
             // Expected
         }
     }
+
+    @Test
+    public void testSetConfiguration() throws Exception {
+        String fopxconf = "<fop version=\"1.0\">\n"
+                + "<source-resolution>288</source-resolution>"
+                + "</fop>";
+        Configuration cfg = new DefaultConfigurationBuilder().build(new 
ByteArrayInputStream(fopxconf.getBytes()));
+        FopFactory fopFactory = new FopFactoryBuilder(new 
File(".").toURI()).setConfiguration(cfg).build();
+        assertEquals((int)fopFactory.getSourceResolution(), 288);
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org

Reply via email to