How to set Writer Paragraph Gradient Transparency using macro?

Does anyone have code on how to set a paragraph background to gradient transparency.

I am looking to replicate the dialog behaviour in a macro (python).
2023-02-08_13-56-58

This is a sample of the result I am looking to acheive.
2023-02-08_13-53-33

I have successfully done this For a Shape in Draw, I can even add a shape to a Writer doc and apply the gradient transparency. But, when it comes to a paragraph I can not get it to work.
I have now spent a day on this issue and would greatly appreciate any help.

I have been able to replicate every tab behaviour in the Paragrah dialog (for ODEV project) except for Transparency Gradient.

Just a tip:

Create a template (manually), create the desired paragraph styles with gradient color background (manualy) inside; and apply the existing style by macro - if it is necessary.

Thanks for the suggestion.

I am building out a framework. So I am looking to create formmating classes for direct formating of objects, applying styles to objects and finally modifying of styles.

For direct formatting in Writer I have everything except for the Paragraph Gradient Transparency.

Did you try FillTransparenceGradient property of FillProperties Service?

Short answer yes.

Like I mentioned above. I have it working for Draw and Shapes inserted into Writer. Just not paragraphs.

The overall class structure is complex but see gradient.py for the version that works with Draw and Impress and Shapes in general.

I have found that settting paragraph values requires setting of extra properties in many cases.

As usual in such cases, I believe that the easiest would be for you to debug. It is open source, after all :wink:

What happens in case of dialog is inside SwTextShell::Execute for SID_PARA_DLG; interestingly, when the result set contains an unnamed XFillGradientItem, it adds another XFillGradientItem; finally, sw_ParagraphDialogResult is called, which does all the actual work in SwEditShell::SetAttrSet (you would need to debug further to see where the gradient bits finally get applied).

And compare with what happens in SwXParagraph::setPropertyValue. I hope it would allow to see the difference, find what else is needed, and maybe you’ll find some bugs.

I just finished testing applying Paragraph background gradient transparency to a Paragraph Style. It works when applied to a style; However, No mater what I try it is not working to apply directly to a paragraph.

1 Like

Test it, it set some gradient at position of Visible Cursor.

Sub paragraphGradient
	dim oDoc as object, oVCur as object
	oDoc=ThisComponent
	oVCur=oDoc.CurrentController.ViewCursor
	dim gradient as new com.sun.star.awt.Gradient
	with gradient
		.Angle=0
		.Border=15
		.EndColor=RGB(255,0,0)
		.EndIntensity=100
		.StartIntensity=100
		.StepCount=0
		.Style=com.sun.star.awt.GradientStyle.RADIAL
		.XOffset=50
		.YOffset=50
		.StartColor=RGB(0,0,255)
	end with
	with oVCur.TextParagraph
		.FillStyle=com.sun.star.drawing.FillStyle.GRADIENT
		.FillGradient=gradient
	end with
End Sub

Good example of setting a gradient color; Howerver, I am looking to set the Paragraph (or cursor) Background Transparency Gradient (FillTransparence property). As Mentioned above.

I already have Gradient fill working (see code, test).

Also I can successfuly set the Background gradient transparency of a shape (see test). Just not a paragraph.