corinthia-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Kelly <pmke...@apache.org>
Subject Attributes (Branch"odf-filter-attempt2" review)
Date Tue, 12 May 2015 06:31:54 GMT
Ok I started writing out a response and it got quite long, so I’m going to split this into
multiple emails to help separate subsequent discussion of particular aspects.

printNode:

The attrs field of the DFNode struct is an array, not a single object. It contains attrsCount
elements. Accessing it in the way that printNode does is incorrect for two reasons:

1) The fact that attrs is non-NULL doesn’t necessarily mean that the node has attributes.
It’s possible that it did at one point have attributes, but those were all removed. In such
a case, attrsCount will be zero, but attrs will still be non-NULL. Have a look at the implementation
of DFGetAttribute, DFSetAttribute, DFRemoveAttribute in DFDOM.c to see how attrs, attrsCount,
and attrsAlloc are used.

2) If there are multiple attributes, this will only print the first.

To go through all the attributes and print out their tags & values, you would use a loop:

    for (int i = 0; i < n->attrsCount; i++) {
        printf("tag %u value %s\n",n->attrs[i].tag,n->attrs[i].value);
    }

You can also use DFGetAttribute if you want to already know the tag you are looking for (e.g.
TEXT_OUTLINE_LEVEL). This function will return NULL if the attribute does not exist, or the
attribute value if it does.

—
Dr Peter M. Kelly
pmkelly@apache.org

PGP key: http://www.kellypmk.net/pgp-key <http://www.kellypmk.net/pgp-key>
(fingerprint 5435 6718 59F0 DD1F BFA0 5E46 2523 BAA1 44AE 2966)

> On 10 May 2015, at 8:52 am, Gabriela Gibson <gabriela.gibson@gmail.com> wrote:
> 
> Hi,
> 
> So far I got my branch to produce a list of html nodes (and report on
> still missing stuff).
> 
> This is probably a good point to have a look if the approach I'm using
> here is any good.
> 
> It of course has quite a few warts still, and I think I will need to
> add function pointers to the ODF_to_HTML_key struct to deal with some
> special cases.  If that struct is a good idea that is.
> 
> The branch can be found here:
> 
> https://github.com/apache/incubator-corinthia/commit/c81e68626489b9515e7e8f3a5ce5d38ac8f59af0
> 
> I added the test odt file I was using, plus the current output of the program.
> 
> thanks for looking,
> 
> G
> 
> -- 
> Visit my Coding Diary: http://gabriela-gibson.blogspot.com/


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message