Fixed minor bug in Properties
[openoffice-python:openoffice-python.git] / openoffice / __init__.py
1 # -*- mode: python ; coding: utf-8 -*-
2 #
3 # Copyright (c) 2008 by Hartmut Goebel <h.goebel@goebel-consult.de>
4 # Licenced under the GNU General Public License v3 (GPLv3)
5 # see file LICENSE-gpl-3.0.txt
6 #
7
8 __author__ = "Hartmut Goebel <h.goebel@goebel-consult.de>"
9 __copyright__ = "Copyright (c) 2008 by Hartmut Goebel <h.goebel@goebel-consult.de>"
10 __licence__ = "GPLv3 - GNU General Public License v3"
11
12 import uno
13 from com.sun.star.beans import PropertyValue
14
15 def iter(elems, prefix=''):
16     # todo: getByIndex verwenden??
17     if hasattr(elems, 'createEnumeration'):
18         enumerator = elems.createEnumeration()
19         while enumerator.hasMoreElements():
20             yield enumerator.nextElement()
21     else:
22         for name in elems.ElementNames:
23             if name.startswith(prefix):
24                 yield elems.getByName(name)
25
26 def Properties(**kw):
27     return  [PropertyValue(k, 0, v,0)
28              for k,v in kw.iteritems()]