Look at this BASIC code: > sub TestRootAccess1 > GlobalScope.BasicLibraries.LoadLibrary("Tools") > Dim KeyWriter As Object > KeyWriter = GetRegistryKeyContent("org.openoffice.Office.Calc/Input", True) > KeyWriter.setPropertyValue("ExpandReference", True) > KeyWriter.commitChanges() > ' Use *different* object to read the setting > MsgBox GetRegistryKeyContent("org.openoffice.Office.Calc/Input").getByName("ExpandReference") > end sub This code will show "True", irrespective of previous setting value (which means it works as expected). Now modify that like this: > sub TestRootAccess2 > GlobalScope.BasicLibraries.LoadLibrary("Tools") > With GetRegistryKeyContent("org.openoffice.Office.Calc/Input", True) > .setPropertyValue("ExpandReference", False) > .commitChanges() > End With > ' Use *different* object to read the setting > MsgBox GetRegistryKeyContent("org.openoffice.Office.Calc/Input").getByName("ExpandReference") > end sub Now this code will not actually change the setting; e.g., if TestRootAccess2 run after the previous TestRootAccess1, the result of TestRootAccess2 will be True, not the expected False. The problem seems to be that the With statement does not evaluate its argument (GetRegistryKeyContent("org.openoffice.Office.Calc/Input", True)) at entry to use it later at each member access, but evaluates it each time anew when it accesses the members of the object using unqualified ".member" syntax. That means that commitChanges() is executed for a different object than setPropertyValue(), and the changes are not committed. The help for With statement [1] mentions "single object": > Use With and End With if you have several properties or methods for a single object. VBA help [2] also says about that: > Executes a series of statements on a single object or a user-defined type. VB help [3] goes even further: > objectExpression Required. An expression that evaluates to an object. The expression may be arbitrarily complex and is evaluated only once. So the implementation of With looks inconsistent, unexpected, inefficient (in the best case) and wrong. [1] https://help.libreoffice.org/6.4/en-US/text/sbasic/shared/03090411.html [2] https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/with-statement [3] https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/with-end-with-statement Tested with Version: 6.4.3.1 (x64) Build ID: 4d2b2b47cca498fed6abf712a36d0788901091eb CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: default; VCL: win; Locale: en-US (ru_RU); UI-Language: en-US Calc: threaded
Already repro with OOo 2.2.0
*** Bug 99554 has been marked as a duplicate of this bug. ***
Dear Mike Kaganski, To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug
https://gerrit.libreoffice.org/c/core/+/171980
Mike Kaganski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/f3f46b5fe729876d128f63f7ab158954ab6657d7 tdf#132064: make With statement only evaluate its argument once It will be available in 25.2.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.
Mike Kaganski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/fa8a0f514a4c722974410e4cbfa8ea12f3304003 Related: tdf#132064 Use set to clear the With internal variable It will be available in 25.2.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.
Mike Kaganski committed a patch related to this issue. It has been pushed to "libreoffice-24-8": https://git.libreoffice.org/core/commit/bf87977617ead6221e0a42fea3d3e69c983dd805 tdf#132064: make With statement only evaluate its argument once It will be available in 24.8.1. 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.
Mike Kaganski committed a patch related to this issue. It has been pushed to "libreoffice-24-8": https://git.libreoffice.org/core/commit/46dfd2c75bfc9a56659db00f1a8b3946bc8d8340 Related: tdf#132064 Use set to clear the With internal variable It will be available in 24.8.1. 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.
This patch breaks the TexMaths extension. Indeed in TexMaths I frequently use Basic code like the following one to create resizable dialogs: ' Create new outer base dialog ' oParent: parent window peer ' Return dialog window Function CreateBaseDialog(oParent as Variant) as Variant Dim oToolkit as Variant oToolkit = oParent.getToolkit() Dim WA as Variant, aRect as Variant, oDesc as Variant WA = com.sun.star.awt.WindowAttribute aRect = CreateUnoStruct("com.sun.star.awt.Rectangle") oDesc = CreateUnoStruct("com.sun.star.awt.WindowDescriptor") With oDesc .Type = com.sun.star.awt.WindowClass.SIMPLE .WindowServiceName = "dialog" .Parent = oParent .ParentIndex = -1 .Bounds = aRect .WindowAttributes = WA.CLOSEABLE OR WA.MOVEABLE OR WA.SIZEABLE OR WA.BORDER End With Dim oDialog as Variant oDialog = oToolkit.createWindow(oDesc) ' Create listeners oDialog.addTopWindowListener(CreateUnoListener("MainWindowListener_", "com.sun.star.awt.XTopWindowListener")) oDialog.addWindowListener(CreateUnoListener("MainWindowListener_", "com.sun.star.awt.XWindowListener")) CreateBaseDialog = oDialog End Function The above function is called like this: Sub Test ' Parent window Dim oParent as Variant oParent = ThisComponent.getCurrentController().getFrame().getContainerWindow() ' Create base outer window as modal dialog Dim oDlgBaseMain as Variant oDlgBaseMain = CreateBaseDialog(oParent) ' Set window title oDlgBaseMain.setTitle("Dialog Title") End Sub Running the Test() subprogram in LibreOffice 24.8.1.2 results in the following error message: "Basic runtime error. Property or method not found: setTitle." This worked without problem in LibreOffice 24.8.0.2. A simple workaround is to replace: With oDesc .Type = com.sun.star.awt.WindowClass.SIMPLE .WindowServiceName = "dialog" .Parent = oParent .ParentIndex = -1 .Bounds = aRect .WindowAttributes = WA.CLOSEABLE OR WA.MOVEABLE OR WA.SIZEABLE OR WA.BORDER End With with: 'With oDesc oDesc.Type = com.sun.star.awt.WindowClass.SIMPLE oDesc.WindowServiceName = "dialog" oDesc.Parent = oParent oDesc.ParentIndex = -1 oDesc.Bounds = aRect oDesc.WindowAttributes = WA.CLOSEABLE OR WA.MOVEABLE OR WA.SIZEABLE OR WA.BORDER 'End With in function CreateBaseDialog(). This problem probably affects other extensions...
*This* one is RESOLVED FIXED. Any regression from this are *separate* bugs (with this in See Also). Now please take a look at bug 162962, and see if its fix possibly fixes your issue, too. If not, please do file it separately. Thank you.
... or maybe more likely bug 162935.