You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2015/07/17 03:20:20 UTC
svn commit: r1691472 - in /poi/trunk/src: java/org/apache/poi/hssf/record/
java/org/apache/poi/hssf/usermodel/ java/org/apache/poi/ss/usermodel/
ooxml/java/org/apache/poi/xssf/usermodel/
Author: nick
Date: Fri Jul 17 01:20:20 2015
New Revision: 1691472
URL: http://svn.apache.org/r1691472
Log:
#58130 more progress towards supporting other CF types
Modified:
poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java
poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java
poi/trunk/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java?rev=1691472&r1=1691471&r2=1691472&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java Fri Jul 17 01:20:20 2015
@@ -20,11 +20,13 @@ package org.apache.poi.hssf.record;
import java.util.Arrays;
import org.apache.poi.hssf.record.cf.IconMultiStateFormatting;
+import org.apache.poi.hssf.record.cf.Threshold;
import org.apache.poi.hssf.record.common.FtrHeader;
import org.apache.poi.hssf.record.common.FutureRecord;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.formula.Formula;
import org.apache.poi.ss.formula.ptg.Ptg;
+import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
@@ -116,6 +118,22 @@ public final class CFRule12Record extend
return new CFRule12Record(CONDITION_TYPE_CELL_VALUE_IS, comparisonOperation,
formula1, formula2, formula3);
}
+ /**
+ * Creates a new Icon Set / Multi-State formatting
+ */
+ public static CFRule12Record create(HSSFSheet sheet, IconSet iconSet) {
+ Threshold[] ts = new Threshold[iconSet.num];
+ for (int i=0; i<ts.length; i++) {
+ ts[i] = new Threshold();
+ }
+
+ CFRule12Record r = new CFRule12Record(CONDITION_TYPE_COLOR_SCALE,
+ ComparisonOperator.NO_COMPARISON);
+ r.getMultiStateFormatting().setIconSet(iconSet);
+ r.getMultiStateFormatting().setThresholds(ts);
+ return r;
+ }
+ // TODO Static creators for the other record types
public CFRule12Record(RecordInputStream in) {
futureHeader = new FtrHeader(in);
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java?rev=1691472&r1=1691471&r2=1691472&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java Fri Jul 17 01:20:20 2015
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.usermodel;
+import org.apache.poi.hssf.record.CFRule12Record;
import org.apache.poi.hssf.record.CFRuleBase;
import org.apache.poi.hssf.record.CFRuleRecord;
import org.apache.poi.hssf.record.aggregates.CFRecordsAggregate;
@@ -24,6 +25,7 @@ import org.apache.poi.hssf.record.aggreg
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.usermodel.ConditionalFormatting;
import org.apache.poi.ss.usermodel.ConditionalFormattingRule;
+import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet;
import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
import org.apache.poi.ss.util.CellRangeAddress;
@@ -90,21 +92,23 @@ public final class HSSFSheetConditionalF
return new HSSFConditionalFormattingRule(_sheet, rr);
}
- // TODO Support types beyond CELL_VALUE_IS and FORMULA
-
/**
* A factory method allowing the creation of conditional formatting
- * rules using an Icon Set / Multi-State formatting/
+ * rules using an Icon Set / Multi-State formatting.
+ * The thresholds for it will be created, but will be empty
+ * and require configuring with
+ * {@link HSSFConditionalFormattingRule#getMultiStateFormatting()}
+ * then
+ * {@link HSSFIconMultiStateFormatting#getThresholds()}
*/
- // TODO Implement
-/*
public HSSFConditionalFormattingRule createConditionalFormattingRule(
- IconSet iconSet) { // TODO Multi-State data for it
+ IconSet iconSet) {
CFRule12Record rr = CFRule12Record.create(_sheet, iconSet);
return new HSSFConditionalFormattingRule(_sheet, rr);
}
-*/
+ // TODO Support types beyond CELL_VALUE_IS and FORMULA and ICONs
+
/**
* Adds a copy of HSSFConditionalFormatting object to the sheet
* <p>This method could be used to copy HSSFConditionalFormatting object
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java?rev=1691472&r1=1691471&r2=1691472&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java Fri Jul 17 01:20:20 2015
@@ -74,11 +74,16 @@ public interface ConditionalFormattingRu
PatternFormatting createPatternFormatting();
/**
- * @return - pattern formatting object if defined, <code>null</code> otherwise
+ * @return - pattern formatting object if defined, <code>null</code> otherwise
*/
PatternFormatting getPatternFormatting();
/**
+ * @return - icon / multi-state formatting object if defined, <code>null</code> otherwise
+ */
+ IconMultiStateFormatting getMultiStateFormatting();
+
+ /**
* Type of conditional formatting rule.
* <p>
* MUST be one of the IDs of a {@link ConditionType}
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java?rev=1691472&r1=1691471&r2=1691472&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java Fri Jul 17 01:20:20 2015
@@ -19,6 +19,7 @@
package org.apache.poi.ss.usermodel;
+import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet;
import org.apache.poi.ss.util.CellRangeAddress;
/**
@@ -136,6 +137,18 @@ public interface SheetConditionalFormatt
ConditionalFormattingRule createConditionalFormattingRule(String formula);
/**
+ * Create an Icon Set / Multi-State conditional formatting rule.
+ * <p>The thresholds for it will be created, but will be empty
+ * and require configuring with
+ * {@link ConditionalFormattingRule#getMultiStateFormatting()}
+ * then
+ * {@link IconMultiStateFormatting#getThresholds()}
+ */
+ ConditionalFormattingRule createConditionalFormattingRule(IconSet iconSet);
+
+ // TODO Support types beyond CELL_VALUE_IS and FORMULA and ICONs
+
+ /**
* Gets Conditional Formatting object at a particular index
*
* @param index 0-based index of the Conditional Formatting object to fetch
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java?rev=1691472&r1=1691471&r2=1691472&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java Fri Jul 17 01:20:20 2015
@@ -178,6 +178,14 @@ public class XSSFConditionalFormattingRu
return new XSSFPatternFormatting(dxf.getFill());
}
+
+
+ public IconMultiStateFormatting createMultiStateFormatting() {
+ throw new IllegalArgumentException("Not implemented yet"); // TODO
+ }
+ public IconMultiStateFormatting getMultiStateFormatting() {
+ throw new IllegalArgumentException("Not implemented yet"); // TODO
+ }
/**
* Type of conditional formatting rule.
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java?rev=1691472&r1=1691471&r2=1691472&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java Fri Jul 17 01:20:20 2015
@@ -27,10 +27,13 @@ import org.apache.poi.ss.SpreadsheetVers
import org.apache.poi.ss.usermodel.ComparisonOperator;
import org.apache.poi.ss.usermodel.ConditionalFormatting;
import org.apache.poi.ss.usermodel.ConditionalFormattingRule;
+import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet;
import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
import org.apache.poi.ss.util.CellRangeAddress;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCfRule;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColorScale;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTConditionalFormatting;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIconSet;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCfType;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STConditionalFormattingOperator;
@@ -118,6 +121,32 @@ public class XSSFSheetConditionalFormatt
return rule;
}
+ /**
+ * A factory method allowing the creation of conditional formatting
+ * rules using an Icon Set / Multi-State formatting.
+ * The thresholds for it will be created, but will be empty
+ * and require configuring with
+ * {@link XSSFConditionalFormattingRule#getMultiStateFormatting()}
+ * then
+ * {@link XSSFIconMultiStateFormatting#getThresholds()}
+ */
+ public XSSFConditionalFormattingRule createConditionalFormattingRule(IconSet iconSet) {
+ XSSFConditionalFormattingRule rule = new XSSFConditionalFormattingRule(_sheet);
+ CTCfRule cfRule = rule.getCTCfRule();
+ cfRule.setType(STCfType.COLOR_SCALE);
+
+ CTIconSet icons = cfRule.addNewIconSet();
+ if (iconSet.name != null) {
+ // TODO Map to the enum
+// icons.setIconSet();
+ }
+ // TODO Add cfvos
+
+ return rule;
+ }
+
+ // TODO Support types beyond CELL_VALUE_IS and FORMULA and ICONs
+
@SuppressWarnings("deprecation")
public int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule[] cfRules) {
if (regions == null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org