Exemplo n.º 1
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;
        }
        // Token: 0x06006835 RID: 26677 RVA: 0x001D5B40 File Offset: 0x001D3D40
        internal PageBreakRecord FormatFinite(Size pageSize, Thickness pageMargin, PageBreakRecord breakRecord)
        {
            Invariant.Assert(!this.IsDisposed);
            this._formattedLinesCount = 0;
            TextDpi.EnsureValidPageSize(ref pageSize);
            TextDpi.EnsureValidPageMargin(ref pageMargin, pageSize);
            double num = PtsHelper.CalculatePageMarginAdjustment(this._structuralCache, pageSize.Width - (pageMargin.Left + pageMargin.Right));

            if (!DoubleUtil.IsZero(num))
            {
                pageMargin.Right += num - num / 100.0;
            }
            this._pageMargin = pageMargin;
            base.SetSize(pageSize);
            base.SetContentBox(new Rect(pageMargin.Left, pageMargin.Top, pageSize.Width - (pageMargin.Left + pageMargin.Right), pageSize.Height - (pageMargin.Top + pageMargin.Bottom)));
            using (this._structuralCache.SetDocumentFormatContext(this))
            {
                this.OnBeforeFormatPage();
                if (this._ptsPage.PrepareForFiniteUpdate(breakRecord))
                {
                    this._structuralCache.CurrentFormatContext.PushNewPageData(pageSize, this._pageMargin, true, true);
                    this._ptsPage.UpdateFinitePage(breakRecord);
                }
                else
                {
                    this._structuralCache.CurrentFormatContext.PushNewPageData(pageSize, this._pageMargin, false, true);
                    this._ptsPage.CreateFinitePage(breakRecord);
                }
                this._structuralCache.CurrentFormatContext.PopPageData();
                this.OnAfterFormatPage();
                this._structuralCache.DetectInvalidOperation();
            }
            return(this._ptsPage.BreakRecord);
        }