Difference between revisions of "Zh/Documentation/DevGuide/FirstSteps/How do I know Which Type I Have?"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m
 
Line 4: Line 4:
 
|NextPage=Zh/Documentation/DevGuide/FirstSteps/Example: Hello Text, Hello Table, Hello Shape
 
|NextPage=Zh/Documentation/DevGuide/FirstSteps/Example: Hello Text, Hello Table, Hello Shape
 
}}
 
}}
[[en:Documentation/DevGuide/FirstSteps/How do I know Which Type I Have?]]
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/FirstSteps/{{SUBPAGENAME}}}}
  
 
{{DISPLAYTITLE:如何判断类型?}}
 
{{DISPLAYTITLE:如何判断类型?}}

Latest revision as of 01:51, 14 May 2009




从方法收到对象后,最常见的问题是确定其真正具有的功能。 通过查看 Java IDE 中的代码自动完成,可以找到从方法返回的对象的基本接口。您会发现 loadComponentFromURL() 返回 com.sun.star.lang.XComponent


在 NetBeans IDE 中,按 Alt + F1 键可以阅读所使用的接口和服务的说明。


但方法只能被指定为返回一个接口类型。从方法获得的接口通常支持多个接口,而不仅仅支持由此 方法返回的那个接口(尤其是在这些接口的设计先于 UNO 中多继承接口类型的可用性时)。而且, 接口不会提供对象含有的属性的任何信息。


因此,应该先通过此手册了解如何进行所需的操作。然后,再使用代码自动完成和 API 引用编写代码。 此外,可以尝试使可 Java 工具 InstanceInspector(它是 OpenOffice.org SDK 示例的一部分)。它是可以与办公软件一起注册的 Java 组件,并可以显示当前正在使用的对象的接口和属性。 在 OpenOffice.org Basic 中,可以使用以下 Basic 属性检查对象。

  sub main
    oDocument = thiscomponent
    msgBox(oDocument.dbg_methods)
    msgBox(oDocument.dbg_properties)
    msgBox(oDocument.dbg_supportedInterfaces)
  end sub
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages