Пример #1
0
        /// <summary>
        /// Clone a new instance of SLFont with identical font settings.
        /// </summary>
        /// <returns>An SLFont object with identical font settings.</returns>
        public SLFont Clone()
        {
            SLFont font = new SLFont(this.MajorFont, this.MinorFont, this.listThemeColors, this.listIndexedColors);

            font.FontName             = this.FontName;
            font.CharacterSet         = this.CharacterSet;
            font.FontFamily           = this.FontFamily;
            font.Bold                 = this.Bold;
            font.Italic               = this.Italic;
            font.Strike               = this.Strike;
            font.Outline              = this.Outline;
            font.Shadow               = this.Shadow;
            font.Condense             = this.Condense;
            font.Extend               = this.Extend;
            font.clrFontColor         = this.clrFontColor.Clone();
            font.HasFontColor         = this.HasFontColor;
            font.FontSize             = this.FontSize;
            font.vUnderline           = this.vUnderline;
            font.HasUnderline         = this.HasUnderline;
            font.vVerticalAlignment   = this.vVerticalAlignment;
            font.HasVerticalAlignment = this.HasVerticalAlignment;
            font.vFontScheme          = this.vFontScheme;
            font.HasFontScheme        = this.HasFontScheme;

            return(font);
        }
Пример #2
0
        /// <summary>
        /// Append given text in the current theme's minor font and default font size.
        /// </summary>
        /// <param name="Text">The text.</param>
        public void AppendText(string Text)
        {
            SLFont font = new SLFont(this.MajorFont, this.MinorFont, this.listThemeColors, this.listIndexedColors);

            font.SetFont(FontSchemeValues.Minor, SLConstants.DefaultFontSize);

            this.AppendText(Text, font);
        }
Пример #3
0
        internal void FromDifferentialType(X14.DifferentialType dt)
        {
            this.SetAllNull();

            List <System.Drawing.Color> listempty = new List <System.Drawing.Color>();

            if (dt.Font != null)
            {
                HasFont       = true;
                this.fontReal = new SLFont(SLConstants.OfficeThemeMajorLatinFont, SLConstants.OfficeThemeMinorLatinFont, listempty, listempty);
                this.fontReal.FromFont(dt.Font);
            }

            if (dt.NumberingFormat != null)
            {
                HasNumberingFormat = true;
                this.nfFormatCode  = new SLNumberingFormat();
                this.nfFormatCode.FromNumberingFormat(dt.NumberingFormat);
            }

            if (dt.Fill != null)
            {
                HasFill       = true;
                this.fillReal = new SLFill(listempty, listempty);
                this.fillReal.FromFill(dt.Fill);
            }

            if (dt.Alignment != null)
            {
                HasAlignment   = true;
                this.alignReal = new SLAlignment();
                this.alignReal.FromAlignment(dt.Alignment);
            }

            if (dt.Border != null)
            {
                HasBorder       = true;
                this.borderReal = new SLBorder(listempty, listempty);
                this.borderReal.FromBorder(dt.Border);
            }

            if (dt.Protection != null)
            {
                HasProtection       = true;
                this.protectionReal = new SLProtection();
                this.protectionReal.FromProtection(dt.Protection);
            }

            Sync();
        }
Пример #4
0
        private void SetAllNull()
        {
            List <System.Drawing.Color> listempty = new List <System.Drawing.Color>();

            this.alignReal      = new SLAlignment();
            HasAlignment        = false;
            this.protectionReal = new SLProtection();
            HasProtection       = false;
            this.nfFormatCode   = new SLNumberingFormat();
            HasNumberingFormat  = false;
            this.fontReal       = new SLFont(SLConstants.OfficeThemeMajorLatinFont, SLConstants.OfficeThemeMinorLatinFont, listempty, listempty);
            HasFont             = false;
            this.fillReal       = new SLFill(listempty, listempty);
            HasFill             = false;
            this.borderReal     = new SLBorder(listempty, listempty);
            HasBorder           = false;
        }
Пример #5
0
        /// <summary>
        /// Append given text with a given font style.
        /// </summary>
        /// <param name="Text">The text.</param>
        /// <param name="TextFont">The font style.</param>
        public void AppendText(string Text, SLFont TextFont)
        {
            Run           run      = new Run();
            RunProperties runprops = new RunProperties();

            if (TextFont.FontName != null)
            {
                runprops.Append(new RunFont()
                {
                    Val = TextFont.FontName
                });
            }

            if (TextFont.CharacterSet != null)
            {
                runprops.Append(new RunPropertyCharSet()
                {
                    Val = TextFont.CharacterSet.Value
                });
            }

            if (TextFont.FontFamily != null)
            {
                runprops.Append(new FontFamily()
                {
                    Val = TextFont.FontFamily.Value
                });
            }

            if (TextFont.Bold != null)
            {
                runprops.Append(new Bold()
                {
                    Val = TextFont.Bold.Value
                });
            }

            if (TextFont.Italic != null)
            {
                runprops.Append(new Italic()
                {
                    Val = TextFont.Italic.Value
                });
            }

            if (TextFont.Strike != null)
            {
                runprops.Append(new Strike()
                {
                    Val = TextFont.Strike.Value
                });
            }

            if (TextFont.Outline != null)
            {
                runprops.Append(new Outline()
                {
                    Val = TextFont.Outline.Value
                });
            }

            if (TextFont.Shadow != null)
            {
                runprops.Append(new Shadow()
                {
                    Val = TextFont.Shadow.Value
                });
            }

            if (TextFont.Condense != null)
            {
                runprops.Append(new Condense()
                {
                    Val = TextFont.Condense.Value
                });
            }

            if (TextFont.Extend != null)
            {
                runprops.Append(new Extend()
                {
                    Val = TextFont.Extend.Value
                });
            }

            if (TextFont.HasFontColor)
            {
                runprops.Append(TextFont.clrFontColor.ToSpreadsheetColor());
            }

            if (TextFont.FontSize != null)
            {
                runprops.Append(new FontSize()
                {
                    Val = TextFont.FontSize.Value
                });
            }

            if (TextFont.HasUnderline)
            {
                runprops.Append(new Underline()
                {
                    Val = TextFont.Underline
                });
            }

            if (TextFont.HasVerticalAlignment)
            {
                runprops.Append(new VerticalTextAlignment()
                {
                    Val = TextFont.VerticalAlignment
                });
            }

            if (TextFont.HasFontScheme)
            {
                runprops.Append(new FontScheme()
                {
                    Val = TextFont.FontScheme
                });
            }

            if (runprops.ChildElements.Count > 0)
            {
                run.Append(runprops);
            }

            run.Text      = new Text();
            run.Text.Text = Text;
            if (SLTool.ToPreserveSpace(Text))
            {
                run.Text.Space = SpaceProcessingModeValues.Preserve;
            }

            bool           bFound = false;
            OpenXmlElement oxe    = istrReal.FirstChild;

            foreach (var child in this.istrReal.ChildElements)
            {
                if (child is Text || child is Run)
                {
                    oxe    = child;
                    bFound = true;
                }
            }

            if (bFound)
            {
                istrReal.InsertAfter(run, oxe);
            }
            else
            {
                istrReal.PrependChild(run);
            }
        }