Set field master content for expression fields

I substitute data in the writer document via field master. If I use com.sun.star.text.fieldmaster.User fields I set Content property for field masters, call XRefreshable.refresh() from document as it provided in “Fields in a Template” example from developer guide.

If I create fields with com.sun.star.text.fieldmaster.SetExpression to use with hidden paragraph their field master doesn’t contains Content property. How should I change value of these fields and refresh document?

Example template: https://ask.libreoffice.org/upfiles/1592566447636209.odt

Python standalone source: #!/usr/bin/env python3import logginglogging.basicConfig(level=logging.DEBUG) - Pastebin.com

A sample document with a macro would be nice, to allow others to not invent own macros, and test.

I’ve added template example and part of source to fill data to the document.

I’ve tried to iterate over DependentTextFields of field master and set Content here but it doesn’t help.

I’ve added call to XTextDocument.reformat() to the end but it doesn’t help too.

The code above didn’t help me. It is not a document with embedded macros; and I had never worked with Java scripts. If it were some embedded Java code, or an equivalent Basic code, I would be able to test and possibly advise. In the current form, when I need to do some unknown steps to make it working (create a Java solution? translate this to another language?), it would wait for those who are familiar with the worlkflow.

I’ve rewritten it to python.

This is the document with the BASIC macro embedded (I hope it is correct). But now the question is: what should happen when it’s run? Please describe like:

The document contain nothing except the field(s) in question. When the macro runs, I expect field in paragraph N to change from A to B.

Thanks.

Looks like it some locales issue. For User field it accepts dot as decimal separator and correctly formats Content field. For SetExpression it accepts comma as decimal separator and doesn’t accept dot. If I send “9,9” to Content paragraph correctly hides.

I suppose I should try to distinguish numeric data from string data and set values depending on it.