Bug 137568 - Enhancement: Format - Comments... should be greyed out when there are no comments
Summary: Enhancement: Format - Comments... should be greyed out when there are no comm...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.1.0.0.alpha0+
Hardware: All All
: lowest enhancement
Assignee: sdc.blanco
URL:
Whiteboard: target:7.1.0
Keywords:
Depends on:
Blocks: Main-Menu
  Show dependency treegraph
 
Reported: 2020-10-17 22:33 UTC by sdc.blanco
Modified: 2020-10-27 07:36 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
screenshot (131.47 KB, image/png)
2020-10-18 12:36 UTC, BogdanB
Details
Not greyed out example (418.13 KB, application/pdf)
2020-10-18 13:25 UTC, sdc.blanco
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sdc.blanco 2020-10-17 22:33:48 UTC
1. Open any document (without any comments)
2. Format > Comments...  

Result:  Nothing happens.

3.  Insert a comment in comment-less document.
4.  Format > Comments...

Result: Character dialog box appears

Enhancement:  Format > Comments... should be greyed out until one or more comments are present.
Comment 1 BogdanB 2020-10-18 12:36:08 UTC Comment hidden (obsolete)
Comment 2 sdc.blanco 2020-10-18 13:25:03 UTC Comment hidden (obsolete)
Comment 3 BogdanB 2020-10-18 14:56:06 UTC
Confirm in
Version: 7.0.2.2
Build ID: 8349ace3c3162073abd90d81fd06dcfb6b36b994
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

It is useless to stay like this.
Comment 4 sdc.blanco 2020-10-19 11:23:49 UTC
@Heiko - I tried, without success, to find in the code where this should be modified. I am not sure that I can achieve the intended result, but I wanted to at least try. 

I think the "State" (of whether comments exist or not) is set here.
https://opengrok.libreoffice.org/xref/core/sw/source/uibase/shells/textfld.cxx?r=93099409&fi=StateField#778  or maybe here: https://opengrok.libreoffice.org/xref/core/sw/source/uibase/shells/annotsh.cxx?r=2c771c05#1139  
and I can see that the menu item is .uno:FormatAllNotes, but I could not see where the test should be made in deciding whether to make the menu item active.

Can you give me some code pointers?  Thanks.
Comment 5 Heiko Tietze 2020-10-20 11:25:06 UTC
(In reply to sdc.blanco from comment #4)
> Can you give me some code pointers?  Thanks.

+++ b/sw/source/uibase/shells/textfld.cxx
@@ -803,6 +803,8 @@ void SwTextShell::StateField( SfxItemSet &rSet )
                     rSet.InvalidateItem( FN_DELETE_COMMENT );
                     rSet.InvalidateItem( FN_HIDE_NOTE );
                 }
+                if (!pPostItMgr->HasNotes())
+                    rSet.DisableItem( FN_FORMAT_ALL_NOTES );
             }
             break;

(Please double check the logic)
Comment 6 Commit Notification 2020-10-21 07:50:53 UTC
Seth Chaiklin committed a patch related to this issue.
It has been pushed to "master":

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

tdf#137568  grey-out Format - Comments in menu,  when no comments

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 7 BogdanB 2020-10-27 07:36:06 UTC
It's ok now in
Version: 7.1.0.0.alpha1+
Build ID: 0f0a5b63b19196f9463149a0a1991704c940efe2
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

Verified.