iTextSharp.text.pdf.FloatLayout.floatingLayout C# (CSharp) Метод

floatingLayout() приватный Метод

private floatingLayout ( ColumnText compositeColumn, List floatingElements, bool simulate ) : int
compositeColumn ColumnText
floatingElements List
simulate bool
Результат int
        private int floatingLayout(ColumnText compositeColumn, List<IElement> floatingElements, bool simulate)
        {
            int status = ColumnText.NO_MORE_TEXT;
            float minYLine = yLine;
            float leftWidth = 0;
            float rightWidth = 0;

            while (floatingElements.Count > 0) {
                if (floatingElements[0] is PdfDiv) {
                    PdfDiv floatingElement = (PdfDiv)floatingElements[0];
                    floatingElements.RemoveAt(0);
                    status = floatingElement.layout(compositeColumn, true, floatLeftX, minY, floatRightX, yLine);
                    if ((status & ColumnText.NO_MORE_TEXT) == 0) {
                        yLine = minYLine;
                        floatLeftX = leftX;
                        floatRightX = rightX;
                        status = floatingElement.layout(compositeColumn, true, floatLeftX, minY, floatRightX, yLine);
                        if ((status & ColumnText.NO_MORE_TEXT) == 0) {
                            floatingElements.Insert(0, floatingElement);
                            break;
                        }
                    }
                    if (floatingElement.Float == PdfDiv.FloatType.LEFT) {
                        status = floatingElement.layout(compositeColumn, simulate, floatLeftX, minY, floatRightX, yLine);
                        floatLeftX += floatingElement.getActualWidth();
                        leftWidth += floatingElement.getActualWidth();
                    } else if (floatingElement.Float == PdfDiv.FloatType.RIGHT) {
                        status = floatingElement.layout(compositeColumn, simulate, floatRightX - floatingElement.getActualWidth() - 0.01f, minY, floatRightX, yLine);
                        floatRightX -= floatingElement.getActualWidth();
                        rightWidth += floatingElement.getActualWidth();
                    }
                    minYLine = Math.Min(minYLine, yLine - floatingElement.getActualHeight());
                } else {
                    IElement firstElement = floatingElements[0];
                    if (firstElement is ISpaceable) {
                        yLine -= ((ISpaceable)firstElement).SpacingBefore;
                    }
                    compositeColumn = simulate ? ColumnText.Duplicate(this.compositeColumn) : this.compositeColumn;
                    compositeColumn.AddElement(firstElement);
                    floatingElements.RemoveAt(0);
                    if (yLine > minYLine)
                        compositeColumn.SetSimpleColumn(floatLeftX, yLine, floatRightX, minYLine);
                    else
                        compositeColumn.SetSimpleColumn(floatLeftX, yLine, floatRightX, minY);

                    compositeColumn.FilledWidth = 0;

                    status = compositeColumn.Go(simulate);
                    if (yLine > minYLine && (floatLeftX > leftX || floatRightX < rightX) && (status & ColumnText.NO_MORE_TEXT) == 0) {
                        yLine = minYLine;
                        floatLeftX = leftX;
                        floatRightX = rightX;
                        if (leftWidth != 0 && rightWidth != 0) {
                            filledWidth = rightX - leftX;
                        } else {
                            if (leftWidth > filledWidth) {
                                filledWidth = leftWidth;
                            }
                            if (rightWidth > filledWidth) {
                                filledWidth = rightWidth;
                            }
                        }

                        leftWidth = 0;
                        rightWidth = 0;
                        compositeColumn.SetSimpleColumn(floatLeftX, yLine, floatRightX, minY);
                        status = compositeColumn.Go(simulate);
                        minYLine = compositeColumn.YLine + compositeColumn.Descender;
                        yLine = minYLine;
                        if (compositeColumn.FilledWidth > filledWidth) {
                            filledWidth = compositeColumn.FilledWidth;
                        }
                    } else {
                        if (rightWidth > 0) {
                            rightWidth += compositeColumn.FilledWidth;
                        } else if (leftWidth > 0) {
                            leftWidth += compositeColumn.FilledWidth;
                        } else if (compositeColumn.FilledWidth > filledWidth) {
                            filledWidth = compositeColumn.FilledWidth;
                        }
                        minYLine = Math.Min(compositeColumn.YLine + compositeColumn.Descender, minYLine);
                        yLine = compositeColumn.YLine + compositeColumn.Descender;
                    }

                    if ((status & ColumnText.NO_MORE_TEXT) == 0) {
                        if (!simulate) {
                            floatingElements.InsertRange(0, compositeColumn.CompositeElements);
                        } else {
                            floatingElements.Insert(0, firstElement);
                        }

                        compositeColumn.CompositeElements.Clear();
                        break;
                    } else {
                        compositeColumn.CompositeElements.Clear();
                    }
                }
            }

            if (leftWidth != 0 && rightWidth != 0) {
                filledWidth = rightX - leftX;
            } else {
                if (leftWidth > filledWidth) {
                    filledWidth = leftWidth;
                }
                if (rightWidth > filledWidth) {
                    filledWidth = rightWidth;
                }
            }

            yLine = minYLine;
            floatLeftX = leftX;
            floatRightX = rightX;

            return status;
        }