Beispiel #1
0
        internal static void CalcTextBox(IFlxGraphics Canvas, TFontCache FontCache, real Zoom100, RectangleF CellRect, real Clp, bool MultiLine, real Alpha, bool Vertical, TRichString OutText, Font AFont, TAdaptativeFormats AdaptativeFormats, out SizeF TextExtent, out TXRichStringList TextLines, out TFloatList MaxDescent)
        {
            TextExtent = new SizeF(0, 0);
            TextLines  = new TXRichStringList();

            MaxDescent = new TFloatList();
            real MaxTextWidth;

            if (MultiLine || Vertical)
            {
                real Md;
                real TextHeight = RenderMetrics.CalcTextExtent(Canvas, FontCache, Zoom100, AFont, new TRichString("M"), out Md).Height; //not perfect since the rich string might have different fonts, but a good approx.
                MaxTextWidth = CalcMaxTextWidth(ref CellRect, Clp, Alpha, TextHeight);

                RenderMetrics.SplitText(Canvas, FontCache, Zoom100, OutText, AFont, MaxTextWidth, TextLines, out TextExtent, Vertical, MaxDescent, AdaptativeFormats);
            }
            else
            {
                TextLines.Add(new TXRichString(OutText, false, 0, 0, AdaptativeFormats));
                real mdx = 0;
                TextExtent           = RenderMetrics.CalcTextExtent(Canvas, FontCache, Zoom100, AFont, OutText, out mdx);
                TextLines[0].XExtent = TextExtent.Width;
                TextLines[0].YExtent = TextExtent.Height;
                MaxTextWidth         = CalcMaxTextWidth(ref CellRect, Clp, Alpha, TextExtent.Height);
                MaxDescent.Add(mdx);
            }

            if (AdaptativeFormats != null && AdaptativeFormats.WildcardPos >= 0)
            {
                MaxTextWidth -= 2 * Clp; //Add some extra clipping so the text doesn't go through the line.
                if (Vertical)
                {
                }
                else
                {
                    AddWildcard(Canvas, FontCache, Zoom100, AFont, MaxTextWidth, TextLines, ref TextExtent);
                }
            }
        }
Beispiel #2
0
        private static void AddWildcard(IFlxGraphics Canvas, TFontCache FontCache, real Zoom100,
                                        Font AFont, real MaxTextWidth, TXRichStringList TextLines, ref SizeF TextExtent)
        {
            TXRichString LineWithWildcard = null;

            foreach (TXRichString line in TextLines)
            {
                if (line.s == null || line.s.RTFRunCount > 0)
                {
                    return;                                           //wildcards only apply to non formatted lines.
                }
                if (line.AdaptFormat != null && line.AdaptFormat.WildcardPos >= 0)
                {
                    LineWithWildcard = line;
                    break;
                }
            }

            if (LineWithWildcard == null)
            {
                return;
            }
            AddWilcardtoLine(Canvas, FontCache, Zoom100, AFont, MaxTextWidth, ref TextExtent, LineWithWildcard);
        }
Beispiel #3
0
        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;
                }
            }
        }
Beispiel #4
0
        private static RectangleF CalcTextCoordsRotated(real[] X, real[] Y, TVAlign VAlign, THAlign HAlign, real Alpha, ref RectangleF CellRect, real Clp, bool FmtGeneral, real SinAlpha, real CosAlpha, TXRichStringList TextLines, double Linespacing)
        {
            //General horiz align depends on the rotation
            THAlign RHAlign = HAlign;

            if (FmtGeneral)
            {
                if (Alpha == 90)
                {
                    RHAlign = THAlign.Right;
                }
                else if (Alpha > 0)
                {
                    RHAlign = THAlign.Left;
                }
                else if (Alpha != -90)
                {
                    RHAlign = THAlign.Right;
                }
                else
                {
                    RHAlign = THAlign.Left;
                }
            }


            /*
             * This is quite complex because each box of text has 4 corners. We always write on left-bottom coordinate, but to keep
             * calculations easy, we will calculate the left-bottom for alpha > 0, and left-top for alpha < 0
             *            ___                   ___x
             * (Alpha>0) /  /      (Alpha < 0)  \  \
             *          /  /                     \  \
             *          --x                       ---
             *
             * We will then adjust the x coord for alpha < 0 to be left-bottom.
             */

            real xdiff = 0;
            real XOfs = 0;
            real GlobalMinBoxX = 0, GlobalMaxBoxX = 0;

            for (int i = 0; i < TextLines.Count; i++)
            {
                real hcosAlpha = TextLines[i].YExtent * CosAlpha;
                real wsinAlpha = TextLines[i].XExtent * SinAlpha;
                real dy        = Math.Abs(wsinAlpha) + hcosAlpha;

                switch (VAlign)
                {
                case TVAlign.Top:
                    Y[i] = CellRect.Top + Clp + dy;
                    break;

                case TVAlign.Center:
                    Y[i] = (CellRect.Top + CellRect.Bottom + dy) / 2;
                    break;

                default:
                    Y[i] = CellRect.Bottom - Clp;
                    break;
                }                 //case

                if (Alpha < 0)
                {
                    Y[i] -= dy;
                }


                //Now accumulate in x
                real wcosAlpha = TextLines[i].XExtent * CosAlpha;
                real hsinAlpha = TextLines[i].YExtent * SinAlpha;

                if (i > 0)
                {
                    int  z    = Alpha > 0? i: i - 1;
                    real xinc = TextLines[z].YExtent / SinAlpha;                      //xinc here is what we need to stack boxes one after the other, keeping the same Y.
                    XOfs += xinc;
                }

                X[i] = XOfs;
                if (i > 0)
                {
                    X[i] += (Y[0] - Y[i]) * CosAlpha / SinAlpha;                         //if both Y are not aligned, we need to substract that offset.
                }
                switch (RHAlign)
                {
                case THAlign.Right:
                    real MaxBoxX = X[i] + wcosAlpha;
                    if (MaxBoxX > GlobalMaxBoxX)
                    {
                        GlobalMaxBoxX = MaxBoxX;
                        xdiff         = CellRect.Right - Clp - MaxBoxX;
                    }

                    break;

                case THAlign.Center:
                    real cMaxBoxX = X[i] + wcosAlpha;
                    if (cMaxBoxX > GlobalMaxBoxX)
                    {
                        GlobalMaxBoxX = cMaxBoxX;
                    }
                    real cMinBoxX = X[i] - Math.Abs(hsinAlpha);
                    if (cMinBoxX < GlobalMinBoxX)
                    {
                        GlobalMinBoxX = cMinBoxX;
                    }
                    if (i == TextLines.Count - 1)
                    {
                        if (Alpha > 0)
                        {
                            real h0sinAlpha = TextLines[0].YExtent * SinAlpha;
                            xdiff = (CellRect.Left + CellRect.Right - (GlobalMaxBoxX - GlobalMinBoxX)) / 2 + h0sinAlpha;
                        }
                        else
                        {
                            real w0cosAlpha = TextLines[0].XExtent * CosAlpha;
                            xdiff = (CellRect.Left + CellRect.Right + (GlobalMaxBoxX - GlobalMinBoxX)) / 2 - w0cosAlpha;
                        }
                    }

                    break;

                default:
                    real MinBoxX = X[i] - Math.Abs(hsinAlpha);
                    if (MinBoxX < GlobalMinBoxX)
                    {
                        GlobalMinBoxX = MinBoxX;
                        xdiff         = CellRect.Left + Clp - MinBoxX;
                    }
                    break;
                }                 //case
            }

            real MinX = 0, MinY = 0, MaxX = 0, MaxY = 0;

            //second pass. adjust offsets. if alpha < 0, adjust x to be left-bottom, to write the text.
            for (int i = 0; i < TextLines.Count; i++)
            {
                X[i] += xdiff;

                real wcosAlpha = TextLines[i].XExtent * CosAlpha;
                real hsinAlpha = TextLines[i].YExtent * SinAlpha;
                real hcosAlpha = TextLines[i].YExtent * CosAlpha;
                real wsinAlpha = TextLines[i].XExtent * SinAlpha;

                if (i == 0)
                {
                    CalcBox(X[i], Y[i], Alpha, wcosAlpha, hsinAlpha, hcosAlpha, wsinAlpha, out MinX, out MinY, out MaxX, out MaxY);
                }
                else
                {
                    real aMinX, aMinY, aMaxX, aMaxY;
                    CalcBox(X[i], Y[i], Alpha, wcosAlpha, hsinAlpha, hcosAlpha, wsinAlpha, out aMinX, out aMinY, out aMaxX, out aMaxY);
                    MinX = Math.Min(MinX, aMinX);
                    MaxX = Math.Max(MaxX, aMaxX);
                    MinY = Math.Min(MinY, aMinY);
                    MaxY = Math.Max(MaxY, aMaxY);
                }

                if (Alpha < 0)
                {
                    Y[i] += hcosAlpha;
                    X[i] += hsinAlpha;                     //adjust because we are not using the same x to write the text.
                }
            }
            return(RectangleF.FromLTRB(MinX, MinY, MaxX, MaxY));
        }
Beispiel #5
0
        private static RectangleF CalcTextCoordsAlpha0(real[] X, real[] Y, TVAlign VAlign, ref THAlign HAlign, real Indent, ref RectangleF CellRect, real Clp, ref SizeF TextExtent, bool FmtGeneral, bool Vertical, bool IsLeftToRight, TXRichStringList TextLines, double Linespacing)
        {
            RectangleF ContainingRect;
            real       AcumY      = 0;
            real       MinX       = 0;
            real       TextHeight = Y.Length < 1 ? TextExtent.Height : (float)(TextLines[Y.Length - 1].YExtent + (TextExtent.Height - TextLines[Y.Length - 1].YExtent) * Linespacing); //Last line doesn't add linespace.

            for (int i = 0; i < X.Length; i++)
            {
                switch (VAlign)
                {
                case TVAlign.Top: Y[i] = AcumY + CellRect.Top + Clp + TextLines[i].YExtent; break;                         //Used to be "CellRect.Top + Clp + TextExtent.Height * Lines" instead, but it goes too low.

                case TVAlign.Center: Y[i] = AcumY + (CellRect.Top + CellRect.Bottom - TextHeight) / 2 + TextLines[i].YExtent; break;

                default: Y[i] = AcumY + CellRect.Bottom - Clp - TextHeight + TextLines[i].YExtent; break;
                }                 //case

                AcumY += (float)(TextLines[i].YExtent * Linespacing);


                THAlign RHAlign = HAlign;
                if (FmtGeneral)
                {
                    if (IsLeftToRight)
                    {
                        RHAlign = THAlign.Right; HAlign = RHAlign;
                    }
                    if (Vertical)
                    {
                        RHAlign = THAlign.Center; HAlign = RHAlign;
                    }
                }
                switch (RHAlign)
                {
                case THAlign.Right: X[i] = CellRect.Right - Clp - TextLines[i].XExtent - Indent; break;

                case THAlign.Center: X[i] = (CellRect.Left + CellRect.Right - TextLines[i].XExtent) / 2; break;

                default: X[i] = CellRect.Left + Clp + 1f * FlexCelRender.DispMul / 100f + Indent; break;
                }                 //case

                if (i == 0 || MinX > X[i])
                {
                    MinX = X[i];
                }
            }
            ContainingRect = new RectangleF(MinX, Y[0] - TextLines[0].YExtent, TextExtent.Width, TextHeight);
            return(ContainingRect);
        }
Beispiel #6
0
        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));
            }
        }
Beispiel #7
0
        internal static void SplitText(IFlxGraphics Canvas, TFontCache FontCache, real Zoom100,
                                       TRichString Text, Font AFont, real w, TXRichStringList TextLines, out SizeF TextExtent, bool Vertical, TFloatList MaxDescent, TAdaptativeFormats AdaptFormat)
        {
            TextLines.Clear();
            MaxDescent.Clear();

            int idx = 0;
            int fit = 0;


            TextExtent = new SizeF(0, 0);
            if (w <= 0 || Text.Value.Length <= 0)
            {
                return;
            }

            while (idx < Text.Value.Length)
            {
                int Enter     = Text.Value.IndexOf((char)0x0A, idx);
                int MaxLength = Text.Value.Length - idx;
                if (Enter >= 0)
                {
                    MaxLength = Enter - idx;
                }

                if (Vertical)
                {
                    fit = 1;
                    CharUtils.SameOrMore(Text.Value, idx, ref fit);
                }
                else
                {
                    //Not a really efficient way, but...
                    //First Guess. whole string.
                    fit = MaxLength;

                    real md;
                    real wc = CalcTextExtent(Canvas, FontCache, Zoom100, AFont, Text.Substring(idx, fit), out md).Width;
                    FitOneLine(Canvas, FontCache, Zoom100, Text, AFont, w, idx, ref fit, ref wc);

                    if (fit <= 0)
                    {
                        fit = 1;                               //avoid infinite loop
                    }
                    CharUtils.SameOrMore(Text.Value, idx, ref fit);


                    if (Text.Value.IndexOf(' ', idx, fit) >= 0)
                    {
                        int minfit = 1;
                        CharUtils.SameOrMore(Text.Value, idx, ref minfit);
                        while (fit > minfit && fit < MaxLength && Text.Value[idx + fit] != ' ')
                        {
                            fit--;
                        }
                    }
                    while (fit < MaxLength && Text.Value[idx + fit] == ' ')
                    {
                        fit++;
                    }
                    //No need to adjust fit for surrogates. it will always be at the start of one.
                }

                //int Enter=Text.Value.IndexOf((char)0x0A, idx, fit);
                //if (Enter>0) fit=Enter-idx;
                int TextLen = Math.Min(MaxLength, fit);
                TextLines.Add(new TXRichString(Text.Substring(idx, TextLen), true, 0, 0, TAdaptativeFormats.CopyTo(AdaptFormat, idx, TextLen)));

                if (fit + idx < Text.Value.Length && Text.Value[idx + fit] == (char)0x0A)
                {
                    TextLines[TextLines.Count - 1].Split = false;
                    if (idx + fit < Text.Value.Length - 1)                  //An Enter at the end behaves different, it means we have a new empty line.
                    {
                        idx++;
                    }
                }
                if (fit + idx >= Text.Value.Length)
                {
                    TextLines[TextLines.Count - 1].Split = false;
                }

                idx += fit;

                //Recalculate dx
                real        mdx   = 0;
                TRichString sx    = TextLines[TextLines.Count - 1].s;
                SizeF       bSize = CalcTextExtent(Canvas, FontCache, Zoom100, AFont, sx, out mdx);
                if (bSize.Height == 0)
                {
                    real  mdx3;
                    SizeF bSize3 = CalcTextExtent(Canvas, FontCache, Zoom100, AFont, new TRichString("M"), out mdx3);
                    bSize.Height = bSize3.Height;
                }

                SizeF bSize2 = bSize;
                if (sx != null && sx.Length > 0 && sx.ToString()[sx.Length - 1] == ' ')             //This is to right align line with spaces at the end.
                {
                    real mdx2;
                    bSize2 = CalcTextExtent(Canvas, FontCache, Zoom100, AFont, sx.RightTrim(), out mdx2);
                }
                TextLines[TextLines.Count - 1].XExtent = bSize2.Width;
                TextLines[TextLines.Count - 1].YExtent = bSize.Height;                 // not bSize2.Height; This might be even 0.

                MaxDescent.Add(mdx);
                if (TextExtent.Width < bSize.Width)
                {
                    TextExtent.Width = bSize.Width;
                }
                TextExtent.Height += bSize.Height;
            }             //while
        }
Beispiel #8
0
        internal int CalcCellHeight(int Row, int Col, TRichString val, int CellXF, ExcelFile Workbook, real RowMultDisplay, real ColMultDisplay, TMultipleCellAutofitList MultipleRowAutofits)
        {
            if (CellXF < 0)
            {
                return(0xFF);
            }
            if (CellXF >= XFHeight.Length)
            {
                return(0xFF);                                        //Just to make sure. We don't want a wrong file to blow here.
            }
            int Result  = XFHeight[CellXF];
            int Result0 = Result;

            if (val == null)
            {
                return(Result);
            }

            TXFRecord XFRec = Wg.CellXF[CellXF];
            bool      Vertical;
            real      Alpha = FlexCelRender.CalcAngle(XFRec.Rotation, out Vertical);


            if (!XFRec.WrapText && !Vertical && Alpha == 0)
            {
                return(Result);
            }

            Font AFont = gr.FontCache.GetFont(XFFonts[CellXF], 1);

            RectangleF    CellRect = new RectangleF();
            TXlsCellRange rg       = Workbook.CellMergedBounds(Row, Col);

            for (int c = rg.Left; c <= rg.Right; c++)
            {
                CellRect.Width += Workbook.GetColWidth(c, true) / ColMultDisplay;
            }

            SizeF            TextExtent;
            TXRichStringList TextLines  = new TXRichStringList();
            TFloatList       MaxDescent = new TFloatList();

            real Clp = 1 * FlexCelRender.DispMul / 100f;
            real Wr  = 0;

            if (Alpha == 0)
            {
                Wr = CellRect.Right - CellRect.Left - 2 * Clp;
            }
            else
            {
                Wr = 1e6f;                 //When we have an angle, it means "make the row as big as needed to fit". So SplitText needs no limits.
            }


            RenderMetrics.SplitText(gr.Canvas, gr.FontCache, 1, val, AFont, Wr, TextLines, out TextExtent, Vertical, MaxDescent, null);

            if (TextLines.Count <= 0)
            {
                return(Result);
            }

            real H = 0;
            real W = 0;

            for (int i = 0; i < TextLines.Count; i++)
            {
                H += TextLines[i].YExtent;
                if (TextLines[i].XExtent > W)
                {
                    W = TextLines[i].XExtent;
                }
            }

            if (Alpha != 0)
            {
                real SinAlpha = (real)Math.Sin(Alpha * Math.PI / 180); real CosAlpha = (real)Math.Cos(Alpha * Math.PI / 180);
                H = H * CosAlpha + W * Math.Abs(SinAlpha);
            }
            Result = (int)Math.Ceiling(RowMultDisplay * (H + 2 * Clp));

            if (rg.RowCount > 1)
            {
                if (MultipleRowAutofits != null)
                {
                    MultipleRowAutofits.Add(new TMultipleCellAutofit(rg, Result));
                }
                return(Result0);                //We will autofit this later.
            }
            if (Result < 0)
            {
                Result = 0;
            }

            return(Result);
        }
Beispiel #9
0
        internal int CalcCellWidth(int Row, int Col, TRichString val, int CellXF, ExcelFile Workbook, real RowMultDisplay, real ColMultDisplay, TMultipleCellAutofitList MultipleColAutofits)
        {
            if (val == null || val.Value == null || val.Value.Length == 0)
            {
                return(0);
            }

            TXFRecord XFRec = Wg.CellXF[CellXF];
            bool      Vertical;
            real      Alpha = FlexCelRender.CalcAngle(XFRec.Rotation, out Vertical);

            Font AFont = gr.FontCache.GetFont(XFFonts[CellXF], 1);             //dont dispose

            TXlsCellRange rg = Workbook.CellMergedBounds(Row, Col);

            SizeF            TextExtent;
            TXRichStringList TextLines  = new TXRichStringList();
            TFloatList       MaxDescent = new TFloatList();

            real Clp = 1 * FlexCelRender.DispMul / 100f;
            real Wr  = 0;

            if (Alpha != 90 && Alpha != -90)
            {
                Wr = 1e6f;                                          //this means "make the column as big as needed to fit". So SplitText needs no limits.
            }
            else
            {
                RectangleF CellRect = new RectangleF();
                for (int r = rg.Top; r <= rg.Bottom; r++)
                {
                    CellRect.Height += Workbook.GetRowHeight(r, true) / RowMultDisplay;
                }
                Wr = CellRect.Height - 2 * Clp;
            }


            RenderMetrics.SplitText(gr.Canvas, gr.FontCache, 1, val, AFont, Wr, TextLines, out TextExtent, Vertical, MaxDescent, null);

            if (TextLines.Count <= 0)
            {
                return(0);
            }

            real Rr = 0;
            real Ww = 0;

            for (int i = 0; i < TextLines.Count; i++)
            {
                Rr += TextLines[i].YExtent;
                if (TextLines[i].XExtent > Ww)
                {
                    Ww = TextLines[i].XExtent;
                }
            }
            if (Alpha != 0)
            {
                real SinAlpha = (real)Math.Sin(Alpha * Math.PI / 180); real CosAlpha = (real)Math.Cos(Alpha * Math.PI / 180);
                Ww = Ww * CosAlpha + Rr * Math.Abs(SinAlpha);
            }
            int Result = (int)Math.Ceiling(ColMultDisplay * (Ww + 4 * Clp));

            if (rg.ColCount > 1)
            {
                if (MultipleColAutofits != null)
                {
                    MultipleColAutofits.Add(new TMultipleCellAutofit(rg, Result));
                }
                return(0);                //We will autofit this later.
            }

            if (Result < 0)
            {
                Result = 0;
            }
            return(Result);
        }