Bug 84144 - Sections hiding opposite to condition
Summary: Sections hiding opposite to condition
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Section
  Show dependency treegraph
 
Reported: 2014-09-21 21:14 UTC by Chas Belov
Modified: 2019-11-30 05:32 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Demonstration of issue (9.30 KB, application/vnd.oasis.opendocument.text)
2014-09-21 21:14 UTC, Chas Belov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chas Belov 2014-09-21 21:14:48 UTC
Created attachment 106623 [details]
Demonstration of issue

If I change the condition on a conditional text field, this causes a hidden section to unhide.

Steps:
1. Insert variable varA with value "is" (without the quotes) 
-- a. Insert > Fields > Other > Variables > Set Variable
-- b. Name: varA 
-- c. Value: is
-- d. Click Insert

2. Press enter

3. Insert variable varB with value "is" (without the quotes)
-- same as step 1 with name varB

4. Press enter

5. Insert a conditional field based on varA
-- a. Insert > Fields > Other > Functions > Conditional Text
-- b. Condition: varA EQ "is" (with the quotes)
-- c. Then: Ais
-- d. Else: AisNot
-- e. Click OK

6. Press enter

7. Insert two section based on varB
-- a. Type "Hide this section if varB is" (without the quotes)
-- b. Press enter
-- c. Type "Hide this section if varB is not" (ditto)
-- d. Select the first of the two lines
-- e. Insert > Section
-- f. Check Hide
-- g. Condition: varB EQ "is"
-- h. Select the second of the two lines
-- i. Insert > Section
-- j. Check Hide
-- k. Condition: varB NEQ "is"

Actual result: "Hide this section if varB is" shows, "Hide this section if varB is not" is hidden

Expected result: "Hide this section if varB is" is hidden, "Hide this section if varB is not" shows

Attachment is at this point.

Actually 4.2.6.3 but that's not offered in the dropdown at time of filing.
Hardware is Intel Core 2 Duo
Editing
Comment 1 Alex Thurgood 2014-09-23 12:25:50 UTC
*** Bug 84148 has been marked as a duplicate of this bug. ***
Comment 2 Alex Thurgood 2014-09-23 12:42:00 UTC
I can reproduce this behaviour on OSX 10.9.4

LO Version: 4.4.0.0.alpha0+
Build ID: e9645402b1e5aaf399aed68fe961fe6ebdb2df1e
Comment 3 Alex Thurgood 2014-09-23 12:47:37 UTC
Doesn't work in LO Version 3.6.7.2 (Build ID: e183d5b) either.
Comment 4 Alex Thurgood 2014-09-23 12:50:53 UTC
Same behaviour also present in OOo 321 (320m18) so this behaviour is inherited from OOo
Comment 5 QA Administrators 2016-11-08 11:54:55 UTC Comment hidden (obsolete)
Comment 6 Mike Kaganski 2019-11-30 05:32:35 UTC
This works as intended, and is not a bug; but please see at the end of the comment.

Inserting a "Set variable" field *for the first time*, you *define* a variable in the document; and also *define its type*, which can be *numeric* or *textual*. After the definition, you can't change the type (until you remove the variable from document using "cross" button in "Set variable" insertion dialog).

By default, all variables are created of numeric type.
Setting a variable's type is done by assigning it "Text" *format* when creating it.

When a variable is created numeric, i.e. not assigned "Text" format when created, its value is treated as a formula, and its result is converted to number. E.g., putting "is" with quotes would make the variable equal to result of conversion of text "is" to a number, which is 0. Putting "123a456" in quotes would result in number 123, because conversion to number stops at non-numeric character "a". `1+2` (without quotes) gives 3. Putting `pi` (without quotes) into the value of the numeric variable produces result of 3.14..., using one of predefined values [1] (note that value names are case-insensitive). When you have created a numeric variable varA with value 3, creating numeric varB with formula `varA + 1` will give 4.

For a numeric variable, there is a specific situation when you put an undefined name into its value box. E.g., creating numeric varA with value `is` without quotes, when no variable `is` was defined, produces varA variable with *empty* value, which e.g. also produces empty results of formulas like `varA + 1`.

When a variable is defined textual (by setting its format to Text upon its creation), anything you write into the value box is treated as plain string (except when you put an existing variable name); e.g., putting `is` without quotes into the value box (assuming there's no variable `is` predefined) will produce string "is", which might be tested using condition `var EQ "is"` [2]; putting "is" *with* quotes into the value box will produce 4-character string *containing the quotes*, so the condition `var EQ "is"` would fail this time; `1+2` would produce string "1+2". But when you have a variable txtA containing "AAA", and you create another textual txtB with value `txtA`, txtB will contain AAA.

Note again that trying to change existing variable type after creation will not work, neither in "Set variable field", nor in "Show variable", "Input field", or others.

So your steps in comment 0 lack a step between 1.b and 1.c, which would be

1.b.1. Format: Text

With that, your document will work => NOTABUG.

Now I agree that there a problem with the Set Variable fields, worth a separate issue:

The aspects of *creation* of a variable; *variables having a type*; and other variable manipulations (e.g., that variables don't get deleted when the last field setting/using it is removed; or inability to change type; or empty result when using undefined names in numeric variables; or using predefined variable names in textual variables) are unclear, not intuitive, and not well documented and represented in UI. There's tdf#111888 regarding one of aspects of variable manipulation, but unrelated to this issue (which is about variable types).

Please create a separate issue(s) regarding documentation and usability about these problems.

[1] https://help.libreoffice.org/6.3/en-US/text/swriter/02/14020000.html
[2] https://help.libreoffice.org/6.3/en-US/text/swriter/01/04090200.html