Difference between revisions of "Porting notes"
From Apache OpenOffice Wiki
Line 11: | Line 11: | ||
=== Hints for porting idl === | === Hints for porting idl === | ||
− | ==== | + | ==== Objects with Default Properties ==== |
− | ==== | + | This is something not handled by the helperapi but something you should be aware of when implementing a vba compatibility object. What is a default property, an example probably explains the concept better. |
+ | |||
+ | Range("a1") = "text" | ||
+ | |||
+ | is a short cut for | ||
+ | |||
+ | Range("a1").Value = "text" | ||
+ | |||
+ | <tt>Value</tt> is a default property in the example above. We can provide similar behavior in basic with a compatibility api object ensuring the object implements [http://api.openoffice.org/source/browse/*checkout*/api/udkapi/com/sun/star/script/XDefaultProperty.idl XDefaultProperty.idl ] | ||
+ | |||
+ | ==== Objects with Default Method ==== | ||
+ | |||
+ | Similar to above some vba objects have a default method e.g. the <tt>Collection</tt> object | ||
+ | |||
+ | set col = Sheets | ||
+ | msgbox col(1).Name | ||
+ | |||
+ | is a short cut for | ||
+ | |||
+ | set col = Sheets | ||
+ | msgbox col.Item(1).Name | ||
+ | |||
+ | <tt>Item</tt> is a default method in the example above. We can provide similar behavior in basic with a compatibility api object ensuring the object implements [http://api.openoffice.org/source/browse/*checkout*/api/udkapi/com/sun/star/script/XDefaultMethod.idl XDefaultMethod.idl ] | ||
+ | |||
==== Porting Collection objects ==== | ==== Porting Collection objects ==== |
Revision as of 22:25, 25 February 2007
Things to watch out for
- The mapping of the vba constants is different. Take for example the xlGuess constant, in VBA it's fully qualified name is Excel.XlYesNoGuess.xlGuess, in the helperapi it's com.sun.star.helper.constant.XlYesNoGuess.xlGuess and in oovbaapi it's org.openoffice.excel.XlYesNoGuess.xlGuess
- All objects in the helperapi extend HelperInterfaceAdaptor, nothing similar (yet) exists in oovbaapi so this can be ignored in the implementation
- There are a quite few helper classes in the helperapi project e.g. RangeHelper.java they shouldn't be confused with the actual implementation objects we wish to port.
- classes and idl files of the same name can exist in multiple namespaces and this can be confusing. Because the helperapi was written with both the word and excel api(s) in mind there can be classes that share a common implementation and interfaces e.g.
- com/sun/star/helper/calc/XShape.idl
- com/sun/star/helper/common/XShape.idl
- com/sun/star/helper/writer/XShape.idl
- Collections, these are handled differently see implementing a vba Collection in oovbaapi
- Every helperapi idl method defines BasicErrorException which allows and api method to transfer an error code and associated string paramater to basic.
Hints for porting idl
Objects with Default Properties
This is something not handled by the helperapi but something you should be aware of when implementing a vba compatibility object. What is a default property, an example probably explains the concept better.
Range("a1") = "text"
is a short cut for
Range("a1").Value = "text"
Value is a default property in the example above. We can provide similar behavior in basic with a compatibility api object ensuring the object implements XDefaultProperty.idl
Objects with Default Method
Similar to above some vba objects have a default method e.g. the Collection object
set col = Sheets msgbox col(1).Name
is a short cut for
set col = Sheets msgbox col.Item(1).Name
Item is a default method in the example above. We can provide similar behavior in basic with a compatibility api object ensuring the object implements XDefaultMethod.idl