You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2020/03/08 08:28:18 UTC

svn commit: r1874966 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/HSSFFont.java java/org/apache/poi/ss/usermodel/Font.java ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

Author: centic
Date: Sun Mar  8 08:28:17 2020
New Revision: 1874966

URL: http://svn.apache.org/viewvc?rev=1874966&view=rev
Log:
Bug 60282: Update JavaDoc and use a common constant for TWIPS_PER_POINT

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/Font.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java?rev=1874966&r1=1874965&r2=1874966&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java Sun Mar  8 08:28:17 2020
@@ -120,7 +120,7 @@ public final class HSSFFont implements F
 
     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 F
 
     public short getFontHeightInPoints()
     {
-        return ( short ) (font.getFontHeight() / 20);
+        return ( short ) (font.getFontHeight() / Font.TWIPS_PER_POINT);
     }
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Font.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Font.java?rev=1874966&r1=1874965&r2=1874966&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Font.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Font.java Sun Mar  8 08:28:17 2020
@@ -26,76 +26,82 @@ public interface Font {
      * normal type of black color.
      */
 
-    public final static short COLOR_NORMAL = 0x7fff;
+    short COLOR_NORMAL = 0x7fff;
 
     /**
      * Dark Red color
      */
 
-    public final static short COLOR_RED = 0xa;
+    short COLOR_RED = 0xa;
 
     /**
      * no type offsetting (not super or subscript)
      */
 
-    public final static short SS_NONE = 0;
+    short SS_NONE = 0;
 
     /**
      * superscript
      */
 
-    public final static short SS_SUPER = 1;
+    short SS_SUPER = 1;
 
     /**
      * subscript
      */
 
-    public final static short SS_SUB = 2;
+    short SS_SUB = 2;
 
     /**
      * not underlined
      */
 
-    public final static byte U_NONE = 0;
+    byte U_NONE = 0;
 
     /**
      * single (normal) underline
      */
 
-    public final static byte U_SINGLE = 1;
+    byte U_SINGLE = 1;
 
     /**
      * double underlined
      */
 
-    public final static byte U_DOUBLE = 2;
+    byte U_DOUBLE = 2;
 
     /**
      * accounting style single underline
      */
 
-    public final static byte U_SINGLE_ACCOUNTING = 0x21;
+    byte U_SINGLE_ACCOUNTING = 0x21;
 
     /**
      * accounting style double underline
      */
 
-    public final static byte U_DOUBLE_ACCOUNTING = 0x22;
+    byte U_DOUBLE_ACCOUNTING = 0x22;
 
     /**
      * ANSI character set
      */
-    public final static byte ANSI_CHARSET = 0;
+    byte ANSI_CHARSET = 0;
 
     /**
      * Default character set.
      */
-    public final static byte DEFAULT_CHARSET = 1;
+    byte DEFAULT_CHARSET = 1;
 
     /**
      * 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)
@@ -266,13 +272,13 @@ public interface Font {
 
     /**
      * Get the index within the XSSFWorkbook (sequence within the collection of Font objects)
-     * 
+     *
      * @return unique index number of the underlying record this Font represents (probably you don't care
      *  unless you're comparing which one is which)
      * @deprecated use <code>getIndexAsInt()</code> instead
      */
     @Removal(version = "4.2")
-    public short getIndex();
+    short getIndex();
 
     /**
      * 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)
      * @since 4.0.0
      */
-    public int getIndexAsInt();
+    int getIndexAsInt();
 
-    public void setBold(boolean bold);
+    void setBold(boolean bold);
 
-    public boolean getBold();
+    boolean getBold();
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java?rev=1874966&r1=1874965&r2=1874966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java Sun Mar  8 08:28:17 2020
@@ -195,7 +195,7 @@ public class XSSFFont implements Font {
      * @see #getFontHeightInPoints()
      */
     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
      */
     public void setFontHeight(short height) {
-        setFontHeight((double) height/20);
+        setFontHeight((double) height/Font.TWIPS_PER_POINT);
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1874966&r1=1874965&r2=1874966&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sun Mar  8 08:28:17 2020
@@ -60,6 +60,7 @@ import org.apache.poi.ss.usermodel.CellS
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.DataValidation;
 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.Header;
 import org.apache.poi.ss.usermodel.IgnoredErrorType;
@@ -156,7 +157,12 @@ public class XSSFSheet extends POIXMLDoc
     private static final double DEFAULT_MARGIN_BOTTOM = 0.75;
     private static final double DEFAULT_MARGIN_LEFT = 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!
     protected CTSheet sheet;
@@ -763,9 +769,9 @@ public class XSSFSheet extends POIXMLDoc
         XSSFRow prev = _rows.get(rownumI);
         if(prev != null){
             // the Cells in an existing row are invalidated on-purpose, in order to clean up correctly, we
-            // need to call the remove, so things like ArrayFormulas and CalculationChain updates are done 
-            // correctly. 
-            // We remove the cell this way as the internal cell-list is changed by the remove call and 
+            // need to call the remove, so things like ArrayFormulas and CalculationChain updates are done
+            // correctly.
+            // We remove the cell this way as the internal cell-list is changed by the remove call and
             // thus would cause ConcurrentModificationException otherwise
             while(prev.getFirstCellNum() != -1) {
                 prev.removeCell(prev.getCell(prev.getFirstCellNum()));
@@ -986,7 +992,7 @@ public class XSSFSheet extends POIXMLDoc
      */
     @Override
     public short getDefaultRowHeight() {
-        return (short)(getDefaultRowHeightInPoints() * TWIPS_PER_POINT);
+        return (short)(getDefaultRowHeightInPoints() * Font.TWIPS_PER_POINT);
     }
 
 
@@ -1444,7 +1450,7 @@ public class XSSFSheet extends POIXMLDoc
     }
 
     /**
-     * Sets the sheet password. 
+     * Sets the sheet password.
      *
      * @param password if null, the password will be removed
      * @param hashAlgo if null, the password will be set as XOR password (Excel 2010 and earlier)
@@ -2598,7 +2604,7 @@ public class XSSFSheet extends POIXMLDoc
      */
     @Override
     public void setDefaultRowHeight(short height) {
-        setDefaultRowHeightInPoints((float)height / TWIPS_PER_POINT);
+        setDefaultRowHeightInPoints((float)height / Font.TWIPS_PER_POINT);
     }
 
     /**
@@ -3223,7 +3229,7 @@ public class XSSFSheet extends POIXMLDoc
 
     private void shiftCommentsForColumns(XSSFVMLDrawing vml, int startColumnIndex, int endColumnIndex, final int n){
         // then do the actual moving and also adjust comments/rowHeight
-        // we need to sort it in a way so the shifting does not mess up the structures, 
+        // we need to sort it in a way so the shifting does not mess up the structures,
         // i.e. when shifting down, start from down and go up, when shifting up, vice-versa
         SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>((o1, o2) -> {
             int column1 = o1.getColumn();
@@ -3261,7 +3267,7 @@ public class XSSFSheet extends POIXMLDoc
             }
         }
         // adjust all the affected comment-structures now
-        // the Map is sorted and thus provides them in the order that we need here, 
+        // the Map is sorted and thus provides them in the order that we need here,
         // i.e. from down to up if shifting down, vice-versa otherwise
         for(Map.Entry<XSSFComment, Integer> entry : commentsToShift.entrySet()) {
             entry.getKey().setColumn(entry.getValue());



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org