예제 #1
0
        /// <summary>
        /// Generate styles from config json object
        /// </summary>
        /// <param name="styleDefinitionsPart1">Styles object</param>
        /// <param name="rules">Config json object</param>
        /// <param name="latent">If user need latent style</param>
        private static void GenerateStyleDefinitionsPartContent(StyleDefinitionsPart styleDefinitionsPart1, List <Rule> rules, bool latent)
        {
            Styles styles = new Styles()
            {
                MCAttributes = new MarkupCompatibilityAttributes()
            };

            DocDefaults docDefaults = new DocDefaults {
                RunPropertiesDefault = new RunPropertiesDefault {
                    RunPropertiesBaseStyle = new RunPropertiesBaseStyle {
                        RunFonts = new RunFonts {
                            Ascii = "Times New Roman", HighAnsi = "Times New Roman", EastAsia = "宋体", ComplexScript = "Times New Roman"
                        },
                        Kern = new Kern {
                            Val = 2U
                        },
                        Languages = new Languages {
                            Val = "en-US", EastAsia = "zh-CN", Bidi = "ar-SA"
                        },
                        FontSize = new FontSize {
                            Val = "24"
                        },
                        FontSizeComplexScript = new FontSizeComplexScript {
                            Val = "24"
                        }
                    }
                },
                ParagraphPropertiesDefault = new ParagraphPropertiesDefault()
            };

            styles.Append(docDefaults);

            if (latent)
            {
                styles.Append(GeneratedCode.GenerateLatentStyles());
            }

            StyleFactory styleFactory = new StyleFactory();
            var          result       = styleFactory.GenerateStyles(rules);

            foreach (Style style in result)
            {
                styles.Append(style);
            }

            styleDefinitionsPart1.Styles = styles;
        }