コード例 #1
0
ファイル: FontFormatting.cs プロジェクト: zzy092/npoi
        public Object Clone()
        {
            FontFormatting other = new FontFormatting();

            Array.Copy(_rawData, 0, other._rawData, 0, _rawData.Length);
            return(other);
        }
コード例 #2
0
 private HSSFFontFormatting GetFontFormatting(bool Create)
 {
     FontFormatting fontFormatting = cfRuleRecord.FontFormatting;
     if (fontFormatting != null)
     {
         cfRuleRecord.FontFormatting=(fontFormatting);
         return new HSSFFontFormatting(cfRuleRecord);
     }
     else if (Create)
     {
         fontFormatting = new FontFormatting();
         cfRuleRecord.FontFormatting=(fontFormatting);
         return new HSSFFontFormatting(cfRuleRecord);
     }
     else
     {
         return null;
     }
 }
コード例 #3
0
ファイル: CFRuleRecord.cs プロジェクト: Reinakumiko/npoi
        public CFRuleRecord(RecordInputStream in1)
        {
            field_1_condition_type = (byte)in1.ReadByte();
            field_2_comparison_operator = (byte)in1.ReadByte();
            int field_3_formula1_len = in1.ReadUShort();
            int field_4_formula2_len = in1.ReadUShort();
            field_5_options = in1.ReadInt();
            field_6_not_used = in1.ReadShort();

            if (ContainsFontFormattingBlock)
            {
                _fontFormatting = new FontFormatting(in1);
            }

            if (ContainsBorderFormattingBlock)
            {
                _borderFormatting = new BorderFormatting(in1);
            }

            if (ContainsPatternFormattingBlock)
            {
                _patternFormatting = new PatternFormatting(in1);
            }
            field_17_formula1 = FR.Formula.Read(field_3_formula1_len, in1);
            field_18_formula2 = FR.Formula.Read(field_4_formula2_len, in1);
    }
コード例 #4
0
ファイル: CFRuleRecord.cs プロジェクト: Reinakumiko/npoi
        /** Creates new CFRuleRecord */
        private CFRuleRecord(byte conditionType, ComparisonOperator comparisonOperation)
        {
            field_1_condition_type = conditionType;
            field_2_comparison_operator =(byte) comparisonOperation;

            // Set modification flags to 1: by default options are not modified
            field_5_options = modificationBits.SetValue(field_5_options, -1);
            // Set formatting block flags to 0 (no formatting blocks)
            field_5_options = fmtBlockBits.SetValue(field_5_options, 0);
            field_5_options = Undocumented.Clear(field_5_options);

            //TODO:: check what's this field used for
            field_6_not_used = unchecked((short)0x8002); // Excel seems to Write this value, but it doesn't seem to care what it Reads
            _fontFormatting = null;
            //field_8_align_text_break = 0;
            //field_9_align_text_rotation_angle = 0;
            //field_10_align_indentation = 0;
            //field_11_relative_indentation = 0;
            //field_12_not_used = 0;
            _borderFormatting = null;
            _patternFormatting = null;
            field_17_formula1 = FR.Formula.Create(Ptg.EMPTY_PTG_ARRAY);
            field_18_formula2 = FR.Formula.Create(Ptg.EMPTY_PTG_ARRAY);
        }
コード例 #5
0
 public HSSFFontFormatting(CFRuleRecord cfRuleRecord)
 {
     this.fontFormatting = cfRuleRecord.FontFormatting;
 }
コード例 #6
0
        private void TestCFRuleRecord1(CFRuleRecord record)
	    {
		    FontFormatting fontFormatting = new FontFormatting();
		    TestFontFormattingAccessors(fontFormatting);
		    Assert.IsFalse(record.ContainsFontFormattingBlock);
		    record.FontFormatting = (fontFormatting);
		    Assert.IsTrue(record.ContainsFontFormattingBlock);

		    BorderFormatting borderFormatting = new BorderFormatting();
		    TestBorderFormattingAccessors(borderFormatting);
		    Assert.IsFalse(record.ContainsBorderFormattingBlock);
		    record.BorderFormatting = (borderFormatting);
		    Assert.IsTrue(record.ContainsBorderFormattingBlock);

		    Assert.IsFalse(record.IsLeftBorderModified);
		    record.IsLeftBorderModified = (true);
		    Assert.IsTrue(record.IsLeftBorderModified);

		    Assert.IsFalse(record.IsRightBorderModified);
		    record.IsRightBorderModified = (true);
		    Assert.IsTrue(record.IsRightBorderModified);

		    Assert.IsFalse(record.IsTopBorderModified);
		    record.IsTopBorderModified = (true);
		    Assert.IsTrue(record.IsTopBorderModified);

		    Assert.IsFalse(record.IsBottomBorderModified);
		    record.IsBottomBorderModified = (true);
		    Assert.IsTrue(record.IsBottomBorderModified);

		    Assert.IsFalse(record.IsTopLeftBottomRightBorderModified);
		    record.IsTopLeftBottomRightBorderModified = (true);
		    Assert.IsTrue(record.IsTopLeftBottomRightBorderModified);

		    Assert.IsFalse(record.IsBottomLeftTopRightBorderModified);
		    record.IsBottomLeftTopRightBorderModified = (true);
		    Assert.IsTrue(record.IsBottomLeftTopRightBorderModified);


		    PatternFormatting patternFormatting = new PatternFormatting();
		    TestPatternFormattingAccessors(patternFormatting);
		    Assert.IsFalse(record.ContainsPatternFormattingBlock);
		    record.PatternFormatting = (patternFormatting);
		    Assert.IsTrue(record.ContainsPatternFormattingBlock);

		    Assert.IsFalse(record.IsPatternBackgroundColorModified);
		    record.IsPatternBackgroundColorModified = (true);
		    Assert.IsTrue(record.IsPatternBackgroundColorModified);

		    Assert.IsFalse(record.IsPatternColorModified);
		    record.IsPatternColorModified = (true);
		    Assert.IsTrue(record.IsPatternColorModified);

		    Assert.IsFalse(record.IsPatternStyleModified);
		    record.IsPatternStyleModified = (true);
		    Assert.IsTrue(record.IsPatternStyleModified);
	    }
コード例 #7
0
        private void TestFontFormattingAccessors(FontFormatting fontFormatting)
        {
            // Check for defaults
            Assert.IsFalse(fontFormatting.IsEscapementTypeModified);
            Assert.IsFalse(fontFormatting.IsFontCancellationModified);
            Assert.IsFalse(fontFormatting.IsFontOutlineModified);
            Assert.IsFalse(fontFormatting.IsFontShadowModified);
            Assert.IsFalse(fontFormatting.IsFontStyleModified);
            Assert.IsFalse(fontFormatting.IsUnderlineTypeModified);
            Assert.IsFalse(fontFormatting.IsFontWeightModified);

            Assert.IsFalse(fontFormatting.IsBold);
            Assert.IsFalse(fontFormatting.IsItalic);
            Assert.IsFalse(fontFormatting.IsOutlineOn);
            Assert.IsFalse(fontFormatting.IsShadowOn);
            Assert.IsFalse(fontFormatting.IsStruckout);

            Assert.AreEqual(FontSuperScript.None, fontFormatting.EscapementType);
            Assert.AreEqual(-1, fontFormatting.FontColorIndex);
            Assert.AreEqual(-1, fontFormatting.FontHeight);
            Assert.AreEqual(0, fontFormatting.FontWeight);
            Assert.AreEqual(FontUnderlineType.None, fontFormatting.UnderlineType);

            fontFormatting.IsBold = (true);
            Assert.IsTrue(fontFormatting.IsBold);
            fontFormatting.IsBold = (false);
            Assert.IsFalse(fontFormatting.IsBold);

            fontFormatting.EscapementType = FontSuperScript.Sub;
            Assert.AreEqual(FontSuperScript.Sub, fontFormatting.EscapementType);
            fontFormatting.EscapementType = FontSuperScript.Super;
            Assert.AreEqual(FontSuperScript.Super, fontFormatting.EscapementType);
            fontFormatting.EscapementType = FontSuperScript.None;
            Assert.AreEqual(FontSuperScript.None, fontFormatting.EscapementType);

            fontFormatting.IsEscapementTypeModified = (false);
            Assert.IsFalse(fontFormatting.IsEscapementTypeModified);
            fontFormatting.IsEscapementTypeModified = (true);
            Assert.IsTrue(fontFormatting.IsEscapementTypeModified);

            fontFormatting.IsFontWeightModified = (false);
            Assert.IsFalse(fontFormatting.IsFontWeightModified);
            fontFormatting.IsFontWeightModified = (true);
            Assert.IsTrue(fontFormatting.IsFontWeightModified);

            fontFormatting.IsFontCancellationModified = (false);
            Assert.IsFalse(fontFormatting.IsFontCancellationModified);
            fontFormatting.IsFontCancellationModified = (true);
            Assert.IsTrue(fontFormatting.IsFontCancellationModified);

            fontFormatting.FontColorIndex = ((short)10);
            Assert.AreEqual(10, fontFormatting.FontColorIndex);

            fontFormatting.FontHeight = (100);
            Assert.AreEqual(100, fontFormatting.FontHeight);

            fontFormatting.IsFontOutlineModified = (false);
            Assert.IsFalse(fontFormatting.IsFontOutlineModified);
            fontFormatting.IsFontOutlineModified = (true);
            Assert.IsTrue(fontFormatting.IsFontOutlineModified);

            fontFormatting.IsFontShadowModified = (false);
            Assert.IsFalse(fontFormatting.IsFontShadowModified);
            fontFormatting.IsFontShadowModified = (true);
            Assert.IsTrue(fontFormatting.IsFontShadowModified);

            fontFormatting.IsFontStyleModified = (false);
            Assert.IsFalse(fontFormatting.IsFontStyleModified);
            fontFormatting.IsFontStyleModified = (true);
            Assert.IsTrue(fontFormatting.IsFontStyleModified);

            fontFormatting.IsItalic = (false);
            Assert.IsFalse(fontFormatting.IsItalic);
            fontFormatting.IsItalic = (true);
            Assert.IsTrue(fontFormatting.IsItalic);

            fontFormatting.IsOutlineOn = (false);
            Assert.IsFalse(fontFormatting.IsOutlineOn);
            fontFormatting.IsOutlineOn = (true);
            Assert.IsTrue(fontFormatting.IsOutlineOn);

            fontFormatting.IsShadowOn = (false);
            Assert.IsFalse(fontFormatting.IsShadowOn);
            fontFormatting.IsShadowOn = (true);
            Assert.IsTrue(fontFormatting.IsShadowOn);

            fontFormatting.IsStruckout = (false);
            Assert.IsFalse(fontFormatting.IsStruckout);
            fontFormatting.IsStruckout = (true);
            Assert.IsTrue(fontFormatting.IsStruckout);

            fontFormatting.UnderlineType = FontUnderlineType.DoubleAccounting;
            Assert.AreEqual(FontUnderlineType.DoubleAccounting, fontFormatting.UnderlineType);

            fontFormatting.IsUnderlineTypeModified = (false);
            Assert.IsFalse(fontFormatting.IsUnderlineTypeModified);
            fontFormatting.IsUnderlineTypeModified = (true);
            Assert.IsTrue(fontFormatting.IsUnderlineTypeModified);
        }