ASF Bugzilla – Attachment 22648 Details for
Bug 45917
Documentation XSSFFont
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch XSSFFont
20080930XSSFFont.diff (text/plain), 16.71 KB, created by
Gisella Bronzetti
on 2008-09-30 05:05:44 UTC
(
hide
)
Description:
patch XSSFFont
Filename:
MIME Type:
Creator:
Gisella Bronzetti
Created:
2008-09-30 05:05:44 UTC
Size:
16.71 KB
patch
obsolete
>Index: src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java (revision 700063) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java (working copy) >@@ -32,6 +32,12 @@ > import org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnderlineValues; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignRun; > >+/** >+ * Represents a Font used in a workbook. >+ * >+ * @author gisella bronzetti >+ */ >+ > public class XSSFFont implements Font { > > public static final String DEFAULT_FONT_NAME="Calibri"; >@@ -40,32 +46,56 @@ > > private CTFont ctFont; > >+ /** >+ * Create a new XSSFFont >+ * @param font the underlying XMLBeans font >+ */ > public XSSFFont(CTFont font) { > this.ctFont=font; > } >- >+ >+ /** >+ * Create a new XSSFont. This method is protected to be used only by XSSFWorkbook >+ */ > protected XSSFFont() { > this.ctFont = CTFont.Factory.newInstance(); > } > >- >+ /** >+ * get the underlying XMLBeans font >+ */ > public CTFont getCTFont(){ > return ctFont; > } > >- >+ /** >+ * get a boolean value for the boldness to use. >+ * @return boolean - bold >+ */ > public boolean getBold() { >- CTBooleanProperty bold=ctFont.sizeOfBArray() == 0 ? null : ctFont.getBArray(0); >+ CTBooleanProperty bold = ctFont.sizeOfBArray() == 0 ? null : ctFont.getBArray(0); > return (bold!=null && bold.getVal()); > } > >+ /** >+ * get character-set to use. >+ * @return byte - character-set >+ * @see FontCharset >+ */ > public byte getCharSet() { >- CTIntProperty charset= ctFont.sizeOfCharsetArray() == 0?null:ctFont.getCharsetArray(0); >+ CTIntProperty charset = ctFont.sizeOfCharsetArray() == 0 ? null : ctFont.getCharsetArray(0); > return charset == null ? FontCharset.ANSI.getValue() : FontCharset.valueOf(charset.getVal()).getValue(); > } > >+ >+ /** >+ * get the indexed color value for the font >+ * References a color definited in IndexedColors. >+ * @return short - indexed color to use >+ * @see IndexedColors >+ */ > public short getColor() { >- CTColor color=ctFont.sizeOfColorArray()==0?null: ctFont.getColorArray(0); >+ CTColor color = ctFont.sizeOfColorArray() == 0 ? null : ctFont.getColorArray(0); > if(color == null) return IndexedColors.BLACK.getIndex(); > > long index=color.getIndexed(); >@@ -81,21 +111,35 @@ > } > > >+ /** >+ * get the color value for the font >+ * References a color definited as Standard Alpha Red Green Blue color value (ARGB). >+ * @return XSSFColor - rgb color to use >+ */ > public XSSFColor getRgbColor() { >- CTColor ctColor=ctFont.sizeOfColorArray()==0?null: ctFont.getColorArray(0); >+ CTColor ctColor = ctFont.sizeOfColorArray() == 0 ? null : ctFont.getColorArray(0); > XSSFColor color=new XSSFColor(ctColor); > return color; > } > >+ >+ /** >+ * get the color value for the font >+ * References a color definited in theme. >+ * @return short - theme color to use >+ */ > public short getThemeColor() { >- CTColor color=ctFont.sizeOfColorArray()==0?null: ctFont.getColorArray(0); >+ CTColor color = ctFont.sizeOfColorArray() == 0 ? null : ctFont.getColorArray(0); > long index=color.getTheme(); > return (short)index; > } > >- >+ /** >+ * get the font height in point. >+ * @return short - height in point >+ */ > public short getFontHeight() { >- CTFontSize size=ctFont.sizeOfSzArray()==0?null: ctFont.getSzArray(0); >+ CTFontSize size = ctFont.sizeOfSzArray() == 0 ? null : ctFont.getSzArray(0); > if(size!=null){ > double fontHeight= size.getVal(); > return (short)fontHeight; >@@ -104,9 +148,11 @@ > return DEFAULT_FONT_SIZE; > } > >- >+ /** >+ * @see #getFontHeight() >+ */ > public short getFontHeightInPoints() { >- CTFontSize size=ctFont.sizeOfSzArray()==0?null: ctFont.getSzArray(0); >+ CTFontSize size = ctFont.sizeOfSzArray() == 0 ? null : ctFont.getSzArray(0); > if(size!=null){ > double fontHeight= size.getVal(); > return (short)fontHeight; >@@ -115,25 +161,42 @@ > return DEFAULT_FONT_SIZE; > } > >- >+ /** >+ * get the name of the font (i.e. Arial) >+ * @return String - a string representing the name of the font to use >+ */ > public String getFontName() { > CTFontName name = ctFont.sizeOfNameArray() == 0 ? null : ctFont.getNameArray(0); > return name == null ? null : name.getVal(); > } > >- >+ /** >+ * get a boolean value that specify whether to use italics or not >+ * @return boolean - value for italic >+ */ > public boolean getItalic() { >- CTBooleanProperty italic=ctFont.sizeOfIArray()==0?null:ctFont.getIArray(0); >+ CTBooleanProperty italic = ctFont.sizeOfIArray() == 0 ? null : ctFont.getIArray(0); > return italic!=null && italic.getVal(); > } >- >+ >+ /** >+ * get a boolean value that specify whether to use a strikeout horizontal line through the text or not >+ * @return boolean - value for strikeout >+ */ > public boolean getStrikeout() { >- CTBooleanProperty strike=ctFont.sizeOfStrikeArray()==0?null:ctFont.getStrikeArray(0); >+ CTBooleanProperty strike = ctFont.sizeOfStrikeArray() == 0 ? null : ctFont.getStrikeArray(0); > return strike!=null && strike.getVal(); > } > >+ /** >+ * get normal,super or subscript. >+ * @return short - offset type to use (none,super,sub) >+ * @see Font#SS_NONE >+ * @see Font#SS_SUPER >+ * @see Font#SS_SUB >+ */ > public short getTypeOffset() { >- CTVerticalAlignFontProperty vAlign=ctFont.sizeOfVertAlignArray()==0?null:ctFont.getVertAlignArray(0); >+ CTVerticalAlignFontProperty vAlign = ctFont.sizeOfVertAlignArray() == 0 ? null : ctFont.getVertAlignArray(0); > if(vAlign!=null){ > int val=vAlign.getVal().intValue(); > switch (val) { >@@ -150,12 +213,13 @@ > return Font.SS_NONE; > } > >+ /** >+ * get type of text underlining to use >+ * @return byte - underlining type >+ * @see FontUnderline >+ */ > public byte getUnderline() { >- /* >- CTUnderlineProperty underline = ctFont.sizeOfUArray() == 0 ? null : ctFont.getUArray(0); >- return underline == null ? (byte)FontUnderline.NONE.getValue().intValue() : (byte)FontUnderline.valueOf(underline.getVal()).getValue().intValue(); >- */ >- CTUnderlineProperty underline=ctFont.sizeOfUArray()==0?null:ctFont.getUArray(0); >+ CTUnderlineProperty underline = ctFont.sizeOfUArray() == 0 ? null : ctFont.getUArray(0); > if(underline!=null){ > FontUnderline fontUnderline=FontUnderline.valueOf(underline.getVal()); > switch (fontUnderline.getValue().intValue()) { >@@ -179,17 +243,21 @@ > } > > /** >- * Set characters in bold face font style. >- * If omitted, the default value is true. >+ * set a boolean value for the boldness to use. If omitted, the default value is true. >+ * @param boolean - boldness to use > */ > public void setBold(boolean bold) { >- CTBooleanProperty ctBold=ctFont.sizeOfBArray()==0?ctFont.addNewB():ctFont.getBArray(0); >+ CTBooleanProperty ctBold = ctFont.sizeOfBArray() == 0 ? ctFont.addNewB() : ctFont.getBArray(0); > ctBold.setVal(true); > } > >- >+ /** >+ * set character-set to use. >+ * @param byte - charset >+ * @see FontCharset >+ */ > public void setCharSet(byte charset) { >- CTIntProperty charsetProperty=ctFont.sizeOfCharsetArray()==0?ctFont.addNewCharset():ctFont.getCharsetArray(0); >+ CTIntProperty charsetProperty = ctFont.sizeOfCharsetArray() == 0 ? ctFont.addNewCharset() : ctFont.getCharsetArray(0); > switch (charset) { > case Font.ANSI_CHARSET: > charsetProperty.setVal(FontCharset.ANSI.getValue()); >@@ -205,14 +273,22 @@ > } > } > >- >+ /** >+ * set character-set to use. >+ * @param FontCharset >+ */ > public void setCharSet(FontCharset charSet) { >- setCharSet(charSet.getValue()); >+ setCharSet(charSet.getValue()); > } > >+ /** >+ * set the indexed color for the font >+ * @param short - color to use >+ * @see #DEFAULT_FONT_COLOR - Note: default font color >+ * @see IndexedColors >+ */ > public void setColor(short color) { >- CTColor ctColor=ctFont.sizeOfColorArray()==0?ctFont.addNewColor():ctFont.getColorArray(0); >- >+ CTColor ctColor = ctFont.sizeOfColorArray() == 0 ? ctFont.addNewColor() : ctFont.getColorArray(0); > switch (color) { > case Font.COLOR_NORMAL:{ > ctColor.setIndexed(XSSFFont.DEFAULT_FONT_COLOR); >@@ -227,48 +303,97 @@ > } > } > >- >+ /** >+ * set the font height in points. >+ * @param short - height in points >+ */ > public void setFontHeight(short height) { > setFontHeight((double)height); > } > >+ /** >+ * set the font height in points. >+ * @param double - height in points >+ */ > public void setFontHeight(double height) { > CTFontSize fontSize=ctFont.sizeOfSzArray()==0?ctFont.addNewSz():ctFont.getSzArray(0); > fontSize.setVal(height); > } > >+ /** >+ * @link #setFontHeight >+ */ > public void setFontHeightInPoints(short height) { >- setFontHeight((double)height); >+ setFontHeight(height); > } > >- >+ /** >+ * set the color for the font in Standard Alpha Red Green Blue color value >+ * @param XSSFColor - color to use >+ */ > public void setRgbColor(XSSFColor color) { >- CTColor ctColor=ctFont.sizeOfColorArray()==0?ctFont.addNewColor():ctFont.getColorArray(0); >+ CTColor ctColor = ctFont.sizeOfColorArray() == 0 ? ctFont.addNewColor() : ctFont.getColorArray(0); > ctColor.setRgb(color.getRgb()); > } > >+ /** >+ * set the theme color for the font to use >+ * @param short - theme color to use >+ */ > public void setThemeColor(short theme) { >- CTColor ctColor=ctFont.sizeOfColorArray()==0?ctFont.addNewColor():ctFont.getColorArray(0); >+ CTColor ctColor = ctFont.sizeOfColorArray() == 0 ? ctFont.addNewColor() : ctFont.getColorArray(0); > ctColor.setTheme(theme); > } > >+ /** >+ * set the name for the font (i.e. Arial). >+ * If the font doesn't exist (because it isn't installed on the system), >+ * or the charset is invalid for that font, then another font should >+ * be substituted. >+ * The string length for this attribute shall be 0 to 31 characters. >+ * Default font name is Calibri. >+ * >+ * @param String - value representing the name of the font to use >+ * @see #DEFAULT_FONT_NAME >+ */ > public void setFontName(String name) { >- CTFontName fontName=ctFont.sizeOfNameArray()==0?ctFont.addNewName():ctFont.getNameArray(0); >+ CTFontName fontName = ctFont.sizeOfNameArray() == 0 ? ctFont.addNewName() : ctFont.getNameArray(0); > fontName.setVal(name); > } > >+ >+ /** >+ * set a boolean value for the property specifying whether to use italics or not >+ * If omitted, the default value is true. >+ * @param boolean - value for italics or not >+ */ > public void setItalic(boolean italic) { >- CTBooleanProperty bool=ctFont.sizeOfIArray()==0?ctFont.addNewI():ctFont.getIArray(0); >+ CTBooleanProperty bool = ctFont.sizeOfIArray() == 0 ? ctFont.addNewI() : ctFont.getIArray(0); > bool.setVal(italic); > } >+ > >+ /** >+ * set a boolean value for the property specifying whether to use a strikeout horizontal line through the text or not >+ * If omitted, the default value is true. >+ * @param boolean - value for strikeout or not >+ */ > public void setStrikeout(boolean strikeout) { >- CTBooleanProperty strike=ctFont.sizeOfStrikeArray()==0?ctFont.addNewStrike():ctFont.getStrikeArray(0); >+ CTBooleanProperty strike = ctFont.sizeOfStrikeArray() == 0 ? ctFont.addNewStrike() : ctFont.getStrikeArray(0); > strike.setVal(strikeout); > } > >+ /** >+ * set normal,super or subscript, that representing the vertical-alignment setting. >+ * Setting this to either subscript or superscript shall make the font size smaller if a >+ * smaller font size is available. >+ * @param short - offset type to use (none,super,sub) >+ * @see #SS_NONE >+ * @see #SS_SUPER >+ * @see #SS_SUB >+ */ > public void setTypeOffset(short offset) { >- CTVerticalAlignFontProperty offsetProperty=ctFont.sizeOfVertAlignArray()==0?ctFont.addNewVertAlign(): ctFont.getVertAlignArray(0); >+ CTVerticalAlignFontProperty offsetProperty = ctFont.sizeOfVertAlignArray() == 0 ? ctFont.addNewVertAlign() : ctFont.getVertAlignArray(0); > switch (offset) { > case Font.SS_NONE: > offsetProperty.setVal(STVerticalAlignRun.BASELINE); >@@ -282,8 +407,14 @@ > } > } > >+ /** >+ * set the style of underlining that is used. >+ * The none style is equivalent to not using underlining at all. >+ * @param byte - underline type to use >+ * @see FontUnderline >+ */ > public void setUnderline(byte underline) { >- CTUnderlineProperty ctUnderline=ctFont.sizeOfUArray()==0?ctFont.addNewU():ctFont.getUArray(0); >+ CTUnderlineProperty ctUnderline = ctFont.sizeOfUArray() == 0 ? ctFont.addNewU() : ctFont.getUArray(0); > switch (underline) { > case Font.U_DOUBLE: > ctUnderline.setVal(FontUnderline.DOUBLE.getValue()); >@@ -304,8 +435,14 @@ > } > } > >+ /** >+ * set an enumeration representing the style of underlining that is used. >+ * The none style is equivalent to not using underlining at all. >+ * The possible values for this attribute are defined by the FontUnderline >+ * @param FontUnderline - FontUnderline enum value >+ */ > public void setUnderline(FontUnderline underline) { >- CTUnderlineProperty ctUnderline=ctFont.sizeOfUArray()==0?ctFont.addNewU():ctFont.getUArray(0); >+ CTUnderlineProperty ctUnderline = ctFont.sizeOfUArray() == 0 ? ctFont.addNewU() : ctFont.getUArray(0); > ctUnderline.setVal(underline.getValue()); > } > >@@ -331,33 +468,56 @@ > return fonts.size() - 1; > } > >-/* >- this methds are used only for XSSFFont and aren't in Font interface >- are used in method SthlesTable.createDefaultfont >- */ >- >+ /** >+ * get the font scheme property. >+ * is used only in StylesTable to create the default instance of font >+ * @return FontScheme >+ * @see org.apache.poi.xssf.model.StylesTable#createDefaultFont() >+ */ > public FontScheme getScheme(){ >- CTFontScheme scheme=ctFont.sizeOfSchemeArray()==0?null:ctFont.getSchemeArray(0); >+ CTFontScheme scheme = ctFont.sizeOfSchemeArray() == 0 ? null : ctFont.getSchemeArray(0); > return scheme == null ? FontScheme.NONE : FontScheme.valueOf(scheme.getVal()); > } > >+ /** >+ * set font scheme property >+ * @param scheme - FontScheme enum value >+ * @see FontScheme >+ */ > public void setScheme(FontScheme scheme){ >- CTFontScheme ctFontScheme=ctFont.sizeOfSchemeArray()==0?ctFont.addNewScheme():ctFont.getSchemeArray(0); >+ CTFontScheme ctFontScheme = ctFont.sizeOfSchemeArray() == 0 ? ctFont.addNewScheme() : ctFont.getSchemeArray(0); > ctFontScheme.setVal(scheme.getValue()); > } > >- >+ /** >+ * get the font family to use. >+ * @param int - family value >+ * @see FontFamily >+ */ > public int getFamily(){ > CTIntProperty family = ctFont.sizeOfFamilyArray() == 0 ? ctFont.addNewFamily() : ctFont.getFamilyArray(0); > return family == null ? FontFamily.NOT_APPLICABLE.getValue() : FontFamily.valueOf(family.getVal()).getValue(); > } > >- >+ /** >+ * Set the font family this font belongs to. >+ * A font family is a set of fonts having common stroke width and serif characteristics. >+ * The font name overrides when there are conflicting values. >+ * >+ * @param int - family value >+ * @see FontFamily >+ */ > public void setFamily(int value){ > CTIntProperty family = ctFont.sizeOfFamilyArray() == 0 ? ctFont.addNewFamily() : ctFont.getFamilyArray(0); >- family.setVal(value); >+ family.setVal(value); > } >- >+ >+ /** >+ * set an enumeration representing the font family this font belongs to. >+ * A font family is a set of fonts having common stroke width and serif characteristics. >+ * @param font family >+ * @link #setFamily(int value) >+ */ > public void setFamily(FontFamily family){ > setFamily(family.getValue()); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 45917
: 22648