<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - Inconsistent, history-dependent results of referencing missing variables in conditional text"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=107523">107523</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inconsistent, history-dependent results of referencing missing variables in conditional text
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.2.6.2 release
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Writer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>echristenson@hubbell-icd.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Description:
conditional text, conditional sections, Writer 5.2.6.2, the result of
evaluating a conditional text or a condition to hide a section seems to depend
on whether the variable was previously set in the document, even if the field
that set it has since been erased with the "delete" key.

If I write my conditional text field first, and never set the variable
referenced therein, it seems to evaluate TRUE.  If I then set the variable
referenced therein, with a field in front of the conditional text, things work
as expected.  If I then delete that field, the condition (just the variable)
evaluates as FALSE.  The only user-apparent difference between the two states
is the history of editing the document.


Steps to Reproduce:
1.new writer document.
2.Insert conditional Text using SecondVar (Conditional Text SecondVar --
SecondVar is Set: SecondVar is Clear).
2. Note: SecondVar evaluates to Set
3.Insert Conditional Text using BoolVar (Condtional Text BoolVar -- BoolVar is
Set: BoolVar is Clear).
4. Insert fields/more fields, variables, BoolVar, format Boolean, value TRUE
5. Note: BoolVar evaluates to Set.
6. Erase BoolVar field.
7. BoolVar now evaluates to Clear. 

Actual Results:  
7. BoolVar now evaluates to clear, unlike SecondVar, which evaluates to set.

Expected Results:
BoolVar should have evaluated to Set, or SecondVar should have evaluated to
Clear. (or, alternatively, there should be a way within an expression to tell
if a variable has been set or not)


Reproducible: Always

User Profile Reset: No

Additional Info:
More generally, LO Writer *should* be consistent in its handling of
uninitialized fields when they are tested.  I'd like to see a defined()
operator, like in the C pre-processor, to test whether a user variable has been
set or not.

I have a much longer document where a more complicated conditional (A OR B OR
C) evaluates differently on the first and second consecutive evaluation, two
lines apart.


User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101
Firefox/53.0</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>