poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1694121 - in /poi/trunk/src/ooxml/java/org/apache/poi/xssf: model/ThemesTable.java usermodel/XSSFFont.java
Date Tue, 04 Aug 2015 22:46:27 GMT
Author: nick
Date: Tue Aug  4 22:46:27 2015
New Revision: 1694121

URL: http://svn.apache.org/r1694121
Log:
Pull out indexes from the switch statement to constants, and fix warnings

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java?rev=1694121&r1=1694120&r2=1694121&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java Tue Aug  4 22:46:27
2015
@@ -34,6 +34,19 @@ import org.openxmlformats.schemas.drawin
  * colors and fonts.
  */
 public class ThemesTable extends POIXMLDocumentPart {
+   public static final int THEME_LT1 = 0;
+   public static final int THEME_DK1 =1;
+   public static final int THEME_LT2 = 2;
+   public static final int THEME_DK2 = 3;
+   public static final int THEME_ACCENT1 = 4;
+   public static final int THEME_ACCENT2 = 5;
+   public static final int THEME_ACCENT3 = 6;
+   public static final int THEME_ACCENT4 = 7;
+   public static final int THEME_ACCENT5 = 8;
+   public static final int THEME_ACCENT6 = 9;
+   public static final int THEME_HLINK = 10;
+   public static final int THEME_FOLHLINK = 11;
+
     private ThemeDocument theme;
 
     /**
@@ -69,7 +82,7 @@ public class ThemesTable extends POIXMLD
     }
 
     /**
-     * Convert a theme "index" into a color.
+     * Convert a theme "index" (as used by fonts etc) into a color.
      * @param idx A theme "index"
      * @return The mapped XSSFColor, or null if not mapped.
      */
@@ -80,18 +93,18 @@ public class ThemesTable extends POIXMLD
         CTColorScheme colorScheme = theme.getTheme().getThemeElements().getClrScheme();
         CTColor ctColor;
         switch (idx) {
-            case  0: ctColor = colorScheme.getLt1(); break;
-            case  1: ctColor = colorScheme.getDk1(); break;
-            case  2: ctColor = colorScheme.getLt2(); break;
-            case  3: ctColor = colorScheme.getDk2(); break;
-            case  4: ctColor = colorScheme.getAccent1(); break;
-            case  5: ctColor = colorScheme.getAccent2(); break;
-            case  6: ctColor = colorScheme.getAccent3(); break;
-            case  7: ctColor = colorScheme.getAccent4(); break;
-            case  8: ctColor = colorScheme.getAccent5(); break;
-            case  9: ctColor = colorScheme.getAccent6(); break;
-            case 10: ctColor = colorScheme.getHlink(); break;
-            case 11: ctColor = colorScheme.getFolHlink(); break;
+            case THEME_LT1: ctColor = colorScheme.getLt1(); break;
+            case THEME_DK1: ctColor = colorScheme.getDk1(); break;
+            case THEME_LT2: ctColor = colorScheme.getLt2(); break;
+            case THEME_DK2: ctColor = colorScheme.getDk2(); break;
+            case THEME_ACCENT1: ctColor = colorScheme.getAccent1(); break;
+            case THEME_ACCENT2: ctColor = colorScheme.getAccent2(); break;
+            case THEME_ACCENT3: ctColor = colorScheme.getAccent3(); break;
+            case THEME_ACCENT4: ctColor = colorScheme.getAccent4(); break;
+            case THEME_ACCENT5: ctColor = colorScheme.getAccent5(); break;
+            case THEME_ACCENT6: ctColor = colorScheme.getAccent6(); break;
+            case THEME_HLINK:   ctColor = colorScheme.getHlink();   break;
+            case THEME_FOLHLINK:ctColor = colorScheme.getFolHlink();break;
             default: return null;
         }
 

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=1694121&r1=1694120&r2=1694121&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 Tue Aug  4 22:46:27
2015
@@ -303,10 +303,7 @@ public class XSSFFont implements Font {
      * @see FontCharset
      */
     public void setCharSet(byte charset) {
-       int cs = (int)charset;
-       if(cs < 0) {
-          cs += 256;
-       }
+       int cs = charset & 0xff;
        setCharSet(cs);
     }
     /**
@@ -373,7 +370,7 @@ public class XSSFFont implements Font {
         if(color == null) _ctFont.setColorArray(null);
         else {
             CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.addNewColor() : _ctFont.getColorArray(0);
-            ctColor.setRgb(color.getRgb());
+            ctColor.setRgb(color.getRGB());
         }
     }
 



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


Mime
View raw message