Bug 157391 - Access items in the Navigator window programatically
Summary: Access items in the Navigator window programatically
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
(earliest affected) release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL: https://ask.libreoffice.org/t/96147
Keywords: needsDevAdvice
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
Reported: 2023-09-23 10:26 UTC by fuzzybear
Modified: 2023-10-21 06:15 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description fuzzybear 2023-09-23 10:26:15 UTC
Is there any way to access the details in the navigator window programatically using UNO? ... and if not could there be?

So much of my effort goes in to traversing a document to find elements that are already displayed in the Navigator - one example is hyperlinks but doubtless there are others.

I am sure that accessing items directly from the Navigator window would be more performant & reliable than document traversal.

The Navigator window is a great tool, and developers working with LibreOffice would be able to produce better, more optimised solutions using it.
Comment 1 Wolfgang Jäger 2023-09-23 11:00:44 UTC
This is only about the Navigator as shown for Writer documents.
Comment 2 Stéphane Guillou (stragu) 2023-10-17 16:05:15 UTC
I don't really understand the use case.
Can you please provide a precise example of what you want to do and how it would be useful? Comparing "what you do know" with "what you would like instead". Possibly attaching an example macro too.

Thank you!
Comment 3 Wolfgang Jäger 2023-10-17 19:17:27 UTC
The questioner was advised to post a feature request to the bug tracker in the thread https://ask.libreoffice.org/t/96147 of the ask site.

Generally it's unclear for what reasons the software creates a list of hyperlinks for thw Writer document, and shows it in the navigator, but doesn't make it accessible via an API service.

Bookmarksd, e.g, are also listed in the navigator, but also accessible via the model's property .bookmarks. Same thing with TextTable objects, TextFields  ...

You may read the request this way: Don'waste effort by creating lists (or trees?) for the navigator without also giving access to them to programmers of custom code.
Comment 4 fuzzybear 2023-10-19 15:24:41 UTC
Apologies for my delayed response - Wolfgang Jäger's summary is correct.

It is not such a burning issue now, as I have approached the issue I had a different way - but I believe that it would be useful to be able to access the data within the navigator window programatically.

It would certainly be quicker that iterating through with something like this:

for text_portion in text.createEnumeration():
    if text_portion.HyperLinkURL != "":
        hyperlink = text_portion.HyperLinkURL
Comment 5 QA Administrators 2023-10-20 03:15:35 UTC Comment hidden (obsolete)
Comment 6 Stéphane Guillou (stragu) 2023-10-20 12:58:13 UTC
Thank you, that makes more sense. Marking as "new" but asking for dev advice.

Apart from Hyperlinks, what other elements are missing? Maybe this enhancement request can be about hyperlinks specifically, to have something more actionable.
Comment 7 fuzzybear 2023-10-21 06:15:40 UTC
There's various information available there, unfortunately I am not sufficiently knowledgeable with regard to what of that information is available through pre existing APIs within the tool. Hyperlink enumeration is an obvious example but I expect that there are others.