Beispiel #1
0
        private static void SetFactories(StyleConverter result)
        {
            result.cssClassNameGenerator = new NameGenerator
            {
                Prefix = result.config.DynamicCssClassPrefix
            };
            var pClassFactory = new ParagraphClassFactory(
                result.cssClassNameGenerator,
                result.defaultsProvider,
                result.pStylePPropsCache,
                result.nStyleCPropsCache,
                result.cssPropsFactory
                );

            pClassFactory.Tag            = result.config.ContainerTag;
            result.ParagraphClassFactory = pClassFactory;
            result.RunClassFactory       = new RunClassFactory(
                result.cssClassNameGenerator,
                result.defaultsProvider,
                result.pStyleRPropsCache,
                result.nStyleNPropsCache,
                result.rStylePPropsCache,
                result.cssPropsFactory
                );
        }
Beispiel #2
0
 private static void SetDocumentParts(StyleConverter result, WordprocessingDocument wpDoc)
 {
     result.wpDoc     = wpDoc;
     result.styles    = wpDoc.MainDocumentPart.StyleDefinitionsPart?.Styles;
     result.theme     = wpDoc.MainDocumentPart.ThemePart?.Theme;
     result.numbering = wpDoc.MainDocumentPart.NumberingDefinitionsPart?.Numbering;
 }
Beispiel #3
0
        private static void SetCache(StyleConverter result)
        {
            var styleEnum = result.styles?.Elements <WStyle>() ?? new WStyle[0];

            result.pStylePPropsCache = new PStylePPropsCache(result.cssPropsFactory, styleEnum);
            result.pStyleRPropsCache = new PStyleRPropsCache(result.cssPropsFactory, styleEnum);
            result.rStylePPropsCache = new RStyleRPropsCache(result.cssPropsFactory, styleEnum);
            result.nStyleCPropsCache = new ContainerNumberingPropsCache(result.cssPropsFactory, result.numberingProvider);
            result.nStyleNPropsCache = new NumberNumberingPropsCache(result.cssPropsFactory, result.numberingProvider);
        }
Beispiel #4
0
        public static StyleConverter Build(WordprocessingDocument wpDoc, StyleConfig config)
        {
            var result = new StyleConverter();

            result.config = config;
            SetDocumentParts(result, wpDoc);
            SetProviders(result);
            SetCache(result);
            SetFactories(result);
            return(result);
        }
Beispiel #5
0
        private static void SetProviders(StyleConverter result)
        {
            result.themeColorsProvider = new ThemeColorsProvider(result.theme);
            result.themeFontProvider   = new ThemeFontsProvider(result.theme);
            result.numberingProvider   = new NumberingProvider(result.numbering, result.styles);
            result.defaultsProvider    = new DefaultsProvider(
                new Lazy <ICssPropertiesFactory>(() => result.cssPropsFactory),
                result.styles
                );

            result.cssPropsFactory = new CssPropertiesFactory(
                result.config,
                result.themeFontProvider,
                result.themeColorsProvider,
                result.numberingProvider,
                result.defaultsProvider
                );
        }