- Timestamp:
- 09/20/11 12:01:22 (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/model/properties/run/HighlightColor.java
r1665 r1666 20 20 package org.docx4j.model.properties.run; 21 21 22 import org.docx4j.UnitsOfMeasurement;23 22 import org.docx4j.jaxb.Context; 24 import org.docx4j.wml.CTShd;25 23 import org.docx4j.wml.Highlight; 26 24 import org.docx4j.wml.RPr; 27 25 import org.w3c.dom.Element; 28 import org.w3c.dom.css.CSSPrimitiveValue;29 26 import org.w3c.dom.css.CSSValue; 30 27 … … 34 31 public final static String FO_NAME = "background-color"; 35 32 33 /* 34 * TODO: this class assumes that the 35 * colors specified in org.docx4j.wml.Highlight 36 * are valid CSS and XSL colors, and 37 * vice versa. 38 * 39 * Someone needs to add handling/mappings for when 40 * this is not the case. 41 */ 36 42 37 43 public HighlightColor(Highlight shading) { … … 41 47 public HighlightColor(CSSValue value) { 42 48 43 CTShd shd = Context.getWmlObjectFactory().createCTShd(); 44 45 // PrimitiveType 25 -> RGBCOLOR 46 short ignored = 1; 47 48 CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue)value; 49 float fRed = cssPrimitiveValue.getRGBColorValue().getRed().getFloatValue(ignored); 50 float fGreen = cssPrimitiveValue.getRGBColorValue().getGreen().getFloatValue(ignored); 51 float fBlue = cssPrimitiveValue.getRGBColorValue().getBlue().getFloatValue(ignored); 52 53 shd.setFill(UnitsOfMeasurement.rgbTripleToHex(fRed, fGreen, fBlue) ); 54 49 Highlight shd = Context.getWmlObjectFactory().createHighlight(); 50 shd.setVal(value.getCssText()); 55 51 this.setObject( shd ); 56 52 } … … 61 57 Highlight shd = ((Highlight)this.getObject()); 62 58 63 // TODO64 // STShd styleVal = shd.getVal();65 66 // if (shd.getColor()!=null &&67 // !shd.getColor().equals("auto")) {68 // log.warn("TODO support w:shd/@w:color=" + shd.getColor() );69 // }70 71 // We just support fill color right now72 59 if (shd.getVal()!=null && 73 !shd.getVal().equals(" auto")) {60 !shd.getVal().equals("none")) { 74 61 return composeCss(CSS_NAME, shd.getVal() ); 75 62 } else { 76 63 return CSS_NULL; 77 64 } 78 79 // if (shd.getFill()!=null &&80 // !shd.getFill().equals("auto")) {81 // return composeCss(CSS_NAME, "#" + shd.getFill() );82 // } else {83 // return CSS_NULL;84 // }85 86 65 } 87 66 … … 92 71 Highlight shd = ((Highlight)this.getObject()); 93 72 94 // TODO95 // STShd styleVal = shd.getVal();96 97 // if (shd.getColor()!=null &&98 // !shd.getColor().equals("auto")) {99 // log.warn("TODO support w:shd/@w:color=" + shd.getColor() );100 // }101 102 // We just support fill color right now103 73 if (shd.getVal()!=null && 104 !shd.getVal().equals(" auto")) {74 !shd.getVal().equals("none")) { 105 75 foElement.setAttribute(FO_NAME, shd.getVal() ); 106 76 } 107 77 108 // if (shd.getFill()!=null &&109 // !shd.getFill().equals("auto")) {110 // foElement.setAttribute(FO_NAME, "#" + shd.getFill() );111 // }112 78 } 113 79
Note: See TracChangeset
for help on using the changeset viewer.
