Beispiel #1
0
        protected override void OnArrange()
        {
            base.OnArrange();

            PTS.FSFLOATERDETAILS floaterDetails;
            PTS.Validate(PTS.FsQueryFloaterDetails(PtsContext.Context, _paraHandle.Value, out floaterDetails));

            // Get paragraph's rectangle.
            _rect = floaterDetails.fsrcFloater;

            MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (ParentFlowDirection != PageFlowDirection)
            {
                mbp.MirrorMargin();

                PTS.FSRECT pageRect = _pageContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(PTS.FlowDirectionToFswdir(ParentFlowDirection), ref pageRect, ref _rect, PTS.FlowDirectionToFswdir(PageFlowDirection), out _rect));
            }

            _rect.u  += mbp.MarginLeft;
            _rect.du -= mbp.MarginLeft + mbp.MarginRight;
            _rect.du  = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du);
            _rect.dv  = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv);
        }
        protected override void OnArrange()
        {
            base.OnArrange();

            // Query paragraph details
            PTS.FSSUBTRACKDETAILS subtrackDetails;
            PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails));

            // Adjust rectangle and offset to take into account MBPs
            MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element);

            if (ParentFlowDirection != PageFlowDirection)
            {
                mbp.MirrorMargin();
            }

            _rect.u  += mbp.MarginLeft;
            _rect.du -= mbp.MarginLeft + mbp.MarginRight;

            _rect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du);
            _rect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv);

            uint fswdirSubtrack = PTS.FlowDirectionToFswdir(_flowDirection);

            // There is possibility to get empty track.
            if (subtrackDetails.cParas != 0)
            {
                // Get list of paragraphs
                PTS.FSPARADESCRIPTION [] arrayParaDesc;
                PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc);

                PtsHelper.ArrangeParaList(PtsContext, subtrackDetails.fsrc, arrayParaDesc, fswdirSubtrack);
            }
        }
        protected override void OnArrange()
        {
            base.OnArrange();
            PTS.FSFLOATERDETAILS fsfloaterdetails;
            PTS.Validate(PTS.FsQueryFloaterDetails(base.PtsContext.Context, this._paraHandle.Value, out fsfloaterdetails));
            this._rect = fsfloaterdetails.fsrcFloater;
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (base.ParentFlowDirection != base.PageFlowDirection)
            {
                mbpInfo.MirrorMargin();
                PTS.FSRECT pageRect = this._pageContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(PTS.FlowDirectionToFswdir(base.ParentFlowDirection), ref pageRect, ref this._rect, PTS.FlowDirectionToFswdir(base.PageFlowDirection), out this._rect));
            }
            this._rect.u  = this._rect.u + mbpInfo.MarginLeft;
            this._rect.du = this._rect.du - (mbpInfo.MarginLeft + mbpInfo.MarginRight);
            this._rect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.du);
            this._rect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.dv);
        }
Beispiel #4
0
        protected override void OnArrange()
        {
            base.OnArrange();
            PTS.FSSUBTRACKDETAILS fssubtrackdetails;
            PTS.Validate(PTS.FsQuerySubtrackDetails(base.PtsContext.Context, this._paraHandle.Value, out fssubtrackdetails));
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (base.ParentFlowDirection != base.PageFlowDirection)
            {
                mbpInfo.MirrorMargin();
            }
            this._rect.u  = this._rect.u + mbpInfo.MarginLeft;
            this._rect.du = this._rect.du - (mbpInfo.MarginLeft + mbpInfo.MarginRight);
            this._rect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.du);
            this._rect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.dv);
            uint fswdirTrack = PTS.FlowDirectionToFswdir(this._flowDirection);

            if (fssubtrackdetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION[] arrayParaDesc;
                PtsHelper.ParaListFromSubtrack(base.PtsContext, this._paraHandle.Value, ref fssubtrackdetails, out arrayParaDesc);
                PtsHelper.ArrangeParaList(base.PtsContext, fssubtrackdetails.fsrc, arrayParaDesc, fswdirTrack);
            }
        }
        internal unsafe void FormatParaFinite(SubpageParaClient paraClient, IntPtr pbrkrecIn, int fBRFromPreviousPage, IntPtr footnoteRejector, int fEmptyOk, int fSuppressTopSpace, uint fswdir, ref PTS.FSRECT fsrcToFill, MarginCollapsingState mcs, PTS.FSKCLEAR fskclearIn, PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn, out PTS.FSFMTR fsfmtr, out IntPtr pfspara, out IntPtr pbrkrecOut, out int dvrUsed, out PTS.FSBBOX fsbbox, out IntPtr pmcsclientOut, out PTS.FSKCLEAR fskclearOut, out int dvrTopSpace)
        {
            uint num = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));

            if (mcs != null && pbrkrecIn != IntPtr.Zero)
            {
                mcs = null;
            }
            PTS.FSRECT fsrect = default(PTS.FSRECT);
            int        num2   = fsrcToFill.du;
            int        num3   = fsrcToFill.dv;

            Invariant.Assert(base.Element is TableCell || base.Element is AnchoredBlock);
            fskclearIn = PTS.WrapDirectionToFskclear((WrapDirection)base.Element.GetValue(Block.ClearFloatersProperty));
            int num4 = 0;
            MarginCollapsingState marginCollapsingState = null;
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (num != fswdir)
            {
                PTS.FSRECT pageRect = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(fswdir, ref pageRect, ref fsrcToFill, num, out fsrcToFill));
                mbpInfo.MirrorMargin();
            }
            num2 = Math.Max(1, num2 - (mbpInfo.MBPLeft + mbpInfo.MBPRight));
            if (pbrkrecIn == IntPtr.Zero)
            {
                MarginCollapsingState.CollapseTopMargin(base.PtsContext, mbpInfo, mcs, out marginCollapsingState, out num4);
                if (PTS.ToBoolean(fSuppressTopSpace))
                {
                    num4 = 0;
                }
                num3 = Math.Max(1, num3 - (num4 + mbpInfo.BPTop));
                if (marginCollapsingState != null)
                {
                    marginCollapsingState.Dispose();
                    marginCollapsingState = null;
                }
            }
            fsrect.du = num2;
            fsrect.dv = num3;
            ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(this._element);
            double     lineHeightValue             = DynamicPropertyReader.GetLineHeightValue(this._element);
            double     pageFontSize   = (double)this._structuralCache.PropertyOwner.GetValue(TextElement.FontSizeProperty);
            FontFamily pageFontFamily = (FontFamily)this._structuralCache.PropertyOwner.GetValue(TextElement.FontFamilyProperty);
            int        num5           = PtsHelper.CalculateColumnCount(columnProperties, lineHeightValue, TextDpi.FromTextDpi(num2), pageFontSize, pageFontFamily, false);

            PTS.FSCOLUMNINFO[] array = new PTS.FSCOLUMNINFO[num5];
            fixed(PTS.FSCOLUMNINFO *ptr = array)
            {
                PtsHelper.GetColumnsInfo(columnProperties, lineHeightValue, TextDpi.FromTextDpi(num2), pageFontSize, pageFontFamily, num5, ptr, false);
            }

            base.StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(num2), TextDpi.FromTextDpi(num3)), default(Thickness), false, true);
            fixed(PTS.FSCOLUMNINFO *ptr2 = array)
            {
                PTS.Validate(PTS.FsCreateSubpageFinite(base.PtsContext.Context, pbrkrecIn, fBRFromPreviousPage, this._mainTextSegment.Handle, footnoteRejector, fEmptyOk, fSuppressTopSpace, fswdir, num2, num3, ref fsrect, num5, ptr2, 0, 0, null, null, 0, null, null, PTS.FromBoolean(false), fsksuppresshardbreakbeforefirstparaIn, out fsfmtr, out pfspara, out pbrkrecOut, out dvrUsed, out fsbbox, out pmcsclientOut, out dvrTopSpace), base.PtsContext);
            }

            base.StructuralCache.CurrentFormatContext.PopPageData();
            fskclearOut = PTS.FSKCLEAR.fskclearNone;
            if (PTS.ToBoolean(fsbbox.fDefined))
            {
                dvrUsed       = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
                fsrcToFill.du = Math.Max(fsrcToFill.du, fsbbox.fsrc.du + fsbbox.fsrc.u);
            }
            if (pbrkrecIn == IntPtr.Zero)
            {
                dvrTopSpace = ((mbpInfo.BPTop != 0) ? num4 : dvrTopSpace);
                dvrUsed    += num4 + mbpInfo.BPTop;
            }
            if (pmcsclientOut != IntPtr.Zero)
            {
                marginCollapsingState = (base.PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState);
                PTS.ValidateHandle(marginCollapsingState);
                pmcsclientOut = IntPtr.Zero;
            }
            if (fsfmtr.kstop >= PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace)
            {
                dvrUsed = (dvrTopSpace = 0);
            }
            else
            {
                if (fsfmtr.kstop == PTS.FSFMTRKSTOP.fmtrGoalReached)
                {
                    MarginCollapsingState marginCollapsingState2;
                    int num6;
                    MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbpInfo, marginCollapsingState, out marginCollapsingState2, out num6);
                    pmcsclientOut = ((marginCollapsingState2 != null) ? marginCollapsingState2.Handle : IntPtr.Zero);
                    if (pmcsclientOut == IntPtr.Zero)
                    {
                        dvrUsed += num6 + mbpInfo.BPBottom;
                    }
                }
                fsbbox.fsrc.u  = fsrcToFill.u + mbpInfo.MarginLeft;
                fsbbox.fsrc.v  = fsrcToFill.v + dvrTopSpace;
                fsbbox.fsrc.du = Math.Max(fsrcToFill.du - (mbpInfo.MarginLeft + mbpInfo.MarginRight), 0);
                fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
            }
            if (num != fswdir)
            {
                PTS.FSRECT pageRect2 = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(num, ref pageRect2, ref fsbbox, fswdir, out fsbbox));
            }
            if (marginCollapsingState != null)
            {
                marginCollapsingState.Dispose();
                marginCollapsingState = null;
            }
            paraClient.SetChunkInfo(pbrkrecIn == IntPtr.Zero, pbrkrecOut == IntPtr.Zero);
        }
        internal unsafe void UpdateBottomlessPara(IntPtr pfspara, SubpageParaClient paraClient, int fSuppressTopSpace, uint fswdir, int urTrack, int durTrack, int vrTrack, MarginCollapsingState mcs, PTS.FSKCLEAR fskclearIn, int fInterruptable, out PTS.FSFMTRBL fsfmtrbl, out int dvrUsed, out PTS.FSBBOX fsbbox, out IntPtr pmcsclientOut, out PTS.FSKCLEAR fskclearOut, out int dvrTopSpace, out int fPageBecomesUninterruptable)
        {
            uint num  = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));
            int  num2 = durTrack;
            int  urMargin;
            int  vrMargin = urMargin = 0;

            Invariant.Assert(base.Element is TableCell || base.Element is AnchoredBlock);
            fskclearIn = PTS.WrapDirectionToFskclear((WrapDirection)base.Element.GetValue(Block.ClearFloatersProperty));
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (num != fswdir)
            {
                PTS.FSRECT fsrect   = new PTS.FSRECT(urTrack, 0, durTrack, 0);
                PTS.FSRECT pageRect = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(fswdir, ref pageRect, ref fsrect, num, out fsrect));
                urTrack  = fsrect.u;
                durTrack = fsrect.du;
                mbpInfo.MirrorMargin();
            }
            num2 = Math.Max(1, num2 - (mbpInfo.MBPLeft + mbpInfo.MBPRight));
            MarginCollapsingState marginCollapsingState;
            int num3;

            MarginCollapsingState.CollapseTopMargin(base.PtsContext, mbpInfo, mcs, out marginCollapsingState, out num3);
            if (marginCollapsingState != null)
            {
                marginCollapsingState.Dispose();
                marginCollapsingState = null;
            }
            int durMargin = num2;
            ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(this._element);
            double     lineHeightValue             = DynamicPropertyReader.GetLineHeightValue(this._element);
            double     pageFontSize   = (double)this._structuralCache.PropertyOwner.GetValue(TextElement.FontSizeProperty);
            FontFamily pageFontFamily = (FontFamily)this._structuralCache.PropertyOwner.GetValue(TextElement.FontFamilyProperty);
            int        num4           = PtsHelper.CalculateColumnCount(columnProperties, lineHeightValue, TextDpi.FromTextDpi(num2), pageFontSize, pageFontFamily, false);

            PTS.FSCOLUMNINFO[] array = new PTS.FSCOLUMNINFO[num4];
            fixed(PTS.FSCOLUMNINFO *ptr = array)
            {
                PtsHelper.GetColumnsInfo(columnProperties, lineHeightValue, TextDpi.FromTextDpi(num2), pageFontSize, pageFontFamily, num4, ptr, false);
            }

            base.StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(num2), TextDpi.MaxWidth), default(Thickness), true, false);
            fixed(PTS.FSCOLUMNINFO *ptr2 = array)
            {
                PTS.Validate(PTS.FsUpdateBottomlessSubpage(base.PtsContext.Context, pfspara, this._mainTextSegment.Handle, fSuppressTopSpace, fswdir, num2, urMargin, durMargin, vrMargin, num4, ptr2, 0, null, null, 0, null, null, PTS.FromBoolean(true), out fsfmtrbl, out dvrUsed, out fsbbox, out pmcsclientOut, out dvrTopSpace, out fPageBecomesUninterruptable), base.PtsContext);
            }

            base.StructuralCache.CurrentFormatContext.PopPageData();
            fskclearOut = PTS.FSKCLEAR.fskclearNone;
            if (fsfmtrbl != PTS.FSFMTRBL.fmtrblCollision)
            {
                if (pmcsclientOut != IntPtr.Zero)
                {
                    marginCollapsingState = (base.PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState);
                    PTS.ValidateHandle(marginCollapsingState);
                    pmcsclientOut = IntPtr.Zero;
                }
                MarginCollapsingState marginCollapsingState2;
                int num5;
                MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbpInfo, marginCollapsingState, out marginCollapsingState2, out num5);
                pmcsclientOut = ((marginCollapsingState2 != null) ? marginCollapsingState2.Handle : IntPtr.Zero);
                if (marginCollapsingState != null)
                {
                    marginCollapsingState.Dispose();
                    marginCollapsingState = null;
                }
                if (PTS.ToBoolean(fsbbox.fDefined))
                {
                    dvrUsed  = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
                    durTrack = Math.Max(durTrack, fsbbox.fsrc.du + fsbbox.fsrc.u);
                }
                dvrTopSpace    = ((mbpInfo.BPTop != 0) ? num3 : dvrTopSpace);
                dvrUsed       += num3 + mbpInfo.BPTop + (num5 + mbpInfo.BPBottom);
                fsbbox.fsrc.u  = urTrack + mbpInfo.MarginLeft;
                fsbbox.fsrc.v  = vrTrack + dvrTopSpace;
                fsbbox.fsrc.du = Math.Max(durTrack - (mbpInfo.MarginLeft + mbpInfo.MarginRight), 0);
                fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
            }
            else
            {
                pfspara = IntPtr.Zero;
                dvrUsed = (dvrTopSpace = 0);
            }
            if (num != fswdir)
            {
                PTS.FSRECT pageRect2 = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(num, ref pageRect2, ref fsbbox, fswdir, out fsbbox));
            }
            paraClient.SetChunkInfo(true, true);
        }
        internal void UpdateBottomlessPara(IntPtr pfspara, ContainerParaClient paraClient, int iArea, IntPtr pfsgeom, int fSuppressTopSpace, uint fswdir, int urTrack, int durTrack, int vrTrack, MarginCollapsingState mcs, PTS.FSKCLEAR fskclearIn, int fInterruptable, out PTS.FSFMTRBL fsfmtrbl, out int dvrUsed, out PTS.FSBBOX fsbbox, out IntPtr pmcsclientOut, out PTS.FSKCLEAR fskclearOut, out int dvrTopSpace, out int fPageBecomesUninterruptable)
        {
            uint    num     = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);
            MarginCollapsingState marginCollapsingState;
            int num2;

            MarginCollapsingState.CollapseTopMargin(base.PtsContext, mbpInfo, mcs, out marginCollapsingState, out num2);
            if (PTS.ToBoolean(fSuppressTopSpace))
            {
                num2 = 0;
            }
            Invariant.Assert(base.Element is Block || base.Element is ListItem);
            fskclearIn = PTS.WrapDirectionToFskclear((WrapDirection)base.Element.GetValue(Block.ClearFloatersProperty));
            if (num != fswdir)
            {
                PTS.FSRECT fsrect   = new PTS.FSRECT(urTrack, 0, durTrack, 0);
                PTS.FSRECT pageRect = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(fswdir, ref pageRect, ref fsrect, num, out fsrect));
                urTrack  = fsrect.u;
                durTrack = fsrect.du;
                mbpInfo.MirrorMargin();
            }
            int num3 = 0;
            int ur   = Math.Max(Math.Min(urTrack + mbpInfo.MBPLeft, urTrack + durTrack - 1), urTrack);
            int dur  = Math.Max(durTrack - (mbpInfo.MBPLeft + mbpInfo.MBPRight), 0);
            int num4 = vrTrack + (num2 + mbpInfo.BPTop);

            try
            {
                PTS.Validate(PTS.FsUpdateBottomlessSubtrack(base.PtsContext.Context, pfspara, base.Handle, iArea, pfsgeom, fSuppressTopSpace, num, ur, dur, num4, (marginCollapsingState != null) ? marginCollapsingState.Handle : IntPtr.Zero, fskclearIn, fInterruptable, out fsfmtrbl, out dvrUsed, out fsbbox, out pmcsclientOut, out fskclearOut, out num3, out fPageBecomesUninterruptable), base.PtsContext);
            }
            finally
            {
                if (marginCollapsingState != null)
                {
                    marginCollapsingState.Dispose();
                    marginCollapsingState = null;
                }
            }
            if (fsfmtrbl != PTS.FSFMTRBL.fmtrblCollision)
            {
                if (pmcsclientOut != IntPtr.Zero)
                {
                    marginCollapsingState = (base.PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState);
                    PTS.ValidateHandle(marginCollapsingState);
                    pmcsclientOut = IntPtr.Zero;
                }
                MarginCollapsingState marginCollapsingState2;
                int num5;
                MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbpInfo, marginCollapsingState, out marginCollapsingState2, out num5);
                pmcsclientOut = ((marginCollapsingState2 != null) ? marginCollapsingState2.Handle : IntPtr.Zero);
                if (marginCollapsingState != null)
                {
                    marginCollapsingState.Dispose();
                    marginCollapsingState = null;
                }
                dvrTopSpace = ((mbpInfo.BPTop != 0) ? num2 : num3);
                dvrUsed    += num4 - vrTrack + num5 + mbpInfo.BPBottom;
            }
            else
            {
                pfspara     = IntPtr.Zero;
                dvrTopSpace = 0;
            }
            fsbbox.fsrc.u  = fsbbox.fsrc.u - mbpInfo.MBPLeft;
            fsbbox.fsrc.du = fsbbox.fsrc.du + (mbpInfo.MBPLeft + mbpInfo.MBPRight);
            if (num != fswdir)
            {
                PTS.FSRECT pageRect2 = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(num, ref pageRect2, ref fsbbox, fswdir, out fsbbox));
            }
            paraClient.SetChunkInfo(true, true);
        }
        internal void FormatParaFinite(ContainerParaClient paraClient, IntPtr pbrkrecIn, int fBRFromPreviousPage, int iArea, IntPtr footnoteRejector, IntPtr geometry, int fEmptyOk, int fSuppressTopSpace, uint fswdir, ref PTS.FSRECT fsrcToFill, MarginCollapsingState mcs, PTS.FSKCLEAR fskclearIn, PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn, out PTS.FSFMTR fsfmtr, out IntPtr pfspara, out IntPtr pbrkrecOut, out int dvrUsed, out PTS.FSBBOX fsbbox, out IntPtr pmcsclientOut, out PTS.FSKCLEAR fskclearOut, out int dvrTopSpace)
        {
            uint num = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));

            if (mcs != null && pbrkrecIn != IntPtr.Zero)
            {
                mcs = null;
            }
            int num2 = 0;
            int num3 = 0;
            MarginCollapsingState marginCollapsingState = null;

            Invariant.Assert(base.Element is Block || base.Element is ListItem);
            fskclearIn = PTS.WrapDirectionToFskclear((WrapDirection)base.Element.GetValue(Block.ClearFloatersProperty));
            PTS.FSRECT fsrect  = fsrcToFill;
            MbpInfo    mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (num != fswdir)
            {
                PTS.FSRECT pageRect = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(fswdir, ref pageRect, ref fsrect, num, out fsrect));
                PTS.Validate(PTS.FsTransformRectangle(fswdir, ref pageRect, ref fsrcToFill, num, out fsrcToFill));
                mbpInfo.MirrorMargin();
            }
            fsrect.u  += mbpInfo.MBPLeft;
            fsrect.du -= mbpInfo.MBPLeft + mbpInfo.MBPRight;
            fsrect.u   = Math.Max(Math.Min(fsrect.u, fsrcToFill.u + fsrcToFill.du - 1), fsrcToFill.u);
            fsrect.du  = Math.Max(fsrect.du, 0);
            if (pbrkrecIn == IntPtr.Zero)
            {
                MarginCollapsingState.CollapseTopMargin(base.PtsContext, mbpInfo, mcs, out marginCollapsingState, out num2);
                if (PTS.ToBoolean(fSuppressTopSpace))
                {
                    num2 = 0;
                }
                fsrect.v  += num2 + mbpInfo.BPTop;
                fsrect.dv -= num2 + mbpInfo.BPTop;
                fsrect.v   = Math.Max(Math.Min(fsrect.v, fsrcToFill.v + fsrcToFill.dv - 1), fsrcToFill.v);
                fsrect.dv  = Math.Max(fsrect.dv, 0);
            }
            int num4 = 0;

            try
            {
                PTS.Validate(PTS.FsFormatSubtrackFinite(base.PtsContext.Context, pbrkrecIn, fBRFromPreviousPage, base.Handle, iArea, footnoteRejector, geometry, fEmptyOk, fSuppressTopSpace, num, ref fsrect, (marginCollapsingState != null) ? marginCollapsingState.Handle : IntPtr.Zero, fskclearIn, fsksuppresshardbreakbeforefirstparaIn, out fsfmtr, out pfspara, out pbrkrecOut, out dvrUsed, out fsbbox, out pmcsclientOut, out fskclearOut, out num4), base.PtsContext);
            }
            finally
            {
                if (marginCollapsingState != null)
                {
                    marginCollapsingState.Dispose();
                    marginCollapsingState = null;
                }
                if (num4 > 1073741823)
                {
                    num4 = 0;
                }
            }
            dvrTopSpace = ((mbpInfo.BPTop != 0) ? num2 : num4);
            dvrUsed    += fsrect.v - fsrcToFill.v;
            if (fsfmtr.kstop >= PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace)
            {
                dvrUsed = 0;
            }
            if (pmcsclientOut != IntPtr.Zero)
            {
                marginCollapsingState = (base.PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState);
                PTS.ValidateHandle(marginCollapsingState);
                pmcsclientOut = IntPtr.Zero;
            }
            if (fsfmtr.kstop == PTS.FSFMTRKSTOP.fmtrGoalReached)
            {
                MarginCollapsingState marginCollapsingState2 = null;
                MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbpInfo, marginCollapsingState, out marginCollapsingState2, out num3);
                pmcsclientOut = ((marginCollapsingState2 != null) ? marginCollapsingState2.Handle : IntPtr.Zero);
                dvrUsed      += num3 + mbpInfo.BPBottom;
                dvrUsed       = Math.Min(fsrcToFill.dv, dvrUsed);
            }
            if (marginCollapsingState != null)
            {
                marginCollapsingState.Dispose();
                marginCollapsingState = null;
            }
            fsbbox.fsrc.u  = fsbbox.fsrc.u - mbpInfo.MBPLeft;
            fsbbox.fsrc.du = fsbbox.fsrc.du + (mbpInfo.MBPLeft + mbpInfo.MBPRight);
            if (num != fswdir)
            {
                PTS.FSRECT pageRect2 = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(num, ref pageRect2, ref fsbbox, fswdir, out fsbbox));
            }
            paraClient.SetChunkInfo(pbrkrecIn == IntPtr.Zero, pbrkrecOut == IntPtr.Zero);
        }