Esempio n. 1
0
File: Font.cs Progetto: ornoand/npoi
        public static CT_Fonts Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Fonts ctObj = new CT_Fonts();

            if (node.Attributes["w:hint"] != null)
            {
                ctObj.hint = (ST_Hint)Enum.Parse(typeof(ST_Hint), node.Attributes["w:hint"].Value);
            }
            ctObj.ascii    = XmlHelper.ReadString(node.Attributes["w:ascii"]);
            ctObj.hAnsi    = XmlHelper.ReadString(node.Attributes["w:hAnsi"]);
            ctObj.eastAsia = XmlHelper.ReadString(node.Attributes["w:eastAsia"]);
            ctObj.cs       = XmlHelper.ReadString(node.Attributes["w:cs"]);
            if (node.Attributes["w:asciiTheme"] != null)
            {
                ctObj.asciiTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:asciiTheme"].Value);
            }
            if (node.Attributes["w:hAnsiTheme"] != null)
            {
                ctObj.hAnsiTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:hAnsiTheme"].Value);
            }
            if (node.Attributes["w:eastAsiaTheme"] != null)
            {
                ctObj.eastAsiaTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:eastAsiaTheme"].Value);
            }
            if (node.Attributes["w:cstheme"] != null)
            {
                ctObj.cstheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:cstheme"].Value);
            }
            return(ctObj);
        }
Esempio n. 2
0
        /// <summary>
        /// Specifies the fonts which shall be used to display the text contents of
        /// this run.The default handling for fcr == null is to overwrite the
        /// ascii font char range with the given font family and also set all not
        /// specified font ranges
        /// </summary>
        /// <param name="fontFamily">fontFamily</param>
        /// <param name="fcr">FontCharRange or null for default handling</param>
        public void SetFontFamily(String fontFamily, FontCharRange fcr)
        {
            W.CT_RPr   pr    = run.IsSetRPr1() ? run.rPr1 : run.AddNewRPr1();
            W.CT_Fonts fonts = pr.IsSetRFonts() ? pr.rFonts : pr.AddNewRFonts();

            if (fcr == FontCharRange.None)
            {
                fonts.ascii = (fontFamily);
                if (!fonts.IsSetHAnsi())
                {
                    fonts.hAnsi = (fontFamily);
                }
                if (!fonts.IsSetCs())
                {
                    fonts.cs = (fontFamily);
                }
                if (!fonts.IsSetEastAsia())
                {
                    fonts.eastAsia = (fontFamily);
                }
            }
            else
            {
                switch (fcr)
                {
                case FontCharRange.Ascii:
                    fonts.ascii = (fontFamily);
                    break;

                case FontCharRange.CS:
                    fonts.cs = (fontFamily);
                    break;

                case FontCharRange.EastAsia:
                    fonts.eastAsia = (fontFamily);
                    break;

                case FontCharRange.HAnsi:
                    fonts.hAnsi = (fontFamily);
                    break;
                }
            }
        }
Esempio n. 3
0
        /**
         * Sets the default font on ctStyles DocDefaults parameter
         * @param fonts
         */
        public void SetDefaultFonts(CT_Fonts fonts)
        {
            CT_DocDefaults docDefaults = null;
            CT_RPr RunProps = null;

            // Just making sure we use the members that have already been defined
            if (ctStyles.IsSetDocDefaults())
            {
                docDefaults = ctStyles.docDefaults;
                if (docDefaults.IsSetRPrDefault())
                {
                    CT_RPrDefault RPrDefault = docDefaults.rPrDefault;
                    if (RPrDefault.IsSetRPr())
                    {
                        RunProps = RPrDefault.rPr;
                    }
                }
            }

            if (docDefaults == null)
                docDefaults = ctStyles.AddNewDocDefaults();
            if (RunProps == null)
                RunProps = docDefaults.AddNewRPrDefault().AddNewRPr();

            RunProps.rFonts = (fonts);
        }
Esempio n. 4
0
        public void TestLanguages()
        {
            XWPFDocument docOut = new XWPFDocument();
            XWPFStyles styles = docOut.CreateStyles();
            styles.SetEastAsia("Chinese");

            styles.SetSpellingLanguage("English");

            CT_Fonts def = new CT_Fonts();
            styles.SetDefaultFonts(def);
        }
Esempio n. 5
0
        /**
         * Sets the default font on ctStyles DocDefaults parameter
         * TODO Replace this with specific Setters for each type, possibly
         *  on XWPFDefaultRunStyle
         */
        public void SetDefaultFonts(CT_Fonts fonts)
        {
            EnsureDocDefaults();

            CT_RPr RunProps = defaultRunStyle.GetRPr();
            RunProps.rFonts = (/*setter*/fonts);
        }
Esempio n. 6
0
 public static CT_Fonts Parse(XmlNode node, XmlNamespaceManager namespaceManager)
 {
     if (node == null)
         return null;
     CT_Fonts ctObj = new CT_Fonts();
     ctObj.ascii = XmlHelper.ReadString(node.Attributes["w:ascii"]);
     ctObj.hAnsi = XmlHelper.ReadString(node.Attributes["w:hAnsi"]);
     ctObj.eastAsia = XmlHelper.ReadString(node.Attributes["w:eastAsia"]);
     ctObj.cs = XmlHelper.ReadString(node.Attributes["w:cs"]);
     if (node.Attributes["w:hint"] != null && node.Attributes["w:hint"].Value!="default")
         ctObj.hint = (ST_Hint)Enum.Parse(typeof(ST_Hint), node.Attributes["w:hint"].Value);
     if (node.Attributes["w:asciiTheme"] != null)
         ctObj.asciiTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:asciiTheme"].Value);
     if (node.Attributes["w:hAnsiTheme"] != null)
         ctObj.hAnsiTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:hAnsiTheme"].Value);
     if (node.Attributes["w:eastAsiaTheme"] != null)
         ctObj.eastAsiaTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:eastAsiaTheme"].Value);
     if (node.Attributes["w:cstheme"] != null)
         ctObj.cstheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:cstheme"].Value);
     return ctObj;
 }