Bug 159444 - "View > Field Names" can trigger confusing mode, implement warning
Summary: "View > Field Names" can trigger confusing mode, implement warning
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.4.1 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks: Fields
  Show dependency treegraph
 
Reported: 2024-01-30 11:18 UTC by jan d
Modified: 2024-06-13 14:17 UTC (History)
3 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 jan d 2024-01-30 11:18:43 UTC
Description:
"View/Field Names" switches the display of fields between their rendering in the document vs. an internal representation which shows name or id of the target to ease finding problems. 

The mode can be triggered easily by accident in menu or via a keyboard shortcut which is appearent based on the questions on ask.libreoffice (see https://bugs.documentfoundation.org/show_bug.cgi?id=159299#c1 ) 

A common solution to such modes is implementing a warning that announces the mode to be triggered with the option to not show the warning again. Such a solution was already implemented for https://bugs.documentfoundation.org/show_bug.cgi?id=155561 and is also used by other products e.g. Firefox when entering cursor navigation via pressing F7 or Window’s sticky keys (5x Shift).

The warning can read: 
"You activated Field Names. This will show the names of fields not as they appear in the final document but with their internal identifiers. Do you want to activate Field Names? 
Don't show again [ ] 
Yes/ No"

Steps to Reproduce:
Click View/Field Names or press Ctrl+F9

Actual Results:
Activates internal field names instead of final rendering of the document; some of the field names are random IDs. 

Expected Results:
Enable people to activate the mode, but prevent accidental activation


Reproducible: Always


User Profile Reset: No

Additional Info:
Might be a relativly easy fix?
Comment 1 Heiko Tietze 2024-01-31 09:37:59 UTC
Prototype in https://gerrit.libreoffice.org/c/core/+/153505

Hossein, please add a code pointer where the Fieldnames command is execute (cannot find a SID_FIELDNAMES).
Comment 2 Buovjaga 2024-01-31 13:26:32 UTC
Reverting risky needinfo status which should not be used in this case.
Comment 3 Hossein 2024-06-13 14:12:50 UTC
(In reply to Heiko Tietze from comment #1)
> Prototype in https://gerrit.libreoffice.org/c/core/+/153505
> 
> Hossein, please add a code pointer where the Fieldnames command is execute
> (cannot find a SID_FIELDNAMES).
Starting from the menu text, "View > Field Names", one can find pointers:

$ git grep "Field Names"
officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu:          <value xml:lang="en-US">~Field Names</value>

This is the relevant part from the above file:
      <node oor:name=".uno:Fieldnames" oor:op="replace">
        <prop oor:name="Label" oor:type="xs:string">
          <value xml:lang="en-US">~Field Names</value>
        </prop>
        <prop oor:name="Properties" oor:type="xs:int">
          <value>1</value>
        </prop>
      </node>

Then UNO command for this purpose is ".uno:Fieldnames". Searching for this command leads to sw/sdi/swriter.sdi which defines it:

$ git grep Fieldnames
...
sw/sdi/swriter.sdi:SfxBoolItem Fieldnames FN_VIEW_FIELDNAME
...

And this is the relevant part:

SfxBoolItem Fieldnames FN_VIEW_FIELDNAME

[
    AutoUpdate = FALSE,
    FastCall = FALSE,
    ReadOnlyDoc = TRUE,
    Toggle = FALSE,
    Container = FALSE,
    RecordAbsolute = FALSE,
    RecordPerSet;


    AccelConfig = TRUE,
    MenuConfig = TRUE,
    ToolBoxConfig = TRUE,
    GroupId = SfxGroupId::View;
]

Following FN_VIEW_FIELDNAME, one can find sw/source/uibase/uiview/view0.cxx, which is used to handle that menu option, and also as an accelerator with F9_MOD1 (Ctrl+F9) in officecfg/registry/data/org/openoffice/Office/Accelerators.xcu:

$ git grep FN_VIEW_FIELDNAME *.cxx
sw/source/uibase/uiview/view0.cxx:            //FN_VIEW_FIELDNAME,    /**/
sw/source/uibase/uiview/view0.cxx:            case FN_VIEW_FIELDNAME:
sw/source/uibase/uiview/view0.cxx:    case FN_VIEW_FIELDNAME:

EasyHacker should do something similar done in below patch, to define a dialog that will be showed for the first time. The code changes should be done in sw/source/uibase/uiview/view0.cxx. After querying configuration to make sure that showing hint is still enabled (should be true for the first time), then the hint dialog should be displayed.

153505: Resolves tdf#155561 - Notification for the overwrite mode
https://gerrit.libreoffice.org/c/core/+/153505