Frames, Windows, and Titles

Creating a macro - Writing a Script - Using the API

Frames, Windows, and Titles

Postby Keith Wild » Tue Aug 02, 2011 11:58 am

I am trying to begin to understand frames and windows, and would be grateful for some help. I am working in Calc if that makes any difference.

I have found http://www.oooforum.org/forum/viewtopic.phtml?t=52636 very useful as a starting point (NB: I'm not interested in the dialog in the thread), but I still lack some basic understanding and haven't been able to find anything in the standard textbooks i.e. Basic Programming Guide and Andrew Pitonyak's books.

1. Is each frame associated with a unique window and vice-versa?
2. When I Mri the window generated by the code in the above thread I can't see a getFrame method or anything similar, which I would expect if 1 above were true.
3. When I Mri the frame generated by the code in the above thread there are two methods in the frame, namely getComponentWindow and getContainerWindow, which seems to suggest there is not a unique window associated with this frame, but what is the difference between these methods? I put them both under “Watch” in the IDE and the Component window remained as a Null object, and the Container window returned an object, but I couldn't work out what it was.
4. The code generates a visible object on my screen (see below), but is this just the window, or the window and frame that I am seeing? In fact is the frame a visible object at all? If not, what is it?
5. As a point of detail you can see that the object generated does not have a title – which I would expect to be at the top of the image just to the right of the blue circle with the two white birds. However, the code includes myFrame.Title = "Test", which I thought would appear in the image. Why doesn't it? NB I also tried myFrame.setTitle("Test"), but this didn't work either. I also tried myWindow.Title = "Test" (based on something in the contribution by ms777, Tue Feb 06, 2007 5:42 am in the above thread), but this returned an error: property or method not found).
Frames Windows and Titles.JPG
AOO 4.1.3
macOS High Sierra version 10.13.1
Keith Wild
 
Posts: 52
Joined: Wed Aug 12, 2009 1:14 pm
Location: London, UK

Re: Frames, Windows, and Titles

Postby hanya » Tue Aug 02, 2011 2:41 pm

Keith Wild wrote:1. Is each frame associated with a unique window and vice-versa?
Unique one.
Keith Wild wrote:2. When I Mri the window generated by the code in the above thread I can't see a getFrame method or anything similar, which I would expect if 1 above were true.
You can not get the frame from the window which is shown in the frame.
3 and 4 ....
Your window shows the frame and ContainerWindow. So, you have to make and put your own ComponentWindow into it. The example written by ms777 does not set ComponentWindow because of setComponent method is not used.

Now you can not set your title for the window which is created by the way described in the mentioned thread, depends on http://openoffice.org/bugzilla/show_bug.cgi?id=91177. Try:
viewtopic.php?f=20&t=37522#p173106

MRI extension uses own window. If you want to see its code, check create_frame function in extension_dir_of_mri/pythonpath/mytools_Mri/ui/frame.py.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 882
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Frames, Windows, and Titles

Postby Keith Wild » Sun Aug 07, 2011 2:31 pm

Hanya

Thank you for your reply, which helped me understand windows and frames a little more. However, I still can't set a title to the frame I created. Adding to the code in the thread I originally referred to, I tried to create a Component window as follows (I assume here that component just means a Calc spreadsheet or Writer document or similar).

Code: Select all   Expand viewCollapse view
isOK = myFrame.setComponent(myWindow,Null)
myComWindow = myFrame.getComponentWindow


This returned an object, which I assume was a Component window, but I couldn't see Title property or a setTitle method, so it wasn't much use.

I looked at the thread you referred to, and although I didn't understand much of it because it was in Python, the message seems to be that you can't set the title of a frame created yourself. Instead just get a frame from a component already loaded and use this . So the "solution" is something like

Code: Select all   Expand viewCollapse view
myDoc = StarDesktop.loadComponentFromURL(Url, "_blank", 0, Dummy())
myDocFrame = myDoc.getCurrentController.getFrame
myDocFrame.Title = "Test"


and indeed this worked. However, how do you manipulate the window? Can you amend the Window Descriptor and WindowAttribute of an already existing window. If so, how?

Finally, I note your reference to MRI. However, I couldn't locate the code you suggested looking at. I tried looking in the MRI library of the My Macros library container, but only found a short Basic macro there. Neither could I find anything looking in C:\Program Files\OpenOffice.org 3. Do I need a Python interpreter (or whatever the proper name is) to be able to locate and read the code? If so could I get hold of one somewhere - assuming that I could understand enough to be able to gain some benefit from looking at the code?
AOO 4.1.3
macOS High Sierra version 10.13.1
Keith Wild
 
Posts: 52
Joined: Wed Aug 12, 2009 1:14 pm
Location: London, UK

Re: Frames, Windows, and Titles

Postby Villeroy » Sun Aug 07, 2011 2:37 pm

The following Basic code has been recorded by the MRI tool with oInitialTarget being ThisComponent
Code: Select all   Expand viewCollapse view
Sub Snippet(Optional oInitialTarget As Object)
  Dim oCurrentController As Object
  Dim oFrame As Object

  oCurrentController = oInitialTarget.CurrentController
  oFrame = oCurrentController.Frame
  oFrame.Title = "Test Title"
 
End Sub

The current document title reads "Test Title" now.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26145
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Frames, Windows, and Titles

Postby hanya » Sun Aug 07, 2011 2:51 pm

Keith Wild wrote:Finally, I note your reference to MRI. However, I couldn't locate the code you suggested looking at. I tried looking in the MRI library of the My Macros library container, but only found a short Basic macro there. Neither could I find anything looking in C:\Program Files\OpenOffice.org 3. Do I need a Python interpreter (or whatever the proper name is) to be able to locate and read the code? If so could I get hold of one somewhere - assuming that I could understand enough to be able to gain some benefit from looking at the code?
Get the extension package of MRI and unpack it as ZIP archive. You can find the code in pythonpath/mytools_Mri/... directory of the unpacked files.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 882
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Frames, Windows, and Titles

Postby Villeroy » Sun Aug 07, 2011 4:38 pm

hanya wrote:Get the extension package of MRI and unpack it as ZIP archive. You can find the code in pythonpath/mytools_Mri/... directory of the unpacked files.

The extension is integrated in the help files.
You call from the document menu:Tools>Add-Ons>MRI (which inspects the current document).
Double-click the line with CurrentController, from there you get to the Frame, change mode to "Set" and double-click the Title property. Enter a title.
Finally you drag the bottom border (above the "status bar") upwards and see the code in whatever language you want (default is Basic)
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26145
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests