Bug 160580 - Add UNO commands to jump to the first/last sheet
Summary: Add UNO commands to jump to the first/last sheet
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.2.1.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 162882 162885 (view as bug list)
Depends on:
Blocks: UNO-Command-New Sheet-Tabs-Bar
  Show dependency treegraph
 
Reported: 2024-04-08 02:55 UTC by alex
Modified: 2024-09-16 09:24 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description alex 2024-04-08 02:55:46 UTC
Description:
I’m a long-time Calc fan and user, and in a relatively recent update I’ve noticed that the CTRL-PGUP/CTRL-PGDN shortcuts for switching sheets behave differently.

Previously (as recently as 7.6.4.1), once on the very first or last sheet of a workbook, using the shortcut CTRL-PGUP or CTRL-PGDN would stop.
This behaviour was:
* Consistent the GUI buttons for “Scroll to next/previous sheet”, which do nothing once you are at the “end” of the strip.
* A convenient and long standing way to return to the start/end by holding the keyboard shortcut - essentially a shortcut to “Scroll to last/first sheet”.

In a recent update, this keyboard shortcut now “wraps around”, so that the selected sheet infinitely returns from the start to the other end.
This is inconsistent with the GUI, and breaks prior behaviour for no reason.

Is there any setting to revert this, or is it simply a bug that needs fixing?

Steps to Reproduce:
1. Create a Calc workbook with multiple sheets
2. Use the CTRL-PGDN (To next sheet) shortcut repeatedly to move to the last sheet of the workbook
3. Once on the last sheet, press CTRL-PGDN again

Actual Results:
The first sheet of the the workbook is selected, unlike if you attempt to click the gui button for "Scroll to next sheet".

Expected Results:
The "To next sheet" shortcut should not move focus if there is no next sheet to move to.
The same applies to "To previous sheet"


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.2.2.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: kf5 (cairo+xcb)
Locale: en-NZ (en_NZ.UTF-8); UI: en-US
Calc: threaded
Comment 1 alex 2024-04-08 06:28:15 UTC
I had replies over on ask/ pointing out that this was a newly added feature per https://bugs.documentfoundation.org/show_bug.cgi?id=156311.

As such, clearly it's a desired behaviour for some: is it possible to provide a configuration option to disable this - or perhaps rebind the keyboard customisation to a slightly different option?
Comment 2 ady 2024-04-08 15:08:06 UTC
While I agree with the request to have a keyboard shortcut(s) to go to the first/last worksheet(s), there are several problems with the request, unfortunately.

The first problem to bind a keyboard shortcut to "navigate/go to first worksheet" (and another shortcut for the last worksheet) is that the function is not defined/listed in the Customize list.

I am not sure, but I believe a new UNO command would be needed?


The "second" problem related to this request is that the arrows that should allow to navigate to first/prior/next/last worksheets are not working.

STR:
1. New Calc.
2. Add 3 (empty) worksheets.
3. Try to use the arrow "icons" to navigate to first/prior/next/last worksheets by clicking on any of them.

 > the arrows are all grayed out. AFAIR, these never worked.

There is probably some bug report about this other issue. While this "second" issue is about mouse interaction instead of using the keyboard, these are probably related/connected in some area.

Since this request is a consequence of tdf#156311, I am CC'ing Denis Sorotnik and Heiko.
Comment 3 alex 2024-04-08 18:30:01 UTC
To clarify, I am not suggesting a new shortcut to go to the first/last sheet - just that the former behaviour of the next/previous shortcuts be made available in some way.
The change made in 24.2 alters long standing things that work:just hold down CTRL-PGDN and you end up at the last sheet. If you really need to get there fast, move to the mouse button. Both options give a certain outcome, while the new reaction of the shortcut is to create uncertainty about which sheet will be active. 

I don't understand any of the architecture, but the buttons in the GUI retain this behaviour, and it existed prior to 24.2, so it's hard to imagine it needs something totally new built.

Regarding exposing something new in the customise list, perhaps a separate entry for "next sheet - wrap at last" might be comprehensible to users?
Comment 4 ady 2024-04-08 20:23:24 UTC
(In reply to alex from comment #3)
> To clarify, I am not suggesting a new shortcut to go to the first/last sheet
> - just that the former behaviour of the next/previous shortcuts be made
> available in some way.

The request is clear. It would be some advance experimental setting, buried within some not-so-obvious dialogue.

OTOH, since there are no shortcuts available for "go to first/last worksheets", having the possibility to assign a shortcut would be less "advance/experimental".

I was just taking part of your comment 0 and suggesting a possible alternative way to solve the UX problem.

> 
> the buttons in the GUI
> retain this behaviour, and it existed prior to 24.2, so it's hard to imagine
> it needs something totally new built.

For some users, the arrow UI icons to go to first/prior/next/last worksheet are always grayed out, not clickable. You can click on a specific worksheet tab, but not on the arrows. This is a separate bug report, but somewhat related to this request.

> 
> Regarding exposing something new in the customise list, perhaps a separate
> entry for "next sheet - wrap at last" might be comprehensible to users?

The functions I mentioned in my comment 2 would be "to first (work)sheet" and "to last (work)sheet". These do not exist, AFAIK. Whether these would deserve to be added, or to provide whichever alternative to this request, it is for the UX Team and other devs to evaluate.
Comment 5 alex 2024-04-08 20:42:12 UTC
(In reply to ady from comment #4)
> (In reply to alex from comment #3)
> > To clarify, I am not suggesting a new shortcut to go to the first/last sheet
> > - just that the former behaviour of the next/previous shortcuts be made
> > available in some way.
> 
> The request is clear. It would be some advance experimental setting, buried
> within some not-so-obvious dialogue.
> 
> OTOH, since there are no shortcuts available for "go to first/last
> worksheets", having the possibility to assign a shortcut would be less
> "advance/experimental".
> 
> I was just taking part of your comment 0 and suggesting a possible
> alternative way to solve the UX problem.
> 
> > 
> > the buttons in the GUI
> > retain this behaviour, and it existed prior to 24.2, so it's hard to imagine
> > it needs something totally new built.
> 
> For some users, the arrow UI icons to go to first/prior/next/last worksheet
> are always grayed out, not clickable. You can click on a specific worksheet
> tab, but not on the arrows. This is a separate bug report, but somewhat
> related to this request.
> 
> > 
> > Regarding exposing something new in the customise list, perhaps a separate
> > entry for "next sheet - wrap at last" might be comprehensible to users?
> 
> The functions I mentioned in my comment 2 would be "to first (work)sheet"
> and "to last (work)sheet". These do not exist, AFAIK. Whether these would
> deserve to be added, or to provide whichever alternative to this request, it
> is for the UX Team and other devs to evaluate.

Thanks for the extra info - I realise we're mostly agreeing and hope some improvement can come from the discussion!
Comment 6 Heiko Tietze 2024-04-09 15:00:47 UTC
My take: introduce UNO commands for first/last sheet and keep the patch unconditional.
Comment 7 ady 2024-04-09 17:47:03 UTC
(In reply to ady from comment #2)
>  > the arrows are all grayed out. AFAIR, these never worked.

That is tdf#156328.



(In reply to ady from comment #2)
> I am not sure, but I believe a new UNO command would be needed?
> 

(In reply to Heiko Tietze from comment #6)
> My take: introduce UNO commands for first/last sheet and keep the patch
> unconditional.


@Denis, since you very recently solved tdf#156311 that triggered this tdf#160580, maybe you could take a look at this.
Comment 8 ady 2024-09-09 21:11:30 UTC
*** Bug 162882 has been marked as a duplicate of this bug. ***
Comment 9 ady 2024-09-09 21:12:59 UTC
*** Bug 162885 has been marked as a duplicate of this bug. ***
Comment 10 geoff183 2024-09-13 23:46:57 UTC
The new behavior is aligned with other common UX designs. e.g these applications also wrap around: xfce4-terminal, firefox, GIMP, thunar... I'm sure there are plenty more. I also preferred the previous way This sort of change probably won't be reverted or given an option.

I found this code snippet which selects the 3rd sheet:

  dim document   as object
  dim dispatcher as object
  document   = ThisComponent.CurrentController.Frame
  dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
  dim args1(0) as new com.sun.star.beans.PropertyValue
  args1(0).Name = "Nr"
  args1(0).Value = 3
  dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())

If you are motivated enough, you could make a macro triggered with two keyboard shortcuts to do something like this:

  alt-pgup
  if current_sheet != 1
    goto current_sheet-1

  alt-pgdn
    get max_number_of_sheets
    if current_sheet != max_number_of_sheets
      goto current_sheet+1
Comment 11 ady 2024-09-14 00:52:08 UTC
(In reply to geoff183 from comment #10)
> The new behavior is aligned with other common UX designs. e.g these
> applications also wrap around: xfce4-terminal, firefox, GIMP, thunar... I'm
> sure there are plenty more. I also preferred the previous way This sort of
> change probably won't be reverted or given an option.

Unfortunately, developers might very scarcely use spreadsheet tools (as users). Perhaps we (users) should rather stop using Calc as a spreadsheet tool and we might try using either xfce4-terminal, Firefox, GIMP or Thunar for such purpose(?). Oh, wait, those are not spreadsheet tools. Apparently we should start using those anyway.

Spreadsheets are popular for several reasons, one of them being the flexibility of the relevant tools. Sadly, Calc is being restricted on each iteration, with changes being applied according to some subjective mood ("I like it, and everyone else should too, and everyone will work as I do").
Comment 12 alex 2024-09-14 08:25:48 UTC
(In reply to geoff183 from comment #10)
> The new behavior is aligned with other common UX designs. e.g these
> applications also wrap around: xfce4-terminal, firefox, GIMP, thunar... I'm
> sure there are plenty more. I also preferred the previous way This sort of
> change probably won't be reverted or given an option.
> 
> I found this code snippet which selects the 3rd sheet:
> 
>   dim document   as object
>   dim dispatcher as object
>   document   = ThisComponent.CurrentController.Frame
>   dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
>   dim args1(0) as new com.sun.star.beans.PropertyValue
>   args1(0).Name = "Nr"
>   args1(0).Value = 3
>   dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())
> 
> If you are motivated enough, you could make a macro triggered with two
> keyboard shortcuts to do something like this:
> 
>   alt-pgup
>   if current_sheet != 1
>     goto current_sheet-1
> 
>   alt-pgdn
>     get max_number_of_sheets
>     if current_sheet != max_number_of_sheets
>       goto current_sheet+1

Thanks - it turns out that yes I am motivated enough - it just hadn't occurred to me to fix it that way!

In case it's of use to anybody else at all, here are four macros which can a/ Return the ToNextSheet/ToPreviousSheet to their 'classic' behaviour, and b/ Provide the GotoFirst/GotoLast behaviour that others asked for.
All can be bound to whatever keystrokes are preferred!

REM  *****  BASIC  *****
sub ToNextSheet_classic
	' Select next worksheet but DON'T wrap (ie as prior to v24.2)
	dim document   as object
	dim dispatcher as object
	document   = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

	dim iSmax as Integer
	dim iSindex as Integer
	iSmax=ThisComponent.Sheets.count - 1
	iSIndex=Thiscomponent.CurrentController.ActiveSheet.RangeAddress.Sheet
	if iSIndex < iSmax then
		dispatcher.executeDispatch(document, ".uno:JumpToNextTable", "", 0, Array())
	end if
end sub
sub ToPreviousSheet_classic
	' Select previous worksheet but DON'T wrap (ie as prior to v24.2)
	dim document   as object
	dim dispatcher as object
	document   = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

	dim iSindex as Integer
	iSIndex=Thiscomponent.CurrentController.ActiveSheet.RangeAddress.Sheet
	if iSIndex > 0 then
		dispatcher.executeDispatch(document, ".uno:JumpToPrevTable", "", 0, Array())
	end if
end sub
sub ToFirstSheet
	' Select first worksheet
	dim document   as object
	dim dispatcher as object
	document   = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

	dim args1(0) as new com.sun.star.beans.PropertyValue
	args1(0).Name = "Nr"
	args1(0).Value =1
	dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())	
end sub
sub ToLastSheet
	' Select last worksheet
	dim document   as object
	dim dispatcher as object
	document   = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

	dim iSmax as Integer
	iSmax=ThisComponent.Sheets.count
	dim args1(0) as new com.sun.star.beans.PropertyValue
	args1(0).Name = "Nr"
	args1(0).Value = iSmax
	dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())	
end sub
Comment 13 alex 2024-09-14 08:40:36 UTC
(In reply to geoff183 from comment #10)
> The new behavior is aligned with other common UX designs. e.g these
> applications also wrap around: xfce4-terminal, firefox, GIMP, thunar... I'm
> sure there are plenty more. I also preferred the previous way This sort of
> change probably won't be reverted or given an option.
While I've found a solution that works for me thanks to your suggestion, I feel compelled to address this observation.
The other applications you cite where navigation does wrap back around on reaching the end are all applications where the tabs don't really have an intrinsic structure/order to them.  
While users may have opened some browser tabs, or images in gimp in a specific order while working on them, in a spreadsheet the order of the tabs is often fundamental to the document's purpose, and is *always* retained when revisiting the document.
I'm not as salty as @ady was about it, but their point stands that spreadsheets are at their core about structuring particular subsets of data/content, and that is not really the case for terminals, web browsers, image editors or file managers.