private List <Rect> GetRectanglesInPage(ContentElement e, int start, int length)
        {
            List <Rect> list = new List <Rect>();

            Invariant.Assert(!this.IsEmpty);
            PTS.FSPAGEDETAILS fspagedetails;
            PTS.Validate(PTS.FsQueryPageDetails(this.PtsContext.Context, this._ptsPage.Value, out fspagedetails));
            if (PTS.ToBoolean(fspagedetails.fSimple))
            {
                list = PtsHelper.GetRectanglesInTrack(this.PtsContext, e, start, length, ref fspagedetails.u.simple.trackdescr);
            }
            else
            {
                ErrorHandler.Assert(fspagedetails.u.complex.cFootnoteColumns == 0, ErrorHandler.NotSupportedFootnotes);
                if (fspagedetails.u.complex.cSections != 0)
                {
                    PTS.FSSECTIONDESCRIPTION[] array;
                    PtsHelper.SectionListFromPage(this.PtsContext, this._ptsPage.Value, ref fspagedetails, out array);
                    for (int i = 0; i < array.Length; i++)
                    {
                        list = this.GetRectanglesInSection(e, start, length, ref array[i]);
                        Invariant.Assert(list != null);
                        if (list.Count != 0)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    list = new List <Rect>();
                }
            }
            return(list);
        }
 internal void ArrangePage()
 {
     if (this.IsEmpty)
     {
         return;
     }
     this._section.UpdateSegmentLastFormatPositions();
     PTS.FSPAGEDETAILS fspagedetails;
     PTS.Validate(PTS.FsQueryPageDetails(this.PtsContext.Context, this._ptsPage.Value, out fspagedetails));
     if (PTS.ToBoolean(fspagedetails.fSimple))
     {
         this._section.StructuralCache.CurrentArrangeContext.PushNewPageData(this._pageContextOfThisPage, fspagedetails.u.simple.trackdescr.fsrc, this._finitePage);
         PtsHelper.ArrangeTrack(this.PtsContext, ref fspagedetails.u.simple.trackdescr, PTS.FlowDirectionToFswdir(this._section.StructuralCache.PageFlowDirection));
         this._section.StructuralCache.CurrentArrangeContext.PopPageData();
         return;
     }
     ErrorHandler.Assert(fspagedetails.u.complex.cFootnoteColumns == 0, ErrorHandler.NotSupportedFootnotes);
     if (fspagedetails.u.complex.cSections != 0)
     {
         PTS.FSSECTIONDESCRIPTION[] array;
         PtsHelper.SectionListFromPage(this.PtsContext, this._ptsPage.Value, ref fspagedetails, out array);
         for (int i = 0; i < array.Length; i++)
         {
             this.ArrangeSection(ref array[i]);
         }
     }
 }
        internal ReadOnlyCollection <ColumnResult> GetColumnResults(out bool hasTextContent)
        {
            Invariant.Assert(!this.IsDisposed);
            List <ColumnResult> list = new List <ColumnResult>(0);

            hasTextContent = false;
            if (!(this._ptsPage.PageHandle == IntPtr.Zero))
            {
                PTS.FSPAGEDETAILS fspagedetails;
                PTS.Validate(PTS.FsQueryPageDetails(this.StructuralCache.PtsContext.Context, this._ptsPage.PageHandle, out fspagedetails));
                if (PTS.ToBoolean(fspagedetails.fSimple))
                {
                    PTS.FSTRACKDETAILS fstrackdetails;
                    PTS.Validate(PTS.FsQueryTrackDetails(this.StructuralCache.PtsContext.Context, fspagedetails.u.simple.trackdescr.pfstrack, out fstrackdetails));
                    if (fstrackdetails.cParas > 0)
                    {
                        list = new List <ColumnResult>(1);
                        ColumnResult columnResult = new ColumnResult(this, ref fspagedetails.u.simple.trackdescr, default(Vector));
                        list.Add(columnResult);
                        if (columnResult.HasTextContent)
                        {
                            hasTextContent = true;
                        }
                    }
                }
                else if (fspagedetails.u.complex.cSections > 0)
                {
                    PTS.FSSECTIONDESCRIPTION[] array;
                    PtsHelper.SectionListFromPage(this.StructuralCache.PtsContext, this._ptsPage.PageHandle, ref fspagedetails, out array);
                    PTS.FSSECTIONDETAILS fssectiondetails;
                    PTS.Validate(PTS.FsQuerySectionDetails(this.StructuralCache.PtsContext.Context, array[0].pfssection, out fssectiondetails));
                    if (PTS.ToBoolean(fssectiondetails.fFootnotesAsPagenotes) && fssectiondetails.u.withpagenotes.cBasicColumns > 0)
                    {
                        PTS.FSTRACKDESCRIPTION[] array2;
                        PtsHelper.TrackListFromSection(this.StructuralCache.PtsContext, array[0].pfssection, ref fssectiondetails, out array2);
                        list = new List <ColumnResult>(fssectiondetails.u.withpagenotes.cBasicColumns);
                        foreach (PTS.FSTRACKDESCRIPTION fstrackdescription in array2)
                        {
                            if (fstrackdescription.pfstrack != IntPtr.Zero)
                            {
                                PTS.FSTRACKDETAILS fstrackdetails2;
                                PTS.Validate(PTS.FsQueryTrackDetails(this.StructuralCache.PtsContext.Context, fstrackdescription.pfstrack, out fstrackdetails2));
                                if (fstrackdetails2.cParas > 0)
                                {
                                    ColumnResult columnResult2 = new ColumnResult(this, ref fstrackdescription, default(Vector));
                                    list.Add(columnResult2);
                                    if (columnResult2.HasTextContent)
                                    {
                                        hasTextContent = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Invariant.Assert(list != null);
            return(new ReadOnlyCollection <ColumnResult>(list));
        }
        private IInputElement InputHitTestPage(PTS.FSPOINT pt)
        {
            IInputElement inputElement = null;

            if (this._pageContextOfThisPage.FloatingElementList != null)
            {
                int num = 0;
                while (num < this._pageContextOfThisPage.FloatingElementList.Count && inputElement == null)
                {
                    BaseParaClient baseParaClient = this._pageContextOfThisPage.FloatingElementList[num];
                    inputElement = baseParaClient.InputHitTest(pt);
                    num++;
                }
            }
            if (inputElement == null)
            {
                PTS.FSPAGEDETAILS fspagedetails;
                PTS.Validate(PTS.FsQueryPageDetails(this.PtsContext.Context, this._ptsPage.Value, out fspagedetails));
                if (PTS.ToBoolean(fspagedetails.fSimple))
                {
                    if (fspagedetails.u.simple.trackdescr.fsrc.Contains(pt))
                    {
                        inputElement = PtsHelper.InputHitTestTrack(this.PtsContext, pt, ref fspagedetails.u.simple.trackdescr);
                    }
                }
                else
                {
                    ErrorHandler.Assert(fspagedetails.u.complex.cFootnoteColumns == 0, ErrorHandler.NotSupportedFootnotes);
                    if (fspagedetails.u.complex.cSections != 0)
                    {
                        PTS.FSSECTIONDESCRIPTION[] array;
                        PtsHelper.SectionListFromPage(this.PtsContext, this._ptsPage.Value, ref fspagedetails, out array);
                        int num2 = 0;
                        while (num2 < array.Length && inputElement == null)
                        {
                            if (array[num2].fsrc.Contains(pt))
                            {
                                inputElement = this.InputHitTestSection(pt, ref array[num2]);
                            }
                            num2++;
                        }
                    }
                }
            }
            return(inputElement);
        }
 internal void UpdateViewport(ref PTS.FSRECT viewport)
 {
     if (!this.IsEmpty)
     {
         PTS.FSPAGEDETAILS fspagedetails;
         PTS.Validate(PTS.FsQueryPageDetails(this.PtsContext.Context, this._ptsPage.Value, out fspagedetails));
         if (PTS.ToBoolean(fspagedetails.fSimple))
         {
             PtsHelper.UpdateViewportTrack(this.PtsContext, ref fspagedetails.u.simple.trackdescr, ref viewport);
             return;
         }
         ErrorHandler.Assert(fspagedetails.u.complex.cFootnoteColumns == 0, ErrorHandler.NotSupportedFootnotes);
         if (fspagedetails.u.complex.cSections != 0)
         {
             PTS.FSSECTIONDESCRIPTION[] array;
             PtsHelper.SectionListFromPage(this.PtsContext, this._ptsPage.Value, ref fspagedetails, out array);
             for (int i = 0; i < array.Length; i++)
             {
                 this.UpdateViewportSection(ref array[i], ref viewport);
             }
         }
     }
 }
        private void UpdatePageVisuals(Size arrangeSize)
        {
            Invariant.Assert(!this.IsEmpty);
            PTS.FSPAGEDETAILS fspagedetails;
            PTS.Validate(PTS.FsQueryPageDetails(this.PtsContext.Context, this._ptsPage.Value, out fspagedetails));
            if (fspagedetails.fskupd == PTS.FSKUPDATE.fskupdNoChange)
            {
                return;
            }
            ErrorHandler.Assert(fspagedetails.fskupd != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid);
            if (this._visual.Children.Count != 2)
            {
                this._visual.Children.Clear();
                this._visual.Children.Add(new ContainerVisual());
                this._visual.Children.Add(new ContainerVisual());
            }
            ContainerVisual containerVisual = (ContainerVisual)this._visual.Children[0];
            ContainerVisual visual          = (ContainerVisual)this._visual.Children[1];

            if (PTS.ToBoolean(fspagedetails.fSimple))
            {
                PTS.FSKUPDATE fskupd = fspagedetails.u.simple.trackdescr.fsupdinf.fskupd;
                if (fskupd == PTS.FSKUPDATE.fskupdInherited)
                {
                    fskupd = fspagedetails.fskupd;
                }
                VisualCollection children = containerVisual.Children;
                if (fskupd == PTS.FSKUPDATE.fskupdNew)
                {
                    children.Clear();
                    children.Add(new ContainerVisual());
                }
                else if (children.Count == 1 && children[0] is SectionVisual)
                {
                    children.Clear();
                    children.Add(new ContainerVisual());
                }
                ContainerVisual containerVisual2 = (ContainerVisual)children[0];
                PtsHelper.UpdateTrackVisuals(this.PtsContext, containerVisual2.Children, fspagedetails.fskupd, ref fspagedetails.u.simple.trackdescr);
            }
            else
            {
                ErrorHandler.Assert(fspagedetails.u.complex.cFootnoteColumns == 0, ErrorHandler.NotSupportedFootnotes);
                bool flag = fspagedetails.u.complex.cSections == 0;
                if (!flag)
                {
                    PTS.FSSECTIONDESCRIPTION[] array;
                    PtsHelper.SectionListFromPage(this.PtsContext, this._ptsPage.Value, ref fspagedetails, out array);
                    flag = (array.Length == 0);
                    if (!flag)
                    {
                        ErrorHandler.Assert(array.Length == 1, ErrorHandler.NotSupportedMultiSection);
                        VisualCollection children = containerVisual.Children;
                        if (children.Count == 0)
                        {
                            children.Add(new SectionVisual());
                        }
                        else if (!(children[0] is SectionVisual))
                        {
                            children.Clear();
                            children.Add(new SectionVisual());
                        }
                        this.UpdateSectionVisuals((SectionVisual)children[0], fspagedetails.fskupd, ref array[0]);
                    }
                }
                if (flag)
                {
                    containerVisual.Children.Clear();
                }
            }
            PtsHelper.UpdateFloatingElementVisuals(visual, this._pageContextOfThisPage.FloatingElementList);
        }