Problem with cursor.charStyleName

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
lunter
Posts: 28
Joined: Fri May 29, 2009 9:16 am

Problem with cursor.charStyleName

Post by lunter »

Code: Select all

// php

 $t=$doc->Text;
 $c=$t->createTextCursor();

 $c->charStyleName='red';
 $t->insertString($c,'First paragraph',false);

 $t->insertControlCharacter($c,0,false); // PARAGRAPH_BREAK

 $c->charStyleName='blue';
 $t->insertString($c,'Second paragraph',false);

 $t->insertControlCharacter($c,0,false); // PARAGRAPH_BREAK

// $c->charStyleName=''; <-- error
 $t->insertString($c,'Third paragraph',false);
My first paragraph has red letter color (defined in CharacterStyles.red)
Second paragraph has blue letter color (defined in CharacterStyles.blue)

How to disable cursor charStyleName before writting third paragraph? It is still blue...
OOo 3.3.X on MS Windows 7
User avatar
squenson
Volunteer
Posts: 1885
Joined: Wed Jan 30, 2008 9:21 pm
Location: Lausanne, Switzerland

Re: problem with cursor.charStyleName

Post by squenson »

Just an idea, the default style is called "default" so you may try with this value.
LibreOffice 4.2.3.3. on Ubuntu 14.04
lunter
Posts: 28
Joined: Fri May 29, 2009 9:16 am

Re: problem with cursor.charStyleName

Post by lunter »

$c->charStyleName='Default';
or
$c->charStyleName='default';

returns errors...
OOo 3.3.X on MS Windows 7
j.kornelsn
Posts: 14
Joined: Wed Oct 06, 2010 6:26 am

Re: Problem with cursor.charStyleName

Post by j.kornelsn »

This should work (tested in Python):

Code: Select all

$c->setPropertyToDefault("CharStyleName");
$c->setAllPropertiesToDefault();
LO / AOO on Ubuntu / Windows
Post Reply