ashok _ wrote:
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())
On 7/12/07, Zbigniew Banach <[EMAIL PROTECTED]> wrote:
Hi everyone,
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
taking the ubound of getByIndex is more elegant no ?
you can also use *setAllPropertiesToDefault*(); as a direct change to
the selctect text
hope it helps
Fernand
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.
Cheers,
Zbigniew Banach
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]