Package org.openxmlformats.schemas.spreadsheetml.x2006.main

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont


    assertEquals(true, ctFont.getStrikeArray(0).getVal());
    assertEquals(true,ctFont.getStrikeArray(0).getVal());
  }

  public void testFontHeight() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTFontSize size=ctFont.addNewSz();
    size.setVal(11);
    ctFont.setSzArray(0,size);

    XSSFFont xssfFont=new XSSFFont(ctFont);
    assertEquals(11,xssfFont.getFontHeightInPoints());

    xssfFont.setFontHeight(20);
    assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
  }
View Full Code Here


    xssfFont.setFontHeight(20);
    assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
  }

  public void testFontHeightInPoint() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTFontSize size=ctFont.addNewSz();
    size.setVal(14);
    ctFont.setSzArray(0,size);

    XSSFFont xssfFont=new XSSFFont(ctFont);
    assertEquals(14,xssfFont.getFontHeightInPoints());

    xssfFont.setFontHeightInPoints((short)20);
    assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
  }
View Full Code Here

    xssfFont.setFontHeightInPoints((short)20);
    assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
  }

  public void testUnderline() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTUnderlineProperty underlinePropr=ctFont.addNewU();
    underlinePropr.setVal(STUnderlineValues.SINGLE);
    ctFont.setUArray(0,underlinePropr);

    XSSFFont xssfFont=new XSSFFont(ctFont);
    assertEquals(Font.U_SINGLE, xssfFont.getUnderline());

    xssfFont.setUnderline(Font.U_DOUBLE);
    assertEquals(ctFont.getUArray().length,1);
    assertEquals(STUnderlineValues.DOUBLE,ctFont.getUArray(0).getVal());
   
    xssfFont.setUnderline(FontUnderline.DOUBLE_ACCOUNTING);
    assertEquals(ctFont.getUArray().length,1);
    assertEquals(STUnderlineValues.DOUBLE_ACCOUNTING,ctFont.getUArray(0).getVal());
  }
View Full Code Here

    assertEquals(ctFont.getUArray().length,1);
    assertEquals(STUnderlineValues.DOUBLE_ACCOUNTING,ctFont.getUArray(0).getVal());
  }

  public void testColor() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTColor color=ctFont.addNewColor();
    color.setIndexed(XSSFFont.DEFAULT_FONT_COLOR);
    ctFont.setColorArray(0,color);

    XSSFFont xssfFont=new XSSFFont(ctFont);
    assertEquals(IndexedColors.BLACK.getIndex(),xssfFont.getColor());

    xssfFont.setColor(IndexedColors.RED.getIndex());
    assertEquals(IndexedColors.RED.getIndex(), ctFont.getColorArray(0).getIndexed());
  }
View Full Code Here

    xssfFont.setColor(IndexedColors.RED.getIndex());
    assertEquals(IndexedColors.RED.getIndex(), ctFont.getColorArray(0).getIndexed());
  }

  public void testRgbColor() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTColor color=ctFont.addNewColor();

    color.setRgb(Integer.toHexString(0xFFFFFF).getBytes());
    ctFont.setColorArray(0,color);

    XSSFFont xssfFont=new XSSFFont(ctFont);
    assertEquals(ctFont.getColorArray(0).getRgb()[0],xssfFont.getXSSFColor().getRgb()[0]);
    assertEquals(ctFont.getColorArray(0).getRgb()[1],xssfFont.getXSSFColor().getRgb()[1]);
    assertEquals(ctFont.getColorArray(0).getRgb()[2],xssfFont.getXSSFColor().getRgb()[2]);
    assertEquals(ctFont.getColorArray(0).getRgb()[3],xssfFont.getXSSFColor().getRgb()[3]);

    color.setRgb(Integer.toHexString(0xF1F1F1).getBytes());
    XSSFColor newColor=new XSSFColor(color);
    xssfFont.setColor(newColor);
    assertEquals(ctFont.getColorArray(0).getRgb()[2],newColor.getRgb()[2]);
  }
View Full Code Here

    xssfFont.setColor(newColor);
    assertEquals(ctFont.getColorArray(0).getRgb()[2],newColor.getRgb()[2]);
  }

  public void testThemeColor() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTColor color=ctFont.addNewColor();
    color.setTheme(1);
    ctFont.setColorArray(0,color);

    XSSFFont xssfFont=new XSSFFont(ctFont);
    assertEquals(ctFont.getColorArray(0).getTheme(),xssfFont.getThemeColor());

    xssfFont.setThemeColor(IndexedColors.RED.getIndex());
    assertEquals(IndexedColors.RED.getIndex(),ctFont.getColorArray(0).getTheme());
  }
View Full Code Here

    xssfFont.setThemeColor(IndexedColors.RED.getIndex());
    assertEquals(IndexedColors.RED.getIndex(),ctFont.getColorArray(0).getTheme());
  }

  public void testFamily() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTIntProperty family=ctFont.addNewFamily();
    family.setVal(FontFamily.MODERN.getValue());
    ctFont.setFamilyArray(0,family);

    XSSFFont xssfFont=new XSSFFont(ctFont);
    assertEquals(FontFamily.MODERN.getValue(),xssfFont.getFamily());
  }
View Full Code Here

    XSSFFont xssfFont=new XSSFFont(ctFont);
    assertEquals(FontFamily.MODERN.getValue(),xssfFont.getFamily());
  }

  public void testScheme() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTFontScheme scheme=ctFont.addNewScheme();
    scheme.setVal(STFontScheme.MAJOR);
    ctFont.setSchemeArray(0,scheme);

    XSSFFont font=new XSSFFont(ctFont);
    assertEquals(FontScheme.MAJOR,font.getScheme());

    font.setScheme(FontScheme.NONE);
    assertEquals(STFontScheme.NONE,ctFont.getSchemeArray(0).getVal());
  }
View Full Code Here

    font.setScheme(FontScheme.NONE);
    assertEquals(STFontScheme.NONE,ctFont.getSchemeArray(0).getVal());
  }

  public void testTypeOffset() {
    CTFont ctFont=CTFont.Factory.newInstance();
    CTVerticalAlignFontProperty valign=ctFont.addNewVertAlign();
    valign.setVal(STVerticalAlignRun.BASELINE);
    ctFont.setVertAlignArray(0,valign);

    XSSFFont font=new XSSFFont(ctFont);
    assertEquals(Font.SS_NONE,font.getTypeOffset());

    font.setTypeOffset(XSSFFont.SS_SUPER);
    assertEquals(STVerticalAlignRun.SUPERSCRIPT,ctFont.getVertAlignArray(0).getVal());
  }
View Full Code Here

    /**
     *
     * CTRPrElt --> CTFont adapter
     */
    protected static CTFont toCTFont(CTRPrElt pr){
        CTFont ctFont =  CTFont.Factory.newInstance();

        if(pr.sizeOfBArray() > 0) ctFont.addNewB().setVal(pr.getBArray(0).getVal());
        if(pr.sizeOfUArray() > 0) ctFont.addNewU().setVal(pr.getUArray(0).getVal());
        if(pr.sizeOfIArray() > 0) ctFont.addNewI().setVal(pr.getIArray(0).getVal());
        if(pr.sizeOfColorArray() > 0) {
            CTColor c1 = pr.getColorArray(0);
            CTColor c2 = ctFont.addNewColor();
            if(c1.isSetAuto()) c2.setAuto(c1.getAuto());
            if(c1.isSetIndexed()) c2.setIndexed(c1.getIndexed());
            if(c1.isSetRgb()) c2.setRgb(c1.getRgb());
            if(c1.isSetTheme()) c2.setTheme(c1.getTheme());
            if(c1.isSetTint()) c2.setTint(c1.getTint());
        }
        if(pr.sizeOfSzArray() > 0) ctFont.addNewSz().setVal(pr.getSzArray(0).getVal());
        if(pr.sizeOfRFontArray() > 0) ctFont.addNewName().setVal(pr.getRFontArray(0).getVal());
        if(pr.sizeOfFamilyArray() > 0) ctFont.addNewFamily().setVal(pr.getFamilyArray(0).getVal());
        if(pr.sizeOfSchemeArray() > 0) ctFont.addNewScheme().setVal(pr.getSchemeArray(0).getVal());
        if(pr.sizeOfCharsetArray() > 0) ctFont.addNewCharset().setVal(pr.getCharsetArray(0).getVal());
        if(pr.sizeOfCondenseArray() > 0) ctFont.addNewCondense().setVal(pr.getCondenseArray(0).getVal());
        if(pr.sizeOfExtendArray() > 0) ctFont.addNewExtend().setVal(pr.getExtendArray(0).getVal());
        if(pr.sizeOfVertAlignArray() > 0) ctFont.addNewVertAlign().setVal(pr.getVertAlignArray(0).getVal());
        if(pr.sizeOfOutlineArray() > 0) ctFont.addNewOutline().setVal(pr.getOutlineArray(0).getVal());
        if(pr.sizeOfShadowArray() > 0) ctFont.addNewShadow().setVal(pr.getShadowArray(0).getVal());
        if(pr.sizeOfStrikeArray() > 0) ctFont.addNewStrike().setVal(pr.getStrikeArray(0).getVal());

        return ctFont;
    }
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont

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.