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

From Apache OpenOffice Wiki
Jump to: navigation, search
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%3F]]
+
[[en:Documentation/DevGuide/FirstSteps/How do I know Which Type I Have?]]
  
{{DISPLAYTITLE:How Do I Know Which Type I Have?}}
+
{{DISPLAYTITLE:如何判断类型?}}
A common problem is deciding what capabilities an object really has, after you receive it from a method.
+
By observing the code completion in Java IDE, you can discover the base interface of an object returned from a method. You will notice that <code>loadComponentFromURL()</code> returns a <idl>com.sun.star.lang.XComponent</idl>.
+
  
By pressing Alt + F1 in the NetBeans IDE you can read specifications about the interfaces and services you are using.
 
  
However, methods can only be specified to return one interface type. The interface you get from a method very often supports more interfaces than the one that is returned by the method (especially when the design of those interfaces predates the availability of multiple-inheritance interface types in UNO). Furthermore, the interface does not tell anything about the properties the object contains.  
+
从方法收到对象后,最常见的问题是确定其真正具有的功能。
 +
通过查看 Java IDE 中的代码自动完成,可以找到从方法返回的对象的基本接口。您会发现
 +
<code>loadComponentFromURL()</code> 返回 <idl>com.sun.star.lang.XComponent</idl>。
 +
在 NetBeans IDE 中,按 Alt + F1 键可以阅读所使用的接口和服务的说明。
 +
但方法只能被指定为返回一个接口类型。从方法获得的接口通常支持多个接口,而不仅仅支持由此
 +
方法返回的那个接口(尤其是在这些接口的设计先于 UNO 中多继承接口类型的可用性时)。而且,
 +
接口不会提供对象含有的属性的任何信息。
 +
因此,应该先通过此手册了解如何进行所需的操作。然后,再使用代码自动完成和 API 引用编写代码。
 +
此外,可以尝试使可 Java 工具 InstanceInspector(它是 {{PRODUCTNAME}} SDK 示例的一部分)。它是可以与
 +
办公软件一起注册的 Java 组件,并可以显示当前正在使用的对象的接口和属性。
 +
在 {{PRODUCTNAME}} Basic 中,可以使用以下 Basic 属性检查对象。
  
Therefore you should uses this manual to get an idea how things work. Then start writing code, using the code completion and the API reference.
 
 
In addition, you can try the InstanceInspector, a Java tool which is part of the {{PRODUCTNAME}} SDK examples. It is a Java component that can be registered with the office and shows interfaces and properties of the object you are currently working with.
 
 
In {{PRODUCTNAME}} Basic, you can inspect objects using the following Basic properties.
 
  
 
   <source lang="vb">
 
   <source lang="vb">
Line 31: Line 33:
 
{{PDL1}}
 
{{PDL1}}
  
[[Category:Documentation/Developers Guide/First Steps]]
+
 
 +
[[Category:中文]]
 +
[[Category:文档]]
 +
[[Category:开发者指南]]
 +
[[Category:准备工作]]

Revision as of 02:04, 5 June 2008



从方法收到对象后,最常见的问题是确定其真正具有的功能。 通过查看 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