How do I detect if the screen is in fullscreen?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
aengelriv
Posts: 10
Joined: Fri Sep 08, 2017 5:47 am

How do I detect if the screen is in fullscreen?

Post by aengelriv »

Greeting

with code

Code: Select all

dim document   as object
dim dispatcher as object		
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FullScreen"
args1(0).Value = TRUE
dispatcher.executeDispatch(document, ".uno:FullScreen", "", 0, args1())
---- go to see screen in fullscreen

¿but, how can you detect if the screen is in fullscreen mode ?
with what lines of code?

thanks!
Llibreoffice 4.4 windows/Puppylinux
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How do I detect if the screen is in fullscreen?

Post by Zizi64 »

viewtopic.php?f=9&t=43318

Your macro was created wiht the Macrorecorder. But you need study the API functions if you want WRITE your macros. That method is much more efficient than the Macrorecorder.
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.
aengelriv
Posts: 10
Joined: Fri Sep 08, 2017 5:47 am

Re: How do I detect if the screen is in fullscreen?

Post by aengelriv »

thanks!
excuse my english
but, I do not need ismaximize status
I need to know the fullscreen status of the window
obviously i need to use the API in my macro

I search with "mri" but I can not find how to search the fullscreen status
especially to locate the status of args1(0).Value = TRUE (or False) in

how to know if it is in True o False the status of Fullscreen

with

Code: Select all

mri Thiscomponent.CurrentController.ViewSettings
i dont localized Fullscreen property
But you need study the API functions if you want WRITE your macros
I searched in google on fullscreen but I do not find anything and that's why I come to this forum
again, with what code detect the fullscreen status
Thanks again!
Llibreoffice 4.4 windows/Puppylinux
aengelriv
Posts: 10
Joined: Fri Sep 08, 2017 5:47 am

Re: How do I detect if the screen is in fullscreen?

Post by aengelriv »

regards
for interested

after searching googling and much experimenting, I found an alternative to fullscreen
That is, it runs the same

Code: Select all

Sub FullScreen_with_LayoutManager
  isview=ThisComponent.CurrentController.Frame.LayoutManager.isVisible()
  if isview="True" then
	  '  emulates a fullscreen
	  ThisComponent.CurrentController.Frame.LayoutManager.setVisible(FALSE)
  else
   '  came back normal screen
	  ThisComponent.CurrentController.Frame.LayoutManager.setVisible(True)
end if
End Sub
Last edited by aengelriv on Sat Sep 16, 2017 7:09 pm, edited 1 time in total.
Llibreoffice 4.4 windows/Puppylinux
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: How do I detect if the screen is in fullscreen?

Post by RusselB »

You have an endif at the bottom of your code with no corresponding if
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How do I detect if the screen is in fullscreen?

Post by Lupp »

What about

Code: Select all

REM  *****  BASIC  *****

Function contWinSize()
theFrame = ThisComponent.CurrentController.Frame
fa = CreateUnoservice("com.sun.star.sheet.FunctionAccess")
contWinSize = fa.CallFunction("COMPLEX", _
                           Array(theFrame.ContainerWindow.PosSize.Width, theFrame.ContainerWindow.PosSize.Height)
End Function

Function compWinSize()
theFrame = ThisComponent.CurrentController.Frame
fa = CreateUnoservice("com.sun.star.sheet.FunctionAccess")
compWinSize = fa.CallFunction("COMPLEX", _
                           Array(theFrame.ComponentWindow.PosSize.Width, theFrame.ComponentWindow.PosSize.Height)
End Function

Function isFullScreen()
If contWinSize() = compWinSize() Then
    isFullScreen = 1
Else
    isFullScreen = 0
End If
End Function
Or do you know a case where the ContainerWindow and the ComponentWindow have same size - except the FullScreen case?

A bit clearer, probably:

Code: Select all

Function contWinSize(p)
theContWin = ThisComponent.CurrentController.Frame.ContainerWindow
fa = CreateUnoservice("com.sun.star.sheet.FunctionAccess")
contWinSize = fa.CallFunction("COMPLEX", Array(theContWin.PosSize.Width, theContWin.PosSize.Height)
End Function

Function compWinSize()
theCompWin = ThisComponent.CurrentController.Frame.ComponentWindow
fa = CreateUnoservice("com.sun.star.sheet.FunctionAccess")
compWinSize = fa.CallFunction("COMPLEX", Array(theCompWin.PosSize.Width, theCompWin.PosSize.Height)
End Function

Function isFullScreen()
If contWinSize() = compWinSize() Then
    isFullScreen = 1
Else
    isFullScreen = 0
End If
End Function
Last edited by Lupp on Tue Sep 19, 2017 12:29 am, edited 2 times in total.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How do I detect if the screen is in fullscreen?

Post by Villeroy »

The correct function name is com.sun.star.sheet.addin.Analysis.getComplex
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
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How do I detect if the screen is in fullscreen?

Post by Lupp »

Yes. Nonetheless I just tested and the FunctionAccess services of LibO V5.4.1 and of AOO V4.1.3 as well were able to execute the function called by "COMPLEX".
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How do I detect if the screen is in fullscreen?

Post by Villeroy »

Strange. I have to call it by the full add-in name. LO 5.4.1 on Windows 10 right now. Otherwise I get a "no such element" exception.
The full screen detection works fine.
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
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How do I detect if the screen is in fullscreen?

Post by Lupp »

Strange, yes. Probably my UI-language and locale being both 'English (UK)'? Not very likely I admit.
(Cant do further tsting now. Off for two days.)
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
aengelriv
Posts: 10
Joined: Fri Sep 08, 2017 5:47 am

Re: How do I detect if the screen is in fullscreen?

Post by aengelriv »

Hi
A)
In my calc shows the following error
com.sun.star.container.nosuchelementexception
in the line
contWinSize = fa.CallFunction("COMPLEX", _
maybe missing COMPLEX Function??
I use LibreOffice 4.4.7.2 in Puppy tahrpup version 6.0.6
''-----------------------------------------------------
well, With the 'Lupp' user code (spreadsheet)
I maked adaptation for Writer of the Fullscreen

Code: Select all

Sub FullScreen_with_LayoutManager_writer

	 xFrame=ThisComponent.CurrentController.Frame	
	 Height_Component=xFrame.ComponentWindow.PosSize.Height
	 Width_Component=xFrame.ComponentWindow.PosSize.Width
	 Height_Conteiner=xFrame.ContainerWindow.PosSize.Height
	 Widht_Conteiner=xFrame.ContainerWindow.PosSize.Width 
	 
	 if Height_Component=Height_Conteiner and Width_Component=Widht_Conteiner then
	    isFullScreen = 1
	 Else
	    isFullScreen = 0 
 	endif 	
	'msgbox  isFullScreen	
end sub
Could this macro (writer) be equivalent to the version of the Lupp code for spreadsheet ??
. [[[-- work in calc too!! ]]]
B)
a little didactics :?
What is the difference between ComponentWindow and ContainerWindow?
excuses for my English :oops:
Thanks!
Llibreoffice 4.4 windows/Puppylinux
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: How do I detect if the screen is in fullscreen?

Post by JohnSUN-Pensioner »

aengelriv wrote: What is the difference between ComponentWindow and ContainerWindow?
IMHO approximately so
SomeWindows.png
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
aengelriv
Posts: 10
Joined: Fri Sep 08, 2017 5:47 am

Re: How do I detect if the screen is in fullscreen?

Post by aengelriv »

regards
thank you for your insight, then (excuse my doubt :oops: )
the internal area would be componentwindow?
the external area would be containerwindow?
Thank you again!
Llibreoffice 4.4 windows/Puppylinux
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: How do I detect if the screen is in fullscreen?

Post by JohnSUN-Pensioner »

Hmm... I'm also doubt... What about the Developers Guide? I think they need to know for sure. ;)
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How do I detect if the screen is in fullscreen?

Post by Zizi64 »

the internal area would be componentwindow?
the external area would be containerwindow?
Display the values in the macro with a MsgBox (or the Print command). When the window sizes are not equals, you can determine which is the smaller and which is the larger...
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.
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How do I detect if the screen is in fullscreen?

Post by Lupp »

A few additional comments.

-1- (@Villeroy mainly:) I tested again, and I cannot help. LibO V 5.4.1 and AOO V4.3.1 both cretae FunctionAccess service objects for me which are able to CallFunction the COMPLEX function by its short name. No idea concerning the different behaviour of systems/installations insofar.
-2- Using the above posted functions in spreadsheet cells suffers (as with many functions relying on objects) from the fact that recalculation OnOpen is already started in advance of the completion of the initialization. The ComponentWindow included with the Frame of an open document e.g. may not yet be initialized when a function trying to access it is called. Errors of type Object variable not set may occur. In LibO I also got the case that no errors were thrown, but a ComponentWindow size of 0+0i was returned.
-3- LibO Calc and AOO Calc both do not recalculate the volatile functions when toggling the FullScreen mode or otherwise changing the window size. They cannot be used for triggering the recalculation of cell formulas in the context discussed here. (Strange to me!)
-4- A FunctionAccess service as I used it is created by the UnoRE, not by the component or a dependent object. You can create and use it in the context of any document under LibO or AOO. In specific you can supply capabilities implemented by standard functions of Calc to any kind of document.
-5- To return the window sizes as complex values was a choice of mine considering the fact that there are two relevant numeric values closely paired. Of course it can be done in different ways. And if the format is used, we can easily achieve the composition without using the COMPLEX function of Calc. Respectively for the positions.
-6- The 'Find' toolbar behaves differently in LibO and in AOO concerning the FullScreen mode. In AOO it persists if enabled. In this case the ComponentWindow.Height remains less than ContainerWindow.Height - except the 'Find' toolbar is not docked (floating). Checking for this mode by user code we have to regard this fact. I originally use LibO where the 'Find' toolbar is abandonend in FullScreen like any toolbars even if floating.

Also see demo.
Attachments
aoo90280isFullScreen.odt
(14.27 KiB) Downloaded 166 times
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How do I detect if the screen is in fullscreen?

Post by Villeroy »

It's a mystery. All my AOO/LO installations on LInux and Windows insist in the full name "com.sun.star.addin.Analysis.getComplex"
aengelriv wrote:In my calc shows the following error
com.sun.star.container.nosuchelementexception
replace COMPLEX with com.sun.star.sheet.addin.Analysis.getComplex
 Edit: Sorry, forgot the sheet. 
Last edited by Villeroy on Thu Sep 21, 2017 11:56 pm, edited 1 time in total.
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
aengelriv
Posts: 10
Joined: Fri Sep 08, 2017 5:47 am

Re: How do I detect if the screen is in fullscreen?

Post by aengelriv »

Hello
in writer .. error
with COMPLEX
and ... replace COMPLEX with com.sun.star.addin.Analysis.getComplex, too
in Calc error.. too
Attachments
error.png
Llibreoffice 4.4 windows/Puppylinux
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How do I detect if the screen is in fullscreen?

Post by Villeroy »

Sorry, replace COMPLEX with com.sun.star.sheet.addin.Analysis.getComplex

You get the full name of certain functions that are not part of the Open Document standard like this:
1. Enter a valid function call into a cell, e.g. =COMPLEX(1;2)
2. Query the formula property of that cell


A macro to get/set the English formula of the active cell as it is stored in the ods document, including a function to get the active cell of a spreadsheet view:

Code: Select all

Sub showENFormula
Dim oView,oCell as object,sFml$
   oView = thisComponent.CurrentController
   oCell = getActiveCell(oView)
   sFml = oCell.getFormula()
   sFml = inputbox("Unlocalized Formula of Focussed Cell:","showENFormula",sFml)
   if sFml <> "" then oCell.setFormula(sFml)
End Sub
Function getActiveCell(oView)
Dim as1(), lSheet&,lCol&,lRow$, sDum as String,bErr as Boolean
   as1()  = Split(oView.ViewData, ";")
   lSheet = CLng(as1(1))
   sDum = as1(lSheet +3)
   as1() = Split(sDum, "/")
   on error goto errSlash
      lCol = CLng(as1(0))
      lRow = CLng(as1(1))
   on error goto 0
   getActiveCell = oView.Model.getSheets.getByIndex(lSheet).getcellByPosition(lCol,lRow)
exit Function
errSlash:
   if NOT(bErr) then
      bErr = True
      as1() = Split(sDum, "+")
      resume
   endif
End Function
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
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How do I detect if the screen is in fullscreen?

Post by Lupp »

@aengelriv
Did you note that I included code completely avoiding the usage of Calc functions? Simply omit the two functions based on FunctionAccess and the parts of the Sub callimg them. I only included this part with respect to earlier posts in this thred.
The replacing functions do not contain any problematic code. No errors expected insofar!
See new attachment.
aoo90280isFullScreen.odt
(13.41 KiB) Downloaded 141 times
@Villeroy
Yes, your code is surely useful, and I didn't know that way to get the cell under focus. Thanks. In fact I get the fully qualified names for the functions under discussion this way, but
You get the full name of certain functions that are not part of the Open Document standard like this:
The (pseudo-) type Complex and many related functions are specified in the respective OpenFormula document
http://docs.oasis-open.org/office/v1.2/ ... -part2.odt under "4.4 Complex Number" and under
"2.3.4 OpenDocument Formula Large Group Evaluator"
COMPLEX 6.8.2 ; IMABS 6.8.3 ; IMAGINARY 6.8.4 ; IMARGUMENT 6.8.5 ;
IMCONJUGATE 6.8.6 ; IMCOS 6.8.7 ; IMCOT 6.8.9 ; IMCSC 6.8.10 ; IMCSCH 6.8.11 ; IMDIV
6.8.12 ; IMEXP 6.8.13 ; IMLN 6.8.14 ; IMLOG10 6.8.15 ; IMLOG2 6.8.16 ; IMPOWER 6.8.17 ;
IMPRODUCT 6.8.18 ; IMREAL 6.8.19 ; IMSEC 6.8.22 ; IMSECH 6.8.23 ; IMSIN 6.8.20 ; IMSQRT
6.8.24 ; IMSUB 6.8.25 ; IMSUM 6.8.26 ; IMTAN 6.8.27

On the other hand the recently (in LibO) impemented functions CONCAT and TEXTJOIN have internal qualified names containing the 'MicroSoft' key in one place. (I haven't them at hand at the moment.) They are not specified by OpenFormula and only implemented under the general clause for compatibility with Excel. These functions are shown for me by your code with their short names.

The mystery doesn't just persist. It is growing.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: How do I detect if the screen is in fullscreen?

Post by arfgh »

JohnSUN-Pensioner wrote:
aengelriv wrote: What is the difference between ComponentWindow and ContainerWindow?
IMHO approximately so
SomeWindows.png
so in the ComponentWindow should be some property or methor to control the scrollbar, because they appears into that ComponentWindow part.
But i cant locate how...

anybody know ?
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: How do I detect if the screen is in fullscreen?

Post by RPG »

Maybe this code can help you a little. I do not know if it works alway.

Romke

Code: Select all

sub isfullscreen
dim oContainerwindow
oContainerwindow=thiscomponent.getCurrentController.getFrame.getContainerWindow
print  oContainerwindow.IsMaximized,oContainerwindow.IsMinimized
if  oContainerwindow.IsMaximized=false and oContainerwindow.IsMinimized=false then 
	print "Fullscreen"
else print "Not fullscreen"
end if
end sub
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How do I detect if the screen is in fullscreen?

Post by Lupp »

I just tested the above suggested code with AOO 4.1.3 and with LibO 5.4.2 (Calc and Writer) under Win10.
With both these office applications the returned results were independent of whether the document was switched to full screen or not.
AOO 4.1.3 always returned False, False, "Fullscreen".
LibO 5.4.2 always returned True, False, "Not fullscreen".

The reworked code recommended by me in a previous post, but only included in a demo there, is as follows (Expand view!):

Code: Select all

Function isFullScreen()
If contWinSize() = compWinSize() Then
    isFullScreen = 1
Else
    isFullScreen = 0
End If
End Function

REM Windows sizes are 2D. To return them as simple results the string format 
REM for complex numbers was used with:
REM Width coded as the REAL and Height coded as the IMAGINARY component.
REM The standard functions IMREAL and IMAGINARY of Calc are applicable. 

Function contWinSize()
theDoc = ThisComponent
theCC  = theDoc.CurrentController
theFrame = theCC.Frame
theContWin = theFrame.ContainerWindow
contWinSize = "" & theContWin.PosSize.Width & "+" & theContWin.PosSize.Height & "i"
End Function

Function compWinSize()
theDoc = ThisComponent
theCC  = theDoc.CurrentController
theFrame = theCC.Frame
theCompWin = theCC.ComponentWindow
compWinSize = "" & theCompWin.PosSize.Width & "+" & theCompWin.PosSize.Height & "i"
End Function
Last edited by Lupp on Tue Oct 17, 2017 3:03 pm, edited 1 time in total.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: How do I detect if the screen is in fullscreen?

Post by arfgh »

other possible way is to check the frame.containerWindow resolution, and if match desktop resolution.....
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: How do I detect if the screen is in fullscreen?

Post by RPG »

@Lupp
When I placed the short macro I did have tested it with several documents open at the same time and I did get the good result when some are fullscreen and other are not fullscreen. Maybe the test is not good enough there I have normally only screens maximized. Now I have a screen minimized between other maximized screens and one Fullscreen. I do not get the good results. But it is not only the difference between the screens. There is somethings what is also important but I do not know. In short: sometimes it is working sometimes it is not working

Before I did see the good results and now I do not see the good results. It is not only the minimized screen what is the problem there is more. I did use the same code. So maybe I have to look more when I think I want do it but it, is not important for me. It did learn me a little more about frames.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Post Reply