private Win32ObjectSafeHandle CreateGdiFont(RPLFormat.WritingModes writingMode, int fontSize, bool bold, bool italic, bool lineThrough, byte charset, bool verticalFont, string fontFamily) { int nEscapement = 0; int nOrientation = 0; if (this.VerticalMode) { if (!this.UseEmSquare) { if (writingMode == RPLFormat.WritingModes.Vertical) { nEscapement = 2700; nOrientation = 2700; } else { nEscapement = 900; nOrientation = 900; } } if (verticalFont) { fontFamily = "@" + fontFamily; } } return(Win32.CreateFont(-fontSize, 0, nEscapement, nOrientation, bold ? 700 : 400, (uint)(italic ? 1 : 0), 0u, (uint)(lineThrough ? 1 : 0), charset, 4u, 0u, this.m_fontQuality, 0u, fontFamily)); }
private void RenderWritingMode(int cellIndex, RPLFormat.WritingModes writingModes) { if (writingModes == RPLFormat.WritingModes.Vertical || writingModes == RPLFormat.WritingModes.Rotate270) { int tcLocation = GetTcLocation(m_numColumns, cellIndex); ushort uShort = LittleEndian.getUShort(m_tapx.Buf, tcLocation); uShort = (ushort)(uShort | (byte)((writingModes == RPLFormat.WritingModes.Vertical) ? (TC_ROTATEFONT | TC_VERTICAL) : (TC_BACKWARD | TC_VERTICAL))); LittleEndian.PutUShort(m_tapx.Buf, tcLocation, uShort); } }
private void SetWritingMode(RPLFormat.WritingModes mode) { switch (mode) { case RPLFormat.WritingModes.Rotate270: this._document.TableContext.CurrentCell.CellProperties.TextOrientation = OpenXmlTableCellPropertiesModel.TextOrientationEnum.Rotate270; break; case RPLFormat.WritingModes.Vertical: this._document.TableContext.CurrentCell.CellProperties.TextOrientation = OpenXmlTableCellPropertiesModel.TextOrientationEnum.Rotate90; break; } }
public void DrawTextRun(TextRun run, Paragraph paragraph, Win32DCSafeHandle hdc, float dpiX, FontCache fontCache, int x, int y, int baselineY, int lineHeight, Rectangle layoutRectangle) { RPLFormat.WritingModes writingMode = WritingMode; if (string.IsNullOrEmpty(run.Text)) { return; } Underline underline = null; if (run.UnderlineHeight > 0) { underline = new Underline(run, hdc, fontCache, layoutRectangle, x, baselineY, writingMode); } int x2; int baselineY2; switch (writingMode) { case RPLFormat.WritingModes.Horizontal: x2 = layoutRectangle.X + x; baselineY2 = layoutRectangle.Y + baselineY; break; case RPLFormat.WritingModes.Vertical: x2 = layoutRectangle.X + (layoutRectangle.Width - baselineY); baselineY2 = layoutRectangle.Y + x; break; case RPLFormat.WritingModes.Rotate270: x2 = layoutRectangle.X + baselineY; baselineY2 = layoutRectangle.Y + layoutRectangle.Height - x; break; default: throw new NotSupportedException(); } if (!m_context.TestMode) { TextBox.DrawTextRun(run, hdc, fontCache, x2, baselineY2, underline); } else { TextBox.ExtDrawTextRun(run, hdc, fontCache, x2, baselineY2, underline); } RenderingTextRun renderingTextRun = run.TextRunProperties as RenderingTextRun; if (renderingTextRun == null) { return; } RPLTextRunProps rPLTextRunProps = renderingTextRun.InstanceProperties as RPLTextRunProps; if (rPLTextRunProps == null) { return; } float num = SharedRenderer.ConvertToMillimeters(run.GetWidth(hdc, fontCache), dpiX); float num2 = SharedRenderer.ConvertToMillimeters(run.GetHeight(hdc, fontCache), dpiX); float num3 = SharedRenderer.ConvertToMillimeters(x, dpiX); float num4 = SharedRenderer.ConvertToMillimeters(y, dpiX); SizeF empty = SizeF.Empty; PointF location = PointF.Empty; if (writingMode == RPLFormat.WritingModes.Horizontal) { empty = new SizeF(num, num2); location = new PointF(num3 + TextPosition.X, num4 - num2 + TextPosition.Y); } else { empty = new SizeF(num2, num); if (writingMode == RPLFormat.WritingModes.Vertical) { float num5 = SharedRenderer.ConvertToMillimeters(layoutRectangle.Right, dpiX); float num6 = SharedRenderer.ConvertToMillimeters(layoutRectangle.Y, dpiX); location = new PointF(num5 - num4, num6 + num3); } else { float num7 = SharedRenderer.ConvertToMillimeters(layoutRectangle.X, dpiX); float num8 = SharedRenderer.ConvertToMillimeters(layoutRectangle.Bottom, dpiX); location = new PointF(num7 + num4 - num2, num8 - num3 - num); } } RectangleF position = new RectangleF(location, empty); renderingTextRun.ProcessActions(m_context, rPLTextRunProps.UniqueName, rPLTextRunProps.ActionInfo, position); string toolTip = renderingTextRun.ToolTip; if (!string.IsNullOrEmpty(toolTip)) { m_context.RenderingReport.ToolTips.Add(new ReportToolTip(rPLTextRunProps.UniqueName, position, toolTip)); } }
private void AdjustParagraphLayout(float totalContent, float newContent, float usedContent, bool firstParagraph, RPLFormat.WritingModes writingMode, ref float delta, ref RectangleF layoutParagraph, ref PointF offset) { _ = DefinitionProperties; RPLFormat.VerticalAlignments verticalAlign = VerticalAlign; if (firstParagraph) { bool flag = false; if ((writingMode != 0) ? (totalContent < TextPosition.Width) : (totalContent < TextPosition.Height)) { switch (verticalAlign) { case RPLFormat.VerticalAlignments.Top: delta = 0f; break; case RPLFormat.VerticalAlignments.Bottom: delta = 0f; if (writingMode == RPLFormat.WritingModes.Horizontal) { delta = TextPosition.Height - totalContent; } else { delta = TextPosition.Width - totalContent; } if (delta < 0f) { delta = 0f; } break; default: delta = 0f; if (writingMode == RPLFormat.WritingModes.Horizontal) { delta = (TextPosition.Height - totalContent) / 2f; } else { delta = (TextPosition.Width - totalContent) / 2f; } if (delta < 0f) { delta = 0f; } break; } } } if (writingMode == RPLFormat.WritingModes.Horizontal) { layoutParagraph = new RectangleF(TextPosition.X, TextPosition.Y + usedContent + delta, TextPosition.Width, newContent); offset = new PointF(0f, usedContent + delta); return; } float num = newContent; float num2; if (writingMode == RPLFormat.WritingModes.Vertical) { num2 = TextPosition.Width - (usedContent + delta + newContent); if (num2 < 0f) { num += num2; num2 = 0f; } } else { num2 = usedContent + delta; if (num > TextPosition.Width) { num = TextPosition.Width; } } layoutParagraph = new RectangleF(TextPosition.X + num2, TextPosition.Y, num, TextPosition.Height); offset = new PointF(newContent, 0f); }
internal override void DrawContent(GdiContext context) { RPLTextBoxPropsDef rPLTextBoxPropsDef = DefinitionProperties as RPLTextBoxPropsDef; RPLTextBoxProps rPLTextBoxProps = InstanceProperties as RPLTextBoxProps; if (rPLTextBoxProps.IsToggleParent) { GetToggleImage(context.GdiWriter, out Bitmap image); if (m_toggleRectangleMM.Width > 0f) { DrawResourceImage(imageRectanglePX: new RectangleF(0f, 0f, image.Width, image.Height), context: context, image: image, itemRectangleMM: m_toggleRectangleMM); } } if (rPLTextBoxPropsDef.CanSort) { GetSortImage(context.GdiWriter, out Bitmap image2, out SortOrder _); if (m_sortRectangleMM.Width > 0f) { DrawResourceImage(imageRectanglePX: new RectangleF(0f, 0f, image2.Width, image2.Height), context: context, image: image2, itemRectangleMM: m_sortRectangleMM); } } if (TextPosition.Width <= 0f || TextPosition.Height <= 0f) { return; } RPLFormat.WritingModes writingMode = WritingMode; float contentHeight = 0f; float contentHeight2 = 0f; if (writingMode == RPLFormat.WritingModes.Horizontal) { contentHeight = rPLTextBoxProps.ContentHeight; } else { contentHeight2 = rPLTextBoxProps.ContentHeight; } List <Paragraph> list = null; List <RTSelectionHighlight> list2 = null; FlowContext flowContext = new FlowContext(TextPosition.Width, TextPosition.Height); bool flag = !rPLTextBoxPropsDef.CanGrow && !rPLTextBoxPropsDef.CanShrink; if (flag) { m_richTextBox.Paragraphs = new List <Paragraph>(m_paragraphs.Count); for (int i = 0; i < m_paragraphs.Count; i++) { RTSelectionHighlight searchHit = m_paragraphs[i].GetSearchHit(context); if (searchHit != null) { context.TextRunIndexHitStart = searchHit.SelectionStart.TextRunIndex; context.TextRunIndexHitEnd = searchHit.SelectionEnd.TextRunIndex; } m_paragraphs[i].DrawContent(context); m_richTextBox.Paragraphs.Add(m_paragraphs[i].RichParagraph); context.TextRunIndexHitStart = -1; context.TextRunIndexHitEnd = -1; } m_richTextBox.ScriptItemize(); if (writingMode == RPLFormat.WritingModes.Horizontal) { TextBox.MeasureFullHeight(m_richTextBox, context.Graphics, context.FontCache, flowContext, out contentHeight); } else { TextBox.MeasureFullHeight(m_richTextBox, context.Graphics, context.FontCache, flowContext, out contentHeight2); } list = m_richTextBox.Paragraphs; m_richTextBox.Paragraphs = null; } if (writingMode == RPLFormat.WritingModes.Horizontal) { if (contentHeight + 0.001f > TextPosition.Height) { flowContext.LineLimit = false; } } else if (contentHeight2 + 0.001f > TextPosition.Width) { flowContext.LineLimit = false; } m_richTextBox.Paragraphs = new List <Paragraph>(1); bool flag2 = true; float num = 0f; float num2 = 0f; for (int j = 0; j < m_paragraphs.Count; j++) { if (writingMode == RPLFormat.WritingModes.Horizontal) { if (num > 0f) { if (num >= TextPosition.Height) { break; } flowContext.Height = TextPosition.Height - num; } } else if (num2 > 0f) { if (num2 >= TextPosition.Width) { break; } flowContext.Width = TextPosition.Width - num2; } RTSelectionHighlight searchHit2 = m_paragraphs[j].GetSearchHit(context); if (!flag) { if (searchHit2 != null) { context.TextRunIndexHitStart = searchHit2.SelectionStart.TextRunIndex; context.TextRunIndexHitEnd = searchHit2.SelectionEnd.TextRunIndex; } m_paragraphs[j].DrawContent(context); m_richTextBox.Paragraphs.Add(m_paragraphs[j].RichParagraph); context.TextRunIndexHitStart = -1; context.TextRunIndexHitEnd = -1; m_richTextBox.ScriptItemize(); } else { m_richTextBox.Paragraphs.Add(list[0]); } if (searchHit2 != null) { searchHit2.SelectionStart.ParagraphIndex = 0; searchHit2.SelectionEnd.ParagraphIndex = 0; list2 = new List <RTSelectionHighlight>(0); list2.Add(searchHit2); } float height = 0f; List <Paragraph> rTParagraphs = LineBreaker.Flow(m_richTextBox, context.Graphics, context.FontCache, flowContext, keepLines: true, out height); RectangleF layoutParagraph = RectangleF.Empty; PointF offset = PointF.Empty; float delta = 0f; if (writingMode == RPLFormat.WritingModes.Horizontal) { AdjustParagraphLayout(contentHeight, height, num, flag2, writingMode, ref delta, ref layoutParagraph, ref offset); } else { AdjustParagraphLayout(contentHeight2, height, num2, flag2, writingMode, ref delta, ref layoutParagraph, ref offset); } m_context = context; m_paragraphs[j].TextPosition = layoutParagraph; RichTextRenderer richTextRenderer = new RichTextRenderer(); try { richTextRenderer.SetTextbox(m_richTextBox); richTextRenderer.RTParagraphs = rTParagraphs; richTextRenderer.FontCache = context.FontCache; if (writingMode == RPLFormat.WritingModes.Horizontal) { RenderRichText(richTextRenderer, context.Graphics, TextPosition, offset, list2); } else { RenderRichText(richTextRenderer, context.Graphics, layoutParagraph, offset, list2); } richTextRenderer.FontCache = null; } finally { if (richTextRenderer != null) { richTextRenderer.Dispose(); richTextRenderer = null; } } m_context = null; flowContext.Reset(); if (writingMode == RPLFormat.WritingModes.Horizontal) { if (flag2) { num += delta; flag2 = false; } num += height; } else { if (flag2) { num2 += delta; flag2 = false; } num2 += height; } if (searchHit2 != null) { searchHit2.SelectionStart.ParagraphIndex = j; searchHit2.SelectionEnd.ParagraphIndex = j; } m_richTextBox.Paragraphs.RemoveAt(0); if (!flag) { m_paragraphs[j].RichParagraph = null; } else { list.RemoveAt(0); } } if (list != null && list.Count > 0) { list.Clear(); } list = null; }
public static void GetFontFormatInformation(RPLElementProps elementProperties, out RPLFormat.WritingModes writingMode, out RPLFormat.Directions direction, out RPLFormat.VerticalAlignments verticalAlign, out RPLFormat.TextAlignments textAlign, ref bool stringFormatFromInstance) { writingMode = (RPLFormat.WritingModes)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)30, ref stringFormatFromInstance); direction = (RPLFormat.Directions)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)29, ref stringFormatFromInstance); verticalAlign = (RPLFormat.VerticalAlignments)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)26, ref stringFormatFromInstance); textAlign = (RPLFormat.TextAlignments)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)25, ref stringFormatFromInstance); }
internal static void GetFontFormatInformation(RPLElementProps elementProperties, out RPLFormat.WritingModes writingMode, out RPLFormat.Directions direction, out RPLFormat.VerticalAlignments verticalAlign, out RPLFormat.TextAlignments textAlign, ref bool stringFormatFromInstance) { writingMode = (RPLFormat.WritingModes)GetStylePropertyValueObject(elementProperties, 30, ref stringFormatFromInstance); direction = (RPLFormat.Directions)GetStylePropertyValueObject(elementProperties, 29, ref stringFormatFromInstance); verticalAlign = (RPLFormat.VerticalAlignments)GetStylePropertyValueObject(elementProperties, 26, ref stringFormatFromInstance); textAlign = (RPLFormat.TextAlignments)GetStylePropertyValueObject(elementProperties, 25, ref stringFormatFromInstance); }
public Underline(TextRun run, Win32DCSafeHandle hdc, FontCache fontCache, Rectangle layoutRectangle, int x, int baselineY, RPLFormat.WritingModes writingMode) { int width = run.GetWidth(hdc, fontCache); int num = (int)((double)(int)((double)run.UnderlineHeight * 0.085) * 1.5); switch (writingMode) { case RPLFormat.WritingModes.Horizontal: this.m_startPoint = new Point(layoutRectangle.X + x, layoutRectangle.Y + baselineY + num); this.m_endPoint = new Point(Math.Min(this.m_startPoint.X + width, layoutRectangle.Right), this.m_startPoint.Y); break; case RPLFormat.WritingModes.Vertical: this.m_startPoint = new Point(layoutRectangle.Right - baselineY - num - 1, layoutRectangle.Y + x); this.m_endPoint = new Point(this.m_startPoint.X, Math.Min(this.m_startPoint.Y + width, layoutRectangle.Bottom)); break; case RPLFormat.WritingModes.Rotate270: this.m_startPoint = new Point(layoutRectangle.X + baselineY + num, layoutRectangle.Bottom - x); this.m_endPoint = new Point(this.m_startPoint.X, Math.Max(this.m_startPoint.Y - width, layoutRectangle.Top)); break; } }
public virtual void DrawTextRun(Win32DCSafeHandle hdc, FontCache fontCache, ReportTextBox textBox, TextRun run, TypeCode typeCode, RPLFormat.TextAlignments textAlign, RPLFormat.VerticalAlignments verticalAlign, RPLFormat.WritingModes writingMode, RPLFormat.Directions direction, Point position, Rectangle layoutRectangle, int lineHeight, int baselineY) { }
public override void DrawTextRun(Win32DCSafeHandle hdc, FontCache fontCache, ReportTextBox textBox, AspNetCore.ReportingServices.Rendering.RichText.TextRun run, TypeCode typeCode, RPLFormat.TextAlignments textAlign, RPLFormat.VerticalAlignments verticalAlign, RPLFormat.WritingModes writingMode, RPLFormat.Directions direction, Point pointPosition, System.Drawing.Rectangle layoutRectangle, int lineHeight, int baselineY) { if (!string.IsNullOrEmpty(run.Text)) { int x; int baselineY2; switch (writingMode) { case RPLFormat.WritingModes.Horizontal: x = layoutRectangle.X + pointPosition.X; baselineY2 = layoutRectangle.Y + baselineY; break; case RPLFormat.WritingModes.Vertical: x = layoutRectangle.X + (layoutRectangle.Width - baselineY); baselineY2 = layoutRectangle.Y + pointPosition.X; break; case RPLFormat.WritingModes.Rotate270: x = layoutRectangle.X + baselineY; baselineY2 = layoutRectangle.Y + layoutRectangle.Height - pointPosition.X; break; default: throw new NotSupportedException(); } Underline underline = null; if (run.UnderlineHeight > 0) { underline = new Underline(run, hdc, fontCache, layoutRectangle, pointPosition.X, baselineY, writingMode); } if (!this.IsEmf) { AspNetCore.ReportingServices.Rendering.RichText.TextBox.DrawTextRun(run, hdc, fontCache, x, baselineY2, underline); } else { AspNetCore.ReportingServices.Rendering.RichText.TextBox.ExtDrawTextRun(run, hdc, fontCache, x, baselineY2, underline); } } }