internal SLDifferentialFormat TranslateToDifferentialFormat(SLStyle style)
        {
            style.Sync();
            SLDifferentialFormat df = new SLDifferentialFormat();
            if (style.HasNumberingFormat) df.FormatCode = style.FormatCode;

            if (style.Font.Italic != null && style.Font.Italic.Value) df.Font.Italic = true;
            if (style.Font.Bold != null && style.Font.Bold.Value) df.Font.Bold = true;
            if (style.Font.HasUnderline) df.Font.Underline = style.Font.Underline;
            if (style.Font.HasFontColor)
            {
                df.Font.clrFontColor = style.Font.clrFontColor.Clone();
                df.Font.HasFontColor = true;
            }
            if (style.Font.Strike != null && style.Font.Strike.Value) df.Font.Strike = true;

            if (style.HasBorder) df.Border = style.Border.Clone();
            if (style.HasFill) df.Fill = style.Fill.Clone();

            df.Sync();
            return df;
        }
Exemplo n.º 2
0
        internal void TranslateStyleIdsToStyles(ref SLStyle style)
        {
            int index;

            if (style.NumberFormatId != null)
            {
                index = (int)style.NumberFormatId.Value;
                style.nfFormatCode = new SLNumberingFormat();
                style.nfFormatCode.NumberFormatId = (uint)index;

                if (dictStyleNumberingFormat.ContainsKey(index))
                {
                    style.nfFormatCode.FromHash(dictStyleNumberingFormat[index]);
                }
                else if (dictBuiltInNumberingFormat.ContainsKey(index))
                {
                    style.nfFormatCode.FormatCode = dictBuiltInNumberingFormat[index];
                }
                else
                {
                    // don't know the format code, but *something* has to be written.
                    //style.nfFormatCode.FormatCode = string.Format("Built-in format code {0}", index);
                    style.nfFormatCode.FormatCode = SLConstants.NumberFormatGeneral;
                }
                style.HasNumberingFormat = true;
            }
            else
            {
                style.RemoveFormatCode();
            }

            if (style.FontId != null)
            {
                style.HasFont = true;
                index = (int)style.FontId.Value;
                if (index >= 0 && index < listStyleFont.Count)
                {
                    style.fontReal = new SLFont(SimpleTheme.MajorLatinFont, SimpleTheme.MinorLatinFont, SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
                    style.fontReal.FromHash(listStyleFont[index]);
                }
                else
                {
                    style.RemoveFont();
                }
            }
            else
            {
                style.RemoveFont();
            }

            if (style.FillId != null)
            {
                style.HasFill = true;
                index = (int)style.FillId.Value;
                if (index >= 0 && index < listStyleFill.Count)
                {
                    style.fillReal = new SLFill(SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
                    style.fillReal.FromHash(listStyleFill[index]);
                }
                else
                {
                    style.RemoveFill();
                }
            }
            else
            {
                style.RemoveFill();
            }

            if (style.BorderId != null)
            {
                style.HasBorder = true;
                index = (int)style.BorderId.Value;
                if (index >= 0 && index < listStyleBorder.Count)
                {
                    style.borderReal = new SLBorder(SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
                    style.borderReal.FromHash(listStyleBorder[index]);
                }
                else
                {
                    style.RemoveBorder();
                }
            }
            else
            {
                style.RemoveBorder();
            }

            style.Sync();
        }
Exemplo n.º 3
0
        internal void TranslateStylesToStyleIds(ref SLStyle style)
        {
            style.Sync();

            if (style.nfFormatCode.FormatCode.Length > 0)
            {
                style.NumberFormatId = (uint)this.SaveToStylesheetNumberingFormat(style.nfFormatCode.ToHash());
            }
            else
            {
                style.NumberFormatId = (uint)this.NumberFormatGeneralId;
            }

            if (style.HasFont)
            {
                style.FontId = (uint)this.SaveToStylesheetFont(style.fontReal.ToHash());
            }
            else
            {
                style.FontId = (uint)this.SaveToStylesheetFont(listStyleFont[0]);
            }

            if (style.HasFill)
            {
                style.FillId = (uint)this.SaveToStylesheetFill(style.fillReal.ToHash());
            }
            else
            {
                SLFill fill = new SLFill(SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
                fill.SetPatternType(PatternValues.None);
                style.FillId = (uint)this.SaveToStylesheetFill(fill.ToHash());
            }

            if (style.HasBorder)
            {
                style.BorderId = (uint)this.SaveToStylesheetBorder(style.borderReal.ToHash());
            }
            else
            {
                SLBorder border = new SLBorder(SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
                style.BorderId = (uint)this.SaveToStylesheetBorder(border.ToHash());
            }
        }
Exemplo n.º 4
0
        internal void MergeStyle(SLStyle NewStyle)
        {
            NewStyle.Sync();

            if (NewStyle.HasAlignment) this.Alignment = NewStyle.Alignment.Clone();
            if (NewStyle.HasProtection) this.Protection = NewStyle.Protection.Clone();
            if (NewStyle.HasNumberingFormat) this.FormatCode = NewStyle.FormatCode;

            if (NewStyle.HasFont)
            {
                // what's the point if there's no font name?
                this.fontReal.FontName = NewStyle.fontReal.FontName;

                if (NewStyle.fontReal.CharacterSet != null) this.fontReal.CharacterSet = NewStyle.fontReal.CharacterSet.Value;
                if (NewStyle.fontReal.FontFamily != null) this.fontReal.FontFamily = NewStyle.fontReal.FontFamily.Value;
                if (NewStyle.fontReal.Bold != null) this.fontReal.Bold = NewStyle.fontReal.Bold.Value;
                if (NewStyle.fontReal.Italic != null) this.fontReal.Italic = NewStyle.fontReal.Italic.Value;
                if (NewStyle.fontReal.Strike != null) this.fontReal.Strike = NewStyle.fontReal.Strike.Value;
                if (NewStyle.fontReal.Outline != null) this.fontReal.Outline = NewStyle.fontReal.Outline.Value;
                if (NewStyle.fontReal.Shadow != null) this.fontReal.Shadow = NewStyle.fontReal.Shadow.Value;
                if (NewStyle.fontReal.Condense != null) this.fontReal.Condense = NewStyle.fontReal.Condense.Value;
                if (NewStyle.fontReal.Extend != null) this.fontReal.Extend = NewStyle.fontReal.Extend.Value;
                if (NewStyle.fontReal.HasFontColor)
                {
                    this.fontReal.clrFontColor = NewStyle.fontReal.clrFontColor.Clone();
                    this.fontReal.HasFontColor = (this.fontReal.clrFontColor.Color.IsEmpty) ? false : true;
                }

                // no point if there's no font size either
                this.fontReal.FontSize = NewStyle.fontReal.FontSize;

                if (NewStyle.fontReal.HasUnderline) this.fontReal.Underline = NewStyle.fontReal.Underline;
                if (NewStyle.fontReal.HasVerticalAlignment) this.fontReal.VerticalAlignment = NewStyle.fontReal.VerticalAlignment;

                if (NewStyle.fontReal.HasFontScheme)
                {
                    this.fontReal.FontScheme = NewStyle.fontReal.FontScheme;
                }
                else
                {
                    this.fontReal.FontScheme = FontSchemeValues.None;
                    this.fontReal.HasFontScheme = false;
                }

                this.HasFont = true;
            }

            if (NewStyle.HasFill) this.Fill = NewStyle.Fill.Clone();

            if (NewStyle.HasBorder)
            {
                if (NewStyle.borderReal.HasLeftBorder) this.borderReal.LeftBorder = NewStyle.borderReal.LeftBorder.Clone();
                if (NewStyle.borderReal.HasRightBorder) this.borderReal.RightBorder = NewStyle.borderReal.RightBorder.Clone();
                if (NewStyle.borderReal.HasTopBorder) this.borderReal.TopBorder = NewStyle.borderReal.TopBorder.Clone();
                if (NewStyle.borderReal.HasBottomBorder) this.borderReal.BottomBorder = NewStyle.borderReal.BottomBorder.Clone();
                if (NewStyle.borderReal.HasDiagonalBorder) this.borderReal.DiagonalBorder = NewStyle.borderReal.DiagonalBorder.Clone();
                if (NewStyle.borderReal.HasVerticalBorder) this.borderReal.VerticalBorder = NewStyle.borderReal.VerticalBorder.Clone();
                if (NewStyle.borderReal.HasHorizontalBorder) this.borderReal.HorizontalBorder = NewStyle.borderReal.HorizontalBorder.Clone();
                this.borderReal.DiagonalUp = NewStyle.borderReal.DiagonalUp;
                this.borderReal.DiagonalDown = NewStyle.borderReal.DiagonalDown;
                this.borderReal.Outline = NewStyle.borderReal.Outline;

                this.HasBorder = true;
            }
        }