Bug 170386 - Setting CharWeight of a textbox while controllers are locked breaks saving that property in a macro
Summary: Setting CharWeight of a textbox while controllers are locked breaks saving th...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:26.8.0 target:26.2.1
Keywords:
Depends on:
Blocks:
 
Reported: 2026-01-19 12:44 UTC by Mike Kaganski
Modified: 2026-02-02 14:22 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 2026-01-19 12:44:35 UTC
Consider this macro:

sub test()
  doc = StarDesktop.loadComponentFromURL("private:factory/sdraw", "_default", 0, array())
  page = doc.getDrawPages().getByIndex(0)
  doc.lockControllers()
  shape = doc.createInstance("com.sun.star.drawing.TextShape")
  page.add(shape)
  shape.setString("Some Text")
  point = new com.sun.star.awt.Point
  point.X = 2000
  point.Y = 600
  shape.setPosition(point)
  shape.setPropertyValue("CharWeight", 150)
  doc.unlockControllers()
  doc.storeAsURL(ConvertToURL("C:/Downloads/test.odg"), array())
end sub

It creates a new Draw document; locks its controllers; creates and inserts a TextShape; sets its text, position, and weight; unlocks controllers and saves. (NB: change the path inside ConvertToURL to a path suitable for you when testing.)

The created document is displayed immediately as saved and unchanged; and the text is shown bold, as expected. However, File->Reload changes the text to normal.

Commenting out `doc.lockControllers()` and `doc.unlockControllers()` fixes the issue (but of course, that's not a solution: lockControllers helps improve performance, and should not create such a problem). The resulting document.xml has a paragraph autostyle (setting bold) used in <text:p> of the <draw:text-box>, unlike the case when controllers were locked (even though another paragraph autostyle, also with bold, is set in draw:text-style-name in <draw:frame>).
Comment 1 Roman Kuznetsov 2026-01-27 10:06:38 UTC
https://gerrit.libreoffice.org/c/core/+/198187
Comment 2 Commit Notification 2026-01-28 09:36:35 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/3f87466d6db4ba694a8ba9f74dcac1b142a15f30

tdf#170386: Delay broadcasting object changes, not drop it

It will be available in 26.8.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 3 Commit Notification 2026-02-02 14:22:28 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

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

tdf#170386: Delay broadcasting object changes, not drop it

It will be available in 26.2.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.