// Token: 0x060067F6 RID: 26614 RVA: 0x001D3800 File Offset: 0x001D1A00
 private PTS.FSRECT CalculateSearchArea(FigureHorizontalAnchor horizAnchor, FigureVerticalAnchor vertAnchor, ref PTS.FSRECT fsrcPage, ref PTS.FSRECT fsrcMargin, ref PTS.FSRECT fsrcTrack, ref PTS.FSRECT fsrcFigurePreliminary)
 {
     PTS.FSRECT result;
     if (FigureHelper.IsHorizontalPageAnchor(horizAnchor))
     {
         result.u  = fsrcPage.u;
         result.du = fsrcPage.du;
     }
     else if (FigureHelper.IsHorizontalContentAnchor(horizAnchor))
     {
         result.u  = fsrcMargin.u;
         result.du = fsrcMargin.du;
     }
     else
     {
         result.u  = fsrcTrack.u;
         result.du = fsrcTrack.du;
     }
     if (FigureHelper.IsVerticalPageAnchor(vertAnchor))
     {
         result.v  = fsrcPage.v;
         result.dv = fsrcPage.dv;
     }
     else if (FigureHelper.IsVerticalContentAnchor(vertAnchor))
     {
         result.v  = fsrcMargin.v;
         result.dv = fsrcMargin.dv;
     }
     else
     {
         result.v  = fsrcFigurePreliminary.v;
         result.dv = fsrcTrack.v + fsrcTrack.dv - fsrcFigurePreliminary.v;
     }
     return(result);
 }
        // ------------------------------------------------------------------
        // Determines the max total height for this figure element, subtracts the element margins to determine the maximum size the
        // Subpage can be formatted at.
        // ------------------------------------------------------------------
        private double LimitTotalHeightFromAnchor(double height, double elementMarginHeight)
        {
            Figure element = (Figure)Element;
            FigureVerticalAnchor vertAnchor = element.VerticalAnchor;

            double maxTotalHeight = 0.0;

            // Value is in pixels. Now we limit value to max out depending on anchoring.
            if (FigureHelper.IsVerticalPageAnchor(vertAnchor))
            {
                maxTotalHeight = StructuralCache.CurrentFormatContext.PageHeight;
            }
            else
            {
                Thickness pageMargin = StructuralCache.CurrentFormatContext.PageMargin;
                maxTotalHeight = StructuralCache.CurrentFormatContext.PageHeight - pageMargin.Top - pageMargin.Bottom;
            }

            if ((height + elementMarginHeight) > maxTotalHeight)
            {
                height = Math.Max(TextDpi.MinWidth, maxTotalHeight - elementMarginHeight);
            }

            return(height);
        }
        // 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: 0x060067F5 RID: 26613 RVA: 0x001D3770 File Offset: 0x001D1970
        private double LimitTotalHeightFromAnchor(double height, double elementMarginHeight)
        {
            Figure figure = (Figure)base.Element;
            FigureVerticalAnchor verticalAnchor = figure.VerticalAnchor;
            double num;

            if (FigureHelper.IsVerticalPageAnchor(verticalAnchor))
            {
                num = base.StructuralCache.CurrentFormatContext.PageHeight;
            }
            else
            {
                Thickness pageMargin = base.StructuralCache.CurrentFormatContext.PageMargin;
                num = base.StructuralCache.CurrentFormatContext.PageHeight - pageMargin.Top - pageMargin.Bottom;
            }
            if (height + elementMarginHeight > num)
            {
                height = Math.Max(TextDpi.MinWidth, num - elementMarginHeight);
            }
            return(height);
        }
Exemplo n.º 5
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);
        }