Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 336813
Collapse All | Expand All

(-)a/org.eclipse.mylyn.wikitext.core/src/org/eclipse/mylyn/wikitext/core/parser/TableCellAttributes.java (+12 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     David Green - initial API and implementation
9
 *     David Green - initial API and implementation
10
 *     Torkild U. Resheim - Added border attribute, bug 336813
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.mylyn.wikitext.core.parser;
12
package org.eclipse.mylyn.wikitext.core.parser;
12
13
Lines 17-22 import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType; Link Here
17
 * {@link BlockType#TABLE_CELL_NORMAL}.
18
 * {@link BlockType#TABLE_CELL_NORMAL}.
18
 * 
19
 * 
19
 * @author David Green
20
 * @author David Green
21
 * @author Torkild U. Resheim, MARINTEK
20
 * @since 1.0
22
 * @since 1.0
21
 */
23
 */
22
public class TableCellAttributes extends Attributes {
24
public class TableCellAttributes extends Attributes {
Lines 30-35 public class TableCellAttributes extends Attributes { Link Here
30
32
31
	private String colspan;
33
	private String colspan;
32
34
35
	private String border;
36
33
	public String getBgcolor() {
37
	public String getBgcolor() {
34
		return bgcolor;
38
		return bgcolor;
35
	}
39
	}
Lines 70-73 public class TableCellAttributes extends Attributes { Link Here
70
		this.colspan = colspan;
74
		this.colspan = colspan;
71
	}
75
	}
72
76
77
	public void setBorder(String border) {
78
		this.border = border;
79
	}
80
81
	public String getBorder() {
82
		return border;
83
	}
84
73
}
85
}
(-)a/org.eclipse.mylyn.wikitext.core/src/org/eclipse/mylyn/wikitext/core/parser/TableRowAttributes.java (+13 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     David Green - initial API and implementation
9
 *     David Green - initial API and implementation
10
 *     Torkild U. Resheim - Added border attribute, bug 336813
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.mylyn.wikitext.core.parser;
12
package org.eclipse.mylyn.wikitext.core.parser;
12
13
Lines 16-30 import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType; Link Here
16
 * Attributes that may used when creating blocks of type {@link BlockType#TABLE_ROW}.
17
 * Attributes that may used when creating blocks of type {@link BlockType#TABLE_ROW}.
17
 * 
18
 * 
18
 * @author David Green
19
 * @author David Green
20
 * @author Torkild U. Resheim, MARINTEK
19
 * @since 1.0
21
 * @since 1.0
20
 */
22
 */
21
public class TableRowAttributes extends Attributes {
23
public class TableRowAttributes extends Attributes {
24
22
	private String bgcolor;
25
	private String bgcolor;
23
26
24
	private String align;
27
	private String align;
25
28
26
	private String valign;
29
	private String valign;
27
30
31
	private String border;
32
28
	public String getBgcolor() {
33
	public String getBgcolor() {
29
		return bgcolor;
34
		return bgcolor;
30
	}
35
	}
Lines 49-52 public class TableRowAttributes extends Attributes { Link Here
49
		this.valign = valign;
54
		this.valign = valign;
50
	}
55
	}
51
56
57
	public void setBorder(String border) {
58
		this.border = border;
59
	}
60
61
	public String getBorder() {
62
		return border;
63
	}
64
52
}
65
}
(-)a/org.eclipse.mylyn.wikitext.core/src/org/eclipse/mylyn/wikitext/core/parser/builder/XslfoDocumentBuilder.java (+70 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     David Green - initial API and implementation
9
 *     David Green - initial API and implementation
10
 *     Torkild U. Resheim - Added table attributes, bug 336813
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.mylyn.wikitext.core.parser.builder;
13
package org.eclipse.mylyn.wikitext.core.parser.builder;
Lines 27-32 import org.eclipse.mylyn.wikitext.core.parser.Attributes; Link Here
27
import org.eclipse.mylyn.wikitext.core.parser.ImageAttributes;
28
import org.eclipse.mylyn.wikitext.core.parser.ImageAttributes;
28
import org.eclipse.mylyn.wikitext.core.parser.ListAttributes;
29
import org.eclipse.mylyn.wikitext.core.parser.ListAttributes;
29
import org.eclipse.mylyn.wikitext.core.parser.TableAttributes;
30
import org.eclipse.mylyn.wikitext.core.parser.TableAttributes;
31
import org.eclipse.mylyn.wikitext.core.parser.TableCellAttributes;
32
import org.eclipse.mylyn.wikitext.core.parser.TableRowAttributes;
30
import org.eclipse.mylyn.wikitext.core.util.XmlStreamWriter;
33
import org.eclipse.mylyn.wikitext.core.util.XmlStreamWriter;
31
34
32
/**
35
/**
Lines 37-42 import org.eclipse.mylyn.wikitext.core.util.XmlStreamWriter; Link Here
37
 * @see <a href="http://en.wikipedia.org/wiki/XSL_Formatting_Objects">XSL-FO (WikiPedia)</a>
40
 * @see <a href="http://en.wikipedia.org/wiki/XSL_Formatting_Objects">XSL-FO (WikiPedia)</a>
38
 * @see <a href="http://www.w3schools.com/xslfo/default.asp">XSL-FO Tutorial</a>
41
 * @see <a href="http://www.w3schools.com/xslfo/default.asp">XSL-FO Tutorial</a>
39
 * @author David Green
42
 * @author David Green
43
 * @author Torkild U. Resheim
40
 * @since 1.1
44
 * @since 1.1
41
 */
45
 */
42
public class XslfoDocumentBuilder extends AbstractXmlDocumentBuilder {
46
public class XslfoDocumentBuilder extends AbstractXmlDocumentBuilder {
Lines 337-342 public class XslfoDocumentBuilder extends AbstractXmlDocumentBuilder { Link Here
337
		case TABLE_CELL_HEADER:
341
		case TABLE_CELL_HEADER:
338
		case TABLE_CELL_NORMAL:
342
		case TABLE_CELL_NORMAL:
339
			writer.writeStartElement(foNamespaceUri, "table-cell"); //$NON-NLS-1$
343
			writer.writeStartElement(foNamespaceUri, "table-cell"); //$NON-NLS-1$
344
			applyTableCellAttributes(attributes);
340
			writer.writeAttribute("padding-left", "2pt"); //$NON-NLS-1$ //$NON-NLS-2$
345
			writer.writeAttribute("padding-left", "2pt"); //$NON-NLS-1$ //$NON-NLS-2$
341
			writer.writeAttribute("padding-right", "2pt"); //$NON-NLS-1$ //$NON-NLS-2$
346
			writer.writeAttribute("padding-right", "2pt"); //$NON-NLS-1$ //$NON-NLS-2$
342
			writer.writeAttribute("padding-top", "2pt"); //$NON-NLS-1$ //$NON-NLS-2$
347
			writer.writeAttribute("padding-top", "2pt"); //$NON-NLS-1$ //$NON-NLS-2$
Lines 349-354 public class XslfoDocumentBuilder extends AbstractXmlDocumentBuilder { Link Here
349
			break;
354
			break;
350
		case TABLE_ROW:
355
		case TABLE_ROW:
351
			writer.writeStartElement(foNamespaceUri, "table-row"); //$NON-NLS-1$
356
			writer.writeStartElement(foNamespaceUri, "table-row"); //$NON-NLS-1$
357
			applyTableRowAttributes(attributes);
352
			break;
358
			break;
353
		default:
359
		default:
354
			throw new IllegalStateException(type.name());
360
			throw new IllegalStateException(type.name());
Lines 402-407 public class XslfoDocumentBuilder extends AbstractXmlDocumentBuilder { Link Here
402
		}
408
		}
403
	}
409
	}
404
410
411
	private void applyTableCellAttributes(Attributes attributes) {
412
		if (attributes instanceof TableCellAttributes) {
413
			TableCellAttributes cellAttributes = (TableCellAttributes) attributes;
414
			if (cellAttributes.getBgcolor() != null) {
415
				writer.writeAttribute(CSS_RULE_BACKGROUND_COLOR, cellAttributes.getBgcolor());
416
			}
417
			if (cellAttributes.getColspan() != null) {
418
				writer.writeAttribute("number-columns-spanned", cellAttributes.getColspan()); //$NON-NLS-1$
419
			}
420
			if (cellAttributes.getColspan() != null) {
421
				writer.writeAttribute("number-rows-spanned", cellAttributes.getRowspan()); //$NON-NLS-1$
422
			}
423
			if (cellAttributes.getBorder() != null) {
424
				writer.writeAttribute("border", cellAttributes.getBorder()); //$NON-NLS-1$
425
			}
426
			// Expecting values left, right or center
427
			if (cellAttributes.getAlign() != null) {
428
				writer.writeAttribute("text-align", cellAttributes.getAlign()); //$NON-NLS-1$				
429
			}
430
			if (cellAttributes.getValign() != null) {
431
				String value = cellAttributes.getAlign();
432
				if (cellAttributes.getValign().equals("top")) { //$NON-NLS-1$
433
					value = "before"; //$NON-NLS-1$
434
				}
435
				if (cellAttributes.getValign().equals("middle")) { //$NON-NLS-1$
436
					value = "center"; //$NON-NLS-1$
437
				}
438
				if (cellAttributes.getValign().equals("bottom")) { //$NON-NLS-1$
439
					value = "after"; //$NON-NLS-1$
440
				}
441
				if (value != null) {
442
					writer.writeAttribute("display-align", value); //$NON-NLS-1$									
443
				}
444
			}
445
		}
446
	}
447
448
	private void applyTableRowAttributes(Attributes attributes) {
449
		if (attributes instanceof TableRowAttributes) {
450
			TableRowAttributes rowAttributes = (TableRowAttributes) attributes;
451
			if (rowAttributes.getBgcolor() != null) {
452
				writer.writeAttribute(CSS_RULE_BACKGROUND_COLOR, rowAttributes.getBgcolor());
453
			}
454
			if (rowAttributes.getBorder() != null) {
455
				writer.writeAttribute("border", rowAttributes.getBorder()); //$NON-NLS-1$
456
			}
457
			if (rowAttributes.getValign() != null) {
458
				String value = rowAttributes.getAlign();
459
				if (rowAttributes.getValign().equals("top")) { //$NON-NLS-1$
460
					value = "before"; //$NON-NLS-1$
461
				}
462
				if (rowAttributes.getValign().equals("middle")) { //$NON-NLS-1$
463
					value = "center"; //$NON-NLS-1$
464
				}
465
				if (rowAttributes.getValign().equals("bottom")) { //$NON-NLS-1$
466
					value = "after"; //$NON-NLS-1$
467
				}
468
				if (value != null) {
469
					writer.writeAttribute("display-align", value); //$NON-NLS-1$									
470
				}
471
			}
472
		}
473
	}
474
405
	private void applyTableAttributes(Attributes attributes) {
475
	private void applyTableAttributes(Attributes attributes) {
406
		// applyAttributes(attributes);
476
		// applyAttributes(attributes);
407
477

Return to bug 336813