[Solved] Accessing Navigator/Styles when Floating

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
JeJe
Volunteer
Posts: 2777
Joined: Wed Mar 09, 2016 2:40 pm

[Solved] Accessing Navigator/Styles when Floating

Post by JeJe »

This problem doesn't matter that much to me but I can't access floating windows in Writer having spent a while with MRI trying.

In Writer I can access the Navigator/Styles and Formatting windows when they are docked using thiscomponent.currentcontroller.componentwindow.AccessibleContext

When these are floating however they don't appear there.

The windows behave differently when floating in that there is only a single one of each window for all documents opened. The information shown and position of the window changes depending on which document is given the focus.

They don't appear in the list of Stardesktop frames though.

Anyone know how to access these?

The intention would be, for example, to set the Styles and Formatting to open at the formatting for Characters instead of for Paragraphs - which can be achieved using the AccessibleContext when docked.

Edit:

calling

Code: Select all

msgbox thiscomponent.currentcontroller.componentwindow.AccessibleContext.getAccessibleChildcount
shows the absence of these windows when floating but presence when docked.

I've looked at the component window, container window and Frame LayoutManager elements and can't find any reference to these floating windows there. I presume access (if there is any) would be via the StarDesktop as all documents share them when floating.
Last edited by floris v on Tue Jul 30, 2019 2:06 pm, edited 2 times in total.
Reason: Added green checkmark, floris v, moderator
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Zizi64
Volunteer
Posts: 11358
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Accessing Navigator/Styles and Formatting when Floating

Post by Zizi64 »

Why you need to appear the user interface in a macro? You can handle the styles (and the direct formatting properties) directly by the API functions - without controlling the 'Styles and Formatting' user interface.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JeJe
Volunteer
Posts: 2777
Joined: Wed Mar 09, 2016 2:40 pm

Re: Accessing Navigator/Styles and Formatting when Floating

Post by JeJe »

I've been working on an extension to improve the handling of the UI Elements. To better restore what you exit Writer with when you open your document again - without having to manually do things like reopen split windows, reposition them, set the UI elements for each frame and so on every time... which can be a real pain.

Its clunky to have to click on the "styles and formatting" button in the sidebar and then click on the "Display formatting styles for Characters button" because that choice isn't saved on exit. I can do this in code with AccessibleContext when docked but when floating there appears to be no access to the window.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Accessing Navigator/Styles and Formatting when Floating

Post by Villeroy »

Code: Select all

Sub Snippet
  Dim oCurrentController As Variant
  Dim oFrame As Variant
  Dim oFrames As Variant
  Dim oContainerWindow As Variant
  Dim oWindows As Variant
  Dim oXWindow As Variant
  Dim oXWindow2 As Variant
  Dim oXWindow3 As Variant
  Dim oXWindow4 As Variant

  oCurrentController = ThisComponent.getCurrentController()
  oFrame = oCurrentController.getFrame()
  oFrames = oFrame.getFrames()
  
  oContainerWindow = oFrame.getContainerWindow()
  oWindows = oContainerWindow.getWindows()
  oXWindow = oWindows(0)
  
  oXWindow2 = oWindows(1)
  oXWindow3 = oWindows(2)
  oXWindow4 = oWindows(4)
REM +11 more windows
End Sub
It can be difficult to find the right window by its properties. I'm pretty sure that there is no such object as _the_ stylist window.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 2777
Joined: Wed Mar 09, 2016 2:40 pm

Re: Accessing Navigator/Styles and Formatting when Floating

Post by JeJe »

Thanks for trying... I looked at the windows for the Component and Container windows using MRI.

I get 13 windows and 6 visible for the container window regardless of whether the Navigator etc windows are shown - even when docked.

They're accessible via the Component window's AccessibleContext but not when floating when they are shared by all documents.

Code: Select all


Sub Snippet
  oCurrentController = ThisComponent.getCurrentController()
  oFrame = oCurrentController.getFrame()
  oFrames = oFrame.getFrames()
 
  oContainerWindow = oFrame.getContainerWindow()
  oWindows = oContainerWindow.getWindows()
for i = 0 to  ubound(oWindows)
if oWindows(i).isvisible = true then c=c+1
next
msgbox c
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: Accessing Navigator/Styles and Formatting when Floating

Post by hubert lambert »

Hi,

You may try something like thise :

Code: Select all

sub getFloatingNavigatorPanel()
    globalscope.BasicLibraries.loadLibrary("Tools")
    navigatorName = GetRegistryKeyContent("org.openoffice.Office.UI.Sidebar/Content/PanelList/SwNavigatorPanel").Title
    tk = stardesktop.CurrentFrame.ComponentWindow.Toolkit
    for n = 0 to tk.TopWindowCount -1
        topwindow = tk.getTopWindow(n)
        if topwindow.AccessibleContext.AccessibleName = navigatorName then
            mri topwindow
            exit sub
        end if
    next n
    print "No floating navigator panel."
end sub
Regards.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
JeJe
Volunteer
Posts: 2777
Joined: Wed Mar 09, 2016 2:40 pm

Re: Accessing Navigator/Styles and Formatting when Floating

Post by JeJe »

Brilliant thanks - that's exactly what I wanted!
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply