Bug 60282: Update JavaDoc and use a common constant for TWIPS_PER_POINT

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874966 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2020-03-08 08:28:17 +00:00
parent af4751b260
commit 1e8cba79ce
4 changed files with 43 additions and 31 deletions

View File

@ -120,7 +120,7 @@ public final class HSSFFont implements Font {
public void setFontHeightInPoints(short height) public void setFontHeightInPoints(short height)
{ {
font.setFontHeight(( short ) (height * 20)); font.setFontHeight(( short ) (height * Font.TWIPS_PER_POINT));
} }
/** /**
@ -143,7 +143,7 @@ public final class HSSFFont implements Font {
public short getFontHeightInPoints() public short getFontHeightInPoints()
{ {
return ( short ) (font.getFontHeight() / 20); return ( short ) (font.getFontHeight() / Font.TWIPS_PER_POINT);
} }
/** /**

View File

@ -26,76 +26,82 @@ public interface Font {
* normal type of black color. * normal type of black color.
*/ */
public final static short COLOR_NORMAL = 0x7fff; short COLOR_NORMAL = 0x7fff;
/** /**
* Dark Red color * Dark Red color
*/ */
public final static short COLOR_RED = 0xa; short COLOR_RED = 0xa;
/** /**
* no type offsetting (not super or subscript) * no type offsetting (not super or subscript)
*/ */
public final static short SS_NONE = 0; short SS_NONE = 0;
/** /**
* superscript * superscript
*/ */
public final static short SS_SUPER = 1; short SS_SUPER = 1;
/** /**
* subscript * subscript
*/ */
public final static short SS_SUB = 2; short SS_SUB = 2;
/** /**
* not underlined * not underlined
*/ */
public final static byte U_NONE = 0; byte U_NONE = 0;
/** /**
* single (normal) underline * single (normal) underline
*/ */
public final static byte U_SINGLE = 1; byte U_SINGLE = 1;
/** /**
* double underlined * double underlined
*/ */
public final static byte U_DOUBLE = 2; byte U_DOUBLE = 2;
/** /**
* accounting style single underline * accounting style single underline
*/ */
public final static byte U_SINGLE_ACCOUNTING = 0x21; byte U_SINGLE_ACCOUNTING = 0x21;
/** /**
* accounting style double underline * accounting style double underline
*/ */
public final static byte U_DOUBLE_ACCOUNTING = 0x22; byte U_DOUBLE_ACCOUNTING = 0x22;
/** /**
* ANSI character set * ANSI character set
*/ */
public final static byte ANSI_CHARSET = 0; byte ANSI_CHARSET = 0;
/** /**
* Default character set. * Default character set.
*/ */
public final static byte DEFAULT_CHARSET = 1; byte DEFAULT_CHARSET = 1;
/** /**
* Symbol character set * Symbol character set
*/ */
public final static byte SYMBOL_CHARSET = 2; byte SYMBOL_CHARSET = 2;
/**
* Font height is handled in points and 1/20th of points so
* this is the constant used to convert between those two units.
*/
int TWIPS_PER_POINT = 20;
/** /**
* set the name for the font (i.e. Arial) * set the name for the font (i.e. Arial)
@ -272,7 +278,7 @@ public interface Font {
* @deprecated use <code>getIndexAsInt()</code> instead * @deprecated use <code>getIndexAsInt()</code> instead
*/ */
@Removal(version = "4.2") @Removal(version = "4.2")
public short getIndex(); short getIndex();
/** /**
* get the index within the XSSFWorkbook (sequence within the collection of Font objects) * get the index within the XSSFWorkbook (sequence within the collection of Font objects)
@ -281,9 +287,9 @@ public interface Font {
* unless you're comparing which one is which) * unless you're comparing which one is which)
* @since 4.0.0 * @since 4.0.0
*/ */
public int getIndexAsInt(); int getIndexAsInt();
public void setBold(boolean bold); void setBold(boolean bold);
public boolean getBold(); boolean getBold();
} }

View File

@ -195,7 +195,7 @@ public class XSSFFont implements Font {
* @see #getFontHeightInPoints() * @see #getFontHeightInPoints()
*/ */
public short getFontHeight() { public short getFontHeight() {
return (short)(getFontHeightRaw()*20); return (short)(getFontHeightRaw()*Font.TWIPS_PER_POINT);
} }
/** /**
@ -394,7 +394,7 @@ public class XSSFFont implements Font {
* @param height - height in points * @param height - height in points
*/ */
public void setFontHeight(short height) { public void setFontHeight(short height) {
setFontHeight((double) height/20); setFontHeight((double) height/Font.TWIPS_PER_POINT);
} }
/** /**

View File

@ -60,6 +60,7 @@ import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationHelper; import org.apache.poi.ss.usermodel.DataValidationHelper;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Footer; import org.apache.poi.ss.usermodel.Footer;
import org.apache.poi.ss.usermodel.Header; import org.apache.poi.ss.usermodel.Header;
import org.apache.poi.ss.usermodel.IgnoredErrorType; import org.apache.poi.ss.usermodel.IgnoredErrorType;
@ -156,7 +157,12 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
private static final double DEFAULT_MARGIN_BOTTOM = 0.75; private static final double DEFAULT_MARGIN_BOTTOM = 0.75;
private static final double DEFAULT_MARGIN_LEFT = 0.7; private static final double DEFAULT_MARGIN_LEFT = 0.7;
private static final double DEFAULT_MARGIN_RIGHT = 0.7; private static final double DEFAULT_MARGIN_RIGHT = 0.7;
public static final int TWIPS_PER_POINT = 20;
/**
* Kept for backwards-compatibility, use {@link Font#TWIPS_PER_POINT} instead.
* @deprecated POI 4.1.3
*/
public static final int TWIPS_PER_POINT = Font.TWIPS_PER_POINT;
//TODO make the two variable below private! //TODO make the two variable below private!
protected CTSheet sheet; protected CTSheet sheet;
@ -986,7 +992,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
*/ */
@Override @Override
public short getDefaultRowHeight() { public short getDefaultRowHeight() {
return (short)(getDefaultRowHeightInPoints() * TWIPS_PER_POINT); return (short)(getDefaultRowHeightInPoints() * Font.TWIPS_PER_POINT);
} }
@ -2598,7 +2604,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
*/ */
@Override @Override
public void setDefaultRowHeight(short height) { public void setDefaultRowHeight(short height) {
setDefaultRowHeightInPoints((float)height / TWIPS_PER_POINT); setDefaultRowHeightInPoints((float)height / Font.TWIPS_PER_POINT);
} }
/** /**