public int SetCellAlignV(int Row, int Col, TVFlxAlignment Va) { int cellFormat = this.GetCellFormat(Row, Col); TFlxFormat format = this.GetFormat(cellFormat); format.VAlignment = Va; cellFormat = this.AddFormat(format); this.SetCellFormat(Row, Col, cellFormat); return(cellFormat); }
internal static void DrawRichText(ExcelFile Workbook, IFlxGraphics Canvas, TFontCache FontCache, real Zoom100, bool ReverseRightToLeftStrings, ref RectangleF CellRect, ref RectangleF PaintClipRect, ref RectangleF TextRect, ref RectangleF ContainingRect, real Clp, THFlxAlignment HJustify, TVFlxAlignment VJustify, real Alpha, Color DrawFontColor, TSubscriptData SubData, TRichString OutText, SizeF TextExtent, TXRichStringList TextLines, Font AFont, TFloatList MaxDescent, real[] X, real[] Y) { RectangleF FinalRect = CellRect; if (ContainingRect.Right > PaintClipRect.Left && ContainingRect.Left < PaintClipRect.Right && Intersect(TextRect, PaintClipRect, out FinalRect)) { real dy = 0; int TextLinesCount = TextLines.Count; if (VJustify == TVFlxAlignment.justify || VJustify == TVFlxAlignment.distributed) { if (TextLinesCount > 1) { dy = (CellRect.Height - TextExtent.Height - 2 * Clp) / (TextLinesCount - 1); } } float eps = 0.0001F; //Tolerance for the comparison, these are floats, not doubles, and we get rounding errors soon. if (TextRect.Left - eps <= ContainingRect.Left && TextRect.Right + eps >= ContainingRect.Right && TextRect.Top - eps <= ContainingRect.Top && TextRect.Bottom + eps >= ContainingRect.Bottom) { Canvas.SetClipReplace(PaintClipRect); //This will improve pdf export a lot, since we can now join all the BT/ET tags inside one, and then we can also join fonts inside the ET/BT tags. } else { if (Alpha == 0 || Alpha == 90) { Canvas.SetClipReplace(FinalRect); } else { Canvas.SetClipReplace(RectangleF.FromLTRB(PaintClipRect.Left, FinalRect.Top, PaintClipRect.Right, FinalRect.Bottom)); //rotated text can move to other used cells horizontally. } } real AcumDy = 0; for (int i = 0; i < TextLinesCount; i++) { TXRichString TextLine = TextLines[i]; if ((Alpha == 0) && (HJustify == THFlxAlignment.justify && TextLine.Split) || (HJustify == THFlxAlignment.distributed) ) { Canvas.SetClipReplace(FinalRect); WriteJustText(Workbook, Canvas, FontCache, Zoom100, ReverseRightToLeftStrings, AFont, DrawFontColor, Y[i] + AcumDy, SubData.Offset(Canvas, AFont), CellRect, Clp, TextLine.s, TextLine.XExtent, MaxDescent[i], HJustify == THFlxAlignment.distributed, TextLine.AdaptFormat); } else { WriteText(Workbook, Canvas, FontCache, Zoom100, AFont, DrawFontColor, X[i], Y[i] + AcumDy, SubData.Offset(Canvas, AFont), GetVisualString(TextLine.s, ReverseRightToLeftStrings), Alpha, MaxDescent[i], TextLine.AdaptFormat); } AcumDy += dy; } } }
internal static RectangleF CalcTextCoords(out real[] X, out real[] Y, TRichString OutText, TVAlign VAlign, ref THAlign HAlign, real Indent, real Alpha, RectangleF CellRect, real Clp, SizeF TextExtent, bool FmtGeneral, bool Vertical, real SinAlpha, real CosAlpha, TXRichStringList TextLines, double Linespacing0, TVFlxAlignment VJustify) { double Linespacing = VJustify == TVFlxAlignment.distributed || VJustify == TVFlxAlignment.justify ? 1.0 : Linespacing0; bool TextLeftToRight = IsLeftToRight(OutText.ToString()); X = new real[TextLines.Count]; Y = new real[TextLines.Count]; if (Alpha == 0) //optimize the most common case { return(CalcTextCoordsAlpha0(X, Y, VAlign, ref HAlign, Indent, ref CellRect, Clp, ref TextExtent, FmtGeneral, Vertical, TextLeftToRight, TextLines, Linespacing)); } else { // There is rotation. Now values of TextExtent are not ok, since lines will stack.for example /////// Each line has the same y, and the x is calculated as height/cosAlpha return(CalcTextCoordsRotated(X, Y, VAlign, HAlign, Alpha, ref CellRect, Clp, FmtGeneral, SinAlpha, CosAlpha, TextLines, Linespacing)); } }