<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 - STYLE(foo) inside some functions behaves strangely"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=113595">113595</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>STYLE(foo) inside some functions behaves strangely
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (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>Calc
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>turbobeholder@mail.ru
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Description:
STYLE(...) inside certain functions seems to be called when it should not, even
if the rest of the formula seems to work normally.

Steps to Reproduce:
1. Start a new spreadsheet
2. Pick a cell... any cell. Insert this formula: ="foo"&SWITCH(
0,0,3&STYLE("Neutral"),-1,5&STYLE("Bad"),+1,7&STYLE("Good"))
3. Recalculate (F9) a few times.

Actual Results:  
The cell's value is "foo30", toggling between "Bad" and "Good" (red and green)
styles.

Expected Results:
The cell shows "foo30" in "Neutral" style (yellow)


Reproducible: Always


User Profile Reset: No



Additional Info:
Without the first (unused) STYLE exactly the same happens. Without either 2nd
or 3rd "&STYLE", the cell toggles between the other one and "Neutral" instead.

If the first argument is 1 or -1, the value is picked from the correct branch,
and toggling is still between the last 2 styles.

First it looked like SWITCH function is broken, but it's something weirder.

The same happens if you replace SWITCH with CONCATENATE - correct output value,
STYLE toggles. But SWITCH is supposed to ignore wrong branches, thus there
should be no possibility of racing in GUI or anything like that.

This does not happen with IF:
="foo"&IF( 0=0,3&STYLE("Neutral"), 5&STYLE("Bad"))
The result: "foo30" painted yellow as expected.

Does not depend on whether OpenGL and jRE are enabled or not.
Version: 5.4.1.2
Build ID: 1:5.4.1-0ubuntu1
CPU threads: 2; OS: Linux 4.13; UI render: default; VCL: x11; 
Locale: en-US (en_US.UTF-8); Calc: group


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:56.0) Gecko/20100101
Firefox/56.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>