Search in sources :

Example 1 with PatternFormatting

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;
}
Also used : PatternFormatting(org.apache.poi.hssf.record.cf.PatternFormatting) BorderFormatting(org.apache.poi.hssf.record.cf.BorderFormatting) FontFormatting(org.apache.poi.hssf.record.cf.FontFormatting)

Example 2 with PatternFormatting

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());
}
Also used : PatternFormatting(org.apache.poi.hssf.record.cf.PatternFormatting) BorderFormatting(org.apache.poi.hssf.record.cf.BorderFormatting) FontFormatting(org.apache.poi.hssf.record.cf.FontFormatting)

Example 3 with PatternFormatting

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();
}
Also used : PatternFormatting(org.apache.poi.hssf.record.cf.PatternFormatting) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Example 4 with PatternFormatting

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);
}
Also used : PatternFormatting(org.apache.poi.hssf.record.cf.PatternFormatting)

Aggregations

PatternFormatting (org.apache.poi.hssf.record.cf.PatternFormatting)4 BorderFormatting (org.apache.poi.hssf.record.cf.BorderFormatting)2 FontFormatting (org.apache.poi.hssf.record.cf.FontFormatting)2 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 Test (org.junit.Test)1