//------------------------------------------------------------------- // Determines whether a floater should be rejected or not //------------------------------------------------------------------- private bool IsFloaterRejected(bool fAtMaxWidth, double availableSpace) { if (fAtMaxWidth) { return(false); } if (Element is Floater && HorizontalAlignment != HorizontalAlignment.Stretch) { return(false); } else if (Element is Figure) { FigureLength figureLength = ((Figure)Element).Width; if (figureLength.IsAuto) { return(false); } if (figureLength.IsAbsolute && figureLength.Value < availableSpace) { return(false); } } return(true); }
void OnMouseDownDecreaseWidth(object sender, MouseButtonEventArgs args) { FigureLength myFigureLength = myFigure.Width; double widthValue = myFigureLength.Value; if (widthValue > 0) { myFigure.Width = new FigureLength((widthValue - 10), FigureUnitType.Pixel); } }
// ------------------------------------------------------------------ // Width figure size calculation // ------------------------------------------------------------------ internal static double CalculateFigureWidth(StructuralCache structuralCache, Figure figure, FigureLength figureLength, out bool isWidthAuto) { double value; isWidthAuto = figureLength.IsAuto ? true : false; // Check figure's horizontal anchor. If anchored to page, use page width to format FigureHorizontalAnchor horizontalAnchor = figure.HorizontalAnchor; if(figureLength.IsPage || (figureLength.IsAuto && IsHorizontalPageAnchor(horizontalAnchor))) { value = structuralCache.CurrentFormatContext.PageWidth * figureLength.Value; } else if (figureLength.IsAbsolute) { value = CalculateFigureCommon(figureLength); } else // figureLength.IsColumn || figureLength.IsContent || figureLength.IsAuto { double columnWidth, gap, rule; int cColumns; GetColumnMetrics(structuralCache, out cColumns, out columnWidth, out gap, out rule); if (figureLength.IsContent || (figureLength.IsAuto && IsHorizontalContentAnchor(horizontalAnchor))) { // Use content width for figure value = (columnWidth * cColumns + gap * (cColumns - 1)) * figureLength.Value; } else // figureLength.IsColumn || figureLength.IsAuto { // We do this to prevent a 2.0 columns from spanning 2.0 + gap, so we just check for edge double lengthValue = figureLength.Value; int columnGapsSpanned = (int) lengthValue; if(columnGapsSpanned == lengthValue && columnGapsSpanned > 0) { columnGapsSpanned -= 1; } value = (columnWidth * lengthValue) + gap * columnGapsSpanned; } } Invariant.Assert(!DoubleUtil.IsNaN(value)); return value; }
// Token: 0x060067D2 RID: 26578 RVA: 0x001D1AD8 File Offset: 0x001CFCD8 internal static double CalculateFigureCommon(FigureLength figureLength) { double result; if (figureLength.IsAuto) { result = double.NaN; } else if (figureLength.IsAbsolute) { result = figureLength.Value; } else { Invariant.Assert(false, "Unknown figure length type specified."); result = 0.0; } return(result); }
// ------------------------------------------------------------------ // Common figure size calculation // ------------------------------------------------------------------ internal static double CalculateFigureCommon(FigureLength figureLength) { double value; if(figureLength.IsAuto) { value = Double.NaN; } else if(figureLength.IsAbsolute) { value = figureLength.Value; } else { Invariant.Assert(false, "Unknown figure length type specified."); value = 0.0; } return value; }
// ------------------------------------------------------------------ // 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(!DoubleUtil.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; }
// ------------------------------------------------------------------ // Width figure size calculation // ------------------------------------------------------------------ internal static double CalculateFigureWidth(StructuralCache structuralCache, Figure figure, FigureLength figureLength, out bool isWidthAuto) { double value; isWidthAuto = figureLength.IsAuto ? true : false; // Check figure's horizontal anchor. If anchored to page, use page width to format FigureHorizontalAnchor horizontalAnchor = figure.HorizontalAnchor; if (figureLength.IsPage || (figureLength.IsAuto && IsHorizontalPageAnchor(horizontalAnchor))) { value = structuralCache.CurrentFormatContext.PageWidth * figureLength.Value; } else if (figureLength.IsAbsolute) { value = CalculateFigureCommon(figureLength); } else // figureLength.IsColumn || figureLength.IsContent || figureLength.IsAuto { double columnWidth, gap, rule; int cColumns; GetColumnMetrics(structuralCache, out cColumns, out columnWidth, out gap, out rule); if (figureLength.IsContent || (figureLength.IsAuto && IsHorizontalContentAnchor(horizontalAnchor))) { // Use content width for figure value = (columnWidth * cColumns + gap * (cColumns - 1)) * figureLength.Value; } else // figureLength.IsColumn || figureLength.IsAuto { // We do this to prevent a 2.0 columns from spanning 2.0 + gap, so we just check for edge double lengthValue = figureLength.Value; int columnGapsSpanned = (int)lengthValue; if (columnGapsSpanned == lengthValue && columnGapsSpanned > 0) { columnGapsSpanned -= 1; } value = (columnWidth * lengthValue) + gap * columnGapsSpanned; } } Invariant.Assert(!double.IsNaN(value)); return(value); }
// ------------------------------------------------------------------ // 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); }
//-------------------------------------------------------------------- // // Internal Methods // //------------------------------------------------------------------- #region Internal Methods /// <summary> /// Converts a FigureLength instance to a String given the CultureInfo. /// </summary> /// <param name="fl">FigureLength instance to convert.</param> /// <param name="cultureInfo">Culture Info.</param> /// <returns>String representation of the object.</returns> static internal string ToString(FigureLength fl, CultureInfo cultureInfo) { switch (fl.FigureUnitType) { // for Auto print out "Auto". value is always "1.0" case FigureUnitType.Auto: return ("Auto"); case FigureUnitType.Pixel: return Convert.ToString(fl.Value, cultureInfo); default: return Convert.ToString(fl.Value, cultureInfo) + " " + fl.FigureUnitType.ToString(); } }
// 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); }