コード例 #1
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);
        }
コード例 #2
0
ファイル: CFRuleRecord.cs プロジェクト: zhgl7688/-
        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);
        }
コード例 #3
0
ファイル: CFRuleBase.cs プロジェクト: zzy092/npoi
        protected int ReadFormatOptions(RecordInputStream in1)
        {
            formatting_options  = in1.ReadInt();
            formatting_not_used = in1.ReadShort();

            int len = 6;

            if (ContainsFontFormattingBlock)
            {
                _fontFormatting = new FontFormatting(in1);
                len            += _fontFormatting.DataLength;
            }

            if (ContainsBorderFormattingBlock)
            {
                _borderFormatting = new BorderFormatting(in1);
                len += _borderFormatting.DataLength;
            }

            if (ContainsPatternFormattingBlock)
            {
                _patternFormatting = new PatternFormatting(in1);
                len += _patternFormatting.DataLength;
            }

            return(len);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="iFactr.UI.Font"/> structure.
        /// </summary>
        /// <param name="name">The name of the font family.</param>
        /// <param name="size">The size of the text characters.</param>
        /// <param name="formatting">Any special formatting applied to the font.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="size"/> is less than 0.</exception>
        public Font(string name, double size, FontFormatting formatting)
        {
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size", "Size cannot be less than 0.");
            }

            Name       = string.IsNullOrEmpty(name) ? PreferredLabelFont.Name : name;
            Size       = size;
            Formatting = formatting;
        }
コード例 #5
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);
            }
        }
コード例 #6
0
        private void testCFRuleBase(CFRuleBase 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);

            PatternFormatting patternFormatting = new PatternFormatting();

            TestPatternFormattingAccessors(patternFormatting);
            Assert.IsFalse(record.ContainsPatternFormattingBlock);
            record.PatternFormatting = (patternFormatting);
            Assert.IsTrue(record.ContainsPatternFormattingBlock);
        }
コード例 #7
0
ファイル: CFRuleRecord.cs プロジェクト: zhgl7688/-
        /** 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);
        }
コード例 #8
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);
        }
コード例 #9
0
 public bool Equals(FontFormatting other)
 {
     return(Equals(Font, other.Font) && Color.Equals(other.Color) && OutlineWidth == other.OutlineWidth &&
            ShadowDistance == other.ShadowDistance);
 }
コード例 #10
0
ファイル: HSSFFontFormatting.cs プロジェクト: yesonsik/npoi
 public HSSFFontFormatting(CFRuleRecord cfRuleRecord)
 {
     this.fontFormatting = cfRuleRecord.FontFormatting;
 }
コード例 #11
0
ファイル: TestCFRuleRecord.cs プロジェクト: thinhmascot/NPOI
        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(0, fontFormatting.EscapementType);
            Assert.AreEqual(-1, fontFormatting.FontColorIndex);
            Assert.AreEqual(-1, fontFormatting.FontHeight);
            Assert.AreEqual(0, fontFormatting.FontWeight);
            Assert.AreEqual(0, fontFormatting.UnderlineType);

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

            fontFormatting.EscapementType = (FontFormatting.SS_SUB);
            Assert.AreEqual(FontFormatting.SS_SUB, fontFormatting.EscapementType);
            fontFormatting.EscapementType = (FontFormatting.SS_SUPER);
            Assert.AreEqual(FontFormatting.SS_SUPER, fontFormatting.EscapementType);
            fontFormatting.EscapementType = (FontFormatting.SS_NONE);
            Assert.AreEqual(FontFormatting.SS_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 = (FontFormatting.U_DOUBLE_ACCOUNTING);
            Assert.AreEqual(FontFormatting.U_DOUBLE_ACCOUNTING, fontFormatting.UnderlineType);

            fontFormatting.IsUnderlineTypeModified = (false);
            Assert.IsFalse(fontFormatting.IsUnderlineTypeModified);
            fontFormatting.IsUnderlineTypeModified = (true);
            Assert.IsTrue(fontFormatting.IsUnderlineTypeModified);
        }
コード例 #12
0
 public HSSFFontFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook)
 {
     this.fontFormatting = cfRuleRecord.FontFormatting;
     this.workbook       = workbook;
 }