def test_Type(self): STRING_TYPE = uno.getTypeByName("string") LONG_TYPE = uno.getTypeByName("long") string_type = uno.Type("string", STRING) long_type = uno.Type("long", LONG) self.assertEqual(STRING_TYPE, STRING_TYPE) self.assertEqual(STRING_TYPE, string_type) self.assertFalse((STRING_TYPE != string_type)) self.assertNotEqual(STRING_TYPE, LONG) self.assertEqual(LONG_TYPE, long_type)
def testStandard(self): self.failUnless(IllegalArgumentException != None, "none-test") self.failUnlessRaises(IllegalArgumentException, self.tobj.raiseException, 1, "foo", self.tobj) self.failUnless( TWO == uno.Enum("test.testtools.bridgetest.TestEnum", "TWO"), "enum") self.failUnless(UNSIGNED_LONG == uno.Enum("com.sun.star.uno.TypeClass", "UNSIGNED_LONG")) self.failUnless(typeOfIllegalArgumentException == uno.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION)) # should not throw an exception e = EventObject() e.Source = self.ctx e = EventObject(self.ctx) e = EventObject(e)
def get_seitenleiste(self): if debug: log(inspect.stack) desk = self.desktop contr = desk.CurrentComponent.CurrentController wins = contr.ComponentWindow.Windows childs = [] from com.sun.star.uno.TypeClass import INTERFACE otype = uno.Type('com.sun.star.awt.XTopWindow2', INTERFACE) for w in wins: if not w.isVisible(): continue if w.AccessibleContext.AccessibleChildCount == 0: continue else: child = w.AccessibleContext.getAccessibleChild(0) if 'Organon: dockable window' == child.AccessibleContext.AccessibleName: continue if otype not in child.Types: continue else: childs.append(child) orga_sb = None if len(childs) == 1: seitenleiste = childs[0] else: seitenleiste = None if seitenleiste: for w in seitenleiste.Windows: try: for w2 in w.Windows: if w2.AccessibleContext.AccessibleDescription == 'Organon': orga_sb = w2 except: pass return orga_sb, seitenleiste
def get_property_value(self, name): entry = self.current target = entry.target inspected = entry.inspected # normal property if entry.has_interface("com.sun.star.beans.XPropertySet"): psinfo = target.getPropertySetInfo() if psinfo and psinfo.hasPropertyByName(name): try: value = target.getPropertyValue(name) temp_type = psinfo.getPropertyByName(name).Type if temp_type is None: temp_type = uno.Type("any", TypeClass.ANY) entry = self.engine.create(self, name, value) idl = entry.type ext_type = ExtType2(entry, self.engine, temp_type.typeName, temp_type.typeClass) entry.type = ext_type entry.code_entry = self.code( type=CGType.PROP ,mode=CGMode.GET, key=name, value_type=entry.type, idl=idl) return self.action_by_type(entry) except Exception as e: self.error("Exception, to get property: %s, %s" % (name, str(e))) traceback.print_exc() if self.mode: return else: raise # pseud property if inspected.hasMethod("get%s" % name, MethodConcept.ALL): return self.call_method("get%s" % name, pseud=True) elif inspected.hasMethod("is%s" % name, MethodConcept.ALL): return self.call_method("is%s" % name, pseud=True) elif inspected.hasMethod("set%s" % name, MethodConcept.ALL): return self.status("Write only pseud property: %s" % name) # interface attributes if inspected.hasProperty(name, PropertyConcept.ATTRIBUTES): psinfo = inspected.getProperty(name, PropertyConcept.ATTRIBUTES) try: value = getattr(target, name) entry = self.engine.create(self, name, value) #temp_type = entry.type #if temp_type.getTypeClass() == TypeClass.SEQUENCE: ext_type = ExtType2(entry, self.engine, psinfo.Type.typeName, psinfo.Type.typeClass) entry.type = ext_type attr_def = self.engine.find_attribute_interface( self.current, name) if attr_def is False: attr_def = "" entry.code_entry = self.code( type=CGType.ATTR, mode=CGMode.GET, key=name, value_type=entry.type, idl=attr_def) return self.action_by_type(entry) except Exception as e: self.error("Exception, to get attribute: %s, %s" % (name, str(e))) traceback.print_exc() if self.mode: return else: raise # XVclWindowPeer if entry.has_interface("com.sun.star.awt.XVclWindowPeer"): try: value = target.getProperty(name) temp_type = inspected.getProperty(name, PropertyConcept.ALL).Type if temp_type is None: temp_type = uno.Type("any", TypeClass.ANY) entry = self.engine.create(self, name, value) # ToDo code return self.action_by_type(entry) except Exception as e: self.error("Exception, to get %s, %s" % (name, str(e))) traceback.print_exc() if self.mode: return else: raise