Difference between revisions of "ObjectInspectorComparison"
SergeMoutou (Talk | contribs) m (→Conclusion) |
SergeMoutou (Talk | contribs) m (→OOoBasic generation) |
||
Line 1: | Line 1: | ||
= OOoBasic generation = | = OOoBasic generation = | ||
− | I want to generate OOoBasic code for the example showed [[ | + | I want to generate OOoBasic code for the example showed below : obtaining the selected text from a writer document. Here is a screenshot: |
+ | |||
+ | [[Image:ch7Inspector5.png]] | ||
+ | |||
+ | and compare the old Object Inspector with the new one. | ||
== Object Inspector 1.0 == | == Object Inspector 1.0 == | ||
− | The old Object Inspector was very easy to use (for me Inspector.oxt 103,7ko). You never have to "invoke" if you want, only to develop the IDL-tree branchs (more on IDL-tree definition [[Programming_OOoWriter#Java_Inspector_1.0|here]]). | + | The old Object Inspector was very easy to use (for me Inspector.oxt 103,7ko). You never have to "invoke" if you want, only to develop the IDL-tree branchs (more on IDL-tree definition [[Programming_OOoWriter#Java_Inspector_1.0|here]]). Here is a screenshot of part of IDL-tree: |
+ | |||
+ | [[Image:ch7Inspector4.png|The New Object Inspector (Java)]] | ||
+ | |||
+ | Starting from the developped branchs of the tree, this Object Inspector was also able to generate this code : | ||
<source lang="OOBas"> | <source lang="OOBas"> |
Revision as of 15:20, 11 February 2009
OOoBasic generation
I want to generate OOoBasic code for the example showed below : obtaining the selected text from a writer document. Here is a screenshot:
and compare the old Object Inspector with the new one.
Object Inspector 1.0
The old Object Inspector was very easy to use (for me Inspector.oxt 103,7ko). You never have to "invoke" if you want, only to develop the IDL-tree branchs (more on IDL-tree definition here). Here is a screenshot of part of IDL-tree:
Starting from the developped branchs of the tree, this Object Inspector was also able to generate this code :
Sub Main(_oUnoEntryObject as Object) Dim xController as Object xController = _oUnoEntryObject.getCurrentController() Dim oSelection as Object oSelection = xController.getSelection() Dim oIndex as Object oIndex = oSelection.getByIndex(0) Dim sString as String sString = oIndex.getString() End Sub
where you see a kind of Sub (which I personally wouldn't name Main) with a parameter. If you call this Sub with ThisComponent as argument, it works properly, perhaps with adding a print sString to see the corresponding result in a message Box. For Instance :
Sub Main Main2(ThisComponent) end Sub Sub Main2(_oUnoEntryObject as Object) Dim xController as Object xController = _oUnoEntryObject.getCurrentController() Dim oSelection as Object oSelection = xController.getSelection() Dim oIndex as Object oIndex = oSelection.getByIndex(0) Dim sString as String sString = oIndex.getString() print sString End Sub
works for me very well, only with a very little modification if you compare it with the automatic generated code of the first listing.
Object Inspector 2.0
Using this Object Inspector 2.0 (Inspector.oxt 318,5 ko) is less intuitive for me, than the previous one. It's impossible to walk through the IDL tree in one tab. It shows you the result of a method but you have to "invoke" this method to walk trough the complete IDL-Tree and sometimes it doesn't work : for me the getByIndex doesn't work. The problem of invoking is, you create a new tab and when generating the code you have to generate the code in every tab. And you have then also great modifications to do with hand.
I want to resolve the same problem with this new Object Inspector. First a tab ("Sans nom 1") is automaticaly created and it stops with method getCurrentController : Inspector shows me that the Returned type is : com.sun.star.uno.XInterface but cut the branch here : unable to go further. If you want to go further you have to "invoke" the corresponding method wich gives you a new tab : "getCurrentController result". And so on...
If you ask to generate code, the fist tab "Sans nom 1" generates :
REM This program stub was automatically created by the REM OpenOffice.org Object Inspector Extension. REM See http://api.openoffice.org/ for more information. Sub Main doc = StarDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, Array()) retvalgetCurrentController = doc.getCurrentController() End Sub
instead of what I expected :
Sub Main doc = ThisComponent retvalgetCurrentController = doc.getCurrentController() End Sub
Object Inspector 1.0 was also unable to see I was working with current document. Template:Documentation/Note
In tab "getCurrentController result" I walk through the tree with
methods -> getSelection -> "Invoke"
which gives me a new tab "getSelection Result".
The corresponding OOoBasic code automatically generated is (in "getCurrentController result" tab) :
REM This program stub was automatically created by the REM OpenOffice.org Object Inspector Extension. REM See http://api.openoffice.org/ for more information. Sub Main doc = StarDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, Array()) retvalgetSelection = doc.getSelection() End Sub
This is a wrong code because doc.getSelection() doesn't exist !!!! Object Inspector is unable to memory what was previously done in a previous tab.
As shown the first problem comes early : you have to replace doc by retvalgetCurrentController and insert a line between both to give with copy and paste with both program.
REM This program stub was automatically created by the REM OpenOffice.org Object Inspector Extension. REM See http://api.openoffice.org/ for more information. Sub Main 'doc = StarDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, Array()) doc=ThisComponent retvalgetCurrentController = doc.getCurrentController() retvalgetSelection = retvalgetCurrentController.getSelection() End Sub
In the previous version variables where automatically declared.
Conclusion
Although enlargement in size (from 103,7ko to 318,5ko) I will wait a new version and use the previous version.
Have the old Object Inspector to hand.
SergeMoutou 15:14, 11 February 2009 (UTC)