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) { 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) { 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) { 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); }
/// <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); }
/// <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> /// 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> /// 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> /// /// </summary> /// <param name="mergeInfo"></param> /// <returns></returns> internal void Append(FormatInfo mergeInfo) { ParagraphFormatInfo formatInfo = (ParagraphFormatInfo)mergeInfo; this.lineInfos.AddRange(formatInfo.lineInfos); }
/// <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); }
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 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> /// /// </summary> /// <param name="mergeInfo"></param> /// <returns></returns> internal void Append(FormatInfo mergeInfo) { ParagraphFormatInfo formatInfo = (ParagraphFormatInfo)mergeInfo; _lineInfos.AddRange(formatInfo._lineInfos); }
/// <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(_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); }
/// <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> /// 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; } } }