internal override void Format(Area area, FormatInfo previousFormatInfo) { FormattedTextFrame formattedTextFrame = new FormattedTextFrame(this.textframe, this.documentRenderer, this.fieldInfos); formattedTextFrame.Format(this.gfx); ((TextFrameFormatInfo)this.renderInfo.FormatInfo).formattedTextFrame = formattedTextFrame; base.Format(area, previousFormatInfo); }
internal override void Format(Area area, FormatInfo previousFormatInfo) { ChartFormatInfo formatInfo = (ChartFormatInfo)this.renderInfo.FormatInfo; TextArea textArea = (TextArea)this.chart.GetValue("HeaderArea", GV.ReadOnly); formatInfo.formattedHeader = GetFormattedTextArea(textArea, this.chart.Width.Point); textArea = (TextArea)this.chart.GetValue("FooterArea", GV.ReadOnly); formatInfo.formattedFooter = GetFormattedTextArea(textArea, this.chart.Width.Point); textArea = (TextArea)this.chart.GetValue("LeftArea", GV.ReadOnly); formatInfo.formattedLeft = GetFormattedTextArea(textArea); textArea = (TextArea)this.chart.GetValue("RightArea", GV.ReadOnly); formatInfo.formattedRight = GetFormattedTextArea(textArea); textArea = (TextArea)this.chart.GetValue("TopArea", GV.ReadOnly); formatInfo.formattedTop = GetFormattedTextArea(textArea, GetTopBottomWidth()); textArea = (TextArea)this.chart.GetValue("BottomArea", GV.ReadOnly); formatInfo.formattedBottom = GetFormattedTextArea(textArea, GetTopBottomWidth()); base.Format(area, previousFormatInfo); formatInfo.chartFrame = ChartMapper.ChartMapper.Map(this.chart); }
internal override void Format(Area area, FormatInfo previousFormatInfo) { FormattedTextFrame formattedTextFrame = new FormattedTextFrame(_textframe, _documentRenderer, _fieldInfos); formattedTextFrame.Format(_gfx); ((TextFrameFormatInfo)_renderInfo.FormatInfo).FormattedTextFrame = formattedTextFrame; base.Format(area, previousFormatInfo); }
internal override void Format(Area area, FormatInfo previousFormatInfo) { BarcodeFormatInfo formatInfo = (BarcodeFormatInfo)this.renderInfo.FormatInfo; formatInfo.Height = this.barcode.Height.Point; formatInfo.Width = this.barcode.Width.Point; base.Format(area, previousFormatInfo); }
internal override void Format(Area area, FormatInfo previousFormatInfo) { PageBreakRenderInfo pbRenderInfo = new PageBreakRenderInfo(); pbRenderInfo.FormatInfo = new PageBreakFormatInfo(); _renderInfo = pbRenderInfo; pbRenderInfo.LayoutInfo.PageBreakBefore = true; pbRenderInfo.LayoutInfo.ContentArea = new Rectangle(area.Y, area.Y, 0, 0); pbRenderInfo.DocumentObject = _pageBreak; }
internal override void Format(Area area, FormatInfo previousFormatInfo) { this.imageFilePath = image.GetFilePath(this.documentRenderer.WorkingDirectory); //if (!File.Exists(this.imageFilePath)) if (!XImage.ExistsFile(this.imageFilePath)) { this.failure = ImageFailure.FileNotFound; Trace.WriteLine(Messages.ImageNotFound(this.image.Name), "warning"); } ImageFormatInfo formatInfo = (ImageFormatInfo)this.renderInfo.FormatInfo; formatInfo.failure = this.failure; formatInfo.ImagePath = this.imageFilePath; CalculateImageDimensions(); base.Format(area, previousFormatInfo); }
internal override void Format(Area area, FormatInfo previousFormatInfo) { _imageFilePath = _image.GetFilePath(_documentRenderer.WorkingDirectory); // The Image is stored in the string if path starts with "base64:", otherwise we check whether the file exists. if (!_imageFilePath.StartsWith("base64:") && !XImage.ExistsFile(_imageFilePath)) { _failure = ImageFailure.FileNotFound; Debug.WriteLine(Messages2.ImageNotFound(_image.Name), "warning"); } ImageFormatInfo formatInfo = (ImageFormatInfo)_renderInfo.FormatInfo; formatInfo.Failure = _failure; formatInfo.ImagePath = _imageFilePath; CalculateImageDimensions(); base.Format(area, previousFormatInfo); }
bool NeedsEndingOnNextArea(int idx, Renderer renderer, Area remainingArea, bool isFirstOnPage) { LayoutInfo layoutInfo = renderer.RenderInfo.LayoutInfo; if (isFirstOnPage && layoutInfo.KeepTogether) return false; FormatInfo formatInfo = renderer.RenderInfo.FormatInfo; if (!formatInfo.EndingIsComplete) return false; if (layoutInfo.KeepWithNext) { remainingArea = remainingArea.Lower(layoutInfo.ContentArea.Height); return NextElementsDontFit(idx, remainingArea, layoutInfo.MarginBottom); } return false; }
bool NextElementsDontFit(int idx, Area remainingArea, XUnit previousMarginBottom) { XUnit elementDistance = previousMarginBottom; Area area = remainingArea; for (int index = idx + 1; index < this.elements.Count; ++index) { // Never combine more than MaxCombineElements elements if (index - idx > MaxCombineElements) return false; DocumentObject obj = this.elements[index]; Renderer currRenderer = Renderer.Create(this.gfx, this.documentRenderer, obj, this.areaProvider.AreaFieldInfos); elementDistance = MarginMax(elementDistance, currRenderer.InitialLayoutInfo.MarginTop); area = area.Lower(elementDistance); if (area.Height <= 0) return true; currRenderer.Format(area, null); FormatInfo currFormatInfo = currRenderer.RenderInfo.FormatInfo; LayoutInfo currLayoutInfo = currRenderer.RenderInfo.LayoutInfo; if (!(currLayoutInfo.VerticalReference == VerticalReference.PreviousElement)) return false; if (!currFormatInfo.StartingIsComplete) return true; if (currLayoutInfo.KeepTogether && !currFormatInfo.IsComplete) return true; if (!(currLayoutInfo.KeepTogether && currLayoutInfo.KeepWithNext)) return false; area = area.Lower(currLayoutInfo.ContentArea.Height); if (area.Height <= 0) return true; elementDistance = currLayoutInfo.MarginBottom; } return false; }
/// <summary> /// Returns the union of this area snd the given one. /// </summary> /// <param name="area">The area to unite with.</param> /// <returns>The union of the two areas.</returns> internal abstract Area Unite(Area area);
/// <summary> /// Indicates that a break between areas has to be performed before the element with the given idx. /// </summary> /// <param name="idx">Index of the document element.</param> /// <param name="renderer">A formatted renderer for the document element.</param> /// <param name="remainingArea">The remaining area.</param> bool IsForcedAreaBreak(int idx, Renderer renderer, Area remainingArea) { FormatInfo formatInfo = renderer.RenderInfo.FormatInfo; LayoutInfo layoutInfo = renderer.RenderInfo.LayoutInfo; if (formatInfo.IsStarting && !formatInfo.StartingIsComplete) return true; if (layoutInfo.KeepTogether && !formatInfo.IsComplete) return true; if (layoutInfo.KeepTogether && layoutInfo.KeepWithNext) { Area area = remainingArea.Lower(layoutInfo.ContentArea.Height); return NextElementsDontFit(idx, area, layoutInfo.MarginBottom); } return false; }
/// <summary> /// Formats the object by calculating distances and linebreaks and stopping when the area is filled. /// </summary> /// <param name="area">The area to render into.</param> /// <param name="previousFormatInfo">An information object received from a previous call of Format(). /// Null for the first call.</param> internal abstract void Format(Area area, FormatInfo previousFormatInfo);
/// <summary> /// Formats the elements on the areas provided by the area provider. /// </summary> /// <param name="gfx">The graphics object to render on.</param> /// <param name="topLevel">if set to <c>true</c> formats the object is on top level.</param> public void FormatOnAreas(XGraphics gfx, bool topLevel) { _gfx = gfx; XUnit prevBottomMargin = 0; XUnit yPos = prevBottomMargin; RenderInfo prevRenderInfo = null; FormatInfo prevFormatInfo = null; List <RenderInfo> renderInfos = new List <RenderInfo>(); bool ready = _elements.Count == 0; bool isFirstOnPage = true; Area area = _areaProvider.GetNextArea(); XUnit maxHeight = area.Height; if (ready) { _areaProvider.StoreRenderInfos(renderInfos); return; } int idx = 0; while (!ready && area != null) { DocumentObject docObj = _elements[idx]; Renderer renderer = Renderer.Create(gfx, _documentRenderer, docObj, _areaProvider.AreaFieldInfos); if (renderer != null) // "Slightly hacked" for legends: see below { renderer.MaxElementHeight = maxHeight; } if (topLevel && _documentRenderer.HasPrepareDocumentProgress) { _documentRenderer.OnPrepareDocumentProgress(_documentRenderer.ProgressCompleted + idx + 1, _documentRenderer.ProgressMaximum); } // "Slightly hacked" for legends: they are rendered as part of the chart. // So they are skipped here. if (renderer == null) { ready = idx == _elements.Count - 1; if (ready) { _areaProvider.StoreRenderInfos(renderInfos); } ++idx; continue; } /////////////////////////////////////////// if (prevFormatInfo == null) { LayoutInfo initialLayoutInfo = renderer.InitialLayoutInfo; XUnit distance = prevBottomMargin; if (initialLayoutInfo.VerticalReference == VerticalReference.PreviousElement && initialLayoutInfo.Floating != Floating.None) { distance = MarginMax(initialLayoutInfo.MarginTop, distance); } area = area.Lower(distance); } renderer.Format(area, prevFormatInfo); _areaProvider.PositionHorizontally(renderer.RenderInfo.LayoutInfo); bool pagebreakBefore = _areaProvider.IsAreaBreakBefore(renderer.RenderInfo.LayoutInfo) && !isFirstOnPage; pagebreakBefore = pagebreakBefore || !isFirstOnPage && IsForcedAreaBreak(idx, renderer, area); if (!pagebreakBefore && renderer.RenderInfo.FormatInfo.IsEnding) { if (PreviousRendererNeedsRemoveEnding(prevRenderInfo, renderer.RenderInfo, area)) { prevRenderInfo.RemoveEnding(); renderer = Renderer.Create(gfx, _documentRenderer, docObj, _areaProvider.AreaFieldInfos); renderer.MaxElementHeight = maxHeight; renderer.Format(area, prevRenderInfo.FormatInfo); } else if (NeedsEndingOnNextArea(idx, renderer, area, isFirstOnPage)) { renderer.RenderInfo.RemoveEnding(); prevRenderInfo = FinishPage(renderer.RenderInfo, pagebreakBefore, ref renderInfos); if (prevRenderInfo != null) { prevFormatInfo = prevRenderInfo.FormatInfo; } else { prevFormatInfo = null; isFirstOnPage = true; } prevBottomMargin = 0; area = _areaProvider.GetNextArea(); maxHeight = area.Height; } else { renderInfos.Add(renderer.RenderInfo); isFirstOnPage = false; _areaProvider.PositionVertically(renderer.RenderInfo.LayoutInfo); if (renderer.RenderInfo.LayoutInfo.VerticalReference == VerticalReference.PreviousElement && renderer.RenderInfo.LayoutInfo.Floating != Floating.None) { prevBottomMargin = renderer.RenderInfo.LayoutInfo.MarginBottom; if (renderer.RenderInfo.LayoutInfo.Floating != Floating.None) { area = area.Lower(renderer.RenderInfo.LayoutInfo.ContentArea.Height); } } else { prevBottomMargin = 0; } prevFormatInfo = null; prevRenderInfo = null; ++idx; } } else { if (renderer.RenderInfo.FormatInfo.IsEmpty && isFirstOnPage) { area = area.Unite(new Rectangle(area.X, area.Y, area.Width, double.MaxValue)); renderer = Renderer.Create(gfx, _documentRenderer, docObj, _areaProvider.AreaFieldInfos); renderer.MaxElementHeight = maxHeight; renderer.Format(area, prevFormatInfo); prevFormatInfo = null; _areaProvider.PositionHorizontally(renderer.RenderInfo.LayoutInfo); _areaProvider.PositionVertically(renderer.RenderInfo.LayoutInfo); ready = idx == _elements.Count - 1; ++idx; } prevRenderInfo = FinishPage(renderer.RenderInfo, pagebreakBefore, ref renderInfos); if (prevRenderInfo != null) { prevFormatInfo = prevRenderInfo.FormatInfo; } else { prevFormatInfo = null; } isFirstOnPage = true; prevBottomMargin = 0; if (!ready) { area = _areaProvider.GetNextArea(); maxHeight = area.Height; } } if (idx == _elements.Count && !ready) { _areaProvider.StoreRenderInfos(renderInfos); ready = true; } } }
/// <summary> /// Formats the paragraph by performing line breaks etc. /// </summary> /// <param name="area">The area in which to render.</param> /// <param name="previousFormatInfo">The format info that was obtained on formatting the same paragraph on a previous area.</param> internal override void Format(Area area, FormatInfo previousFormatInfo) { ParagraphFormatInfo formatInfo = ((ParagraphFormatInfo)this.renderInfo.FormatInfo); if (!InitFormat(area, previousFormatInfo)) { formatInfo.isStarting = false; return; } formatInfo.isEnding = true; FormatResult lastResult = FormatResult.Continue; while (this.currentLeaf != null) { FormatResult result = FormatElement(this.currentLeaf.Current); switch (result) { case FormatResult.Ignore: this.currentLeaf = this.currentLeaf.GetNextLeaf(); break; case FormatResult.Continue: lastResult = result; this.currentLeaf = this.currentLeaf.GetNextLeaf(); break; case FormatResult.NewLine: lastResult = result; StoreLineInformation(); if (!StartNewLine()) { result = FormatResult.NewArea; formatInfo.isEnding = false; } break; } if (result == FormatResult.NewArea) { lastResult = result; formatInfo.isEnding = false; break; } } if (formatInfo.IsEnding && lastResult != FormatResult.NewLine) StoreLineInformation(); formatInfo.imageRenderInfos = this.imageRenderInfos; FinishLayoutInfo(); }
/// <summary> /// Formats (measures) the table. /// </summary> /// <param name="area">The area on which to fit the table.</param> /// <param name="previousFormatInfo"></param> internal override void Format(Area area, FormatInfo previousFormatInfo) { DocumentElements elements = DocumentRelations.GetParent(this.table) as DocumentElements; if (elements != null) { Section section = DocumentRelations.GetParent(elements) as Section; if (section != null) this.doHorizontalBreak = section.PageSetup.HorizontalPageBreak; } this.renderInfo = new TableRenderInfo(); InitFormat(area, previousFormatInfo); // Don't take any Rows higher then MaxElementHeight XUnit topHeight = this.CalcStartingHeight(); XUnit probeHeight = topHeight; XUnit offset = 0; if (this.startRow > this.lastHeaderRow + 1 && this.startRow < this.table.Rows.Count) offset = (XUnit)this.bottomBorderMap[this.startRow] - topHeight; else offset = -CalcMaxTopBorderWidth(0); int probeRow = this.startRow; XUnit currentHeight = 0; XUnit startingHeight = 0; bool isEmpty = false; while (probeRow < this.table.Rows.Count) { bool firstProbe = probeRow == this.startRow; probeRow = (int)this.connectedRowsMap[probeRow]; // Don't take any Rows higher then MaxElementHeight probeHeight = (XUnit)this.bottomBorderMap[probeRow + 1] - offset; if (firstProbe && probeHeight > MaxElementHeight - Tolerance) probeHeight = MaxElementHeight - Tolerance; //The height for the first new row(s) + headerrows: if (startingHeight == 0) { if (probeHeight > area.Height) { isEmpty = true; break; } startingHeight = probeHeight; } if (probeHeight > area.Height) break; else { this.currRow = probeRow; currentHeight = probeHeight; ++probeRow; } } if (!isEmpty) { TableFormatInfo formatInfo = (TableFormatInfo)this.renderInfo.FormatInfo; formatInfo.startRow = this.startRow; formatInfo.isEnding = currRow >= this.table.Rows.Count - 1; formatInfo.endRow = this.currRow; } FinishLayoutInfo(area, currentHeight, startingHeight); }
/// <summary> /// Formats the shape. /// </summary> /// <param name="area">The area to fit in the shape.</param> /// <param name="previousFormatInfo"></param> internal override void Format(Area area, FormatInfo previousFormatInfo) { Floating floating = GetFloating(); bool fits = floating == Floating.None || this.ShapeHeight <= area.Height; ((ShapeFormatInfo)this.renderInfo.FormatInfo).fits = fits; FinishLayoutInfo(area); }
void FinishLayoutInfo(Area area) { LayoutInfo layoutInfo = this.renderInfo.LayoutInfo; Area contentArea = new Rectangle(area.X, area.Y, ShapeWidth, ShapeHeight); layoutInfo.ContentArea = contentArea; layoutInfo.MarginTop = this.shape.WrapFormat.DistanceTop.Point; layoutInfo.MarginLeft = this.shape.WrapFormat.DistanceLeft.Point; layoutInfo.MarginBottom = this.shape.WrapFormat.DistanceBottom.Point; layoutInfo.MarginRight = this.shape.WrapFormat.DistanceRight.Point; layoutInfo.KeepTogether = true; layoutInfo.KeepWithNext = false; layoutInfo.PageBreakBefore = false; layoutInfo.MinWidth = this.ShapeWidth; if (this.shape.Top.ShapePosition == ShapePosition.Undefined) layoutInfo.Top = this.shape.Top.Position.Point; layoutInfo.VerticalAlignment = GetVerticalAlignment(); layoutInfo.HorizontalAlignment = GetHorizontalAlignment(); if (this.shape.Left.ShapePosition == ShapePosition.Undefined) layoutInfo.Left = this.shape.Left.Position.Point; layoutInfo.HorizontalReference = GetHorizontalReference(); layoutInfo.VerticalReference = GetVerticalReference(); layoutInfo.Floating = GetFloating(); }
void ReMeasureLine(ref LineInfo lineInfo) { //--- Save --------------------------------- ParagraphIterator iter; int blankCount; XUnit xPosition; XUnit lineWidth; XUnit wordsWidth; XUnit blankWidth; SaveBeforeProbing(out iter, out blankCount, out wordsWidth, out xPosition, out lineWidth, out blankWidth); bool origLastTabPassed = this.lastTabPassed; //------------------------------------------ this.currentLeaf = lineInfo.startIter; this.endLeaf = lineInfo.endIter; this.formattingArea = this.renderInfo.LayoutInfo.ContentArea; this.tabOffsets = new ArrayList(); this.currentLineWidth = 0; this.currentWordsWidth = 0; Rectangle fittingRect = this.formattingArea.GetFittingRect(this.currentYPosition, this.currentVerticalInfo.height); if (fittingRect == null) GetType(); if (fittingRect != null) { this.currentXPosition = fittingRect.X + this.LeftIndent; FormatListSymbol(); bool goOn = true; while (goOn && this.currentLeaf != null) { if (this.currentLeaf.Current == lineInfo.lastTab) this.lastTabPassed = true; FormatElement(this.currentLeaf.Current); goOn = this.currentLeaf != null && this.currentLeaf.Current != this.endLeaf.Current; if (goOn) this.currentLeaf = this.currentLeaf.GetNextLeaf(); } lineInfo.lineWidth = this.currentLineWidth; lineInfo.wordsWidth = this.currentWordsWidth; lineInfo.blankCount = this.currentBlankCount; lineInfo.tabOffsets = this.tabOffsets; lineInfo.reMeasureLine = false; this.lastTabPassed = origLastTabPassed; } RestoreAfterProbing(iter, blankCount, wordsWidth, xPosition, lineWidth, blankWidth); }
/// <summary> /// Initializes this instance for formatting. /// </summary> /// <param name="area">The area for formatting</param> /// <param name="previousFormatInfo">A previous format info.</param> /// <returns>False, if nothing of the paragraph will fit the area any more.</returns> private bool InitFormat(Area area, FormatInfo previousFormatInfo) { _phase = Phase.Formatting; _tabOffsets = new List<TabOffset>(); ParagraphFormatInfo prevParaFormatInfo = (ParagraphFormatInfo)previousFormatInfo; if (previousFormatInfo == null || prevParaFormatInfo.LineCount == 0) { ((ParagraphFormatInfo)_renderInfo.FormatInfo)._isStarting = true; ParagraphIterator parIt = new ParagraphIterator(_paragraph.Elements); _currentLeaf = parIt.GetFirstLeaf(); _isFirstLine = true; } else { _currentLeaf = prevParaFormatInfo.GetLastLineInfo().EndIter.GetNextLeaf(); _isFirstLine = false; ((ParagraphFormatInfo)_renderInfo.FormatInfo)._isStarting = false; } _startLeaf = _currentLeaf; _currentVerticalInfo = CalcCurrentVerticalInfo(); _currentYPosition = area.Y + TopBorderOffset; _formattingArea = area; Rectangle rect = _formattingArea.GetFittingRect(_currentYPosition, _currentVerticalInfo.Height); if (rect == null) return false; _currentXPosition = rect.X + LeftIndent; if (_isFirstLine) FormatListSymbol(); return true; }
/// <summary> /// Indicates that the Ending of the element has to be removed. /// </summary> /// <param name="prevRenderInfo">The prev render info.</param> /// <param name="succedingRenderInfo">The succeding render info.</param> /// <param name="remainingArea">The remaining area.</param> bool PreviousRendererNeedsRemoveEnding(RenderInfo prevRenderInfo, RenderInfo succedingRenderInfo, Area remainingArea) { if (prevRenderInfo == null) return false; LayoutInfo layoutInfo = succedingRenderInfo.LayoutInfo; FormatInfo formatInfo = succedingRenderInfo.FormatInfo; LayoutInfo prevLayoutInfo = prevRenderInfo.LayoutInfo; if (formatInfo.IsEnding && !formatInfo.EndingIsComplete) { Area area = this.areaProvider.ProbeNextArea(); if (area.Height > prevLayoutInfo.TrailingHeight + layoutInfo.TrailingHeight + Renderer.Tolerance) return true; } return false; }
void InitFormat(Area area, FormatInfo previousFormatInfo) { TableFormatInfo prevTableFormatInfo = (TableFormatInfo)previousFormatInfo; TableRenderInfo tblRenderInfo = new TableRenderInfo(); tblRenderInfo.table = this.table; this.renderInfo = tblRenderInfo; if (prevTableFormatInfo != null) { this.mergedCells = prevTableFormatInfo.mergedCells; this.formattedCells = prevTableFormatInfo.formattedCells; this.bottomBorderMap = prevTableFormatInfo.bottomBorderMap; this.lastHeaderRow = prevTableFormatInfo.lastHeaderRow; this.connectedRowsMap = prevTableFormatInfo.connectedRowsMap; this.startRow = prevTableFormatInfo.endRow + 1; } else { this.mergedCells = new MergedCellList(this.table); FormatCells(); CalcLastHeaderRow(); CreateConnectedRows(); CreateBottomBorderMap(); if (this.doHorizontalBreak) { CalcLastHeaderColumn(); CreateConnectedColumns(); } this.startRow = this.lastHeaderRow + 1; } ((TableFormatInfo)tblRenderInfo.FormatInfo).mergedCells = this.mergedCells; ((TableFormatInfo)tblRenderInfo.FormatInfo).formattedCells = this.formattedCells; ((TableFormatInfo)tblRenderInfo.FormatInfo).bottomBorderMap = this.bottomBorderMap; ((TableFormatInfo)tblRenderInfo.FormatInfo).connectedRowsMap = this.connectedRowsMap; ((TableFormatInfo)tblRenderInfo.FormatInfo).lastHeaderRow = this.lastHeaderRow; }
private void FinishLayoutInfo(Area area, XUnit currentHeight, XUnit startingHeight) { LayoutInfo layoutInfo = _renderInfo.LayoutInfo; layoutInfo.StartingHeight = startingHeight; //REM: Trailing height would have to be calculated in case tables had a keep with next property. layoutInfo.TrailingHeight = 0; if (_currRow >= 0) { layoutInfo.ContentArea = new Rectangle(area.X, area.Y, 0, currentHeight); XUnit width = LeftBorderOffset; foreach (Column clm in _table.Columns) { width += clm.Width; } layoutInfo.ContentArea.Width = width; } layoutInfo.MinWidth = layoutInfo.ContentArea.Width; if (!_table.Rows._leftIndent.IsNull) layoutInfo.Left = _table.Rows.LeftIndent.Point; else if (_table.Rows.Alignment == RowAlignment.Left) { XUnit leftOffset = LeftBorderOffset; leftOffset += _table.Columns[0].LeftPadding; layoutInfo.Left = -leftOffset; } switch (_table.Rows.Alignment) { case RowAlignment.Left: layoutInfo.HorizontalAlignment = ElementAlignment.Near; break; case RowAlignment.Right: layoutInfo.HorizontalAlignment = ElementAlignment.Far; break; case RowAlignment.Center: layoutInfo.HorizontalAlignment = ElementAlignment.Center; break; } }
void FinishLayoutInfo(Area area, XUnit currentHeight, XUnit startingHeight) { LayoutInfo layoutInfo = this.renderInfo.LayoutInfo; layoutInfo.StartingHeight = startingHeight; //REM: Trailing height would have to be calculated in case tables had a keep with next property. layoutInfo.TrailingHeight = 0; if (this.currRow >= 0) { layoutInfo.ContentArea = new Rectangle(area.X, area.Y, 0, currentHeight); XUnit width = LeftBorderOffset; foreach (Column clm in this.table.Columns) { width += clm.Width; } layoutInfo.ContentArea.Width = width; } layoutInfo.MinWidth = layoutInfo.ContentArea.Width; if (!this.table.Rows.IsNull("LeftIndent")) layoutInfo.Left = this.table.Rows.LeftIndent.Point; else if (this.table.Rows.Alignment == RowAlignment.Left) { if (table.Columns.Count > 0) // Errors in Wiki syntax can lead to tables w/o columns ... { XUnit leftOffset = LeftBorderOffset; leftOffset += table.Columns[0].LeftPadding; layoutInfo.Left = -leftOffset; } #if DEBUG else table.GetType(); #endif } switch (this.table.Rows.Alignment) { case RowAlignment.Left: layoutInfo.HorizontalAlignment = ElementAlignment.Near; break; case RowAlignment.Right: layoutInfo.HorizontalAlignment = ElementAlignment.Far; break; case RowAlignment.Center: layoutInfo.HorizontalAlignment = ElementAlignment.Center; break; } }
/// <summary> /// Returns the union of the rectangle and the given area. /// </summary> /// <param name="area">The area to unite with.</param> /// <returns>The union of the two areas.</returns> internal override Area Unite(Area area) { if (area == null) return this; // This implementation is of course not correct, but it works for our purposes. XUnit minTop = Math.Min(_y, area.Y); XUnit minLeft = Math.Min(_x, area.X); XUnit maxRight = Math.Max(_x + _width, area.X + area.Width); XUnit maxBottom = Math.Max(_y + _height, area.Y + area.Height); return new Rectangle(minLeft, minTop, maxRight - minLeft, maxBottom - minTop); }
/// <summary> /// Initializes this instance for formatting. /// </summary> /// <param name="area">The area for formatting</param> /// <param name="previousFormatInfo">A previous format info.</param> /// <returns>False, if nothing of the paragraph will fit the area any more.</returns> private bool InitFormat(Area area, FormatInfo previousFormatInfo) { this.phase = Phase.Formatting; this.tabOffsets = new ArrayList(); ParagraphFormatInfo prevParaFormatInfo = (ParagraphFormatInfo)previousFormatInfo; if (previousFormatInfo == null || prevParaFormatInfo.LineCount == 0) { ((ParagraphFormatInfo)this.renderInfo.FormatInfo).isStarting = true; ParagraphIterator parIt = new ParagraphIterator(this.paragraph.Elements); this.currentLeaf = parIt.GetFirstLeaf(); this.isFirstLine = true; } else { this.currentLeaf = prevParaFormatInfo.GetLastLineInfo().endIter.GetNextLeaf(); this.isFirstLine = false; ((ParagraphFormatInfo)this.renderInfo.FormatInfo).isStarting = false; } this.startLeaf = this.currentLeaf; this.currentVerticalInfo = CalcCurrentVerticalInfo(); this.currentYPosition = area.Y + TopBorderOffset; this.formattingArea = area; Rectangle rect = this.formattingArea.GetFittingRect(this.currentYPosition, this.currentVerticalInfo.height); if (rect == null) return false; this.currentXPosition = rect.X + LeftIndent; if (this.isFirstLine) FormatListSymbol(); return true; }
/// <summary> /// Indicates that the Ending of the element has to be removed. /// </summary> /// <param name="prevRenderInfo">The prev render info.</param> /// <param name="succedingRenderInfo">The succeding render info.</param> /// <param name="remainingArea">The remaining area.</param> bool PreviousRendererNeedsRemoveEnding(RenderInfo prevRenderInfo, RenderInfo succedingRenderInfo, Area remainingArea) { if (prevRenderInfo == null) { return(false); } LayoutInfo layoutInfo = succedingRenderInfo.LayoutInfo; FormatInfo formatInfo = succedingRenderInfo.FormatInfo; LayoutInfo prevLayoutInfo = prevRenderInfo.LayoutInfo; if (formatInfo.IsEnding && !formatInfo.EndingIsComplete) { Area area = _areaProvider.ProbeNextArea(); if (area.Height > prevLayoutInfo.TrailingHeight + layoutInfo.TrailingHeight + Renderer.Tolerance) { return(true); } } return(false); }
private void InitFormat(Area area, FormatInfo previousFormatInfo) { TableFormatInfo prevTableFormatInfo = (TableFormatInfo)previousFormatInfo; TableRenderInfo tblRenderInfo = new TableRenderInfo(); tblRenderInfo.DocumentObject = _table; // Equalize the two borders, that are used to determine a rounded corner's border. // This way the innerWidth of the cell, which is got by the saved _formattedCells, is the same regardless of which corner relevant border is set. foreach (Row row in _table.Rows) foreach (Cell cell in row.Cells) EqualizeRoundedCornerBorders(cell); _renderInfo = tblRenderInfo; if (prevTableFormatInfo != null) { _mergedCells = prevTableFormatInfo.MergedCells; _formattedCells = prevTableFormatInfo.FormattedCells; _bottomBorderMap = prevTableFormatInfo.BottomBorderMap; _lastHeaderRow = prevTableFormatInfo.LastHeaderRow; _connectedRowsMap = prevTableFormatInfo.ConnectedRowsMap; _startRow = prevTableFormatInfo.EndRow + 1; } else { _mergedCells = new MergedCellList(_table); FormatCells(); CalcLastHeaderRow(); CreateConnectedRows(); CreateBottomBorderMap(); if (_doHorizontalBreak) { CalcLastHeaderColumn(); CreateConnectedColumns(); } _startRow = _lastHeaderRow + 1; } ((TableFormatInfo)tblRenderInfo.FormatInfo).MergedCells = _mergedCells; ((TableFormatInfo)tblRenderInfo.FormatInfo).FormattedCells = _formattedCells; ((TableFormatInfo)tblRenderInfo.FormatInfo).BottomBorderMap = _bottomBorderMap; ((TableFormatInfo)tblRenderInfo.FormatInfo).ConnectedRowsMap = _connectedRowsMap; ((TableFormatInfo)tblRenderInfo.FormatInfo).LastHeaderRow = _lastHeaderRow; }
/// <summary> /// Formats (measures) the table. /// </summary> /// <param name="area"> The area on which to fit the table. </param> /// <param name="previousFormatInfo"> </param> public override void Format(Area area, FormatInfo previousFormatInfo) { DocumentElements elements = DocumentRelations.GetParent(_table) as DocumentElements; if (elements != null) { Section section = DocumentRelations.GetParent(elements) as Section; if (section != null) { _doHorizontalBreak = section.PageSetup.HorizontalPageBreak; } } _renderInfo = new TableRenderInfo(); InitFormat(area, previousFormatInfo); // Don't take any Rows higher then MaxElementHeight XUnit topHeight = CalcStartingHeight(); XUnit probeHeight = topHeight; XUnit offset; if (_startRow > _lastHeaderRow + 1 && _startRow < _table.Rows.Count) { offset = _bottomBorderMap[_startRow] - topHeight; } else { offset = -CalcMaxTopBorderWidth(0); } int probeRow = _startRow; XUnit currentHeight = 0; XUnit startingHeight = 0; bool isEmpty = false; while (probeRow < _table.Rows.Count) { bool firstProbe = probeRow == _startRow; probeRow = _connectedRowsMap[probeRow]; // Don't take any Rows higher then MaxElementHeight probeHeight = _bottomBorderMap[probeRow + 1] - offset; // First test whether MaxElementHeight has been set. if (MaxElementHeight > 0 && firstProbe && probeHeight > MaxElementHeight - Tolerance) { probeHeight = MaxElementHeight - Tolerance; } //if (firstProbe && probeHeight > MaxElementHeight - Tolerance) // probeHeight = MaxElementHeight - Tolerance; //The height for the first new row(s) + headerrows: if (startingHeight == 0) { if (probeHeight > area.Height) { isEmpty = true; break; } startingHeight = probeHeight; } if (probeHeight > area.Height) { break; } else { _currRow = probeRow; currentHeight = probeHeight; ++probeRow; } } if (!isEmpty) { TableFormatInfo formatInfo = (TableFormatInfo)_renderInfo.FormatInfo; formatInfo.StartRow = _startRow; formatInfo._isEnding = _currRow >= _table.Rows.Count - 1; formatInfo.EndRow = _currRow; } FinishLayoutInfo(area, currentHeight, startingHeight); }