by wschofield » Sun Jun 12, 2016 2:39 am
Either I am doing it wrong or this is still a bug. I am attempting to start with a Text element and climb up to the ContentAccessor of the Paragraph that contains it. It seems like a reasonable plan but getting the parent object of the Text element returns another Text element it seems. The method I am using is below. I call it with a Text element and it is written to recurse up the tree till it finds what I'm looking for.
- Code: Select all
private List<Object> getContentList(Object o)
{
List<Object> content = null;
Object p = null;
if (o instanceof Text)
{
p = ((Text) o).getParent();
}
else if (o instanceof R)
{
p = ((R) o).getParent();
}
else if (o instanceof P)
{
p = ((P) o).getParent();
}
else if (o instanceof Body)
{
p = o; // at the top
}
boolean contentHolder = (p instanceof ContentAccessor && !(o instanceof P));
if (!contentHolder)
{
if (p != null)
content = getContentList(p);
}
else
{
content = ((ContentAccessor) p).getContent();
}
return content;
}