Bug 144859 - <switchinline select="sys"> mechanism misbehaves when embedded
Summary: <switchinline select="sys"> mechanism misbehaves when embedded
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
7.2.0.3 rc
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard: target:24.2.0
Keywords:
Depends on:
Blocks: New-Help
  Show dependency treegraph
 
Reported: 2021-10-01 17:24 UTC by Ming Hua
Modified: 2023-07-31 14:24 UTC (History)
2 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 Ming Hua 2021-10-01 17:24:39 UTC
It seems the
<switchinline select="sys">
  <caseinline select="MAC"> 
  ...
  </caseinline>
  <defaultinline>
  ...
  </defaultinline>
</switchinline>
mechanism used in help documentation that displays different content for different OS platform is working as intended when used directly in the .xhp file, for example:
https://help.libreoffice.org/7.3/en-US/text/shared/00/edit_menu.html?System=MAC
shows the "Command+<key>" shortcuts for macOS correctly.  And if one changes the URL to use "...?System=WIN", it will show "Ctrl+<key>" as it should.

But if such text is embedded in another .xhp file, for example in:
https://help.libreoffice.org/7.3/en-US/text/shared/01/02070000.html?System=MAC
it shows wrong "CommandCtrl + Shift + V" while it should show "Command + Shift + V".

I see this problem in both the 7.3/master online help (the URLs above) and local offline help installed from 7.2.0 RC3 MSI installer.  Note that I tested on a Windows computer and hand-edited the "System=MAC" part of the URL, hope it's the correct way / same way a macOS computer would construct the URL.
Comment 1 Olivier Hallot 2022-07-01 11:29:58 UTC
This bug requires changes in

+ help3xsl/help2.js :

// Find spans that need the switch treatment and give it to them
var spans = document.querySelectorAll("[class^=switch]");
(...)

function setApplSpan(spanZ) 
function setSystemSpan(spanZ)

+ help3xsl/online_transform.xsl :
switch /switchinline
case
default
Comment 2 Buovjaga 2022-12-01 15:01:39 UTC
Note that we want to get rid of the switches completely, but it is not trivial
Comment 3 Olivier Hallot 2023-07-29 20:56:46 UTC
to fix this issue I need a javascript code that handles the current pseudo code

For this use case System is WIN. Note that second switch must return the DEFAULT case.


switch System {
case MAC:
   mac help stuff
   break;
case WIN:
   win help stuff
   switch System {
        case MAC:
            mac help2 stuff
            break;
         case DEFAULT:
            DEFAULT help2 stuff
            break;
        default:
            undefined system stuff
   }        
   break;
case UNIX: 
   unix help stuff
   break;
case DEFAULT:
   DEFAULT help stuff
   break;
default:
   undefined system stuff
}
Comment 4 Commit Notification 2023-07-31 14:24:47 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/886cebba80267127e47de6f5dad57745cfe54752

tdf#144859 - fix switch javascript logic.