Changeset 1666


Ignore:
Timestamp:
09/20/11 12:01:22 (8 months ago)
Author:
jharrop
Message:

Note about the need for color mapping.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/model/properties/run/HighlightColor.java

    r1665 r1666  
    2020package org.docx4j.model.properties.run; 
    2121 
    22 import org.docx4j.UnitsOfMeasurement; 
    2322import org.docx4j.jaxb.Context; 
    24 import org.docx4j.wml.CTShd; 
    2523import org.docx4j.wml.Highlight; 
    2624import org.docx4j.wml.RPr; 
    2725import org.w3c.dom.Element; 
    28 import org.w3c.dom.css.CSSPrimitiveValue; 
    2926import org.w3c.dom.css.CSSValue; 
    3027 
     
    3431        public final static String FO_NAME  = "background-color";  
    3532         
     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         */ 
    3642         
    3743        public HighlightColor(Highlight shading) { 
     
    4147        public HighlightColor(CSSValue value) {  
    4248                 
    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()); 
    5551                this.setObject( shd  ); 
    5652        } 
     
    6157                Highlight shd = ((Highlight)this.getObject()); 
    6258                 
    63                 // TODO 
    64                 // 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 now 
    7259                if (shd.getVal()!=null && 
    73                 !shd.getVal().equals("auto")) { 
     60                !shd.getVal().equals("none")) { 
    7461                        return composeCss(CSS_NAME, shd.getVal() ); 
    7562                } else { 
    7663                        return CSS_NULL; 
    7764                } 
    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                  
    8665        } 
    8766 
     
    9271                Highlight shd = ((Highlight)this.getObject()); 
    9372                 
    94                 // TODO 
    95                 // 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 now 
    10373                if (shd.getVal()!=null && 
    104                                 !shd.getVal().equals("auto")) { 
     74                                !shd.getVal().equals("none")) { 
    10575                        foElement.setAttribute(FO_NAME, shd.getVal() ); 
    10676                }  
    10777                 
    108 //              if (shd.getFill()!=null && 
    109 //                              !shd.getFill().equals("auto")) { 
    110 //                      foElement.setAttribute(FO_NAME, "#" + shd.getFill() ); 
    111 //              }  
    11278        } 
    11379 
Note: See TracChangeset for help on using the changeset viewer.