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 2004/11/01 16:04:51 UTC

cvs commit: xml-fop/src/java/org/apache/fop/render/rtf PageAttributesConverter.java TextAttributesConverter.java TableAttributesConverter.java ListAttributesConverter.java FOPRtfAttributes.java

jeremias    2004/11/01 07:04:51

  Modified:    src/java/org/apache/fop/render/rtf
                        PageAttributesConverter.java
                        TextAttributesConverter.java
                        TableAttributesConverter.java
                        ListAttributesConverter.java FOPRtfAttributes.java
  Log:
  Correct handling of internal units (both twips and half-points are used)
  
  Revision  Changes    Path
  1.13      +9 -9      xml-fop/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
  
  Index: PageAttributesConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PageAttributesConverter.java	20 Oct 2004 17:53:35 -0000	1.12
  +++ PageAttributesConverter.java	1 Nov 2004 15:04:50 -0000	1.13
  @@ -50,8 +50,8 @@
               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 @@
                   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");
  
  
  
  1.22      +6 -6      xml-fop/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
  
  Index: TextAttributesConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- TextAttributesConverter.java	1 Nov 2004 12:39:14 -0000	1.21
  +++ TextAttributesConverter.java	1 Nov 2004 15:04:50 -0000	1.22
  @@ -132,7 +132,7 @@
       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 @@
       }
   
       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);
       }
   
   
  
  
  
  1.23      +2 -2      xml-fop/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
  
  Index: TableAttributesConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TableAttributesConverter.java	1 Nov 2004 12:39:14 -0000	1.22
  +++ TableAttributesConverter.java	1 Nov 2004 15:04:50 -0000	1.23
  @@ -79,7 +79,7 @@
       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;
       }
   
  
  
  
  1.10      +3 -3      xml-fop/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java
  
  Index: ListAttributesConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ListAttributesConverter.java	20 Oct 2004 17:53:35 -0000	1.9
  +++ ListAttributesConverter.java	1 Nov 2004 15:04:50 -0000	1.10
  @@ -44,8 +44,8 @@
           
           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
  
  
  
  1.3       +15 -3     xml-fop/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
  
  Index: FOPRtfAttributes.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FOPRtfAttributes.java	1 Nov 2004 12:38:48 -0000	1.2
  +++ FOPRtfAttributes.java	1 Nov 2004 15:04:50 -0000	1.3
  @@ -29,13 +29,25 @@
    * A RtfAttributes subclass that adds some helper set methods. 
    */
   public class FOPRtfAttributes extends RtfAttributes {
  +
       /**
  -     * Set an attribute that has a Length value
  +     * 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 set(String name, Length value) {
  +    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 (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 setHalfPoints(String name, Length value) {
           set(name, value.getValue() / (1000 / 2)); //Convert millipoints to half-points
           return this;
       }
  
  
  

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