aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-09-05 09:03:23 +0000
committerJeremias Maerki <jeremias@apache.org>2005-09-05 09:03:23 +0000
commitc40720187a665b216e6f6098cbeb24dbb350c187 (patch)
treed55aa56e618d5150f0ac2ed5f2386c5c681e1a4e /src
parent299c6b1393cf9d5194929ac8c756171b2ff2ce4f (diff)
downloadxmlgraphics-fop-c40720187a665b216e6f6098cbeb24dbb350c187.tar.gz
xmlgraphics-fop-c40720187a665b216e6f6098cbeb24dbb350c187.zip
Bugzilla #36475:
Fix for block background not extending to the whole block content-width. Submitted by: Sergey Simonchik <Sergey.Simonchik.at.borland.com> git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@278695 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/render/rtf/TextAttributesConverter.java44
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java10
2 files changed, 37 insertions, 17 deletions
diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
index 39a91ef91..a08350f4b 100644
--- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.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.
@@ -16,12 +16,9 @@
/* $Id$ */
-
package org.apache.fop.render.rtf;
//FOP
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.datatypes.Length;
@@ -51,21 +48,19 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
* @author Chris Scott
* @author rmarra
*/
-
class TextAttributesConverter {
- private static Log log = new SimpleLog("FOP/RTF");
-
+
/**
* Converts all known text FO properties to RtfAttributes
* @param props list of FO properites, which are to be converted
*/
public static RtfAttributes convertAttributes(Block fobj)
- throws FOPException {
+ throws FOPException {
FOPRtfAttributes attrib = new FOPRtfAttributes();
attrFont(fobj.getCommonFont(), attrib);
attrFontColor(fobj.getColor(), attrib);
//attrTextDecoration(fobj.getTextDecoration(), attrib);
- attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
+ attrBlockBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
attrBlockTextAlign(fobj.getTextAlign(), attrib);
@@ -77,7 +72,7 @@ class TextAttributesConverter {
* @param props list of FO properites, which are to be converted
*/
public static RtfAttributes convertBlockContainerAttributes(BlockContainer fobj)
- throws FOPException {
+ throws FOPException {
FOPRtfAttributes attrib = new FOPRtfAttributes();
attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib);
attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
@@ -166,7 +161,8 @@ class TextAttributesConverter {
- private static void attrTextDecoration(CommonTextDecoration textDecoration, RtfAttributes rtfAttr) {
+ private static void attrTextDecoration(CommonTextDecoration textDecoration,
+ RtfAttributes rtfAttr) {
if (textDecoration == null) {
return;
}
@@ -196,11 +192,13 @@ class TextAttributesConverter {
/*
private static void attrBlockDimension(FObj fobj, FOPRtfAttributes rtfAttr) {
- Length ipd = fobj.getProperty(Constants.PR_INLINE_PROGRESSION_DIMENSION).getLengthRange().getOptimum().getLength();
+ Length ipd = fobj.getProperty(Constants.PR_INLINE_PROGRESSION_DIMENSION)
+ .getLengthRange().getOptimum().getLength();
if (ipd.getEnum() != Constants.EN_AUTO) {
rtfAttr.set(RtfText.FRAME_WIDTH, ipd);
}
- Length bpd = fobj.getProperty(Constants.PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange().getOptimum().getLength();
+ Length bpd = fobj.getProperty(Constants.PR_BLOCK_PROGRESSION_DIMENSION)
+ .getLengthRange().getOptimum().getLength();
if (bpd.getEnum() != Constants.EN_AUTO) {
rtfAttr.set(RtfText.FRAME_HEIGHT, bpd);
}
@@ -228,12 +226,26 @@ class TextAttributesConverter {
}
/**
+ * Reads background-color for block from <code>bpb</code> and writes it to
+ * <code>rtfAttr</code>.
+ */
+ private static void attrBlockBackgroundColor(
+ CommonBorderPaddingBackground bpb, RtfAttributes rtfAttr) {
+ if (bpb.hasBackground()) {
+ rtfAttr.set(RtfText.SHADING, RtfText.FULL_SHADING);
+ rtfAttr.set(RtfText.SHADING_FRONT_COLOR,
+ convertFOPColorToRTF(bpb.backgroundColor));
+ }
+ }
+
+ /**
* Reads background-color from bl and writes it to rtfAttr.
*
* @param bl the Block object the properties are read from
* @param rtfAttr the RtfAttributes object the attributes are written to
*/
- private static void attrBackgroundColor(CommonBorderPaddingBackground bpb, RtfAttributes rtfAttr) {
+ private static void attrBackgroundColor(CommonBorderPaddingBackground bpb,
+ RtfAttributes rtfAttr) {
ColorType fopValue = bpb.backgroundColor;
int rtfColor = 0;
/* FOP uses a default background color of "transparent", which is
@@ -258,9 +270,9 @@ class TextAttributesConverter {
int s = baselineShift.getEnum();
- if (s==Constants.EN_SUPER) {
+ if (s == Constants.EN_SUPER) {
rtfAttr.set(RtfText.ATTR_SUPERSCRIPT);
- } else if (s==Constants.EN_SUB) {
+ } else if (s == Constants.EN_SUB) {
rtfAttr.set(RtfText.ATTR_SUBSCRIPT);
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
index 9ef08f1e4..17cf10c4c 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.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.
@@ -75,6 +75,14 @@ public class RtfText extends RtfElement {
/** constant for subscript */
public static final String ATTR_SUBSCRIPT = "sub";
+ /** RtfText attributes: paragraph shading attributes */
+ /** Constant for the shading of the paragraph */
+ public static final String SHADING = "shading";
+ /** Constant for the document's color tableshading of the paragraph */
+ public static final String SHADING_FRONT_COLOR = "cfpat";
+ /** Constant for the 100% shading of the paragraph */
+ public static final int FULL_SHADING = 10000;
+
/** RtfText attributes: alignment attributes */
/** constant for align center */
public static final String ALIGN_CENTER = "qc";