Skip to content

Commit

Permalink
#79 - Reduce the output of unneeded structure elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
danfickle committed Feb 6, 2019
1 parent d46f4d4 commit bbd7867
Showing 1 changed file with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,13 @@ private void finishTreeItem(AbstractTreeItem item, AbstractStructualElement pare
return;
}

if (child.box instanceof LineBox &&
!child.box.hasNonTextContent(_ctx)) {
// We skip line boxes in the tree.
if (child.box instanceof LineBox ||
(child.box instanceof InlineLayoutBox &&
child.children.size() == 1 &&
child.box.getParent() instanceof LineBox)) {
// We skip (don't create structure element) line boxes in the tree.
// We also skip the common case of a intermediary InlineLayoutBox between the
// LineBox and a single InlineText.
finishTreeItems(child.children, parent);
} else {
createPdfStrucureElement(parent, child);
Expand Down Expand Up @@ -841,22 +845,8 @@ public Token startStructure(StructureType type, Box box) {
switch (type) {
case LAYER:
case FLOAT:
case BLOCK: {
AbstractStructualElement struct = (AbstractStructualElement) box.getAccessibilityObject();
if (struct == null) {
struct = createStructureItem(type, box);
setupStructureElement(struct, box);
}
return FALSE_TOKEN;
}
case INLINE: {
AbstractStructualElement struct = (AbstractStructualElement) box.getAccessibilityObject();
if (struct == null) {
struct = createStructureItem(type, box);
setupStructureElement(struct, box);
}
return FALSE_TOKEN;
}
case BLOCK:
case INLINE:
case INLINE_CHILD_BOX: {
AbstractStructualElement struct = (AbstractStructualElement) box.getAccessibilityObject();
if (struct == null) {
Expand Down

0 comments on commit bbd7867

Please sign in to comment.