Example #1
0
 /// <summary>
 /// Creates a new FlexCelImgExport instance.
 /// </summary>
 public FlexCelImgExport()
 {
     FRenderer   = new FlexCelRender();
     FPrintRange = new TXlsCellRange(0, 0, 0, 0);
     PageSize    = null;
     Resolution  = 96;
 }
Example #2
0
        /// <summary>
        /// Creates a new FlexCelPdfExport instance.
        /// </summary>
        public FlexCelPdfExport()
        {
            FCompress = true;
            FRenderer = new FlexCelRender();
            FRenderer.ReverseRightToLeftStrings = true;
            FPrintRange = new TXlsCellRange(0, 0, 0, 0);
            FProperties = new TPdfProperties();
            PageSize    = null;
            FProgress   = new FlexCelPdfExportProgress();

            FFontEmbed     = TFontEmbed.None;
            FFontSubset    = TFontSubset.Subset;
            FFontMapping   = TFontMapping.ReplaceStandardFonts;
            FFallbackFonts = "Arial Unicode MS";
        }
Example #3
0
        public static bool Check(ref RectangleF r)
        {
            if (r.Right < MinSize || r.Bottom < MinSize || r.Left > MaxSize || r.Top > MaxSize)
            {
                return(true);
            }

            real x1 = r.Left < MinSize? MinSize: r.Left;
            real x2 = r.Right > MaxSize? MaxSize: r.Right;
            real y1 = r.Top < MinSize? MinSize: r.Top;
            real y2 = r.Bottom > MaxSize? MaxSize: r.Bottom;

            r = FlexCelRender.RectangleXY(x1, y1, x2, y2);
            return(false);
        }
Example #4
0
 /// <summary>
 /// Creates a new FlexCelPrintDocument instance.
 /// </summary>
 public FlexCelPrintDocument()
 {
     FRenderer   = new FlexCelRender();
     FPrintRange = new TXlsCellRange(0, 0, 0, 0);
 }
Example #5
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);
        }
Example #6
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);
        }