Bug 140711 - Adjusting Zorder of images causes changes to image index
Summary: Adjusting Zorder of images causes changes to image index
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsDevAdvice
Depends on:
Blocks: Z-Order
  Show dependency treegraph
 
Reported: 2021-02-28 11:15 UTC by Dave Green
Modified: 2024-01-12 13:41 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
A smaller example (18.18 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-03-03 03:48 UTC, John
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Green 2021-02-28 11:15:26 UTC
Description:
I have found (every time) if I attempt to alter the Zorder of an image it alters the index value of other images in the same Calc sheet making it impossible to reference the correct image. I can reference this by the fact that my image data is written to a spreadsheet at each image creation. Position, Index and Zorder are included. If for example I make an image invisible using this index data it is fine. However, if I should adjust the Zorder of any other image on the sheet and then attempt to make one invisible, the wrong image is turned invisible. I have tried to find some correlation in the offset between data and the altered index and it doesn't seem to make any sense. This is a major headache.

Steps to Reproduce:
1.Create a series of images on a Calc spreadsheet
2.Note their index numbers
3.Adjust Zorder of an image
4.Add an extra image or two
4.Note index numbers again and compare

Actual Results:
Results in my case are incorrect images going invisible, being in the wrong place, etc.

Expected Results:
It should have adjusted the Zorder accordingly and left the index numbers as they were


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Private Sub TLLayOneTile(psStartCell as String)
	Dim loCurrentCell as Object	
	Dim laArgs(3) as New com.sun.star.beans.PropertyValue
	Dim loDrawPage as Object
	Dim loImage as Object
	Dim liCount as Integer
	Dim llZ as Long
	loCurrentCell = moMapSheet.GetCellRangeByName(psStartCell)
    ThisComponent.CurrentController.Select(loCurrentCell)
	loDrawPage = ThisComponent.getSheets().getByName("Map").getDrawPage()
    laArgs(0).Name = "FileName"
   	laArgs(0).Value = msTLFullImageURL 
   	laArgs(1).Name = "FilterName"
   	laArgs(1).Value = "<All formats>"
   	laArgs(2).Name = "Style"
   	laArgs(2).Value = "Graphics"
   	moDispatcher.ExecuteDispatch(moDocument, ".uno:InsertGraphic", "", 0, laArgs()) 'declared at module level
   	miGVSqCursorX = UTGetCellCol(psStartCell)
   	miGVSqCursorY = UTGetCellRow(psStartCell)
   	miGVUnsavedImageCount = miGVUnsavedImageCount + 1
   	loImage = loDrawPage.GetByIndex(miGVUnsavedImageCount)
	If UTGetLayZOrder(miGVSqCursorX, miGVSqCursorY, "T") = -998 Or UTGetLayZOrder(miGVSqCursorX, miGVSqCursorY, "T") = -999 Then
  		llZ = loImage.Zorder
 	Else
		loImage.Zorder = UTGetLayZOrder(miGVSqCursorX, miGVSqCursorY, "T") 
	llZ = loImage.Zorder
  	EndIf
   	UTLockImagesMoveSize
   	TLWriteToLayDataSheet miGVSqCursorX, miGVSqCursorY, llZ
   	UTGetSquareCursorData(miGVSqCursorX, miGVSqCursorY, miGVSquareDataRoute)
    TLControlsHandling 1
End Sub
Private Function UTGetLayZOrder(piCol as Integer, piRow as Integer, psCaller as String) as Long
	Dim liI as Integer
	Do
		liI = liI + 1
		If moLayDataSheet.GetCellByPosition(0, liI).String = "" Then
			UTGetLayZOrder = -999 'Flag to show that NO terrains have been placed yet
			Exit Do
		EndIf
		If moLayDataSheet.GetCellByPosition(0, liI).String = Trim(Cstr(piCol)) _
		And moLayDataSheet.GetCellByPosition(1, liI).String = Trim(Cstr(piRow)) Then
			If psCaller = "T" And moLayDataSheet.GetCellByPosition(12, liI).String = "" Then
				UTGetLayZOrder = -998 'Flag to show that a terrain has not been placed HERE yet
				Exit Do
			EndIf
			Select Case psCaller
			Case "T"
				UTGetLayZOrder = Clng(moLayDataSheet.GetCellByPosition(12, liI).String)
			Case "U"
				UTGetLayZOrder = Clng(moLayDataSheet.GetCellByPosition(13, liI).String)
			Case "R"
				UTGetLayZOrder = Clng(moLayDataSheet.GetCellByPosition(14, liI).String)
			Case "D"
				UTGetLayZOrder = Clng(moLayDataSheet.GetCellByPosition(15, liI).String)
			Case "L"
				UTGetLayZOrder = Clng(moLayDataSheet.GetCellByPosition(16, liI).String)	
			End Select
			Exit Do
		EndIf
	Loop														
End Function
Comment 1 John 2021-03-03 03:46:28 UTC
I believe I've confirmed this behavior with a smaller example, will attach. The results of GetByIndex() are intimately related to the Zorder.

I'm having a hard time figuring out the intended ordering by reading here:

https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1drawing_1_1DrawPage.html

Perhaps there is a better documentation to look at.
Comment 2 John 2021-03-03 03:48:23 UTC
Created attachment 170188 [details]
A smaller example

Click the form button and some Zorder properties will change pseudorandomly, each time filling out a cell with an indication of which image is in that index (text based on where it used to be)
Comment 3 Stéphane Guillou (stragu) 2024-01-12 12:55:57 UTC
Reproduced in recent trunk build:

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 3cb1ed4339fc9aec414c0f112a69705a7a4d9cc6
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Same on OOo 3.3.
Comment 4 Stéphane Guillou (stragu) 2024-01-12 13:41:05 UTC
Discussion with vmikos on IRC suggests it is expected that modifying the Z order changes the indices, which is the behaviour since OOo times.
As an alternative, maybe assign fixed names to objects?