[Solved] OOo Calc macro to Maximize a window

Creating a macro - Writing a Script - Using the API

[Solved] OOo Calc macro to Maximize a window

Postby alf50 » Tue Aug 16, 2011 5:24 am

Can someone show me a OOo Calc macro to Maximize a window.
I want this macro to look at the
- current size of the computer screen I am on,
- Leave all the Menus in the Calc Window available for my use,
- Leave all the Docing bars visible on the screen, and
- Maximize the the window to the remaining space.

On a Macintosh running OS X 10.6.8 This is equivalent to clicking the Green "+" Button in the upper Left Corner of the window.

On a PC running WIndows 7, this is equivalent to clicking the square box in the upper right hand corner of the window.

I have been looking for a solution for weeks without success.

I DO NOT WANT THE "FULLSCREEN" view that eliminates all the menu bars!!! Any help would be greatly appreciated!!
Last edited by alf50 on Mon Nov 26, 2012 12:23 am, edited 1 time in total.
OpenOffice 4.1.5 on Mac El Capitan(10.11.6) and MS Windows10
alf50
 
Posts: 97
Joined: Sun Jun 13, 2010 2:55 pm

Re: OOo Calc macro to Maximize a window

Postby FJCC » Tue Aug 16, 2011 6:17 am

I think this works
Code: Select all   Expand viewCollapse view
oController = ThisComponent.getCurrentController()
oFrame = oController.getFrame()
oContainerWindow = oFrame.ContainerWindow
oContainerWindow.isMaximized = True
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7360
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: OOo Calc macro to Maximize a window

Postby alf50 » Tue Aug 16, 2011 10:57 pm

FJCC-
When I try to run the code as a separate macro, it does nothing.

I also tried dimensioning each element (ie: oController, oFram, oContainerWindow) as Objects, but that did not work either.

I tried running on both a OS X 10.6.8 Mac and a Win 7 PC.

Any other suggestions???
OpenOffice 4.1.5 on Mac El Capitan(10.11.6) and MS Windows10
alf50
 
Posts: 97
Joined: Sun Jun 13, 2010 2:55 pm

Re: OOo Calc macro to Maximize a window

Postby RPG » Tue Aug 16, 2011 11:46 pm

Hello

The code is working for me.
Store the macro in the document and not in My macros.

Tell
LibreOffice 6.2.5.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2172
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: OOo Calc macro to Maximize a window

Postby alf50 » Wed Aug 17, 2011 1:35 am

None of my efforts seem to do anything. I set up a button on the Calc Spread Sheet I have open,
then I link the button to Mfull, but when I click the "Full" Button, nothing happens. Any suggestions about any other code modifications?

If I knew what arg1() values to pass to the dispatcher, and what ".uno:isMaximized" CALL name to use, maybe this would work.
Is there a list of dispatcher, .uno: commands that I can go to??
Code: Select all   Expand viewCollapse view
Sub Mfull

Rem --- I noticed that FJCC and RPG are working with MS XP and Open SUSE 11.4 respectively
Rem --- I am working with Mac OS X 10.6.8 and MS Win7-- Could that be the problem?? ----
Rem --- Added dim statements as a last resort, that did not work either -------
dim document   as object
dim dispatcher as object
dim oController as object
dim oFrame as object
dim oContainerWindow as object
Rem -------------------------------------

Rem --- Added doc and dispatch for first modification tried, that did not work -------
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oController = ThisComponent.getCurrentController()

Rem --- Original Suggestion tried -------
oFrame = oController.getFrame()
oContainerWindow = oFrame.ContainerWindow
oContainerWindow.isMaximized = True
Rem -------------------------------------

Rem --- Most code I right works when I add args(), but not this time -------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "oContainerWindow"
args1(0).Value = "True"
dispatcher.executeDispatch(document, ".uno:isMaximized", "", 0, args1())
Rem -------------------------------------

End sub
OpenOffice 4.1.5 on Mac El Capitan(10.11.6) and MS Windows10
alf50
 
Posts: 97
Joined: Sun Jun 13, 2010 2:55 pm

Re: OOo Calc macro to Maximize a window

Postby FJCC » Wed Aug 17, 2011 4:08 am

Here is a file with my original macro. If I open it at less then full size and then click the button on Sheet1, the Calc window fills the screen. Does it work for you?

The dispatcher commands are poorly documented. A list is here but note that it is for OOo 2.X, showing how old it is.
Attachments
FullSize.ods
(9 KiB) Downloaded 268 times
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7360
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: OOo Calc macro to Maximize a window

Postby alf50 » Wed Aug 17, 2011 5:16 am

FJCC,

Your "FullSize.ods" does not work on the Mac using OS X 10.6.8 or my PC Laptop running MS Win7.

I am running OOo 3.2.1 on both the Mac and the PC. The 3.3 is unstable in WIndows 7.

Does this macro only work in 3.3?

I also tried running it under 3.3 on the Mac, the macro doesn't work there either.
OpenOffice 4.1.5 on Mac El Capitan(10.11.6) and MS Windows10
alf50
 
Posts: 97
Joined: Sun Jun 13, 2010 2:55 pm

Re: OOo Calc macro to Maximize a window

Postby FJCC » Wed Aug 17, 2011 6:17 am

I don't have access to a Mac. I don't know of any reason the macro wouldn't work with versions earlier than 3.3 or on a Mac. It isn't exactly fancy. I hope one of the volunteers with a Mac can take a look. If no one responds after a day or so, perhaps you could post a link to this thread in the Mac section of Setup and Troubleshooting
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7360
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: OOo Calc macro to Maximize a window

Postby MrProgrammer » Thu Aug 18, 2011 4:31 pm

alf50 wrote:I want this macro to … Maximize the the window to the remaining space. … This is equivalent to clicking the Green "+" Button in the upper Left Corner of the window.
In my experience this is not what the Zoom (green) button does. Try it in some applications. Sometimes it does maximize the window, sometimes it just makes the window a different (not maximized) size. Apple's help says "Click the green zoom (+) button in the top-left corner of the window to switch between a larger and smaller window size." and that doesn't mention "maximized'.

alf50 wrote:I have been looking for a solution for weeks without success.
You're spending too much time on this. Just get used to the way Mac's work. Personally, I also prefer the windows in all applications to be maximized but find that sometimes (not too often) I open a non-OOo application (say a PDF in Preview) and have to drag the window edges to make it larger. You can read about what others have done by searching the web (not this forum) for terms like: Mac Maximize Window Shortcut Button Size Full Screen Commmand etc. But note that there are some applications (like the Mac's Calculator) where it is impossible to maximize the window.

For OOo, specifically, I find that once you have manually maximized the window size, OOo remembers that and opens documents in maximized windows. So you don't need a button or macro after you've set it the first time.

If this answered your question please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800 on MacOS 10.14.6.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Moderator
 
Posts: 3873
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests