From c00bdcc884f9a98d4d1d48e49ed528269badf70a Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 1 Nov 2004 12:39:14 +0000 Subject: [PATCH] Avoid with certain NPEs. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198119 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/rtf/TableAttributesConverter.java | 9 +++++---- .../apache/fop/render/rtf/TextAttributesConverter.java | 7 ++++--- .../apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java index 8310f86bc..7ccc49ed5 100644 --- a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java @@ -119,10 +119,11 @@ public class TableAttributesConverter { // Cell background color ColorType color = fobj.getCommonBorderPaddingBackground().backgroundColor; - if (color.getAlpha() != 0 - || color.getRed() != 0 - || color.getGreen() != 0 - || color.getBlue() != 0) { + if ((color != null) + && (color.getAlpha() != 0 + || color.getRed() != 0 + || color.getGreen() != 0 + || color.getBlue() != 0)) { attrib.set(ITableAttributes.CELL_COLOR_BACKGROUND, color); } diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index 004281416..5df06ed1c 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -132,7 +132,7 @@ class TextAttributesConverter { private static void attrFont(CommonFont font, FOPRtfAttributes rtfAttr) { rtfAttr.set(RtfText.ATTR_FONT_FAMILY, RtfFontManager.getInstance().getFontNumber(font.fontFamily)); - rtfAttr.set("fs", font.fontSize); + rtfAttr.set(RtfText.ATTR_FONT_SIZE, font.fontSize); if (font.fontWeight.equals("bold") || font.fontWeight.equals("700")) { rtfAttr.set("b", 1); @@ -230,10 +230,11 @@ class TextAttributesConverter { default here. Changing FOP's default to "white" causes problems in PDF output, so we will look for the default here & change it to "auto". */ - if ((fopValue.getRed() == 0) + if ((fopValue == null) + || ((fopValue.getRed() == 0) && (fopValue.getGreen() == 0) && (fopValue.getBlue() == 0) - && (fopValue.getAlpha() == 0)) { + && (fopValue.getAlpha() == 0))) { return; } else { rtfColor = convertFOPColorToRTF(fopValue); diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java index 14ee7c5af..681b07540 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java @@ -264,7 +264,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { } } - if (parentTable.isHighestRow(id)) { + if ((parentTable != null) && (parentTable.isHighestRow(id))) { if (!cell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_BOTTOM)) { cell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_BOTTOM, (String)attrib.getValue(ITableAttributes.ROW_BORDER_BOTTOM)); -- 2.39.5