]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Simplified configuration XML as proposed.
authorJeremias Maerki <jeremias@apache.org>
Mon, 24 Oct 2005 19:48:37 +0000 (19:48 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 24 Oct 2005 19:48:37 +0000 (19:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@328145 13f79535-47bb-0310-9956-ffa450edef68

conf/fop.xconf
src/java/org/apache/fop/apps/FOUserAgent.java

index c5534b134a16cf2c73809357756a376796312f93..a997a89d2ad975a1f3b703c94dad63e94b1df86e 100644 (file)
@@ -14,15 +14,13 @@ the location of this file.
 <!-- NOTE: This is the version of the configuration -->
 <fop version="1.0">
 
-  <base url="./"/>
-  <!-- pixel to millimeter to specify dpi, 72dpi -->
-  <pixelToMillimeter value="0.35277777777777777778"/>
-  <pagesettings>
-  <!-- default page-height and page-width, in case
+  <!-- Base URL for resolving relative URLs -->
+  <base>.</base>
+  <!-- Internal resolution in dpi (dots/pixels per inch), default: 72dpi -->
+  <resolution>72</resolution>
+  <!-- Default page-height and page-width, in case
        value is specified as auto -->
-    <pageHeight value="11in"/>
-    <pageWidth value="8.26in"/>
-  </pagesettings>
+  <default-page-settings height="11in" width="8.26in"/>
   
   <!-- Information for specific renderers -->
   <!-- Uses renderer mime type for renderers -->
index b462bc58c79bbddd4ef3db7e7ac858a6f10e564e..567bd531bc82f9b87ce2d645561a8ee77933ba49 100644 (file)
@@ -355,14 +355,16 @@ public class FOUserAgent {
         log.info("Initializing User Agent Configuration");
         if (userConfig.getChild("base", false) != null) {
             try {
-                String cfgBaseDir = userConfig.getChild("base")
-                                    .getAttribute("url");
-                File dir = new File(cfgBaseDir);
-                if (dir.isDirectory()) {
-                    cfgBaseDir = "file://" + dir.getCanonicalPath() 
-                        + System.getProperty("file.separator");
+                String cfgBaseDir = userConfig.getChild("base").getValue(null);
+                if (cfgBaseDir != null) {
+                    File dir = new File(cfgBaseDir);
+                    if (dir.isDirectory()) {
+                        cfgBaseDir = "file://" + dir.getCanonicalPath() 
+                            + System.getProperty("file.separator");
+                        cfgBaseDir = cfgBaseDir.replace(
+                                System.getProperty("file.separator").charAt(0), '/');
+                    }
                 }
-                URL cfgBaseURL = new URL(cfgBaseDir);
                 setBaseURL(cfgBaseDir);
             } catch (MalformedURLException mue) {
                 log.error("Base URL in user config is malformed!");
@@ -374,17 +376,18 @@ public class FOUserAgent {
         if (userConfig.getChild("pixelToMillimeter", false) != null) {
             this.px2mm = userConfig.getChild("pixelToMillimeter")
                             .getAttributeAsFloat("value", DEFAULT_PX2MM);
-            log.info("pixelToMillimeter set to: " + px2mm);
+            log.info("pixelToMillimeter set to: " + px2mm + " (" + (25.4f / px2mm) + "dpi)");
+        } else if (userConfig.getChild("resolution", false) != null) {
+            this.px2mm = 25.4f / userConfig.getChild("resolution").getValueAsFloat(DEFAULT_PX2MM);
+            log.info("pixelToMillimeter set to: " + px2mm + " (" + (25.4f / px2mm) + "dpi)");
         }
-        Configuration pageConfig = userConfig.getChild("pagesettings");
-        if (pageConfig.getChild("pageHeight", false) != null) {
-            setPageHeight(pageConfig.getChild("pageHeight")
-                            .getAttribute("value"));
+        Configuration pageConfig = userConfig.getChild("default-page-settings");
+        if (pageConfig.getAttribute("height", null) != null) {
+            setPageHeight(pageConfig.getAttribute("height"));
             log.info("Default page-height set to: " + pageHeight);
         }
-        if (pageConfig.getChild("pageWidth", false) != null) {
-            setPageWidth(pageConfig.getChild("pageWidth")
-                            .getAttribute("value"));
+        if (pageConfig.getAttribute("width", null) != null) {
+            setPageWidth(pageConfig.getAttribute("width"));
             log.info("Default page-width set to: " + pageWidth);
         }
     }