/*
- * 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.
/* $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;
* @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);
* @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);
- private static void attrTextDecoration(CommonTextDecoration textDecoration, RtfAttributes rtfAttr) {
+ private static void attrTextDecoration(CommonTextDecoration textDecoration,
+ RtfAttributes rtfAttr) {
if (textDecoration == null) {
return;
}
/*
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);
}
rtfAttr.set(rtfValue);
}
+ /**
+ * 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
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);
}
}
/*
- * 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.
/** 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";