Aspose.Words.Examples.CSharp.Loading_Saving.SectionSplitter.VisitSectionStart C# (CSharp) Метод

VisitSectionStart() публичный Метод

public VisitSectionStart ( Section section ) : VisitorAction
section Section
Результат VisitorAction
        public override VisitorAction VisitSectionStart(Section section)
        {
            mSectionCount++;
            Section previousSection = (Section)section.PreviousSibling;

            // If there is a previous section attempt to copy any linked header footers otherwise they will not appear in an 
            // Extracted document if the previous section is missing.
            if (previousSection != null)
            {
                if (!section.PageSetup.RestartPageNumbering)
                {
                    section.PageSetup.RestartPageNumbering = true;
                    section.PageSetup.PageStartingNumber = previousSection.PageSetup.PageStartingNumber + mPageNumberFinder.PageSpan(previousSection);
                }

                foreach (HeaderFooter previousHeaderFooter in previousSection.HeadersFooters)
                {
                    if (section.HeadersFooters[previousHeaderFooter.HeaderFooterType] == null)
                    {
                        HeaderFooter newHeaderFooter = (HeaderFooter)previousSection.HeadersFooters[previousHeaderFooter.HeaderFooterType].Clone(true);
                        section.HeadersFooters.Add(newHeaderFooter);
                    }
                }
            }

            // Manually set the result of these fields before sections are split.
            foreach (HeaderFooter headerFooter in section.HeadersFooters)
            {
                foreach (Field field in headerFooter.Range.Fields)
                {
                    if (field.Type == FieldType.FieldSection || field.Type == FieldType.FieldSectionPages)
                    {
                        field.Result = (field.Type == FieldType.FieldSection) ? mSectionCount.ToString() :
                            mPageNumberFinder.PageSpan(section).ToString();
                        field.IsLocked = true;
                    }
                }
            }

            // All fields in the body should stay the same, this also improves field update time.
            foreach (Field field in section.Body.Range.Fields)
                field.IsLocked = true;

            return VisitorAction.Continue;
        }