Bug 150167 - createUnoService returns wrong type for CharacterProperties and ParagraphProperties
Summary: createUnoService returns wrong type for CharacterProperties and ParagraphProp...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.3.2.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-27 13:22 UTC by eseb63
Modified: 2022-08-23 13:54 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
demo with characterProperties (82.16 KB, image/jpeg)
2022-07-27 13:26 UTC, eseb63
Details
demo with paragraphProperties (73.51 KB, image/jpeg)
2022-07-27 13:27 UTC, eseb63
Details

Note You need to log in before you can comment on or make changes to this bug.
Description eseb63 2022-07-27 13:22:55 UTC
Description:
instantiating the service "com.sun.star.style.CharacterProperties" with the createUnoService command returns a "com.sun.star.comp.chart2.RegressionEquation" service instead

instantiating the service "com.sun.star.style.ParagraphProperties" with the createUnoService command returns a "com.sun.star.comp.chart2.Title" service instead


Steps to Reproduce:
1. write this code and launch it:

Sub testCharacterProperties
	dim oService as object
	oService = CreateUnoService("com.sun.star.style.CharacterProperties")
	print oService.implementationName
End Sub

Sub testParagraphProperties
	dim oService as object
	oService = CreateUnoService("com.sun.star.style.ParagraphProperties")
	print oService.implementationName
End Sub



Actual Results:
for CharacterProperties, i get a com.sun.star.comp.chart2.RegressionEquation which supports several services

for ParagraphProperties, i get a com.sun.star.comp.chart2.Title which supports several services

Expected Results:
for CharacterProperties, i expect a CharacterProperties service and only it

for ParagraphProperties, i expect a ParagraphProperties service and only it


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.3.2.2 (x86) / LibreOffice Community
Build ID: 49f2b1bff42cfccbd8f788c8dc32c1c309559be0
CPU threads: 2; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: fr-FR (fr_FR); UI: fr-FR
Calc: threaded
Comment 1 eseb63 2022-07-27 13:26:16 UTC
Created attachment 181437 [details]
demo with characterProperties
Comment 2 eseb63 2022-07-27 13:27:44 UTC
Created attachment 181438 [details]
demo with paragraphProperties
Comment 3 Mike Kaganski 2022-07-27 14:01:54 UTC
implementationName is not service name, and its value is not part of the API (e.g., it may be changed...)

The question is - why these service may be instantiated like this. They seem to have no meaning outside of respective objects.
Comment 4 eseb63 2022-07-27 20:52:11 UTC
what would be a good manner to instantiate them? why the createUnoService does not return the good service ?

i have to copy rich text from Calc cells to comments and from comments to cells : so i search a generic way to  get the character/paragraph properties to reproduce formatting. I saw examples that analyze the property names of a textRange (getPropertySetInfo => getProperties : first 4 letters = "char" or "para" but it's not very clean i think). 

As they belong to the services characterProperties/paragraphProperties, i wanted to instantiate the service to accuraterly list his properties and only them.

does exist another way to achieve that?
Comment 5 eseb63 2022-08-22 13:15:47 UTC
might you reply to my questions please ?
Comment 6 Mike Kaganski 2022-08-22 13:54:14 UTC
(In reply to eseb63 from comment #5)

Questions like "How do I..." belong to e.g. https://ask.libreoffice.org/; please ask your question there.
Comment 7 eseb63 2022-08-22 21:40:41 UTC
maybe, but "why the createUnoService does not return the good service" is a question for the support team i think ?
Comment 8 Maxim Monastirsky 2022-08-22 23:32:35 UTC
The term "service" used here is a bit misleading. There is no such thing as a "ParagraphProperties service" that you can instantiate. ParagraphProperties is just a *specification* that can be implemented by different components (like paragraphs, cells etc.). That means that if such "service" references some interfaces or properties, you can expect them to be present in components that claim to implement this service (among others). That's it.

Regarding createUnoService, I believe it just picks a random component whose entry in a .component file has that service listed.
Comment 9 eseb63 2022-08-23 13:09:45 UTC
thanks for your explanation but it's quite confusing for me ... so, some services are "true" services that can be instantiated  and others like paragraphProperties and characterProperties are not ? how to know that, since the LibreOffice API Reference  presents them as "normal" services without other information about instantiation restrictions ?

How to navigate when you start in LibreOffice programming if you cannot trust the incomplete and misleading help?
Comment 10 Stephan Bergmann 2022-08-23 13:54:48 UTC
(In reply to eseb63 from comment #9)
> thanks for your explanation but it's quite confusing for me ... so, some
> services are "true" services that can be instantiated  and others like
> paragraphProperties and characterProperties are not ? how to know that,
> since the LibreOffice API Reference  presents them as "normal" services
> without other information about instantiation restrictions ?
> 
> How to navigate when you start in LibreOffice programming if you cannot
> trust the incomplete and misleading help?

That's how so-called "new style" (or "interface-based") service declarations came about (that start with "service SomwService: XSomeInterface" in UNOIDL), to distinguish them from the somewhat ill-conceived "old-style" (or "accumulation-based") service declarations (that start with "service SomeService {" in UNOIDL).  See <https://wiki.documentfoundation.org/Documentation/DevGuide/Professional_UNO#Services> for further reading.