public override Status Layout(Area area) { BlockArea blockArea; if (this.marker == MarkerBreakAfter) { return(new Status(Status.OK)); } if (this.marker == MarkerStart) { AccessibilityProps mAccProps = propMgr.GetAccessibilityProps(); AuralProps mAurProps = propMgr.GetAuralProps(); BorderAndPadding bap = propMgr.GetBorderAndPadding(); BackgroundProps bProps = propMgr.GetBackgroundProps(); HyphenationProps mHyphProps = propMgr.GetHyphenationProps(); MarginProps mProps = propMgr.GetMarginProps(); RelativePositionProps mRelProps = propMgr.GetRelativePositionProps(); this.align = this.properties.GetTextAlign(); this.alignLast = this.properties.GetTextAlignLast(); this.breakAfter = this.properties.GetProperty("break-after").GetEnum(); this.lineHeight = this.properties.GetProperty("line-height").GetLength().MValue(); this.startIndent = this.properties.GetProperty("start-indent").GetLength().MValue(); this.endIndent = this.properties.GetProperty("end-indent").GetLength().MValue(); this.spaceBefore = this.properties.GetProperty("space-before.optimum").GetLength().MValue(); this.spaceAfter = this.properties.GetProperty("space-after.optimum").GetLength().MValue(); this.textIndent = this.properties.GetProperty("text-indent").GetLength().MValue(); this.keepWithNext = this.properties.GetProperty("keep-with-next").GetEnum(); this.blockWidows = this.properties.GetProperty("widows").GetNumber().IntValue(); this.blockOrphans = (int) this.properties.GetProperty("orphans").GetNumber().IntValue(); this.id = this.properties.GetProperty("id").GetString(); if (area is BlockArea) { area.end(); } if (area.getIDReferences() != null) { area.getIDReferences().CreateID(id); } this.marker = 0; int breakBeforeStatus = propMgr.CheckBreakBefore(area); if (breakBeforeStatus != Status.OK) { return(new Status(breakBeforeStatus)); } int numChildren = this.children.Count; for (int i = 0; i < numChildren; i++) { FONode fo = (FONode)children[i]; if (fo is FOText) { if (((FOText)fo).willCreateArea()) { fo.SetWidows(blockWidows); break; } else { children.RemoveAt(i); numChildren = this.children.Count; i--; } } else { fo.SetWidows(blockWidows); break; } } for (int i = numChildren - 1; i >= 0; i--) { FONode fo = (FONode)children[i]; if (fo is FOText) { if (((FOText)fo).willCreateArea()) { fo.SetOrphans(blockOrphans); break; } } else { fo.SetOrphans(blockOrphans); break; } } } if ((spaceBefore != 0) && (this.marker == 0)) { area.addDisplaySpace(spaceBefore); } if (anythingLaidOut) { this.textIndent = 0; } if (marker == 0 && area.getIDReferences() != null) { MyIDRefs refs = (MyIDRefs)area.getIDReferences(); refs.ConfigureID(id, area); } int spaceLeft = area.spaceLeft(); blockArea = new BlockArea(propMgr.GetFontState(area.getFontInfo()), area.getAllocationWidth(), area.spaceLeft(), startIndent, endIndent, textIndent, align, alignLast, lineHeight); blockArea.setGeneratedBy(this); this.areasGenerated++; if (this.areasGenerated == 1) { blockArea.isFirst(true); } blockArea.addLineagePair(this, this.areasGenerated); blockArea.setParent(area); blockArea.setPage(area.getPage()); blockArea.setBackground(propMgr.GetBackgroundProps()); blockArea.setBorderAndPadding(propMgr.GetBorderAndPadding()); blockArea.setHyphenation(propMgr.GetHyphenationProps()); blockArea.start(); blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); blockArea.setIDReferences(area.getIDReferences()); blockArea.setTableCellXOffset(area.getTableCellXOffset()); for (int i = this.marker; i < children.Count; i++) { FONode fo = (FONode)children[i]; Status status; if ((status = fo.Layout(blockArea)).isIncomplete()) { this.marker = i; if (status.getCode() == Status.AREA_FULL_NONE) { if ((i != 0)) { status = new Status(Status.AREA_FULL_SOME); area.addChild(blockArea); area.setMaxHeight(area.getMaxHeight() - spaceLeft + blockArea.getMaxHeight()); area.increaseHeight(blockArea.GetHeight()); anythingLaidOut = true; return(status); } else { anythingLaidOut = false; return(status); } } area.addChild(blockArea); area.setMaxHeight(area.getMaxHeight() - spaceLeft + blockArea.getMaxHeight()); area.increaseHeight(blockArea.GetHeight()); anythingLaidOut = true; return(status); } anythingLaidOut = true; } blockArea.end(); area.setMaxHeight(area.getMaxHeight() - spaceLeft + blockArea.getMaxHeight()); area.addChild(blockArea); area.increaseHeight(blockArea.GetHeight()); if (spaceAfter != 0) { area.addDisplaySpace(spaceAfter); } if (area is BlockArea) { area.start(); } areaHeight = blockArea.GetHeight(); contentWidth = blockArea.getContentWidth(); int breakAfterStatus = propMgr.CheckBreakAfter(area); if (breakAfterStatus != Status.OK) { this.marker = MarkerBreakAfter; blockArea = null; return(new Status(breakAfterStatus)); } if (keepWithNext != 0) { blockArea = null; return(new Status(Status.KEEP_WITH_NEXT)); } blockArea.isLast(true); blockArea = null; return(new Status(Status.OK)); }
public override Status Layout(Area area) { if (!(area is BlockArea)) { FonetDriver.ActiveDriver.FireFonetWarning( "Page-number-citation outside block area"); return(new Status(Status.OK)); } MyIDRefs idReferences = area.GetMyRefs(); this.area = area; if (this.marker == MarkerStart) { AccessibilityProps mAccProps = propMgr.GetAccessibilityProps(); AuralProps mAurProps = propMgr.GetAuralProps(); BorderAndPadding bap = propMgr.GetBorderAndPadding(); BackgroundProps bProps = propMgr.GetBackgroundProps(); MarginInlineProps mProps = propMgr.GetMarginInlineProps(); RelativePositionProps mRelProps = propMgr.GetRelativePositionProps(); ColorType c = this.properties.GetProperty("color").GetColorType(); this.red = c.Red; this.green = c.Green; this.blue = c.Blue; this.wrapOption = (WrapOption)this.properties.GetProperty("wrap-option").GetEnum(); this.whiteSpaceCollapse = this.properties.GetProperty("white-space-collapse").GetEnum(); this.refId = this.properties.GetProperty("ref-id").GetString(); if (this.refId.Equals("")) { throw new FonetException("page-number-citation must contain \"ref-id\""); } this.id = this.properties.GetProperty("id").GetString(); idReferences.CreateID(id); ts = new TextState(); this.marker = 0; } if (marker == 0) { idReferences.ConfigureID(id, area); } pageNumber = idReferences.getPageNumber(refId); if (pageNumber != null) { this.marker = FOText.addText((BlockArea)area, propMgr.GetFontState(area.getFontInfo()), red, green, blue, wrapOption, null, whiteSpaceCollapse, pageNumber.ToCharArray(), 0, pageNumber.Length, ts, VerticalAlign.BASELINE); } else { BlockArea blockArea = (BlockArea)area; LineArea la = blockArea.getCurrentLineArea(); if (la == null) { return(new Status(Status.AREA_FULL_NONE)); } la.changeFont(propMgr.GetFontState(area.getFontInfo())); la.changeColor(red, green, blue); la.changeWrapOption(wrapOption); la.changeWhiteSpaceCollapse(whiteSpaceCollapse); la.addPageNumberCitation(refId, null); this.marker = -1; } if (this.marker == -1) { return(new Status(Status.OK)); } else { return(new Status(Status.AREA_FULL_NONE)); } }
public override Status Layout(Area area) { if (this.marker == MarkerBreakAfter) { return(new Status(Status.OK)); } if (this.marker == MarkerStart) { AccessibilityProps mAccProps = propMgr.GetAccessibilityProps(); AuralProps mAurProps = propMgr.GetAuralProps(); BorderAndPadding bap = propMgr.GetBorderAndPadding(); BackgroundProps bProps = propMgr.GetBackgroundProps(); RelativePositionProps mRelProps = propMgr.GetRelativePositionProps(); this.spaceBefore = this.properties.GetProperty("space-before.optimum").GetLength().MValue(); this.spaceAfter = this.properties.GetProperty("space-after.optimum").GetLength().MValue(); this.id = this.properties.GetProperty("id").GetString(); try { area.getIDReferences().CreateID(id); } catch (FonetException e) { throw e; } if (area is BlockArea) { area.end(); } if (rowSpanMgr == null) { rowSpanMgr = new RowSpanMgr(columns.Count); } this.marker = 0; } if ((spaceBefore != 0) && (this.marker == 0)) { area.increaseHeight(spaceBefore); } if (marker == 0) { MyIDRefs refs = (MyIDRefs)area.getIDReferences(); refs.ConfigureID(id, area); } int spaceLeft = area.spaceLeft(); this.areaContainer = new AreaContainer(propMgr.GetFontState(area.getFontInfo()), 0, area.getContentHeight(), area.getContentWidth(), area.spaceLeft(), Position.RELATIVE); areaContainer.foCreator = this; areaContainer.setPage(area.getPage()); areaContainer.setParent(area); areaContainer.setBackground(propMgr.GetBackgroundProps()); areaContainer.setBorderAndPadding(propMgr.GetBorderAndPadding()); areaContainer.start(); areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); areaContainer.setIDReferences(area.getIDReferences()); Hashtable keepWith = new Hashtable(); int numChildren = this.children.Count; TableRow lastRow = null; bool endKeepGroup = true; for (int i = this.marker; i < numChildren; i++) { Object child = children[i]; if (child is Marker) { ((Marker)child).Layout(area); continue; } if (!(child is TableRow)) { throw new FonetException("Currently only Table Rows are supported in table body, header and footer"); } TableRow row = (TableRow)child; row.SetRowSpanMgr(rowSpanMgr); row.SetColumns(columns); row.DoSetup(areaContainer); if ((row.GetKeepWithPrevious().GetKeepType() != KeepValue.KEEP_WITH_AUTO || row.GetKeepWithNext().GetKeepType() != KeepValue.KEEP_WITH_AUTO || row.GetKeepTogether().GetKeepType() != KeepValue.KEEP_WITH_AUTO) && lastRow != null && !keepWith.Contains(lastRow)) { keepWith.Add(lastRow, null); } else { if (endKeepGroup && keepWith.Count > 0) { keepWith = new Hashtable(); } if (endKeepGroup && i > this.marker) { rowSpanMgr.SetIgnoreKeeps(false); } } bool bRowStartsArea = (i == this.marker); if (bRowStartsArea == false && keepWith.Count > 0) { if (children.IndexOf(keepWith[0]) == this.marker) { bRowStartsArea = true; } } row.setIgnoreKeepTogether(bRowStartsArea && startsAC(area)); Status status = row.Layout(areaContainer); if (status.isIncomplete()) { if (status.isPageBreak()) { this.marker = i; area.addChild(areaContainer); area.increaseHeight(areaContainer.GetHeight()); if (i == numChildren - 1) { this.marker = MarkerBreakAfter; if (spaceAfter != 0) { area.increaseHeight(spaceAfter); } } return(status); } if ((keepWith.Count > 0) && (!rowSpanMgr.IgnoreKeeps())) { row.RemoveLayout(areaContainer); foreach (TableRow tr in keepWith.Keys) { tr.RemoveLayout(areaContainer); i--; } if (i == 0) { ResetMarker(); rowSpanMgr.SetIgnoreKeeps(true); return(new Status(Status.AREA_FULL_NONE)); } } this.marker = i; if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { status = new Status(Status.AREA_FULL_SOME); } if (!((i == 0) && (areaContainer.getContentHeight() <= 0))) { area.addChild(areaContainer); area.increaseHeight(areaContainer.GetHeight()); } rowSpanMgr.SetIgnoreKeeps(true); return(status); } else if (status.getCode() == Status.KEEP_WITH_NEXT || rowSpanMgr.HasUnfinishedSpans()) { keepWith.Add(row, null); endKeepGroup = false; } else { endKeepGroup = true; } lastRow = row; area.setMaxHeight(area.getMaxHeight() - spaceLeft + this.areaContainer.getMaxHeight()); spaceLeft = area.spaceLeft(); } area.addChild(areaContainer); areaContainer.end(); area.increaseHeight(areaContainer.GetHeight()); if (spaceAfter != 0) { area.increaseHeight(spaceAfter); area.setMaxHeight(area.getMaxHeight() - spaceAfter); } if (area is BlockArea) { area.start(); } return(new Status(Status.OK)); }
public override Status Layout(Area area) { if (this.marker == MarkerBreakAfter) { return(new Status(Status.OK)); } if (this.marker == MarkerStart) { if (!setup) { DoSetup(area); } if (cellArray == null) { InitCellArray(); area.getIDReferences().CreateID(id); } this.marker = 0; int breakStatus = propMgr.CheckBreakBefore(area); if (breakStatus != Status.OK) { return(new Status(breakStatus)); } } if (marker == 0) { MyIDRefs refs = (MyIDRefs)area.getIDReferences(); refs.ConfigureID(id, area); //area.getIDReferences().ConfigureID(id, area); } int spaceLeft = area.spaceLeft(); this.areaContainer = new AreaContainer(propMgr.GetFontState(area.getFontInfo()), 0, 0, area.getContentWidth(), spaceLeft, Position.RELATIVE); areaContainer.foCreator = this; areaContainer.setPage(area.getPage()); areaContainer.setParent(area); areaContainer.setBackground(propMgr.GetBackgroundProps()); areaContainer.start(); areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); areaContainer.setIDReferences(area.getIDReferences()); largestCellHeight = minHeight; bool someCellDidNotLayoutCompletely = false; int offset = 0; int iColIndex = 0; foreach (TableColumn tcol in columns) { TableCell cell; ++iColIndex; int colWidth = tcol.GetColumnWidth(); if (cellArray.GetCellType(iColIndex) == CellArray.CELLSTART) { cell = cellArray.GetCell(iColIndex); } else { if (rowSpanMgr.IsInLastRow(iColIndex)) { int h = rowSpanMgr.GetRemainingHeight(iColIndex); if (h > largestCellHeight) { largestCellHeight = h; } } offset += colWidth; continue; } cell.SetStartOffset(offset); offset += colWidth; int rowSpan = cell.GetNumRowsSpanned(); Status status; if ((status = cell.Layout(areaContainer)).isIncomplete()) { if ((keepTogether.GetKeepType() == KeepValue.KEEP_WITH_ALWAYS) || (status.getCode() == Status.AREA_FULL_NONE) || rowSpan > 1) { this.ResetMarker(); this.RemoveID(area.getIDReferences()); return(new Status(Status.AREA_FULL_NONE)); } else if (status.getCode() == Status.AREA_FULL_SOME) { someCellDidNotLayoutCompletely = true; } } int hi = cell.GetHeight(); if (rowSpan > 1) { rowSpanMgr.AddRowSpan(cell, iColIndex, cell.GetNumColumnsSpanned(), hi, rowSpan); } else if (hi > largestCellHeight) { largestCellHeight = hi; } } area.setMaxHeight(area.getMaxHeight() - spaceLeft + this.areaContainer.getMaxHeight()); for (int iCol = 1; iCol <= columns.Count; iCol++) { if (cellArray.GetCellType(iCol) == CellArray.CELLSTART && rowSpanMgr.IsSpanned(iCol) == false) { cellArray.GetCell(iCol).SetRowHeight(largestCellHeight); } } rowSpanMgr.FinishRow(largestCellHeight); area.addChild(areaContainer); areaContainer.SetHeight(largestCellHeight); areaAdded = true; areaContainer.end(); area.addDisplaySpace(largestCellHeight + areaContainer.getPaddingTop() + areaContainer.getBorderTopWidth() + areaContainer.getPaddingBottom() + areaContainer.getBorderBottomWidth()); if (someCellDidNotLayoutCompletely) { return(new Status(Status.AREA_FULL_SOME)); } else { if (rowSpanMgr.HasUnfinishedSpans()) { return(new Status(Status.KEEP_WITH_NEXT)); } if (breakAfter == BreakAfter.PAGE) { this.marker = MarkerBreakAfter; return(new Status(Status.FORCE_PAGE_BREAK)); } if (breakAfter == BreakAfter.ODD_PAGE) { this.marker = MarkerBreakAfter; return(new Status(Status.FORCE_PAGE_BREAK_ODD)); } if (breakAfter == BreakAfter.EVEN_PAGE) { this.marker = MarkerBreakAfter; return(new Status(Status.FORCE_PAGE_BREAK_EVEN)); } if (breakAfter == BreakAfter.COLUMN) { this.marker = MarkerBreakAfter; return(new Status(Status.FORCE_COLUMN_BREAK)); } if (keepWithNext.GetKeepType() != KeepValue.KEEP_WITH_AUTO) { return(new Status(Status.KEEP_WITH_NEXT)); } return(new Status(Status.OK)); } }