You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/09/06 14:07:54 UTC

svn commit: r278982 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf: BorderAttributesConverter.java rtflib/rtfdoc/RtfAttributes.java

Author: jeremias
Date: Tue Sep  6 05:07:49 2005
New Revision: 278982

URL: http://svn.apache.org/viewcvs?rev=278982&view=rev
Log:
Bugzilla #36508:
Support for padding-before and padding-after in RTF output.
Submitted by: Sergey Simonchik <Sergey.Simonchik.at.borland.com>

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java?rev=278982&r1=278981&r2=278982&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java Tue Sep  6 05:07:49 2005
@@ -30,6 +30,7 @@
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.IBorderAttributes;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
 
 /** Constants for RTF border attribute names, and a static method for converting
  *  fo attribute strings. */
@@ -54,6 +55,23 @@
             //division by 50 to convert millipoints to twips
             attrs.set(IBorderAttributes.BORDER_WIDTH, border.getBorderWidth(side, false) / 50);
             attributes.set(controlWord, attrs);
+            attrs.setTwips(IBorderAttributes.BORDER_SPACE, border.getPadding(side, false, null));
+            attributes.set(controlWord, attrs);
+        } else {
+            // Here padding specified, but corresponding border is not available
+            
+            // Padding in millipoints
+            double paddingPt = border.getPadding(side, false, null) / 1000.0;
+            // Padding in twips
+            int padding = (int) Math.round(paddingPt * FoUnitsConverter.POINT_TO_TWIPS);
+            
+            // Add padding to corresponding space (space-before or space-after)
+            // if side == START or END, do nothing
+            if (side == CommonBorderPaddingBackground.BEFORE) {
+                attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE);
+            } else if (side == CommonBorderPaddingBackground.AFTER) {
+                attributes.addIntegerValue(padding, RtfText.SPACE_AFTER);
+            }
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java?rev=278982&r1=278981&r2=278982&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java Tue Sep  6 05:07:49 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -147,7 +147,7 @@
     /**
      * Set an attribute that has nested attributes as value
      * @param name name of attribute
-     * @param type value of the nested attributes
+     * @param value value of the nested attributes
      * @return this (which now contains the new entry)
      */
     public RtfAttributes set(String name, RtfAttributes value) {
@@ -214,5 +214,18 @@
         } else {
             xslAttributes = new org.xml.sax.helpers.AttributesImpl(pAttribs);
         }
+    }
+    
+    /**
+     * Add integer value <code>addValue</code> to attribute with name <code>name</code>.
+     * If there is no such setted attribute, then value of this attribure is equal to 
+     * <code>addValue</code>.
+     * @param addValue the increment of value
+     * @param name the name of attribute
+     */
+    public void addIntegerValue(int addValue, String name) {
+        Integer value = (Integer) getValue(name);
+        int v = (value != null) ? value.intValue() : 0; 
+        set(name, v + addValue);
     }
 }



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