private void _CombinePass() { if (_fixedSOMPage.SemanticBoxes.Count < 2) { //Nothing to do return; } int prevBoxCount; do { prevBoxCount = _fixedSOMPage.SemanticBoxes.Count; List <FixedSOMSemanticBox> boxes = _fixedSOMPage.SemanticBoxes; for (int i = 0; i < boxes.Count; i++) { FixedSOMTable table1 = boxes[i] as FixedSOMTable; if (table1 != null) { //Check for nested tables for (int j = i + 1; j < boxes.Count; j++) { FixedSOMTable table2 = boxes[j] as FixedSOMTable; if (table2 != null && table1.AddContainer(table2)) { boxes.Remove(table2); } } continue; } FixedSOMFixedBlock box1 = boxes[i] as FixedSOMFixedBlock; if (box1 == null || box1.IsFloatingImage) { continue; } for (int j = i + 1; j < boxes.Count; j++) { FixedSOMFixedBlock box2 = boxes[j] as FixedSOMFixedBlock; if (box2 != null && !box2.IsFloatingImage && box2.Matrix.Equals(box1.Matrix) && (_IsSpatiallyCombinable(box1, box2, 0, 0))) { { box1.CombineWith(box2); boxes.Remove(box2); } } } } } while (_fixedSOMPage.SemanticBoxes.Count > 1 && _fixedSOMPage.SemanticBoxes.Count != prevBoxCount); }
// Token: 0x06002E2C RID: 11820 RVA: 0x000D0B2C File Offset: 0x000CED2C private bool _AddToInnerTable(FixedSOMContainer container) { foreach (FixedSOMSemanticBox fixedSOMSemanticBox in this._semanticBoxes) { FixedSOMTable fixedSOMTable = fixedSOMSemanticBox as FixedSOMTable; if (fixedSOMTable != null && fixedSOMTable.AddContainer(container)) { return(true); } } return(false); }
// Token: 0x06002E01 RID: 11777 RVA: 0x000CF564 File Offset: 0x000CD764 private void _CombinePass() { if (this._fixedSOMPage.SemanticBoxes.Count < 2) { return; } int count; do { count = this._fixedSOMPage.SemanticBoxes.Count; List <FixedSOMSemanticBox> semanticBoxes = this._fixedSOMPage.SemanticBoxes; for (int i = 0; i < semanticBoxes.Count; i++) { FixedSOMTable fixedSOMTable = semanticBoxes[i] as FixedSOMTable; if (fixedSOMTable != null) { for (int j = i + 1; j < semanticBoxes.Count; j++) { FixedSOMTable fixedSOMTable2 = semanticBoxes[j] as FixedSOMTable; if (fixedSOMTable2 != null && fixedSOMTable.AddContainer(fixedSOMTable2)) { semanticBoxes.Remove(fixedSOMTable2); } } } else { FixedSOMFixedBlock fixedSOMFixedBlock = semanticBoxes[i] as FixedSOMFixedBlock; if (fixedSOMFixedBlock != null && !fixedSOMFixedBlock.IsFloatingImage) { for (int k = i + 1; k < semanticBoxes.Count; k++) { FixedSOMFixedBlock fixedSOMFixedBlock2 = semanticBoxes[k] as FixedSOMFixedBlock; if (fixedSOMFixedBlock2 != null && !fixedSOMFixedBlock2.IsFloatingImage && fixedSOMFixedBlock2.Matrix.Equals(fixedSOMFixedBlock.Matrix) && this._IsSpatiallyCombinable(fixedSOMFixedBlock, fixedSOMFixedBlock2, 0.0, 0.0)) { fixedSOMFixedBlock.CombineWith(fixedSOMFixedBlock2); semanticBoxes.Remove(fixedSOMFixedBlock2); } } } } } }while (this._fixedSOMPage.SemanticBoxes.Count > 1 && this._fixedSOMPage.SemanticBoxes.Count != count); }
private void _FillTables(List <FixedSOMTableRow> tableRows) { List <FixedSOMTable> tables = new List <FixedSOMTable>(); foreach (FixedSOMTableRow row in tableRows) { FixedSOMTable table = null; double fudge = 0.01; foreach (FixedSOMTable t in tables) { if (Math.Abs(t.BoundingRect.Left - row.BoundingRect.Left) < fudge && Math.Abs(t.BoundingRect.Right - row.BoundingRect.Right) < fudge && Math.Abs(t.BoundingRect.Bottom - row.BoundingRect.Top) < fudge) { table = t; break; } } if (table == null) { table = new FixedSOMTable(_fixedSOMPage); tables.Add(table); } table.AddRow(row); } //Check for nested tables first for (int i = 0; i < tables.Count - 1; i++) { for (int j = i + 1; j < tables.Count; j++) { if (tables[i].BoundingRect.Contains(tables[j].BoundingRect) && tables[i].AddContainer(tables[j])) { tables.RemoveAt(j--); } else if (tables[j].BoundingRect.Contains(tables[i].BoundingRect) && tables[j].AddContainer(tables[i])) { tables.RemoveAt(i--); if (i < 0) { break; } } } } foreach (FixedSOMTable table in tables) { if (table.IsSingleCelled) { continue; } bool containsAnything = false; for (int i = 0; i < _fixedSOMPage.SemanticBoxes.Count;) { //Only FixedBlocks are added to tables at this stage if (_fixedSOMPage.SemanticBoxes[i] is FixedSOMFixedBlock && table.AddContainer(_fixedSOMPage.SemanticBoxes[i] as FixedSOMContainer)) { _fixedSOMPage.SemanticBoxes.RemoveAt(i); containsAnything = true; } else { i++; } } if (containsAnything) { table.DeleteEmptyRows(); table.DeleteEmptyColumns(); //Remove any internal empty tables //Do grouping and sorting inside cells foreach (FixedSOMTableRow row in table.SemanticBoxes) { foreach (FixedSOMTableCell cell in row.SemanticBoxes) { for (int i = 0; i < cell.SemanticBoxes.Count;) { FixedSOMTable innerTable = cell.SemanticBoxes[i] as FixedSOMTable; if (innerTable != null && innerTable.IsEmpty) { cell.SemanticBoxes.Remove(innerTable); } else { i++; } } _CreateGroups(cell); cell.SemanticBoxes.Sort(); } } _fixedSOMPage.AddTable(table); } } }
private void _FillTables(List<FixedSOMTableRow> tableRows) { List<FixedSOMTable> tables = new List<FixedSOMTable>(); foreach (FixedSOMTableRow row in tableRows) { FixedSOMTable table = null; double fudge = 0.01; foreach (FixedSOMTable t in tables) { if (Math.Abs(t.BoundingRect.Left - row.BoundingRect.Left) < fudge && Math.Abs(t.BoundingRect.Right - row.BoundingRect.Right) < fudge && Math.Abs(t.BoundingRect.Bottom - row.BoundingRect.Top) < fudge) { table = t; break; } } if (table == null) { table = new FixedSOMTable(_fixedSOMPage); tables.Add(table); } table.AddRow(row); } //Check for nested tables first for (int i=0; i<tables.Count-1; i++) { for (int j=i+1; j<tables.Count; j++) { if (tables[i].BoundingRect.Contains(tables[j].BoundingRect) && tables[i].AddContainer(tables[j])) { tables.RemoveAt(j--); } else if (tables[j].BoundingRect.Contains(tables[i].BoundingRect) && tables[j].AddContainer(tables[i])) { tables.RemoveAt(i--); if (i < 0) { break; } } } } foreach (FixedSOMTable table in tables) { if (table.IsSingleCelled) { continue; } bool containsAnything = false; for (int i = 0; i < _fixedSOMPage.SemanticBoxes.Count;) { //Only FixedBlocks are added to tables at this stage if (_fixedSOMPage.SemanticBoxes[i] is FixedSOMFixedBlock && table.AddContainer(_fixedSOMPage.SemanticBoxes[i] as FixedSOMContainer)) { _fixedSOMPage.SemanticBoxes.RemoveAt(i); containsAnything = true; } else { i++; } } if (containsAnything) { table.DeleteEmptyRows(); table.DeleteEmptyColumns(); //Remove any internal empty tables //Do grouping and sorting inside cells foreach (FixedSOMTableRow row in table.SemanticBoxes) { foreach (FixedSOMTableCell cell in row.SemanticBoxes) { for (int i=0; i<cell.SemanticBoxes.Count;) { FixedSOMTable innerTable = cell.SemanticBoxes[i] as FixedSOMTable; if (innerTable != null && innerTable.IsEmpty) { cell.SemanticBoxes.Remove(innerTable); } else { i++; } } _CreateGroups(cell); cell.SemanticBoxes.Sort(); } } _fixedSOMPage.AddTable(table); } } }
public void AddTable(FixedSOMTable table) { base.Add(table); }
// Token: 0x06002DDF RID: 11743 RVA: 0x000CE42C File Offset: 0x000CC62C public void AddTable(FixedSOMTable table) { base.Add(table); }
// Token: 0x06002E05 RID: 11781 RVA: 0x000CFA4C File Offset: 0x000CDC4C private void _FillTables(List <FixedSOMTableRow> tableRows) { List <FixedSOMTable> list = new List <FixedSOMTable>(); foreach (FixedSOMTableRow fixedSOMTableRow in tableRows) { FixedSOMTable fixedSOMTable = null; double num = 0.01; foreach (FixedSOMTable fixedSOMTable2 in list) { if (Math.Abs(fixedSOMTable2.BoundingRect.Left - fixedSOMTableRow.BoundingRect.Left) < num && Math.Abs(fixedSOMTable2.BoundingRect.Right - fixedSOMTableRow.BoundingRect.Right) < num && Math.Abs(fixedSOMTable2.BoundingRect.Bottom - fixedSOMTableRow.BoundingRect.Top) < num) { fixedSOMTable = fixedSOMTable2; break; } } if (fixedSOMTable == null) { fixedSOMTable = new FixedSOMTable(this._fixedSOMPage); list.Add(fixedSOMTable); } fixedSOMTable.AddRow(fixedSOMTableRow); } for (int i = 0; i < list.Count - 1; i++) { for (int j = i + 1; j < list.Count; j++) { if (list[i].BoundingRect.Contains(list[j].BoundingRect) && list[i].AddContainer(list[j])) { list.RemoveAt(j--); } else if (list[j].BoundingRect.Contains(list[i].BoundingRect) && list[j].AddContainer(list[i])) { list.RemoveAt(i--); if (i < 0) { break; } } } } foreach (FixedSOMTable fixedSOMTable3 in list) { if (!fixedSOMTable3.IsSingleCelled) { bool flag = false; int k = 0; while (k < this._fixedSOMPage.SemanticBoxes.Count) { if (this._fixedSOMPage.SemanticBoxes[k] is FixedSOMFixedBlock && fixedSOMTable3.AddContainer(this._fixedSOMPage.SemanticBoxes[k] as FixedSOMContainer)) { this._fixedSOMPage.SemanticBoxes.RemoveAt(k); flag = true; } else { k++; } } if (flag) { fixedSOMTable3.DeleteEmptyRows(); fixedSOMTable3.DeleteEmptyColumns(); foreach (FixedSOMSemanticBox fixedSOMSemanticBox in fixedSOMTable3.SemanticBoxes) { FixedSOMTableRow fixedSOMTableRow2 = (FixedSOMTableRow)fixedSOMSemanticBox; foreach (FixedSOMSemanticBox fixedSOMSemanticBox2 in fixedSOMTableRow2.SemanticBoxes) { FixedSOMTableCell fixedSOMTableCell = (FixedSOMTableCell)fixedSOMSemanticBox2; int l = 0; while (l < fixedSOMTableCell.SemanticBoxes.Count) { FixedSOMTable fixedSOMTable4 = fixedSOMTableCell.SemanticBoxes[l] as FixedSOMTable; if (fixedSOMTable4 != null && fixedSOMTable4.IsEmpty) { fixedSOMTableCell.SemanticBoxes.Remove(fixedSOMTable4); } else { l++; } } this._CreateGroups(fixedSOMTableCell); fixedSOMTableCell.SemanticBoxes.Sort(); } } this._fixedSOMPage.AddTable(fixedSOMTable3); } } } }