Thank you all for your replies. My last question never got answered (the one about re-selecting a multi selection), so I guess I should ask it again in a new thread and also do more experiments on my own.
Johnny Andersson 2007/4/17, Mathias Bauer <[EMAIL PROTECTED]>:
Johnny Andersson wrote: > In your example you go for an object directly: > ThisComponent.CurrentSelection(0). > In my example I do like this to obtain the same (?) thing: > ThisComponent.getCurrentSelection().getByIndex(0) Simplified explanation: in Basic this is the same. In fact the first variant is automatically "translated" into the second one internally as the "real" C++ objects only understand that one. > My thought was something like "since there is a method, it is probably > supposed to be used". That's not like Basic developers want to have it. :-) So we added the "syntactic sugar" to our Basic to meet expectations. > On the other hand, if ThisComponent.CurrentSelection(0) is possible to do, > that object is obviously not private, so I should feel free to use it. *Every* object is private in UNO based development. There is no way to access any data of a UNO object directly, not in Basic and not in any other programming language. "Private" doesn't mean "not accessible". It means that you can access the bits of it of directly, only its interface. This is the basic building principle of UNO and there is no way to circumvent it. So an object TheObject might contain another object TheSubObject. In UNO API it might expose this object by offering the method getTheSubObject() or even allow to overwrite this object with another instance by offering the method setTheSubObject(). Basic analyses the API of the UNO object at runtime and every time when it finds a "getSomething()" method in it it simulates a "property" type member of the Basic object representing the UNO object. If it also finds a "setSomething()" method it allows to assign an instance to it otherwise the "property" is read-only. So in my example you can write "TheObject.TheSubObject.doSomething()" if "TheObject" has this "getTheSubObject" method and the returned object has a method "doSomething". > Which is the "proper" way to do things? Is the rule that "if a variable or > an object is private, use their methods, otherwise manipulate them > directly"? As I said, you can't manipulate any UNO object directly, whatever syntax you use. You always use its UNO interface, with "sugar" in Basic or without in C++ or Java. In Basic you should take the simpler syntax to improve the readability of your code but that's a matter of taste. Ciao, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't reply to "[EMAIL PROTECTED]". I use it for the OOo lists and only rarely read other mails sent to it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
