Bug 146426 - Dynamically (macro) added controls to form x position ignored (Libre Base EDITING)
Summary: Dynamically (macro) added controls to form x position ignored (Libre Base EDI...
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.2.3.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2021-12-26 17:56 UTC by Leslie
Modified: 2021-12-29 11:36 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
base file that shows bug (11.55 KB, application/vnd.sun.xml.base)
2021-12-26 17:57 UTC, Leslie
Details
Base file showing bug (12.47 KB, application/vnd.sun.xml.base)
2021-12-26 21:31 UTC, Leslie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Leslie 2021-12-26 17:56:43 UTC
Description:
Controls added to a form by macro cannot be positioned along the x axis. The value given to the control model is ignored and subsequent calls to setPosSize() are also ignored and the control is locked to the position.   
If you go into edit mode and select that now added control you can drag it up and down but not left or right. 
The problem may be related to the default value of the controls anchor property.
The anchor value of the added control defaults to "as character". If in edit mode you manually change the anchor on the control to anything else you can move the control as normal.  
I have not found a way to change the anchor property of the control programmatically as the anchor property of the model is read only.   
Although this is a BASIC problem it only seems to relate to Libre Base. I believe it works as expected in Libre Calc.  


Steps to Reproduce:
1. create a data base
2. add a form 
3. write code to add a control to the form
4. code the position of the control 
5. run the code

Actual Results:
control is positioned on left edge of form

Expected Results:
control is positioned where the code assigns it


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.2.3.2 (x64) / LibreOffice Community
Build ID: d166454616c1632304285822f9c83ce2e660fd92
CPU threads: 4; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded
Comment 1 Leslie 2021-12-26 17:57:27 UTC
Created attachment 177147 [details]
base file that shows bug
Comment 2 Leslie 2021-12-26 21:31:38 UTC
Created attachment 177148 [details]
Base file showing bug

Open the base file and double click the testform to open the form. 
Then press the button.
Comment 3 Stang 2021-12-27 03:17:26 UTC
Sample works when anchor is changed after an instance of the control is created:

    oControlShape.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE

place after:

    sub AddControl(byref controlName as string, byref label as string, byref            oDocument as object, byref oDrawPage as object)  as object 
       dim oControlShape as object 
       dim aPoint as object, aSize as object, oModel as object
	 	
    oControlShape = oDocument.createInstance("com.sun.star.drawing.ControlShape")
Comment 4 Alex Thurgood 2021-12-27 09:05:34 UTC
@Leslie:

When testing with 
Version: 7.2.1.2 / LibreOffice Community
Build ID: 87b77fad49947c1441b67c559c339af8f3517e22
CPU threads: 8; OS: Mac OS X 10.16; UI render: default; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
Calc: threaded

If I press the push button repeatedly, I get a row of side-by-side text box controls filled with the word "test", until the width of the page is filled, at which point the next text box gets added underneath (presumably at a distance set by the control height or the paragraph parameters. The addition of subsequent text box controls follows the same pattern.

Is this what is supposed to happen ? 
If so, then I can't reproduce on macOS with the above version.
Comment 5 Alex Thurgood 2021-12-27 09:27:14 UTC
OK, so my bad, I thought that the problem was the positioning of multiple textbox controls via Basic.

Confirming.

I suspect that you are right about the default anchor attribute of "to character" instead of "to page".

I wouldn't be surprised if nobody really thought about the impact on Form designers, especially when using the Basic API.

Have a read of this:

https://bugs.documentfoundation.org/show_bug.cgi?id=99646

What is your setting under 
Tools > Options > LibO Writer > Formatting Aids > Image: Anchor ?

This can also be set in the Advanced Configuration Dialog :

Under Options > LibreOffice > Advanced > Expert Configuration ..
search for 'Anchor'
org.openoffice.Office.Writer > Content > Display

Value  | Anchor 
  0      FLY_TO_PARA
  1      FLY_TO_CHAR
  2      FLY_AS_CHAR

What are your configuration settings in this regard ?

I note that there is no default "to Page"...
Comment 6 Leslie 2021-12-28 04:05:02 UTC
As Stang wrote, it is possible to change the anchortype when the control is created and this seems to allow placement the control where it is coded.  
You can see this forum for more info: https://ask.libreoffice.org/t/libre-base-how-to-change-fixedtext-control-size-at-runtime/72015/16   
I am no longer of the opinion that this is a bug, just an unfortunate design choice. 
Therefore I am changing this to 'not a bug'.   
I have instead submitted a Request For Enhancement regarding this matter.  
You can find that here:
https://bugs.documentfoundation.org/show_bug.cgi?id=146442
Thank you for looking at it.