[Solved] Accessing Navigator/Styles when Floating

Creating a macro - Writing a Script - Using the API

[Solved] Accessing Navigator/Styles when Floating

Postby JeJe » Mon Jul 22, 2019 12:09 am

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   Expand viewCollapse view
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
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 590
Joined: Wed Mar 09, 2016 2:40 pm

Re: Accessing Navigator/Styles and Formatting when Floating

Postby Zizi64 » Mon Jul 22, 2019 7:20 am

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; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.8; AOO4.1.6
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.
User avatar
Zizi64
Volunteer
 
Posts: 8376
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Accessing Navigator/Styles and Formatting when Floating

Postby JeJe » Mon Jul 22, 2019 9:55 am

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.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 590
Joined: Wed Mar 09, 2016 2:40 pm

Re: Accessing Navigator/Styles and Formatting when Floating

Postby Villeroy » Mon Jul 22, 2019 12:17 pm

Code: Select all   Expand viewCollapse view
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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27239
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Accessing Navigator/Styles and Formatting when Floating

Postby JeJe » Mon Jul 22, 2019 12:29 pm

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   Expand viewCollapse view

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
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 590
Joined: Wed Mar 09, 2016 2:40 pm

Re: Accessing Navigator/Styles and Formatting when Floating

Postby hubert lambert » Tue Jul 30, 2019 11:55 am

Hi,

You may try something like thise :
Code: Select all   Expand viewCollapse view
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
hubert lambert
 
Posts: 132
Joined: Mon Jun 13, 2016 10:50 am

Re: Accessing Navigator/Styles and Formatting when Floating

Postby JeJe » Tue Jul 30, 2019 1:26 pm

Brilliant thanks - that's exactly what I wanted!
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 590
Joined: Wed Mar 09, 2016 2:40 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests