// Token: 0x0600680B RID: 26635 RVA: 0x001D3C64 File Offset: 0x001D1E64
        internal override void ArrangeFloater(PTS.FSRECT rcFloater, PTS.FSRECT rcHostPara, uint fswdirParent, PageContext pageContext)
        {
            if (this.IsFloaterHorizontallyCentered(rcFloater, rcHostPara))
            {
                rcFloater.u = rcHostPara.u + (rcHostPara.du - rcFloater.du) / 2;
            }
            this._rect = rcFloater;
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            this._rect.v              = this._rect.v + mbpInfo.MarginTop;
            this._rect.dv             = this._rect.dv - (mbpInfo.MarginTop + mbpInfo.MarginBottom);
            this._rect.u              = this._rect.u + mbpInfo.MarginLeft;
            this._rect.du             = this._rect.du - (mbpInfo.MarginLeft + mbpInfo.MarginRight);
            this._flowDirectionParent = PTS.FswdirToFlowDirection(fswdirParent);
            this._flowDirection       = (FlowDirection)base.Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty);
            this._pageContext         = pageContext;
            if (base.ThisFlowDirection != base.PageFlowDirection)
            {
                mbpInfo.MirrorBP();
            }
            this._contentRect.u  = this._rect.u + mbpInfo.BPLeft;
            this._contentRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.du - mbpInfo.BPRight - mbpInfo.BPLeft);
            this._contentRect.v  = this._rect.v + mbpInfo.BPTop;
            this._contentRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.dv - mbpInfo.BPBottom - mbpInfo.BPTop);
            this._paddingRect.u  = this._rect.u + mbpInfo.BorderLeft;
            this._paddingRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.du - mbpInfo.BorderRight - mbpInfo.BorderLeft);
            this._paddingRect.v  = this._rect.v + mbpInfo.BorderTop;
            this._paddingRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.dv - mbpInfo.BorderBottom - mbpInfo.BorderTop);
            this.OnArrange();
        }
        // ------------------------------------------------------------------
        // Create new margin collapsing state and collapse margins if necessary.
        // If no collapsing happens, retrieve margin from old collapsing state.
        // This margin value should be used to advance pen.
        // ------------------------------------------------------------------
        internal static void CollapseTopMargin(
            PtsContext ptsContext,              // Current PTS Context.
            MbpInfo mbp,                        // MBP information for element entering the scope
            MarginCollapsingState mcsCurrent,   // current margin collapsing state (adjacent to the new one).
            out MarginCollapsingState mcsNew,   // margin collapsing state for element entering the scope
            out int margin)                     // collapsed margin value
        {
            margin = 0;
            mcsNew = null;

            // Create new margin collapsing info
            mcsNew = new MarginCollapsingState(ptsContext, mbp.MarginTop);
            // collapse margins, if current margin collapsing exists
            if (mcsCurrent != null)
            {
                mcsNew.Collapse(mcsCurrent);
            }

            // If border or paddind is specified:
            // (1) get collapsed margin value
            // (2) set new mcs to null, because we don't have one anymore
            if (mbp.BPTop != 0)
            {
                margin = mcsNew.Margin;
                mcsNew.Dispose();
                mcsNew = null;
            }
            else if (mcsCurrent == null && DoubleUtil.IsZero(mbp.Margin.Top))
            {
                // No need to create new margin collapsing info
                mcsNew.Dispose();
                mcsNew = null;
            }
        }
Esempio n. 3
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Adjust the width available for the Floater.
        /// </summary>
        private void AdjustDurAvailable(double specifiedWidth, ref int durAvailable, out int subpageWidth)
        {
            // If width on floater is specified, use the specified value.
            // Use page size from current format context to limit MBP
            MbpInfo mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);

            if (!Double.IsNaN(specifiedWidth))
            {
                TextDpi.EnsureValidPageWidth(ref specifiedWidth);
                // If specified width is greater than available width, do not exceed available width
                int durSpecified = TextDpi.ToTextDpi(specifiedWidth);
                if ((durSpecified + mbp.MarginRight + mbp.MarginLeft) <= durAvailable)
                {
                    // Set durAvailable to durSpecified plus margins, which will be added later.
                    // Set subpage width to specified width less border and padding
                    durAvailable = durSpecified + mbp.MarginLeft + mbp.MarginRight;
                    subpageWidth = Math.Max(1, durSpecified - (mbp.BPLeft + mbp.BPRight));
                }
                else
                {
                    // Use durAvailable, less MBP to set subpage width. We cannot set figure to specified width
                    subpageWidth = Math.Max(1, durAvailable - (mbp.MBPLeft + mbp.MBPRight));
                }
            }
            else
            {
                // No width specified. Use durAvailable, less MBP to set subpage width.
                subpageWidth = Math.Max(1, durAvailable - (mbp.MBPLeft + mbp.MBPRight));
            }
        }
        // Token: 0x06006B6E RID: 27502 RVA: 0x001F0978 File Offset: 0x001EEB78
        internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited)
        {
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            PtsHelper.UpdateMirroringTransform(base.PageFlowDirection, base.ThisFlowDirection, this._visual, TextDpi.FromTextDpi(2 * this._rect.u + this._rect.du));
            UIElementIsland uielementIsland = ((UIElementParagraph)base.Paragraph).UIElementIsland;

            if (uielementIsland != null)
            {
                if (this._visual.Children.Count != 1 || this._visual.Children[0] != uielementIsland)
                {
                    Visual visual = VisualTreeHelper.GetParent(uielementIsland) as Visual;
                    if (visual != null)
                    {
                        ContainerVisual containerVisual = visual as ContainerVisual;
                        Invariant.Assert(containerVisual != null, "Parent should always derives from ContainerVisual.");
                        containerVisual.Children.Remove(uielementIsland);
                    }
                    this._visual.Children.Clear();
                    this._visual.Children.Add(uielementIsland);
                }
                uielementIsland.Offset = new PTS.FSVECTOR(this._rect.u + mbpInfo.BPLeft, this._rect.v + mbpInfo.BPTop).FromTextDpi();
            }
            else
            {
                this._visual.Children.Clear();
            }
            Brush backgroundBrush = (Brush)base.Paragraph.Element.GetValue(TextElement.BackgroundProperty);

            this._visual.DrawBackgroundAndBorder(backgroundBrush, mbpInfo.BorderBrush, mbpInfo.Border, this._rect.FromTextDpi(), this.IsFirstChunk, this.IsLastChunk);
        }
        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);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// GetRowProperties
        /// </summary>
        /// <param name="fswdirTable">Flow direction for table</param>
        /// <param name="rowprops">Row properties structure</param>
        internal void GetRowProperties(
            uint fswdirTable,                       // IN:
            out PTS.FSTABLEROWPROPS rowprops)       // OUT:
        {
            // local variables
            PTS.FSKROWHEIGHTRESTRICTION fskrowheight;
            int  dvrAboveBelow;
            bool isLastRowOfRowGroup = (Row.Index == Row.RowGroup.Rows.Count - 1);

            //  Note: PTS generally does not accept rows with no real cells
            //  (Defintinion: real cell is
            //      a) cell with no vertical merge;
            //      OR
            //      b) vertically merged cell ending in this row)
            //  However PTS accepts a row with no real cells if it has explicit height set.
            //  So fskrowheight is set to "0" if
            //      a) user said so;
            //      b) no real cells found;

            GetRowHeight(out fskrowheight, out dvrAboveBelow);

            // initialize output parameter(s)
            rowprops = new PTS.FSTABLEROWPROPS();

            rowprops.fskrowbreak             = PTS.FSKROWBREAKRESTRICTION.fskrowbreakAnywhere;
            rowprops.fskrowheight            = fskrowheight;
            rowprops.dvrRowHeightRestriction = 0;
            rowprops.dvrAboveRow             = dvrAboveBelow;
            rowprops.dvrBelowRow             = dvrAboveBelow;


            int cellSpacing = TextDpi.ToTextDpi(Table.InternalCellSpacing);

            // Clip MBP values to structural cache's current format context size. Also use current format context's page height to
            // clip cell spacing
            MbpInfo mbpInfo = MbpInfo.FromElement(Table, StructuralCache.TextFormatterHost.PixelsPerDip);

            if (Row.Index == 0 && Table.IsFirstNonEmptyRowGroup(Row.RowGroup.Index))
            {
                rowprops.dvrAboveTopRow = mbpInfo.BPTop + cellSpacing / 2;
            }
            else
            {
                rowprops.dvrAboveTopRow = dvrAboveBelow;
            }

            if (isLastRowOfRowGroup && Table.IsLastNonEmptyRowGroup(Row.RowGroup.Index))
            {
                rowprops.dvrBelowBottomRow = mbpInfo.BPBottom + cellSpacing / 2;
            }
            else
            {
                rowprops.dvrBelowBottomRow = dvrAboveBelow;
            }

            rowprops.dvrAboveRowBreak = cellSpacing / 2;
            rowprops.dvrBelowRowBreak = cellSpacing / 2;

            rowprops.cCells = Row.FormatCellCount;
        }
        /// <summary>
        /// Resolve Auto values for Margin.
        /// </summary>
        private static void ResolveAutoMargin(MbpInfo mbp, DependencyObject o, double lineHeight)
        {
            Thickness defaultMargin;

            if (o is Paragraph)
            {
                DependencyObject parent = ((Paragraph)o).Parent;
                if (parent is ListItem || parent is TableCell || parent is AnchoredBlock)
                {
                    defaultMargin = new Thickness(0);
                }
                else
                {
                    defaultMargin = new Thickness(0, lineHeight, 0, lineHeight);
                }
            }
            else if (o is Table || o is List)
            {
                defaultMargin = new Thickness(0, lineHeight, 0, lineHeight);
            }
            else if (o is Figure || o is Floater)
            {
                defaultMargin = new Thickness(0.5 * lineHeight);
            }
            else
            {
                defaultMargin = new Thickness(0);
            }
            mbp.Margin = new Thickness(
                Double.IsNaN(mbp.Margin.Left) ? defaultMargin.Left : mbp.Margin.Left,
                Double.IsNaN(mbp.Margin.Top) ? defaultMargin.Top : mbp.Margin.Top,
                Double.IsNaN(mbp.Margin.Right) ? defaultMargin.Right : mbp.Margin.Right,
                Double.IsNaN(mbp.Margin.Bottom) ? defaultMargin.Bottom : mbp.Margin.Bottom);
        }
Esempio n. 8
0
        // ------------------------------------------------------------------
        // Create new margin collapsing state and collapse margins if necessary.
        // If no collapsing happens, retrieve margin from old collapsing state.
        // This margin value should be used to advance pen.
        // ------------------------------------------------------------------
        internal static void CollapseTopMargin(
            PtsContext ptsContext,              // Current PTS Context.
            MbpInfo mbp,                        // MBP information for element entering the scope
            MarginCollapsingState mcsCurrent,   // current margin collapsing state (adjacent to the new one).
            out MarginCollapsingState mcsNew,   // margin collapsing state for element entering the scope
            out int margin)                     // collapsed margin value
        {
            margin = 0;
            mcsNew = null;

            // Create new margin collapsing info
            mcsNew = new MarginCollapsingState(ptsContext, mbp.MarginTop);
            // collapse margins, if current margin collapsing exists
            if (mcsCurrent != null)
            {
                mcsNew.Collapse(mcsCurrent);
            }

            // If border or paddind is specified:
            // (1) get collapsed margin value
            // (2) set new mcs to null, because we don't have one anymore
            if (mbp.BPTop != 0)
            {
                margin = mcsNew.Margin;
                mcsNew.Dispose();
                mcsNew = null;
            }
            else if (mcsCurrent == null && DoubleUtil.IsZero(mbp.Margin.Top))
            {
                // No need to create new margin collapsing info
                mcsNew.Dispose();
                mcsNew = null;
            }
        }
Esempio n. 9
0
        //------------------------------------------------------
        //
        //  Protected Methods
        //
        //------------------------------------------------------

        #region Protected Methods
        #endregion Protected Methods

        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        /// <summary>
        /// Collapse Margins
        /// </summary>
        /// <param name="paraClient">Para client</param>
        /// <param name="mcs">input margin collapsing state</param>
        /// <param name="fswdir">current direction (of the track, in which margin collapsing is happening)</param>
        /// <param name="suppressTopSpace">suppress empty space at the top of page</param>
        /// <param name="dvr">dvr, calculated based on margin collapsing state</param>
        internal override void CollapseMargin(
            BaseParaClient paraClient,          // IN:
            MarginCollapsingState mcs,          // IN:  input margin collapsing state
            uint fswdir,                        // IN:  current direction (of the track, in which margin collapsing is happening)
            bool suppressTopSpace,              // IN:  suppress empty space at the top of page
            out int dvr)                        // OUT: dvr, calculated based on margin collapsing state
        {
            if (suppressTopSpace && (StructuralCache.CurrentFormatContext.FinitePage || mcs == null))
            {
                dvr = 0;
            }
            else
            {
                MbpInfo mbp = MbpInfo.FromElement(Table, StructuralCache.TextFormatterHost.PixelsPerDip);
                MarginCollapsingState mcsOut = null;
                MarginCollapsingState.CollapseTopMargin(PtsContext, mbp, mcs, out mcsOut, out dvr);

                if (mcsOut != null)
                {
                    dvr = mcsOut.Margin;
                    mcsOut.Dispose();
                    mcsOut = null;
                }
            }
        }
Esempio n. 10
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);
        }
        internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited)
        {
            // Query paragraph details
            PTS.FSSUBTRACKDETAILS subtrackDetails;
            PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails));

            // Draw border and background info.

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

            if (ThisFlowDirection != PageFlowDirection)
            {
                mbp.MirrorBP();
            }

            Brush backgroundBrush = (Brush)Paragraph.Element.GetValue(TextElement.BackgroundProperty);

            _visual.DrawBackgroundAndBorder(backgroundBrush, mbp.BorderBrush, mbp.Border, _rect.FromTextDpi(), IsFirstChunk, IsLastChunk);

            // There might be possibility to get empty sub-track, skip the sub-track in such case.
            if (subtrackDetails.cParas != 0)
            {
                // Get list of paragraphs
                PTS.FSPARADESCRIPTION [] arrayParaDesc;
                PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc);

                // Render list of paragraphs
                PtsHelper.UpdateParaListVisuals(PtsContext, _visual.Children, fskupdInherited, arrayParaDesc);
            }
            else
            {
                _visual.Children.Clear();
            }
        }
Esempio n. 12
0
        //-------------------------------------------------------------------
        // CollapseMargin
        //-------------------------------------------------------------------
        internal override void CollapseMargin(
            BaseParaClient paraClient,          // IN:
            MarginCollapsingState mcs,          // IN:  input margin collapsing state
            uint fswdir,                        // IN:  current direction (of the track, in which margin collapsing is happening)
            bool suppressTopSpace,              // IN:  suppress empty space at the top of page
            out int dvr)                        // OUT: dvr, calculated based on margin collapsing state
        {
            MbpInfo mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);
            MarginCollapsingState mcsNew;
            int margin;

            MarginCollapsingState.CollapseTopMargin(PtsContext, mbp, mcs, out mcsNew, out margin);

            if (suppressTopSpace)
            {
                dvr = 0;
            }
            else
            {
                dvr = margin;
                if (mcsNew != null)
                {
                    dvr += mcsNew.Margin;
                }
            }
            if (mcsNew != null)
            {
                mcsNew.Dispose();
            }
        }
Esempio n. 13
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;
            }
        }
 // Token: 0x06006B60 RID: 27488 RVA: 0x001F0134 File Offset: 0x001EE334
 internal override void FormatFloaterContentFinite(FloaterBaseParaClient paraClient, IntPtr pbrkrecIn, int fBRFromPreviousPage, IntPtr footnoteRejector, int fEmptyOk, int fSuppressTopSpace, uint fswdir, int fAtMaxWidth, int durAvailable, int dvrAvailable, PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn, out PTS.FSFMTR fsfmtr, out IntPtr pfsFloatContent, out IntPtr pbrkrecOut, out int durFloaterWidth, out int dvrFloaterHeight, out PTS.FSBBOX fsbbox, out int cPolygons, out int cVertices)
 {
     Invariant.Assert(paraClient is UIElementParaClient);
     Invariant.Assert(base.Element is BlockUIContainer);
     if (fAtMaxWidth == 0 && fEmptyOk == 1)
     {
         durFloaterWidth = (dvrFloaterHeight = 0);
         cPolygons       = (cVertices = 0);
         fsfmtr          = default(PTS.FSFMTR);
         fsfmtr.kstop    = PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace;
         fsfmtr.fContainsItemThatStoppedBeforeFootnote = 0;
         fsfmtr.fForcedProgress = 0;
         fsbbox          = default(PTS.FSBBOX);
         fsbbox.fDefined = 0;
         pbrkrecOut      = IntPtr.Zero;
         pfsFloatContent = IntPtr.Zero;
         return;
     }
     cPolygons = (cVertices = 0);
     fsfmtr.fForcedProgress = PTS.FromBoolean(fAtMaxWidth == 0);
     if (((BlockUIContainer)base.Element).Child != null)
     {
         this.EnsureUIElementIsland();
         this.FormatUIElement(durAvailable, out fsbbox);
     }
     else
     {
         this.ClearUIElementIsland();
         MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);
         fsbbox.fsrc    = default(PTS.FSRECT);
         fsbbox.fsrc.du = durAvailable;
         fsbbox.fsrc.dv = mbpInfo.BPTop + mbpInfo.BPBottom;
     }
     durFloaterWidth  = fsbbox.fsrc.du;
     dvrFloaterHeight = fsbbox.fsrc.dv;
     if (dvrAvailable < dvrFloaterHeight && fEmptyOk == 1)
     {
         durFloaterWidth = (dvrFloaterHeight = 0);
         fsfmtr          = default(PTS.FSFMTR);
         fsfmtr.kstop    = PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace;
         fsbbox          = default(PTS.FSBBOX);
         fsbbox.fDefined = 0;
         pfsFloatContent = IntPtr.Zero;
     }
     else
     {
         fsbbox.fDefined = 1;
         pfsFloatContent = paraClient.Handle;
         if (dvrAvailable < dvrFloaterHeight)
         {
             Invariant.Assert(fEmptyOk == 0);
             fsfmtr.fForcedProgress = 1;
         }
         fsfmtr.kstop = PTS.FSFMTRKSTOP.fmtrGoalReached;
     }
     pbrkrecOut = IntPtr.Zero;
     fsfmtr.fContainsItemThatStoppedBeforeFootnote = 0;
 }
Esempio n. 15
0
        protected override void OnArrange()
        {
            base.OnArrange();
            ((SubpageParagraph)base.Paragraph).UpdateSegmentLastFormatPositions();
            PTS.FSSUBPAGEDETAILS fssubpagedetails;
            PTS.Validate(PTS.FsQuerySubpageDetails(base.PtsContext.Context, this._paraHandle.Value, out fssubpagedetails));
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (base.ThisFlowDirection != base.PageFlowDirection)
            {
                mbpInfo.MirrorBP();
            }
            if (!this.IsFirstChunk)
            {
                mbpInfo.Border  = new Thickness(mbpInfo.Border.Left, 0.0, mbpInfo.Border.Right, mbpInfo.Border.Bottom);
                mbpInfo.Padding = new Thickness(mbpInfo.Padding.Left, 0.0, mbpInfo.Padding.Right, mbpInfo.Padding.Bottom);
            }
            if (!this.IsLastChunk)
            {
                mbpInfo.Border  = new Thickness(mbpInfo.Border.Left, mbpInfo.Border.Top, mbpInfo.Border.Right, 0.0);
                mbpInfo.Padding = new Thickness(mbpInfo.Padding.Left, mbpInfo.Padding.Top, mbpInfo.Padding.Right, 0.0);
            }
            this._contentRect.u  = this._rect.u + mbpInfo.BPLeft;
            this._contentRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.du - mbpInfo.BPRight - mbpInfo.BPLeft);
            this._contentRect.v  = this._rect.v + mbpInfo.BPTop;
            this._contentRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.dv - mbpInfo.BPBottom - mbpInfo.BPTop);
            this._paddingRect.u  = this._rect.u + mbpInfo.BorderLeft;
            this._paddingRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.du - mbpInfo.BorderRight - mbpInfo.BorderLeft);
            this._paddingRect.v  = this._rect.v + mbpInfo.BorderTop;
            this._paddingRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), this._rect.dv - mbpInfo.BorderBottom - mbpInfo.BorderTop);
            if (PTS.ToBoolean(fssubpagedetails.fSimple))
            {
                this._pageContextOfThisPage.PageRect = new PTS.FSRECT(fssubpagedetails.u.simple.trackdescr.fsrc);
                base.Paragraph.StructuralCache.CurrentArrangeContext.PushNewPageData(this._pageContextOfThisPage, fssubpagedetails.u.simple.trackdescr.fsrc, base.Paragraph.StructuralCache.CurrentArrangeContext.FinitePage);
                PtsHelper.ArrangeTrack(base.PtsContext, ref fssubpagedetails.u.simple.trackdescr, fssubpagedetails.u.simple.fswdir);
                base.Paragraph.StructuralCache.CurrentArrangeContext.PopPageData();
                return;
            }
            this._pageContextOfThisPage.PageRect = new PTS.FSRECT(fssubpagedetails.u.complex.fsrc);
            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++)
                {
                    base.Paragraph.StructuralCache.CurrentArrangeContext.PushNewPageData(this._pageContextOfThisPage, array[i].fsrc, base.Paragraph.StructuralCache.CurrentArrangeContext.FinitePage);
                    PtsHelper.ArrangeTrack(base.PtsContext, ref array[i], fssubpagedetails.u.complex.fswdir);
                    base.Paragraph.StructuralCache.CurrentArrangeContext.PopPageData();
                }
            }
        }
        // Token: 0x06006B63 RID: 27491 RVA: 0x001F0474 File Offset: 0x001EE674
        internal override void GetMCSClientAfterFloater(uint fswdirTrack, MarginCollapsingState mcs, out IntPtr pmcsclientOut)
        {
            MbpInfo mbp = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);
            MarginCollapsingState marginCollapsingState;
            int num;

            MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbp, null, out marginCollapsingState, out num);
            if (marginCollapsingState != null)
            {
                pmcsclientOut = marginCollapsingState.Handle;
                return;
            }
            pmcsclientOut = IntPtr.Zero;
        }
Esempio n. 17
0
        // Token: 0x060067D8 RID: 26584 RVA: 0x001D20E0 File Offset: 0x001D02E0
        internal void ArrangeFigure(PTS.FSRECT rcFigure, PTS.FSRECT rcHostPara, uint fswdirParent, PageContext pageContext)
        {
            this._rect = rcFigure;
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            this._rect.v              = this._rect.v + mbpInfo.MarginTop;
            this._rect.dv             = this._rect.dv - (mbpInfo.MarginTop + mbpInfo.MarginBottom);
            this._rect.u              = this._rect.u + mbpInfo.MarginLeft;
            this._rect.du             = this._rect.du - (mbpInfo.MarginLeft + mbpInfo.MarginRight);
            this._pageContext         = pageContext;
            this._flowDirectionParent = PTS.FswdirToFlowDirection(fswdirParent);
            this._flowDirection       = (FlowDirection)base.Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty);
            this.OnArrange();
        }
        // Token: 0x06006AC8 RID: 27336 RVA: 0x001E9078 File Offset: 0x001E7278
        internal override void CollapseMargin(BaseParaClient paraClient, MarginCollapsingState mcs, uint fswdir, bool suppressTopSpace, out int dvr)
        {
            if (suppressTopSpace && (base.StructuralCache.CurrentFormatContext.FinitePage || mcs == null))
            {
                dvr = 0;
                return;
            }
            MbpInfo mbp = MbpInfo.FromElement(this.Table, base.StructuralCache.TextFormatterHost.PixelsPerDip);
            MarginCollapsingState marginCollapsingState = null;

            MarginCollapsingState.CollapseTopMargin(base.PtsContext, mbp, mcs, out marginCollapsingState, out dvr);
            if (marginCollapsingState != null)
            {
                dvr = marginCollapsingState.Margin;
                marginCollapsingState.Dispose();
                marginCollapsingState = null;
            }
        }
Esempio n. 19
0
 // Token: 0x060068B9 RID: 26809 RVA: 0x001D8E68 File Offset: 0x001D7068
 internal static MbpInfo FromElement(DependencyObject o, double pixelsPerDip)
 {
     if (o is Block || o is AnchoredBlock || o is TableCell || o is ListItem)
     {
         MbpInfo mbpInfo         = new MbpInfo((TextElement)o);
         double  lineHeightValue = DynamicPropertyReader.GetLineHeightValue(o);
         if (mbpInfo.IsMarginAuto)
         {
             MbpInfo.ResolveAutoMargin(mbpInfo, o, lineHeightValue);
         }
         if (mbpInfo.IsPaddingAuto)
         {
             MbpInfo.ResolveAutoPadding(mbpInfo, o, lineHeightValue, pixelsPerDip);
         }
         return(mbpInfo);
     }
     return(MbpInfo._empty);
 }
Esempio n. 20
0
        // Token: 0x060068C1 RID: 26817 RVA: 0x001D9154 File Offset: 0x001D7354
        private static void ResolveAutoPadding(MbpInfo mbp, DependencyObject o, double lineHeight, double pixelsPerDip)
        {
            Thickness thickness;

            if (o is Figure || o is Floater)
            {
                thickness = new Thickness(0.5 * lineHeight);
            }
            else if (o is List)
            {
                thickness = ListMarkerSourceInfo.CalculatePadding((List)o, lineHeight, pixelsPerDip);
            }
            else
            {
                thickness = new Thickness(0.0);
            }
            mbp.Padding = new Thickness(double.IsNaN(mbp.Padding.Left) ? thickness.Left : mbp.Padding.Left, double.IsNaN(mbp.Padding.Top) ? thickness.Top : mbp.Padding.Top, double.IsNaN(mbp.Padding.Right) ? thickness.Right : mbp.Padding.Right, double.IsNaN(mbp.Padding.Bottom) ? thickness.Bottom : mbp.Padding.Bottom);
        }
Esempio n. 21
0
        //-------------------------------------------------------------------
        // GetMCSClientAfterFloater
        //-------------------------------------------------------------------
        internal override void GetMCSClientAfterFloater(
            uint fswdirTrack,                   // IN:  direction of Track
            MarginCollapsingState mcs,          // IN:  input margin collapsing state
            out IntPtr pmcsclientOut)           // OUT: MCSCLIENT that floater will return to track
        {
            MarginCollapsingState mcsNew;
            int     margin;
            MbpInfo mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);

            MarginCollapsingState.CollapseBottomMargin(PtsContext, mbp, null, out mcsNew, out margin);
            if (mcsNew != null)
            {
                pmcsclientOut = mcsNew.Handle;
            }
            else
            {
                pmcsclientOut = IntPtr.Zero;
            }
        }
        // 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;
        }
        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);
        }
        // Token: 0x06006ACC RID: 27340 RVA: 0x001E9198 File Offset: 0x001E7398
        internal void GetMCSClientAfterTable(uint fswdirTrack, IntPtr pmcsclientIn, out IntPtr ppmcsclientOut)
        {
            ppmcsclientOut = IntPtr.Zero;
            MbpInfo mbp = MbpInfo.FromElement(this.Table, base.StructuralCache.TextFormatterHost.PixelsPerDip);
            MarginCollapsingState mcsCurrent = null;

            if (pmcsclientIn != IntPtr.Zero)
            {
                mcsCurrent = (base.PtsContext.HandleToObject(pmcsclientIn) as MarginCollapsingState);
            }
            MarginCollapsingState marginCollapsingState = null;
            int num;

            MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbp, mcsCurrent, out marginCollapsingState, out num);
            if (marginCollapsingState != null)
            {
                ppmcsclientOut = marginCollapsingState.Handle;
            }
        }
Esempio n. 25
0
        // ------------------------------------------------------------------
        // Arrange floater
        //
        //      rcFloater - rectangle of the floater
        //      rcHostPara - rectangle of the host text paragraph.
        // ------------------------------------------------------------------
        internal override void ArrangeFloater(PTS.FSRECT rcFloater, PTS.FSRECT rcHostPara, uint fswdirParent, PageContext pageContext)
        {
            // If alignment is set to Stretch and floater width is less than para width, center it
            if (IsFloaterHorizontallyCentered(rcFloater, rcHostPara))
            {
                rcFloater.u = rcHostPara.u + (rcHostPara.du - rcFloater.du) / 2;
            }

            // Set paragraph rectangle (relative to the page)
            _rect = rcFloater;

            // Adjust rect to account for margins
            // Add margin values to rect offsets and subtract them from rect widths
            MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            _rect.v  += mbp.MarginTop;
            _rect.dv -= mbp.MarginTop + mbp.MarginBottom;
            _rect.u  += mbp.MarginLeft;
            _rect.du -= mbp.MarginLeft + mbp.MarginRight;

            _flowDirectionParent = PTS.FswdirToFlowDirection(fswdirParent);
            _flowDirection       = (FlowDirection)Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty);
            _pageContext         = pageContext;

            if (ThisFlowDirection != PageFlowDirection)
            {
                mbp.MirrorBP();
            }

            _contentRect.u  = _rect.u + mbp.BPLeft;
            _contentRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du - mbp.BPRight - mbp.BPLeft);
            _contentRect.v  = _rect.v + mbp.BPTop;
            _contentRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv - mbp.BPBottom - mbp.BPTop);

            _paddingRect.u  = _rect.u + mbp.BorderLeft;
            _paddingRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du - mbp.BorderRight - mbp.BorderLeft);
            _paddingRect.v  = _rect.v + mbp.BorderTop;
            _paddingRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv - mbp.BorderBottom - mbp.BorderTop);

            // Do paragraph specifc arrange
            OnArrange();
        }
Esempio n. 26
0
        // Token: 0x06006828 RID: 26664 RVA: 0x001D5528 File Offset: 0x001D3728
        private void AdjustDurAvailable(double specifiedWidth, ref int durAvailable, out int subpageWidth)
        {
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (double.IsNaN(specifiedWidth))
            {
                subpageWidth = Math.Max(1, durAvailable - (mbpInfo.MBPLeft + mbpInfo.MBPRight));
                return;
            }
            TextDpi.EnsureValidPageWidth(ref specifiedWidth);
            int num = TextDpi.ToTextDpi(specifiedWidth);

            if (num + mbpInfo.MarginRight + mbpInfo.MarginLeft <= durAvailable)
            {
                durAvailable = num + mbpInfo.MarginLeft + mbpInfo.MarginRight;
                subpageWidth = Math.Max(1, num - (mbpInfo.BPLeft + mbpInfo.BPRight));
                return;
            }
            subpageWidth = Math.Max(1, durAvailable - (mbpInfo.MBPLeft + mbpInfo.MBPRight));
        }
Esempio n. 27
0
        /// <summary>
        /// Get MbpInfo from DependencyObject.
        /// </summary>
        /// <param name="o">DependencyObject for which MBP properties are retrieved.</param>
        internal static MbpInfo FromElement(DependencyObject o)
        {
            if (o is Block || o is AnchoredBlock || o is TableCell || o is ListItem)
            {
                MbpInfo mbp = new MbpInfo((TextElement)o);
                double lineHeight = DynamicPropertyReader.GetLineHeightValue(o);

                if (mbp.IsMarginAuto)
                {
                    ResolveAutoMargin(mbp, o, lineHeight);
                }
                if (mbp.IsPaddingAuto)
                {
                    ResolveAutoPadding(mbp, o, lineHeight);
                }

                return mbp;
            }

            return _empty;
        }
Esempio n. 28
0
        /// <summary>
        /// Validates visual node associated with paragraph.
        /// </summary>
        internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited)
        {
            // Obtain all mbd info
            MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            // MIRROR entire element to interface with underlying layout tree.
            // Border/Padding does not need to be mirrored, as it'll be mirrored with the content.
            PtsHelper.UpdateMirroringTransform(PageFlowDirection, ThisFlowDirection, _visual, TextDpi.FromTextDpi(2 * _rect.u + _rect.du));

            // Add UIElementIsland to visual tree and set appropiate offset.
            UIElementIsland uiElementIsland = ((UIElementParagraph)Paragraph).UIElementIsland;

            if (uiElementIsland != null)
            {
                if (_visual.Children.Count != 1 || _visual.Children[0] != uiElementIsland)
                {
                    // Disconnect UIElementIsland from its old parent.
                    Visual currentParent = VisualTreeHelper.GetParent(uiElementIsland) as Visual;
                    if (currentParent != null)
                    {
                        ContainerVisual parent = currentParent as ContainerVisual;
                        Invariant.Assert(parent != null, "Parent should always derives from ContainerVisual.");
                        parent.Children.Remove(uiElementIsland);
                    }

                    _visual.Children.Clear();
                    _visual.Children.Add(uiElementIsland);
                }
                uiElementIsland.Offset = new PTS.FSVECTOR(_rect.u + mbp.BPLeft, _rect.v + mbp.BPTop).FromTextDpi();
            }
            else
            {
                _visual.Children.Clear();
            }

            // Draw background and borders.
            Brush backgroundBrush = (Brush)Paragraph.Element.GetValue(TextElement.BackgroundProperty);

            _visual.DrawBackgroundAndBorder(backgroundBrush, mbp.BorderBrush, mbp.Border, _rect.FromTextDpi(), IsFirstChunk, IsLastChunk);
        }
Esempio n. 29
0
        internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited)
        {
            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.ThisFlowDirection != base.PageFlowDirection)
            {
                mbpInfo.MirrorBP();
            }
            Brush backgroundBrush = (Brush)base.Paragraph.Element.GetValue(TextElement.BackgroundProperty);

            this._visual.DrawBackgroundAndBorder(backgroundBrush, mbpInfo.BorderBrush, mbpInfo.Border, this._rect.FromTextDpi(), this.IsFirstChunk, this.IsLastChunk);
            if (fssubtrackdetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION[] arrayParaDesc;
                PtsHelper.ParaListFromSubtrack(base.PtsContext, this._paraHandle.Value, ref fssubtrackdetails, out arrayParaDesc);
                PtsHelper.UpdateParaListVisuals(base.PtsContext, this._visual.Children, fskupdInherited, arrayParaDesc);
                return;
            }
            this._visual.Children.Clear();
        }
Esempio n. 30
0
 // Token: 0x060068B1 RID: 26801 RVA: 0x001D8CE8 File Offset: 0x001D6EE8
 internal static void CollapseTopMargin(PtsContext ptsContext, MbpInfo mbp, MarginCollapsingState mcsCurrent, out MarginCollapsingState mcsNew, out int margin)
 {
     margin = 0;
     mcsNew = null;
     mcsNew = new MarginCollapsingState(ptsContext, mbp.MarginTop);
     if (mcsCurrent != null)
     {
         mcsNew.Collapse(mcsCurrent);
     }
     if (mbp.BPTop != 0)
     {
         margin = mcsNew.Margin;
         mcsNew.Dispose();
         mcsNew = null;
         return;
     }
     if (mcsCurrent == null && DoubleUtil.IsZero(mbp.Margin.Top))
     {
         mcsNew.Dispose();
         mcsNew = null;
     }
 }
        /// <summary>
        /// Resolve Auto values for Padding.
        /// </summary>
        private static void ResolveAutoPadding(MbpInfo mbp, DependencyObject o, double lineHeight)
        {
            Thickness defaultPadding;

            if (o is Figure || o is Floater)
            {
                defaultPadding = new Thickness(0.5 * lineHeight);
            }
            else if (o is List)
            {
                defaultPadding = ListMarkerSourceInfo.CalculatePadding((List)o, lineHeight);
            }
            else
            {
                defaultPadding = new Thickness(0);
            }
            mbp.Padding = new Thickness(
                Double.IsNaN(mbp.Padding.Left) ? defaultPadding.Left : mbp.Padding.Left,
                Double.IsNaN(mbp.Padding.Top) ? defaultPadding.Top : mbp.Padding.Top,
                Double.IsNaN(mbp.Padding.Right) ? defaultPadding.Right : mbp.Padding.Right,
                Double.IsNaN(mbp.Padding.Bottom) ? defaultPadding.Bottom : mbp.Padding.Bottom);
        }
        // Token: 0x06006B61 RID: 27489 RVA: 0x001F02F8 File Offset: 0x001EE4F8
        internal override void FormatFloaterContentBottomless(FloaterBaseParaClient paraClient, int fSuppressTopSpace, uint fswdir, int fAtMaxWidth, int durAvailable, int dvrAvailable, out PTS.FSFMTRBL fsfmtrbl, out IntPtr pfsFloatContent, out int durFloaterWidth, out int dvrFloaterHeight, out PTS.FSBBOX fsbbox, out int cPolygons, out int cVertices)
        {
            Invariant.Assert(paraClient is UIElementParaClient);
            Invariant.Assert(base.Element is BlockUIContainer);
            if (fAtMaxWidth == 0)
            {
                durFloaterWidth  = durAvailable + 1;
                dvrFloaterHeight = dvrAvailable + 1;
                cPolygons        = (cVertices = 0);
                fsfmtrbl         = PTS.FSFMTRBL.fmtrblInterrupted;
                fsbbox           = default(PTS.FSBBOX);
                fsbbox.fDefined  = 0;
                pfsFloatContent  = IntPtr.Zero;
                return;
            }
            cPolygons = (cVertices = 0);
            if (((BlockUIContainer)base.Element).Child != null)
            {
                this.EnsureUIElementIsland();
                this.FormatUIElement(durAvailable, out fsbbox);
                pfsFloatContent  = paraClient.Handle;
                fsfmtrbl         = PTS.FSFMTRBL.fmtrblGoalReached;
                fsbbox.fDefined  = 1;
                durFloaterWidth  = fsbbox.fsrc.du;
                dvrFloaterHeight = fsbbox.fsrc.dv;
                return;
            }
            this.ClearUIElementIsland();
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);

            fsbbox.fsrc      = default(PTS.FSRECT);
            fsbbox.fsrc.du   = durAvailable;
            fsbbox.fsrc.dv   = mbpInfo.BPTop + mbpInfo.BPBottom;
            fsbbox.fDefined  = 1;
            pfsFloatContent  = paraClient.Handle;
            fsfmtrbl         = PTS.FSFMTRBL.fmtrblGoalReached;
            durFloaterWidth  = fsbbox.fsrc.du;
            dvrFloaterHeight = fsbbox.fsrc.dv;
        }
Esempio n. 33
0
        // ------------------------------------------------------------------
        // Update current margin collapsing state and collapse margins if 
        // necessary. If no collapsing happens, retrieve margin from previous 
        // collapsing state. This margin value should be used to advance pen.
        // ------------------------------------------------------------------
        internal static void CollapseBottomMargin(
            PtsContext ptsContext,              // Current PTS Context.
            MbpInfo mbp,                        // MBP information for element leaving the scope
            MarginCollapsingState mcsCurrent,   // current margin collapsing state (adjacent to the new one).
            out MarginCollapsingState mcsNew,   // margin collapsing state for element leaving the scope
            out int margin)                     // collapsed margin value
        {
            margin = 0;
            mcsNew = null;

            // Create new margin collapsing state, if necessary
            if (!DoubleUtil.IsZero(mbp.Margin.Bottom))
            {
                mcsNew = new MarginCollapsingState(ptsContext, mbp.MarginBottom);
            }

            // If the current margin collapsing state does not exist, we are done.
            // Otherwise, get current border and padding and decide if to collapse margin.
            if (mcsCurrent != null)
            {
                if (mbp.BPBottom != 0)
                {
                    // No collapsing happens, get margin value
                    margin = mcsCurrent.Margin;
                }
                else
                {
                    // Collapse margins
                    if (mcsNew == null)
                    {
                        mcsNew = new MarginCollapsingState(ptsContext, 0);
                    }
                    mcsNew.Collapse(mcsCurrent);
                }
            }
        }
Esempio n. 34
0
 /// <summary>
 /// Resolve Auto values for Padding.
 /// </summary>
 private static void ResolveAutoPadding(MbpInfo mbp, DependencyObject o, double lineHeight)
 {
     Thickness defaultPadding;
     if (o is Figure || o is Floater)
     {
         defaultPadding = new Thickness(0.5 * lineHeight);
     }
     else if (o is List)
     {
         defaultPadding = ListMarkerSourceInfo.CalculatePadding((List)o, lineHeight);
     }
     else
     {
         defaultPadding = new Thickness(0);
     }
     mbp.Padding = new Thickness(
         Double.IsNaN(mbp.Padding.Left) ? defaultPadding.Left : mbp.Padding.Left,
         Double.IsNaN(mbp.Padding.Top) ? defaultPadding.Top : mbp.Padding.Top,
         Double.IsNaN(mbp.Padding.Right) ? defaultPadding.Right : mbp.Padding.Right,
         Double.IsNaN(mbp.Padding.Bottom) ? defaultPadding.Bottom : mbp.Padding.Bottom);
 }
Esempio n. 35
0
        /// <summary>
        /// Content rect - Rect from which rows/rowgroups/columns are calculated.
        /// </summary>
        private PTS.FSRECT GetTableContentRect(MbpInfo mbpInfo)
        {
            int calculatedBPTop = IsFirstChunk ? mbpInfo.BPTop : 0;
            int calculatedBPBottom = IsLastChunk ? mbpInfo.BPBottom : 0;

            return new PTS.FSRECT(_rect.u + mbpInfo.BPLeft,
                                  _rect.v + calculatedBPTop,
                                  Math.Max(_rect.du - (mbpInfo.BPRight + mbpInfo.BPLeft), 1),
                                  Math.Max(_rect.dv - calculatedBPBottom - calculatedBPTop, 1)
                                 );
        }
Esempio n. 36
0
        private void DrawRowBackgrounds(DrawingContext dc, PTS.FSTABLEROWDESCRIPTION[] arrayTableRowDesc, Rect tableContentRect, MbpInfo mbpInfo)
        {
            double rowTop = tableContentRect.Y;
            Rect rowRect = tableContentRect;

            for (int iR = 0; iR < arrayTableRowDesc.Length; ++iR)
            {
                TableRow row = ((RowParagraph)(PtsContext.HandleToObject(arrayTableRowDesc[iR].fsnmRow))).Row;
                Brush rowBackgroundBrush = (Brush)row.GetValue(TextElement.BackgroundProperty);

                rowRect.Y = rowTop;
                rowRect.Height = GetActualRowHeight(arrayTableRowDesc, iR, mbpInfo);

                if (rowBackgroundBrush != null)
                {
                    dc.DrawRectangle(rowBackgroundBrush, null, rowRect);
                }

                rowTop += rowRect.Height; // Adjust for top of next row
            }
        }
Esempio n. 37
0
        private void DrawRowGroupBackgrounds(DrawingContext dc, PTS.FSTABLEROWDESCRIPTION[] arrayTableRowDesc, Rect tableContentRect, MbpInfo mbpInfo)
        {
            double rowGroupTop = tableContentRect.Y;
            double rowGroupHeight = 0;
            Rect rowRect = tableContentRect;
            Brush rowGroupBackgroundBrush;

            if(arrayTableRowDesc.Length > 0)
            {
                TableRow row = ((RowParagraph)(PtsContext.HandleToObject(arrayTableRowDesc[0].fsnmRow))).Row;
                TableRowGroup tableRowGroup = row.RowGroup;

                for (int iR = 0; iR < arrayTableRowDesc.Length; ++iR)
                {
                    row = ((RowParagraph)(PtsContext.HandleToObject(arrayTableRowDesc[iR].fsnmRow))).Row;

                    if (tableRowGroup != row.RowGroup)
                    {
                        rowGroupBackgroundBrush = (Brush)tableRowGroup.GetValue(TextElement.BackgroundProperty);

                        if (rowGroupBackgroundBrush != null)
                        {
                            rowRect.Y = rowGroupTop;
                            rowRect.Height = rowGroupHeight;
                            dc.DrawRectangle(rowGroupBackgroundBrush, null, rowRect);
                        }

                        rowGroupTop += rowGroupHeight;
                        tableRowGroup = row.RowGroup;
                        rowGroupHeight = GetActualRowHeight(arrayTableRowDesc, iR, mbpInfo);
                    }
                    else
                    {
                        rowGroupHeight += GetActualRowHeight(arrayTableRowDesc, iR, mbpInfo);
                    }
                }

                rowGroupBackgroundBrush = (Brush)tableRowGroup.GetValue(TextElement.BackgroundProperty);
                if (rowGroupBackgroundBrush != null)
                {
                    rowRect.Y = rowGroupTop;
                    rowRect.Height = rowGroupHeight;
                    dc.DrawRectangle(rowGroupBackgroundBrush, null, rowRect);
                }
            }

        }
Esempio n. 38
0
        /// <summary>
        /// Calculates actual row height, subtracting what was previously reported as dvrBeforeTopRow and dvrAfterBottomRow
        /// </summary>
        private double GetActualRowHeight(PTS.FSTABLEROWDESCRIPTION[] arrayTableRowDesc, int rowIndex, MbpInfo mbpInfo)
        {
            int dvAdjustment = 0;

            if(IsFirstChunk && rowIndex == 0)
            {
                dvAdjustment = -mbpInfo.BPTop;
            }

            if(IsLastChunk && rowIndex == arrayTableRowDesc.Length - 1)
            {
                dvAdjustment = -mbpInfo.BPBottom;
            }

            return TextDpi.FromTextDpi(arrayTableRowDesc[rowIndex].u.dvrRow + dvAdjustment);
        }
Esempio n. 39
0
 /// <summary>
 /// Static constructor.
 /// </summary>
 static MbpInfo()
 {
     _empty = new MbpInfo();
 }
Esempio n. 40
0
 /// <summary>
 /// Resolve Auto values for Margin.
 /// </summary>
 private static void ResolveAutoMargin(MbpInfo mbp, DependencyObject o, double lineHeight)
 {
     Thickness defaultMargin;
     if (o is Paragraph)
     {
         DependencyObject parent = ((Paragraph)o).Parent;
         if (parent is ListItem || parent is TableCell || parent is AnchoredBlock)
         {
             defaultMargin = new Thickness(0);
         }
         else
         {
             defaultMargin = new Thickness(0, lineHeight, 0, lineHeight);
         }
     }
     else if (o is Table || o is List)
     {
         defaultMargin = new Thickness(0, lineHeight, 0, lineHeight);
     }
     else if (o is Figure || o is Floater)
     {
         defaultMargin = new Thickness(0.5 * lineHeight);
     }
     else
     {
         defaultMargin = new Thickness(0);
     }
     mbp.Margin = new Thickness(
         Double.IsNaN(mbp.Margin.Left) ? defaultMargin.Left : mbp.Margin.Left,
         Double.IsNaN(mbp.Margin.Top) ? defaultMargin.Top : mbp.Margin.Top,
         Double.IsNaN(mbp.Margin.Right) ? defaultMargin.Right : mbp.Margin.Right,
         Double.IsNaN(mbp.Margin.Bottom) ? defaultMargin.Bottom : mbp.Margin.Bottom);
 }