use of org.apache.poi.hssf.record.cf.PatternFormatting in project poi by apache.
the class CFRuleBase method readFormatOptions.
protected int readFormatOptions(RecordInputStream in) {
formatting_options = in.readInt();
formatting_not_used = in.readShort();
int len = 6;
if (containsFontFormattingBlock()) {
_fontFormatting = new FontFormatting(in);
len += _fontFormatting.getDataLength();
}
if (containsBorderFormattingBlock()) {
_borderFormatting = new BorderFormatting(in);
len += _borderFormatting.getDataLength();
}
if (containsPatternFormattingBlock()) {
_patternFormatting = new PatternFormatting(in);
len += _patternFormatting.getDataLength();
}
return len;
}
use of org.apache.poi.hssf.record.cf.PatternFormatting in project poi by apache.
the class TestCFRuleRecord method testCFRuleBase.
private void testCFRuleBase(CFRuleBase record) {
FontFormatting fontFormatting = new FontFormatting();
testFontFormattingAccessors(fontFormatting);
assertFalse(record.containsFontFormattingBlock());
record.setFontFormatting(fontFormatting);
assertTrue(record.containsFontFormattingBlock());
BorderFormatting borderFormatting = new BorderFormatting();
testBorderFormattingAccessors(borderFormatting);
assertFalse(record.containsBorderFormattingBlock());
record.setBorderFormatting(borderFormatting);
assertTrue(record.containsBorderFormattingBlock());
PatternFormatting patternFormatting = new PatternFormatting();
testPatternFormattingAccessors(patternFormatting);
assertFalse(record.containsPatternFormattingBlock());
record.setPatternFormatting(patternFormatting);
assertTrue(record.containsPatternFormattingBlock());
}
use of org.apache.poi.hssf.record.cf.PatternFormatting in project poi by apache.
the class TestCFRuleRecord method testWrite.
@Test
public void testWrite() throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
CFRuleRecord rr = CFRuleRecord.create(sheet, ComparisonOperator.BETWEEN, "5", "10");
PatternFormatting patternFormatting = new PatternFormatting();
patternFormatting.setFillPattern(PatternFormatting.BRICKS);
rr.setPatternFormatting(patternFormatting);
byte[] data = rr.serialize();
assertEquals(26, data.length);
assertEquals(3, LittleEndian.getShort(data, 6));
assertEquals(3, LittleEndian.getShort(data, 8));
int flags = LittleEndian.getInt(data, 10);
assertEquals("unused flags should be 111", 0x00380000, flags & 0x00380000);
// Otherwise Excel gets unhappy
assertEquals("undocumented flags should be 0000", 0, flags & 0x03C00000);
// check all remaining flag bits (some are not well understood yet)
assertEquals(0x203FFFFF, flags);
workbook.close();
}
use of org.apache.poi.hssf.record.cf.PatternFormatting in project poi by apache.
the class HSSFConditionalFormattingRule method getPatternFormatting.
private HSSFPatternFormatting getPatternFormatting(boolean create) {
PatternFormatting patternFormatting = cfRuleRecord.getPatternFormatting();
if (patternFormatting == null) {
if (!create)
return null;
patternFormatting = new PatternFormatting();
cfRuleRecord.setPatternFormatting(patternFormatting);
}
return new HSSFPatternFormatting(cfRuleRecord, workbook);
}
Aggregations