// Token: 0x060067D1 RID: 26577 RVA: 0x001D1984 File Offset: 0x001CFB84
        internal static double CalculateFigureHeight(StructuralCache structuralCache, Figure figure, FigureLength figureLength, out bool isHeightAuto)
        {
            double num;

            if (figureLength.IsPage)
            {
                num = structuralCache.CurrentFormatContext.PageHeight * figureLength.Value;
            }
            else if (figureLength.IsContent)
            {
                Thickness pageMargin = structuralCache.CurrentFormatContext.PageMargin;
                num = (structuralCache.CurrentFormatContext.PageHeight - pageMargin.Top - pageMargin.Bottom) * figureLength.Value;
            }
            else if (figureLength.IsColumn)
            {
                int    num2;
                double num3;
                double num4;
                double num5;
                FigureHelper.GetColumnMetrics(structuralCache, out num2, out num3, out num4, out num5);
                double num6 = figureLength.Value;
                if (num6 > (double)num2)
                {
                    num6 = (double)num2;
                }
                int num7 = (int)num6;
                if ((double)num7 == num6 && num7 > 0)
                {
                    num7--;
                }
                num = num3 * num6 + num4 * (double)num7;
            }
            else
            {
                num = FigureHelper.CalculateFigureCommon(figureLength);
            }
            if (!DoubleUtil.IsNaN(num))
            {
                FigureVerticalAnchor verticalAnchor = figure.VerticalAnchor;
                if (FigureHelper.IsVerticalPageAnchor(verticalAnchor))
                {
                    num = Math.Max(1.0, Math.Min(num, structuralCache.CurrentFormatContext.PageHeight));
                }
                else
                {
                    Thickness pageMargin2 = structuralCache.CurrentFormatContext.PageMargin;
                    num = Math.Max(1.0, Math.Min(num, structuralCache.CurrentFormatContext.PageHeight - pageMargin2.Top - pageMargin2.Bottom));
                }
                TextDpi.EnsureValidPageWidth(ref num);
                isHeightAuto = false;
            }
            else
            {
                num          = structuralCache.CurrentFormatContext.PageHeight;
                isHeightAuto = true;
            }
            return(num);
        }
        // Token: 0x060067D0 RID: 26576 RVA: 0x001D18A4 File Offset: 0x001CFAA4
        internal static double CalculateFigureWidth(StructuralCache structuralCache, Figure figure, FigureLength figureLength, out bool isWidthAuto)
        {
            isWidthAuto = figureLength.IsAuto;
            FigureHorizontalAnchor horizontalAnchor = figure.HorizontalAnchor;
            double num;

            if (figureLength.IsPage || (figureLength.IsAuto && FigureHelper.IsHorizontalPageAnchor(horizontalAnchor)))
            {
                num = structuralCache.CurrentFormatContext.PageWidth * figureLength.Value;
            }
            else if (figureLength.IsAbsolute)
            {
                num = FigureHelper.CalculateFigureCommon(figureLength);
            }
            else
            {
                int    num2;
                double num3;
                double num4;
                double num5;
                FigureHelper.GetColumnMetrics(structuralCache, out num2, out num3, out num4, out num5);
                if (figureLength.IsContent || (figureLength.IsAuto && FigureHelper.IsHorizontalContentAnchor(horizontalAnchor)))
                {
                    num = (num3 * (double)num2 + num4 * (double)(num2 - 1)) * figureLength.Value;
                }
                else
                {
                    double value = figureLength.Value;
                    int    num6  = (int)value;
                    if ((double)num6 == value && num6 > 0)
                    {
                        num6--;
                    }
                    num = num3 * value + num4 * (double)num6;
                }
            }
            Invariant.Assert(!DoubleUtil.IsNaN(num));
            return(num);
        }
Пример #3
0
        // ------------------------------------------------------------------
        // Height figure size calculation
        // ------------------------------------------------------------------
        internal static double CalculateFigureHeight(StructuralCache structuralCache, Figure figure, FigureLength figureLength, out bool isHeightAuto)
        {
            double value;

            if (figureLength.IsPage)
            {
                value = (structuralCache.CurrentFormatContext.PageHeight) * figureLength.Value;
            }
            else if (figureLength.IsContent) // Column to be treated same as content
            {
                Thickness pageMargin = structuralCache.CurrentFormatContext.PageMargin;

                value = (structuralCache.CurrentFormatContext.PageHeight - pageMargin.Top - pageMargin.Bottom) * figureLength.Value;
            }
            else if (figureLength.IsColumn)
            {
                // Height is calculated based on column width, since column height is the same as content. Per spec.
                // Retrieve all column metrics for current page
                int    cColumns;
                double columnWidth;
                double gap;
                double rule;
                FigureHelper.GetColumnMetrics(structuralCache, out cColumns, out columnWidth, out gap, out rule);

                // We do this to prevent a 2.0 columns from spanning 2.0 + gap, so we just check for edge
                double lengthValue = figureLength.Value;
                if (lengthValue > cColumns)
                {
                    lengthValue = cColumns;
                }
                int columnGapsSpanned = (int)lengthValue;
                if (columnGapsSpanned == lengthValue && columnGapsSpanned > 0)
                {
                    columnGapsSpanned -= 1;
                }

                value = (columnWidth * lengthValue) + gap * columnGapsSpanned;
            }
            else
            {
                value = FigureHelper.CalculateFigureCommon(figureLength);
            }

            if (!double.IsNaN(value))
            {
                FigureVerticalAnchor verticalAnchor = figure.VerticalAnchor;

                // Value is in pixels. Now we limit value to max out depending on anchoring.
                if (FigureHelper.IsVerticalPageAnchor(verticalAnchor))
                {
                    value = Math.Max(1, Math.Min(value, structuralCache.CurrentFormatContext.PageHeight));
                }
                else // Column and paragraph anchoring still max out at content height
                {
                    Thickness pageMargin = structuralCache.CurrentFormatContext.PageMargin;
                    value = Math.Max(1, Math.Min(value, structuralCache.CurrentFormatContext.PageHeight - pageMargin.Top - pageMargin.Bottom));
                }

                TextDpi.EnsureValidPageWidth(ref value);

                isHeightAuto = false;
            }
            else
            {
                value        = structuralCache.CurrentFormatContext.PageHeight;
                isHeightAuto = true;
            }

            return(value);
        }