Download it now!
Bug 135790 - "%MOD1" appears in LO Tip of the Day #41
Summary: "%MOD1" appears in LO Tip of the Day #41
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
7.0.0.3 release
Hardware: x86-64 (AMD64) Linux (All)
: medium minor
Assignee: Heiko Tietze
URL:
Whiteboard: target:7.1.0 target:7.0.2
Keywords:
Depends on:
Blocks: Tip-Of-The-Day
  Show dependency treegraph
 
Reported: 2020-08-16 01:14 UTC by skierpage
Modified: 2020-09-10 20:00 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
%MOD1 appears in Tip of the Day 41 (30.43 KB, image/png)
2020-08-16 01:14 UTC, skierpage
Details

Note You need to log in before you can comment on or make changes to this bug.
Description skierpage 2020-08-16 01:14:19 UTC
Created attachment 164340 [details]
%MOD1 appears in Tip of the Day 41

I started my LibreOffice flatpak (7.0.0.3 8061b3e9204bef6b321a21033174034a5e2ea88e) and Tip of the Day 41/222 appeared:

  Need to insert the date in a spreadsheet cell? Type Ctrl+; or Shift+%MOD1+; to insert the time.

"Ctrl" should appear in place of %MOD1 on Windows and Linux.

Expected result:
  Need to insert the date in a spreadsheet cell? Press Ctrl+; . Press Shift+Ctrl+; to insert the time.

(or just mention Calc's Insert menu items for this, see below)

Cause of the bug:

The text comes from https://github.com/LibreOffice/core/blob/18c97df0dcb348134d3ceac022a799338e02d7f5/cui/inc/tipoftheday.hrc#L88 :
     { NC_("RID_CUI_TIPOFTHEDAY", "Need to insert the date in a spreadsheet cell? Type %MOD1+; or Shift+%MOD1+; to insert the time."), "", "tipoftheday_c.png"},

I think the bug lies in TipOfTheDayDialog::UpdateTip() in https://github.com/LibreOffice/core/blob/master/cui/source/dialogs/tipofthedaydlg.cxx#L82 which performs a single replace of "%MOD1" leaving the second variable unchanged. It would have to replace %MOD1 in a loop or use a replaceAtMultiple function or regexp.

Additional info:

This specific tip is still really hard to read because semicolon is also punctuation organizing a sentence; I changed the phrasing above under "Expected result" to clarify. Ideally you'd use CSS that draws keycaps e.g. https://jsfiddle.net/7rg5pLs8/1/ . That might address bug 130979, which talks of the difficulty of localizing the modifier key's name. There's also a mail thread about problems with this tip for keyboard layouts that don't have a dedicated semicolon key, https://www.mail-archive.com/l10n@global.libreoffice.org/msg12782.html

Maybe it's easier if this Tip of the Day tells users
  Use the menu items Insert > Date and Insert > Time to insert the current date or time into a spreadsheet

since these menu items indicate the keyboard shortcut. Then there's no mention of %MOD1 or Ctrl and all three problems go away! 😉
Comment 1 Julien Nabet 2020-08-16 09:50:33 UTC
Heiko: thought you might be interested in this one.
Comment 2 Heiko Tietze 2020-08-16 13:03:08 UTC
%MOD1 is replaced by Ctrl or Cmd depending on the OS. Weird that it doesn't work. Please copy/paste your app version (About > Copy (unlabelled)).
Comment 3 BogdanB 2020-08-16 13:57:35 UTC
The same in 
Version: 7.0.0.3
Build ID: 8061b3e9204bef6b321a21033174034a5e2ea88e
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 4 Ming Hua 2020-08-16 15:37:31 UTC
Also reproducible on Windows, with Chinese UI for the translated tip.

I'm by no means a competent C++ programmer, but it seems to me the string replacement logic starting from:
https://opengrok.libreoffice.org/xref/core/cui/source/dialogs/tipofthedaydlg.cxx?r=1bc50aca#90
only attempts to replace %MOD1/%MOD2 once and doesn't properly process strings with two instances of "%MOD1", like tip #41 mentioned here.
Comment 5 Julien Nabet 2020-08-16 18:27:08 UTC
(In reply to Ming Hua from comment #4)
> Also reproducible on Windows, with Chinese UI for the translated tip.
> 
> I'm by no means a competent C++ programmer, but it seems to me the string
> replacement logic starting from:
> https://opengrok.libreoffice.org/xref/core/cui/source/dialogs/tipofthedaydlg.
> cxx?r=1bc50aca#90
> only attempts to replace %MOD1/%MOD2 once and doesn't properly process
> strings with two instances of "%MOD1", like tip #41 mentioned here.

I'm not expert too but agree with your analysis.
I think we should use "while" blocks to replace MOD1 and MOD2.
Comment 6 skierpage 2020-08-17 00:05:03 UTC
(In reply to Ming Hua from comment #4)
> the string replacement logic .... only attempts to replace %MOD1/%MOD2 once
Yes, what I wrote ;-)

(In reply to Julien Nabet from comment #5)
> I think we should use "while" blocks to replace MOD1 and MOD2.

Which leaves the other two issues I referenced (localization of modifier keys and no semicolon in some keyboard layouts). What do you think of changing the tip to mention the items in the Insert menu instead?

There are three other tips of the day in cui/inc/tipoftheday.hrc with MOD1 twice that also display garbled (and no tips with MOD2 twice):

#38: "To quickly insert or delete rows, select the desired number of rows (or columns) and press %MOD1+ to add or %MOD1- to delete."), ""

#94: "Configure use of the %MOD1 key to open hyperlinks? Tools ▸ Options ▸ %PRODUCTNAME ▸ Security ▸ Options ▸ “%MOD1+click required to open hyperlinks”."

#153: "Apply Heading paragraph styles in Writer with shortcut keys: %MOD1+1 applies Heading 1, %MOD1+2 applies Heading 2, etc."

Note tip #38 is inconsistent, it should be %MOD1++ and %MOD1+- which is even more confusing than Ctrl+; , another reason to render keyboard keys as keycaps. I filed separate enhancement bug 135816.
Comment 7 Ming Hua 2020-08-17 13:33:30 UTC
(In reply to skierpage from comment #6)
> (In reply to Ming Hua from comment #4)
> > the string replacement logic .... only attempts to replace %MOD1/%MOD2 once
>
> Yes, what I wrote ;-)
Of course.  I was just not accustomed to the original bug reporter proposing solutions and didn't read carefully enough. :-P

> Which leaves the other two issues I referenced (localization of modifier
> keys and no semicolon in some keyboard layouts). What do you think of
> changing the tip to mention the items in the Insert menu instead?
I'm not a developer, but as far as I understand, the point of tip #41 is to notify users the existense of these two keyboard shortcuts as alternatives for the Insert > Date and Insert > Time menu items, so your proposal

(In reply to skierpage from comment #0)
> Maybe it's easier if this Tip of the Day tells users
>   Use the menu items Insert > Date and Insert > Time to insert the current
> date or time into a spreadsheet
kind of defeats the purpose.
Comment 8 Heiko Tietze 2020-08-31 09:40:20 UTC
Patch at https://gerrit.libreoffice.org/c/core/+/101700
Comment 9 Commit Notification 2020-08-31 11:14:07 UTC
Heiko Tietze committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/db5f204b1d3d96975d902b587d6d18bc06610eea

Resolves tdf#135790 - Support for multiple %MOD1/2 entries

It will be available in 7.1.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2020-09-02 05:37:51 UTC
Heiko Tietze committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/e21768ce2898453226aedd5f8ce19d8075f5bec5

Resolves tdf#135790 - Support for multiple %MOD1/2 entries

It will be available in 7.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 BogdanB 2020-09-10 20:00:28 UTC
Verified.
Perfect!

Version: 7.1.0.0.alpha0+
Build ID: 63d4d3421fec5a4e9e88dcee2992cda38cc7452a
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (ro_RO.UTF-8); UI: en-US
Calc: threaded