public void Init(CreateAndRegisterStream createAndRegisterStream, AutoFit autoFit, string reportName) { this.m_outStream = createAndRegisterStream(reportName, "doc", null, "application/msword", false, StreamOper.CreateAndRegister); this.m_tableStream = createAndRegisterStream("TableStream", null, null, null, true, StreamOper.CreateOnly); this.m_mainStream = createAndRegisterStream("WordDocument", null, null, null, true, StreamOper.CreateOnly); this.m_fontTable = createAndRegisterStream("FontTable", null, null, null, true, StreamOper.CreateOnly); this.m_dataStream = createAndRegisterStream("Data", null, null, null, true, StreamOper.CreateOnly); this.m_listStream = createAndRegisterStream("List", null, null, null, true, StreamOper.CreateOnly); this.m_listLevelStream = createAndRegisterStream("ListLevel", null, null, null, true, StreamOper.CreateOnly); Stream textPiece = createAndRegisterStream("TextPiece", null, null, null, true, StreamOper.CreateOnly); Stream chpTable = createAndRegisterStream("ChpTable", null, null, null, true, StreamOper.CreateOnly); Stream papTable = createAndRegisterStream("PapTable", null, null, null, true, StreamOper.CreateOnly); this.m_charFormat = new CharacterFormat(chpTable, this.m_fcStart); this.m_parFormat = new ParagraphFormat(papTable, this.m_fcStart); this.m_wordText = new WordText(textPiece); this.m_secFormat = new SectionFormat(); this.m_currentRow = new TableData(1, true); this.m_tapStack = new Stack <TableData>(); this.m_fontNameSet = new Dictionary <string, int>(); this.WriteFont("Times New Roman"); this.WriteFont("Symbol"); this.WriteFont("Arial"); this.m_imgIndex = 0; this.m_fldsMain = new FieldsTable(); this.m_fldsHdr = new FieldsTable(); this.m_fldsCurrent = this.m_fldsMain; this.m_bookmarks = new Bookmarks(); this.m_images = new Dictionary <ImageHash, int>(); this.m_autoFit = autoFit; }
public override bool Render() { RPLItemMeasurement rPLItemMeasurement = null; bool flag = true; string author = ""; string title = ""; string description = ""; AutoFit autoFit = base.m_writer.AutoFit; float num = 0f; float leftMargin = 0f; float rightMargin = 0f; RPLPageLayout rPLPageLayout = null; List <RPLReport> rplReportCache = new List <RPLReport>(); bool flag2 = false; bool flag3 = false; SectionEntry sectionEntry = null; while (!base.m_spbProcessing.Done) { if (!flag) { base.m_writer.WritePageBreak(); } base.m_spbProcessing.GetNextPage(out base.m_rplReport); RPLPageContent rPLPageContent = base.m_rplReport.RPLPaginatedPages[0]; RPLReportSection rPLReportSection = rPLPageContent.GetNextReportSection(); bool flag4 = false; bool flag5 = true; while (rPLReportSection != null) { rPLItemMeasurement = rPLReportSection.Columns[0]; float width = rPLReportSection.BodyArea.Width; RPLHeaderFooter footer = null; SectionEntry se = null; if (!flag5 || sectionEntry == null || string.CompareOrdinal(sectionEntry.SectionId, rPLReportSection.ID) != 0) { if (RSTrace.RenderingTracer.TraceVerbose) { RSTrace.RenderingTracer.Trace("The left or right margin is either <0 or the sum exceeds the page width."); } sectionEntry = (se = this.RenderHeaderFooters(rPLReportSection, flag5, ref flag4, rplReportCache, ref footer, ref flag2, ref flag3)); } flag = base.SetFirstPageDimensions(flag, rPLPageContent, ref rPLPageLayout, ref leftMargin, ref rightMargin, ref num, ref title, ref author, ref description); num = base.RevisePageDimensions(leftMargin, rightMargin, num, width, autoFit); base.RenderHeaderBetweenSections(rPLReportSection, flag5); base.RenderBodyContent(width, rPLItemMeasurement); rPLReportSection = base.AdvanceToNextSection(rPLPageContent, rPLReportSection, ref flag5, sectionEntry, footer, se); } if (!base.m_spbProcessing.Done && !flag4) { base.m_rplReport.Release(); } } base.m_writer.WriteParagraphEnd(); base.m_writer.SetPageDimensions(base.m_pageHeight, num, leftMargin, rightMargin, rPLPageLayout.MarginTop, rPLPageLayout.MarginBottom); base.FinishRendering(rplReportCache, title, author, description); return(true); }
internal override bool Render() { RPLItemMeasurement rPLItemMeasurement = null; bool flag = true; string author = ""; string title = ""; string description = ""; AutoFit autoFit = m_writer.AutoFit; float width = 0f; float leftMargin = 0f; float rightMargin = 0f; RPLPageLayout rplPageLayout = null; List <RPLReport> rplReportCache = new List <RPLReport>(); bool hasHeaderSoFar = false; bool hasFooterSoFar = false; SectionEntry sectionEntry = null; while (!m_spbProcessing.Done) { if (!flag) { m_writer.WritePageBreak(); } m_spbProcessing.GetNextPage(out m_rplReport); RPLPageContent rPLPageContent = m_rplReport.RPLPaginatedPages[0]; RPLReportSection rPLReportSection = rPLPageContent.GetNextReportSection(); bool pageCached = false; bool firstSection = true; while (rPLReportSection != null) { rPLItemMeasurement = rPLReportSection.Columns[0]; float width2 = rPLReportSection.BodyArea.Width; RPLHeaderFooter footer = null; SectionEntry se = null; if (!firstSection || sectionEntry == null || string.CompareOrdinal(sectionEntry.SectionId, rPLReportSection.ID) != 0) { if (RSTrace.RenderingTracer.TraceVerbose) { RSTrace.RenderingTracer.Trace("The left or right margin is either <0 or the sum exceeds the page width."); } sectionEntry = (se = RenderHeaderFooters(rPLReportSection, firstSection, ref pageCached, rplReportCache, ref footer, ref hasHeaderSoFar, ref hasFooterSoFar)); } flag = SetFirstPageDimensions(flag, rPLPageContent, ref rplPageLayout, ref leftMargin, ref rightMargin, ref width, ref title, ref author, ref description); width = RevisePageDimensions(leftMargin, rightMargin, width, width2, autoFit); RenderHeaderBetweenSections(rPLReportSection, firstSection); RenderBodyContent(width2, rPLItemMeasurement); rPLReportSection = AdvanceToNextSection(rPLPageContent, rPLReportSection, ref firstSection, sectionEntry, footer, se); } if (!m_spbProcessing.Done && !pageCached) { m_rplReport.Release(); } } m_writer.WriteParagraphEnd(); m_writer.SetPageDimensions(m_pageHeight, width, leftMargin, rightMargin, rplPageLayout.MarginTop, rplPageLayout.MarginBottom); FinishRendering(rplReportCache, title, author, description); return(true); }
private void updateBoundingBoxes(GLText glText, AutoFit autoFit, IGLMatrices textMatrices, IGLMatrices labelMatrices, PointF textScaleUp, PointF textScaleDown, PointF labelResolutionFactor, bool buildRenderBox, bool buildHitTestBox) { switch (autoFit) { case AutoFit.NoFitting: build(_labelBoundingBoxes, BaseSize.Width / labelResolutionFactor.X, BaseSize.Height / labelResolutionFactor.Y, labelMatrices, buildRenderBox, buildHitTestBox); updateText(glText, buildRenderBox, BaseSize, textScaleUp, textScaleDown, int.MaxValue); build(_textBoundingBoxes, glText.BitmapWidth, glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; case AutoFit.TextShouldWrapAndLabelShouldFitHeight: build(_textBoundingBoxes, glText.BitmapWidth, glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox); build(_labelBoundingBoxes, BaseSize.Width / labelResolutionFactor.X, glText.Height / labelResolutionFactor.Y, labelMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; case AutoFit.TextShouldFitLabel: build(_labelBoundingBoxes, BaseSize.Width / labelResolutionFactor.X, BaseSize.Height / labelResolutionFactor.Y, labelMatrices, buildRenderBox, buildHitTestBox); updateText(glText, buildRenderBox, glText.Width > BaseSize.Width ? new SizeF(0f, BaseSize.Height) : BaseSize, textScaleUp, textScaleDown, int.MaxValue); float textWidth = glText.Width < BaseSize.Width ? glText.BitmapWidth : MathUtils.Lerp(0f, 0f, glText.Width, BaseSize.Width, glText.BitmapWidth); float textHeight = glText.Height < BaseSize.Height ? glText.BitmapHeight : MathUtils.Lerp(0f, 0f, glText.Height, BaseSize.Height, glText.BitmapHeight); build(_textBoundingBoxes, textWidth, textHeight, textMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; case AutoFit.LabelShouldFitText: build(_textBoundingBoxes, glText.BitmapWidth, glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox); build(_labelBoundingBoxes, glText.Width / labelResolutionFactor.X, glText.Height / labelResolutionFactor.Y, labelMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; case AutoFit.TextShouldCrop: build(_labelBoundingBoxes, BaseSize.Width / labelResolutionFactor.X, BaseSize.Height / labelResolutionFactor.Y, labelMatrices, buildRenderBox, buildHitTestBox); updateText(glText, buildRenderBox, glText.Width > BaseSize.Width ? GLText.EmptySize : new SizeF(BaseSize.Width, GLText.EmptySize.Height), textScaleUp, textScaleDown, (int)BaseSize.Width, true); float heightOfText = glText.Height < BaseSize.Height ? glText.BitmapHeight : MathUtils.Lerp(0f, 0f, glText.Height, BaseSize.Height, glText.BitmapHeight); build(_textBoundingBoxes, glText.BitmapWidth, heightOfText, textMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; default: throw new NotSupportedException(autoFit.ToString()); } }
public void Init(CreateAndRegisterStream createAndRegisterStream, AutoFit autoFit, string reportName) { this._createAndRegisterStream = createAndRegisterStream; this._autofit = autoFit; this.InitCache(this._createAndRegisterStream); this._document = new OpenXmlDocumentModel(createAndRegisterStream(reportName, "docx", null, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", true, StreamOper.CreateAndRegister), this.CreateXmlStreamImplementation, this._scalabilityCache); this._nextPictureId = 0u; this._forceEmptyLayoutCell = false; }
public virtual Size GetPreferredSize() { if (AutoFit != null) { var sz = AutoFit.GetPreferredSize(); sz.Width += AutoFit.Margin[0] + AutoFit.Margin[2]; sz.Height += AutoFit.Margin[1] + AutoFit.Margin[3]; return(sz); } return(Bounds.Size); }
public ControlState(ControlState source) { _textFormatted = source._textFormatted; _text = source._text; _javaText = source._javaText; Typeface = source.Typeface; TextColor = source.TextColor; AvailWidth = source.AvailWidth; AvailHeight = source.AvailHeight; TextSize = source.TextSize; Lines = source.Lines; AutoFit = source.AutoFit; LineBreakMode = source.LineBreakMode; SyncFontSize = source.SyncFontSize; }
public LabelState(Label label) { HorizontalTextAlignment = label.HorizontalTextAlignment; VerticalTextAlignment = label.VerticalTextAlignment; FontFamily = label.FontFamily; FontSize = label.FontSize; FontAttributes = label.FontAttributes; Text = label.Text; HtmlText = label.HtmlText; AutoFit = label.AutoFit; Lines = label.Lines; FittedFontSize = label.FittedFontSize; SynchronizedFontSize = label.SynchronizedFontSize; }
public void WriteTableBegin(float left, bool layoutTable, AutoFit autofit) { if (this._state == State.InBody || this._state == State.InHeaderFooter || this._state == State.InCell) { if (this._state == State.InCell) { this._currentCell.PrepareForNestedTable(); } this._state = State.InTable; this._currentTable = new OpenXmlTableModel(this.CurrentTable, this._interleavingWriter, autofit); this._depth++; } else { WordOpenXmlUtils.FailCodingError(); } }
public AGSTextConfig(IBrush brush = null, IFont font = null, IBrush outlineBrush = null, float outlineWidth = 0f, IBrush shadowBrush = null, float shadowOffsetX = 0f, float shadowOffsetY = 0f, Alignment alignment = Alignment.TopLeft, AutoFit autoFit = AutoFit.NoFitting, float paddingLeft = 2f, float paddingRight = 2f, float paddingTop = 2f, float paddingBottom = 2f) { Brush = brush ?? Hooks.BrushLoader.LoadSolidBrush(Colors.White); Font = font ?? AGSGameSettings.DefaultTextFont; OutlineBrush = outlineBrush ?? Hooks.BrushLoader.LoadSolidBrush(Colors.White); OutlineWidth = outlineWidth; ShadowBrush = shadowBrush; ShadowOffsetX = shadowOffsetX; ShadowOffsetY = shadowOffsetY; Alignment = alignment; AutoFit = autoFit; PaddingLeft = paddingLeft; PaddingRight = paddingRight; PaddingTop = paddingTop; PaddingBottom = paddingBottom; }
#pragma warning restore CS0067 public AGSTextConfig(IBrush brush = null, IFont font = null, IBrush outlineBrush = null, float outlineWidth = 0f, IBrush shadowBrush = null, float shadowOffsetX = 0f, float shadowOffsetY = 0f, Alignment alignment = Alignment.TopLeft, AutoFit autoFit = AutoFit.NoFitting, float paddingLeft = 2f, float paddingRight = 2f, float paddingTop = 2f, float paddingBottom = 2f) { Brush = brush ?? _brushes.LoadSolidBrush(Colors.White); Font = font ?? AGSGame.Game?.Settings.Defaults.TextFont; OutlineBrush = outlineBrush ?? _brushes.LoadSolidBrush(Colors.White); OutlineWidth = outlineWidth; ShadowBrush = shadowBrush; ShadowOffsetX = shadowOffsetX; ShadowOffsetY = shadowOffsetY; Alignment = alignment; AutoFit = autoFit; PaddingLeft = paddingLeft; PaddingRight = paddingRight; PaddingTop = paddingTop; PaddingBottom = paddingBottom; }
private void updateBoundingBoxes(IObject obj, IDrawableInfo drawable, IViewport viewport) { AutoFit autoFit = getAutoFit(); float height = obj.Height; float width = obj.Width; if (autoFit == AutoFit.LabelShouldFitText) { updateText(GLText.EmptySize, null); CustomImageSize = new SizeF(_glText.Width, _glText.Height); } else { CustomImageSize = BaseSize; } var resolutionFactor = string.IsNullOrEmpty(Text) ? AGSModelMatrixComponent.NoScaling : new PointF(GLText.TextResolutionFactorX, GLText.TextResolutionFactorY); CustomImageResolutionFactor = resolutionFactor; var noFactor = AGSModelMatrixComponent.NoScaling; bool resolutionMatches = resolutionFactor.Equals(noFactor); var viewportMatrix = drawable.IgnoreViewport ? Matrix4.Identity : _viewport.GetViewport(drawable.RenderLayer.Z).GetMatrix(viewport, drawable.RenderLayer.ParallaxSpeed); var modelMatrices = obj.GetModelMatrices(); IGLMatrices textRenderMatrices = new GLMatrices { ModelMatrix = modelMatrices.InObjResolutionMatrix, ViewportMatrix = viewportMatrix }; //_textRenderMatrixBuilder.Build(_labelMatrixRenderTarget, sprite, parent, matrix, areaScaling, resolutionFactor); IGLMatrices labelRenderMatrices = new GLMatrices { ModelMatrix = modelMatrices.InVirtualResolutionMatrix, ViewportMatrix = viewportMatrix }; // _labelRenderMatrixBuilder.Build(_labelMatrixRenderTarget, sprite, parent, matrix, areaScaling, noFactor); IGLMatrices textHitTestMatrices = resolutionMatches ? textRenderMatrices : labelRenderMatrices; IGLMatrices labelHitTestMatrices = labelRenderMatrices; updateBoundingBoxes(autoFit, textHitTestMatrices, labelHitTestMatrices, noFactor, resolutionMatches, true); if (!resolutionMatches) { updateBoundingBoxes(autoFit, textRenderMatrices, labelRenderMatrices, resolutionFactor, true, false); } }
internal DeviceInfo(NameValueCollection deviceInfo) { m_rawDeviceInfo = deviceInfo; string value = deviceInfo["AutoFit"]; if (!string.IsNullOrEmpty(value)) { try { AutoFit = (AutoFit)Enum.Parse(AutoFit.GetType(), value, ignoreCase: true); } catch (Exception) { RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "AutoFit value is not valid"); } } m_expandToggles = ParseBool(deviceInfo["ExpandToggles"], m_expandToggles); m_fixedPageWidth = ParseBool(deviceInfo["FixedPageWidth"], m_fixedPageWidth); m_omitHyperlinks = ParseBool(deviceInfo["OmitHyperlinks"], m_omitHyperlinks); m_omitDrillthroughs = ParseBool(deviceInfo["OmitDrillthroughs"], m_omitDrillthroughs); }
//todo: share code with font factory private ITextConfig getTextConfig(IBrush brush = null, IFont font = null, IBrush outlineBrush = null, float outlineWidth = 0f, IBrush shadowBrush = null, float shadowOffsetX = 0f, float shadowOffsetY = 0f, Alignment alignment = Alignment.TopLeft, AutoFit autoFit = AutoFit.NoFitting, float paddingLeft = 2f, float paddingRight = 2f, float paddingTop = 2f, float paddingBottom = 2f, SizeF?labelMinSize = null) { return(new AGSTextConfig { Brush = brush ?? _device.BrushLoader.LoadSolidBrush(Colors.White), Font = font ?? _defaultFonts.Text, OutlineBrush = outlineBrush ?? _device.BrushLoader.LoadSolidBrush(Colors.White), OutlineWidth = outlineWidth, ShadowBrush = shadowBrush, ShadowOffsetX = shadowOffsetX, ShadowOffsetY = shadowOffsetY, Alignment = alignment, AutoFit = autoFit, PaddingLeft = paddingLeft, PaddingRight = paddingRight, PaddingTop = paddingTop, PaddingBottom = paddingBottom, LabelMinSize = labelMinSize }); }
public void RenderAll(Graphics ctx, float dt) { if (AutoFit != null) { AutoFit.Render(ctx, 0.0f); Bounds = CorrectBounds; } Render(ctx, dt); Animation ain = InAnimation, aout = OutAnimation; switch (state) { case ElementState.Showing: { ain?.Apply(ref props); ain?.Update(dt); if (ain == null || (ain != null && ain.State == AnimationState.Finished)) { state = ElementState.Shown; } } break; case ElementState.Hiding: { aout?.Apply(ref props); aout?.Update(dt); if (aout == null || (aout != null && aout.State == AnimationState.Finished)) { state = ElementState.Hidden; } } break; } }
internal Table(DocX document, XElement xml) : base(document, xml) { autofit = AutoFit.ColumnWidth; this.Xml = xml; this.mainPart = document.mainPart; XElement properties = xml.Element(XName.Get("tblPr", DocX.w.NamespaceName)); XElement style = properties?.Element(XName.Get("tblStyle", DocX.w.NamespaceName)); if (style != null) { XAttribute val = style.Attribute(XName.Get("val", DocX.w.NamespaceName)); if (val != null) { String cleanValue = val.Value.Replace("-", string.Empty); if (Enum.IsDefined(typeof(TableDesign), cleanValue)) { design = (TableDesign)Enum.Parse(typeof(TableDesign), cleanValue); } else { design = TableDesign.Custom; } } else design = TableDesign.None; } else design = TableDesign.None; XElement tableLook = properties?.Element(XName.Get("tblLook", DocX.w.NamespaceName)); if (tableLook != null) { TableLook = new TableLook { FirstRow = tableLook.GetAttribute(XName.Get("firstRow", DocX.w.NamespaceName)) == "1", LastRow = tableLook.GetAttribute(XName.Get("lastRow", DocX.w.NamespaceName)) == "1", FirstColumn = tableLook.GetAttribute(XName.Get("firstColumn", DocX.w.NamespaceName)) == "1", LastColumn = tableLook.GetAttribute(XName.Get("lastColumn", DocX.w.NamespaceName)) == "1", NoHorizontalBanding = tableLook.GetAttribute(XName.Get("noHBand", DocX.w.NamespaceName)) == "1", NoVerticalBanding = tableLook.GetAttribute(XName.Get("noVBand", DocX.w.NamespaceName)) == "1" }; } }
#pragma warning disable IDE0060 // Remove unused parameter internal static StaticLayout Truncate(string text, Forms9Patch.F9PFormattedString baseFormattedString, TextPaint paint, int availWidth, int availHeight, AutoFit fit, LineBreakMode lineBreakMode, float lineHeightMultiplier, ref int lines, ref ICharSequence textFormatted) #pragma warning restore IDE0060 // Remove unused parameter { StaticLayout layout = null; var fontMetrics = paint.GetFontMetrics(); var fontLineHeight = fontMetrics.Descent - fontMetrics.Ascent; var fontLeading = System.Math.Abs(fontMetrics.Bottom - fontMetrics.Descent); textFormatted = ((ICharSequence)baseFormattedString?.ToSpannableString()) ?? new Java.Lang.String(text); if (lines > 0) { if (baseFormattedString != null) { layout = TextExtensions.StaticLayout(textFormatted, paint, availWidth, Android.Text.Layout.Alignment.AlignNormal, lineHeightMultiplier, 0.0f, true); if (layout.Height > availHeight) { var visibleLines = (int)((fontLeading + availHeight) / (fontLineHeight + fontLeading)); if (visibleLines < lines) { lines = visibleLines; } } if (layout.LineCount > lines && lines > 0) { var secondToLastEnd = lines > 1 ? layout.GetLineEnd(lines - 2) : 0; var start = lines > 1 ? layout.GetLineStart(layout.LineCount - 2) : 0; textFormatted?.Dispose(); switch (lineBreakMode) { case LineBreakMode.HeadTruncation: textFormatted = StartTruncatedFormatted(baseFormattedString, paint, secondToLastEnd, start, layout.GetLineEnd(layout.LineCount - 1), availWidth, lineHeightMultiplier); break; case LineBreakMode.MiddleTruncation: textFormatted = MidTruncatedFormatted(baseFormattedString, paint, secondToLastEnd, layout.GetLineStart(lines - 1), (layout.GetLineEnd(lines - 1) + layout.GetLineStart(lines - 1)) / 2 - 1, start, layout.GetLineEnd(layout.LineCount - 1), availWidth, lineHeightMultiplier); break; case LineBreakMode.TailTruncation: textFormatted = EndTruncatedFormatted(baseFormattedString, paint, secondToLastEnd, layout.GetLineStart(lines - 1), layout.GetLineEnd(layout.LineCount - 1), availWidth, lineHeightMultiplier); break; default: textFormatted = TruncatedFormatted(baseFormattedString, paint, secondToLastEnd, layout.GetLineStart(lines - 1), layout.GetLineEnd(layout.LineCount - 1), availWidth, lineHeightMultiplier); break; } } } else { layout = TextExtensions.StaticLayout(text, paint, availWidth, Android.Text.Layout.Alignment.AlignNormal, lineHeightMultiplier, 0.0f, true); if (layout.Height > availHeight) { var visibleLines = (int)((fontLeading + availHeight) / (fontLineHeight + fontLeading)); if (visibleLines < lines) { lines = visibleLines; } } if (layout.LineCount > lines && lines > 0) { var secondToLastEnd = lines > 1 ? layout.GetLineEnd(lines - 2) : 0; var start = lines > 1 ? layout.GetLineStart(layout.LineCount - 2) : 0; switch (lineBreakMode) { case LineBreakMode.HeadTruncation: text = StartTruncatedLastLine(text, paint, secondToLastEnd, start, layout.GetLineEnd(layout.LineCount - 1), availWidth, lineHeightMultiplier); break; case LineBreakMode.MiddleTruncation: text = MidTruncatedLastLine(text, paint, secondToLastEnd, layout.GetLineStart(lines - 1), (layout.GetLineEnd(lines - 1) + layout.GetLineStart(lines - 1)) / 2 - 1, start, layout.GetLineEnd(layout.LineCount - 1), availWidth, lineHeightMultiplier); break; case LineBreakMode.TailTruncation: text = EndTruncatedLastLine(text, paint, secondToLastEnd, layout.GetLineStart(lines - 1), layout.GetLineEnd(layout.LineCount - 1), availWidth, lineHeightMultiplier); break; default: text = text.Substring(0, layout.GetLineEnd(lines - 1)); break; } textFormatted?.Dispose(); textFormatted = new Java.Lang.String(text); } } } var result = TextExtensions.StaticLayout(textFormatted, paint, availWidth, Android.Text.Layout.Alignment.AlignNormal, lineHeightMultiplier, 0.0f, true); layout?.Dispose(); //textFormatted?.Dispose(); // this causes Bc3.Keypad to break! return(result); }
//bool _truncating; internal static StaticLayout Truncate(string text, F9PFormattedString baseFormattedString, TextPaint paint, int availWidth, int availHeight, AutoFit fit, LineBreakMode lineBreakMode, ref int lines, ref ICharSequence textFormatted) { StaticLayout layout = null; var fontMetrics = paint.GetFontMetrics(); var fontLineHeight = fontMetrics.Descent - fontMetrics.Ascent; var fontLeading = System.Math.Abs(fontMetrics.Bottom - fontMetrics.Descent); textFormatted = ((ICharSequence)baseFormattedString?.ToSpannableString()) ?? new Java.Lang.String(text); if (lines > 0) { if (baseFormattedString != null) { layout = new StaticLayout(textFormatted, paint, availWidth, Android.Text.Layout.Alignment.AlignNormal, 1.0f, 0.0f, true); if (layout.Height > availHeight) { var visibleLines = (int)((fontLeading + availHeight) / (fontLineHeight + fontLeading)); if (visibleLines < lines) { lines = visibleLines; } } if (layout.LineCount > lines && lines > 0) { var secondToLastEnd = lines > 1 ? layout.GetLineEnd(lines - 2) : 0; var start = lines > 1 ? layout.GetLineStart(layout.LineCount - 2) : 0; switch (lineBreakMode) { case LineBreakMode.HeadTruncation: textFormatted = StartTruncatedFormatted(baseFormattedString, paint, secondToLastEnd, start, layout.GetLineEnd(layout.LineCount - 1), availWidth); break; case LineBreakMode.MiddleTruncation: textFormatted = MidTruncatedFormatted(baseFormattedString, paint, secondToLastEnd, layout.GetLineStart(lines - 1), (layout.GetLineEnd(lines - 1) + layout.GetLineStart(lines - 1)) / 2 - 1, start, layout.GetLineEnd(layout.LineCount - 1), availWidth); break; case LineBreakMode.TailTruncation: textFormatted = EndTruncatedFormatted(baseFormattedString, paint, secondToLastEnd, layout.GetLineStart(lines - 1), layout.GetLineEnd(layout.LineCount - 1), availWidth); break; default: //textFormatted = baseFormattedString.ToSpannableString(EllipsePlacement.None, 0, 0, layout.GetLineEnd(lines - 1)); textFormatted = TruncatedFormatted(baseFormattedString, paint, secondToLastEnd, layout.GetLineStart(lines - 1), layout.GetLineEnd(layout.LineCount - 1), availWidth); break; } } } else { layout = new StaticLayout(text, paint, availWidth, Android.Text.Layout.Alignment.AlignNormal, 1.0f, 0.0f, true); if (layout.Height > availHeight) { var visibleLines = (int)((fontLeading + availHeight) / (fontLineHeight + fontLeading)); if (visibleLines < lines) { lines = visibleLines; } } if (layout.LineCount > lines && lines > 0) { var secondToLastEnd = lines > 1 ? layout.GetLineEnd(lines - 2) : 0; var start = lines > 1 ? layout.GetLineStart(layout.LineCount - 2) : 0; switch (lineBreakMode) { case LineBreakMode.HeadTruncation: text = StartTruncatedLastLine(text, paint, secondToLastEnd, start, layout.GetLineEnd(layout.LineCount - 1), availWidth); break; case LineBreakMode.MiddleTruncation: text = MidTruncatedLastLine(text, paint, secondToLastEnd, layout.GetLineStart(lines - 1), (layout.GetLineEnd(lines - 1) + layout.GetLineStart(lines - 1)) / 2 - 1, start, layout.GetLineEnd(layout.LineCount - 1), availWidth); break; case LineBreakMode.TailTruncation: text = EndTruncatedLastLine(text, paint, secondToLastEnd, layout.GetLineStart(lines - 1), layout.GetLineEnd(layout.LineCount - 1), availWidth); break; default: text = text.Substring(0, layout.GetLineEnd(lines - 1)); break; } textFormatted = new Java.Lang.String(text); } } } return(new StaticLayout(textFormatted, paint, availWidth, Android.Text.Layout.Alignment.AlignNormal, 1.0f, 0.0f, true)); }
public override bool Render() { RPLItemMeasurement rPLItemMeasurement = null; bool flag = true; string author = ""; string title = ""; string description = ""; AutoFit autoFit = base.m_writer.AutoFit; float num = 0f; float leftMargin = 0f; float rightMargin = 0f; RPLPageLayout rPLPageLayout = null; bool flag2 = false; List <RPLReport> rplReportCache = new List <RPLReport>(); while (!base.m_spbProcessing.Done) { if (!flag) { base.m_writer.WritePageBreak(); } base.m_spbProcessing.GetNextPage(out base.m_rplReport); RPLPageContent rPLPageContent = base.m_rplReport.RPLPaginatedPages[0]; RPLReportSection rPLReportSection = rPLPageContent.GetNextReportSection(); bool flag3 = false; bool flag4 = true; while (rPLReportSection != null) { rPLItemMeasurement = rPLReportSection.Columns[0]; float width = rPLReportSection.BodyArea.Width; RPLHeaderFooter footer = null; SectionEntry sectionEntry = null; if (!flag4 || this.m_sections.Count == 0 || string.CompareOrdinal(this.m_sections[this.m_sections.Count - 1].SectionId, rPLReportSection.ID) != 0) { if (RSTrace.RenderingTracer.TraceVerbose) { RSTrace.RenderingTracer.Trace("The left or right margin is either <0 or the sum exceeds the page width."); } sectionEntry = new SectionEntry(rPLReportSection); if (rPLReportSection.Footer != null) { footer = (rPLReportSection.Footer.Element as RPLHeaderFooter); } if (sectionEntry.HeaderMeasurement != null || sectionEntry.FooterMeasurement != null) { flag2 = true; } this.m_sections.Add(sectionEntry); base.CachePage(ref flag3, rplReportCache); } flag = base.SetFirstPageDimensions(flag, rPLPageContent, ref rPLPageLayout, ref leftMargin, ref rightMargin, ref num, ref title, ref author, ref description); num = base.RevisePageDimensions(leftMargin, rightMargin, num, width, autoFit); base.RenderHeaderBetweenSections(rPLReportSection, flag4); base.RenderBodyContent(width, rPLItemMeasurement); rPLReportSection = base.AdvanceToNextSection(rPLPageContent, rPLReportSection, ref flag4, this.m_sections[this.m_sections.Count - 1], footer, sectionEntry); } if (!base.m_spbProcessing.Done && !flag3) { base.m_rplReport.Release(); } } base.m_writer.WriteParagraphEnd(); base.m_writer.SetPageDimensions(base.m_pageHeight, num, leftMargin, rightMargin, rPLPageLayout.MarginTop, rPLPageLayout.MarginBottom); if (flag2) { base.m_inHeaderFooter = true; base.m_writer.InitHeaderFooter(); bool flag5 = false; base.m_needsToResetTextboxes = true; for (int i = 0; i < this.m_sections.Count; i++) { RPLItemMeasurement headerMeasurement = this.m_sections[i].HeaderMeasurement; if (headerMeasurement != null) { base.RenderRectangle((RPLContainer)headerMeasurement.Element, 0f, true, headerMeasurement, new BorderContext(), false, true); } base.m_writer.FinishHeader(i); RPLItemMeasurement footerMeasurement = this.m_sections[i].FooterMeasurement; if (footerMeasurement != null) { base.RenderRectangle((RPLContainer)footerMeasurement.Element, 0f, true, footerMeasurement, new BorderContext(), false, true); } base.m_writer.FinishFooter(i); if (i == 0) { bool flag6 = headerMeasurement != null; bool flag7 = flag6 && !(headerMeasurement.Element.ElementPropsDef as RPLHeaderFooterPropsDef).PrintOnFirstPage; bool flag8 = footerMeasurement != null; bool flag9 = flag8 && !(footerMeasurement.Element.ElementPropsDef as RPLHeaderFooterPropsDef).PrintOnFirstPage; flag5 = ((flag7 || flag9) && (flag6 || flag8)); if (flag5) { if (flag6 && !flag7) { base.RenderRectangle((RPLContainer)headerMeasurement.Element, 0f, true, headerMeasurement, new BorderContext(), false, true); } base.m_writer.FinishHeader(i, Word97Writer.HeaderFooterLocation.First); if (flag8 && !flag9) { base.RenderRectangle((RPLContainer)footerMeasurement.Element, 0f, true, footerMeasurement, new BorderContext(), false, true); } base.m_writer.FinishFooter(i, Word97Writer.HeaderFooterLocation.First); } base.m_needsToResetTextboxes = false; } } base.m_writer.FinishHeadersFooters(flag5); base.m_inHeaderFooter = false; } base.FinishRendering(rplReportCache, title, author, description); return(true); }
public OpenXmlTableModel(OpenXmlTableModel containingTable, InterleavingWriter interleavingWriter, AutoFit autofit) { this._containingTable = containingTable; this._interleavingWriter = interleavingWriter; this._interleavingWriter.TextWriter.Write("<w:tbl>"); this._tableProperties = new OpenXmlTablePropertiesModel(autofit); }
internal Table(DocX document, XElement xml) : base(document, xml) { autofit = AutoFit.ColumnWidth; this.Xml = xml; XElement properties = xml.Element(XName.Get("tblPr", DocX.w.NamespaceName)); XElement style = properties.Element(XName.Get("tblStyle", DocX.w.NamespaceName)); if (style != null) { XAttribute val = style.Attribute(XName.Get("val", DocX.w.NamespaceName)); if (val != null) { try { design = (TableDesign)Enum.Parse(typeof(TableDesign), val.Value.Replace("-", string.Empty)); } catch (Exception) { design = TableDesign.Custom; } } else design = TableDesign.None; } else design = TableDesign.None; XElement tableLook = properties.Element(XName.Get("tblLook", DocX.w.NamespaceName)); if (tableLook != null) { TableLook = new TableLook(); TableLook.FirstRow = tableLook.GetAttribute(XName.Get("firstRow", DocX.w.NamespaceName)) == "1"; TableLook.LastRow = tableLook.GetAttribute(XName.Get("lastRow", DocX.w.NamespaceName)) == "1"; TableLook.FirstColumn = tableLook.GetAttribute(XName.Get("firstColumn", DocX.w.NamespaceName)) == "1"; TableLook.LastColumn = tableLook.GetAttribute(XName.Get("lastColumn", DocX.w.NamespaceName)) == "1"; TableLook.NoHorizontalBanding = tableLook.GetAttribute(XName.Get("noHBand", DocX.w.NamespaceName)) == "1"; TableLook.NoVerticalBanding = tableLook.GetAttribute(XName.Get("noVBand", DocX.w.NamespaceName)) == "1"; } }
public OpenXmlTablePropertiesModel(AutoFit autofit) { this._autofit = (autofit == AutoFit.True || autofit == AutoFit.Default); }
public void InitTableRow(float leftStart, float rowHeight, float[] columnWidths, AutoFit autoFit) { if (this.m_tapx.Offset == 14) { float num = 0f; foreach (float num2 in columnWidths) { num += num2; } if (num / 25.399999618530273 > 22.0) { RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "The maximum page width of the report exceeds 22 inches (55.88 centimeters)."); } else if (columnWidths.Length > 63) { RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "The rendered report contains a table that has more than 63 columns."); } this.m_columnWidths = columnWidths; this.m_numColumns = columnWidths.Length; this.m_borderColors = new CellBorderColor(this.m_numColumns); this.m_cellShading = new CellShading(this.m_numColumns, this.m_tableShd); this.m_cellPadding = new CellPadding(this.m_numColumns); this.CreateTableDefSprm(leftStart); if (autoFit != AutoFit.Never) { this.m_tapx.AddSprm(13845, (int)autoFit, null); } if (this.m_tableShd != null) { this.m_tapx.AddSprm(54880, 0, this.m_tableShd); } this.m_startOffset = this.m_tapx.Offset; } else { this.m_tapx.Clear(this.m_startOffset, this.m_tapx.Buf.Length - this.m_startOffset); int tcLocation = this.GetTcLocation(this.m_numColumns, 0); this.m_tapx.Clear(tcLocation, this.m_numColumns * 20); this.m_borderColors.Reset(); this.m_cellShading.Reset(); this.m_cellPadding.Reset(); this.m_tapx.Reset(this.m_startOffset); } this.m_rowHeight = Word97Writer.ToTwips(rowHeight); this.WriteExactRowHeight = false; this.WriteRowHeight = true; }
internal override bool Render() { RPLItemMeasurement rPLItemMeasurement = null; bool flag = true; string author = ""; string title = ""; string description = ""; AutoFit autoFit = m_writer.AutoFit; float width = 0f; float leftMargin = 0f; float rightMargin = 0f; RPLPageLayout rplPageLayout = null; bool flag2 = false; List <RPLReport> rplReportCache = new List <RPLReport>(); while (!m_spbProcessing.Done) { if (!flag) { m_writer.WritePageBreak(); } m_spbProcessing.GetNextPage(out m_rplReport); RPLPageContent rPLPageContent = m_rplReport.RPLPaginatedPages[0]; RPLReportSection rPLReportSection = rPLPageContent.GetNextReportSection(); bool pageCached = false; bool firstSection = true; while (rPLReportSection != null) { rPLItemMeasurement = rPLReportSection.Columns[0]; float width2 = rPLReportSection.BodyArea.Width; RPLHeaderFooter footer = null; SectionEntry sectionEntry = null; if (!firstSection || m_sections.Count == 0 || string.CompareOrdinal(m_sections[m_sections.Count - 1].SectionId, rPLReportSection.ID) != 0) { if (RSTrace.RenderingTracer.TraceVerbose) { RSTrace.RenderingTracer.Trace("The left or right margin is either <0 or the sum exceeds the page width."); } sectionEntry = new SectionEntry(rPLReportSection); if (rPLReportSection.Footer != null) { footer = (rPLReportSection.Footer.Element as RPLHeaderFooter); } if (sectionEntry.HeaderMeasurement != null || sectionEntry.FooterMeasurement != null) { flag2 = true; } m_sections.Add(sectionEntry); CachePage(ref pageCached, rplReportCache); } flag = SetFirstPageDimensions(flag, rPLPageContent, ref rplPageLayout, ref leftMargin, ref rightMargin, ref width, ref title, ref author, ref description); width = RevisePageDimensions(leftMargin, rightMargin, width, width2, autoFit); RenderHeaderBetweenSections(rPLReportSection, firstSection); RenderBodyContent(width2, rPLItemMeasurement); rPLReportSection = AdvanceToNextSection(rPLPageContent, rPLReportSection, ref firstSection, m_sections[m_sections.Count - 1], footer, sectionEntry); } if (!m_spbProcessing.Done && !pageCached) { m_rplReport.Release(); } } m_writer.WriteParagraphEnd(); m_writer.SetPageDimensions(m_pageHeight, width, leftMargin, rightMargin, rplPageLayout.MarginTop, rplPageLayout.MarginBottom); if (flag2) { m_inHeaderFooter = true; m_writer.InitHeaderFooter(); bool flag3 = false; m_needsToResetTextboxes = true; for (int i = 0; i < m_sections.Count; i++) { RPLItemMeasurement headerMeasurement = m_sections[i].HeaderMeasurement; if (headerMeasurement != null) { RenderRectangle((RPLContainer)headerMeasurement.Element, 0f, canGrow: true, headerMeasurement, new BorderContext(), inTablix: false, ignoreStyles: true); } m_writer.FinishHeader(i); RPLItemMeasurement footerMeasurement = m_sections[i].FooterMeasurement; if (footerMeasurement != null) { RenderRectangle((RPLContainer)footerMeasurement.Element, 0f, canGrow: true, footerMeasurement, new BorderContext(), inTablix: false, ignoreStyles: true); } m_writer.FinishFooter(i); if (i != 0) { continue; } bool flag4 = headerMeasurement != null; bool flag5 = flag4 && !(headerMeasurement.Element.ElementPropsDef as RPLHeaderFooterPropsDef).PrintOnFirstPage; bool flag6 = footerMeasurement != null; bool flag7 = flag6 && !(footerMeasurement.Element.ElementPropsDef as RPLHeaderFooterPropsDef).PrintOnFirstPage; flag3 = ((flag5 || flag7) && (flag4 || flag6)); if (flag3) { if (flag4 && !flag5) { RenderRectangle((RPLContainer)headerMeasurement.Element, 0f, canGrow: true, headerMeasurement, new BorderContext(), inTablix: false, ignoreStyles: true); } m_writer.FinishHeader(i, Word97Writer.HeaderFooterLocation.First); if (flag6 && !flag7) { RenderRectangle((RPLContainer)footerMeasurement.Element, 0f, canGrow: true, footerMeasurement, new BorderContext(), inTablix: false, ignoreStyles: true); } m_writer.FinishFooter(i, Word97Writer.HeaderFooterLocation.First); } m_needsToResetTextboxes = false; } m_writer.FinishHeadersFooters(flag3); m_inHeaderFooter = false; } FinishRendering(rplReportCache, title, author, description); return(true); }
protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Size availableSize) { if (DebugCondition) { System.Diagnostics.Debug.WriteLine(""); } var label = Element; var textBlock = Control; DebugMessage("[" + _measureOverrideInvocation + "] MeasureOverride pre-Enter availableSize=[" + availableSize + "] ElemmentSize=[" + Element.Bounds.Size + "] PageSize=[" + Xamarin.Forms.Application.Current.MainPage.Bounds.Size + "]"); DebugMessage("[" + _measureOverrideInvocation + "] \t\t availWidth>=Page.Width=[" + (Math.Round(availableSize.Width) >= Math.Round(Xamarin.Forms.Application.Current.MainPage.Width)) + "]"); DebugMessage("[" + _measureOverrideInvocation + "] \t\t availHeight>=Page.Height=[" + (Math.Round(availableSize.Height) >= Math.Round(Xamarin.Forms.Application.Current.MainPage.Height)) + "]"); DebugMessage("[" + _measureOverrideInvocation + "] \t\t Element.Parent=[" + Element.Parent + "]"); DebugMessage("[" + _measureOverrideInvocation + "] \t\t MeasureOverride FontSize=[" + textBlock.FontSize + "] BaseLineOffset=[" + textBlock.BaselineOffset + "] LineHeight=[" + textBlock.LineHeight + "]"); if (DebugCondition) { System.Diagnostics.Debug.WriteLine(""); } if (label == null || textBlock == null || availableSize.Width == 0 || availableSize.Height == 0) { return(new Windows.Foundation.Size(0, 0)); } //if (Double.IsInfinity(availableSize.Height) && Double.IsInfinity(availableSize.Width)) // LayoutValid = false; if (LayoutValid && _lastAvailableSize.Width <= availableSize.Width && _lastAvailableSize.Height <= availableSize.Height && _lastElementSize == Element.Bounds.Size && DateTime.Now - _lastMeasure < TimeSpan.FromSeconds(1)) { return(_lastMeasureOverrideResult); } //_lastAvailableSize = availableSize; if (DebugCondition) { System.Diagnostics.Debug.WriteLine(""); } DebugMessage("[" + _measureOverrideInvocation + "] MeasureOverride ENTER availableSize=[" + availableSize + "]"); //Element.IsInNativeLayout = true; label.SetIsInNativeLayout(true); double width = (Math.Round(availableSize.Width) >= Math.Round(Xamarin.Forms.Application.Current.MainPage.Width)) && label.Width > 0 ? Math.Min(label.Width, availableSize.Width) : availableSize.Width; double height = (Math.Round(availableSize.Height) >= Math.Round(Xamarin.Forms.Application.Current.MainPage.Height)) && label.Height > 0 ? Math.Min(label.Height, availableSize.Height) : availableSize.Height; if (Double.IsInfinity(availableSize.Width) && (label.Width < 0 || !newElement)) { width = availableSize.Width; } if (Double.IsInfinity(availableSize.Height) && (label.Height < 0 || !newElement)) { height = availableSize.Height; } newElement = false; if (Element.Width > 0 && Element.Height > 0 && !Double.IsInfinity(width) && !Double.IsInfinity(height)) // This line was causing UWP to fail to correctly update width of BcOperandLabel during editing. //if (Element.Width > width && Element.Height > height && !Double.IsInfinity(width) && !Double.IsInfinity(height)) { width = Math.Max(Element.Width, width); height = Math.Max(Element.Height, height); } DebugMessage("[" + _measureOverrideInvocation + "] \t\t width=[" + width + "] height=[" + height + "]"); if (DebugCondition) { System.Diagnostics.Debug.WriteLine(""); } //double width = !double.IsInfinity(availableSize.Width) && label.Width > 0 ? Math.Min(label.Width, availableSize.Width) : availableSize.Width; //double height = !double.IsInfinity(availableSize.Height) && label.Height > 0 ? Math.Min(label.Height, availableSize.Height) : availableSize.Height; //double width = availableSize.Width; //double height = availableSize.Height; var result = new Windows.Foundation.Size(width, height); if (textBlock != null) { // reset FontSize var tmpFontSize = label.DecipheredFontSize(); if (DebugCondition) { System.Diagnostics.Debug.WriteLine(""); } if (Element.SynchronizedFontSize > Element.MinFontSize) { tmpFontSize = Element.SynchronizedFontSize; } var minFontSize = label.DecipheredMinFontSize(); textBlock.MaxLines = 0; // int.MaxValue / 3; textBlock.MaxWidth = double.PositiveInfinity; textBlock.MaxHeight = double.PositiveInfinity; textBlock.MinHeight = 0; textBlock.MinWidth = 0; //textBlock.LineStackingStrategy = LineStackingStrategy. // textBlock.TextWrapping = TextWrapping.WrapWholeWords; UpdateLineBreakMode(textBlock); double tmpHt = -1; textBlock.SetAndFormatText(label, tmpFontSize); textBlock.Measure(new Windows.Foundation.Size(width, double.PositiveInfinity)); _fontMetrics = textBlock.GetFontMetrics(); if (label.Lines == 0) { // do our best job to fit the existing space. if (textBlock.DesiredSize.Width - width > Precision || textBlock.DesiredSize.Height - height > Precision) { tmpFontSize = ZeroLinesFit(label, textBlock, minFontSize, tmpFontSize, width, height); textBlock.SetAndFormatText(label, tmpFontSize); textBlock.Measure(new Windows.Foundation.Size(width, double.PositiveInfinity)); } } else if (label.AutoFit == AutoFit.Lines) { tmpHt = height; if (height > int.MaxValue / 3) { //tmpHt = height = label.Lines * (_fontMetrics.LineHeightForFontSize(tmpFontSize) + ; tmpHt = height = _fontMetrics.HeightForLinesAtFontSize(label.Lines, tmpFontSize); } else {// set the font size to fit Label.Lines into the available height //tmpFontSize = _fontMetrics.FontSizeFromLineHeight(height / label.Lines); tmpFontSize = _fontMetrics.FontSizeFromLinesInHeight(label.Lines, tmpHt); tmpFontSize = FontExtensions.ClipFontSize(tmpFontSize, label); textBlock.SetAndFormatText(label, tmpFontSize); textBlock.Measure(new Windows.Foundation.Size(width, double.PositiveInfinity)); } } else if (label.AutoFit == AutoFit.Width) { //if (textBlock.DesiredSize.Height / textBlock.LineHeight > label.Lines) if (textBlock.ActualWidth > textBlock.DesiredSize.Width || textBlock.DesiredSize.Height / textBlock.LineHeight > label.Lines) { tmpFontSize = WidthAndLinesFit(label, textBlock, label.Lines, minFontSize, tmpFontSize, width); textBlock.SetAndFormatText(label, tmpFontSize); textBlock.Measure(new Windows.Foundation.Size(width, double.PositiveInfinity)); } } // autofit is off! // No need to do anything at the moment. Will textBlock.SetAndFormat and textBlock.Measure at the end //{ // textBlock.SetAndFormatText(label, tmpFontSize); // textBlock?.Measure(new Windows.Foundation.Size(w, double.PositiveInfinity)); //} // none of these should happen so let's keep an eye out for it to be sure everything upstream is working if (tmpFontSize > label.DecipheredFontSize()) { throw new Exception("fitting somehow returned a tmpFontSize > label.FontSize"); } if (tmpFontSize < label.DecipheredMinFontSize()) { throw new Exception("fitting somehow returned a tmpFontSize < label.MinFontSize"); } // the following doesn't apply when where growing //if (tmpFontSize > label.DecipheredMinFontSize() && (textBlock.DesiredSize.Width > Math.Ceiling(w) || textBlock.DesiredSize.Height > Math.Ceiling(Math.Max(availableSize.Height, label.Height))) ) // throw new Exception("We should never exceed the available bounds if the FontSize is greater than label.MinFontSize"); // we needed the following in Android as well. Xamarin layout really doesn't like this to be changed in real time. if (Element != null && Control != null) // multipicker test was getting here with Element and Control both null { if (tmpFontSize == Element.FontSize || (Element.FontSize == -1 && tmpFontSize == FontExtensions.DefaultFontSize())) { if (DebugCondition) { System.Diagnostics.Debug.WriteLine(""); } Element.FittedFontSize = -1; } else { if (DebugCondition) { System.Diagnostics.Debug.WriteLine(""); } Element.FittedFontSize = tmpFontSize; } } DebugMessage("[" + _measureOverrideInvocation + "] MeasureOverride Element.FittedFontSize=[" + Element.FittedFontSize + "]"); /* * var syncFontSize = ((ILabel)label).SynchronizedFontSize; * DebugMessage("[" + _measureOverrideInvocation + "] syncFontSize=[" + syncFontSize+"]"); * if (syncFontSize >= 0 && tmpFontSize != syncFontSize) * { * tmpHt = -1; * textBlock.SetAndFormatText(label, syncFontSize); * textBlock.Measure(new Windows.Foundation.Size(width, double.PositiveInfinity)); * } * else * { * textBlock.SetAndFormatText(label, tmpFontSize); * textBlock.Measure(new Windows.Foundation.Size(width, double.PositiveInfinity)); * } */ result = new Windows.Foundation.Size(Math.Ceiling(textBlock.DesiredSize.Width), Math.Ceiling(tmpHt > -1 ? tmpHt : textBlock.DesiredSize.Height)); if (DebugCondition && label.Width > 0 && label.Height > 0 && (textBlock.DesiredSize.Width > label.Width || textBlock.DesiredSize.Height > label.Height)) { System.Diagnostics.Debug.WriteLine(""); } DebugMessage("[" + _measureOverrideInvocation + "] availableSize=[" + availableSize + "] result=[" + result + "] FontSize=[" + textBlock.FontSize + "] LineHeight=[" + textBlock.LineHeight + "] "); //System.Diagnostics.Debug.WriteLine("[" + _measureOverrideInvocation + "] MeasureOverride [" + (Element.Text ?? Element.HtmlText)+"] availableSize=[" + availableSize + "] result=[" + result + "] FontSize=[" + textBlock.FontSize + "] LineHeight=[" + textBlock.LineHeight + "] "); textBlock.MaxLines = label.Lines; } label.SetIsInNativeLayout(false); DebugMessage("[" + _measureOverrideInvocation + "] MeasureOverride EXIT"); LayoutValid = true; _lastAvailableSize = availableSize; _lastElementSize = Element.Bounds.Size; _lastAutoFit = label.AutoFit; _lastLines = label.Lines; _lastMeasure = DateTime.Now; _lastMeasureOverrideResult = result; if (DebugCondition) { _measureOverrideInvocation++; } return(result); }
private void updateBoundingBoxes(AutoFit autoFit, IGLMatrices textMatrices, IGLMatrices labelMatrices, PointF resolutionFactor, bool buildRenderBox, bool buildHitTestBox) { switch (autoFit) { case AutoFit.NoFitting: _boundingBoxBuilder.Build(_labelBoundingBoxes, BaseSize.Width, BaseSize.Height, labelMatrices, buildRenderBox, buildHitTestBox); updateText(GLText.EmptySize, null); _boundingBoxBuilder.Build(_textBoundingBoxes, _glText.BitmapWidth, _glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; case AutoFit.TextShouldWrapAndLabelShouldFitHeight: _boundingBoxBuilder.Build(_labelBoundingBoxes, BaseSize.Width, BaseSize.Height, labelMatrices, buildRenderBox, buildHitTestBox); updateText(GLText.EmptySize, (int?)BaseSize.Width); _boundingBoxBuilder.Build(_textBoundingBoxes, _glText.BitmapWidth, _glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox); _boundingBoxBuilder.Build(_labelBoundingBoxes, _glText.Width, _glText.Height, labelMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; case AutoFit.TextShouldFitLabel: _boundingBoxBuilder.Build(_labelBoundingBoxes, BaseSize.Width, BaseSize.Height, labelMatrices, buildRenderBox, buildHitTestBox); updateText(_glText.Width > BaseSize.Width ? GLText.EmptySize : new SizeF(BaseSize.Width, GLText.EmptySize.Height), null); float textWidth = _glText.Width < BaseSize.Width ? _glText.BitmapWidth : MathUtils.Lerp(0f, 0f, _glText.Width, BaseSize.Width, _glText.BitmapWidth); float textHeight = _glText.Height < BaseSize.Height ? _glText.BitmapHeight : MathUtils.Lerp(0f, 0f, _glText.Height, BaseSize.Height, _glText.BitmapHeight); _boundingBoxBuilder.Build(_textBoundingBoxes, textWidth, textHeight, textMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; case AutoFit.LabelShouldFitText: _boundingBoxBuilder.Build(_textBoundingBoxes, _glText.BitmapWidth, _glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox); _boundingBoxBuilder.Build(_labelBoundingBoxes, _glText.Width * resolutionFactor.X, _glText.Height * resolutionFactor.Y, textMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; case AutoFit.TextShouldCrop: _boundingBoxBuilder.Build(_labelBoundingBoxes, BaseSize.Width, BaseSize.Height, labelMatrices, buildRenderBox, buildHitTestBox); updateText(_glText.Width > BaseSize.Width ? GLText.EmptySize : new SizeF(BaseSize.Width, GLText.EmptySize.Height), (int)BaseSize.Width, true); float heightOfText = _glText.Height < BaseSize.Height ? _glText.BitmapHeight : MathUtils.Lerp(0f, 0f, _glText.Height, BaseSize.Height, _glText.BitmapHeight); _boundingBoxBuilder.Build(_textBoundingBoxes, _glText.BitmapWidth, heightOfText, textMatrices, buildRenderBox, buildHitTestBox); _usedLabelBoundingBoxes = _labelBoundingBoxes; _usedTextBoundingBoxes = _textBoundingBoxes; break; default: throw new NotSupportedException(autoFit.ToString()); } }
private void updateBoundingBoxes(IObject obj, IDrawableInfoComponent drawable, IViewport viewport) { var noFactor = AGSModelMatrixComponent.NoScaling; bool resolutionMatches; PointF hitTestResolutionFactor; Size resolution; PointF textScaleFactor = new PointF(GLText.TextResolutionFactorX, GLText.TextResolutionFactorY); if (!textScaleFactor.Equals(_lastTextScaleFactor)) { _lastTextScaleFactor = textScaleFactor; onBoundingBoxShouldChange(); } resolutionMatches = AGSModelMatrixComponent.GetVirtualResolution(false, _virtualResolution, drawable, textScaleFactor, out hitTestResolutionFactor, out resolution); var scaleUpText = hitTestResolutionFactor; var scaleDownText = noFactor; if (!textScaleFactor.Equals(hitTestResolutionFactor)) { textScaleFactor = noFactor; scaleDownText = hitTestResolutionFactor; } AutoFit autoFit = getAutoFit(); float height = obj.Height; float width = obj.Width; bool shouldUpdateBoundingBoxes = _shouldUpdateBoundingBoxes; _shouldUpdateBoundingBoxes = false; if (autoFit == AutoFit.LabelShouldFitText) { updateText(_glTextHitTest, resolutionMatches, GLText.EmptySize, scaleUpText, scaleDownText, int.MaxValue); if (!resolutionMatches) { updateText(_glTextRender, true, GLText.EmptySize, scaleUpText, scaleDownText, int.MaxValue); } CustomImageSize = new SizeF(_glTextHitTest.Width, _glTextHitTest.Height); } else if (autoFit == AutoFit.TextShouldWrapAndLabelShouldFitHeight) { updateText(_glTextHitTest, resolutionMatches, new SizeF(BaseSize.Width, GLText.EmptySize.Height), scaleUpText, scaleDownText, (int)BaseSize.Width); if (!resolutionMatches) { updateText(_glTextRender, true, new SizeF(BaseSize.Width, GLText.EmptySize.Height), scaleUpText, scaleDownText, (int)BaseSize.Width); } CustomImageSize = new SizeF(BaseSize.Width, _glTextHitTest.Height); } else { CustomImageSize = BaseSize; } CustomImageResolutionFactor = hitTestResolutionFactor; var viewportMatrix = drawable.IgnoreViewport ? Matrix4.Identity : _viewport.GetViewport(drawable.RenderLayer.Z).GetMatrix(viewport, drawable.RenderLayer.ParallaxSpeed); if (!viewportMatrix.Equals(_lastViewportMatrix)) { _lastViewportMatrix = viewportMatrix; onBoundingBoxShouldChange(); } var modelMatrices = obj.GetModelMatrices(); if (!modelMatrices.Equals(_lastMatrices)) { _lastMatrices = modelMatrices; onBoundingBoxShouldChange(); } if (!shouldUpdateBoundingBoxes) { return; } IGLMatrices textRenderMatrices = acquireMatrix(0).SetMatrices(modelMatrices.InObjResolutionMatrix, viewportMatrix); IGLMatrices labelRenderMatrices = obj.RenderLayer.IndependentResolution != null ? textRenderMatrices : acquireMatrix(1).SetMatrices(modelMatrices.InVirtualResolutionMatrix, viewportMatrix); IGLMatrices textHitTestMatrices = resolutionMatches ? textRenderMatrices : obj.RenderLayer.IndependentResolution == null ? labelRenderMatrices : acquireMatrix(2).SetMatrices(modelMatrices.InVirtualResolutionMatrix, viewportMatrix); IGLMatrices labelHitTestMatrices = obj.RenderLayer.IndependentResolution == null ? labelRenderMatrices : textHitTestMatrices; if (textScaleFactor.Equals(hitTestResolutionFactor)) { hitTestResolutionFactor = noFactor; } updateBoundingBoxes(_glTextHitTest, autoFit, textHitTestMatrices, labelHitTestMatrices, scaleUpText, noFactor, hitTestResolutionFactor, resolutionMatches, true); if (!resolutionMatches) { updateBoundingBoxes(_glTextRender, autoFit, textRenderMatrices, labelRenderMatrices, scaleUpText, scaleDownText, noFactor, true, false); } if (_lastWidth != Width || _lastHeight != Height) { OnLabelSizeChanged.Invoke(); } _lastWidth = Width; _lastHeight = Height; }
internal Table(DocX document, XElement xml) { autofit = AutoFit.ColoumnWidth; this.xml = xml; this.document = document; XElement properties = xml.Element(XName.Get("tblPr", DocX.w.NamespaceName)); rows = (from r in xml.Elements(XName.Get("tr", DocX.w.NamespaceName)) select new Row(document, r)).ToList(); rowCount = rows.Count; if (rows.Count > 0) if (rows[0].Cells.Count > 0) columnCount = rows[0].Cells.Count; XElement style = properties.Element(XName.Get("tblStyle", DocX.w.NamespaceName)); if (style != null) { XAttribute val = style.Attribute(XName.Get("val", DocX.w.NamespaceName)); if (val != null) { try { design = (TableDesign)Enum.Parse(typeof(TableDesign), val.Value.Replace("-", string.Empty)); } catch (Exception e) { design = TableDesign.Custom; } } else design = TableDesign.None; } else design = TableDesign.None; }