ashok _ escribió:
I am trying set the SectionLeftMargin property of an XTextSection.... :
xPropSet.setPropertyValue("SectionLeftMargin", new Long(762));
The above raises an IllegalArgumentException...
The section document describes the SectionLeftMargin property as a
"long" datatype..
http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextSection.html#SectionLeftMargin
The following works without raising exceptions :
xPropSet.setPropertyValue("SectionLeftMargin", new Integer(762));
When I view the section properties using XRay, SectionLeftMargin is
indicated as a "long" type again...
so its not the case of the documentation being wrong..
Is this a bug or am I reading the documentation wrong ?
(Java 1.5, Openoffice 2.3.1 , Windows xp... )
this no bug at all, but how the UNO IDL types are mapped to the
different programming languages, see
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/FirstSteps/Common_Types
in the table this is very clear:
UNO Type description Java C++ Basic
long signed 32-bit integer type int sal_Int32 Long
Besides, as setPropertyValue() requireas an any, you must use
java.lang.Integer instead of the primitive type int, as
java.lang.Integer inherits from java.lang.Object, and the UNO IDL any is
mapped to java.lang.Object in the Java bridge, see
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/FirstSteps/Any
"In Java, the any type is mapped to java.lang.Object, but there is also
a special Java class com.sun.star.uno.Any, mainly used in those cases
where a plain Object would be ambiguous. There are two simple rules of
thumb to follow:
When you are supposed to pass in an any value, always pass in a
java.lang.Object or a Java UNO object.
For instance, if you use setPropertyValue() to set a property that has a
non-interface type in the target object, you must pass in a
java.lang.Object for the new value. If the new value is of a primitive
type in Java, use the corresponding Object type for the primitive type:
xCellProps.setPropertyValue("CharWeight", new Double(200.0));"
Reagrds
Ariel.
--
Ariel Constenla-Haile
La Plata, Argentina
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.ArielConstenlaHaile.com.ar/ooo/
"Aus der Kriegsschule des Lebens
- Was mich nicht umbringt,
macht mich härter."
Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]