Macro to replace form control Names and Data fields

I am in the process of constructing a very long survey using LibreOffice Writer. The idea is to eventually export the survey to PDF and, after the PDFs have been filled in by the respondents, extract the form control data using pdftk.

The survey is split in three parts, called “A1”, “A2”, and “A3”.

Each section of the survey contains several questions named “Q1, Q2, … Q100” (starting from 1 in each section).

Each question has a range of answer options, in the form of option buttons, that the respondent can tick. To group the option buttons, each button is given a name in the form control properties according to which section it belongs to, as well as which question number of that section it belongs to. It thus takes on the following naming scheme: “A1.Q1”, “A1.Q2”, …, “A3.Q99”.

The reference value (on) for each button is the option it represents (“a”, “b”, or “c”).

Now, I have assigned the correct names for all option buttons in section A1. To avoid having to manually assign a new name for each option button, I would ideally like to create A2 and A3 as copies of A1 (in separate documents), and run a macro that substitutes “A1” in the Name field and the Data field of the properties of each option button for “A2”, and for “A3”. Is this possible (my knowledge of macros is limited)?

Any help with this would be greatly appreciated! I have attached a dummy document corresponding to the structure of section A1 to exemplify my point.Section A1.odt

For anyone who might face the same issue, I have now solved it by saving the odf document as a Flat XML ODF document. Then you can open the file in Notepad++ and search for “form:name” and replace the relevant names.