Package org.docx4j.wml

Examples of org.docx4j.wml.CTShd


    applyTableCustomAttributes(context, table, transformState, tableRoot);
  }

  protected void appendNoneBordersAndShading(List<Property> tableProperties) {
  CTBorder ctBrdr = null;
  CTShd shd = Context.getWmlObjectFactory().createCTShd();
    ctBrdr = Context.getWmlObjectFactory().createCTBorder();
    ctBrdr.setVal(STBorder.NONE);
    tableProperties.add(new BorderLeft(ctBrdr));
    ctBrdr = Context.getWmlObjectFactory().createCTBorder();
    ctBrdr.setVal(STBorder.NONE);
    tableProperties.add(new BorderRight(ctBrdr));
    ctBrdr = Context.getWmlObjectFactory().createCTBorder();
    ctBrdr.setVal(STBorder.NONE);
    tableProperties.add(new BorderTop(ctBrdr));
    ctBrdr = Context.getWmlObjectFactory().createCTBorder();
    ctBrdr.setVal(STBorder.NONE);
    tableProperties.add(new BorderBottom(ctBrdr));
    shd.setColor("auto");
    shd.setFill("auto");
    shd.setVal(STShd.CLEAR);
    tableProperties.add(new Shading(shd));
  }
View Full Code Here


    }
    return null;
  }

  protected void processAttributes(AbstractWmlConversionContext context, List<Property> properties, Element element) {
  CTShd shd = null;
  int bgColor = 0xffffff; //the background color of the page is assumed as white
  int fgColor = 0; //the default color of the font is assumed as black
  int pctPattern = -1;
    for (int i=0; i<properties.size(); i++) {
      if (properties.get(i) instanceof Shading) {
        shd = (CTShd)properties.get(i).getObject();
        fgColor = extractColor(shd.getColor(), 0);
        if ((shd.getVal() != null) &&
          ("clear".equals(shd.getVal().value())) && 
          ("auto".equals(shd.getFill()))
          ) {
          //This is a reset to the background color of the page,
          //it is treated as an special case, as the background color
          //isn't inherited
          bgColor = 0xffffff;
          pctPattern = -2;
        }
        else {
          pctPattern = (shd.getVal() != null ? extractPattern(shd.getVal().value()) : -1);
          bgColor = extractColor(shd.getFill(), bgColor);
        }
      }
    }
    if (pctPattern == -1) {
      applyAttributes(context, properties, element);
View Full Code Here

    }
    return ret;
  }

  protected Property createShading(int fgColor, int bgColor, int pctFg) {
  CTShd shd = null;
  int resColor = UnitsOfMeasurement.combineColors(fgColor, bgColor, pctFg);
    shd = Context.getWmlObjectFactory().createCTShd();
    shd.setVal(STShd.CLEAR);
    shd.setFill(calcHexColor(resColor));
    return new Shading(shd);
  }
View Full Code Here

    this.setObject(shading);
  }
 
  public PShading(CSSValue value) { 
   
    CTShd shd = Context.getWmlObjectFactory().createCTShd();

    // PrimitiveType 25 -> RGBCOLOR
        short ignored = 1;

        float fRed;
        float fGreen;
        float fBlue;

        CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue) value;
        try {
            fRed = cssPrimitiveValue.getRGBColorValue().getRed()
                    .getFloatValue(ignored);
            fGreen = cssPrimitiveValue.getRGBColorValue().getGreen()
                    .getFloatValue(ignored);
            fBlue = cssPrimitiveValue.getRGBColorValue().getBlue()
                    .getFloatValue(ignored);
        shd.setFill(UnitsOfMeasurement.rgbTripleToHex(fRed, fGreen, fBlue));
       
        } catch (UnsupportedOperationException e) {
         
        try {
          Class<?> xhtmlImporterClass = Class.forName("org.docx4j.convert.in.xhtml.FSColorToHexString");
            Method rgbToHexMethod = xhtmlImporterClass.getMethod("rgbToHex", CSSPrimitiveValue.class);
            shd.setFill((String)rgbToHexMethod.invoke(null, cssPrimitiveValue));
        } catch (Exception e2) {
            log.error("docx4j-XHTMLImport jar not found. Please add this to your classpath.");
        log.error(e2.getMessage(), e2);
        throw e; // same as before
     
View Full Code Here

  }

  @Override
  public String getCssProperty() {
   
    CTShd shd = ((CTShd)this.getObject());
   
    // TODO
    // STShd styleVal = shd.getVal(); 

    if (shd.getColor()!=null &&
        !shd.getColor().equals("auto")) {
      log.warn("TODO support w:shd/@w:color=" + shd.getColor() );
    }
   
    // We just support fill color right now
    if (shd.getFill()!=null &&
        !shd.getFill().equals("auto")) {
      return composeCss(CSS_NAME, "#" + shd.getFill() );
    } else {
      return CSS_NULL;
    }
   
  }
View Full Code Here


  @Override
  public void setXslFO(Element foElement) {

    CTShd shd = ((CTShd)this.getObject());
   
    // TODO
    // STShd styleVal = shd.getVal(); 

    if (shd.getColor()!=null &&
        !shd.getColor().equals("auto")) {
      log.warn("TODO support w:shd/@w:color=" + shd.getColor() );
    }
   
    // We just support fill color right now
    if (shd.getFill()!=null &&
        !shd.getFill().equals("auto")) {
      foElement.setAttribute(FO_NAME, "#" + shd.getFill() );
    }
  }
View Full Code Here


  @Override
  public void setXslFO(Element foElement) {

    CTShd shd = ((CTShd)this.getObject());
   
    // TODO
    // STShd styleVal = shd.getVal(); 

    if (shd.getColor()!=null &&
        !shd.getColor().equals("auto")) {
      log.warn("TODO support w:shd/@w:color=" + shd.getColor() );
    }
   
    // We just support fill color right now
    if (shd.getFill()!=null &&
        !shd.getFill().equals("auto")) {
      foElement.setAttribute(FO_NAME, "#" + shd.getFill() );
    }
  }
View Full Code Here

    List<Object> paragraphElts = null;
    SdtBlock sdtBorders = null;
    SdtBlock sdtShading = null;
    PBdr lastBorders = null;
    PBdr currentBorders = null;
    CTShd lastShading = null;
    CTShd currentShading = null;
    P paragraph = null;
   
    for (Object o : bodyElts) {
      if (o instanceof JAXBElement) {
        o = ((JAXBElement)o).getValue();
View Full Code Here

    this.setObject(textAlignment);
  }
 
  public Shading(CSSValue value) { 
   
    CTShd shd = Context.getWmlObjectFactory().createCTShd();

    // PrimitiveType 25 -> RGBCOLOR
    short ignored = 1;

    CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue)value;
    float fRed = cssPrimitiveValue.getRGBColorValue().getRed().getFloatValue(ignored);
    float fGreen = cssPrimitiveValue.getRGBColorValue().getGreen().getFloatValue(ignored);
    float fBlue = cssPrimitiveValue.getRGBColorValue().getBlue().getFloatValue(ignored);
   
    shd.setFill(UnitsOfMeasurement.rgbTripleToHex(fRed, fGreen, fBlue)  );

    this.setObject( shd  );
  }
View Full Code Here

  }

  @Override
  public String getCssProperty() {
   
    CTShd shd = ((CTShd)this.getObject());
   
    // TODO
    // STShd styleVal = shd.getVal(); 

    if (shd.getColor()!=null &&
        !shd.getColor().equals("auto")) {
      log.warn("TODO support w:shd/@w:color=" + shd.getColor() );
    }
   
    // We just support fill color right now
    if (shd.getFill()!=null &&
        !shd.getFill().equals("auto")) {
      return composeCss(CSS_NAME, "#" + shd.getFill() );
    } else {
      return CSS_NULL;
    }
   
  }
View Full Code Here

TOP

Related Classes of org.docx4j.wml.CTShd

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.