Example #1
0
        public CellOverflowLayoutModel GetModel(int rowIndex)
        {
            if (Viewport == null || !Viewport.Excel.CanCellOverflow)
            {
                return(null);
            }

            CellOverflowLayoutModel model = null;

            if (_cachedCellOverflowModels.TryGetValue(rowIndex, out model))
            {
                if (model == CellOverflowLayoutModel.Empty)
                {
                    return(null);
                }
                return(model);
            }
            model = BuildCellOverflowLayoutModel(rowIndex);
            if (model == null)
            {
                _cachedCellOverflowModels[rowIndex] = CellOverflowLayoutModel.Empty;
                return(model);
            }
            _cachedCellOverflowModels[rowIndex] = model;
            return(model);
        }
Example #2
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (Row == -1 || finalSize.Width == 0 || finalSize.Height == 0)
            {
                foreach (UIElement elem in Children)
                {
                    elem.Arrange(_rcEmpty);
                }
                return(finalSize);
            }

            ColumnLayoutModel colLayoutModel = GetColumnLayoutModel();
            RowLayout         layout         = OwnPanel.GetRowLayoutModel().FindRow(Row);

            foreach (ColumnLayout colLayout in colLayoutModel)
            {
                CellItem cell;
                if (colLayout.Width <= 0.0 || (cell = GetCell(colLayout.Column)) == null)
                {
                    continue;
                }

                double left   = colLayout.X;
                double top    = layout.Y;
                double w      = colLayout.Width;
                double h      = layout.Height;
                int    zIndex = _normalCellZIndexBase + colLayout.Column;

                CellLayout cellLayout = cell.CellLayout;
                if (cellLayout != null)
                {
                    left   = cellLayout.X;
                    top    = cellLayout.Y;
                    w      = cellLayout.Width;
                    h      = cellLayout.Height;
                    zIndex = _spanCellZIndexBase + colLayout.Column;
                }

                // Canvas.SetZIndex 对所有继承自 Panel 的面板都有效,z值大的在上层,z值相同时按 Children 的索引,索引大的在上层
                // 但uno中 Canvas.SetZIndex 无效,只按 Children 的索引确定层次!
                if (cell.CellOverflowLayout != null)
                {
                    zIndex = _flowCellZIndexBase + colLayout.Column;
                }
                zIndex = zIndex % 0x7ffe;
                Canvas.SetZIndex(cell, zIndex);

                cell.Arrange(new Rect(left - Location.X, top - Location.Y, w, h));
            }

            if (_recycledCells.Count > 0)
            {
                foreach (var cell in _recycledCells)
                {
                    cell.Arrange(_rcEmpty);
                }
            }

            CellOverflowLayoutModel cellOverflowLayoutModel = OwnPanel.GetCellOverflowLayoutModel(Row);

            if (cellOverflowLayoutModel == null)
            {
                return(finalSize);
            }

            Worksheet worksheet  = OwnPanel.Excel.ActiveSheet;
            float     zoomFactor = OwnPanel.Excel.ZoomFactor;

            if (cellOverflowLayoutModel.HeadingOverflowlayout != null)
            {
                double num7 = Location.X;
                double num8 = layout.Y;
                for (int j = cellOverflowLayoutModel.HeadingOverflowlayout.Column; j < colLayoutModel[0].Column; j++)
                {
                    double actualColumnWidth = worksheet.GetActualColumnWidth(j, SheetArea.Cells);
                    num7 -= actualColumnWidth * zoomFactor;
                }
                double num12 = worksheet.GetActualColumnWidth(cellOverflowLayoutModel.HeadingOverflowlayout.Column, SheetArea.Cells) * zoomFactor;
                Size   size  = new Size(num12, layout.Height);
                Rect   rect  = new Rect(PointToClient(new Point(num7, num8)), size);
                int    num13 = _flowCellZIndexBase + cellOverflowLayoutModel.HeadingOverflowlayout.Column;
                num13 = num13 % 0x7ffe;
                Canvas.SetZIndex(HeadingOverflowCell, num13);
                HeadingOverflowCell.Arrange(rect);
            }
            if (cellOverflowLayoutModel.TrailingOverflowlayout == null)
            {
                return(finalSize);
            }

            ColumnLayout layout4 = colLayoutModel[colLayoutModel.Count - 1];

            if (layout4 == null)
            {
                return(finalSize);
            }

            double x = layout4.X;
            double y = layout.Y;

            for (int i = layout4.Column; i < cellOverflowLayoutModel.TrailingOverflowlayout.Column; i++)
            {
                x += worksheet.GetActualColumnWidth(i, SheetArea.Cells) * zoomFactor;
            }
            double width = worksheet.GetActualColumnWidth(cellOverflowLayoutModel.TrailingOverflowlayout.Column, SheetArea.Cells) * zoomFactor;
            Size   size2 = new Size(width, layout.Height);
            Rect   rect2 = new Rect(PointToClient(new Point(x, y)), size2);
            int    num18 = _flowCellZIndexBase + cellOverflowLayoutModel.TrailingOverflowlayout.Column;

            num18 = num18 % 0x7ffe;
            Canvas.SetZIndex(TrailingOverflowCell, num18);
            TrailingOverflowCell.Arrange(rect2);
            return(finalSize);
        }
Example #3
0
        protected override Size MeasureOverride(Size availableSize)
        {
            if (Row == -1 || availableSize.Width == 0.0 || availableSize.Height == 0.0)
            {
                foreach (UIElement elem in Children)
                {
                    elem.Measure(_szEmpty);
                }
                return(_szEmpty);
            }

            ColumnLayoutModel       colLayoutModel          = GetColumnLayoutModel();
            RowLayout               layout                  = OwnPanel.GetRowLayoutModel().FindRow(Row);
            CellOverflowLayoutModel cellOverflowLayoutModel = OwnPanel.GetCellOverflowLayoutModel(Row);

            RowWidth = 0.0;
            double height = 0.0;

            foreach (ColumnLayout colLayout in colLayoutModel)
            {
                RowWidth += colLayout.Width;
                CellItem cell = GetCell(colLayout.Column);
                if (cell == null)
                {
                    continue;
                }

                double w = colLayout.Width;
                double h = layout.Height;
                if (cell.CellLayout != null)
                {
                    w = cell.CellLayout.Width;
                    h = cell.CellLayout.Height;
                }

                cell.CellOverflowLayout = null;
                if (cell.CellLayout == null && cellOverflowLayoutModel != null)
                {
                    var cellOverflowLayout = cellOverflowLayoutModel.GetCellOverflowLayout(colLayout.Column);
                    if ((cellOverflowLayout != null) && (cellOverflowLayout.Column == colLayout.Column))
                    {
                        cell.CellOverflowLayout = cellOverflowLayout;
                    }
                }
                cell.Measure(new Size(w, h));
                if (h > height)
                {
                    height = h;
                }
            }

            if (_recycledCells.Count > 0)
            {
                foreach (var cell in _recycledCells)
                {
                    cell.Measure(_szEmpty);
                }
            }

            double width = Math.Min(RowWidth, OwnPanel.GetViewportSize().Width);

            if (cellOverflowLayoutModel != null)
            {
                Worksheet worksheet  = OwnPanel.Excel.ActiveSheet;
                float     zoomFactor = OwnPanel.Excel.ZoomFactor;
                if (cellOverflowLayoutModel.HeadingOverflowlayout != null)
                {
                    HeadingOverflowCell.CellOverflowLayout = cellOverflowLayoutModel.HeadingOverflowlayout;
                    double num8 = worksheet.GetActualColumnWidth(cellOverflowLayoutModel.HeadingOverflowlayout.Column, SheetArea.Cells) * zoomFactor;
                    Size   size = new Size(num8, layout.Height);
                    HeadingOverflowCell.Measure(size);
                }
                if (cellOverflowLayoutModel.TrailingOverflowlayout != null)
                {
                    TrailingOverflowCell.CellOverflowLayout = cellOverflowLayoutModel.TrailingOverflowlayout;
                    double num9  = worksheet.GetActualColumnWidth(cellOverflowLayoutModel.TrailingOverflowlayout.Column, SheetArea.Cells) * zoomFactor;
                    Size   size2 = new Size(num9, layout.Height);
                    TrailingOverflowCell.Measure(size2);
                }
            }
            return(new Size(width, height));
        }
Example #4
0
        //*** CellsPanel.Measure -> RowsLayer.Measure -> RowItem.UpdateChildren -> 行列改变时 CellItem.UpdateChildren -> RowItem.Measure -> CellItem.Measure ***//

        public void UpdateChildren(bool p_updateAllCell)
        {
            // 频繁增删Children子元素会出现卡顿现象!
            // Children = Cells + _recycledCells
            ColumnLayoutModel colLayoutModel = GetColumnLayoutModel();
            int less = colLayoutModel.Count - Children.Count + (_headingOverflowCell == null ? 0 : 1) + (_trailingOverflowCell == null ? 0 : 1);

            if (less > 0)
            {
                for (int i = 0; i < less; i++)
                {
                    var cell = new CellItem(this);
                    Children.Add(cell);
                    _recycledCells.Add(cell);
                }
            }

            // 先回收不可见格
            var cols = Cells.Values.ToList();

            foreach (var cell in cols)
            {
                ColumnLayout layout = colLayoutModel.FindColumn(cell.Column);
                if (layout == null || layout.Width <= 0.0)
                {
                    PushRecycledCell(cell);
                }
            }

            int updateCells = 0;

            ContainsSpanCell = false;
            SpanGraph cachedSpanGraph = OwnPanel.CachedSpanGraph;

            for (int i = 0; i < colLayoutModel.Count; i++)
            {
                ColumnLayout colLayout = colLayoutModel[i];
                if (colLayout.Width <= 0.0)
                {
                    continue;
                }

                byte       state  = cachedSpanGraph.GetState(Row, colLayout.Column);
                CellLayout layout = null;
                if (state > 0)
                {
                    CellLayoutModel cellLayoutModel = OwnPanel.GetCellLayoutModel();
                    if (cellLayoutModel != null)
                    {
                        layout = cellLayoutModel.FindCell(Row, colLayout.Column);
                        if (layout != null)
                        {
                            ContainsSpanCell = true;
                        }
                    }
                }

                CellItem cell         = GetCell(colLayout.Column);
                bool     rangeChanged = false;
                if (layout != null && layout.Width > 0.0 && layout.Height > 0.0)
                {
                    CellRange range = ClipCellRange(layout.GetCellRange());
                    rangeChanged = (Row != range.Row) || (range.Column != colLayout.Column);

                    // 跨多列
                    if (layout.ColumnCount > 1)
                    {
                        // 移除跨度区域内的所有格
                        int maxCol = (layout.Column + layout.ColumnCount) - 1;
                        for (int j = i + 1; j < colLayoutModel.Count; j++)
                        {
                            int curCol = colLayoutModel[j].Column;
                            if (curCol > maxCol)
                            {
                                break;
                            }

                            i = j;
                            CellItem ci = GetCell(curCol);
                            if (ci != null)
                            {
                                PushRecycledCell(ci);
                            }
                        }
                    }
                }

                // 跨度不同不显示
                if (rangeChanged)
                {
                    if (cell != null)
                    {
                        PushRecycledCell(cell);
                    }
                    continue;
                }

                bool updated = false;
                if (cell == null)
                {
                    // 重新利用回收的格
                    cell = _recycledCells[0];
                    _recycledCells.RemoveAt(0);
                    cell.Column = colLayout.Column;
                    Cells.Add(colLayout.Column, cell);
                    updated = true;
                }
                cell.CellLayout = layout;

                if (p_updateAllCell || updated)
                {
                    cell.UpdateChildren();
                    updateCells++;
                }
            }

            CellOverflowLayoutModel cellOverflowLayoutModel = OwnPanel.GetCellOverflowLayoutModel(Row);

            if ((cellOverflowLayoutModel != null) && !cellOverflowLayoutModel.IsEmpty)
            {
                if (cellOverflowLayoutModel.HeadingOverflowlayout != null)
                {
                    if (HeadingOverflowCell == null)
                    {
                        HeadingOverflowCell = new CellItem(this);
                    }
                    if (HeadingOverflowCell.Column != cellOverflowLayoutModel.HeadingOverflowlayout.Column)
                    {
                        HeadingOverflowCell.Column = cellOverflowLayoutModel.HeadingOverflowlayout.Column;
                        HeadingOverflowCell.UpdateChildren();
                        updateCells++;
                    }
                }
                else
                {
                    HeadingOverflowCell = null;
                }

                if (cellOverflowLayoutModel.TrailingOverflowlayout != null)
                {
                    if (TrailingOverflowCell == null)
                    {
                        TrailingOverflowCell = new CellItem(this);
                    }
                    if (TrailingOverflowCell.Column != cellOverflowLayoutModel.TrailingOverflowlayout.Column)
                    {
                        TrailingOverflowCell.Column = cellOverflowLayoutModel.TrailingOverflowlayout.Column;
                        TrailingOverflowCell.UpdateChildren();
                        updateCells++;
                    }
                }
                else
                {
                    TrailingOverflowCell = null;
                }
            }
            else
            {
                HeadingOverflowCell  = null;
                TrailingOverflowCell = null;
            }

#if !IOS
            // iOS在 MeasureOverride 内部调用子元素的 InvalidateMeasure 会造成死循环!
            // 不重新测量会造成如:迷你图忽大忽小的情况
            if (updateCells > 0)
            {
                InvalidateMeasure();
            }
#endif
        }
Example #5
0
        BorderLine GetCellActualBorderLine(int row, int column, Borders borderIndex, out bool isInCellflow)
        {
            isInCellflow = false;
            bool       flag       = false;
            BorderLine empty      = null;
            Cell       cachedCell = null;
            byte       state      = _owner.CachedSpanGraph.GetState(row, column);

            switch (borderIndex)
            {
            case Borders.LEFT:
                if (state <= 0)
                {
                    CellOverflowLayoutModel model = _owner.CellOverflowLayoutBuildEngine.GetModel(row);
                    if (model != null)
                    {
                        CellOverflowLayout cellOverflowLayout = model.GetCellOverflowLayout(column);
                        if (cellOverflowLayout != null)
                        {
                            if (cellOverflowLayout.StartingColumn > -1)
                            {
                                if (cellOverflowLayout.StartingColumn == column)
                                {
                                    empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                                }
                                else
                                {
                                    empty        = null;
                                    isInCellflow = true;
                                }
                            }
                            else if (cellOverflowLayout.Column == column)
                            {
                                empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                            }
                            else
                            {
                                empty        = null;
                                isInCellflow = true;
                            }
                        }
                        else
                        {
                            empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                        }
                    }
                    else
                    {
                        empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                    }
                    break;
                }
                if ((state & 1) != 1)
                {
                    flag = true;
                    break;
                }
                empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                break;

            case Borders.TOP:
                if (state <= 0)
                {
                    empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                    break;
                }
                if ((state & 2) != 2)
                {
                    flag = true;
                    break;
                }
                empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                break;

            case Borders.RIGHT:
                if (state <= 0)
                {
                    CellOverflowLayoutModel model2 = _owner.CellOverflowLayoutBuildEngine.GetModel(row);
                    if (model2 != null)
                    {
                        CellOverflowLayout layout2 = model2.GetCellOverflowLayout(column);
                        if (layout2 != null)
                        {
                            if (layout2.EndingColumn > -1)
                            {
                                if (layout2.EndingColumn == column)
                                {
                                    empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                                }
                                else
                                {
                                    empty        = null;
                                    isInCellflow = true;
                                }
                            }
                            else if (layout2.Column == column)
                            {
                                empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                            }
                            else
                            {
                                empty        = null;
                                isInCellflow = true;
                            }
                        }
                        else
                        {
                            empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                        }
                    }
                    else
                    {
                        empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                    }
                    break;
                }
                if ((state & 4) != 4)
                {
                    flag = true;
                    break;
                }
                empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                break;

            case Borders.BOTTOM:
                if (state <= 0)
                {
                    empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                    break;
                }
                if ((state & 8) != 8)
                {
                    flag = true;
                    break;
                }
                empty = GetCellBorderByBorderIndex(row, column, borderIndex, ref cachedCell);
                break;
            }

            if ((!flag && !isInCellflow) && (empty == null))
            {
                if (_owner.Excel.ZoomFactor < 0.4f)
                {
                    return(BorderLine.Empty);
                }

                empty = _gridLine;
                if ((state & 0x20) == 0x20)
                {
                    return(BorderLine.Empty);
                }

                if (state != 0)
                {
                    return(empty);
                }

                if (cachedCell == null)
                {
                    cachedCell = _owner.CellCache.GetCachedCell(row, column);
                }

                if ((cachedCell != null) && (cachedCell.ActualBackground != null))
                {
                    empty = BorderLine.Empty;
                }
            }
            return(empty);
        }
Example #6
0
        CellOverflowLayout BuildTrailingCellOverflowLayoutModel(int rowIndex, ColumnLayoutModel columnLayoutModel, CellOverflowLayoutModel existed, object textFormattingMode, bool useLayoutRounding)
        {
            ColumnLayout layout = Enumerable.LastOrDefault <ColumnLayout>(columnLayoutModel, delegate(ColumnLayout clm)
            {
                return(clm.Width > 0.0);
            });

            if (layout == null)
            {
                if (columnLayoutModel.Count == 0)
                {
                    return(null);
                }
                layout = columnLayoutModel[0];
            }
            if (!existed.Contains(layout.Column))
            {
                CellOverflowLayout layout2     = new CellOverflowLayout(layout.Column, 0.0);
                ICellsSupport      dataContext = Viewport.GetDataContext();
                SheetSpanModelBase spanModel   = Viewport.GetSpanModel();
                for (int i = 1; i < _maxCellOverflowDistance; i++)
                {
                    int column = layout.Column + i;
                    if (column >= dataContext.Columns.Count)
                    {
                        return(null);
                    }
                    if (dataContext.Columns[column].ActualWidth > 0.0)
                    {
                        if ((spanModel != null) && (spanModel.Find(rowIndex, column) != null))
                        {
                            return(null);
                        }
                        Cell cachedCell = Viewport.CellCache.GetCachedCell(rowIndex, column);
                        if (!string.IsNullOrEmpty(cachedCell.Text))
                        {
                            if (cachedCell.ActualWordWrap)
                            {
                                return(null);
                            }
                            if (cachedCell.ActualShrinkToFit)
                            {
                                return(null);
                            }
                            switch (cachedCell.ToHorizontalAlignment())
                            {
                            case HorizontalAlignment.Left:
                            case HorizontalAlignment.Stretch:
                                return(null);

                            case HorizontalAlignment.Center:
                            {
                                int deadColumnIndex = columnLayoutModel[0].Column - 1;
                                layout2 = BuildCellOverflowLayoutModelForRight(cachedCell, rowIndex, existed, true, deadColumnIndex, textFormattingMode, useLayoutRounding);
                                if ((layout2 == null) || (layout2.StartingColumn > ViewportRightColumn))
                                {
                                    return(null);
                                }
                                layout2.BackgroundWidth += (dataContext.Columns[column].ActualWidth * Viewport.Excel.ZoomFactor) / 2.0;
                                return(layout2);
                            }

                            case HorizontalAlignment.Right:
                            {
                                int num5 = columnLayoutModel[0].Column - 1;
                                layout2 = BuildCellOverflowLayoutModelForRight(cachedCell, rowIndex, existed, false, num5, textFormattingMode, useLayoutRounding);
                                if ((layout2 == null) || (layout2.StartingColumn > ViewportRightColumn))
                                {
                                    return(null);
                                }
                                return(layout2);
                            }
                            }
                            break;
                        }
                    }
                }
            }
            return(null);
        }
Example #7
0
        CellOverflowLayoutModel BuildCellOverflowLayoutModel(int rowIndex)
        {
            if (!Viewport.Excel.CanCellOverflow)
            {
                return(null);
            }

            ColumnLayoutModel viewportColumnLayoutModel = Viewport.Excel.GetViewportColumnLayoutModel(Viewport.ColumnViewportIndex);

            if (viewportColumnLayoutModel == null)
            {
                return(null);
            }
            object    textFormattingMode   = null;
            bool      useLayoutRounding    = Viewport.Excel.UseLayoutRounding;
            SpanGraph cachedSpanGraph      = Viewport.CachedSpanGraph;
            CellOverflowLayoutModel result = new CellOverflowLayoutModel();
            CellOverflowLayout      layout = BuildHeadingCellOverflowLayoutModel(rowIndex, viewportColumnLayoutModel, textFormattingMode, useLayoutRounding);

            result.HeadingOverflowlayout = layout;
            for (int i = 0; i < viewportColumnLayoutModel.Count; i++)
            {
                Cell cachedCell;
                CellOverflowLayout layout3;
                CellOverflowLayout layout5;
                ColumnLayout       layout2 = viewportColumnLayoutModel[i];
                if (layout2.Width > 0.0)
                {
                    cachedCell = Viewport.CellCache.GetCachedCell(rowIndex, layout2.Column);
                    if ((((cachedCell != null) && !string.IsNullOrEmpty(cachedCell.Text)) && (!cachedCell.ActualWordWrap && !cachedCell.ActualShrinkToFit)) && (cachedSpanGraph.GetState(rowIndex, layout2.Column) == 0))
                    {
                        switch (cachedCell.ToHorizontalAlignment())
                        {
                        case HorizontalAlignment.Left:
                        case HorizontalAlignment.Stretch:
                        {
                            int deadColumnIndex     = Enumerable.Last <ColumnLayout>((IEnumerable <ColumnLayout>)viewportColumnLayoutModel).Column + 1;
                            CellOverflowLayout item = BuildCellOverflowLayoutModelForLeft(cachedCell, rowIndex, false, deadColumnIndex, textFormattingMode, useLayoutRounding);
                            if (item != null)
                            {
                                result.Add(item);
                                int index = viewportColumnLayoutModel.IndexOf(viewportColumnLayoutModel.FindColumn(item.EndingColumn));
                                if (index > -1)
                                {
                                    i = index;
                                }
                            }
                            break;
                        }

                        case HorizontalAlignment.Center:
                        {
                            layout3 = new CellOverflowLayout(layout2.Column, 0.0);
                            int num3 = Enumerable.Last <ColumnLayout>((IEnumerable <ColumnLayout>)viewportColumnLayoutModel).Column + 1;
                            CellOverflowLayout layout4 = BuildCellOverflowLayoutModelForLeft(cachedCell, rowIndex, true, num3, textFormattingMode, useLayoutRounding);
                            num3    = viewportColumnLayoutModel[0].Column - 1;
                            layout5 = BuildCellOverflowLayoutModelForRight(cachedCell, rowIndex, result, true, num3, textFormattingMode, useLayoutRounding);
                            if (layout4 == null)
                            {
                                goto Label_01C1;
                            }
                            layout3.EndingColumn         = layout4.EndingColumn;
                            layout3.BackgroundWidth     += layout4.BackgroundWidth;
                            layout3.RightBackgroundWidth = layout4.RightBackgroundWidth;
                            goto Label_01E0;
                        }

                        case HorizontalAlignment.Right:
                        {
                            int num6 = viewportColumnLayoutModel[0].Column - 1;
                            CellOverflowLayout layout7 = BuildCellOverflowLayoutModelForRight(cachedCell, rowIndex, result, false, num6, textFormattingMode, useLayoutRounding);
                            if (layout7 != null)
                            {
                                result.Add(layout7);
                            }
                            break;
                        }
                        }
                    }
                }
                continue;
Label_01C1:
                layout3.BackgroundWidth += layout2.Width / 2.0;
Label_01E0:
                if (layout5 != null)
                {
                    layout3.StartingColumn      = layout5.StartingColumn;
                    layout3.BackgroundWidth    += layout5.BackgroundWidth;
                    layout3.LeftBackgroundWidth = layout5.LeftBackgroundWidth;
                }
                else
                {
                    layout3.BackgroundWidth += layout2.Width / 2.0;
                }
                if (layout3.BackgroundWidth > layout2.Width)
                {
                    Size textSize = MeasureHelper.MeasureTextInCell(cachedCell, new Size(double.PositiveInfinity, double.PositiveInfinity), (double)Viewport.Excel.ZoomFactor, null, textFormattingMode, useLayoutRounding);
                    layout3.ContentWidth = MeasureHelper.ConvertTextSizeToExcelCellSize(textSize, (double)Viewport.Excel.ZoomFactor).Width;
                    result.Add(layout3);
                }
            }
            result.TrailingOverflowlayout = BuildTrailingCellOverflowLayoutModel(rowIndex, viewportColumnLayoutModel, result, textFormattingMode, useLayoutRounding);
            if (((result.Count <= 0) && (result.HeadingOverflowlayout == null)) && (result.TrailingOverflowlayout == null))
            {
                return(null);
            }
            return(result);
        }
Example #8
0
        CellOverflowLayout BuildCellOverflowLayoutModelForRight(Cell bindingCell, int rowIndex, CellOverflowLayoutModel result, bool buildForCenter, int deadColumnIndex, object textFormattingMode, bool useLayoutRounding)
        {
            ICellsSupport dataContext = Viewport.GetDataContext();
            int           index       = bindingCell.Column.Index;

            if (index > deadColumnIndex)
            {
                Column          column          = dataContext.Columns[index];
                CellLayoutModel cellLayoutModel = Viewport.GetCellLayoutModel();
                Column          column2         = dataContext.Columns[index - 1];
                int             num2            = column2.Index;
                if ((cellLayoutModel != null) && (cellLayoutModel.FindCell(rowIndex, num2) != null))
                {
                    return(null);
                }
                Cell cachedCell = Viewport.CellCache.GetCachedCell(rowIndex, num2);
                if ((cachedCell != null) && !string.IsNullOrEmpty(cachedCell.Text))
                {
                    return(null);
                }
                float  zoomFactor = Viewport.Excel.ZoomFactor;
                Size   textSize   = MeasureHelper.MeasureTextInCell(bindingCell, new Size(double.PositiveInfinity, double.PositiveInfinity), (double)zoomFactor, null, textFormattingMode, useLayoutRounding);
                double width      = MeasureHelper.ConvertTextSizeToExcelCellSize(textSize, (double)zoomFactor).Width;
                double num5       = column.ActualWidth * zoomFactor;
                if (buildForCenter)
                {
                    width /= 2.0;
                    num5  /= 2.0;
                }
                double num6 = num5;
                if (num6 < width)
                {
                    CellOverflowLayout layout2 = new CellOverflowLayout(column.Index, num6)
                    {
                        StartingColumn = column.Index
                    };
                    for (int i = index - 1; (i >= 0) && (i >= deadColumnIndex); i--)
                    {
                        column2 = dataContext.Columns[i];
                        num2    = column2.Index;
                        if ((cellLayoutModel != null) && (cellLayoutModel.FindCell(rowIndex, num2) != null))
                        {
                            layout2.BackgroundWidth = num6;
                            layout2.StartingColumn  = dataContext.Columns[i + 1].Index;
                            break;
                        }
                        if (((cachedCell != null) && (result != null)) && result.Contains(column2.Index))
                        {
                            layout2.BackgroundWidth = num6;
                            layout2.StartingColumn  = dataContext.Columns[i + 1].Index;
                            break;
                        }
                        cachedCell = Viewport.CellCache.GetCachedCell(rowIndex, num2);
                        if ((cachedCell != null) && !string.IsNullOrEmpty(cachedCell.Text))
                        {
                            layout2.BackgroundWidth = num6;
                            layout2.StartingColumn  = dataContext.Columns[i + 1].Index;
                            break;
                        }
                        num6 += column2.ActualWidth * zoomFactor;
                        if (((num6 >= width) || (i == 0)) || (i <= deadColumnIndex))
                        {
                            layout2.BackgroundWidth = num6;
                            layout2.StartingColumn  = column2.Index;
                            break;
                        }
                    }
                    if (layout2.StartingColumn != column.Index)
                    {
                        layout2.ContentWidth        = MeasureHelper.ConvertTextSizeToExcelCellSize(textSize, (double)zoomFactor).Width;
                        layout2.LeftBackgroundWidth = num6;
                        return(layout2);
                    }
                }
            }
            return(null);
        }