[poppler] 2 commits - poppler/StructElement.cc poppler/StructElement.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sat Feb 8 00:15:44 PST 2014


 poppler/StructElement.cc |   33 ++++++++++++++++++++-------------
 poppler/StructElement.h  |    1 +
 2 files changed, 21 insertions(+), 13 deletions(-)

New commits:
commit 899799df78c00fc2ca6d2d0e612536b87a871817
Author: Adrian Perez de Castro <aperez at igalia.com>
Date:   Tue Feb 4 19:26:53 2014 +0200

    Allow properly identifying grouping elements
    
    Grouping elements in the Tagged-PDF structure should be identifiable as
    such (see section 14.8.4.2 "Grouping Elements" of the PDF standard). Those
    were previously reported as inline elements, which is quite not correct.
    This patch introduces a new StructElement::isGrouping() method which
    correctly reports grouping elements as such.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=74520

diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
index 558cab4..c3724b8 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -506,6 +506,7 @@ static GBool ownerHasMorePriority(Attribute::Owner a, Attribute::Owner b)
 
 enum ElementType {
   elementTypeUndefined,
+  elementTypeGrouping,
   elementTypeInline,
   elementTypeBlock,
 };
@@ -516,16 +517,16 @@ static const struct TypeMapEntry {
   ElementType               elementType;
   const AttributeMapEntry **attributes;
 } typeMap[] = {
-  { StructElement::Document,   "Document",   elementTypeInline,    attributeMapShared       },
-  { StructElement::Part,       "Part",       elementTypeInline,    attributeMapShared       },
-  { StructElement::Art,        "Art",        elementTypeInline,    attributeMapColumns      },
-  { StructElement::Sect,       "Sect",       elementTypeInline,    attributeMapColumns      },
-  { StructElement::Div,        "Div",        elementTypeInline,    attributeMapColumns      },
-  { StructElement::BlockQuote, "BlockQuote", elementTypeInline,    attributeMapInline       },
-  { StructElement::Caption,    "Caption",    elementTypeInline,    attributeMapInline       },
-  { StructElement::NonStruct,  "NonStruct",  elementTypeInline,    attributeMapInline       },
-  { StructElement::Index,      "Index",      elementTypeInline,    attributeMapInline       },
-  { StructElement::Private,    "Private",    elementTypeInline,    attributeMapInline       },
+  { StructElement::Document,   "Document",   elementTypeGrouping,  attributeMapShared       },
+  { StructElement::Part,       "Part",       elementTypeGrouping,  attributeMapShared       },
+  { StructElement::Art,        "Art",        elementTypeGrouping,  attributeMapColumns      },
+  { StructElement::Sect,       "Sect",       elementTypeGrouping,  attributeMapColumns      },
+  { StructElement::Div,        "Div",        elementTypeGrouping,  attributeMapColumns      },
+  { StructElement::BlockQuote, "BlockQuote", elementTypeGrouping,  attributeMapInline       },
+  { StructElement::Caption,    "Caption",    elementTypeGrouping,  attributeMapInline       },
+  { StructElement::NonStruct,  "NonStruct",  elementTypeGrouping,  attributeMapInline       },
+  { StructElement::Index,      "Index",      elementTypeGrouping,  attributeMapInline       },
+  { StructElement::Private,    "Private",    elementTypeGrouping,  attributeMapInline       },
   { StructElement::Span,       "Span",       elementTypeInline,    attributeMapInline       },
   { StructElement::Quote,      "Quote",      elementTypeInline,    attributeMapInline       },
   { StructElement::Note,       "Note",       elementTypeInline,    attributeMapInline       },
@@ -563,8 +564,8 @@ static const struct TypeMapEntry {
   { StructElement::Figure,     "Figure",     elementTypeUndefined, attributeMapIllustration },
   { StructElement::Formula,    "Formula",    elementTypeUndefined, attributeMapIllustration },
   { StructElement::Form,       "Form",       elementTypeUndefined, attributeMapIllustration },
-  { StructElement::TOC,        "TOC",        elementTypeUndefined, attributeMapShared       },
-  { StructElement::TOCI,       "TOCI",       elementTypeUndefined, attributeMapShared       },
+  { StructElement::TOC,        "TOC",        elementTypeGrouping,  attributeMapShared       },
+  { StructElement::TOCI,       "TOCI",       elementTypeGrouping,  attributeMapShared       },
 };
 
 
@@ -913,6 +914,12 @@ GBool StructElement::isInline() const
   return entry ? (entry->elementType == elementTypeInline) : gFalse;
 }
 
+GBool StructElement::isGrouping() const
+{
+  const TypeMapEntry *entry = getTypeMapEntry(type);
+  return entry ? (entry->elementType == elementTypeGrouping) : gFalse;
+}
+
 GBool StructElement::hasPageRef() const
 {
   return pageRef.isRef() || (parent && parent->hasPageRef());
diff --git a/poppler/StructElement.h b/poppler/StructElement.h
index b9eef8a..7de0082 100644
--- a/poppler/StructElement.h
+++ b/poppler/StructElement.h
@@ -153,6 +153,7 @@ public:
   GBool isOk() const { return type != Unknown; }
   GBool isBlock() const;
   GBool isInline() const;
+  GBool isGrouping() const;
 
   inline GBool isContent() const { return (type == MCID) || isObjectRef(); }
   inline GBool isObjectRef() const { return (type == OBJR && c->ref.num != -1 && c->ref.gen != -1); }
commit 27cd9a00bfebf0602e7ed29a8ee8e16ffff67bde
Author: Adrian Perez de Castro <aperez at igalia.com>
Date:   Tue Feb 4 19:35:58 2014 +0200

    Report LBody elements in Tagged-PDF structure as block elements
    
    According to section 14.8.4.3 "Block-Level Structure Elements"
    (in particular subsection 14.8.4.3.3 "List Elements"), structure
    elements of type LBody must be reported as block elements. This
    patch changes the reported type from elementTypeUndefined to
    elementTypeBlock accordingly.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=74522

diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
index 6392433..558cab4 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -552,7 +552,7 @@ static const struct TypeMapEntry {
   { StructElement::L,          "L",          elementTypeBlock,     attributeMapList         },
   { StructElement::LI,         "LI",         elementTypeBlock,     attributeMapBlock        },
   { StructElement::Lbl,        "Lbl",        elementTypeBlock,     attributeMapBlock        },
-  { StructElement::LBody,      "LBody",      elementTypeUndefined, attributeMapBlock        },
+  { StructElement::LBody,      "LBody",      elementTypeBlock,     attributeMapBlock        },
   { StructElement::Table,      "Table",      elementTypeBlock,     attributeMapTable        },
   { StructElement::TR,         "TR",         elementTypeUndefined, attributeMapShared       },
   { StructElement::TH,         "TH",         elementTypeUndefined, attributeMapTableCell    },


More information about the poppler mailing list