1

Libreoffice Writer supports the idea of "conditional text" by using text fields. However it is unclear to me to what extent one can take advantage of this feature.

For instance would it be possible to:

  • define a macro evaluating to true or false and use it as the condition?

  • refer to properties of cross-references for the condition (e.g., the page where a named reference appears)?

1 Answer 1

0

From https://wiki.openoffice.org/wiki/Documentation/OOo3_User_Guides/Writer_Guide/Developing_conditional_content:

You cannot use internal variables (for example, page number or chapter name) to formulate conditions.

Think of conditional text as having one and only one ability. It can be useful, yes, but does not do a lot of things you might imagine. The basic idea is to have a user variable (built into the Writer document, not a macro variable) that you can set or change at certain places in the document. Then create conditional text that reads the value of that variable in the current place.

For example, go to Ctrl+F2 -> Variables -> Set Variable and define a variable myvar1 as 5.

Next, we can get a little fancier by inserting another Set Variable field with the formula myvar1 + 3. Each time we insert this field, it will increase the value of our variable by 3 at that particular location in the document.

Finally, create conditional text with a condition myvar1 > 10. If we have inserted several fields as described above, then the condition will be true, otherwise, if there is only one, then it will be false.

For more capability, you could write a macro that runs when the document opens and updates various parts of the document. Macros can manipulate cross-references in pretty much any way imaginable. Templates also have many uses and may meet your needs without resorting to macros.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .