예제 #1
0
        // Token: 0x06006880 RID: 26752 RVA: 0x001D7A34 File Offset: 0x001D5C34
        private Rect GetBoundsFromPosition(int cp, int cch, out FlowDirection flowDirection)
        {
            double             num = TextDpi.FromTextDpi(this.CalculateUOffsetShift());
            IList <TextBounds> textBounds;

            if (this._line.HasOverflowed && this.TextParagraph.Properties.TextTrimming != TextTrimming.None)
            {
                Invariant.Assert(DoubleUtil.AreClose(num, 0.0));
                TextLine textLine = this._line.Collapse(new TextCollapsingProperties[]
                {
                    this.GetCollapsingProps(this._wrappingWidth, this.TextParagraph.Properties)
                });
                Invariant.Assert(textLine.HasCollapsed, "Line has not been collapsed");
                textBounds = textLine.GetTextBounds(cp, cch);
            }
            else
            {
                textBounds = this._line.GetTextBounds(cp, cch);
            }
            Invariant.Assert(textBounds != null && textBounds.Count == 1, "Expecting exactly one TextBounds for a single text position.");
            IList <TextRunBounds> textRunBounds = textBounds[0].TextRunBounds;
            Rect rectangle;

            if (textRunBounds != null)
            {
                rectangle = textRunBounds[0].Rectangle;
            }
            else
            {
                rectangle = textBounds[0].Rectangle;
            }
            flowDirection = textBounds[0].FlowDirection;
            rectangle.X  += num;
            return(rectangle);
        }
예제 #2
0
        internal override List <Rect> GetRectangles(ContentElement e, int start, int length)
        {
            List <Rect> list = new List <Rect>();

            if (base.Paragraph.Element as ContentElement == e)
            {
                this.GetRectanglesForParagraphElement(out list);
            }
            else
            {
                PTS.FSSUBPAGEDETAILS fssubpagedetails;
                PTS.Validate(PTS.FsQuerySubpageDetails(base.PtsContext.Context, this._paraHandle.Value, out fssubpagedetails));
                if (PTS.ToBoolean(fssubpagedetails.fSimple))
                {
                    list = PtsHelper.GetRectanglesInTrack(base.PtsContext, e, start, length, ref fssubpagedetails.u.simple.trackdescr);
                }
                else if (fssubpagedetails.u.complex.cBasicColumns != 0)
                {
                    PTS.FSTRACKDESCRIPTION[] array;
                    PtsHelper.TrackListFromSubpage(base.PtsContext, this._paraHandle.Value, ref fssubpagedetails, out array);
                    for (int i = 0; i < array.Length; i++)
                    {
                        List <Rect> rectanglesInTrack = PtsHelper.GetRectanglesInTrack(base.PtsContext, e, start, length, ref array[i]);
                        Invariant.Assert(rectanglesInTrack != null);
                        if (rectanglesInTrack.Count != 0)
                        {
                            list.AddRange(rectanglesInTrack);
                        }
                    }
                }
                list = PtsHelper.OffsetRectangleList(list, TextDpi.FromTextDpi(this.ContentRect.u), TextDpi.FromTextDpi(this.ContentRect.v));
            }
            Invariant.Assert(list != null);
            return(list);
        }
 private void OnAfterFormatPage(bool setSize, bool incremental)
 {
     if (setSize)
     {
         PTS.FSRECT rect        = this.GetRect();
         PTS.FSBBOX boundingBox = this.GetBoundingBox();
         if (!this.FinitePage && PTS.ToBoolean(boundingBox.fDefined))
         {
             rect.dv = Math.Max(rect.dv, boundingBox.fsrc.dv);
         }
         this._calculatedSize.Width  = Math.Max(TextDpi.MinWidth, TextDpi.FromTextDpi(rect.du));
         this._calculatedSize.Height = Math.Max(TextDpi.MinWidth, TextDpi.FromTextDpi(rect.dv));
         if (PTS.ToBoolean(boundingBox.fDefined))
         {
             this._contentSize.Width  = Math.Max(Math.Max(TextDpi.FromTextDpi(boundingBox.fsrc.du), TextDpi.MinWidth), this._calculatedSize.Width);
             this._contentSize.Height = Math.Max(TextDpi.MinWidth, TextDpi.FromTextDpi(boundingBox.fsrc.dv));
             if (!this.FinitePage)
             {
                 this._contentSize.Height = Math.Max(this._contentSize.Height, this._calculatedSize.Height);
             }
         }
         else
         {
             this._contentSize = this._calculatedSize;
         }
     }
     if (!this.IsEmpty && !incremental)
     {
         this.PtsContext.OnPageCreated(this._ptsPage);
     }
     if (this._section.StructuralCache != null)
     {
         this._section.StructuralCache.ClearUpdateInfo(false);
     }
 }
예제 #4
0
        // Token: 0x0600686A RID: 26730 RVA: 0x001D727C File Offset: 0x001D547C
        internal List <Rect> GetRangeBounds(int cp, int cch, double xOffset, double yOffset)
        {
            List <Rect>        list = new List <Rect>();
            double             num  = TextDpi.FromTextDpi(this.CalculateUOffsetShift());
            double             num2 = xOffset + num;
            IList <TextBounds> textBounds;

            if (this._line.HasOverflowed && this.TextParagraph.Properties.TextTrimming != TextTrimming.None)
            {
                Invariant.Assert(DoubleUtil.AreClose(num, 0.0));
                TextLine textLine = this._line.Collapse(new TextCollapsingProperties[]
                {
                    this.GetCollapsingProps(this._wrappingWidth, this.TextParagraph.Properties)
                });
                Invariant.Assert(textLine.HasCollapsed, "Line has not been collapsed");
                textBounds = textLine.GetTextBounds(cp, cch);
            }
            else
            {
                textBounds = this._line.GetTextBounds(cp, cch);
            }
            Invariant.Assert(textBounds.Count > 0);
            for (int i = 0; i < textBounds.Count; i++)
            {
                Rect rectangle = textBounds[i].Rectangle;
                rectangle.X += num2;
                rectangle.Y += yOffset;
                list.Add(rectangle);
            }
            return(list);
        }
예제 #5
0
        // Token: 0x0600676F RID: 26479 RVA: 0x001CECD4 File Offset: 0x001CCED4
        internal Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect)
        {
            Geometry geometry = null;

            if (endPosition.CompareTo(this.Cell.StaticElementEnd) >= 0)
            {
                geometry = new RectangleGeometry(this._rect.FromTextDpi());
            }
            else
            {
                SubpageParagraphResult            subpageParagraphResult = (SubpageParagraphResult)this.CreateParagraphResult();
                ReadOnlyCollection <ColumnResult> columns = subpageParagraphResult.Columns;
                Transform transform = new TranslateTransform(-TextDpi.FromTextDpi(base.ContentRect.u), -TextDpi.FromTextDpi(base.ContentRect.v));
                visibleRect = transform.TransformBounds(visibleRect);
                geometry    = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(columns[0].Paragraphs, subpageParagraphResult.FloatingElements, startPosition, endPosition, 0.0, visibleRect);
                if (geometry != null)
                {
                    Rect viewport = new Rect(0.0, 0.0, TextDpi.FromTextDpi(base.ContentRect.du), TextDpi.FromTextDpi(base.ContentRect.dv));
                    CaretElement.ClipGeometryByViewport(ref geometry, viewport);
                    transform = new TranslateTransform(TextDpi.FromTextDpi(base.ContentRect.u), TextDpi.FromTextDpi(base.ContentRect.v));
                    CaretElement.AddTransformToGeometry(geometry, transform);
                }
            }
            return(geometry);
        }
예제 #6
0
        //-------------------------------------------------------------------
        //
        // Private methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Format UIElement
        /// </summary>
        private void FormatUIElement(int durAvailable, out PTS.FSBBOX fsbbox)
        {
            MbpInfo mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);
            double  elementHeight;
            double  elementWidth = TextDpi.FromTextDpi(Math.Max(1, durAvailable - (mbp.MBPLeft + mbp.MBPRight)));

            if (SizeToFigureParent)
            {
                // Only child of a figure whose height is set. Size to figure's page height less figure's MBP and BlockUIContainer's MBP
                // NOTE: BlockUIContainer margins are always extracted before formatting, either from Figure height or page height
                if (StructuralCache.CurrentFormatContext.FinitePage)
                {
                    elementHeight = StructuralCache.CurrentFormatContext.PageHeight;
                }
                else
                {
                    Figure figure = (Figure)((BlockUIContainer)Element).Parent;
                    Invariant.Assert(figure.Height.IsAbsolute);
                    elementHeight = figure.Height.Value;
                }

                elementHeight = Math.Max(TextDpi.FromTextDpi(1), elementHeight - TextDpi.FromTextDpi(mbp.MBPTop + mbp.MBPBottom));
                UIElementIsland.DoLayout(new Size(elementWidth, elementHeight), false, false);

                // Create fsbbox. Set width to available width since we want block ui container to occupy the full column
                // and UIElement to be algined within it. Set dv to elementHeight.
                fsbbox.fsrc     = new PTS.FSRECT();
                fsbbox.fsrc.du  = durAvailable;
                fsbbox.fsrc.dv  = TextDpi.ToTextDpi(elementHeight) + mbp.BPTop + mbp.BPBottom;
                fsbbox.fDefined = PTS.True;
            }
            else
            {
                // Either BlockUIContainer is not the only child of a figure or the figure's height is unspecified.
                // In this case, size to height of strcutural cache's current page less page margins and container MBP.
                // This is consistent with figure's behavior on sizing to content

                // Always measure at infinity for bottomless, consistent constraint.
                if (StructuralCache.CurrentFormatContext.FinitePage)
                {
                    Thickness pageMargin = StructuralCache.CurrentFormatContext.DocumentPageMargin;
                    elementHeight = StructuralCache.CurrentFormatContext.DocumentPageSize.Height - pageMargin.Top - pageMargin.Bottom - TextDpi.FromTextDpi(mbp.MBPTop + mbp.MBPBottom);
                    elementHeight = Math.Max(TextDpi.FromTextDpi(1), elementHeight);
                }
                else
                {
                    elementHeight = Double.PositiveInfinity;
                }

                Size uiIslandSize = UIElementIsland.DoLayout(new Size(elementWidth, elementHeight), false, true);

                // Create fsbbox. Set width to available width since we want block ui container to occupy the full column
                // and UIElement to be algined within it
                fsbbox.fsrc     = new PTS.FSRECT();
                fsbbox.fsrc.du  = durAvailable;
                fsbbox.fsrc.dv  = TextDpi.ToTextDpi(uiIslandSize.Height) + mbp.BPTop + mbp.BPBottom;
                fsbbox.fDefined = PTS.True;
            }
        }
        private void UpdateSectionVisuals(SectionVisual visual, PTS.FSKUPDATE fskupdInherited, ref PTS.FSSECTIONDESCRIPTION sectionDesc)
        {
            PTS.FSKUPDATE fskupdate = sectionDesc.fsupdinf.fskupd;
            if (fskupdate == PTS.FSKUPDATE.fskupdInherited)
            {
                fskupdate = fskupdInherited;
            }
            ErrorHandler.Assert(fskupdate != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid);
            if (fskupdate == PTS.FSKUPDATE.fskupdNoChange)
            {
                return;
            }
            PTS.FSSECTIONDETAILS fssectiondetails;
            PTS.Validate(PTS.FsQuerySectionDetails(this.PtsContext.Context, sectionDesc.pfssection, out fssectiondetails));
            bool flag;

            if (PTS.ToBoolean(fssectiondetails.fFootnotesAsPagenotes))
            {
                ErrorHandler.Assert(fssectiondetails.u.withpagenotes.cEndnoteColumns == 0, ErrorHandler.NotSupportedFootnotes);
                flag = (fssectiondetails.u.withpagenotes.cBasicColumns == 0);
                if (!flag)
                {
                    PTS.FSTRACKDESCRIPTION[] array;
                    PtsHelper.TrackListFromSection(this.PtsContext, sectionDesc.pfssection, ref fssectiondetails, out array);
                    flag = (array.Length == 0);
                    if (!flag)
                    {
                        ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(this._section.Element);
                        visual.DrawColumnRules(ref array, TextDpi.FromTextDpi(sectionDesc.fsrc.v), TextDpi.FromTextDpi(sectionDesc.fsrc.dv), columnProperties);
                        VisualCollection children = visual.Children;
                        if (fskupdate == PTS.FSKUPDATE.fskupdNew)
                        {
                            children.Clear();
                            for (int i = 0; i < array.Length; i++)
                            {
                                children.Add(new ContainerVisual());
                            }
                        }
                        ErrorHandler.Assert(children.Count == array.Length, ErrorHandler.ColumnVisualCountMismatch);
                        for (int j = 0; j < array.Length; j++)
                        {
                            ContainerVisual containerVisual = (ContainerVisual)children[j];
                            PtsHelper.UpdateTrackVisuals(this.PtsContext, containerVisual.Children, fskupdate, ref array[j]);
                        }
                    }
                }
            }
            else
            {
                ErrorHandler.Assert(false, ErrorHandler.NotSupportedCompositeColumns);
                flag = true;
            }
            if (flag)
            {
                visual.Children.Clear();
            }
        }
예제 #8
0
 // Token: 0x06006866 RID: 26726 RVA: 0x001D6D10 File Offset: 0x001D4F10
 internal void Format(Line.FormattingContext ctx, int dcp, int width, int trackWidth, TextParagraphProperties lineProps, TextLineBreak textLineBreak)
 {
     this._formattingContext = ctx;
     this._dcp           = dcp;
     this._host.Context  = this;
     this._wrappingWidth = TextDpi.FromTextDpi(width);
     this._trackWidth    = TextDpi.FromTextDpi(trackWidth);
     this._mirror        = (lineProps.FlowDirection == FlowDirection.RightToLeft);
     this._indent        = lineProps.Indent;
     try
     {
         if (ctx.LineFormatLengthTarget == -1)
         {
             this._line = this._host.TextFormatter.FormatLine(this._host, dcp, this._wrappingWidth, lineProps, textLineBreak, ctx.TextRunCache);
         }
         else
         {
             this._line = this._host.TextFormatter.RecreateLine(this._host, dcp, ctx.LineFormatLengthTarget, this._wrappingWidth, lineProps, textLineBreak, ctx.TextRunCache);
         }
         this._runs = this._line.GetTextRunSpans();
         Invariant.Assert(this._runs != null, "Cannot retrieve runs collection.");
         if (this._formattingContext.MeasureMode)
         {
             List <InlineObject> list = new List <InlineObject>(1);
             int num = this._dcp;
             foreach (TextSpan <TextRun> textSpan in this._runs)
             {
                 TextRun value = textSpan.Value;
                 if (value is InlineObjectRun)
                 {
                     list.Add(new InlineObject(num, ((InlineObjectRun)value).UIElementIsland, (TextParagraph)this._paraClient.Paragraph));
                 }
                 else if (value is FloatingRun)
                 {
                     if (((FloatingRun)value).Figure)
                     {
                         this._hasFigures = true;
                     }
                     else
                     {
                         this._hasFloaters = true;
                     }
                 }
                 num += textSpan.Length;
             }
             if (list.Count == 0)
             {
                 list = null;
             }
             this.TextParagraph.SubmitInlineObjects(dcp, dcp + this.ActualLength, list);
         }
     }
     finally
     {
         this._host.Context = null;
     }
 }
예제 #9
0
        private unsafe void CreateSubpageBottomlessHelper(PtsContext ptsContext, IntPtr nSeg, int fSuppressTopSpace, uint fswdir, int lWidth, int urMargin, int durMargin, int vrMargin, int cColumns, PTS.FSCOLUMNINFO[] columnInfoCollection, out PTS.FSFMTRBL pfsfmtr, out IntPtr ppSubPage, out int pdvrUsed, out PTS.FSBBOX pfsBBox, out IntPtr pfsMcsClient, out int pTopSpace, out int fPageBecomesUninterruptible)
        {
            base.StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.MaxWidth), default(Thickness), false, false);
            fixed(PTS.FSCOLUMNINFO *ptr = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageBottomless(ptsContext.Context, nSeg, fSuppressTopSpace, fswdir, lWidth, urMargin, durMargin, vrMargin, cColumns, ptr, 0, null, null, 0, null, null, 0, out pfsfmtr, out ppSubPage, out pdvrUsed, out pfsBBox, out pfsMcsClient, out pTopSpace, out fPageBecomesUninterruptible), ptsContext);
            }

            base.StructuralCache.CurrentFormatContext.PopPageData();
        }
예제 #10
0
 /// <summary>
 /// SetCellHeight
 /// </summary>
 /// <param name="cellParaClient">Cell para client</param>
 /// <param name="tableParaClient">Table para client</param>
 /// <param name="subpageBreakRecord">Break record if cell is broken</param>
 /// <param name="fBrokenHere">Cell broken on this page/column</param>
 /// <param name="fswdirTable">Flow direction</param>
 /// <param name="dvrActual">Actual height</param>
 internal void SetCellHeight(
     CellParaClient cellParaClient,          // IN: cell object
     TableParaClient tableParaClient,        // table's para client
     IntPtr subpageBreakRecord,              // not NULL if cell broken from previous page/column
     int fBrokenHere,                        // TRUE if cell broken on this page/column: no reformatting
     uint fswdirTable,
     int dvrActual)
 {
     cellParaClient.ArrangeHeight = TextDpi.FromTextDpi(dvrActual);
 }
예제 #11
0
 internal ColumnResult(FlowDocumentPage page, ref PTS.FSTRACKDESCRIPTION trackDesc, Vector contentOffset)
 {
     this._page           = page;
     this._columnHandle   = trackDesc.pfstrack;
     this._layoutBox      = new Rect(TextDpi.FromTextDpi(trackDesc.fsrc.u), TextDpi.FromTextDpi(trackDesc.fsrc.v), TextDpi.FromTextDpi(trackDesc.fsrc.du), TextDpi.FromTextDpi(trackDesc.fsrc.dv));
     this._layoutBox.X    = this._layoutBox.X + contentOffset.X;
     this._layoutBox.Y    = this._layoutBox.Y + contentOffset.Y;
     this._columnOffset   = new Vector(TextDpi.FromTextDpi(trackDesc.fsrc.u), TextDpi.FromTextDpi(trackDesc.fsrc.v));
     this._hasTextContent = false;
 }
예제 #12
0
 internal ColumnResult(BaseParaClient subpage, ref PTS.FSTRACKDESCRIPTION trackDesc, Vector contentOffset)
 {
     Invariant.Assert(subpage is SubpageParaClient || subpage is FigureParaClient || subpage is FloaterParaClient);
     this._subpage      = subpage;
     this._columnHandle = trackDesc.pfstrack;
     this._layoutBox    = new Rect(TextDpi.FromTextDpi(trackDesc.fsrc.u), TextDpi.FromTextDpi(trackDesc.fsrc.v), TextDpi.FromTextDpi(trackDesc.fsrc.du), TextDpi.FromTextDpi(trackDesc.fsrc.dv));
     this._layoutBox.X  = this._layoutBox.X + contentOffset.X;
     this._layoutBox.Y  = this._layoutBox.Y + contentOffset.Y;
     this._columnOffset = new Vector(TextDpi.FromTextDpi(trackDesc.fsrc.u), TextDpi.FromTextDpi(trackDesc.fsrc.v));
 }
예제 #13
0
        // Token: 0x060068EA RID: 26858 RVA: 0x001D98EC File Offset: 0x001D7AEC
        internal Size MeasureChild(InlineObjectRun inlineObject)
        {
            double height = this._paraClient.Paragraph.StructuralCache.CurrentFormatContext.DocumentPageSize.Height;

            if (!this._paraClient.Paragraph.StructuralCache.CurrentFormatContext.FinitePage)
            {
                height = double.PositiveInfinity;
            }
            return(inlineObject.UIElementIsland.DoLayout(new Size(TextDpi.FromTextDpi(this._durTrack), height), true, true));
        }
        private unsafe void CreateSubpageFiniteHelper(PtsContext ptsContext, IntPtr brParaIn, int fFromPreviousPage, IntPtr nSeg, IntPtr pFtnRej, int fEmptyOk, int fSuppressTopSpace, uint fswdir, int lWidth, int lHeight, ref PTS.FSRECT rcMargin, int cColumns, PTS.FSCOLUMNINFO[] columnInfoCollection, int fApplyColumnBalancing, out PTS.FSFMTR fsfmtr, out IntPtr pSubPage, out IntPtr brParaOut, out int dvrUsed, out PTS.FSBBOX fsBBox, out IntPtr pfsMcsClient, out int topSpace)
        {
            base.StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.FromTextDpi(lHeight)), default(Thickness), false, true);
            fixed(PTS.FSCOLUMNINFO *ptr = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageFinite(ptsContext.Context, brParaIn, fFromPreviousPage, nSeg, pFtnRej, fEmptyOk, fSuppressTopSpace, fswdir, lWidth, lHeight, ref rcMargin, cColumns, ptr, 0, 0, null, null, 0, null, null, 0, PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA.fsksuppresshardbreakbeforefirstparaNone, out fsfmtr, out pSubPage, out brParaOut, out dvrUsed, out fsBBox, out pfsMcsClient, out topSpace), ptsContext);
            }

            base.StructuralCache.CurrentFormatContext.PopPageData();
        }
예제 #15
0
        internal override List <Rect> GetRectangles(ContentElement e, int start, int length)
        {
            List <Rect> rectangles = new List <Rect>();

            if (Paragraph.Element as ContentElement == e)
            {
                // We have found the element. Return rectangles for this paragraph.
                GetRectanglesForParagraphElement(out rectangles);
            }
            else
            {
                // Query subpage details
                PTS.FSSUBPAGEDETAILS subpageDetails;
                PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails));

                // Check subpage content for element. Subpage content may be simple or complex -
                // depending of set of features used in the content of the page.
                // (1) simple subpage (contains only one track)
                // (2) complex subpage (contains columns)
                if (PTS.ToBoolean(subpageDetails.fSimple))
                {
                    // (1) simple subpage (contains only one track)
                    rectangles = PtsHelper.GetRectanglesInTrack(PtsContext, e, start, length, ref subpageDetails.u.simple.trackdescr);
                }
                else
                {
                    // (2) complex page (contains columns)
                    // cBasicColumns == 0, means that subpage content is empty
                    if (subpageDetails.u.complex.cBasicColumns != 0)
                    {
                        // Retrieve description for each column.
                        PTS.FSTRACKDESCRIPTION[] arrayColumnDesc;
                        PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc);

                        // Arrange each track
                        for (int index = 0; index < arrayColumnDesc.Length; index++)
                        {
                            List <Rect> trackRectangles = PtsHelper.GetRectanglesInTrack(PtsContext, e, start, length, ref arrayColumnDesc[index]);
                            Invariant.Assert(trackRectangles != null);
                            if (trackRectangles.Count != 0)
                            {
                                // Add rectangles found in this track to all rectangles
                                rectangles.AddRange(trackRectangles);
                            }
                        }
                    }
                }

                rectangles = PtsHelper.OffsetRectangleList(rectangles, TextDpi.FromTextDpi(ContentRect.u), TextDpi.FromTextDpi(ContentRect.v));
            }

            Invariant.Assert(rectangles != null);
            return(rectangles);
        }
 // Token: 0x06006777 RID: 26487 RVA: 0x001CEE94 File Offset: 0x001CD094
 internal CellInfo(TableParaClient tpc, CellParaClient cpc)
 {
     this._rectTable    = new Rect(TextDpi.FromTextDpi(tpc.Rect.u), TextDpi.FromTextDpi(tpc.Rect.v), TextDpi.FromTextDpi(tpc.Rect.du), TextDpi.FromTextDpi(tpc.Rect.dv));
     this._rectCell     = new Rect(TextDpi.FromTextDpi(cpc.Rect.u), TextDpi.FromTextDpi(cpc.Rect.v), TextDpi.FromTextDpi(cpc.Rect.du), TextDpi.FromTextDpi(cpc.Rect.dv));
     this._autofitWidth = tpc.AutofitWidth;
     this._columnWidths = new double[tpc.CalculatedColumns.Length];
     for (int i = 0; i < tpc.CalculatedColumns.Length; i++)
     {
         this._columnWidths[i] = tpc.CalculatedColumns[i].DurWidth;
     }
     this._cell = cpc.Cell;
 }
예제 #17
0
        /// <summary>
        /// Measure child UIElement.
        /// </summary>
        /// <param name="inlineObject">
        /// Element whose size we are measuring
        /// </param>
        /// <returns>
        /// Size of the child UIElement
        /// </returns>
        internal Size MeasureChild(InlineObjectRun inlineObject)
        {
            // Always measure at infinity for bottomless, consistent constraint.
            double pageHeight = _paraClient.Paragraph.StructuralCache.CurrentFormatContext.DocumentPageSize.Height;

            if (!_paraClient.Paragraph.StructuralCache.CurrentFormatContext.FinitePage)
            {
                pageHeight = Double.PositiveInfinity;
            }

            return(inlineObject.UIElementIsland.DoLayout(new Size(TextDpi.FromTextDpi(_durTrack), pageHeight), true, true));
        }
예제 #18
0
 internal ColumnResult(BaseParaClient subpage, ref PTS.FSTRACKDESCRIPTION trackDesc, Vector contentOffset)
 {
     // Subpage must be figure, floater or subpage paraclient
     Invariant.Assert(subpage is SubpageParaClient || subpage is FigureParaClient || subpage is FloaterParaClient);
     _subpage      = subpage;
     _columnHandle = trackDesc.pfstrack;
     _layoutBox    = new Rect(
         TextDpi.FromTextDpi(trackDesc.fsrc.u), TextDpi.FromTextDpi(trackDesc.fsrc.v),
         TextDpi.FromTextDpi(trackDesc.fsrc.du), TextDpi.FromTextDpi(trackDesc.fsrc.dv));
     _layoutBox.X += contentOffset.X;
     _layoutBox.Y += contentOffset.Y;
     _columnOffset = new Vector(TextDpi.FromTextDpi(trackDesc.fsrc.u), TextDpi.FromTextDpi(trackDesc.fsrc.v));
 }
예제 #19
0
		// Token: 0x060068A0 RID: 26784 RVA: 0x001D8230 File Offset: 0x001D6430
		internal void FormatAndDrawVisual(DrawingContext ctx, LineProperties lineProps, int ur, int vrBaseline)
		{
			bool flag = lineProps.FlowDirection == FlowDirection.RightToLeft;
			this._host.Context = this;
			try
			{
				TextLine textLine = this._host.TextFormatter.FormatLine(this._host, 0, 0.0, lineProps.FirstLineProps, null, new TextRunCache());
				Point origin = new Point(TextDpi.FromTextDpi(ur), TextDpi.FromTextDpi(vrBaseline) - textLine.Baseline);
				textLine.Draw(ctx, origin, flag ? InvertAxes.Horizontal : InvertAxes.None);
				textLine.Dispose();
			}
			finally
			{
				this._host.Context = null;
			}
		}
예제 #20
0
        // Token: 0x0600686C RID: 26732 RVA: 0x001D739C File Offset: 0x001D559C
        internal CharacterHit GetTextPositionFromDistance(int urDistance)
        {
            int num = this.CalculateUOffsetShift();

            if (this._line.HasOverflowed && this.TextParagraph.Properties.TextTrimming != TextTrimming.None)
            {
                TextLine textLine = this._line.Collapse(new TextCollapsingProperties[]
                {
                    this.GetCollapsingProps(this._wrappingWidth, this.TextParagraph.Properties)
                });
                Invariant.Assert(num == 0);
                Invariant.Assert(textLine.HasCollapsed, "Line has not been collapsed");
                return(textLine.GetCharacterHitFromDistance(TextDpi.FromTextDpi(urDistance)));
            }
            return(this._line.GetCharacterHitFromDistance(TextDpi.FromTextDpi(urDistance - num)));
        }
        // Token: 0x06006815 RID: 26645 RVA: 0x001D4A00 File Offset: 0x001D2C00
        internal Geometry GetTightBoundingGeometryFromTextPositions(ReadOnlyCollection <ColumnResult> columns, ReadOnlyCollection <ParagraphResult> floatingElements, ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect)
        {
            Geometry result = null;

            Invariant.Assert(columns != null && columns.Count <= 1, "Columns collection is null.");
            Invariant.Assert(floatingElements != null, "Floating element collection is null.");
            ReadOnlyCollection <ParagraphResult> readOnlyCollection = (columns.Count > 0) ? columns[0].Paragraphs : new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0));

            if (readOnlyCollection.Count > 0 || floatingElements.Count > 0)
            {
                result = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(readOnlyCollection, floatingElements, startPosition, endPosition, TextDpi.FromTextDpi(this._dvrTopSpace), visibleRect);
                Rect viewport = new Rect(0.0, 0.0, TextDpi.FromTextDpi(this._contentRect.du), TextDpi.FromTextDpi(this._contentRect.dv));
                CaretElement.ClipGeometryByViewport(ref result, viewport);
            }
            return(result);
        }
예제 #22
0
        private unsafe void CreateSubpageFiniteHelper(
            PtsContext ptsContext,                   // IN:  ptr to FS context
            IntPtr brParaIn,                         // IN:  break record---use if !NULL
            int fFromPreviousPage,                   // IN:  break record was created on previous page
            IntPtr nSeg,                             // IN:  name of the segment to start from-if pointer to break rec is NULL
            IntPtr pFtnRej,                          // IN:  pftnrej
            int fEmptyOk,                            // IN:  fEmptyOK
            int fSuppressTopSpace,                   // IN:  fSuppressTopSpace
            uint fswdir,                             // IN:  fswdir
            int lWidth,                              // IN:  width of subpage
            int lHeight,                             // IN:  height of subpage
            ref PTS.FSRECT rcMargin,                 // IN:  rectangle within subpage margins
            int cColumns,                            // IN:  number of columns
            PTS.FSCOLUMNINFO[] columnInfoCollection, // IN:  array of column info
            int fApplyColumnBalancing,               // IN:  apply column balancing?
            PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn,
            // IN: suppress breaks at track start?
            out PTS.FSFMTR fsfmtr,              // OUT: why formatting was stopped
            out IntPtr pSubPage,                // OUT: ptr to the subpage
            out IntPtr brParaOut,               // OUT: break record of the subpage
            out int dvrUsed,                    // OUT: dvrUsed
            out PTS.FSBBOX fsBBox,              // OUT: subpage bbox
            out IntPtr pfsMcsClient,            // OUT: margin collapsing state at the bottom
            out int topSpace)                   // OUT: top space due to collapsed margins
        {
            // Exceptions don't need to pop, as the top level measure context will be nulled out if thrown.
            StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.FromTextDpi(lHeight)),
                                                                 new Thickness(),
                                                                 false,
                                                                 true);

            fixed(PTS.FSCOLUMNINFO *rgColumnInfo = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageFinite(ptsContext.Context, brParaIn, fFromPreviousPage, nSeg,
                                                       pFtnRej, fEmptyOk, fSuppressTopSpace, fswdir, lWidth, lHeight,
                                                       ref rcMargin, cColumns, rgColumnInfo, PTS.False,
                                                       0, null, null, 0, null, null, PTS.False,
                                                       fsksuppresshardbreakbeforefirstparaIn,
                                                       out fsfmtr, out pSubPage, out brParaOut, out dvrUsed, out fsBBox, out pfsMcsClient, out topSpace), ptsContext);
            }

            StructuralCache.CurrentFormatContext.PopPageData();
        }
        // Token: 0x06006B64 RID: 27492 RVA: 0x001F04C4 File Offset: 0x001EE6C4
        private void FormatUIElement(int durAvailable, out PTS.FSBBOX fsbbox)
        {
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);
            double  width   = TextDpi.FromTextDpi(Math.Max(1, durAvailable - (mbpInfo.MBPLeft + mbpInfo.MBPRight)));
            double  num;

            if (this.SizeToFigureParent)
            {
                if (base.StructuralCache.CurrentFormatContext.FinitePage)
                {
                    num = base.StructuralCache.CurrentFormatContext.PageHeight;
                }
                else
                {
                    Figure figure = (Figure)((BlockUIContainer)base.Element).Parent;
                    Invariant.Assert(figure.Height.IsAbsolute);
                    num = figure.Height.Value;
                }
                num = Math.Max(TextDpi.FromTextDpi(1), num - TextDpi.FromTextDpi(mbpInfo.MBPTop + mbpInfo.MBPBottom));
                this.UIElementIsland.DoLayout(new Size(width, num), false, false);
                fsbbox.fsrc     = default(PTS.FSRECT);
                fsbbox.fsrc.du  = durAvailable;
                fsbbox.fsrc.dv  = TextDpi.ToTextDpi(num) + mbpInfo.BPTop + mbpInfo.BPBottom;
                fsbbox.fDefined = 1;
                return;
            }
            if (base.StructuralCache.CurrentFormatContext.FinitePage)
            {
                Thickness documentPageMargin = base.StructuralCache.CurrentFormatContext.DocumentPageMargin;
                num = base.StructuralCache.CurrentFormatContext.DocumentPageSize.Height - documentPageMargin.Top - documentPageMargin.Bottom - TextDpi.FromTextDpi(mbpInfo.MBPTop + mbpInfo.MBPBottom);
                num = Math.Max(TextDpi.FromTextDpi(1), num);
            }
            else
            {
                num = double.PositiveInfinity;
            }
            Size size = this.UIElementIsland.DoLayout(new Size(width, num), false, true);

            fsbbox.fsrc     = default(PTS.FSRECT);
            fsbbox.fsrc.du  = durAvailable;
            fsbbox.fsrc.dv  = TextDpi.ToTextDpi(size.Height) + mbpInfo.BPTop + mbpInfo.BPBottom;
            fsbbox.fDefined = 1;
        }
예제 #24
0
        /// <summary>
        /// Returns tight bounding path geometry.
        /// </summary>
        internal Geometry GetTightBoundingGeometryFromTextPositions(ReadOnlyCollection <ColumnResult> columns, ReadOnlyCollection <ParagraphResult> floatingElements, ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect)
        {
            Geometry geometry = null;

            // Floater always has one column, so we can skip getting a column from the text position range
            Invariant.Assert(columns != null && columns.Count <= 1, "Columns collection is null.");
            Invariant.Assert(floatingElements != null, "Floating element collection is null.");
            ReadOnlyCollection <ParagraphResult> paragraphs = (columns.Count > 0) ? columns[0].Paragraphs : new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0));

            if (paragraphs.Count > 0 || floatingElements.Count > 0)
            {
                geometry = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(paragraphs, floatingElements, startPosition, endPosition, TextDpi.FromTextDpi(_dvrTopSpace), visibleRect);

                //  restrict geometry to the floater's content rect boundary.
                //  because of end-of-line / end-of-para simulation calculated geometry could be larger.
                Rect viewport = new Rect(0, 0, TextDpi.FromTextDpi(_contentRect.du), TextDpi.FromTextDpi(_contentRect.dv));
                CaretElement.ClipGeometryByViewport(ref geometry, viewport);
            }
            return(geometry);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="startPosition"></param>
        /// <param name="endPosition"></param>
        /// <param name="visibleRect"></param>
        /// <returns></returns>
        internal Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect)
        {
            Geometry geometry = null;

            // Find out if cell is selected. We consider cell selected if its end tag is crossed by selection.
            // The asymmetry is important here - it allows to use only normalized positions
            // and still be able to select individual cells.
            // Note that this logic is an assumption in textselection unit expansion mechanism
            // (TexSelection.ExtendSelectionToStructuralUnit method).
            if (endPosition.CompareTo(Cell.StaticElementEnd) >= 0)
            {
                geometry = new RectangleGeometry(_rect.FromTextDpi());
            }
            else
            {
                SubpageParagraphResult            paragraphResult = (SubpageParagraphResult)(CreateParagraphResult());
                ReadOnlyCollection <ColumnResult> colResults      = paragraphResult.Columns;
                Transform transform;

                transform   = new TranslateTransform(-TextDpi.FromTextDpi(ContentRect.u), -TextDpi.FromTextDpi(ContentRect.v));
                visibleRect = transform.TransformBounds(visibleRect);
                transform   = null;

                geometry = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(colResults[0].Paragraphs, paragraphResult.FloatingElements, startPosition, endPosition, 0.0, visibleRect);

                if (geometry != null)
                {
                    //  restrict geometry to the cell's content rect boundary.
                    //  because of end-of-line / end-of-para simulation calculated geometry could be larger.
                    Rect viewport = new Rect(0, 0, TextDpi.FromTextDpi(ContentRect.du), TextDpi.FromTextDpi(ContentRect.dv));
                    CaretElement.ClipGeometryByViewport(ref geometry, viewport);

                    transform = new TranslateTransform(TextDpi.FromTextDpi(ContentRect.u), TextDpi.FromTextDpi(ContentRect.v));
                    CaretElement.AddTransformToGeometry(geometry, transform);
                }
            }

            return(geometry);
        }
예제 #26
0
        /// <summary>
        /// Create and format text line.
        /// </summary>
        /// <param name="ctx">
        /// DrawingContext for text line.
        /// </param>
        /// <param name="lineProps">
        /// LineProperties of text line
        /// </param>
        /// <param name="ur">
        /// Horizontal draw location
        /// </param>
        /// <param name="vrBaseline">
        /// Vertical baseline draw location
        /// </param>
        internal void FormatAndDrawVisual(DrawingContext ctx, LineProperties lineProps, int ur, int vrBaseline)
        {
            System.Windows.Media.TextFormatting.TextLine line;
            bool mirror = (lineProps.FlowDirection == FlowDirection.RightToLeft);

            _host.Context = this;

            try
            {
                // Create line object
                line = _host.TextFormatter.FormatLine(_host, 0, 0, lineProps.FirstLineProps, null, new TextRunCache());

                Point drawLocation = new Point(TextDpi.FromTextDpi(ur), TextDpi.FromTextDpi(vrBaseline) - line.Baseline);

                line.Draw(ctx, drawLocation, (mirror ? InvertAxes.Horizontal : InvertAxes.None));
                line.Dispose();
            }
            finally
            {
                // clear the context
                _host.Context = null;
            }
        }
        /// <summary>
        /// C'tor - Just needs the table and cell para clients.
        /// </summary>
        /// <param name="tpc">Table para client.</param>
        /// <param name="cpc">Cell Para client.</param>
        internal CellInfo(TableParaClient tpc, CellParaClient cpc)
        {
            _rectTable = new Rect(TextDpi.FromTextDpi(tpc.Rect.u),
                                  TextDpi.FromTextDpi(tpc.Rect.v),
                                  TextDpi.FromTextDpi(tpc.Rect.du),
                                  TextDpi.FromTextDpi(tpc.Rect.dv));

            _rectCell = new Rect(TextDpi.FromTextDpi(cpc.Rect.u),
                                 TextDpi.FromTextDpi(cpc.Rect.v),
                                 TextDpi.FromTextDpi(cpc.Rect.du),
                                 TextDpi.FromTextDpi(cpc.Rect.dv));

            _autofitWidth = tpc.AutofitWidth;

            _columnWidths = new double[tpc.CalculatedColumns.Length];

            for (int index = 0; index < tpc.CalculatedColumns.Length; index++)
            {
                _columnWidths[index] = tpc.CalculatedColumns[index].DurWidth;
            }

            _cell = cpc.Cell;
        }
예제 #28
0
        // Token: 0x0600686D RID: 26733 RVA: 0x001D7434 File Offset: 0x001D5634
        internal IInputElement InputHitTest(int urOffset)
        {
            DependencyObject dependencyObject = null;
            int          num = this.CalculateUOffsetShift();
            CharacterHit characterHitFromDistance;

            if (this._line.HasOverflowed && this.TextParagraph.Properties.TextTrimming != TextTrimming.None)
            {
                Invariant.Assert(num == 0);
                TextLine textLine = this._line.Collapse(new TextCollapsingProperties[]
                {
                    this.GetCollapsingProps(this._wrappingWidth, this.TextParagraph.Properties)
                });
                Invariant.Assert(textLine.HasCollapsed, "Line has not been collapsed");
                characterHitFromDistance = textLine.GetCharacterHitFromDistance(TextDpi.FromTextDpi(urOffset));
            }
            else
            {
                characterHitFromDistance = this._line.GetCharacterHitFromDistance(TextDpi.FromTextDpi(urOffset - num));
            }
            int         cp          = this._paraClient.Paragraph.ParagraphStartCharacterPosition + characterHitFromDistance.FirstCharacterIndex + characterHitFromDistance.TrailingLength;
            TextPointer textPointer = TextContainerHelper.GetTextPointerFromCP(this._paraClient.Paragraph.StructuralCache.TextContainer, cp, LogicalDirection.Forward) as TextPointer;

            if (textPointer != null)
            {
                TextPointerContext pointerContext = textPointer.GetPointerContext((characterHitFromDistance.TrailingLength == 0) ? LogicalDirection.Forward : LogicalDirection.Backward);
                if (pointerContext == TextPointerContext.Text || pointerContext == TextPointerContext.ElementEnd)
                {
                    dependencyObject = textPointer.Parent;
                }
                else if (pointerContext == TextPointerContext.ElementStart)
                {
                    dependencyObject = textPointer.GetAdjacentElementFromOuterPosition(LogicalDirection.Forward);
                }
            }
            return(dependencyObject as IInputElement);
        }
예제 #29
0
        private unsafe void CreateSubpageBottomlessHelper(
            PtsContext ptsContext,                   // IN:  ptr to FS context
            IntPtr nSeg,                             // IN:  name of the segment to start from
            int fSuppressTopSpace,                   // IN:  suppress top space?
            uint fswdir,                             // IN:  fswdir
            int lWidth,                              // IN:  width of subpage
            int urMargin,                            // IN:  ur of margin
            int durMargin,                           // IN:  dur of margin
            int vrMargin,                            // IN:  vr of margin
            int cColumns,                            // IN:  number of columns
            PTS.FSCOLUMNINFO[] columnInfoCollection, // IN:  array of column info
            out PTS.FSFMTRBL pfsfmtr,                // OUT: why formatting was stopped
            out IntPtr ppSubPage,                    // OUT: ptr to the subpage
            out int pdvrUsed,                        // OUT: dvrUsed
            out PTS.FSBBOX pfsBBox,                  // OUT: subpage bbox
            out IntPtr pfsMcsClient,                 // OUT: margin collapsing state at the bottom
            out int pTopSpace,                       // OUT: top space due to collapsed margins
            out int fPageBecomesUninterruptible)     // OUT: interruption is prohibited from now on
        {
            // Exceptions don't need to pop, as the top level measure context will be nulled out if thrown.
            StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.MaxWidth),
                                                                 new Thickness(),
                                                                 false,
                                                                 false);

            fixed(PTS.FSCOLUMNINFO *rgColumnInfo = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageBottomless(ptsContext.Context, nSeg, fSuppressTopSpace,
                                                           fswdir, lWidth, urMargin, durMargin, vrMargin,
                                                           cColumns, rgColumnInfo, 0, null, null, 0, null, null, PTS.False,
                                                           out pfsfmtr, out ppSubPage, out pdvrUsed, out pfsBBox, out pfsMcsClient,
                                                           out pTopSpace, out fPageBecomesUninterruptible), ptsContext);
            }

            StructuralCache.CurrentFormatContext.PopPageData();
        }
예제 #30
0
        internal override void FormatFloaterContentBottomless(
            FloaterBaseParaClient paraClient,   // IN:
            int fSuppressTopSpace,              // IN:  suppress empty space at the top of the page
            uint fswdir,                        // IN:  direction of track
            int fAtMaxWidth,                    // IN:  formating is at full width of column
            int durAvailable,                   // IN:  width of available space
            int dvrAvailable,                   // IN:  height of available space
            out PTS.FSFMTRBL fsfmtrbl,          // OUT: result of formatting
            out IntPtr pfsFloatContent,         // OUT: opaque for PTS pointer pointer to formatted content
            out int durFloaterWidth,            // OUT: floater width
            out int dvrFloaterHeight,           // OUT: floater height
            out PTS.FSBBOX fsbbox,              // OUT: floater bbox
            out int cPolygons,                  // OUT: number of polygons
            out int cVertices)                  // OUT: total number of vertices in all polygons
        {
            uint fswdirPara = PTS.FlowDirectionToFswdir(((FlowDirection)Element.GetValue(FrameworkElement.FlowDirectionProperty)));

            Invariant.Assert(paraClient is FloaterParaClient);

            int subpageWidth, urSubpageMargin, durSubpageMargin, vrSubpageMargin;
            int dvrTopSpace, fPageBecomesUninterruptable;
            int cColumns;

            PTS.FSCOLUMNINFO[] columnInfoCollection;
            IntPtr             pmcsclientOut;
            MbpInfo            mbp;
            double             specifiedWidth;

            // If horizontal alignment is Stretch and we are not formatting at max width,
            // we cannot proceed.
            if (IsFloaterRejected(PTS.ToBoolean(fAtMaxWidth), TextDpi.FromTextDpi(durAvailable)))
            {
                // Set foater width, height to be greater than available values to signal to PTS that floater does not fit in the space
                durFloaterWidth  = durAvailable + 1;
                dvrFloaterHeight = dvrAvailable + 1;
                cPolygons        = cVertices = 0;
                fsfmtrbl         = PTS.FSFMTRBL.fmtrblInterrupted;
                fsbbox           = new PTS.FSBBOX();
                fsbbox.fDefined  = PTS.False;
                pfsFloatContent  = IntPtr.Zero;
            }
            else
            {
                // Initialize the subpage size. PTS subpage margin is always set to 0 for Floaters.
                // If width on floater is specified, use the specified value.
                // Margin, border and padding of the floater is extracted from available subpage width.
                mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);

                specifiedWidth = CalculateWidth(TextDpi.FromTextDpi(durAvailable));
                AdjustDurAvailable(specifiedWidth, ref durAvailable, out subpageWidth);
                durSubpageMargin = subpageWidth;
                urSubpageMargin  = vrSubpageMargin = 0;

                // Initialize column info. Floater always has just 1 column.
                cColumns             = 1;
                columnInfoCollection = new PTS.FSCOLUMNINFO[cColumns];
                columnInfoCollection[0].durBefore = 0;
                columnInfoCollection[0].durWidth  = subpageWidth;

                // Create subpage
                InvalidateMainTextSegment();
                CreateSubpageBottomlessHelper(PtsContext, _mainTextSegment.Handle, PTS.True,
                                              fswdir, subpageWidth, urSubpageMargin, durSubpageMargin, vrSubpageMargin,
                                              cColumns, columnInfoCollection,
                                              out fsfmtrbl, out pfsFloatContent, out dvrFloaterHeight, out fsbbox, out pmcsclientOut,
                                              out dvrTopSpace, out fPageBecomesUninterruptable);

                if (fsfmtrbl != PTS.FSFMTRBL.fmtrblCollision)
                {
                    // PTS subpage does not support autosizing, but Floater needs to autosize to its
                    // content. To workaround this problem, second format of subpage is performed, if
                    // necessary. It means that if the width of bounding box is smaller than subpage's
                    // width, second formatting is performed.
                    // However, if HorizontalAlignment is set to Stretch we should not reformat because
                    // floater should be at full column width
                    if (PTS.ToBoolean(fsbbox.fDefined))
                    {
                        if (fsbbox.fsrc.du < subpageWidth && Double.IsNaN(specifiedWidth) && HorizontalAlignment != HorizontalAlignment.Stretch)
                        {
                            // There is a need to reformat PTS subpage, so destroy any resourcces allocated by PTS
                            // during previous formatting.
                            if (pfsFloatContent != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpage(PtsContext.Context, pfsFloatContent), PtsContext);
                            }
                            if (pmcsclientOut != IntPtr.Zero)
                            {
                                MarginCollapsingState mcs = PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState;
                                PTS.ValidateHandle(mcs);
                                mcs.Dispose();
                                pmcsclientOut = IntPtr.Zero;
                            }
                            // Create subpage with new width.
                            subpageWidth = durSubpageMargin = fsbbox.fsrc.du + 1; // add 1/300px to avoid rounding errors
                            columnInfoCollection[0].durWidth = subpageWidth;
                            CreateSubpageBottomlessHelper(PtsContext, _mainTextSegment.Handle, PTS.True,
                                                          fswdir, subpageWidth, urSubpageMargin, durSubpageMargin, vrSubpageMargin,
                                                          cColumns, columnInfoCollection,
                                                          out fsfmtrbl, out pfsFloatContent, out dvrFloaterHeight, out fsbbox, out pmcsclientOut,
                                                          out dvrTopSpace, out fPageBecomesUninterruptable);
                        }
                    }
                    else
                    {
                        subpageWidth = TextDpi.ToTextDpi(TextDpi.MinWidth);
                    }

                    // Destroy objects created by PTS, but not used here.
                    if (pmcsclientOut != IntPtr.Zero)
                    {
                        MarginCollapsingState mcs = PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState;
                        PTS.ValidateHandle(mcs);
                        mcs.Dispose();
                        pmcsclientOut = IntPtr.Zero;
                    }

                    // Get the size of the floater. For height PTS already reports calculated value.
                    // But width is the same as subpage width.
                    durFloaterWidth = subpageWidth + mbp.MBPLeft + mbp.MBPRight;

                    dvrFloaterHeight += mbp.MBPTop + mbp.MBPBottom;

                    // Check if floater width fits in available width. It may exceed available width because borders
                    // and padding are added.
                    if (dvrFloaterHeight > dvrAvailable ||
                        (durFloaterWidth > durAvailable && !PTS.ToBoolean(fAtMaxWidth))
                        )
                    {
                        // Get rid of any previous formatting
                        if (pfsFloatContent != IntPtr.Zero)
                        {
                            PTS.Validate(PTS.FsDestroySubpage(PtsContext.Context, pfsFloatContent), PtsContext);
                        }

                        Debug.Assert(pmcsclientOut == IntPtr.Zero);
                        cPolygons       = cVertices = 0;
                        pfsFloatContent = IntPtr.Zero;
                    }
                    else
                    {
                        // Width and height are OK, format floater
                        // Adjust bounding box to cover entire floater.
                        fsbbox.fsrc.u  = 0;
                        fsbbox.fsrc.v  = 0;
                        fsbbox.fsrc.du = durFloaterWidth;
                        fsbbox.fsrc.dv = dvrFloaterHeight;

                        // Tight wrap is disabled for now.
                        cPolygons = cVertices = 0;
                    }
                }
                else
                {
                    Debug.Assert(pmcsclientOut == IntPtr.Zero);
                    durFloaterWidth = dvrFloaterHeight = 0;
                    cPolygons       = cVertices = 0;
                    pfsFloatContent = IntPtr.Zero;
                }
            }

            // Update handle to PTS subpage.
            ((FloaterParaClient)paraClient).SubpageHandle = pfsFloatContent;
        }