Bug 145960 - 'inappropriate property value' constructing a value of SetPropertyValue for a boolean property using Not
Summary: 'inappropriate property value' constructing a value of SetPropertyValue for a...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.4.0 target:7.3.0.2
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-30 08:04 UTC by Mike Kaganski
Modified: 2021-12-29 08:34 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2021-11-30 08:04:23 UTC
Consider this Basic code:

> Sub TestGlobalSheetSettings
>   oManager = GetProcessServiceManager()
>   oConfigProvider = oManager.createInstance("com.sun.star.configuration.ConfigurationProvider")
>   Dim aArg(0 to 0) As New com.sun.star.beans.PropertyValue
>   aArg(0).Name = "nodepath"
>   aArg(0).Value = "/org.openoffice.Office.Math/Misc"
>   oConfigAccess = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aArg)
>   oConfigAccess.SetPropertyValue("AutoCloseBrackets", True)
>   oConfigAccess.SetPropertyValue("AutoCloseBrackets", Not True)
>   oConfigAccess.CommitChanges()
> End Sub

Running it, the line 'oConfigAccess.SetPropertyValue("AutoCloseBrackets", Not True)' fails with the message:

> BASIC runtime error.
> An exception occurred 
> Type: com.sun.star.lang.IllegalArgumentException
> Message: configmgr inappropriate property value.

The previous line, using plain boolean constant, without Not, passes fine.

Tested with Version: 7.2.3.2 (x64) / LibreOffice Community
Build ID: d166454616c1632304285822f9c83ce2e660fd92
CPU threads: 12; OS: Windows 10.0 Build 19043; UI render: default; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: threaded

and current master.
Comment 1 Julien Nabet 2021-12-01 21:05:08 UTC
Just for the record, on pc Debian x86-64 with master sources updated today, I could reproduce this.
I tried to dig in "value.isExtractableTo(mapType(type))" (configmgr/source/access.cxx line 1500), I understood nothing.
Comment 2 Mike Kaganski 2021-12-02 12:50:14 UTC
I suppose that the problem is related to

  TypeName(Not True)

returning "Long", instead of expected "Boolean". But that was already that way in OOo 3.2.0. Yet, the code from comment 0 (replacing "AutoCloseBrackets" property missing in that version with "IgnoreSpacesRight") works fine in that version; it fails in OOo 3.3.0. Likely the check for the type was added in 3.3.0 release cycle. So the fix likely should be to make sure that Not + Boolean (as well as And and Or) results in Boolean.
Comment 3 Andreas Heinisch 2021-12-28 11:29:19 UTC
Code pointer: https://opengrok.libreoffice.org/xref/core/basic/source/sbx/sbxvalue.cxx?r=26f46b86#846

Small test case in both MS and LO:

Sub TestCase()

    Dim a As Boolean
    Dim b As Boolean
    a = True
    b = True
    '                              MS         LO      LO Removing bVBAInterop
    MsgBox TypeName(a \ b)       ' Integer    Long    Boolean
    MsgBox TypeName(a Mod b)     ' Integer    Long    Boolean
    MsgBox TypeName(a And b)     ' Boolean    Long    Boolean
    MsgBox TypeName(a Or b)      ' Boolean    Long    Boolean
    MsgBox TypeName(a Xor b)     ' Boolean    Long    Boolean
    MsgBox TypeName(a Eqv b)     ' Boolean    Long    Boolean
    MsgBox TypeName(a Imp b)     ' Boolean    Long    Boolean
    MsgBox TypeName(Not a)       ' Boolean    Boolean Boolean
    MsgBox TypeName(Not True)    ' Boolean    Long    Boolean
    MsgBox TypeName(Not False)   ' Boolean    Long    Boolean
      
End Sub

I would exclude the mod and the integer division from the boolean assignment.
Comment 4 Commit Notification 2021-12-28 18:55:50 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/565a5fdee3c00b383b4d36180be845d48fd42556

tdf#145960 - Return type of boolean operators should be of type boolean

It will be available in 7.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2021-12-29 08:34:35 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/bd7f01c4ca5222d8d3293cc81802cfd6c0bfdcc3

tdf#145960 - Return type of boolean operators should be of type boolean

It will be available in 7.3.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.