* @param cssAttr The current converted CSS attributes.
* @return The conversion result or null if no converstion has been done.
*/
private ConverterAttributeSet handleStringAttributes(Object key, Object value, ConverterAttributeSet cssAttr)
{
final ConverterAttributeSet attr = new ConverterAttributeSet();
final String styleKey = (String) key;
if (styleKey.equals(RTF_PAGEWIDTH) || styleKey.equals(RTF_PAGEHEIGHT))
{
final float floatValue = ((Float) value).floatValue();
final Object size = cssAttr.getAttribute(PageStyleKeys.SIZE.getName());
double width = 0;
double height = 0;
if(size instanceof PageSize)
{
final PageSize pageSize = (PageSize)size;
width = pageSize.getWidth();
height = pageSize.getHeight();
}
else if(RTF_LANDSCAPE.equals(size))
{
if (styleKey.equals(RTF_PAGEWIDTH))
{
height = twipToInt(floatValue);
}
else
{
width = twipToInt(floatValue);
}
}
else
{
if (styleKey.equals(RTF_PAGEWIDTH))
{
width = twipToInt(floatValue);
}
else
{
height = twipToInt(floatValue);
}
}
attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), new PageSize(width, height));
}
else if(styleKey.equals(RTF_MARGINLEFT))
{
final float floatValue = ((Float) value).floatValue();
attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_LEFT.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
}
else if(styleKey.equals(RTF_MARGINRIGHT))
{
final float floatValue = ((Float) value).floatValue();
attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_RIGHT.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
}
else if(styleKey.equals(RTF_MARGINTOP))
{
final float floatValue = ((Float) value).floatValue();
attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_TOP.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
}
else if(styleKey.equals(RTF_MARGINBOTTOM))
{
final float floatValue = ((Float) value).floatValue();
attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_BOTTOM.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
}
else if(styleKey.equals(RTF_LANDSCAPE))
{
final Object size = cssAttr.getAttribute(PageStyleKeys.SIZE.getName());
if(size instanceof PageSize)
{
final PageSize pageSize = (PageSize)size;
attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), new PageSize(pageSize.getHeight(), pageSize.getWidth()));
}
else
{
attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), RTF_LANDSCAPE);
}
}
else
{
Log.debug(new Log.SimpleMessage("Unkown type of document attribute", styleKey));