Beispiel #1
0
        public override int GetHashCode()
        {
            int val = 0;

            val  = 0 ^ this.HorizontalAlignment.GetHashCode();
            val ^= this.VerticalAlignment.GetHashCode();
            val ^= this.PatternStyle.GetHashCode();
            val ^= this.PatternBackgroundColor.GetHashCode();
            val ^= this.PatternForegroundColor.GetHashCode();
            val  = Utilities.RotateLeft(val, 8) ^ this.Indent;
            val ^= this.Rotation;
            val ^= this.Locked.GetHashCode();
            val ^= this.FormulaHidden.GetHashCode();
            val ^= this.WrapText.GetHashCode();
            val ^= this.ShrinkToFit.GetHashCode();
            val  = Utilities.RotateLeft(val, 8) ^ this.NumberFormat.GetHashCode();
            val ^= this.FontData.GetHashCode();
            val ^= this.BordersUsed.GetHashCode();
            for (int i = 0; i < 4; i++)
            {
                if ((this.BordersUsed & CellBorder.MultipleFromIndividualBorder((IndividualBorder)i)) != MultipleBorders.None)
                {
                    val ^= this.BorderStyle[i].GetHashCode();
                    val ^= this.BorderColor[i].GetHashCode();
                }
            }
            if ((this.BordersUsed & MultipleBorders.Diagonal) != MultipleBorders.None)
            {
                val ^= this.BorderStyle[4].GetHashCode();
                val ^= this.BorderColor[4].GetHashCode();
            }
            return(val);
        }
Beispiel #2
0
        private static void ResolveBorder(CellStyle bordersStyle, MergedCellRange mergedRange, IndividualBorder borderId, int row, int column, int rowInc, int colInc)
        {
            CellBorder border = bordersStyle.Borders[borderId];
            bool       flag   = true;

            while (row < mergedRange.Height)
            {
                if (column >= mergedRange.Width)
                {
                    return;
                }
                CellBorder border2 = mergedRange[row, column].Style.Borders[borderId];
                if (flag)
                {
                    border.LineStyle = border2.LineStyle;
                    border.LineColor = border2.LineColor;
                    flag             = false;
                }
                else if ((border2.LineStyle != border.LineStyle) || (border2.LineColor != border.LineColor))
                {
                    border.LineStyle = LineStyle.None;
                    border.LineColor = Color.Empty;
                    return;
                }
                row    += rowInc;
                column += colInc;
            }
        }
Beispiel #3
0
 public void SetBorders(MultipleBorders multipleBorders, Color lineColor, LineStyle lineStyle)
 {
     for (int i = 0; i < 6; i++)
     {
         IndividualBorder individualBorder = (IndividualBorder)i;
         if ((multipleBorders & CellBorder.MultipleFromIndividualBorder(individualBorder)) != MultipleBorders.None)
         {
             this[individualBorder].SetBorder(lineColor, lineStyle);
         }
     }
 }
Beispiel #4
0
        public override bool Equals(object obj)
        {
            CellStyleData data = (CellStyleData)obj;

            if (((data.HorizontalAlignment == this.HorizontalAlignment) && (data.VerticalAlignment == this.VerticalAlignment)) && (data.PatternStyle == this.PatternStyle))
            {
                int introduced3 = data.PatternBackgroundColor.ToArgb();
                if (introduced3 == this.PatternBackgroundColor.ToArgb())
                {
                    int introduced4 = data.PatternForegroundColor.ToArgb();
                    if ((((introduced4 == this.PatternForegroundColor.ToArgb()) && (data.Indent == this.Indent)) && ((data.Rotation == this.Rotation) && (data.Locked == this.Locked))) && (((data.FormulaHidden == this.FormulaHidden) && (data.WrapText == this.WrapText)) && ((data.ShrinkToFit == this.ShrinkToFit) && (data.NumberFormat == this.NumberFormat))))
                    {
                        if (!data.FontData.Equals(this.FontData))
                        {
                            return(false);
                        }
                        if (data.BordersUsed != this.BordersUsed)
                        {
                            return(false);
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            if ((this.BordersUsed & CellBorder.MultipleFromIndividualBorder((IndividualBorder)i)) != MultipleBorders.None)
                            {
                                if (data.BorderColor[i].ToArgb() != this.BorderColor[i].ToArgb())
                                {
                                    return(false);
                                }
                                if (data.BorderStyle[i] != this.BorderStyle[i])
                                {
                                    return(false);
                                }
                            }
                        }
                        if ((this.BordersUsed & MultipleBorders.Diagonal) != MultipleBorders.None)
                        {
                            if (data.BorderColor[4].ToArgb() != this.BorderColor[4].ToArgb())
                            {
                                return(false);
                            }
                            if (data.BorderStyle[4] != this.BorderStyle[4])
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #5
0
        internal CellStyle StyleResolved(int row, int column)
        {
            if (this.IsStyleDefault)
            {
                return(null);
            }
            IndividualBorder[] borderArray = new IndividualBorder[4];
            int        num    = 0;
            CellBorder border = this.style.Borders[IndividualBorder.Bottom];

            if ((border.LineStyle != LineStyle.None) && (row < base.LastRowIndex))
            {
                borderArray[num++] = IndividualBorder.Bottom;
            }
            border = this.style.Borders[IndividualBorder.Top];
            if ((border.LineStyle != LineStyle.None) && (row > base.FirstRowIndex))
            {
                borderArray[num++] = IndividualBorder.Top;
            }
            border = this.style.Borders[IndividualBorder.Right];
            if ((border.LineStyle != LineStyle.None) && (column < base.LastColumnIndex))
            {
                borderArray[num++] = IndividualBorder.Right;
            }
            border = this.style.Borders[IndividualBorder.Left];
            if ((border.LineStyle != LineStyle.None) && (column > base.FirstColumnIndex))
            {
                borderArray[num++] = IndividualBorder.Left;
            }
            if (num == 0)
            {
                return(this.style);
            }
            CellStyle style = new CellStyle(this.style, this.style.Element.ParentCollection);

            for (int i = 0; i < num; i++)
            {
                style.Borders[borderArray[i]].SetBorder(Color.Empty, LineStyle.None);
            }
            return(style);
        }
Beispiel #6
0
        internal void CopyIfNotUsed(CellStyle lowerPriority)
        {
            this.BeforeChange();
            CellStyleData element = this.element;
            CellStyleData data2   = lowerPriority.element;

            if ((this.UseFlags & CellStyleData.Properties.HorizontalAlignment) == CellStyleData.Properties.None)
            {
                element.HorizontalAlignment = data2.HorizontalAlignment;
            }
            if ((this.UseFlags & CellStyleData.Properties.VerticalAlignment) == CellStyleData.Properties.None)
            {
                element.VerticalAlignment = data2.VerticalAlignment;
            }
            if ((this.UseFlags & CellStyleData.Properties.PatternStyle) == CellStyleData.Properties.None)
            {
                element.PatternStyle = data2.PatternStyle;
            }
            if ((this.UseFlags & CellStyleData.Properties.PatternBackgroundColor) == CellStyleData.Properties.None)
            {
                element.PatternBackgroundColor = data2.PatternBackgroundColor;
            }
            if ((this.UseFlags & CellStyleData.Properties.PatternForegroundColor) == CellStyleData.Properties.None)
            {
                element.PatternForegroundColor = data2.PatternForegroundColor;
            }
            if ((this.UseFlags & CellStyleData.Properties.Indent) == CellStyleData.Properties.None)
            {
                element.Indent = data2.Indent;
            }
            if ((this.UseFlags & CellStyleData.Properties.Rotation) == CellStyleData.Properties.None)
            {
                element.Rotation = data2.Rotation;
            }
            if ((this.UseFlags & CellStyleData.Properties.Locked) == CellStyleData.Properties.None)
            {
                element.Locked = data2.Locked;
            }
            if ((this.UseFlags & CellStyleData.Properties.FormulaHidden) == CellStyleData.Properties.None)
            {
                element.FormulaHidden = data2.FormulaHidden;
            }
            if ((this.UseFlags & CellStyleData.Properties.WrapText) == CellStyleData.Properties.None)
            {
                element.WrapText = data2.WrapText;
            }
            if ((this.UseFlags & CellStyleData.Properties.ShrinkToFit) == CellStyleData.Properties.None)
            {
                element.ShrinkToFit = data2.ShrinkToFit;
            }
            if ((this.UseFlags & CellStyleData.Properties.NumberFormat) == CellStyleData.Properties.None)
            {
                element.NumberFormat = data2.NumberFormat;
            }
            if ((this.UseFlags & CellStyleData.Properties.FontName) == CellStyleData.Properties.None)
            {
                element.FontData.Name = data2.FontData.Name;
            }
            if ((this.UseFlags & CellStyleData.Properties.FontColor) == CellStyleData.Properties.None)
            {
                element.FontData.Color = data2.FontData.Color;
            }
            if ((this.UseFlags & CellStyleData.Properties.FontWeight) == CellStyleData.Properties.None)
            {
                element.FontData.Weight = data2.FontData.Weight;
            }
            if ((this.UseFlags & CellStyleData.Properties.FontSize) == CellStyleData.Properties.None)
            {
                element.FontData.Size = data2.FontData.Size;
            }
            if ((this.UseFlags & CellStyleData.Properties.FontItalic) == CellStyleData.Properties.None)
            {
                element.FontData.Italic = data2.FontData.Italic;
            }
            if ((this.UseFlags & CellStyleData.Properties.FontStrikeout) == CellStyleData.Properties.None)
            {
                element.FontData.Strikeout = data2.FontData.Strikeout;
            }
            if ((this.UseFlags & CellStyleData.Properties.FontScriptPosition) == CellStyleData.Properties.None)
            {
                element.FontData.ScriptPosition = data2.FontData.ScriptPosition;
            }
            if ((this.UseFlags & CellStyleData.Properties.FontUnderlineStyle) == CellStyleData.Properties.None)
            {
                element.FontData.UnderlineStyle = data2.FontData.UnderlineStyle;
            }
            for (int i = 0; i < 4; i++)
            {
                if ((element.BordersUsed & CellBorder.MultipleFromIndividualBorder((IndividualBorder)i)) == MultipleBorders.None)
                {
                    element.BorderColor[i] = data2.BorderColor[i];
                    element.BorderStyle[i] = data2.BorderStyle[i];
                }
            }
            if ((element.BordersUsed & MultipleBorders.Diagonal) == MultipleBorders.None)
            {
                element.BorderColor[4] = data2.BorderColor[4];
                element.BorderStyle[4] = data2.BorderStyle[4];
            }
            element.BordersUsed |= data2.BordersUsed;
            this.UseFlags       |= lowerPriority.UseFlags;
        }