[Libreoffice-bugs] [Bug 99125] Property ParaBackColor in Writer can no longer be set via Basic

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Sun May 14 14:03:43 UTC 2017


https://bugs.documentfoundation.org/show_bug.cgi?id=99125

--- Comment #13 from Gerhard Weydt <gerhard.weydt at t-online.de> ---
@Butch: Comment #11 is not by me, but by Tibor Kovacs, and I am sure it would
work the way he proposes. I didn't try to write the code yet, but setting the
color for a style sets the value in ParaBackColor, in contrast with the
paragraph properties, where it is not set.

It should be something like:
dim neu as object
neu = ThisComponent.createInstance("com.sun.star.style.ParagraphStyle")
ThisComponent.StyleFamilies.getByName("ParagraphStyles").insertByName("?newName?",neu)
neu.ParaBackColor = RGB(0, 255, 0)

and you would have to set some other attributes as well. And then you would
have to set ParaStyleName = "?newName?" for the paragraph(s) you want to color.

But there is another way: using the dispatcher (which I normally do not use). I
recorded a macro when setting the background color via the sidebar, and here is
what was created:

rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "BackgroundColor"
args1(0).Value = 52428

dispatcher.executeDispatch(document, ".uno:BackgroundColor", "", 0, args1())

The color 52428 is the internal value, you would probably use the function RGB
to calculate the value.

This does also work für multiple selections, with the exemption that paragraphs
are not changed if the selection element contained in this pargraph has length
zero, unless the entire selection consists only of one string of length zero.

Using the macro recorder, by the way, does not work correctly when setting the
color using the menu: the macro created concerns numbering! That's probably one
of the reasons why macro recording is considered experimental.

Gerhard

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20170514/ab1fec5c/attachment.html>


More information about the Libreoffice-bugs mailing list