Bug 123083 - Improve word count workflow
Summary: Improve word count workflow
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: reviewed:2023
Keywords: difficultyInteresting, easyHack, needsDevEval, skillCpp, topicUI
: 123333 (view as bug list)
Depends on:
Blocks: Statusbar Word-Count
  Show dependency treegraph
 
Reported: 2019-01-31 10:07 UTC by Heiko Tietze
Modified: 2023-12-14 08:21 UTC (History)
10 users (show)

See Also:
Crash report or crash signature:


Attachments
Mockup (18.87 KB, image/png)
2023-04-11 14:42 UTC, Abdallah Elhdad
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Heiko Tietze 2019-01-31 10:07:43 UTC
The request was raised on Twitter (https://twitter.com/sfmnemonic/status/1083379610035896323) to improve the word count in Writer. We have <n> words, <m> characters currently either for all text or the selection. On click the dialog shows some more info. 

Sounds sufficient to me, in particular with the selection forward/backward the current position, and I would resolve the request as WFM. However the code is simple and enhancements would be possible as easy hacks.
Comment 1 Heiko Tietze 2019-02-02 12:35:07 UTC
In the first step we should count the words/characters before and after the cursor and show this information at the dialog. The second step with be to provide an option to switch between the different variants, perhaps per radio button in the dialog.

Bjoern offered mentoring...
Comment 2 Heiko Tietze 2019-03-13 09:09:13 UTC
Bjoern, could you please add a few code pointers to allow Izabella to start? I jump in with pleasure when in comes to the UI.
Comment 3 Heiko Tietze 2019-06-19 12:54:10 UTC
No code pointers, no easy hack. Please reassign if you want, Izabella.
Comment 4 Heiko Tietze 2019-09-05 08:24:44 UTC
The dialog is implemented in sw/source/ui/dialog/wordcountdialog.cxx. Values are taken from SwDocStat (sw/source/core/doc/docstat.cxx) updated probably per SwDoc::CountWords() but since CountWords has several implementations I'm not sure here. Expert knowledge needed, Bjoern.
Comment 5 Heiko Tietze 2020-02-03 11:02:15 UTC
*** Bug 123333 has been marked as a duplicate of this bug. ***
Comment 6 Heiko Tietze 2022-09-19 08:34:10 UTC
*** Bug 150631 has been marked as a duplicate of this bug. ***
Comment 7 Hossein 2023-03-02 14:50:27 UTC
Re-evaluating the EasyHack in 2023

This issue is still relevant, as the word count dialog in Writer is the same as before.
Comment 8 Abdallah Elhdad 2023-04-02 04:50:05 UTC
(In reply to Heiko Tietze from comment #0)
> The request was raised on Twitter
> (https://twitter.com/sfmnemonic/status/1083379610035896323) 

it seems to me that the tweet has been deleted, I can't access it, what's the requested enhancement?
Comment 9 Buovjaga 2023-04-02 06:17:41 UTC
(In reply to Abdallah Elhdad from comment #8)
> (In reply to Heiko Tietze from comment #0)
> > The request was raised on Twitter
> > (https://twitter.com/sfmnemonic/status/1083379610035896323) 
> 
> it seems to me that the tweet has been deleted, I can't access it, what's
> the requested enhancement?

The requested enhancement is described in this report, you don't need that tweet.
Comment 10 Abdallah Elhdad 2023-04-11 14:12:06 UTC
I'm almost done with the solution for this, but I'm a bit confused. 

how should I deal with the extracted two objects of SwDocStat -for the char, word count before and after the cursor-, in the function SwEditShell::CountWords, it passes only one object, should I change the signature of the function? or create a new function that takes two SwDocStat objects as [out]? 


another question is how I should approach the UI?, with the consideration of two labels of `Selection` and `Document` on top of the dialog.
Comment 11 Heiko Tietze 2023-04-11 14:22:18 UTC
(In reply to Abdallah Elhdad from comment #10)
> I'm almost done with the solution for this, but I'm a bit confused. 
> 
> how should I deal with the extracted two objects of SwDocStat -for the char,
> word count before and after the cursor-, in the function
> SwEditShell::CountWords, it passes only one object, should I change the
> signature of the function? or create a new function that takes two SwDocStat
> objects as [out]? 
You decide :-). Submit a patch and let the developers review.

> another question is how I should approach the UI?, with the consideration of
> two labels of `Selection` and `Document` on top of the dialog.
Create a ui file with Glade (or just hack the XML yourself), add controls to your liking, and load it with welding as done on other places.

To make a dialog nice and informative it needs more than two information. Could imagine:
* Total word/character count
* Selection word/character count
* Before/After cursor word/character count <- this is the request actually
* Number of pages, chapters, figures... 

Don't worry if the dialog has design flaws. Happy to improve this later.
Comment 12 Abdallah Elhdad 2023-04-11 14:42:18 UTC
Created attachment 186582 [details]
Mockup

(In reply to Heiko Tietze from comment #11)
> You decide :-). Submit a patch and let the developers review.

I will work on it in a new -not missy- branch and push for sure! 


> To make a dialog nice and informative it needs more than two information.
> Could imagine:
> * Total word/character count
> * Selection word/character count
> * Before/After cursor word/character count <- this is the request actually
> * Number of pages, chapters, figures... 

maybe in the future, the redesign of the dialog is considered -due to different measures-, for now, I will work with this mockup I made if you have any comments.
Comment 13 Heiko Tietze 2023-04-11 14:49:28 UTC
(In reply to Abdallah Elhdad from comment #12)
> Created attachment 186582 [details]
> Mockup
LGTM, before/after needs to get separated of course. Not sure if characters before/after is needed.

> (In reply to Heiko Tietze from comment #11)
> I will work on it in a new -not missy- branch and push for sure! 
As long the patch is not submitted it's fine to work on master. And submission is done after the review process.

> maybe in the future, the redesign of the dialog is considered -due to
> different measures-, for now, I will work with this mockup I made if you
> have any comments.
Sounds good.
Comment 14 Abdallah Elhdad 2023-04-11 14:54:54 UTC
(In reply to Heiko Tietze from comment #13)

> LGTM, before/after needs to get separated of course. Not sure if characters
> before/after is needed.

in comment #1 adding a char count was suggested, adding the char' count is an easyHack, I will work on the word count for now.
Comment 15 Abdallah Elhdad 2023-04-15 16:30:55 UTC
I don't know if it's a good practice to mention here that I pushed a patch, someone let me know please:) 

oh btw, I did push a patch and it's waiting for a review:)

https://gerrit.libreoffice.org/c/core/+/150309
Comment 16 Buovjaga 2023-12-14 08:21:36 UTC
(In reply to Abdallah Elhdad from comment #15)
> I don't know if it's a good practice to mention here that I pushed a patch,
> someone let me know please:) 
> 
> oh btw, I did push a patch and it's waiting for a review:)
> 
> https://gerrit.libreoffice.org/c/core/+/150309

The patch was never finished, so someone else can create a new patch based on it after carefully reading the last review comments. An appropriate line should be added to the end of the commit message indicating co-author:

Co-authored-by: name <name@example.com>