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/05 13:30:53 UTC

svn commit: r278720 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf: BorderAttributesConverter.java RTFHandler.java TextAttributesConverter.java rtflib/rtfdoc/IBorderAttributes.java

Author: jeremias
Date: Mon Sep  5 04:30:47 2005
New Revision: 278720

URL: http://svn.apache.org/viewcvs?rev=278720&view=rev
Log:
Bugzilla #36476:
Border support on block, block-container and inline introduced. Nesting borders are supported partially: only two levels of nesting.
Consecutive paragraphs with identical border formatting are considered part
of a single group with the border information applying to the entire group.

Bugzilla #36477:
start-indent and end-indent are used instead of margins only to do indentation.

Submitted by: Sergey Simonchik <Sergey.Simonchik.at.borland.com>

Changes to the patch by jeremias:
Fix for deferred handling which didn't work for block-containers. They got ignored.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.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=278720&r1=278719&r2=278720&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 Mon Sep  5 04:30:47 2005
@@ -52,7 +52,7 @@
             attrs.set(IBorderAttributes.BORDER_COLOR, border.getBorderColor(side));
             attrs.set(convertAttributetoRtf(styleEnum));
             //division by 50 to convert millipoints to twips
-            attrs.set(IBorderAttributes.BORDER_WIDTH, border.getBorderWidth(side, false)/50);
+            attrs.set(IBorderAttributes.BORDER_WIDTH, border.getBorderWidth(side, false) / 50);
             attributes.set(controlWord, attrs);
         }
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=278720&r1=278719&r2=278720&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java Mon Sep  5 04:30:47 2005
@@ -1174,6 +1174,12 @@
             } else {
                 endBlock( (Block) foNode);
             }
+        } else if (foNode instanceof BlockContainer) {
+            if (bStart) {
+                startBlockContainer( (BlockContainer) foNode);
+            } else {
+                endBlockContainer( (BlockContainer) foNode);
+            }
         } else if (foNode instanceof BasicLink) {
             //BasicLink must be placed before Inline
             if (bStart) {
@@ -1257,6 +1263,8 @@
             } else {
                 endCell( (TableCell) foNode);
             }
+        } else {
+            log.warn("Ignored deferred event for " + foNode);
         }
     }
     

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java?rev=278720&r1=278719&r2=278720&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Mon Sep  5 04:30:47 2005
@@ -23,6 +23,7 @@
 import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FOText;
 import org.apache.fop.fo.flow.Block;
 import org.apache.fop.fo.flow.BlockContainer;
@@ -33,12 +34,13 @@
 import org.apache.fop.fo.properties.CommonFont;
 import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.CommonTextDecoration;
+import org.apache.fop.render.rtf.BorderAttributesConverter;
+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.RtfColorTable;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFontManager;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
 
-
 /**  Converts FO properties to RtfAttributes
  *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
  *  @author Andreas Putz a.putz@skynamics.com
@@ -63,6 +65,7 @@
         attrBlockBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
         attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
         attrBlockTextAlign(fobj.getTextAlign(), attrib);
+        attrBorder(fobj.getCommonBorderPaddingBackground(), attrib, fobj);
 
         return attrib;
     }
@@ -77,6 +80,7 @@
         attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
         attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
         //attrBlockDimension(fobj, attrib);
+        attrBorder(fobj.getCommonBorderPaddingBackground(), attrib, fobj);
 
         return attrib;
     }
@@ -122,6 +126,7 @@
         attrFontColor(fobj.getColor(), attrib);
 
         attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
+        attrInlineBorder(fobj.getCommonBorderPaddingBackground(), attrib);
         return attrib;
     }
 
@@ -185,8 +190,8 @@
                 cmb.spaceBefore.getOptimum(null).getLength());
         rtfAttr.setTwips(RtfText.SPACE_AFTER, 
                 cmb.spaceAfter.getOptimum(null).getLength());
-        rtfAttr.setTwips(RtfText.LEFT_INDENT_BODY, cmb.marginLeft);
-        rtfAttr.setTwips(RtfText.RIGHT_INDENT_BODY, cmb.marginRight);
+        rtfAttr.setTwips(RtfText.LEFT_INDENT_BODY, cmb.startIndent);
+        rtfAttr.setTwips(RtfText.RIGHT_INDENT_BODY, cmb.endIndent);
     }
 
 
@@ -236,6 +241,58 @@
             rtfAttr.set(RtfText.SHADING_FRONT_COLOR,
                     convertFOPColorToRTF(bpb.backgroundColor));
         }
+    }
+
+    /** Adds border information from <code>bpb</code> to <code>rtrAttr</code>. */
+    private static void attrBorder(CommonBorderPaddingBackground bpb,
+           RtfAttributes rtfAttr, FONode fobj) {
+       if (hasBorder(fobj.getParent())) {
+           attrInlineBorder(bpb, rtfAttr);
+           return;
+       }
+
+       BorderAttributesConverter.makeBorder(bpb,
+               CommonBorderPaddingBackground.BEFORE, rtfAttr,
+               IBorderAttributes.BORDER_TOP);
+       BorderAttributesConverter.makeBorder(bpb,
+               CommonBorderPaddingBackground.AFTER, rtfAttr,
+               IBorderAttributes.BORDER_BOTTOM);
+       BorderAttributesConverter.makeBorder(bpb,
+               CommonBorderPaddingBackground.START, rtfAttr,
+               IBorderAttributes.BORDER_LEFT);
+       BorderAttributesConverter.makeBorder(bpb,
+               CommonBorderPaddingBackground.END, rtfAttr,
+               IBorderAttributes.BORDER_RIGHT);
+    }
+
+    /** @return true, if element <code>node</code> has border. */
+    private static boolean hasBorder(FONode node) {
+        while (node != null) {
+            CommonBorderPaddingBackground commonBorderPaddingBackground = null;
+            if (node instanceof Block) {
+                Block block = (Block) node;
+                commonBorderPaddingBackground = block.getCommonBorderPaddingBackground(); 
+            } else if (node instanceof BlockContainer) { 
+                BlockContainer container = (BlockContainer) node;
+                commonBorderPaddingBackground = container.getCommonBorderPaddingBackground();
+            } 
+
+            if (commonBorderPaddingBackground != null 
+                    && commonBorderPaddingBackground.hasBorder()) {
+                return true;
+            }
+
+            node = node.getParent();
+        }
+        return false; 
+    }
+
+    /** Adds inline border information from <code>bpb</code> to <code>rtrAttr</code>. */
+    private static void attrInlineBorder(CommonBorderPaddingBackground bpb,
+            RtfAttributes rtfAttr) {
+        BorderAttributesConverter.makeBorder(bpb,
+                CommonBorderPaddingBackground.BEFORE, rtfAttr,
+                IBorderAttributes.BORDER_CHARACTER);
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java?rev=278720&r1=278719&r2=278720&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java Mon Sep  5 04:30:47 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.
@@ -30,67 +30,77 @@
 
 public interface IBorderAttributes {
 
+    /** Constant for border left */
+    String BORDER_LEFT = "brdrl";
+    /** Constant for border right */
+    String BORDER_RIGHT = "brdrr";
+    /** Constant for border top */
+    String BORDER_TOP = "brdrt";
+    /** Constant for border bottom */
+    String BORDER_BOTTOM = "brdrb";
+    /** Constant for character border (border always appears on all sides) */
+    String BORDER_CHARACTER = "chbrdr";
     /** Constant for a single-thick border */
-    public static final String BORDER_SINGLE_THICKNESS = "brdrs";
+    String BORDER_SINGLE_THICKNESS = "brdrs";
     /** Constant for a double-thick border */
-    public static final String BORDER_DOUBLE_THICKNESS = "brdrth";
+    String BORDER_DOUBLE_THICKNESS = "brdrth";
     /** Constant for a shadowed border */
-    public static final String BORDER_SHADOWED = "brdrsh";
+    String BORDER_SHADOWED = "brdrsh";
     /** Constant for a double border */
-    public static final String BORDER_DOUBLE = "brdrdb";
+    String BORDER_DOUBLE = "brdrdb";
     /** Constant for a dotted border */
-    public static final String BORDER_DOTTED = "brdrdot";
+    String BORDER_DOTTED = "brdrdot";
     /** Constant for a dashed border */
-    public static final String BORDER_DASH = "brdrdash";
+    String BORDER_DASH = "brdrdash";
     /** Constant for a hairline border */
-    public static final String BORDER_HAIRLINE = "brdrhair";
+    String BORDER_HAIRLINE = "brdrhair";
     /** Constant for a small-dashed border */
-    public static final String BORDER_DASH_SMALL = "brdrdashsm";
+    String BORDER_DASH_SMALL = "brdrdashsm";
     /** Constant for a dot-dashed border */
-    public static final String BORDER_DOT_DASH = "brdrdashd";
+    String BORDER_DOT_DASH = "brdrdashd";
     /** Constant for a dot-dot-dashed border */
-    public static final String BORDER_DOT_DOT_DASH = "brdrdashdd";
+    String BORDER_DOT_DOT_DASH = "brdrdashdd";
     /** Constant for a triple border */
-    public static final String BORDER_TRIPLE = "brdrtriple";
+    String BORDER_TRIPLE = "brdrtriple";
     /** Constant for a think-thin-small border */
-    public static final String BORDER_THINK_THIN_SMALL = "brdrtnthsg";
+    String BORDER_THINK_THIN_SMALL = "brdrtnthsg";
     /** Constant for a thin-thick-small border */
-    public static final String BORDER_THIN_THICK_SMALL = "brdrthtnsg";
+    String BORDER_THIN_THICK_SMALL = "brdrthtnsg";
     /** Constant for a thin-thick-thin-small border */
-    public static final String BORDER_THIN_THICK_THIN_SMALL = "brdrthtnthsg";
+    String BORDER_THIN_THICK_THIN_SMALL = "brdrthtnthsg";
     /** Constant for a think-thin-medium border */
-    public static final String BORDER_THINK_THIN_MEDIUM = "brdrtnthmg";
+    String BORDER_THINK_THIN_MEDIUM = "brdrtnthmg";
     /** Constant for a thin-thick-medium border */
-    public static final String BORDER_THIN_THICK_MEDIUM = "brdrthtnmg";
+    String BORDER_THIN_THICK_MEDIUM = "brdrthtnmg";
     /** Constant for a thin-thick-thin-medium border */
-    public static final String BORDER_THIN_THICK_THIN_MEDIUM = "brdrthtnthmg";
+    String BORDER_THIN_THICK_THIN_MEDIUM = "brdrthtnthmg";
     /** Constant for a think-thin-large border */
-    public static final String BORDER_THINK_THIN_LARGE = "brdrtnthlg";
+    String BORDER_THINK_THIN_LARGE = "brdrtnthlg";
     /** Constant for a thin-thick-large border */
-    public static final String BORDER_THIN_THICK_LARGE = "brdrthtnlg";
+    String BORDER_THIN_THICK_LARGE = "brdrthtnlg";
     /** Constant for a thin-thick-thin-large border */
-    public static final String BORDER_THIN_THICK_THIN_LARGE = "brdrthtnthlg";
+    String BORDER_THIN_THICK_THIN_LARGE = "brdrthtnthlg";
     /** Constant for a wavy border */
-    public static final String BORDER_WAVY = "brdrwavy";
+    String BORDER_WAVY = "brdrwavy";
     /** Constant for a double wavy border */
-    public static final String BORDER_WAVY_DOUBLE = "brdrwavydb";
+    String BORDER_WAVY_DOUBLE = "brdrwavydb";
     /** Constant for a striped border */
-    public static final String BORDER_STRIPED = "brdrdashdotstr";
+    String BORDER_STRIPED = "brdrdashdotstr";
     /** Constant for an embossed border */
-    public static final String BORDER_EMBOSS = "brdremboss";
+    String BORDER_EMBOSS = "brdremboss";
     /** Constant for an engraved border */
-    public static final String BORDER_ENGRAVE = "brdrengrave";
+    String BORDER_ENGRAVE = "brdrengrave";
     /** Constant for an nil border */
-    public static final String BORDER_NIL = "brdrnil";
+    String BORDER_NIL = "brdrnil";
     /** Constant for border color */
-    public static final String BORDER_COLOR = "brdrcf";
+    String BORDER_COLOR = "brdrcf";
     /** Constant for border space */
-    public static final String BORDER_SPACE = "brsp";
+    String BORDER_SPACE = "brsp";
     /** Constant for border width */
-    public static final String BORDER_WIDTH = "brdrw";
+    String BORDER_WIDTH = "brdrw";
 
     /** String array of border attributes */
-    public static final String [] BORDERS = new String[] {
+    String [] BORDERS = new String[] {
         BORDER_SINGLE_THICKNESS,    BORDER_DOUBLE_THICKNESS,            BORDER_SHADOWED,
         BORDER_DOUBLE,              BORDER_DOTTED,                      BORDER_DASH,
         BORDER_HAIRLINE,            BORDER_DASH_SMALL,                  BORDER_DOT_DASH,



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