Support for padding-before and padding-after in RTF output. Submitted by: Sergey Simonchik <Sergey.Simonchik.at.borland.com> git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@278982 13f79535-47bb-0310-9956-ffa450edef68pull/31/head
@@ -30,6 +30,7 @@ import org.apache.fop.fo.Constants; | |||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | |||
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.RtfText; | |||
/** Constants for RTF border attribute names, and a static method for converting | |||
* fo attribute strings. */ | |||
@@ -54,6 +55,23 @@ public class BorderAttributesConverter { | |||
//division by 50 to convert millipoints to twips | |||
attrs.set(IBorderAttributes.BORDER_WIDTH, border.getBorderWidth(side, false) / 50); | |||
attributes.set(controlWord, attrs); | |||
attrs.setTwips(IBorderAttributes.BORDER_SPACE, border.getPadding(side, false, null)); | |||
attributes.set(controlWord, attrs); | |||
} else { | |||
// Here padding specified, but corresponding border is not available | |||
// Padding in millipoints | |||
double paddingPt = border.getPadding(side, false, null) / 1000.0; | |||
// Padding in twips | |||
int padding = (int) Math.round(paddingPt * FoUnitsConverter.POINT_TO_TWIPS); | |||
// Add padding to corresponding space (space-before or space-after) | |||
// if side == START or END, do nothing | |||
if (side == CommonBorderPaddingBackground.BEFORE) { | |||
attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE); | |||
} else if (side == CommonBorderPaddingBackground.AFTER) { | |||
attributes.addIntegerValue(padding, RtfText.SPACE_AFTER); | |||
} | |||
} | |||
} | |||
@@ -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. | |||
@@ -147,7 +147,7 @@ implements java.lang.Cloneable { | |||
/** | |||
* Set an attribute that has nested attributes as value | |||
* @param name name of attribute | |||
* @param type value of the nested attributes | |||
* @param value value of the nested attributes | |||
* @return this (which now contains the new entry) | |||
*/ | |||
public RtfAttributes set(String name, RtfAttributes value) { | |||
@@ -215,4 +215,17 @@ implements java.lang.Cloneable { | |||
xslAttributes = new org.xml.sax.helpers.AttributesImpl(pAttribs); | |||
} | |||
} | |||
/** | |||
* Add integer value <code>addValue</code> to attribute with name <code>name</code>. | |||
* If there is no such setted attribute, then value of this attribure is equal to | |||
* <code>addValue</code>. | |||
* @param addValue the increment of value | |||
* @param name the name of attribute | |||
*/ | |||
public void addIntegerValue(int addValue, String name) { | |||
Integer value = (Integer) getValue(name); | |||
int v = (value != null) ? value.intValue() : 0; | |||
set(name, v + addValue); | |||
} | |||
} |