Bug 99541 - '.uno:GoToCell' call selects an entire column IF the target cell is in column C.
Summary: '.uno:GoToCell' call selects an entire column IF the target cell is in column C.
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.1.2.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Cell-Selection
  Show dependency treegraph
 
Reported: 2016-04-27 21:49 UTC by Fred Hamilton
Modified: 2025-12-06 06:09 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
buggy output on top, expected output on bottom (38.87 KB, image/png)
2016-04-27 21:49 UTC, Fred Hamilton
Details
python code to reproduce column bug in calc (2.26 KB, text/plain)
2016-04-28 20:04 UTC, Fred Hamilton
Details
macro suitable for launching from macro menu inside calc (2.25 KB, text/plain)
2016-04-28 20:21 UTC, Fred Hamilton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fred Hamilton 2016-04-27 21:49:26 UTC
Created attachment 124684 [details]
buggy output on top, expected output on bottom

Discovered while working on a python macro inside Calc (Ubuntu and Win10).  I have no idea whether it's a Calc bug or an uno bug or a...

Using Dispatcher to select a cell pointed to by string newcell (i.e. newcell = 'A3' for first column, third row) and then write the newcell value to the selected cell.  Snippet:

  # move pointer to cell 'newcell'
  oProp.Name = 'ToPoint' 
  oProp.Value = newcell
  properties = (oProp,) 
  dispatcher.executeDispatch( frame, '.uno:GoToCell', '', 0, properties )
		
  # Writes the (intended) cell location to that cell
  oProp.Name = 'StringName' 
  oProp.Value = newcell
  properties = (oProp,) 
  dispatcher.executeDispatch( frame, '.uno:EnterString', '', 0, properties )

If 'newcell' points to a cell in any column except column C (A3, B17, D2, etc.) then that cell is selected and the code works exactly as you'd expect.  

But if newcell points to any location in column C, an entire column is selected, and that column is determined by newcell's *row*.  So newcell = 'A3' selects cell A3.  But newcell = 'C1' selects *all* of column A.  newcell = 'C4' selects *all* of column D, etc.  It only appears to be column C (though I haven't tested it past column F).

Bug appears on LO 5.1.2.2 on both Ubuntu 16.04 and Windows 10, both 64 bit.

The full python macro (to be launched from inside calc) is below and I've attached the output it produces.  There's additional code below (not in the snippet above) that is supposed to change 5 cells in the selected row to $xx.xx currency format.  The output shows that the call to column C caused entire rows (B-F) to change to $xx.xx format.

########################################################################

from com.sun.star.beans import PropertyValue
# import uno  # doesn't seem necessary

# I confess I still don't really understand the structures 
# in the next 6 lines - I just hacked away until it all worked.
desktop = XSCRIPTCONTEXT.getDesktop()
ThisComponent = XSCRIPTCONTEXT.getDocument()
sheet = ThisComponent.getSheets().getByIndex(0)
frame = ThisComponent.getCurrentController().getFrame()
ctx = XSCRIPTCONTEXT.getComponentContext() 
dispatcher = ctx.ServiceManager.createInstanceWithContext( 'com.sun.star.frame.DispatchHelper', ctx )

########################################################################
def StartHere(dummy):
	for i in range(0,7): # generate a block of unformatted numbers
		for j in range (7, 10):
			sheet.getCellByPosition(i, j).setValue(42) 
 
	FormatColumn("A")	
	FormatColumn("B")	
	FormatColumn("C")
	FormatColumn("D")
	FormatColumn("E")
	
	# If column C is run last, you can see the entire column is selected
	# FormatColumn("C")
########################################################################

########################################################################
# Originally this routine formatted some columns to $xx.xx
# I changed it so it writes desired cell location instead.
def FormatColumn(column):
	for i in range(2,7):
		# create newcell, e.g. 'A3'
		newcell = column+str(i)

		# Can't find another way to do this except dispatcher.  Ugh.
		oProp = PropertyValue()
		
		# move "cursor" to cell locaton 'newcell' 
		# However if newcell points to column C, the row number
		# becomes the column number, and the entire column is 
		# selected.  For example, "C2" selects the entire B column,
		# C3 -> C column, C4 -> D column, etc.
		oProp.Name = 'ToPoint' 
		oProp.Value = newcell
		properties = (oProp,) 
		dispatcher.executeDispatch( frame, '.uno:GoToCell', '', 0, properties )

		# Idea was to set $xx.xx format for selected cell, but
		# if cell is Ci, it changes the entire column to $xx.xx
		oProp.Name = 'NumberFormatValue'
		oProp.Value = 21 # currency
		properties = (oProp,)
		dispatcher.executeDispatch( frame, '.uno:NumberFormatValue', '', 0, properties )
		
		# Writes the (intended) cell location to that cell
		oProp.Name = 'StringName' 
		oProp.Value = newcell
		properties = (oProp,) 
		dispatcher.executeDispatch( frame, '.uno:EnterString', '', 0, properties )

if __name__ == '__main__':
    StartHere(1)
Comment 1 raal 2016-04-28 06:51:47 UTC
Hello,

Thank you for filing the bug. Please send us a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO', so please do change it back to 'UNCONFIRMED' once you have attached a document.
(Please note that the attachment will be public, remove any sensitive information before attaching it.)
How can I eliminate confidential data from a sample document?
https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F
Thank you
Comment 2 Fred Hamilton 2016-04-28 20:04:20 UTC
Created attachment 124705 [details]
python code to reproduce column bug in calc

I'm not sure what you asked for by "sample document".  I've attached the python file that will cause this problem (same as in the text of my original submission - probably bad form but I couldn't see how to attach two files when I submitted).

Steps to reproduce:
1) put file in ~/.config/libreoffice/4/user/Scripts/python directory
2) open up an empty/new calc document
3) run this script as a macro (Tools/Macro/Run Macro/Macro Selector/My Macros/example/StartHere)

Step 1 is for linux - for Win/OS X put it in appropriate macro directory.
Comment 3 Fred Hamilton 2016-04-28 20:05:04 UTC
Changed status to unconfirmed.
Comment 4 Fred Hamilton 2016-04-28 20:18:23 UTC
The instructions for reproducing the bug will not work with the original example.py.  I was launching from a button on my toolbar.  When launched from toolbar, main function needs an argument: def StartHere(dummy):

When launched via menu, main function requires no argument: def StartHere():

To reproduce, use new example_menu_launch.py file
Steps to reproduce:
1) put example_menu_launch.py in ~/.config/libreoffice/4/user/Scripts/python directory
2) open up an empty/new calc document
3) run this script as a macro (Tools/Macro/Run Macro/Macro Selector/My Macros/example_menu_launch/StartHere)
Comment 5 Fred Hamilton 2016-04-28 20:21:21 UTC
Created attachment 124706 [details]
macro suitable for launching from macro menu inside calc

example_menu_launch.py will reproduce bug when launched via macro menu in calc.

example.py (earlier attachment) does not work when launched via macro menu in calc.
Comment 6 Buovjaga 2016-05-06 13:09:54 UTC
Confirmed.

Arch Linux 64-bit, KDE Plasma 5
Version: 5.2.0.0.alpha1+
Build ID: 540fee2dc7553152914f7f1d8a41921e765087ef
CPU Threads: 8; OS Version: Linux 4.5; UI Render: default; 
Locale: fi-FI (fi_FI.UTF-8)
Built on April 30th 2016
Comment 7 QA Administrators 2017-05-22 13:38:52 UTC Comment hidden (obsolete)
Comment 8 QA Administrators 2019-12-03 15:01:21 UTC Comment hidden (obsolete)
Comment 9 QA Administrators 2021-12-03 04:46:39 UTC Comment hidden (obsolete)
Comment 10 QA Administrators 2023-12-04 03:17:57 UTC Comment hidden (obsolete)
Comment 11 QA Administrators 2025-12-04 03:18:13 UTC Comment hidden (obsolete)
Comment 12 Fred Hamilton 2025-12-05 23:20:08 UTC
Tested under Windows and Ubuntu.  Failure does not appear, issue seems to be fixed.
Comment 13 Fred Hamilton 2025-12-05 23:58:05 UTC
A little more detail:

I tested the original reproduction macro against both the historical version and the current release:

Tested versions:

LibreOffice 5.1.2.2 (Linux, unpacked portable build)

LibreOffice 24.2.7.2 (Linux Mint)

LibreOffice 24.x (Windows 10)

Results:

In 5.1.2.2, the bug is reproducible. Calling .uno:GoToCell with a target in column C incorrectly selects a full column, and not the requested cell. Behavior matches the original report.

In current LibreOffice (24.x) on both Linux and Windows, the macro behaves correctly. .uno:GoToCell selects the proper cell in column C, and no incorrect column-wide selection occurs.

Conclusion:
The issue no longer reproduces in current LibreOffice versions and can be marked RESOLVED → FIXED.
Comment 14 Buovjaga 2025-12-06 06:09:14 UTC
(In reply to Fred Hamilton from comment #13)
> Conclusion:
> The issue no longer reproduces in current LibreOffice versions and can be
> marked RESOLVED → FIXED.

Thanks for the follow-up. It can stay as worksforme as the fixing commit is not known. Fixes, like the appearance of bugs, can be determined exactly through the process of bibisecting: https://wiki.documentfoundation.org/QA/Bibisect