コード例 #1
0
        internal void Arrange(int du, int dv, PTS.FSRECT rcTable, FlowDirection tableFlowDirection, PageContext pageContext)
        {
            CalculatedColumn[] calculatedColumns   = this._tableParaClient.CalculatedColumns;
            double             internalCellSpacing = this.Table.InternalCellSpacing;
            double             num = -internalCellSpacing;
            int num2 = this.Cell.ColumnIndex + this.Cell.ColumnSpan - 1;

            do
            {
                num += calculatedColumns[num2].DurWidth + internalCellSpacing;
            }while (--num2 >= this.ColumnIndex);
            if (tableFlowDirection != base.PageFlowDirection)
            {
                PTS.FSRECT pageRect = pageContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(PTS.FlowDirectionToFswdir(base.PageFlowDirection), ref pageRect, ref rcTable, PTS.FlowDirectionToFswdir(tableFlowDirection), out rcTable));
            }
            this._rect.u  = du + rcTable.u;
            this._rect.v  = dv + rcTable.v;
            this._rect.du = TextDpi.ToTextDpi(num);
            this._rect.dv = TextDpi.ToTextDpi(this._arrangeHeight);
            if (tableFlowDirection != base.PageFlowDirection)
            {
                PTS.FSRECT pageRect2 = pageContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(PTS.FlowDirectionToFswdir(tableFlowDirection), ref pageRect2, ref this._rect, PTS.FlowDirectionToFswdir(base.PageFlowDirection), out this._rect));
            }
            this._flowDirectionParent = tableFlowDirection;
            this._flowDirection       = (FlowDirection)base.Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty);
            this._pageContext         = pageContext;
            this.OnArrange();
            if (this._paraHandle.Value != IntPtr.Zero)
            {
                PTS.Validate(PTS.FsClearUpdateInfoInSubpage(base.PtsContext.Context, this._paraHandle.Value), base.PtsContext);
            }
        }
コード例 #2
0
        // ------------------------------------------------------------------
        // GetPageDimensions
        // ------------------------------------------------------------------

        /// <summary>
        /// Get page dimensions
        /// </summary>
        /// <param name="fswdir">
        /// OUT: direction of main text
        /// </param>
        /// <param name="fHeaderFooterAtTopBottom">
        /// OUT: header/footer position on the page
        /// </param>
        /// <param name="durPage">
        /// OUT: page width
        /// </param>
        /// <param name="dvrPage">
        /// OUT: page height
        /// </param>
        /// <param name="fsrcMargin">
        /// OUT: rectangle within page margins
        /// </param>
        internal void GetPageDimensions(
            out uint fswdir,
            out int fHeaderFooterAtTopBottom,
            out int durPage,
            out int dvrPage,
            ref PTS.FSRECT fsrcMargin)
        {
            // Set page dimentions
            Size pageSize = _structuralCache.CurrentFormatContext.PageSize;

            durPage = TextDpi.ToTextDpi(pageSize.Width);
            dvrPage = TextDpi.ToTextDpi(pageSize.Height);

            // Set page margin
            Thickness pageMargin = _structuralCache.CurrentFormatContext.PageMargin;

            TextDpi.EnsureValidPageMargin(ref pageMargin, pageSize);
            fsrcMargin.u  = TextDpi.ToTextDpi(pageMargin.Left);
            fsrcMargin.v  = TextDpi.ToTextDpi(pageMargin.Top);
            fsrcMargin.du = durPage - TextDpi.ToTextDpi(pageMargin.Left + pageMargin.Right);
            fsrcMargin.dv = dvrPage - TextDpi.ToTextDpi(pageMargin.Top + pageMargin.Bottom);

            StructuralCache.PageFlowDirection = (FlowDirection)_structuralCache.PropertyOwner.GetValue(FrameworkElement.FlowDirectionProperty);
            fswdir = PTS.FlowDirectionToFswdir(StructuralCache.PageFlowDirection);

            //

            fHeaderFooterAtTopBottom = PTS.False;
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: UIElementParaClient.cs プロジェクト: yk2012985/wpf
        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);
        }
コード例 #5
0
        internal static void ArrangeParaList(PtsContext ptsContext, PTS.FSRECT rcTrackContent, PTS.FSPARADESCRIPTION[] arrayParaDesc, uint fswdirTrack)
        {
            int num = 0;

            for (int i = 0; i < arrayParaDesc.Length; i++)
            {
                BaseParaClient baseParaClient = ptsContext.HandleToObject(arrayParaDesc[i].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(baseParaClient);
                if (i == 0)
                {
                    uint num2 = PTS.FlowDirectionToFswdir(baseParaClient.PageFlowDirection);
                    if (fswdirTrack != num2)
                    {
                        PTS.FSRECT pageRect = baseParaClient.Paragraph.StructuralCache.CurrentArrangeContext.PageContext.PageRect;
                        PTS.Validate(PTS.FsTransformRectangle(fswdirTrack, ref pageRect, ref rcTrackContent, num2, out rcTrackContent));
                    }
                }
                int        dvrTopSpace = arrayParaDesc[i].dvrTopSpace;
                PTS.FSRECT rcPara      = rcTrackContent;
                rcPara.v += num + dvrTopSpace;
                rcPara.dv = arrayParaDesc[i].dvrUsed - dvrTopSpace;
                baseParaClient.Arrange(arrayParaDesc[i].pfspara, rcPara, dvrTopSpace, fswdirTrack);
                num += arrayParaDesc[i].dvrUsed;
            }
        }
コード例 #6
0
 // Token: 0x06006ACB RID: 27339 RVA: 0x001E9124 File Offset: 0x001E7324
 internal void GetTableProperties(uint fswdirTrack, out PTS.FSTABLEOBJPROPS fstableobjprops)
 {
     fstableobjprops                  = default(PTS.FSTABLEOBJPROPS);
     fstableobjprops.fskclear         = PTS.FSKCLEAR.fskclearNone;
     fstableobjprops.ktablealignment  = PTS.FSKTABLEOBJALIGNMENT.fsktableobjAlignLeft;
     fstableobjprops.fFloat           = 0;
     fstableobjprops.fskwr            = PTS.FSKWRAP.fskwrBoth;
     fstableobjprops.fDelayNoProgress = 0;
     fstableobjprops.dvrCaptionTop    = 0;
     fstableobjprops.dvrCaptionBottom = 0;
     fstableobjprops.durCaptionLeft   = 0;
     fstableobjprops.durCaptionRight  = 0;
     fstableobjprops.fswdirTable      = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));
 }
コード例 #7
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        #endregion Public Methods

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

        #region Internal Methods

        /// <summary>
        /// Arrange.
        /// </summary>
        /// <param name="du">U offset component of the cell's visual.</param>
        /// <param name="dv">V offset component of the cell's visual.</param>
        /// <param name="rcTable">Table's rectangle.. (in page flow dir)</param>
        /// <param name="tableFlowDirection">Table's flow direction</param>
        /// <param name="pageContext">Page context</param>
        internal void Arrange(int du, int dv, PTS.FSRECT rcTable, FlowDirection tableFlowDirection, PageContext pageContext)
        {
            //
            // Determine cell width based on column widths.
            //
            CalculatedColumn[] calculatedColumns = _tableParaClient.CalculatedColumns;
            Debug.Assert(calculatedColumns != null &&
                         (Cell.ColumnIndex + Cell.ColumnSpan) <= calculatedColumns.Length);

            double durCellSpacing = Table.InternalCellSpacing;
            double durCellWidth   = -durCellSpacing;

            // find the width sum of all columns the cell spans
            int i = Cell.ColumnIndex + Cell.ColumnSpan - 1;

            do
            {
                durCellWidth += calculatedColumns[i].DurWidth + durCellSpacing;
            } while (--i >= ColumnIndex);

            if (tableFlowDirection != PageFlowDirection)
            {
                PTS.FSRECT pageRect = pageContext.PageRect;

                PTS.Validate(PTS.FsTransformRectangle(PTS.FlowDirectionToFswdir(PageFlowDirection), ref pageRect, ref rcTable, PTS.FlowDirectionToFswdir(tableFlowDirection), out rcTable));
            }

            _rect.u  = du + rcTable.u;
            _rect.v  = dv + rcTable.v;
            _rect.du = TextDpi.ToTextDpi(durCellWidth);
            _rect.dv = TextDpi.ToTextDpi(_arrangeHeight);

            if (tableFlowDirection != PageFlowDirection)
            {
                PTS.FSRECT pageRect = pageContext.PageRect;

                PTS.Validate(PTS.FsTransformRectangle(PTS.FlowDirectionToFswdir(tableFlowDirection), ref pageRect, ref _rect, PTS.FlowDirectionToFswdir(PageFlowDirection), out _rect));
            }

            _flowDirectionParent = tableFlowDirection;
            _flowDirection       = (FlowDirection)Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty);
            _pageContext         = pageContext;

            OnArrange();

            if (_paraHandle.Value != IntPtr.Zero)
            {
                PTS.Validate(PTS.FsClearUpdateInfoInSubpage(PtsContext.Context, _paraHandle.Value), PtsContext);
            }
        }
コード例 #8
0
 // Token: 0x06006B22 RID: 27426 RVA: 0x001EEC70 File Offset: 0x001ECE70
 internal void GetTextProperties(int iArea, ref PTS.FSTXTPROPS fstxtprops)
 {
     fstxtprops.fswdir                              = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));
     fstxtprops.dcpStartContent                     = 0;
     fstxtprops.fKeepTogether                       = PTS.FromBoolean(DynamicPropertyReader.GetKeepTogether(base.Element));
     fstxtprops.cMinLinesAfterBreak                 = DynamicPropertyReader.GetMinOrphanLines(base.Element);
     fstxtprops.cMinLinesBeforeBreak                = DynamicPropertyReader.GetMinWidowLines(base.Element);
     fstxtprops.fDropCap                            = 0;
     fstxtprops.fVerticalGrid                       = 0;
     fstxtprops.fOptimizeParagraph                  = PTS.FromBoolean(this.IsOptimalParagraph);
     fstxtprops.fAvoidHyphenationAtTrackBottom      = 0;
     fstxtprops.fAvoidHyphenationOnLastChainElement = 0;
     fstxtprops.cMaxConsecutiveHyphens              = int.MaxValue;
 }
コード例 #9
0
        // Token: 0x06006A41 RID: 27201 RVA: 0x001E3E34 File Offset: 0x001E2034
        internal void GetSectionProperties(out int fNewPage, out uint fswdir, out int fApplyColumnBalancing, out int ccol, out int cSegmentDefinedColumnSpanAreas, out int cHeightDefinedColumnSpanAreas)
        {
            ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(this.Element);
            Size       pageSize        = this._structuralCache.CurrentFormatContext.PageSize;
            double     lineHeightValue = DynamicPropertyReader.GetLineHeightValue(this.Element);
            Thickness  pageMargin      = this._structuralCache.CurrentFormatContext.PageMargin;
            double     pageFontSize    = (double)this._structuralCache.PropertyOwner.GetValue(TextElement.FontSizeProperty);
            FontFamily pageFontFamily  = (FontFamily)this._structuralCache.PropertyOwner.GetValue(TextElement.FontFamilyProperty);
            bool       finitePage      = this._structuralCache.CurrentFormatContext.FinitePage;

            fNewPage = 0;
            fswdir   = PTS.FlowDirectionToFswdir((FlowDirection)this._structuralCache.PropertyOwner.GetValue(FrameworkElement.FlowDirectionProperty));
            fApplyColumnBalancing = 0;
            ccol = PtsHelper.CalculateColumnCount(columnProperties, lineHeightValue, pageSize.Width - (pageMargin.Left + pageMargin.Right), pageFontSize, pageFontFamily, finitePage);
            cSegmentDefinedColumnSpanAreas = 0;
            cHeightDefinedColumnSpanAreas  = 0;
        }
コード例 #10
0
        /// <summary>
        /// GetTableProperties
        /// </summary>
        /// <param name="fswdirTrack">Direction of Track</param>
        /// <param name="fstableobjprops">Properties of the table</param>
        internal void GetTableProperties(
            uint fswdirTrack,                        // IN:  direction of Track
            out PTS.FSTABLEOBJPROPS fstableobjprops) // OUT: properties of the table
        {
            fstableobjprops = new PTS.FSTABLEOBJPROPS();

            fstableobjprops.fskclear         = PTS.FSKCLEAR.fskclearNone;
            fstableobjprops.ktablealignment  = PTS.FSKTABLEOBJALIGNMENT.fsktableobjAlignLeft;
            fstableobjprops.fFloat           = PTS.False;
            fstableobjprops.fskwr            = PTS.FSKWRAP.fskwrBoth;
            fstableobjprops.fDelayNoProgress = PTS.False;
            fstableobjprops.dvrCaptionTop    = 0;
            fstableobjprops.dvrCaptionBottom = 0;
            fstableobjprops.durCaptionLeft   = 0;
            fstableobjprops.durCaptionRight  = 0;
            fstableobjprops.fswdirTable      = PTS.FlowDirectionToFswdir((FlowDirection)Element.GetValue(FrameworkElement.FlowDirectionProperty));
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        internal static void ArrangeParaList(
            PtsContext ptsContext,
            PTS.FSRECT rcTrackContent,
            PTS.FSPARADESCRIPTION [] arrayParaDesc,
            uint fswdirTrack)
        {
            // For each paragraph, do following:
            // (1) Retrieve ParaClient object
            // (2) Arrange and update paragraph metrics
            int dvrPara = 0;

            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                // (1) Retrieve ParaClient object
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                // Convert to appropriate page coordinates.
                if (index == 0)
                {
                    uint fswdirPage = PTS.FlowDirectionToFswdir(paraClient.PageFlowDirection);

                    if (fswdirTrack != fswdirPage)
                    {
                        PTS.FSRECT pageRect = paraClient.Paragraph.StructuralCache.CurrentArrangeContext.PageContext.PageRect;
                        PTS.Validate(PTS.FsTransformRectangle(fswdirTrack, ref pageRect, ref rcTrackContent, fswdirPage, out rcTrackContent));
                    }
                }

                // (2) Arrange and update paragraph metrics
                int        dvrTopSpace = arrayParaDesc[index].dvrTopSpace;
                PTS.FSRECT rcPara      = rcTrackContent;
                rcPara.v += dvrPara + dvrTopSpace;
                rcPara.dv = arrayParaDesc[index].dvrUsed - dvrTopSpace;

                paraClient.Arrange(arrayParaDesc[index].pfspara, rcPara, dvrTopSpace, fswdirTrack);
                dvrPara += arrayParaDesc[index].dvrUsed;
            }
        }
コード例 #13
0
        // ------------------------------------------------------------------
        // GetSectionProperties
        // ------------------------------------------------------------------

        /// <summary>
        /// Get section properties
        /// </summary>
        /// <param name="fNewPage">
        /// OUT: stop page before this section?
        /// </param>
        /// <param name="fswdir">
        /// OUT: direction of this section
        /// </param>
        /// <param name="fApplyColumnBalancing">
        /// OUT: apply column balancing to this section?
        /// </param>
        /// <param name="ccol">
        /// OUT: number of columns in the main text segment
        /// </param>
        /// <param name="cSegmentDefinedColumnSpanAreas">
        /// OUT: number of segment-defined columnspan areas
        /// </param>
        /// <param name="cHeightDefinedColumnSpanAreas">
        /// OUT: number of height-defined columnsapn areas
        /// </param>
        internal void GetSectionProperties(
            out int fNewPage,
            out uint fswdir,
            out int fApplyColumnBalancing,
            out int ccol,
            out int cSegmentDefinedColumnSpanAreas,
            out int cHeightDefinedColumnSpanAreas)
        {
            ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(Element);
            Size       pageSize       = _structuralCache.CurrentFormatContext.PageSize;
            double     lineHeight     = DynamicPropertyReader.GetLineHeightValue(Element);
            Thickness  pageMargin     = _structuralCache.CurrentFormatContext.PageMargin;
            double     pageFontSize   = (double)_structuralCache.PropertyOwner.GetValue(Block.FontSizeProperty);
            FontFamily pageFontFamily = (FontFamily)_structuralCache.PropertyOwner.GetValue(Block.FontFamilyProperty);
            bool       enableColumns  = _structuralCache.CurrentFormatContext.FinitePage;

            fNewPage = PTS.False; // Since only one section is supported, don't force page break before.
            fswdir   = PTS.FlowDirectionToFswdir((FlowDirection)_structuralCache.PropertyOwner.GetValue(FrameworkElement.FlowDirectionProperty));
            fApplyColumnBalancing = PTS.False;
            ccol = PtsHelper.CalculateColumnCount(columnProperties, lineHeight, pageSize.Width - (pageMargin.Left + pageMargin.Right), pageFontSize, pageFontFamily, enableColumns);
            cSegmentDefinedColumnSpanAreas = 0;
            cHeightDefinedColumnSpanAreas  = 0;
        }
コード例 #14
0
        protected override void OnArrange()
        {
            base.OnArrange();
            PTS.FSSUBTRACKDETAILS fssubtrackdetails;
            PTS.Validate(PTS.FsQuerySubtrackDetails(base.PtsContext.Context, this._paraHandle.Value, out fssubtrackdetails));
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

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

            if (fssubtrackdetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION[] arrayParaDesc;
                PtsHelper.ParaListFromSubtrack(base.PtsContext, this._paraHandle.Value, ref fssubtrackdetails, out arrayParaDesc);
                PtsHelper.ArrangeParaList(base.PtsContext, fssubtrackdetails.fsrc, arrayParaDesc, fswdirTrack);
            }
        }
コード例 #15
0
        internal override void FormatFloaterContentFinite(
            FloaterBaseParaClient paraClient,   // IN:
            IntPtr pbrkrecIn,                   // IN:  break record---use if !IntPtr.Zero
            int fBRFromPreviousPage,            // IN:  break record was created on previous page
            IntPtr footnoteRejector,            // IN:
            int fEmptyOk,                       // IN:  is it OK not to add anything?
            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
            PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn,
            // IN: suppress breaks at track start?
            out PTS.FSFMTR fsfmtr,              // OUT: result of formatting
            out IntPtr pfsFloatContent,         // OUT: opaque for PTS pointer pointer to formatted content
            out IntPtr pbrkrecOut,              // OUT: pointer to the floater content break record
            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)));

            int subpageWidth, subpageHeight;
            int dvrTopSpace;
            int cColumns;

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

            Invariant.Assert(paraClient is FloaterParaClient);

            // If horizontal alignment is Stretch and we are not formatting at max width,
            // we cannot proceed.
            if (IsFloaterRejected(PTS.ToBoolean(fAtMaxWidth), TextDpi.FromTextDpi(durAvailable)))
            {
                durFloaterWidth = dvrFloaterHeight = 0;
                cPolygons       = cVertices = 0;
                fsfmtr          = new PTS.FSFMTR();
                fsfmtr.kstop    = PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace;
                fsfmtr.fContainsItemThatStoppedBeforeFootnote = PTS.False;
                fsfmtr.fForcedProgress = PTS.False;
                fsbbox          = new PTS.FSBBOX();
                fsbbox.fDefined = PTS.False;
                pbrkrecOut      = IntPtr.Zero;
                pfsFloatContent = IntPtr.Zero;
            }
            else
            {
                // When formatting bottomless page, PTS may format paragraphs as finite. This happens
                // in case of multiple columns. In this case make sure that height is not too big.
                if (!StructuralCache.CurrentFormatContext.FinitePage)
                {
                    if (Double.IsInfinity(StructuralCache.CurrentFormatContext.PageHeight))
                    {
                        if (dvrAvailable > PTS.dvBottomUndefined / 2)
                        {
                            dvrAvailable = Math.Min(dvrAvailable, PTS.dvBottomUndefined / 2);
                            fEmptyOk     = PTS.False;
                        }
                    }
                    else
                    {
                        dvrAvailable = Math.Min(dvrAvailable, TextDpi.ToTextDpi(StructuralCache.CurrentFormatContext.PageHeight));
                    }
                }

                // 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 height
                mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);

                // We do not mirror margin as it's used to dist text left and right, and is unnecessary.
                // Clip Floater.Width to available width
                specifiedWidth = CalculateWidth(TextDpi.FromTextDpi(durAvailable));
                AdjustDurAvailable(specifiedWidth, ref durAvailable, out subpageWidth);
                subpageHeight        = Math.Max(1, dvrAvailable - (mbp.MBPTop + mbp.MBPBottom));
                fsrcSubpageMargin    = new PTS.FSRECT();
                fsrcSubpageMargin.du = subpageWidth;
                fsrcSubpageMargin.dv = subpageHeight;

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

                // Format subpage
                CreateSubpageFiniteHelper(PtsContext, pbrkrecIn, fBRFromPreviousPage, _mainTextSegment.Handle,
                                          footnoteRejector, fEmptyOk, PTS.True, fswdir, subpageWidth, subpageHeight,
                                          ref fsrcSubpageMargin, cColumns, columnInfoCollection, PTS.False, fsksuppresshardbreakbeforefirstparaIn,
                                          out fsfmtr, out pfsFloatContent,
                                          out pbrkrecOut, out dvrFloaterHeight, out fsbbox, out pmcsclientOut, out dvrTopSpace);

                // Initialize subpage metrics
                if (fsfmtr.kstop >= PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace)   // No progress or collision
                {
                    Debug.Assert(pmcsclientOut == IntPtr.Zero);
                    durFloaterWidth = dvrFloaterHeight = 0;
                    cPolygons       = cVertices = 0;
                    //pbrkrecpara = IntPtr.Zero;
                }
                else
                {
                    // 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 max 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);
                                pfsFloatContent = IntPtr.Zero;
                            }
                            if (pbrkrecOut != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpageBreakRecord(PtsContext.Context, pbrkrecOut), PtsContext);
                                pbrkrecOut = IntPtr.Zero;
                            }
                            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                     = fsbbox.fsrc.du + 1; // add 1/300px to avoid rounding errors
                            fsrcSubpageMargin.du             = subpageWidth;
                            fsrcSubpageMargin.dv             = subpageHeight;
                            columnInfoCollection[0].durWidth = subpageWidth;
                            CreateSubpageFiniteHelper(PtsContext, pbrkrecIn, fBRFromPreviousPage, _mainTextSegment.Handle,
                                                      footnoteRejector, fEmptyOk, PTS.True, fswdir, subpageWidth, subpageHeight,
                                                      ref fsrcSubpageMargin, cColumns, columnInfoCollection, PTS.False, fsksuppresshardbreakbeforefirstparaIn,
                                                      out fsfmtr, out pfsFloatContent,
                                                      out pbrkrecOut, out dvrFloaterHeight, out fsbbox, out pmcsclientOut, out dvrTopSpace);
                        }
                    }
                    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. Add margin values here since we do not use
                    // distance to text anymore
                    durFloaterWidth = subpageWidth + mbp.MBPLeft + mbp.MBPRight;

                    // Add back all MBP values since we do not use dist to text
                    dvrFloaterHeight += mbp.MBPTop + mbp.MBPBottom;
                    // Check if floater width fits in available width. It may exceed available width because borders and
                    // padding are added.


                    fsbbox.fsrc.u   = 0;
                    fsbbox.fsrc.v   = 0;
                    fsbbox.fsrc.du  = durFloaterWidth;
                    fsbbox.fsrc.dv  = dvrFloaterHeight;
                    fsbbox.fDefined = PTS.True;

                    // Tight wrap is disabled for now.
                    cPolygons = cVertices = 0;

                    if (durFloaterWidth > durAvailable || dvrFloaterHeight > dvrAvailable)
                    {
                        if (PTS.ToBoolean(fEmptyOk))
                        {
                            // Get rid of any previous formatting
                            if (pfsFloatContent != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpage(PtsContext.Context, pfsFloatContent), PtsContext);
                                pfsFloatContent = IntPtr.Zero;
                            }
                            if (pbrkrecOut != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpageBreakRecord(PtsContext.Context, pbrkrecOut), PtsContext);
                                pbrkrecOut = IntPtr.Zero;
                            }
                            cPolygons    = cVertices = 0;
                            fsfmtr.kstop = PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace;
                        }
                        else
                        {
                            fsfmtr.fForcedProgress = PTS.True;
                        }
                    }
                }
            }

            // Update handle to PTS subpage.
            ((FloaterParaClient)paraClient).SubpageHandle = pfsFloatContent;
        }
コード例 #16
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;
        }
コード例 #17
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();
            }
            uint           num                   = PTS.FlowDirectionToFswdir((FlowDirection)base.Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty));
            Brush          backgroundBrush       = (Brush)base.Paragraph.Element.GetValue(TextElement.BackgroundProperty);
            TextProperties defaultTextProperties = new TextProperties(base.Paragraph.Element, StaticTextPointer.Null, false, false, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

            if (fssubtrackdetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION[] array;
                PtsHelper.ParaListFromSubtrack(base.PtsContext, this._paraHandle.Value, ref fssubtrackdetails, out array);
                using (DrawingContext drawingContext = this._visual.RenderOpen())
                {
                    this._visual.DrawBackgroundAndBorderIntoContext(drawingContext, backgroundBrush, mbpInfo.BorderBrush, mbpInfo.Border, this._rect.FromTextDpi(), this.IsFirstChunk, this.IsLastChunk);
                    ListMarkerLine listMarkerLine = new ListMarkerLine(base.Paragraph.StructuralCache.TextFormatterHost, this);
                    int            num2           = 0;
                    for (int i = 0; i < fssubtrackdetails.cParas; i++)
                    {
                        List           list           = base.Paragraph.Element as List;
                        BaseParaClient baseParaClient = base.PtsContext.HandleToObject(array[i].pfsparaclient) as BaseParaClient;
                        PTS.ValidateHandle(baseParaClient);
                        if (i == 0)
                        {
                            num2 = list.GetListItemIndex(baseParaClient.Paragraph.Element as ListItem);
                        }
                        if (baseParaClient.IsFirstChunk)
                        {
                            int firstTextLineBaseline = baseParaClient.GetFirstTextLineBaseline();
                            if (base.PageFlowDirection != base.ThisFlowDirection)
                            {
                                drawingContext.PushTransform(new MatrixTransform(-1.0, 0.0, 0.0, 1.0, TextDpi.FromTextDpi(2 * baseParaClient.Rect.u + baseParaClient.Rect.du), 0.0));
                            }
                            int index;
                            if (2147483647 - i < num2)
                            {
                                index = int.MaxValue;
                            }
                            else
                            {
                                index = num2 + i;
                            }
                            LineProperties lineProps = new LineProperties(base.Paragraph.Element, base.Paragraph.StructuralCache.FormattingOwner, defaultTextProperties, new MarkerProperties(list, index));
                            listMarkerLine.FormatAndDrawVisual(drawingContext, lineProps, baseParaClient.Rect.u, firstTextLineBaseline);
                            if (base.PageFlowDirection != base.ThisFlowDirection)
                            {
                                drawingContext.Pop();
                            }
                        }
                    }
                    listMarkerLine.Dispose();
                }
                PtsHelper.UpdateParaListVisuals(base.PtsContext, this._visual.Children, fskupdInherited, array);
                return;
            }
            this._visual.Children.Clear();
        }
コード例 #18
0
        internal void UpdateBottomlessPara(IntPtr pfspara, ContainerParaClient paraClient, int iArea, IntPtr pfsgeom, int fSuppressTopSpace, uint fswdir, int urTrack, int durTrack, int vrTrack, MarginCollapsingState mcs, PTS.FSKCLEAR fskclearIn, int fInterruptable, out PTS.FSFMTRBL fsfmtrbl, out int dvrUsed, out PTS.FSBBOX fsbbox, out IntPtr pmcsclientOut, out PTS.FSKCLEAR fskclearOut, out int dvrTopSpace, out int fPageBecomesUninterruptable)
        {
            uint    num     = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);
            MarginCollapsingState marginCollapsingState;
            int num2;

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

            try
            {
                PTS.Validate(PTS.FsUpdateBottomlessSubtrack(base.PtsContext.Context, pfspara, base.Handle, iArea, pfsgeom, fSuppressTopSpace, num, ur, dur, num4, (marginCollapsingState != null) ? marginCollapsingState.Handle : IntPtr.Zero, fskclearIn, fInterruptable, out fsfmtrbl, out dvrUsed, out fsbbox, out pmcsclientOut, out fskclearOut, out num3, out fPageBecomesUninterruptable), base.PtsContext);
            }
            finally
            {
                if (marginCollapsingState != null)
                {
                    marginCollapsingState.Dispose();
                    marginCollapsingState = null;
                }
            }
            if (fsfmtrbl != PTS.FSFMTRBL.fmtrblCollision)
            {
                if (pmcsclientOut != IntPtr.Zero)
                {
                    marginCollapsingState = (base.PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState);
                    PTS.ValidateHandle(marginCollapsingState);
                    pmcsclientOut = IntPtr.Zero;
                }
                MarginCollapsingState marginCollapsingState2;
                int num5;
                MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbpInfo, marginCollapsingState, out marginCollapsingState2, out num5);
                pmcsclientOut = ((marginCollapsingState2 != null) ? marginCollapsingState2.Handle : IntPtr.Zero);
                if (marginCollapsingState != null)
                {
                    marginCollapsingState.Dispose();
                    marginCollapsingState = null;
                }
                dvrTopSpace = ((mbpInfo.BPTop != 0) ? num2 : num3);
                dvrUsed    += num4 - vrTrack + num5 + mbpInfo.BPBottom;
            }
            else
            {
                pfspara     = IntPtr.Zero;
                dvrTopSpace = 0;
            }
            fsbbox.fsrc.u  = fsbbox.fsrc.u - mbpInfo.MBPLeft;
            fsbbox.fsrc.du = fsbbox.fsrc.du + (mbpInfo.MBPLeft + mbpInfo.MBPRight);
            if (num != fswdir)
            {
                PTS.FSRECT pageRect2 = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(num, ref pageRect2, ref fsbbox, fswdir, out fsbbox));
            }
            paraClient.SetChunkInfo(true, true);
        }
コード例 #19
0
ファイル: SubpageParagraph.cs プロジェクト: yk2012985/wpf
        internal unsafe void UpdateBottomlessPara(
            IntPtr pfspara,                      // IN:  pointer to the para data
            SubpageParaClient paraClient,        // IN:
            int fSuppressTopSpace,               // IN:  suppress empty space at the top of the page
            uint fswdir,                         // IN:  current direction
            int urTrack,                         // IN:  u of bootomless rectangle to fill
            int durTrack,                        // IN:  du of bootomless rectangle to fill
            int vrTrack,                         // IN:  v of bootomless rectangle to fill
            MarginCollapsingState mcs,           // IN:  input margin collapsing state
            PTS.FSKCLEAR fskclearIn,             // IN:  clear property that must be satisfied
            int fInterruptable,                  // IN:  formatting can be interrupted
            out PTS.FSFMTRBL fsfmtrbl,           // OUT: result of formatting the paragraph
            out int dvrUsed,                     // OUT: vertical space used by the para
            out PTS.FSBBOX fsbbox,               // OUT: para BBox
            out IntPtr pmcsclientOut,            // OUT: margin collapsing state at the bottom
            out PTS.FSKCLEAR fskclearOut,        // OUT: ClearIn for the next paragraph
            out int dvrTopSpace,                 // OUT: top space due to collapsed margin
            out int fPageBecomesUninterruptable) // OUT: interruption is prohibited from now on
        {
            int     subpageWidth, urSubpageMargin, durSubpageMargin, vrSubpageMargin;
            int     cColumns;
            int     marginTop, marginBottom;
            MbpInfo mbp;
            MarginCollapsingState mcsSubpage, mcsBottom;

            PTS.FSCOLUMNINFO[] columnInfoCollection;
            uint fswdirSubpage = PTS.FlowDirectionToFswdir(((FlowDirection)Element.GetValue(FrameworkElement.FlowDirectionProperty)));

            // Initialize the subpage size and its margin.
            subpageWidth    = durTrack;
            urSubpageMargin = vrSubpageMargin = 0;

            // Set clear property
            Invariant.Assert(Element is TableCell || Element is AnchoredBlock);
            fskclearIn = PTS.WrapDirectionToFskclear((WrapDirection)Element.GetValue(Block.ClearFloatersProperty));

            // Take into account MBPs and modify subpage metrics,
            // and make sure that subpage is at least 1 unit wide (cannot measure at width <= 0)
            // NOTE: Do not suppress top space for bottomles pages.
            mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);

            if (fswdirSubpage != fswdir)
            {
                PTS.FSRECT fsrcToFillSubpage = new PTS.FSRECT(urTrack, 0, durTrack, 0);
                PTS.FSRECT pageRect          = StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(fswdir, ref pageRect, ref fsrcToFillSubpage, fswdirSubpage, out fsrcToFillSubpage));

                urTrack  = fsrcToFillSubpage.u;
                durTrack = fsrcToFillSubpage.du;

                mbp.MirrorMargin();
            }

            subpageWidth = Math.Max(1, subpageWidth - (mbp.MBPLeft + mbp.MBPRight));
            MarginCollapsingState.CollapseTopMargin(PtsContext, mbp, mcs, out mcsSubpage, out marginTop);
            // Destroy top margin collapsing state (not needed anymore).
            if (mcsSubpage != null)
            {
                mcsSubpage.Dispose();
                mcsSubpage = null;
            }
            durSubpageMargin = subpageWidth;

            // Initialize column info
            // For bottomles spara, limit line height to the height of the current format context in structural cache.
            ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(_element);
            double     lineHeight     = DynamicPropertyReader.GetLineHeightValue(_element);
            double     pageFontSize   = (double)_structuralCache.PropertyOwner.GetValue(Block.FontSizeProperty);
            FontFamily pageFontFamily = (FontFamily)_structuralCache.PropertyOwner.GetValue(Block.FontFamilyProperty);

            // Get columns info, setting ownerIsFlowDocument flag to false. A flow document should not be formatted as a subpage and we
            // do not want default column widths to be set on TableCells and floaters
            cColumns             = PtsHelper.CalculateColumnCount(columnProperties, lineHeight, TextDpi.FromTextDpi(subpageWidth), pageFontSize, pageFontFamily, false);
            columnInfoCollection = new PTS.FSCOLUMNINFO[cColumns];
            fixed(PTS.FSCOLUMNINFO *rgColumnInfo = columnInfoCollection)
            {
                PtsHelper.GetColumnsInfo(columnProperties, lineHeight, TextDpi.FromTextDpi(subpageWidth), pageFontSize, pageFontFamily, cColumns, rgColumnInfo, false);
            }

            StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(subpageWidth), TextDpi.MaxWidth),
                                                                 new Thickness(),
                                                                 true,
                                                                 false);

            // Create subpage
            fixed(PTS.FSCOLUMNINFO *rgColumnInfo = columnInfoCollection)
            {
                PTS.Validate(PTS.FsUpdateBottomlessSubpage(PtsContext.Context, pfspara, _mainTextSegment.Handle, fSuppressTopSpace,
                                                           fswdir, subpageWidth, urSubpageMargin, durSubpageMargin, vrSubpageMargin,
                                                           cColumns, rgColumnInfo, 0, null, null, 0, null, null, PTS.FromBoolean(true),
                                                           out fsfmtrbl, out dvrUsed, out fsbbox, out pmcsclientOut, out dvrTopSpace,
                                                           out fPageBecomesUninterruptable), PtsContext);
            }

            StructuralCache.CurrentFormatContext.PopPageData();

            fskclearOut = PTS.FSKCLEAR.fskclearNone;

            if (fsfmtrbl != PTS.FSFMTRBL.fmtrblCollision)
            {
                // Bottom margin collapsing:
                // (1) retrieve mcs from the subtrack
                // (2) do margin collapsing; create a new margin collapsing state
                if (pmcsclientOut != IntPtr.Zero)
                {
                    mcsSubpage = PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState;
                    PTS.ValidateHandle(mcsSubpage);
                    pmcsclientOut = IntPtr.Zero;
                }
                MarginCollapsingState.CollapseBottomMargin(PtsContext, mbp, mcsSubpage, out mcsBottom, out marginBottom);
                pmcsclientOut = (mcsBottom != null) ? mcsBottom.Handle : IntPtr.Zero;

                // Since MCS returned by PTS is never passed back, destroy MCS provided by PTS.
                // If necessary, new MCS is created and passed back to PTS.
                if (mcsSubpage != null)
                {
                    mcsSubpage.Dispose();
                    mcsSubpage = null;
                }

                if (PTS.ToBoolean(fsbbox.fDefined))
                {
                    // Workaround for PTS bug 860: get max of the page rect and
                    // bounding box of the page.
                    dvrUsed  = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
                    durTrack = Math.Max(durTrack, fsbbox.fsrc.du + fsbbox.fsrc.u);
                }

                // Take into account MBPs and modify subtrack metrics
                dvrTopSpace = (mbp.BPTop != 0) ? marginTop : dvrTopSpace;
                dvrUsed    += (marginTop + mbp.BPTop) + (marginBottom + mbp.BPBottom);

                // Update bounding box
                fsbbox.fsrc.u  = urTrack + mbp.MarginLeft;
                fsbbox.fsrc.v  = vrTrack + dvrTopSpace;
                fsbbox.fsrc.du = Math.Max(durTrack - (mbp.MarginLeft + mbp.MarginRight), 0);
                fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
            }
            else
            {
                Debug.Assert(pmcsclientOut == IntPtr.Zero);
                pfspara = IntPtr.Zero;
                dvrUsed = dvrTopSpace = 0;
            }


            if (fswdirSubpage != fswdir)
            {
                PTS.FSRECT pageRect = StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(fswdirSubpage, ref pageRect, ref fsbbox, fswdir, out fsbbox));
            }

            // Update information about first/last chunk. In bottomless scenario
            // paragraph is not broken, so there is only one chunk.
            paraClient.SetChunkInfo(true, true);
        }
コード例 #20
0
        internal unsafe void UpdateBottomlessPara(IntPtr pfspara, SubpageParaClient paraClient, int fSuppressTopSpace, uint fswdir, int urTrack, int durTrack, int vrTrack, MarginCollapsingState mcs, PTS.FSKCLEAR fskclearIn, int fInterruptable, out PTS.FSFMTRBL fsfmtrbl, out int dvrUsed, out PTS.FSBBOX fsbbox, out IntPtr pmcsclientOut, out PTS.FSKCLEAR fskclearOut, out int dvrTopSpace, out int fPageBecomesUninterruptable)
        {
            uint num  = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));
            int  num2 = durTrack;
            int  urMargin;
            int  vrMargin = urMargin = 0;

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

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

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

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

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

            base.StructuralCache.CurrentFormatContext.PopPageData();
            fskclearOut = PTS.FSKCLEAR.fskclearNone;
            if (fsfmtrbl != PTS.FSFMTRBL.fmtrblCollision)
            {
                if (pmcsclientOut != IntPtr.Zero)
                {
                    marginCollapsingState = (base.PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState);
                    PTS.ValidateHandle(marginCollapsingState);
                    pmcsclientOut = IntPtr.Zero;
                }
                MarginCollapsingState marginCollapsingState2;
                int num5;
                MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbpInfo, marginCollapsingState, out marginCollapsingState2, out num5);
                pmcsclientOut = ((marginCollapsingState2 != null) ? marginCollapsingState2.Handle : IntPtr.Zero);
                if (marginCollapsingState != null)
                {
                    marginCollapsingState.Dispose();
                    marginCollapsingState = null;
                }
                if (PTS.ToBoolean(fsbbox.fDefined))
                {
                    dvrUsed  = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
                    durTrack = Math.Max(durTrack, fsbbox.fsrc.du + fsbbox.fsrc.u);
                }
                dvrTopSpace    = ((mbpInfo.BPTop != 0) ? num3 : dvrTopSpace);
                dvrUsed       += num3 + mbpInfo.BPTop + (num5 + mbpInfo.BPBottom);
                fsbbox.fsrc.u  = urTrack + mbpInfo.MarginLeft;
                fsbbox.fsrc.v  = vrTrack + dvrTopSpace;
                fsbbox.fsrc.du = Math.Max(durTrack - (mbpInfo.MarginLeft + mbpInfo.MarginRight), 0);
                fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
            }
            else
            {
                pfspara = IntPtr.Zero;
                dvrUsed = (dvrTopSpace = 0);
            }
            if (num != fswdir)
            {
                PTS.FSRECT pageRect2 = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(num, ref pageRect2, ref fsbbox, fswdir, out fsbbox));
            }
            paraClient.SetChunkInfo(true, true);
        }
コード例 #21
0
        internal unsafe void FormatParaFinite(SubpageParaClient paraClient, IntPtr pbrkrecIn, int fBRFromPreviousPage, IntPtr footnoteRejector, int fEmptyOk, int fSuppressTopSpace, uint fswdir, ref PTS.FSRECT fsrcToFill, MarginCollapsingState mcs, PTS.FSKCLEAR fskclearIn, PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn, out PTS.FSFMTR fsfmtr, out IntPtr pfspara, out IntPtr pbrkrecOut, out int dvrUsed, out PTS.FSBBOX fsbbox, out IntPtr pmcsclientOut, out PTS.FSKCLEAR fskclearOut, out int dvrTopSpace)
        {
            uint num = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));

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

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

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

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

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

            base.StructuralCache.CurrentFormatContext.PopPageData();
            fskclearOut = PTS.FSKCLEAR.fskclearNone;
            if (PTS.ToBoolean(fsbbox.fDefined))
            {
                dvrUsed       = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
                fsrcToFill.du = Math.Max(fsrcToFill.du, fsbbox.fsrc.du + fsbbox.fsrc.u);
            }
            if (pbrkrecIn == IntPtr.Zero)
            {
                dvrTopSpace = ((mbpInfo.BPTop != 0) ? num4 : dvrTopSpace);
                dvrUsed    += num4 + mbpInfo.BPTop;
            }
            if (pmcsclientOut != IntPtr.Zero)
            {
                marginCollapsingState = (base.PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState);
                PTS.ValidateHandle(marginCollapsingState);
                pmcsclientOut = IntPtr.Zero;
            }
            if (fsfmtr.kstop >= PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace)
            {
                dvrUsed = (dvrTopSpace = 0);
            }
            else
            {
                if (fsfmtr.kstop == PTS.FSFMTRKSTOP.fmtrGoalReached)
                {
                    MarginCollapsingState marginCollapsingState2;
                    int num6;
                    MarginCollapsingState.CollapseBottomMargin(base.PtsContext, mbpInfo, marginCollapsingState, out marginCollapsingState2, out num6);
                    pmcsclientOut = ((marginCollapsingState2 != null) ? marginCollapsingState2.Handle : IntPtr.Zero);
                    if (pmcsclientOut == IntPtr.Zero)
                    {
                        dvrUsed += num6 + mbpInfo.BPBottom;
                    }
                }
                fsbbox.fsrc.u  = fsrcToFill.u + mbpInfo.MarginLeft;
                fsbbox.fsrc.v  = fsrcToFill.v + dvrTopSpace;
                fsbbox.fsrc.du = Math.Max(fsrcToFill.du - (mbpInfo.MarginLeft + mbpInfo.MarginRight), 0);
                fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
            }
            if (num != fswdir)
            {
                PTS.FSRECT pageRect2 = base.StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(num, ref pageRect2, ref fsbbox, fswdir, out fsbbox));
            }
            if (marginCollapsingState != null)
            {
                marginCollapsingState.Dispose();
                marginCollapsingState = null;
            }
            paraClient.SetChunkInfo(pbrkrecIn == IntPtr.Zero, pbrkrecOut == IntPtr.Zero);
        }
コード例 #22
0
ファイル: SubpageParagraph.cs プロジェクト: yk2012985/wpf
        internal unsafe void FormatParaFinite(
            SubpageParaClient paraClient,       // IN:
            IntPtr pbrkrecIn,                   // IN:  break record---use if !NULL
            int fBRFromPreviousPage,            // IN:  break record was created on previous page
            IntPtr footnoteRejector,            // IN:
            int fEmptyOk,                       // IN:  is it OK not to add anything?
            int fSuppressTopSpace,              // IN:  suppress empty space at the top of the page
            uint fswdir,                        // IN:  current direction
            ref PTS.FSRECT fsrcToFill,          // IN:  rectangle to fill
            MarginCollapsingState mcs,          // IN:  input margin collapsing state
            PTS.FSKCLEAR fskclearIn,            // IN:  clear property that must be satisfied
            PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn,
            // IN: suppress breaks at track start?
            out PTS.FSFMTR fsfmtr,              // OUT: result of formatting the paragraph
            out IntPtr pfspara,                 // OUT: pointer to the para data
            out IntPtr pbrkrecOut,              // OUT: pointer to the para break record
            out int dvrUsed,                    // OUT: vertical space used by the para
            out PTS.FSBBOX fsbbox,              // OUT: para BBox
            out IntPtr pmcsclientOut,           // OUT: margin collapsing state at the bottom
            out PTS.FSKCLEAR fskclearOut,       // OUT: ClearIn for the next paragraph
            out int dvrTopSpace)                // OUT: top space due to collapsed margin
        {
            uint fswdirSubpage = PTS.FlowDirectionToFswdir(((FlowDirection)Element.GetValue(FrameworkElement.FlowDirectionProperty)));

            int     subpageWidth, subpageHeight;
            int     cColumns;
            int     marginTop, marginBottom;
            MbpInfo mbp;
            MarginCollapsingState mcsSubpage, mcsBottom;

            PTS.FSRECT          fsrcSubpageMargin;
            PTS.FSCOLUMNINFO [] columnInfoCollection;

            // Currently it is possible to get MCS and BR in following situation:
            // At the end of the page there is a paragraph with delayed figure, so the figure
            // gets delayed to the next page. But part of the next paragraph fits in the page,
            // so it gets broken. PTS creates BR with delayed figure and broken para.
            // PTS will format the next page starting from delayed figure, which can produce MCS.
            // So when the next paragraph is continued from BR, it has MCS.
            // This problem is currently investigated by PTS team: PTSLS bug 915.
            // For now, MCS gets ignored here.
            //Debug.Assert(pbrkrecIn == IntPtr.Zero || mcs == null, "Broken paragraph cannot have margin collapsing state.");
            if (mcs != null && pbrkrecIn != IntPtr.Zero)
            {
                mcs = null;
            }

            // Initialize the subpage size and its margin.
            fsrcSubpageMargin = new PTS.FSRECT();
            subpageWidth      = fsrcToFill.du;
            subpageHeight     = fsrcToFill.dv;

            // Set clear property
            Invariant.Assert(Element is TableCell || Element is AnchoredBlock);
            fskclearIn = PTS.WrapDirectionToFskclear((WrapDirection)Element.GetValue(Block.ClearFloatersProperty));

            // Take into account MBPs and modify subpage metrics,
            // and make sure that subpage is at least 1 unit wide (cannot measure at width <= 0)
            marginTop  = 0;
            mcsSubpage = null;

            // Get MBP info. Since subpage height and width must be at least 1, the max size for MBP is subpage dimensions less 1
            mbp = MbpInfo.FromElement(Element, StructuralCache.TextFormatterHost.PixelsPerDip);

            if (fswdirSubpage != fswdir)
            {
                PTS.FSRECT pageRect = StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformRectangle(fswdir, ref pageRect, ref fsrcToFill, fswdirSubpage, out fsrcToFill));
                mbp.MirrorMargin();
            }

            subpageWidth = Math.Max(1, subpageWidth - (mbp.MBPLeft + mbp.MBPRight));
            if (pbrkrecIn == IntPtr.Zero)
            {
                // Top margin collapsing. If suppresing top space, top margin is always 0.
                MarginCollapsingState.CollapseTopMargin(PtsContext, mbp, mcs, out mcsSubpage, out marginTop);
                if (PTS.ToBoolean(fSuppressTopSpace))
                {
                    marginTop = 0;
                }
                subpageHeight = Math.Max(1, subpageHeight - (marginTop + mbp.BPTop));
                // Destroy top margin collapsing state (not needed anymore).
                if (mcsSubpage != null)
                {
                    mcsSubpage.Dispose();
                    mcsSubpage = null;
                }
            }
            else
            {
                Debug.Assert(fSuppressTopSpace == 1, "Top space should be always suppressed at the top of broken paragraph.");
            }
            fsrcSubpageMargin.du = subpageWidth;
            fsrcSubpageMargin.dv = subpageHeight;

            // Initialize column info
            ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(_element);
            double     lineHeight     = DynamicPropertyReader.GetLineHeightValue(_element);
            double     pageFontSize   = (double)_structuralCache.PropertyOwner.GetValue(Block.FontSizeProperty);
            FontFamily pageFontFamily = (FontFamily)_structuralCache.PropertyOwner.GetValue(Block.FontFamilyProperty);

            // Get columns info, setting ownerIsFlowDocument flag to false. A flow document should not be formatted as a subpage and we
            // do not want default column widths to be set on TableCells and floaters
            cColumns             = PtsHelper.CalculateColumnCount(columnProperties, lineHeight, TextDpi.FromTextDpi(subpageWidth), pageFontSize, pageFontFamily, false);
            columnInfoCollection = new PTS.FSCOLUMNINFO[cColumns];
            fixed(PTS.FSCOLUMNINFO *rgColumnInfo = columnInfoCollection)
            {
                PtsHelper.GetColumnsInfo(columnProperties, lineHeight, TextDpi.FromTextDpi(subpageWidth), pageFontSize, pageFontFamily, cColumns, rgColumnInfo, false);
            }

            // Format subpage
            StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(subpageWidth), TextDpi.FromTextDpi(subpageHeight)),
                                                                 new Thickness(),
                                                                 false,
                                                                 true);

            fixed(PTS.FSCOLUMNINFO *rgColumnInfo = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageFinite(PtsContext.Context, pbrkrecIn, fBRFromPreviousPage, _mainTextSegment.Handle,
                                                       footnoteRejector, fEmptyOk, fSuppressTopSpace, fswdir, subpageWidth, subpageHeight,
                                                       ref fsrcSubpageMargin, cColumns, rgColumnInfo, PTS.False,
                                                       0, null, null, 0, null, null, PTS.FromBoolean(false),
                                                       fsksuppresshardbreakbeforefirstparaIn,
                                                       out fsfmtr, out pfspara, out pbrkrecOut, out dvrUsed, out fsbbox, out pmcsclientOut, out dvrTopSpace), PtsContext);
            }

            StructuralCache.CurrentFormatContext.PopPageData();

            fskclearOut = PTS.FSKCLEAR.fskclearNone;

            if (PTS.ToBoolean(fsbbox.fDefined))
            {
                // Workaround for PTS bug 860: get max of the page rect and
                // bounding box of the page.
                dvrUsed       = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
                fsrcToFill.du = Math.Max(fsrcToFill.du, fsbbox.fsrc.du + fsbbox.fsrc.u);
            }

            if (pbrkrecIn == IntPtr.Zero) // if first chunk
            {
                // Take into account MBPs and modify subpage metrics
                dvrTopSpace = (mbp.BPTop != 0) ? marginTop : dvrTopSpace;
                dvrUsed    += (marginTop + mbp.BPTop);
            }

            if (pmcsclientOut != IntPtr.Zero)
            {
                mcsSubpage = PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState;
                PTS.ValidateHandle(mcsSubpage);
                pmcsclientOut = IntPtr.Zero;
            }

            // Initialize subpage metrics
            if (fsfmtr.kstop >= PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace)   // No progress or collision
            {
                dvrUsed = dvrTopSpace = 0;
                //pbrkrecOut = IntPtr.Zero;
                //pfspara = IntPtr.Zero;
                //pmcsclientOut = IntPtr.Zero;
            }
            else
            {
                if (fsfmtr.kstop == PTS.FSFMTRKSTOP.fmtrGoalReached)
                {
                    // Bottom margin collapsing:
                    // (a) retrieve mcs from the subpage
                    // (b) do margin collapsing; create a new margin collapsing state
                    // There is no bottom margin collapsing if paragraph will be continued (output break record is not null).
                    MarginCollapsingState.CollapseBottomMargin(PtsContext, mbp, mcsSubpage, out mcsBottom, out marginBottom);
                    pmcsclientOut = (mcsBottom != null) ? mcsBottom.Handle : IntPtr.Zero;

                    if (pmcsclientOut == IntPtr.Zero) // if last chunk
                    {
                        dvrUsed += marginBottom + mbp.BPBottom;
                    }
                }

                // Update bounding box
                fsbbox.fsrc.u  = fsrcToFill.u + mbp.MarginLeft;
                fsbbox.fsrc.v  = fsrcToFill.v + dvrTopSpace;
                fsbbox.fsrc.du = Math.Max(fsrcToFill.du - (mbp.MarginLeft + mbp.MarginRight), 0);
                fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
            }

            if (fswdirSubpage != fswdir)
            {
                PTS.FSRECT pageRect = StructuralCache.CurrentFormatContext.PageRect;
                PTS.Validate(PTS.FsTransformBbox(fswdirSubpage, ref pageRect, ref fsbbox, fswdir, out fsbbox));
            }


            // Since MCS returned by PTS is never passed back, destroy MCS provided by PTS.
            // If necessary, new MCS is created and passed back to PTS (see above).
            if (mcsSubpage != null)
            {
                mcsSubpage.Dispose();
                mcsSubpage = null;
            }


            // Update information about first/last chunk
            paraClient.SetChunkInfo(pbrkrecIn == IntPtr.Zero, pbrkrecOut == IntPtr.Zero);
        }
コード例 #23
0
 internal void ArrangePage()
 {
     if (this.IsEmpty)
     {
         return;
     }
     this._section.UpdateSegmentLastFormatPositions();
     PTS.FSPAGEDETAILS fspagedetails;
     PTS.Validate(PTS.FsQueryPageDetails(this.PtsContext.Context, this._ptsPage.Value, out fspagedetails));
     if (PTS.ToBoolean(fspagedetails.fSimple))
     {
         this._section.StructuralCache.CurrentArrangeContext.PushNewPageData(this._pageContextOfThisPage, fspagedetails.u.simple.trackdescr.fsrc, this._finitePage);
         PtsHelper.ArrangeTrack(this.PtsContext, ref fspagedetails.u.simple.trackdescr, PTS.FlowDirectionToFswdir(this._section.StructuralCache.PageFlowDirection));
         this._section.StructuralCache.CurrentArrangeContext.PopPageData();
         return;
     }
     ErrorHandler.Assert(fspagedetails.u.complex.cFootnoteColumns == 0, ErrorHandler.NotSupportedFootnotes);
     if (fspagedetails.u.complex.cSections != 0)
     {
         PTS.FSSECTIONDESCRIPTION[] array;
         PtsHelper.SectionListFromPage(this.PtsContext, this._ptsPage.Value, ref fspagedetails, out array);
         for (int i = 0; i < array.Length; i++)
         {
             this.ArrangeSection(ref array[i]);
         }
     }
 }
コード例 #24
0
        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.
            MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

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

            uint fswdir = PTS.FlowDirectionToFswdir((FlowDirection)Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty));

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

            // This textProperties object is eventually used in creation of LineProperties, which leads to creation of a TextMarkerSource. TextMarkerSource relies on PixelsPerDip
            // from TextProperties, therefore it must be set here properly.
            TextProperties textProperties = new TextProperties(Paragraph.Element, StaticTextPointer.Null, false /* inline objects */, false /* get background */,
                                                               Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip);

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

                using (DrawingContext ctx = _visual.RenderOpen())
                {
                    _visual.DrawBackgroundAndBorderIntoContext(ctx, backgroundBrush, mbp.BorderBrush, mbp.Border, _rect.FromTextDpi(), IsFirstChunk, IsLastChunk);

                    // Get list of paragraphs
                    ListMarkerLine listMarkerLine           = new ListMarkerLine(Paragraph.StructuralCache.TextFormatterHost, this);
                    int            indexFirstParaInSubtrack = 0;

                    for (int index = 0; index < subtrackDetails.cParas; index++)
                    {
                        List list = Paragraph.Element as List;

                        BaseParaClient listItemParaClient = PtsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                        PTS.ValidateHandle(listItemParaClient);

                        if (index == 0)
                        {
                            indexFirstParaInSubtrack = list.GetListItemIndex(listItemParaClient.Paragraph.Element as ListItem);
                        }

                        if (listItemParaClient.IsFirstChunk)
                        {
                            int dvBaseline = listItemParaClient.GetFirstTextLineBaseline();

                            if (PageFlowDirection != ThisFlowDirection)
                            {
                                ctx.PushTransform(new MatrixTransform(-1.0, 0.0, 0.0, 1.0, TextDpi.FromTextDpi(2 * listItemParaClient.Rect.u + listItemParaClient.Rect.du), 0.0));
                            }

                            int adjustedIndex;
                            if (int.MaxValue - index < indexFirstParaInSubtrack)
                            {
                                adjustedIndex = int.MaxValue;
                            }
                            else
                            {
                                adjustedIndex = indexFirstParaInSubtrack + index;
                            }
                            LineProperties lineProps = new LineProperties(Paragraph.Element, Paragraph.StructuralCache.FormattingOwner, textProperties, new MarkerProperties(list, adjustedIndex));
                            listMarkerLine.FormatAndDrawVisual(ctx, lineProps, listItemParaClient.Rect.u, dvBaseline);

                            if (PageFlowDirection != ThisFlowDirection)
                            {
                                ctx.Pop();
                            }
                        }
                    }


                    listMarkerLine.Dispose();
                }

                // Render list of paragraphs
                PtsHelper.UpdateParaListVisuals(PtsContext, _visual.Children, fskupdInherited, arrayParaDesc);
            }
            else
            {
                _visual.Children.Clear();
            }
        }
コード例 #25
0
        internal void GetFigureProperties(
            FigureParaClient paraClient,        // IN:
            int fInTextLine,                    // IN:  it is attached to text line
            uint fswdir,                        // IN:  current direction
            int fBottomUndefined,               // IN:  bottom of page is not defined
            out int dur,                        // OUT: width of figure
            out int dvr,                        // OUT: height of figure
            out PTS.FSFIGUREPROPS fsfigprops,   // OUT: figure attributes
            out int cPolygons,                  // OUT: number of polygons
            out int cVertices,                  // OUT: total number of vertices in all polygons
            out int durDistTextLeft,            // OUT: distance to text from MinU side
            out int durDistTextRight,           // OUT: distance to text from MaxU side
            out int dvrDistTextTop,             // OUT: distance to text from MinV side
            out int dvrDistTextBottom)          // OUT: distance to text from MaxV side
        {
            Invariant.Assert(StructuralCache.CurrentFormatContext.FinitePage);

            uint fswdirPara = PTS.FlowDirectionToFswdir(((FlowDirection)Element.GetValue(FrameworkElement.FlowDirectionProperty)));

            IntPtr pfsFigureContent;

            PTS.FSBBOX fsbbox;
            int        cColumns;
            int        dvrTopSpace;

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

            Figure element = (Figure)Element;

            // Initialize the subpage size. PTS subpage margin is always set to 0 for Figures.
            // If width on figure is specified, use the specified value.
            // Border and padding of the figure is extracted from available subpage width.
            // We use StructuralCache.CurrentFormatContext's page dimensions as limiting values for figure MBP
            mbp = MbpInfo.FromElement(Element);
            // We do not mirror margin as it's used to dist text left and right, and is unnecessary.

            durDistTextLeft = durDistTextRight = dvrDistTextTop = dvrDistTextBottom = 0;

            // Calculate specified width. IsAuto flag is needed because Auto is formatted the same way as column and will
            // not return Double.NaN.
            bool   isWidthAuto;
            double specifiedWidth = FigureHelper.CalculateFigureWidth(StructuralCache, element,
                                                                      element.Width,
                                                                      out isWidthAuto);


            double anchorLimitedWidth = LimitTotalWidthFromAnchor(specifiedWidth, TextDpi.FromTextDpi(mbp.MarginLeft + mbp.MarginRight));
            int    subpageWidth       = Math.Max(1, TextDpi.ToTextDpi(anchorLimitedWidth) - (mbp.BPLeft + mbp.BPRight));

            // Calculate figure height, IsAuto flag is used as specifiedHeight will never be NaN.
            bool   isHeightAuto;
            double specifiedHeight = FigureHelper.CalculateFigureHeight(StructuralCache, element,
                                                                        element.Height,
                                                                        out isHeightAuto);

            double anchorLimitedHeight = LimitTotalHeightFromAnchor(specifiedHeight, TextDpi.FromTextDpi(mbp.MarginTop + mbp.MarginBottom));
            int    subpageHeight       = Math.Max(1, TextDpi.ToTextDpi(anchorLimitedHeight) - (mbp.BPTop + mbp.BPBottom));

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

            // Create subpage
            {
                PTS.FSFMTR fsfmtr;
                IntPtr     brParaOut;
                PTS.FSRECT marginRect = new PTS.FSRECT(0, 0, subpageWidth, subpageHeight);

                CreateSubpageFiniteHelper(PtsContext, IntPtr.Zero, PTS.False, _mainTextSegment.Handle, IntPtr.Zero, PTS.False, PTS.True,
                                          fswdir, subpageWidth, subpageHeight, ref marginRect,
                                          cColumns, columnInfoCollection, PTS.False,
                                          out fsfmtr, out pfsFigureContent, out brParaOut, out dvr, out fsbbox, out pmcsclientOut,
                                          out dvrTopSpace);

                if (brParaOut != IntPtr.Zero)
                {
                    PTS.Validate(PTS.FsDestroySubpageBreakRecord(PtsContext.Context, brParaOut));
                }
            }

            // PTS subpage does not support autosizing, but Figure 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.

            if (PTS.ToBoolean(fsbbox.fDefined))
            {
                if (fsbbox.fsrc.du < subpageWidth && isWidthAuto)
                {
                    // There is a need to reformat PTS subpage, so destroy any resourcces allocated by PTS
                    // during previous formatting.
                    if (pfsFigureContent != IntPtr.Zero)
                    {
                        PTS.Validate(PTS.FsDestroySubpage(PtsContext.Context, pfsFigureContent), 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 = fsbbox.fsrc.du + 1; // add 1/300px to avoid rounding errors
                    columnInfoCollection[0].durWidth = subpageWidth;

                    // Create subpage
                    PTS.FSFMTR fsfmtr;
                    IntPtr     brParaOut;
                    PTS.FSRECT marginRect = new PTS.FSRECT(0, 0, subpageWidth, subpageHeight);

                    CreateSubpageFiniteHelper(PtsContext, IntPtr.Zero, PTS.False, _mainTextSegment.Handle, IntPtr.Zero, PTS.False, PTS.True,
                                              fswdir, subpageWidth, subpageHeight, ref marginRect,
                                              cColumns, columnInfoCollection, PTS.False,
                                              out fsfmtr, out pfsFigureContent, out brParaOut, out dvr, out fsbbox, out pmcsclientOut,
                                              out dvrTopSpace);

                    if (brParaOut != IntPtr.Zero)
                    {
                        PTS.Validate(PTS.FsDestroySubpageBreakRecord(PtsContext.Context, brParaOut));
                    }
                }
            }
            else
            {
                subpageWidth = TextDpi.ToTextDpi(TextDpi.MinWidth);
            }


            // Get the size of the figure. For height PTS already reports calculated value.
            // But width is the same as subpage width. Include margins in dur since we are not using
            // distance to text anymore.
            dur = subpageWidth + mbp.MBPLeft + mbp.MBPRight;

            // 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;
            }

            dvr += mbp.MBPTop + mbp.MBPBottom;
            if (!isHeightAuto)
            {
                // Replace height with explicit height if specified, adding margins in addition to height
                // Border and padding are included in specified height but margins are external
                dvr = TextDpi.ToTextDpi(anchorLimitedHeight) + mbp.MarginTop + mbp.MarginBottom;
            }

            FigureHorizontalAnchor horzAnchor = element.HorizontalAnchor;
            FigureVerticalAnchor   vertAnchor = element.VerticalAnchor;

            fsfigprops.fskrefU = (PTS.FSKREF)(((int)horzAnchor) / 3);
            fsfigprops.fskrefV = (PTS.FSKREF)(((int)vertAnchor) / 3);
            fsfigprops.fskalfU = (PTS.FSKALIGNFIG)(((int)horzAnchor) % 3);
            fsfigprops.fskalfV = (PTS.FSKALIGNFIG)(((int)vertAnchor) % 3);

            // PTS does not allow to anchor delayed figures to 'Character'
            if (!PTS.ToBoolean(fInTextLine))
            {
                if (fsfigprops.fskrefU == PTS.FSKREF.fskrefChar)
                {
                    fsfigprops.fskrefU = PTS.FSKREF.fskrefMargin;
                    fsfigprops.fskalfU = PTS.FSKALIGNFIG.fskalfMin;
                }
                if (fsfigprops.fskrefV == PTS.FSKREF.fskrefChar)
                {
                    fsfigprops.fskrefV = PTS.FSKREF.fskrefMargin;
                    fsfigprops.fskalfV = PTS.FSKALIGNFIG.fskalfMin;
                }
            }

            // Always wrap text on both sides of the floater.
            fsfigprops.fskwrap       = PTS.WrapDirectionToFskwrap(element.WrapDirection);
            fsfigprops.fNonTextPlane = PTS.False;
            fsfigprops.fAllowOverlap = PTS.False;
            fsfigprops.fDelayable    = PTS.FromBoolean(element.CanDelayPlacement);

            // Tight wrap is disabled for now.
            cPolygons = cVertices = 0;

            // Update handle to PTS subpage.
            ((FigureParaClient)paraClient).SubpageHandle = pfsFigureContent;
        }
コード例 #26
0
        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)
        {
            uint num = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));

            Invariant.Assert(paraClient is FloaterParaClient);
            if (this.IsFloaterRejected(PTS.ToBoolean(fAtMaxWidth), TextDpi.FromTextDpi(durAvailable)))
            {
                durFloaterWidth  = durAvailable + 1;
                dvrFloaterHeight = dvrAvailable + 1;
                cPolygons        = (cVertices = 0);
                fsfmtrbl         = PTS.FSFMTRBL.fmtrblInterrupted;
                fsbbox           = default(PTS.FSBBOX);
                fsbbox.fDefined  = 0;
                pfsFloatContent  = IntPtr.Zero;
            }
            else
            {
                MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);
                double  num2    = this.CalculateWidth(TextDpi.FromTextDpi(durAvailable));
                int     num3;
                this.AdjustDurAvailable(num2, ref durAvailable, out num3);
                int durMargin = num3;
                int urMargin;
                int vrMargin             = urMargin = 0;
                int num4                 = 1;
                PTS.FSCOLUMNINFO[] array = new PTS.FSCOLUMNINFO[num4];
                array[0].durBefore = 0;
                array[0].durWidth  = num3;
                this.InvalidateMainTextSegment();
                IntPtr zero;
                int    num5;
                int    num6;
                this.CreateSubpageBottomlessHelper(base.PtsContext, this._mainTextSegment.Handle, 1, fswdir, num3, urMargin, durMargin, vrMargin, num4, array, out fsfmtrbl, out pfsFloatContent, out dvrFloaterHeight, out fsbbox, out zero, out num5, out num6);
                if (fsfmtrbl != PTS.FSFMTRBL.fmtrblCollision)
                {
                    if (PTS.ToBoolean(fsbbox.fDefined))
                    {
                        if (fsbbox.fsrc.du < num3 && double.IsNaN(num2) && this.HorizontalAlignment != HorizontalAlignment.Stretch)
                        {
                            if (pfsFloatContent != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpage(base.PtsContext.Context, pfsFloatContent), base.PtsContext);
                            }
                            if (zero != IntPtr.Zero)
                            {
                                MarginCollapsingState marginCollapsingState = base.PtsContext.HandleToObject(zero) as MarginCollapsingState;
                                PTS.ValidateHandle(marginCollapsingState);
                                marginCollapsingState.Dispose();
                                zero = IntPtr.Zero;
                            }
                            durMargin         = (num3 = fsbbox.fsrc.du + 1);
                            array[0].durWidth = num3;
                            this.CreateSubpageBottomlessHelper(base.PtsContext, this._mainTextSegment.Handle, 1, fswdir, num3, urMargin, durMargin, vrMargin, num4, array, out fsfmtrbl, out pfsFloatContent, out dvrFloaterHeight, out fsbbox, out zero, out num5, out num6);
                        }
                    }
                    else
                    {
                        num3 = TextDpi.ToTextDpi(TextDpi.MinWidth);
                    }
                    if (zero != IntPtr.Zero)
                    {
                        MarginCollapsingState marginCollapsingState2 = base.PtsContext.HandleToObject(zero) as MarginCollapsingState;
                        PTS.ValidateHandle(marginCollapsingState2);
                        marginCollapsingState2.Dispose();
                        zero = IntPtr.Zero;
                    }
                    durFloaterWidth   = num3 + mbpInfo.MBPLeft + mbpInfo.MBPRight;
                    dvrFloaterHeight += mbpInfo.MBPTop + mbpInfo.MBPBottom;
                    if (dvrFloaterHeight > dvrAvailable || (durFloaterWidth > durAvailable && !PTS.ToBoolean(fAtMaxWidth)))
                    {
                        if (pfsFloatContent != IntPtr.Zero)
                        {
                            PTS.Validate(PTS.FsDestroySubpage(base.PtsContext.Context, pfsFloatContent), base.PtsContext);
                        }
                        cPolygons       = (cVertices = 0);
                        pfsFloatContent = IntPtr.Zero;
                    }
                    else
                    {
                        fsbbox.fsrc.u  = 0;
                        fsbbox.fsrc.v  = 0;
                        fsbbox.fsrc.du = durFloaterWidth;
                        fsbbox.fsrc.dv = dvrFloaterHeight;
                        cPolygons      = (cVertices = 0);
                    }
                }
                else
                {
                    durFloaterWidth = (dvrFloaterHeight = 0);
                    cPolygons       = (cVertices = 0);
                    pfsFloatContent = IntPtr.Zero;
                }
            }
            ((FloaterParaClient)paraClient).SubpageHandle = pfsFloatContent;
        }
コード例 #27
0
        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)
        {
            uint num = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));

            Invariant.Assert(paraClient is FloaterParaClient);
            if (this.IsFloaterRejected(PTS.ToBoolean(fAtMaxWidth), TextDpi.FromTextDpi(durAvailable)))
            {
                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;
            }
            else
            {
                if (!base.StructuralCache.CurrentFormatContext.FinitePage)
                {
                    if (double.IsInfinity(base.StructuralCache.CurrentFormatContext.PageHeight))
                    {
                        if (dvrAvailable > 1073741823)
                        {
                            dvrAvailable = Math.Min(dvrAvailable, 1073741823);
                            fEmptyOk     = 0;
                        }
                    }
                    else
                    {
                        dvrAvailable = Math.Min(dvrAvailable, TextDpi.ToTextDpi(base.StructuralCache.CurrentFormatContext.PageHeight));
                    }
                }
                MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);
                double  num2    = this.CalculateWidth(TextDpi.FromTextDpi(durAvailable));
                int     num3;
                this.AdjustDurAvailable(num2, ref durAvailable, out num3);
                int        num4   = Math.Max(1, dvrAvailable - (mbpInfo.MBPTop + mbpInfo.MBPBottom));
                PTS.FSRECT fsrect = default(PTS.FSRECT);
                fsrect.du = num3;
                fsrect.dv = num4;
                int num5 = 1;
                PTS.FSCOLUMNINFO[] array = new PTS.FSCOLUMNINFO[num5];
                array[0].durBefore = 0;
                array[0].durWidth  = num3;
                IntPtr zero;
                int    num6;
                this.CreateSubpageFiniteHelper(base.PtsContext, pbrkrecIn, fBRFromPreviousPage, this._mainTextSegment.Handle, footnoteRejector, fEmptyOk, 1, fswdir, num3, num4, ref fsrect, num5, array, 0, fsksuppresshardbreakbeforefirstparaIn, out fsfmtr, out pfsFloatContent, out pbrkrecOut, out dvrFloaterHeight, out fsbbox, out zero, out num6);
                if (fsfmtr.kstop >= PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace)
                {
                    durFloaterWidth = (dvrFloaterHeight = 0);
                    cPolygons       = (cVertices = 0);
                }
                else
                {
                    if (PTS.ToBoolean(fsbbox.fDefined))
                    {
                        if (fsbbox.fsrc.du < num3 && double.IsNaN(num2) && this.HorizontalAlignment != HorizontalAlignment.Stretch)
                        {
                            if (pfsFloatContent != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpage(base.PtsContext.Context, pfsFloatContent), base.PtsContext);
                                pfsFloatContent = IntPtr.Zero;
                            }
                            if (pbrkrecOut != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpageBreakRecord(base.PtsContext.Context, pbrkrecOut), base.PtsContext);
                                pbrkrecOut = IntPtr.Zero;
                            }
                            if (zero != IntPtr.Zero)
                            {
                                MarginCollapsingState marginCollapsingState = base.PtsContext.HandleToObject(zero) as MarginCollapsingState;
                                PTS.ValidateHandle(marginCollapsingState);
                                marginCollapsingState.Dispose();
                                zero = IntPtr.Zero;
                            }
                            num3              = fsbbox.fsrc.du + 1;
                            fsrect.du         = num3;
                            fsrect.dv         = num4;
                            array[0].durWidth = num3;
                            this.CreateSubpageFiniteHelper(base.PtsContext, pbrkrecIn, fBRFromPreviousPage, this._mainTextSegment.Handle, footnoteRejector, fEmptyOk, 1, fswdir, num3, num4, ref fsrect, num5, array, 0, fsksuppresshardbreakbeforefirstparaIn, out fsfmtr, out pfsFloatContent, out pbrkrecOut, out dvrFloaterHeight, out fsbbox, out zero, out num6);
                        }
                    }
                    else
                    {
                        num3 = TextDpi.ToTextDpi(TextDpi.MinWidth);
                    }
                    if (zero != IntPtr.Zero)
                    {
                        MarginCollapsingState marginCollapsingState2 = base.PtsContext.HandleToObject(zero) as MarginCollapsingState;
                        PTS.ValidateHandle(marginCollapsingState2);
                        marginCollapsingState2.Dispose();
                        zero = IntPtr.Zero;
                    }
                    durFloaterWidth   = num3 + mbpInfo.MBPLeft + mbpInfo.MBPRight;
                    dvrFloaterHeight += mbpInfo.MBPTop + mbpInfo.MBPBottom;
                    fsbbox.fsrc.u     = 0;
                    fsbbox.fsrc.v     = 0;
                    fsbbox.fsrc.du    = durFloaterWidth;
                    fsbbox.fsrc.dv    = dvrFloaterHeight;
                    fsbbox.fDefined   = 1;
                    cPolygons         = (cVertices = 0);
                    if (durFloaterWidth > durAvailable || dvrFloaterHeight > dvrAvailable)
                    {
                        if (PTS.ToBoolean(fEmptyOk))
                        {
                            if (pfsFloatContent != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpage(base.PtsContext.Context, pfsFloatContent), base.PtsContext);
                                pfsFloatContent = IntPtr.Zero;
                            }
                            if (pbrkrecOut != IntPtr.Zero)
                            {
                                PTS.Validate(PTS.FsDestroySubpageBreakRecord(base.PtsContext.Context, pbrkrecOut), base.PtsContext);
                                pbrkrecOut = IntPtr.Zero;
                            }
                            cPolygons    = (cVertices = 0);
                            fsfmtr.kstop = PTS.FSFMTRKSTOP.fmtrNoProgressOutOfSpace;
                        }
                        else
                        {
                            fsfmtr.fForcedProgress = 1;
                        }
                    }
                }
            }
            ((FloaterParaClient)paraClient).SubpageHandle = pfsFloatContent;
        }
コード例 #28
0
        internal void GetFigureProperties(FigureParaClient paraClient, int fInTextLine, uint fswdir, int fBottomUndefined, out int dur, out int dvr, out PTS.FSFIGUREPROPS fsfigprops, out int cPolygons, out int cVertices, out int durDistTextLeft, out int durDistTextRight, out int dvrDistTextTop, out int dvrDistTextBottom)
        {
            Invariant.Assert(base.StructuralCache.CurrentFormatContext.FinitePage);
            uint    num     = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));
            Figure  figure  = (Figure)base.Element;
            MbpInfo mbpInfo = MbpInfo.FromElement(base.Element, base.StructuralCache.TextFormatterHost.PixelsPerDip);

            durDistTextLeft = (durDistTextRight = (dvrDistTextTop = (dvrDistTextBottom = 0)));
            bool   flag;
            double width = FigureHelper.CalculateFigureWidth(base.StructuralCache, figure, figure.Width, out flag);
            double d     = this.LimitTotalWidthFromAnchor(width, TextDpi.FromTextDpi(mbpInfo.MarginLeft + mbpInfo.MarginRight));
            int    num2  = Math.Max(1, TextDpi.ToTextDpi(d) - (mbpInfo.BPLeft + mbpInfo.BPRight));
            bool   flag2;
            double height = FigureHelper.CalculateFigureHeight(base.StructuralCache, figure, figure.Height, out flag2);
            double d2     = this.LimitTotalHeightFromAnchor(height, TextDpi.FromTextDpi(mbpInfo.MarginTop + mbpInfo.MarginBottom));
            int    num3   = Math.Max(1, TextDpi.ToTextDpi(d2) - (mbpInfo.BPTop + mbpInfo.BPBottom));
            int    num4   = 1;

            PTS.FSCOLUMNINFO[] array = new PTS.FSCOLUMNINFO[num4];
            array[0].durBefore = 0;
            array[0].durWidth  = num2;
            PTS.FSRECT fsrect = new PTS.FSRECT(0, 0, num2, num3);
            PTS.FSFMTR fsfmtr;
            IntPtr     intPtr;
            IntPtr     intPtr2;

            PTS.FSBBOX fsbbox;
            IntPtr     zero;
            int        num5;

            this.CreateSubpageFiniteHelper(base.PtsContext, IntPtr.Zero, 0, this._mainTextSegment.Handle, IntPtr.Zero, 0, 1, fswdir, num2, num3, ref fsrect, num4, array, 0, out fsfmtr, out intPtr, out intPtr2, out dvr, out fsbbox, out zero, out num5);
            if (intPtr2 != IntPtr.Zero)
            {
                PTS.Validate(PTS.FsDestroySubpageBreakRecord(base.PtsContext.Context, intPtr2));
            }
            if (PTS.ToBoolean(fsbbox.fDefined))
            {
                if (fsbbox.fsrc.du < num2 && flag)
                {
                    if (intPtr != IntPtr.Zero)
                    {
                        PTS.Validate(PTS.FsDestroySubpage(base.PtsContext.Context, intPtr), base.PtsContext);
                    }
                    if (zero != IntPtr.Zero)
                    {
                        MarginCollapsingState marginCollapsingState = base.PtsContext.HandleToObject(zero) as MarginCollapsingState;
                        PTS.ValidateHandle(marginCollapsingState);
                        marginCollapsingState.Dispose();
                        zero = IntPtr.Zero;
                    }
                    num2 = fsbbox.fsrc.du + 1;
                    array[0].durWidth = num2;
                    PTS.FSRECT fsrect2 = new PTS.FSRECT(0, 0, num2, num3);
                    PTS.FSFMTR fsfmtr2;
                    IntPtr     intPtr3;
                    this.CreateSubpageFiniteHelper(base.PtsContext, IntPtr.Zero, 0, this._mainTextSegment.Handle, IntPtr.Zero, 0, 1, fswdir, num2, num3, ref fsrect2, num4, array, 0, out fsfmtr2, out intPtr, out intPtr3, out dvr, out fsbbox, out zero, out num5);
                    if (intPtr3 != IntPtr.Zero)
                    {
                        PTS.Validate(PTS.FsDestroySubpageBreakRecord(base.PtsContext.Context, intPtr3));
                    }
                }
            }
            else
            {
                num2 = TextDpi.ToTextDpi(TextDpi.MinWidth);
            }
            dur = num2 + mbpInfo.MBPLeft + mbpInfo.MBPRight;
            if (zero != IntPtr.Zero)
            {
                MarginCollapsingState marginCollapsingState2 = base.PtsContext.HandleToObject(zero) as MarginCollapsingState;
                PTS.ValidateHandle(marginCollapsingState2);
                marginCollapsingState2.Dispose();
                zero = IntPtr.Zero;
            }
            dvr += mbpInfo.MBPTop + mbpInfo.MBPBottom;
            if (!flag2)
            {
                dvr = TextDpi.ToTextDpi(d2) + mbpInfo.MarginTop + mbpInfo.MarginBottom;
            }
            FigureHorizontalAnchor horizontalAnchor = figure.HorizontalAnchor;
            FigureVerticalAnchor   verticalAnchor   = figure.VerticalAnchor;

            fsfigprops.fskrefU = (PTS.FSKREF)(horizontalAnchor / FigureHorizontalAnchor.ContentLeft);
            fsfigprops.fskrefV = (PTS.FSKREF)(verticalAnchor / FigureVerticalAnchor.ContentTop);
            fsfigprops.fskalfU = (PTS.FSKALIGNFIG)(horizontalAnchor % FigureHorizontalAnchor.ContentLeft);
            fsfigprops.fskalfV = (PTS.FSKALIGNFIG)(verticalAnchor % FigureVerticalAnchor.ContentTop);
            if (!PTS.ToBoolean(fInTextLine))
            {
                if (fsfigprops.fskrefU == PTS.FSKREF.fskrefChar)
                {
                    fsfigprops.fskrefU = PTS.FSKREF.fskrefMargin;
                    fsfigprops.fskalfU = PTS.FSKALIGNFIG.fskalfMin;
                }
                if (fsfigprops.fskrefV == PTS.FSKREF.fskrefChar)
                {
                    fsfigprops.fskrefV = PTS.FSKREF.fskrefMargin;
                    fsfigprops.fskalfV = PTS.FSKALIGNFIG.fskalfMin;
                }
            }
            fsfigprops.fskwrap       = PTS.WrapDirectionToFskwrap(figure.WrapDirection);
            fsfigprops.fNonTextPlane = 0;
            fsfigprops.fAllowOverlap = 0;
            fsfigprops.fDelayable    = PTS.FromBoolean(figure.CanDelayPlacement);
            cPolygons = (cVertices = 0);
            paraClient.SubpageHandle = intPtr;
        }
コード例 #29
0
        internal void FormatParaFinite(ContainerParaClient paraClient, IntPtr pbrkrecIn, int fBRFromPreviousPage, int iArea, IntPtr footnoteRejector, IntPtr geometry, int fEmptyOk, int fSuppressTopSpace, uint fswdir, ref PTS.FSRECT fsrcToFill, MarginCollapsingState mcs, PTS.FSKCLEAR fskclearIn, PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn, out PTS.FSFMTR fsfmtr, out IntPtr pfspara, out IntPtr pbrkrecOut, out int dvrUsed, out PTS.FSBBOX fsbbox, out IntPtr pmcsclientOut, out PTS.FSKCLEAR fskclearOut, out int dvrTopSpace)
        {
            uint num = PTS.FlowDirectionToFswdir((FlowDirection)base.Element.GetValue(FrameworkElement.FlowDirectionProperty));

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

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

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

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