]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Correct handling of internal units (both twips and half-points are used)
authorJeremias Maerki <jeremias@apache.org>
Mon, 1 Nov 2004 15:04:50 +0000 (15:04 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 1 Nov 2004 15:04:50 +0000 (15:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198122 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
src/java/org/apache/fop/render/rtf/ListAttributesConverter.java
src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
src/java/org/apache/fop/render/rtf/TextAttributesConverter.java

index d4d80e9b2ef934e74148772e0d2e5cf56bfdc793..5dea87cf5567a57171ef265a28e4438bd6d041d9 100755 (executable)
@@ -29,13 +29,25 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable;
  * A RtfAttributes subclass that adds some helper set methods. 
  */
 public class FOPRtfAttributes extends RtfAttributes {
+
+    /**
+     * Set an attribute that has a Length value (internal units in twips)
+     * @param name name of attribute
+     * @param value value of attribute
+     * @return this (which now contains the new entry)
+     */
+    public RtfAttributes setTwips(String name, Length value) {
+        set(name, value.getValue() / (1000 / 20)); //Convert millipoints to twips
+        return this;
+    }
+
     /**
-     * Set an attribute that has a Length value
+     * Set an attribute that has a Length value (internal units in half-points)
      * @param name name of attribute
      * @param value value of attribute
      * @return this (which now contains the new entry)
      */
-    public RtfAttributes set(String name, Length value) {
+    public RtfAttributes setHalfPoints(String name, Length value) {
         set(name, value.getValue() / (1000 / 2)); //Convert millipoints to half-points
         return this;
     }
index ec3afdacdf6206b199157e5d49fcff02878a14c0..c050e38136884a825750e7c238ae50c76c1dda50 100644 (file)
@@ -44,8 +44,8 @@ public class ListAttributesConverter {
         
         FOPRtfAttributes attrib = new FOPRtfAttributes();
         
-        attrib.set(RtfListTable.LIST_INDENT, fobj.getCommonMarginBlock().startIndent);
-        attrib.set(RtfText.LEFT_INDENT_BODY, fobj.getCommonMarginBlock().endIndent);
+        attrib.setTwips(RtfListTable.LIST_INDENT, fobj.getCommonMarginBlock().startIndent);
+        attrib.setTwips(RtfText.LEFT_INDENT_BODY, fobj.getCommonMarginBlock().endIndent);
         
         /*
          * set list table defaults
index 00efe46b72f6fb95aad79bcc20f0cf93ee5af74b..3947f21d90eeff1fb4a0bcb7fa89eebe05325fa8 100644 (file)
@@ -50,8 +50,8 @@ class PageAttributesConverter {
             RegionBody body   = (RegionBody) pagemaster.getRegion(Constants.FO_REGION_BODY);
             RegionBA after  = (RegionBA) pagemaster.getRegion(Constants.FO_REGION_AFTER);
             
-            attrib.set(RtfPage.PAGE_WIDTH, pagemaster.getPageWidth());
-            attrib.set(RtfPage.PAGE_HEIGHT, pagemaster.getPageHeight());
+            attrib.setTwips(RtfPage.PAGE_WIDTH, pagemaster.getPageWidth());
+            attrib.setTwips(RtfPage.PAGE_HEIGHT, pagemaster.getPageHeight());
             
             Length pageTop = pagemaster.getCommonMarginBlock().marginTop;
             Length pageBottom = pagemaster.getCommonMarginBlock().marginBottom;
@@ -72,24 +72,24 @@ class PageAttributesConverter {
                 bodyRight = (Length) NumericOp.addition(pageRight, bodyMargin.marginRight);
             }
             
-            attrib.set(RtfPage.MARGIN_TOP, bodyTop);
-            attrib.set(RtfPage.MARGIN_BOTTOM, bodyBottom);
-            attrib.set(RtfPage.MARGIN_LEFT, bodyLeft);
-            attrib.set(RtfPage.MARGIN_RIGHT, bodyRight);
+            attrib.setTwips(RtfPage.MARGIN_TOP, bodyTop);
+            attrib.setTwips(RtfPage.MARGIN_BOTTOM, bodyBottom);
+            attrib.setTwips(RtfPage.MARGIN_LEFT, bodyLeft);
+            attrib.setTwips(RtfPage.MARGIN_RIGHT, bodyRight);
 
             //region-before attributes
             Length beforeTop = pageTop;
             if (before != null) {
                 beforeTop = (Length) NumericOp.addition(pageTop, before.getExtent());
             }
-            attrib.set(RtfPage.HEADERY, beforeTop);
+            attrib.setTwips(RtfPage.HEADERY, beforeTop);
 
             //region-after attributes
             Length afterBottom = pageBottom;
             if (after != null) {
                 afterBottom = (Length) NumericOp.addition(pageBottom, after.getExtent());
             }
-            attrib.set(RtfPage.FOOTERY, beforeTop);
+            attrib.setTwips(RtfPage.FOOTERY, beforeTop);
         } catch (Exception e) {
             log.error("Exception in convertPageAttributes: " 
                 + e.getMessage() + "- page attributes ignored");
index 7ccc49ed500a54f7cbcf883dbae4e59bb9bb7d42..25da7bdff838197d5ef869e625b43f169fa96099 100644 (file)
@@ -79,7 +79,7 @@ public class TableAttributesConverter {
     static RtfAttributes convertTableAttributes(Table fobj)
             throws FOPException {
         FOPRtfAttributes attrib = new FOPRtfAttributes();
-        attrib.set(ITableAttributes.ATTR_ROW_LEFT_INDENT, fobj.getCommonMarginBlock().marginLeft);
+        attrib.setTwips(ITableAttributes.ATTR_ROW_LEFT_INDENT, fobj.getCommonMarginBlock().marginLeft);
         return attrib;
     }
 
index 5df06ed1ce858c1c62ec589ee0efa5bf83266e02..a297b642554b043d849535cc76c1943850c362f7 100644 (file)
@@ -132,7 +132,7 @@ class TextAttributesConverter {
     private static void attrFont(CommonFont font, FOPRtfAttributes rtfAttr) {
         rtfAttr.set(RtfText.ATTR_FONT_FAMILY,
                 RtfFontManager.getInstance().getFontNumber(font.fontFamily));
-        rtfAttr.set(RtfText.ATTR_FONT_SIZE, font.fontSize);
+        rtfAttr.setHalfPoints(RtfText.ATTR_FONT_SIZE, font.fontSize);
 
         if (font.fontWeight.equals("bold") || font.fontWeight.equals("700")) {
             rtfAttr.set("b", 1);
@@ -174,12 +174,12 @@ class TextAttributesConverter {
     }
 
     private static void attrBlockMargin(CommonMarginBlock cmb, FOPRtfAttributes rtfAttr) {
-        rtfAttr.set(RtfText.SPACE_BEFORE, 
+        rtfAttr.setTwips(RtfText.SPACE_BEFORE, 
                 cmb.spaceBefore.getOptimum().getLength());
-        rtfAttr.set(RtfText.SPACE_AFTER, 
+        rtfAttr.setTwips(RtfText.SPACE_AFTER, 
                 cmb.spaceAfter.getOptimum().getLength());
-        rtfAttr.set(RtfText.LEFT_INDENT_BODY, cmb.marginLeft);
-        rtfAttr.set(RtfText.RIGHT_INDENT_BODY, cmb.marginRight);
+        rtfAttr.setTwips(RtfText.LEFT_INDENT_BODY, cmb.marginLeft);
+        rtfAttr.setTwips(RtfText.RIGHT_INDENT_BODY, cmb.marginRight);
     }