[Solved] Is there a way to disable screen updating/redrawing

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
frozbie
Posts: 15
Joined: Thu Sep 18, 2008 10:25 am

[Solved] Is there a way to disable screen updating/redrawing

Post by frozbie »

Hi,

I am working on optimizing some existing StarOffice 8 (PU10) basic macros. In addition to tidying up the code, converting recorded code to a standard format and trimming unneeded routines, I am wondering if there is a StarOffice/OpenOffice version of Application.ScreenUpdating from Microsoft Excel.

As you will know, setting this to false in Excel VBA turns off Excel screen updating while the code runs and often substantially speeds up the code.

I've had a search through this forum using terms like screen updating, refresh, speed but am drawing a blank. maybe I'm just using the wrong search terms. Also tried looking through the developers manual but cannot see anything in the contents or index.

Would anyone be able to point me in the right direction or would you know if this is possible?

Thank you,

Regards

Mark
Last edited by frozbie on Thu Oct 16, 2008 11:22 am, edited 1 time in total.
User avatar
probe1
Volunteer
Posts: 277
Joined: Mon Oct 08, 2007 1:34 am
Location: Chonburi Thailand

Re: Is there a way to disable screen updating/redrawing

Post by probe1 »

Mark,

standard question - standard answer:
There is no equivalent.

You can "lock" controllers, so that "not every data update" is send to screen

Code: Select all

ThisComponent.LockControllers
' then do something
ThisComponent.UnlockControllers
Sometimes (if code is working longer with document) it's better to hide the whole document and show it after work has finished; e.g. code to show a hidden document:

Code: Select all

oDoc.getCurrentController().getFrame().getContainerWindow().Visible= TRUE

Does this help?
Cheers
Winfried

DateTime2 extension: insert date, time or timestamp, formatted to your needs
User avatar
frozbie
Posts: 15
Joined: Thu Sep 18, 2008 10:25 am

Re: Is there a way to disable screen updating/redrawing

Post by frozbie »

Probe1,

That is helpful, thanks. I'll run some tests using both these methods and post back results.

Regards

Mark
OOo 3.0.X on MS Windows Vista + Windows XP
User avatar
frozbie
Posts: 15
Joined: Thu Sep 18, 2008 10:25 am

Re: Is there a way to disable screen updating/redrawing

Post by frozbie »

Thought it was about time I updated this post.

Winfried, your help has been invaluable! Using a combination of both methods, I've cut down a pdf report generation and emailing macro from a run time of 4 hours to run in 8 minutes! A macro that was looking up data from an intranet site, formatting and moving formulas around cut down from 70 minutes run time to 15 minutes.

Tested on following systems:

Tests run on Intel Core 2 DUO 2 Ghz; with 2GB RAM; in UK over Wireless LAN and VPN; Using Vista Ultimate; StarOffice 8 PU10

Also on Intel Core 2 DUO 1.8 Ghz; with 2GB RAM; in Brazil over Wireless LAN and VPN; Using Vista Home; StarOffice 8 PU10

Similar results on both systems.
Although I warned a colleague, he was a bit freaked out when his StarOffice window and the task bar icon disapeared. Worth emphasising this when distributing macros using this method.

While testing, I had to interupt the code at one point and then was left with no visible window to work with. Forced me to do some more research and wrote a macro to show all hidden StarOffice windows. Below:

Code: Select all

Function fnSetDocToVisible()
	'// will set all open StarOffice documents to visible
	'// uses code taken from 
	'// http://wiki.services.openoffice.org/wiki/Currently_open_documents
    '// returns an string array of open document titles.
dim oEnum as object, oPosDoc as object, i as integer
dim oListboxDocs as object
dim mTitles() as string
dim mDocs() 
oEnum = StarDesktop.getComponents.createEnumeration

'// iterate over all open StarOffice Documents
i = -1
while oEnum.hasMoreElements
	oPosDoc = oEnum.nextElement
'// if document set to hidden then make visible
'// and return names of all hidden documents
    i = i + 1
	redim preserve mDocs(i)
	redim preserve mTitles(i)
	mDocs(i) = oPosDoc
   	mTitles(i) = oPosDoc.getCurrentController.getFrame.getPropertyValue("Title")
	mDocs(i).getCurrentController().getFrame().getContainerWindow().Visible= TRUE
wend
fnSetDocToVisible = mTitles()
End Function
Bit basic but you could put this in a stand alone calc module and run if you needed to.

Mark
OOo 3.0.X on MS Windows Vista + Windows XP
User avatar
GregMcC
Posts: 12
Joined: Thu Oct 29, 2009 1:29 pm
Location: Liverpool, UK

Re: Is there a way to disable screen updating/redrawing

Post by GregMcC »

Thanks for the feedback of your results
__GregMcC - Liverpool UK
__o-----------------------o
_OpenOffice 3.3 on Vista32
Post Reply