You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openoffice.apache.org by Winfried Rohr <wi...@gmail.com> on 2015/07/09 18:34:29 UTC

[api] WrappedTargetException accessing modules in Basic libraries

Hi, 

I'm writing a Python script, trying to access all Basic modules from files 
in a directory. 
In most cases I get a WrappedTargetException accessing the module(s) from a 
Basic library [line: txt = one_lib.getByName(m)] ... approx. 30% of modules 
are retrieved and printed.

"xdoc" is reference to a Writer/Calc document, opened hidden within a 
function and returned from there, if this matters.

What's wrong?
[code]
        if xdoc:
            log.debug('have document')
            libs = xdoc.BasicLibraries
        else:
            log.debug('no libs found')
            libs = None

        if libs and libs.hasElements():
            insert_text(text, cursor, 'Heading 2', name)

            for lib in libs.ElementNames:
                one_lib = libs.getByName(lib)

                if one_lib.hasElements():
                    for m in one_lib.ElementNames:
                        try:
                            insert_text(text, cursor, stylename='Heading 3', 
s=m)
                            txt = one_lib.getByName(m)
                            insert_text(text, cursor, s=txt)
                        except WrappedTargetException:
                            insert_text(text, cursor, s='FEHLER BEIM LESEN')
[/code]


TIA
Winfried


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@openoffice.apache.org
For additional commands, e-mail: dev-help@openoffice.apache.org