|
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 |
|