Exemplo n.º 1
0
        private static Section CreateSection(
            this IReadOnlyCollection <OpenXml.OpenXmlCompositeElement> xmlElements,
            Word.SectionProperties wordSectionProperties,
            Pack.MainDocumentPart mainDocumentPart,
            HeaderFooterConfiguration headerFooterConfiguration,
            bool isFirst,
            IStyleFactory styleFactory)
        {
            var imageAccessor = new ImageAccessor(mainDocumentPart);

            var sectionProperties    = wordSectionProperties.CreateSectionProperties(mainDocumentPart, isFirst, headerFooterConfiguration);
            var columnsConfiguration = wordSectionProperties.CreateColumnsConfiguration(sectionProperties.PageConfiguration, sectionProperties.Margin);
            var sectionContents      = xmlElements.SplitToSectionContents(columnsConfiguration, imageAccessor, styleFactory);
            var sd = new Section(sectionProperties, sectionContents, imageAccessor, styleFactory);

            return(sd);
        }
Exemplo n.º 2
0
        private static HeaderFooterConfiguration GetHeaderFooterConfiguration(
            this Word.SectionProperties wordSectionProperties,
            Pack.MainDocumentPart mainDocument,
            HeaderFooterConfiguration previousHeaderFooterConfiguration)
        {
            var hasTitlePage = wordSectionProperties.ChildsOfType <Word.TitlePage>().SingleOrDefault()
                               .IsOn(ifOnOffTypeNull: false, ifOnOffValueNull: true);

            var headerRefs = wordSectionProperties
                             .ChildsOfType <Word.HeaderReference>()
                             .Select(fr => new HeaderFooterRef(fr.Id, fr.Type));

            var footerRefs = wordSectionProperties
                             .ChildsOfType <Word.FooterReference>()
                             .Select(fr => new HeaderFooterRef(fr.Id, fr.Type));

            return(previousHeaderFooterConfiguration.Inherited(mainDocument, hasTitlePage, headerRefs, footerRefs));
        }
Exemplo n.º 3
0
        private static SectionProperties CreateSectionProperties(
            this Word.SectionProperties wordSectionProperties,
            Pack.MainDocumentPart mainDocument,
            bool isFirstSection,
            HeaderFooterConfiguration inheritHeaderFooterConfiguration)
        {
            var pageCongifuration = wordSectionProperties.GetPageConfiguration();
            var pageMargin        = wordSectionProperties.GetPageMargin();

            var sectionMark = wordSectionProperties.ChildsOfType <Word.SectionType>().SingleOrDefault()?.Val ?? Word.SectionMarkValues.NextPage;

            var requiresNewPage = isFirstSection || sectionMark == Word.SectionMarkValues.NextPage;

            var headerFooterConfiguration = wordSectionProperties
                                            .GetHeaderFooterConfiguration(mainDocument, inheritHeaderFooterConfiguration);

            return(new SectionProperties(
                       pageCongifuration,
                       headerFooterConfiguration,
                       pageMargin,
                       requiresNewPage));
        }