GetUnderlineStyle() static private méthode

static private GetUnderlineStyle ( string underlineStyle ) : UnderlineStyle
underlineStyle string
Résultat UnderlineStyle
Exemple #1
0
        public static Formatting Parse(XElement rPr)
        {
            Formatting formatting = new Formatting();

            // Build up the Formatting object.
            foreach (XElement option in rPr.Elements())
            {
                switch (option.Name.LocalName)
                {
                case "lang":
                    formatting.Language = new CultureInfo(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName), null) ??
                        option.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName), null) ??
                        option.GetAttribute(XName.Get("bidi", DocX.w.NamespaceName)));
                    break;

                case "spacing":
                    formatting.Spacing = Double.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 20.0;
                    break;

                case "position":
                    formatting.Position = Int32.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
                    break;

                case "kern":
                    formatting.Position = Int32.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
                    break;

                case "w":
                    formatting.PercentageScale = Int32.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName)));
                    break;

                case "rFonts":
                    formatting.FontFamily =
                        new FontFamily(
                            option.GetAttribute(XName.Get("cs", DocX.w.NamespaceName), null) ??
                            option.GetAttribute(XName.Get("ascii", DocX.w.NamespaceName), null) ??
                            option.GetAttribute(XName.Get("hAnsi", DocX.w.NamespaceName), null) ??
                            option.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName)));
                    break;

                case "vanish": formatting.hidden = true; break;

                case "b": formatting.Bold = true; break;

                case "i": formatting.Italic = true; break;

                case "u": formatting.UnderlineStyle = HelperFunctions.GetUnderlineStyle(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName)));
                    break;

                default: break;
                }
            }

            return(formatting);
        }
Exemple #2
0
        public static Formatting Parse(XElement rPr)
        {
            Formatting formatting = new Formatting();

            // Build up the Formatting object.
            foreach (XElement option in rPr.Elements())
            {
                switch (option.Name.LocalName)
                {
                case "lang":
                    formatting.Language = new CultureInfo(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName), null) ??
                        option.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName), null) ??
                        option.GetAttribute(XName.Get("bidi", DocX.w.NamespaceName)));
                    break;

                case "spacing":
                    formatting.Spacing = Double.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 20.0;
                    break;

                case "position":
                    formatting.Position = Int32.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
                    break;

                case "kern":
                    formatting.Position = Int32.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
                    break;

                case "w":
                    formatting.PercentageScale = Int32.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName)));
                    break;

                // <w:sz w:val="20"/><w:szCs w:val="20"/>
                case "sz":
                    formatting.Size = Int32.Parse(
                        option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
                    break;


                case "rFonts":
                    formatting.FontFamily =
                        new Font(
                            option.GetAttribute(XName.Get("cs", DocX.w.NamespaceName), null) ??
                            option.GetAttribute(XName.Get("ascii", DocX.w.NamespaceName), null) ??
                            option.GetAttribute(XName.Get("hAnsi", DocX.w.NamespaceName), null) ??
                            option.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName)));
                    break;

                case "color":
                    try
                    {
                        string color = option.GetAttribute(XName.Get("val", DocX.w.NamespaceName));
                        formatting.FontColor = System.Drawing.ColorTranslator.FromHtml(string.Format("#{0}", color));
                    }
                    catch { }
                    break;

                case "vanish": formatting.hidden = true; break;

                case "b": formatting.Bold = true; break;

                case "i": formatting.Italic = true; break;

                case "u": formatting.UnderlineStyle = HelperFunctions.GetUnderlineStyle(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))); break;

                case "vertAlign":
                    var script = option.GetAttribute(XName.Get("val", DocX.w.NamespaceName), null);
                    formatting.Script = (Script)Enum.Parse(typeof(Script), script);
                    break;

                default: break;
                }
            }


            return(formatting);
        }
Exemple #3
0
        public static Formatting Parse(XElement rPr)
        {
            Formatting formatting = new Formatting();

            foreach (XElement item in rPr.Elements())
            {
                switch (item.Name.LocalName)
                {
                case "lang":
                    formatting.Language = new CultureInfo(item.GetAttribute(XName.Get("val", DocX.w.NamespaceName), null) ?? item.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName), null) ?? item.GetAttribute(XName.Get("bidi", DocX.w.NamespaceName)));
                    break;

                case "spacing":
                    formatting.Spacing = double.Parse(item.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 20.0;
                    break;

                case "position":
                    formatting.Position = int.Parse(item.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
                    break;

                case "kern":
                    formatting.Position = int.Parse(item.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
                    break;

                case "w":
                    formatting.PercentageScale = int.Parse(item.GetAttribute(XName.Get("val", DocX.w.NamespaceName)));
                    break;

                case "sz":
                    formatting.Size = (double)(int.Parse(item.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2);
                    break;

                case "rFonts":
                    formatting.FontFamily = new Font(item.GetAttribute(XName.Get("cs", DocX.w.NamespaceName), null) ?? item.GetAttribute(XName.Get("ascii", DocX.w.NamespaceName), null) ?? item.GetAttribute(XName.Get("hAnsi", DocX.w.NamespaceName), null) ?? item.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName)));
                    break;

                case "color":
                    try
                    {
                        string attribute2 = item.GetAttribute(XName.Get("val", DocX.w.NamespaceName));
                        formatting.FontColor = ColorTranslator.FromHtml($"#{attribute2}");
                    }
                    catch
                    {
                    }
                    break;

                case "vanish":
                    formatting.hidden = true;
                    break;

                case "b":
                    formatting.Bold = true;
                    break;

                case "i":
                    formatting.Italic = true;
                    break;

                case "u":
                    formatting.UnderlineStyle = HelperFunctions.GetUnderlineStyle(item.GetAttribute(XName.Get("val", DocX.w.NamespaceName)));
                    break;

                case "vertAlign":
                {
                    string attribute = item.GetAttribute(XName.Get("val", DocX.w.NamespaceName), null);
                    formatting.Script = (Script)Enum.Parse(typeof(Script), attribute);
                    break;
                }
                }
            }
            return(formatting);
        }