1 17 18 19 20 21 27 28 package org.apache.fop.render.rtf.rtflib.testdocs; 29 30 import java.io.IOException ; 31 32 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; 33 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; 34 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; 35 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; 36 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; 37 38 41 42 class MergedTableCells extends TestDocument { 43 static final int MM_TO_TWIPS = (int)(1440f / 25.4f); 44 45 46 protected void generateDocument(RtfDocumentArea rda, RtfSection sect) 47 throws IOException { 48 sect.newParagraph().newText("This document contains a table with some merged cells."); 49 50 final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); 51 52 { 54 RtfTableRow r = tbl.newTableRow(); 55 RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS); 56 c.setHMerge(RtfTableCell.MERGE_START); 57 c.newParagraph().newText("cell 0,0, width 80mm, merge start, " 58 + "followed by two merged cells totalling 80mm width."); 59 60 c = r.newTableCell(40 * MM_TO_TWIPS); 61 c.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS); 62 c.newParagraph().newText("THIS IS IN AN HMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); 63 64 c = r.newTableCell(40 * MM_TO_TWIPS); 65 c.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS); 66 c.newParagraph().newText("THIS IS IN AN HMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); 67 } 68 69 { 71 RtfTableRow r = tbl.newTableRow(); 72 RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS); 73 c.setVMerge(RtfTableCell.MERGE_START); 74 c.newParagraph().newText("cell 1,0, vertical merge start, 40mm, spans three rows."); 75 76 r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 1,1, no merge, 80mm"); 77 78 c = r.newTableCell(40 * MM_TO_TWIPS); 79 c.setVMerge(RtfTableCell.MERGE_START); 80 c.newParagraph().newText("cell 1,2, vertical merge start, 40mm, spans two rows."); 81 } 82 83 { 85 RtfTableRow r = tbl.newTableRow(); 86 RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS); 87 c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS); 88 c.newParagraph().newText("cell 2,0, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); 89 90 r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 2,1, no merge, 40mm"); 91 r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 2,2, no merge, 40mm"); 92 93 c = r.newTableCell(40 * MM_TO_TWIPS); 94 c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS); 95 c.newParagraph().newText("cell 2,3, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); 96 } 97 98 { 100 RtfTableRow r = tbl.newTableRow(); 101 RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS); 102 c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS); 103 c.newParagraph().newText("cell 3,0, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); 104 105 r.newTableCell(10 * MM_TO_TWIPS).newParagraph().newText("cell 3,1, no merge, 10mm"); 106 r.newTableCell(30 * MM_TO_TWIPS).newParagraph().newText("cell 3,2, no merge, 30mm"); 107 r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 3,3, no merge, 40mm"); 108 r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 3,4, no merge, 40mm"); 109 } 110 111 { 113 RtfTableRow r = tbl.newTableRow(); 114 r.newTableCell(160 * MM_TO_TWIPS).newParagraph().newText 115 ("cell 4,0, width 160mm, only cell in this row"); 116 } 117 } 118 } 119 | Popular Tags |