You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by lt...@apache.org on 2009/04/08 14:12:37 UTC

svn commit: r763202 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo: FoConfiguration.java FoSink.java

Author: ltheussl
Date: Wed Apr  8 12:12:36 2009
New Revision: 763202

URL: http://svn.apache.org/viewvc?rev=763202&view=rev
Log:
[DOXIA-305] make layout properties configurable

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java?rev=763202&r1=763201&r2=763202&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoConfiguration.java Wed Apr  8 12:12:36 2009
@@ -20,7 +20,6 @@
  */
 
 import java.io.File;
-import java.io.FileReader;
 import java.io.IOException;
 import java.util.List;
 
@@ -60,18 +59,7 @@
         // necessary because some attributes contain commas:
         config.setDelimiterParsingDisabled( true );
 
-        try
-        {
-            config.load( getClass().getResourceAsStream( "/fo-styles.xslt" ) );
-        }
-        catch ( ConfigurationException cex )
-        {
-            // this should not happen
-            throw new RuntimeException( cex );
-        }
-
-        this.sets = config.getList( "xsl:attribute-set[@name]" );
-        reset();
+        loadDefaultConfig();
     }
 
     /**
@@ -87,20 +75,20 @@
     public void load( File configFile )
             throws IOException
     {
-        // this overloads default values with custom config
+        config.clear();
+
         try
         {
-            config.load( new FileReader( configFile ) );
+            config.load( configFile );
         }
         catch ( ConfigurationException cex )
         {
             IOException ioe = new IOException();
             ioe.initCause( cex );
-            throw  ioe;
+            throw ioe;
         }
 
-        this.sets = config.getList( "xsl:attribute-set[@name]" );
-        reset();
+        loadDefaultConfig(); // this adds default values that are missing from above
     }
 
     /**
@@ -168,10 +156,12 @@
         String keybase = "xsl:attribute-set(" + String.valueOf( index ) + ")";
 
         Object prop = config.getProperty( keybase + ".xsl:attribute" );
+
         if ( prop instanceof List )
         {
             List values = (List) prop;
             List keys = config.getList( keybase + ".xsl:attribute[@name]" );
+
             for ( int i = 0; i < values.size(); i++ )
             {
                 attributeSet.addAttribute( keys.get( i ), values.get( i ) );
@@ -185,12 +175,30 @@
         }
 
         String extend = config.getString( keybase + "[@use-attribute-sets]" );
+
         if ( extend != null )
         {
             addAttributes( extend );
         }
     }
 
+    /** Load the default fo configuration file. */
+    private void loadDefaultConfig()
+    {
+        try
+        {
+            config.load( getClass().getResourceAsStream( "/fo-styles.xslt" ) );
+        }
+        catch ( ConfigurationException cex )
+        {
+            // this should not happen
+            throw new RuntimeException( cex );
+        }
+
+        this.sets = config.getList( "xsl:attribute-set[@name]" );
+        reset();
+    }
+
     /**
      * (Re-)initialize the AttributeSet.
      */

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java?rev=763202&r1=763201&r2=763202&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java Wed Apr  8 12:12:36 2009
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import java.io.File;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.io.Writer;
@@ -140,6 +141,22 @@
 
     // TODO add FOP compliance mode?
 
+    /**
+     * Load configuration parameters from a File.
+     *
+     * @param configFile the configuration file.
+     *
+     * @throws java.io.IOException if the File cannot be read
+     *  or some error occurs when initializing the configuration parameters.
+     *
+     * @since 1.1.1
+     */
+    public void load( File configFile )
+            throws IOException
+    {
+        config.load( configFile );
+    }
+
     /** {@inheritDoc} */
     public void head()
     {