<The previous article in this series | The table of contents of this series | The next article in this series>
To Know How to Handle (Read or Write) LibreOffice or Apache OpenOffice Calc Spread Sheets via Extensions from Java or Macro Programs
As we have set some spread sheet cell format properties, we can also set some format properties to sub strings in the spread sheet cell.
I see.
Again, I'm not interested in enumerating all the format properties; we will talk about only some format properties that seem useful, to us.
OK.
We will handle only these properties.
- font color
- font name
- font size
- font posture
- font weight
- text underline style
- whether text underline color is automatic
- text underline color
- text overline style
- whether text overline color is automatic
- text overline color
- text strikeout style
They are a subset of spread sheet cell format properties. Obviously, sub strings don't have properties like a borderline.
Yes. As names and values to be set are the same with those of spread sheet cell format properties, I won't cite them here.
All right.
We can handle spread sheet cell string format properties using a 'com.sun.star.text.XTextCursor' instance gotten from the cell UNO object.
I see.
The UNO component of the cursor UNO object implements the 'com.sun.star.beans.XPropertySet' UNO interface, and we just get a UNO proxy for the UNO interface and do the same thing as we did with spread sheet cell format properties.
However, actually, I don't know why, but I couldn't successfully set the text underline color.
How you couldn't?
Uncannily.
I'm asking what happens when you try to set a text underline color.
Whatever color I set, the underline becomes white.
While overline colors can be set successfully?
Yes. Only underlines becomes white.
That's uncanny.
As white is usually invisible, for the time being, we will make text underline colors automatic. As we don't have any necessity to color underlines, that won't be a trouble.
OK.
After all, I have written this code after the code of the previous article.
l_textCursor.gotoStart (false);
l_textCursor.goRight ( (short) 1,false);
l_textCursor.goRight ( (short) 2,true);
XPropertySet l_textCursorInXPropertySet = (XPropertySet) UnoRuntime.queryInterface (XPropertySet.class, l_textCursor);
l_textCursorInXPropertySet.setPropertyValue ("CharColor", new Integer ( (new Color (0, 255, 0)).getRGB ()));
l_textCursorInXPropertySet.setPropertyValue ("CharFontName", "Liberation Mono");
l_textCursorInXPropertySet.setPropertyValue ("CharHeight", new Float (16.0F));
l_textCursorInXPropertySet.setPropertyValue ("CharPosture", FontSlant.ITALIC);
l_textCursorInXPropertySet.setPropertyValue ("CharWeight", new Float (FontWeight.BOLD));
l_textCursorInXPropertySet.setPropertyValue ("CharUnderline", new Short (FontUnderline.DOTTED));
l_textCursorInXPropertySet.setPropertyValue ("CharUnderlineHasColor", new Boolean (false));
//l_currentSpreadSheetCellInXPropertySet.setPropertyValue ("CharUnderlineColor", new Integer ( (new Color (0, 0, 255)).getRGB ()));
l_textCursorInXPropertySet.setPropertyValue ("CharOverline", new Short (FontUnderline.BOLDDOTTED));
l_textCursorInXPropertySet.setPropertyValue ("CharOverlineHasColor", new Boolean (true));
l_textCursorInXPropertySet.setPropertyValue ("CharOverlineColor", new Integer ( (new Color (255, 0, 0)).getRGB ()));
l_textCursorInXPropertySet.setPropertyValue ("CharStrikeout", new Short (FontStrikeout.DOUBLE));
All right.
<The previous article in this series | The table of contents of this series | The next article in this series>