I have a XTextField object that I want to set some text style to. I tried
querying UNO on this object for XTextContext, but that fails with an
underfined property name. I then tried setting the property right on the
XTextField object, but that fails too. Here is the code I'm playing with:
XComponent xComp;
Hashtable textFields;
// FileManager is my own static class for loading OOo files
PropertyValue[] loadProps =
FileManager.createPropertyValueArray(FileManager.createPropertyValue("AsTemplate",
new Any(Type.BOOLEAN, Boolean.TRUE)),
FileManager.createPropertyValue("Hidden", new Any(Type.BOOLEAN,
Boolean.FALSE)));
xComp = FileManager.componentImport("C:/myfile.ott", loadProps);
if (xComp == null) {
System.out.println("xComp is null");
return;
}
XTextDocument xtextdoc = (XTextDocument)
UnoRuntime.queryInterface(XTextDocument.class, xComp);
XTextFieldsSupplier supplier = (XTextFieldsSupplier)
UnoRuntime.queryInterface(XTextFieldsSupplier.class, xtextdoc);
XEnumerationAccess enumAccess = supplier.getTextFields();
XEnumeration xEnum = enumAccess.createEnumeration();
textFields = new Hashtable();
while (xEnum.hasMoreElements()) {
Object o = xEnum.nextElement();
XTextField text = (XTextField)
UnoRuntime.queryInterface(XTextField.class, o);
XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, text);
XServiceInfo xServiceInfo = (XServiceInfo)
UnoRuntime.queryInterface(
XServiceInfo.class, text);
if
(xServiceInfo.supportsService("com.sun.star.text.TextField.Input")) {
textFields.put((String)
xPropertySet.getPropertyValue("Hint"), text);
}
}
Object o = textFields.get("INSADD0");
XTextField text = (XTextField)
UnoRuntime.queryInterface(XTextField.class, o);
XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, text);
xPropertySet.setPropertyValue("Content", "This is a test");
XTextContent xContent = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, text);
XPropertySet textprops = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xContent );
textprops.setPropertyValue("*CharUnderline*", Any(Type.SHORT,
new Short(1)););
com.sun.star.beans.UnknownPropertyException: Unknown property: *
CharUnderline*
This is the list of style properties I have:
"CharFontName"
"CharFontStyleName"
"CharFontFamily"
"CharFontCharSet"
"CharFontPitch"
"CharColor"
"CharEscapement"
"CharHeight"
"CharUnderline"
"CharWeight"
"CharPosture"
"CharAutoKerning"
"CharBackColor"
"CharBackTransparent"
"CharCaseMap"
"CharCrossedOut"
"CharFlash"
"CharStrikeout"
"CharWordMode"
"CharKerning"
"CharLocale"
"CharKeepTogether"
"CharNoLineBreak"
"CharShadowed"
"CharFontType"
"CharStyleName"
"CharContoured"
"CharCombineIsOn"
"CharCombinePrefix"
"CharCombineSuffix"
"CharEmphasis"
"CharRelief"
"RubyText"
"RubyAdjust"
"RubyCharStyleName"
"RubyIsAbove"
"CharRotation"
"CharRotationIsFitToLine"
"CharScaleWidth"
"HyperLinkURL"
"HyperLinkTarget"
"HyperLinkName"
"VisitedCharStyleName"
"UnvisitedCharStyleName"
"CharEscapementHeight"
"CharNoHyphenation"
"CharUnderlineColor"
"CharUnderlineHasColor"
"CharStyleNames"
"CharHidden"
"TextUserDefinedAttributes"
--
Government big enough to supply everything...is big enough to take
everything you have. The course of history shows that as a government grows,
liberty decreases --- Thomas Jefferson
www.CampaignForLiberty.org