// Adjust the cell's display attributes so the table's/row's borders
// are drawn properly.
- // get border attributes from table
- if (index == 0) {
- if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_LEFT)) {
- rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_LEFT,
- (RtfAttributes) tableBorderAttributes.getValue(
- ITableAttributes.CELL_BORDER_LEFT));
+ if (tableBorderAttributes != null) {
+ // get border attributes from table
+ if (index == 0) {
+ String border = ITableAttributes.CELL_BORDER_LEFT;
+ if (!rtfcell.getRtfAttributes().isSet(border)) {
+ rtfcell.getRtfAttributes().set(border,
+ (RtfAttributes) tableBorderAttributes.getValue(border));
+ }
}
- }
- if (index == this.getChildCount() - 1) {
- if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_RIGHT)) {
- rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_RIGHT,
- (RtfAttributes) tableBorderAttributes.getValue(
- ITableAttributes.CELL_BORDER_RIGHT));
+ if (index == this.getChildCount() - 1) {
+ String border = ITableAttributes.CELL_BORDER_RIGHT;
+ if (!rtfcell.getRtfAttributes().isSet(border)) {
+ rtfcell.getRtfAttributes().set(border,
+ (RtfAttributes) tableBorderAttributes.getValue(border));
+ }
}
- }
- if (isFirstRow()) {
- if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_TOP)) {
- rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
- (RtfAttributes) (RtfAttributes) tableBorderAttributes.getValue(
- ITableAttributes.CELL_BORDER_TOP));
+ if (isFirstRow()) {
+ String border = ITableAttributes.CELL_BORDER_TOP;
+ if (!rtfcell.getRtfAttributes().isSet(border)) {
+ rtfcell.getRtfAttributes().set(border,
+ (RtfAttributes) tableBorderAttributes.getValue(border));
+ }
}
- }
- if ((parentTable != null) && (parentTable.isHighestRow(id))) {
- if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_BOTTOM)) {
- rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_BOTTOM,
- (RtfAttributes) tableBorderAttributes.getValue(
- ITableAttributes.CELL_BORDER_BOTTOM));
+ if ((parentTable != null) && (parentTable.isHighestRow(id))) {
+ String border = ITableAttributes.CELL_BORDER_BOTTOM;
+ if (!rtfcell.getRtfAttributes().isSet(border)) {
+ rtfcell.getRtfAttributes().set(border,
+ (RtfAttributes) tableBorderAttributes.getValue(border));
+ }
}
}
package org.apache.fop;
import org.apache.fop.render.pdf.PDFAConformanceTestCase;
+import org.apache.fop.render.rtf.RichTextFormatTestSuite;
import junit.framework.Test;
import junit.framework.TestSuite;
suite.addTest(BasicDriverTestSuite.suite());
suite.addTest(UtilityCodeTestSuite.suite());
suite.addTest(new TestSuite(PDFAConformanceTestCase.class));
+ suite.addTest(RichTextFormatTestSuite.suite());
//$JUnit-END$
return suite;
}
--- /dev/null
+/*
+ * Copyright 2006 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.rtf;
+
+import java.io.StringWriter;
+
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;
+
+import junit.framework.TestCase;
+
+/**
+ * Test for http://issues.apache.org/bugzilla/show_bug.cgi?id=39607
+ */
+public class Bug39607TestCase extends TestCase {
+
+ /**
+ * Test for the NPE describes in bug 39607
+ * @throws Exception If an error occurs
+ */
+ public void testForNPE() throws Exception {
+ StringWriter writer = new StringWriter();
+ RtfFile f = new RtfFile(writer);
+
+ RtfDocumentArea doc = f.startDocumentArea();
+
+ RtfSection section = doc.newSection();
+
+ RtfParagraph paragraph = section.newParagraph();
+ paragraph.newText("Testing fop - rtf module - class RtfTableRow");
+ paragraph.close();
+
+ RtfTable table = section.newTable(null);
+ RtfTableRow row = table.newTableRow();
+ row.newTableCell(2000).newParagraph().newText("blah");
+ row.newTableCell(5000).newParagraph().newText("doubleBlah");
+ row.close();
+ table.close();
+ section.close();
+ doc.close();
+ f.flush();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2006 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.rtf;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite for FOP's RTF library.
+ */
+public class RichTextFormatTestSuite {
+
+ /**
+ * Builds the test suite
+ * @return the test suite
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test suite for RTF library");
+ //$JUnit-BEGIN$
+ suite.addTest(new TestSuite(Bug39607TestCase.class));
+ //$JUnit-END$
+ return suite;
+ }
+}