How do I set the locale of the current selection

I’m trying to set the locale of selected text in writer? I can’t use the pick list because the text has a complex text layout, and the locale is not in the pick list. At present the only method I have that works is to edit the underlying XML by hand.

I’ve been told that the key information is in http://api.libreoffice.org/docs/idl/ref/structcom_1_1sun_1_1star_1_1lang_1_1Locale.html , but I can’t work out how to set the fields. My best efforts are:

dim region as object
region = ThisComponent.CurrentSelection.getByIndex(0)
region.Variant  ="khb-CN"
region.Locale.Language ="qlt"

However, neither the object designated by region has neither property Variant nor property Locale, so the code fails with an appropriate error message.

Hi

You can try something like:

dim region as object
dim oLocalSettings As New com.sun.star.lang.Locale

with oLocalSettings
'	.Country = ?'
	.Language = "qlt"
	.Variant = "khb-CN"
end with

region = ThisComponent.CurrentSelection.getByIndex(0)
region.CharLocale = oLocalSettings

As you can see it is possible to also define the country…
Regards

Excellent! Incidentally, if using it for a complex script such as ‘Old Tai Lue’, one uses CharLocaleComplex. I’ve no idea which one should use for New Tai Lue - last month it was a complex script, this month it ceased to be complex.