aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-09-05 11:30:47 +0000
committerJeremias Maerki <jeremias@apache.org>2005-09-05 11:30:47 +0000
commit0cebf71726b24c24dd90134dacdf0c424044c35b (patch)
tree60852d8e0bfadeb20b94e0d1b6d69d2ed9fbb0e7
parent0389ee358b2b4f4fbe9ebfd7e9cf9d124030dcd5 (diff)
downloadxmlgraphics-fop-0cebf71726b24c24dd90134dacdf0c424044c35b.tar.gz
xmlgraphics-fop-0cebf71726b24c24dd90134dacdf0c424044c35b.zip
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. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@278720 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFHandler.java8
-rw-r--r--src/java/org/apache/fop/render/rtf/TextAttributesConverter.java63
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java72
4 files changed, 110 insertions, 35 deletions
diff --git a/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java b/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
index 0cc69cc64..f71910ec5 100644
--- a/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
@@ -52,7 +52,7 @@ public class BorderAttributesConverter {
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);
}
}
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index a76ecdd02..ca5da52cf 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -1174,6 +1174,12 @@ public class RTFHandler extends FOEventHandler {
} 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 @@ public class RTFHandler extends FOEventHandler {
} else {
endCell( (TableCell) foNode);
}
+ } else {
+ log.warn("Ignored deferred event for " + foNode);
}
}
diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
index a08350f4b..a8eb96274 100644
--- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
@@ -23,6 +23,7 @@ import org.apache.fop.apps.FOPException;
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.CommonBorderPaddingBackground;
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 @@ class TextAttributesConverter {
attrBlockBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
attrBlockTextAlign(fobj.getTextAlign(), attrib);
+ attrBorder(fobj.getCommonBorderPaddingBackground(), attrib, fobj);
return attrib;
}
@@ -77,6 +80,7 @@ class TextAttributesConverter {
attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
//attrBlockDimension(fobj, attrib);
+ attrBorder(fobj.getCommonBorderPaddingBackground(), attrib, fobj);
return attrib;
}
@@ -122,6 +126,7 @@ class TextAttributesConverter {
attrFontColor(fobj.getColor(), attrib);
attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
+ attrInlineBorder(fobj.getCommonBorderPaddingBackground(), attrib);
return attrib;
}
@@ -185,8 +190,8 @@ class TextAttributesConverter {
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);
}
@@ -238,6 +243,58 @@ class TextAttributesConverter {
}
}
+ /** 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);
+ }
+
/**
* Reads background-color from bl and writes it to rtfAttr.
*
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java
index a0e957c73..6a9cafdf9 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java
@@ -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 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
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,