libreoffice-writer

Using a List Box's user-choice as a Condition in LibreOffice Writer


I'm trying to make a form-fillable pdf where List Boxes will affect other parts of the sheet.

I have several Hidden Paragraphs in my document (hiding graphics, etc), and a List Box. I'd like to use the List Box choice as the Condition to dynamically hide and unhide the various Hidden Paragraphs.

Example: The user selects clicks on the List Box, and Cat, Dog, and Bird are listed. If the user selects "Dog" from the list, the paragraph with text and pictures of dogs is no longer hidden.

I get that I have to do Hide Paragraph if [List Box choice] != "Dog" as my Condition, I just can't figure out where to get the List Box choice. Feels like I hit a wall in searching for an answer or guide because I'm missing specific terminology (field? formula?).


Solution

  • According to https://help.libreoffice.org/7.0/en-US/text/swriter/01/04090200.html, you can set up a database for Writer conditions. It looks like this would work with LibreOffice Base, where forms with list boxes can be created.

    However, if you are trying to use values from a list box in a standalone Writer template or other document, then looking at that link, it does not seem possible. Writer conditions are restricted to document metadata, not the contents of the document.

    One solution is to write a macro that pops up a dialog with a list box, and then when the dialog is closed, modify the Writer document based on the selected values. LibreOffice has a dialog development front end to help you set this up, and then you would need to write code to execute the dialog and do the changes. See https://www.pitonyak.org/oo.php for help writing the necessary code.