Their size revert, but why?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Their size revert, but why?

Post by arfgh »

hello there.
I want to resize some text controls depending of the content of the the data source that feed them.
I was doing it with shape, but that is produccing a strange blink in the whole form controls, very disturbing.
So i tried to resize the text controls by other:

Code: Select all

	Dim controller As Object, Ctl As Object, CtlModel As Object, Shape As Object, PreferredSize As New com.sun.star.awt.Size
	controller = ThisComponent.GetCurrentController()
	Shape = ThisComponent.getDrawPage().getByIndex(0)
	Ctl = Shape.control
	CtlModel = controller.getControl(Ctl)
	
	PreferredSize = CtlModel.PreferredSize
	PreferredSize.Width = Shape.Size.Width
	PreferredSize.Height = ((UBound(content) + 1) * 17) * 25

	Dim size As New com.sun.star.awt.Size
	size.Width = int(PreferredSize.width / 26.5)
	size.Height = int(PreferredSize.Height / 26.5)
	CtlModel.setOutputSize(size)
	
	'Shape.SetSize(PreferredSize) 'works but with the blinking in all label controls and image controls
And works. But the most strange is that, after 2 seconds all the altered size controls back automatically to their original size. How is that possible ?
Am I missing something ?

thx in advance

 Edit: Changed subject, was Their size changes! 
Make your post understandable by others 
-- MrProgrammer, forum moderator 
Last edited by MrProgrammer on Sat Apr 08, 2023 10:53 pm, edited 1 time in total.
Reason: Edited topic's subject
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Their size revert, but why ?

Post by arfgh »

bump
resize text control via 'CtlModel.setOutputSize(size)' is ultra fast and causes no anomalies in the other form controls. But size will revert in 1 or 2 seconds without any reason.

Doing it via Shape, works, but soooo slow, and causing blinks in all label and image controls, other than the text controls.
It should exist a reason for this...
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Their size revert, but why ?

Post by JeJe »

If you post a document showing the problem it might help someone provide an answer. At the moment you're expecting people to recreate a document with text controls, guessing the right type of text control and document and with a data source for the textboxes, and then add your code and make it a sub because your code isn't complete - a lot a work you should be doing for people if you want some help.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Their size revert, but why?

Post by arfgh »

no, the code is fully exposed.
For some reason setting the text control using that method will revers to the control original size in 1 or 2 seconds... very strange, and the problem is that way is very speedy in comparisson with shape setSize method....
OpenOffice last version | Mageia Linux x64 | Ubuntu Linux | Windows 8.1 Enterprise x64 | Java last version
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Their size revert, but why?

Post by JeJe »

You got no help.
You bumped it up and you still got no help.
I suggested you make it easier for people to help you. You wait 2 weeks, say "no"

Up to you...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Their size revert, but why?

Post by RPG »

arfgh wrote: Sat Apr 01, 2023 12:28 am I was doing it with shape, but that is produccing a strange blink in the whole form controls, very disturbing.
Maybe you have to use lock and unlock the controllers with

Code: Select all

thiscomponent.lockcontrollers
your code what change the controls/shape
thiscomponent.unlockcontrollers
see Disable screen updates during macro execution
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Their size revert, but why?

Post by Zizi64 »

Am I missing something ?
Please upload your ODF type sample file here.
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.
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Their size revert, but why?

Post by arfgh »

for some reason the problem is about the grouping controls feature. Whith a big group of controls in the document the accesiing of the controls shape is much slower than without group. Even more, for unknow reasons that i dont know, some times the problem goes further having an ultra-slow reading of control shapes, and when that ultra-slow is happening i can only back to the regular speed ungrouping all controls. When this is happening it is that slow, that you can see how a painted shape is changing the color very slowly until it completes. Even it is visible some kind of drawing of all elements that is working very slow :(

The visual problem i am referring with this is that when we modify the controls shape size, to adapt its size for more lines of content, that is causing a visual blink of controls in the whole document, specially noticeable in labels and image controls. But this is not happening without the grouping. Probably all this is a bug, but when i tested the same in my linux distro i have seen how that grouped controls access to their shape is very very speedy in comparisson with the windows version of AOO....

Please, do not say about to dont have controls group because that feature is very important in the design...

Other than the possible bug, trying to change the control size via model and setOutputSize() it is very fast, but the controls changed by that way revert fast to the original size. I have found this interesting trick:

Code: Select all

					size.Width = int(CSize.width / 26.5)
					size.Height = int(CSize.Height / 26.5)
					CtlModel.setOutputSize(size)
					CtlModel.draw(CtlModel.posSize.x, CtlModel.posSize.y)
that require a previous settings of: CtlModel.setDesignMode(true) in order to stay the new size. But this is just curios because this causes other problems in the controls, like the tabs order, etc.

RPG that solution of yours helps for when it is happening that ultra-slow bug.

Code: Select all

thiscomponent.lockcontrollers
your code what change the controls/shape
thiscomponent.unlockcontrollers
But the visual issue remains happening. And that ultra-slow bug is not clear why is happening sometimes when grouping controls, but not others doing same... It's very strange !
Last edited by arfgh on Mon Apr 24, 2023 6:41 pm, edited 2 times in total.
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: Their size revert, but why?

Post by RPG »

I have read your story but it looks me not important. Maybe it can prove you do follow the rules.

Maybe you can study some builtin macro's. They are builtin for ApacheOffice and LibreOffice with the same names and libraries.
they are in the Library "Tools" and the module "ModuleControls"
I believe you need the macro: GetControlShape
' Take care that the libraries are loaded before you call them

I do use it in the following way

Code: Select all

GetControlShape(thiscomponent,"Tekstvak 1").setsize(size)
For your information this is the explanation of the purpose of the macro.
Libreoffice tell this:
' Gets the Shape of a Control( e. g. to reset the size or Position of the control
' Parameters:
' The 'oContainer' is the Document or a specific sheet of a Calc - Document
' 'CName' is the Name of the Control
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Their size revert, but why?

Post by arfgh »

the use of that 'getControlShape' wont differs on what i am explaining. The problem is happening when using a group of controls. And the ultra-slow problem that is appearing sometimes, i dont know why happens, but lockcontrollers fixes it.
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: Their size revert, but why?

Post by RPG »

I think when you want change the size of the shape which belong to a control in a form than you have only to change the size of the shape. It seems to me there is no reason to bring the form in designmode but you can can other reason for it.

There you have grouped the controls it is more difficult to enter the shape. Grouped controls are also grouped shapes and they are in a container. You can see it as a directory in your OS.

I have not much experience of changing the size of controls in a databaseform. I have the idea that a databaseform are more for static use

I think try to understand how the shapes are organized in a drawpage. Give grouped shapes a name what makes it more easy and faster to search.
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Their size revert, but why?

Post by arfgh »

RPG wrote: Tue Apr 25, 2023 10:59 am There you have grouped the controls it is more difficult to enter the shape. Grouped controls are also grouped shapes and they are in a container. You can see it as a directory in your OS.
not necessarily more difficult, just getting by index into, and you got into the group. But there is where the visual blink is appearing. If you alter any control shape on that group, the blink will happen. One blink in all labels and all images per control shape change. Without group of control this is not happening.

I think that the shape controls handle, by some way, is not well optimized in the windows version of AOO... since i saw the linux version so far speedy in comparisson.... For that reason i wanted to change their size by that other way... without a real success.
RPG wrote: Tue Apr 25, 2023 10:59 am I think try to understand how the shapes are organized in a drawpage. Give grouped shapes a name what makes it more easy and faster to search.
Just that is precissely what i am doing. But even more, i have arrays of objects to speed up all this...

Anyways RPG thx a lot to say about lockcontrollers, that is helping so much !! The ultra-slow window redrawing is solved by this :)
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: Their size revert, but why?

Post by RPG »

I have read that you ,Arfgh , are satisfied with the (un)lockcontrollers but I did want better understand more of the complete awt module of OpenOffice.

I do have the idea that part of the problem you can have is a timing problem. You change more then one control in your BASIC code as I understand. When you do change the size of some part of a control then OpenOffice have to change more things then we do in the BASIC code. When we insert a wait command then OpenOffice does get sometime to make the control in the way we want have. It can be that not all controls need the same time to wait. Also it is possible that BASIC is not restart when OpenOffice is doing his work. I mean the wait result is in effect bigger then we asked.

The wait command does not stopped the computer with working it only stopped the current BASIC program. This means OpenOffice can do the real resizing of the object.
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Their size revert, but why?

Post by arfgh »

no, this is some kind of visual bug, that is specially noticeable if the altered size controls are into a group. Other than the visual bug, the iteraction with the controls into that group is kinda slow. And for that reason i wanted to resize them using that other way, but that other seems to be for design mode, or i dont know !

Unfortunatelly i go to need to ungroup the controls and think in other kind of design... But the groups solution is very good in order to perform auto-centering of elements... sad :(
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: Their size revert, but why?

Post by RPG »

The grouping of the control makes it difficult for what you want. It is not only for the programming but I have the idea it cost more time for doing all the work and there it is not implemented you have to do all the programming. It is possible that it is more easy with LibreOffice and also with ApacheOffice under Linux.

I think when you change your design then you see always a little flickering. This flickering is less when your form is good designed and maybe it is not a good idea to it in a database.

Maybe you should not grouped your controls but add your controls in a groupbox or frame. When you group your controls then OpenOffice see it as a single shape containing other shapes.
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
arfgh
Posts: 566
Joined: Tue Mar 05, 2013 6:44 pm

Re: Their size revert, but why?

Post by arfgh »

^^ but that frame in AOO is not acting as the frame control in other languages, that is as a container. Conforming i have read about the frame control, it acts only as a visual frame, not like we want in this case.

And yes, the proper term to define the visual anomaly is flickering. I called it blinking...

A good solution in this case will be to achieve the resize via model like i explained here. It is ultra fast, and causes no flickering in the other form controls. But the controls that we change that way, revert to their original size, sometimes very fast, other times around 1 second later....
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: Their size revert, but why?

Post by RPG »

arfgh wrote: Sun May 07, 2023 2:29 pm but that frame in AOO is not acting as the frame control in other languages, that is as a container. Conforming i have read about the frame control, it acts only as a visual frame, not like we want in this case
I suppose you mean the groupbox is not a container for something. I believe you are right. As far I know the groupbox is only for what see you not any thing else.

But when you need a container for some controls then maybe an other idea can help you. I use several time the Interface XTabControllerModel. It is easy give the controls the same name. The controls must have the same name and must be in the same form as you see in the form-navigator.

I have not found an easy method to resize a control in a working model. I can work for a single control but not for a lot of controls. I think we have to work with listeners and I'm not succeed with that idea.
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Their size revert, but why?

Post by RPG »

It seems to me that the way I follow is only stable when all controls are on screen and visible. If they are not on screen and visible then the problems are rising and change from time to time.
I think it is not a good idea to change the size of the controls in your database form. I do learn this from all the testing special on the moment when I add more controls to the form.
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Post Reply