> Have you thought of using the DispatchHelper api ?
> 
> Something like (in basic):
> 
> dim args(1) as new com.sun.star.beans.PropertyValue
> args(0).Name = "Template"
> args(0).Value = "Default"
> args(1).Name = "Family"
> args(1).Value = 2
> 
> dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args())

Thanks for the suggestion, but after a quick test it seems to me that
the style name supplied here (in this case as args(0).Value) still has
to be the style name from the UI, which for the default style gets
localized (and thus setting "Default" would only work in an
English-based locale). This is the exact same problem I'm having with
TextCursor.CharStyleName, so it seems using the dispatch won't help.
Other suggestions most welcome :)

Cheers,

Zbigniew Banach

>> I'm trying to reset the character style in a piece of Writer document
>> text to default from the API (using a Python macro). To illustrate, I've
>> got a com.sun.star.text.TextCursor full of selected text with the
>> character style 'foo' (set earlier via TextCursor.CharStyleName) and I
>> need to reset the selected text character style to default . I've been
>> trying to crack this for a looong while now, but with no luck, so I
>> guess I need professional help now :)
>>
>> The Reference says (section 8.4.1): "The office comes with a set of
>> default styles. These styles use programmatic names on the API level.
>> (...) Additionally the built-in styles have two different names: a true
>> object name and an alias that is displayed at the user interface. This
>> is not usually visible in an English OpenOffice.org version, except for
>> the default styles that are named "Standard" as programmatic name and
>> "Default" in the user interface."
>>
>> This explains why the CharStyleName property cannot be used to directly
>> set the default style (it only has the localized UI name). Elsewhere
>> (can't remember where), I found the information that the "default" isn't
>> a proper style, but a feature that simply clears all formatting and
>> styles from the text. So how can I access it from the API? AFAIK
>> TextCursor's only property/method related to character styles is
>> CharStyleName, which in this case is useless.
>>
>> Googling around I've found others had this problem, but I found no
>> answers. So far I'm relying on a hack based on the observation that the
>> default style is always (?) last in the style list accessible via
>> document.getStyleFamilies().getByName("CharacterStyles"), but it's
>> hardly elegant and seems asking for trouble.
>>
>> I'd appreciate any help or ideas, as I've been going in circles on this
>> for the last few months.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to