From: Nick Burch Date: Fri, 17 Jul 2015 02:55:22 +0000 (+0000) Subject: Start on XSSF CF Iconset for #58130 X-Git-Tag: REL_3_13_FINAL~240 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5590c5bcad97e393cc6bad0e5987f2f5dd80dcb2;p=poi.git Start on XSSF CF Iconset for #58130 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691479 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java index a1386e400d..814e73ca09 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java @@ -23,15 +23,11 @@ import java.util.HashMap; import java.util.Map; import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold.RangeType; +import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet; import org.apache.poi.xssf.usermodel.XSSFFontFormatting; import org.apache.poi.xssf.model.StylesTable; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCfRule; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCfType; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.STConditionalFormattingOperator; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; /** * XSSF suport for Conditional Formatting rules @@ -179,12 +175,46 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule return new XSSFPatternFormatting(dxf.getFill()); } + public XSSFIconMultiStateFormatting createMultiStateFormatting(IconSet iconSet) { + // Is it already there? + if (_cfRule.isSetIconSet() && _cfRule.getType() == STCfType.ICON_SET) + return getMultiStateFormatting(); + + // Mark it as being an Icon Set + _cfRule.setType(STCfType.ICON_SET); - public IconMultiStateFormatting createMultiStateFormatting() { - throw new IllegalArgumentException("Not implemented yet"); // TODO + // Ensure the right element + CTIconSet icons = null; + if (_cfRule.isSetIconSet()) { + icons = _cfRule.getIconSet(); + } else { + icons = _cfRule.addNewIconSet(); + } + // Set the type of the icon set + if (iconSet.name != null) { + STIconSetType.Enum xIconSet = STIconSetType.Enum.forString(iconSet.name); + icons.setIconSet(xIconSet); + } + + // Add a default set of thresholds + int jump = 100 / iconSet.num; + STCfvoType.Enum type = STCfvoType.Enum.forString(RangeType.PERCENT.name); + for (int i=0; i