Bug 165244 - Macro code to change the font family for a Style works in version 24.8, but fails in LO 25.2
Summary: Macro code to change the font family for a Style works in version 24.8, but f...
Status: REOPENED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
25.2.0.0 alpha0+
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2025-02-13 21:44 UTC by AH
Modified: 2025-02-16 18:12 UTC (History)
4 users (show)

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 AH 2025-02-13 21:44:19 UTC
Description:
LO Writer macro code that works in LO 24.8 fails in 25.2:

	
dim oFamilies as object
dim oStyleDefault as object
dim oStyleHeading as object	
	 
oFamilies = ThisComponent.StyleFamilies.getByName("ParagraphStyles")
oStyleDefault = oFamilies.getByName("Default Paragraph Style")  <<-- ERROR HERE
oStyleDefault.CharFontName = "Liberation Serif"
oStyleDefault.CharHeight = 12

The line: oFamilies.getByName("Default Paragraph Style")

Fails with the message:

BASIC runtime error.
An exception occurred 
Type: com.sun.star.container.NoSuchElementException
Message: Default Paragraph Style.

The same error occurs with oFamilies.getByName("Body Text")

This code works in LO 24.8, but errors in 25.2

Interestingly, it works in 25.2 with Heading 1:

oStyleDefault = oFamilies.getByName("Heading 1")


Steps to Reproduce:
	
dim oFamilies as object
dim oStyleDefault as object
dim oStyleHeading as object	
	 
oFamilies = ThisComponent.StyleFamilies.getByName("ParagraphStyles")
oStyleDefault = oFamilies.getByName("Default Paragraph Style")  <<-- ERROR HERE
oStyleDefault.CharFontName = "Liberation Serif"
oStyleDefault.CharHeight = 12

Actual Results:
The line: oFamilies.getByName("Default Paragraph Style")

Errors with the message:

BASIC runtime error.
An exception occurred 
Type: com.sun.star.container.NoSuchElementException
Message: Default Paragraph Style.

The same error occurs with oFamilies.getByName("Body Text")

This code works in LO 24.8, but errors in 25.2

Interestingly, it works in 25.2 with Heading 1:

oStyleDefault = oFamilies.getByName("Heading 1")

Expected Results:
The macro code should work in version 25.2 just as it does in version 24.8


Reproducible: Always


User Profile Reset: No

Additional Info:
see included code
Comment 1 Xisco Faulí 2025-02-13 22:05:33 UTC
This started to fail after

commit ea84220a7558508dd906c402d68da532b664a20a	[log]
author	Michael Stahl <michael.stahl@allotropia.de>	Thu Dec 05 12:22:14 2024 +0100
committer	Michael Stahl <michael.stahl@allotropia.de>	Mon Dec 09 20:51:08 2024 +0100
tree 944ec7525254e57eaffd8062ec6aca18e15d2f8f
parent 130478ca19dec874a043f4c9d4977aca7fb19cc2 [diff]

tdf#159549 sw: fix ODF import of newly colliding Body Text styles

I believe you macro has to be adapted to 

dim oFamilies as object
dim oStyleDefault as object
dim oStyleHeading as object	
	 
oFamilies = ThisComponent.StyleFamilies.getByName("ParagraphStyles")
oStyleDefault = oFamilies.getByName("Standard")
oStyleDefault.CharFontName = "Liberation Serif"
oStyleDefault.CharHeight = 12

Closing as RESOLVED NOTABUG
Comment 2 AH 2025-02-16 15:32:16 UTC
The changed line:

oStyleDefault = oFamilies.getByName("Standard")

Does not error, but it also has no effect on the "Body Text" style. It did not appear toaffect any Text or Heading style.