Bug 145596 - provide word count annotation to document canvas, alternative to current line count
Summary: provide word count annotation to document canvas, alternative to current line...
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.2.0.1 rc
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Word-Count
  Show dependency treegraph
 
Reported: 2021-11-09 07:36 UTC by tripleo
Modified: 2022-05-31 10:21 UTC (History)
6 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 tripleo 2021-11-09 07:36:53 UTC
Description:
Let's say a user (I don't know which one??) wants to print a draft document that is intended to solicit feedback in ink (not electronic notes or comments), and will modify the document afterwards.

This user will print the document in multiple sizes and wants to be able to find his/her position quickly using both sizes, therefore line count is unreliable as a marker of where in the document a piece of text is.

I think a word count instead of line count is perfect for this.

Maybe this would be a good time to solicit my second idea, which is multiple "style sheets", where draft would be double spaced in a bigger font and final would be single spaced in a smaller font

Steps to Reproduce:
1. Enter content
2. Change (paragraph?) formatting option to word count
3. Magic!

Actual Results:
Only line count is available at this time

Expected Results:
It would be nice to have


Reproducible: Always


User Profile Reset: No



Additional Info:
None.
Comment 1 V Stuart Foote 2021-11-09 14:25:10 UTC
OK, doing a word count annotation to document canvas seems feasible, modeled on the current "Line Numbering" dialog.

Could we also navigate by word count. Maybe establish a movement by blocks of counted words (e.g. 20, 50, 100) and also provide a go-to word.  I guess dialog could control counting of words, e.g. not in header/footer and exclude by paragraph. When active, assume we would want it reflected in the status bar.

And, maybe also as an additional movement mode for Navigator?
Comment 2 Heiko Tietze 2021-11-10 08:01:00 UTC
Doubt it's possible. The file format clearly talks about "line number" and we cannot abuse it to show the word count instead - and expect a cross-application compatibility. It would also be required in alien formats such as OOXML/DOCX.
Comment 3 tripleo 2021-11-11 11:31:35 UTC
(In reply to Heiko Tietze from comment #2)
> Doubt it's possible. The file format clearly talks about "line number" and
> we cannot abuse it to show the word count instead - and expect a
> cross-application compatibility. It would also be required in alien formats
> such as OOXML/DOCX.

Cross-application compatibility is not a concern for me, at least here. I'm not sure about your project's guiding principles though.

More relevant is how to fit this into the file format, as I know it's standardized. I don't know where to begin on that.
Comment 4 tripleo 2021-11-11 13:59:28 UTC
I for got to tell my story...

I recently tried to save a document with close to no formatting as a word .docx
and LO popped up a dialog warning me that some formatting might be lost if I saved in a foreign format.

This is to say that all features need not be available in all formats/applications as long as LO supports it faithfully, unless there is something I don't know.  And if there is, I would like to find out.
Comment 5 QA Administrators 2021-11-17 05:14:47 UTC Comment hidden (noise, obsolete)
Comment 6 Heiko Tietze 2021-11-17 06:13:05 UTC Comment hidden (off-topic)
Comment 7 Heiko Tietze 2022-01-31 13:32:42 UTC
Needinfo for several month now; the line number likely cannot be used for the word count.
Comment 8 tripleo 2022-04-28 20:43:39 UTC
Nobody commented on my comment #3. (Or 4 for that matter)

There may be opposition to include this in the mainline.

I am happy to hack on it myself.  I have distro packages installed, but I mainly run a self compiled build.

If I could get some pointers on how to begin with this, I would happily maintain it for myself.

Another consideration is can this type of functionality be made available through a plugin?


tl;dr:

1a) Where is the line count code in Writer?
1b) Where is the word count code in Writer?

2) What are the limitations of the plugin architecture?
Comment 9 Heiko Tietze 2022-04-29 06:39:23 UTC
If you insert a variable into the document it needs to be defined in the format. And for your use case not only in ODF but also DOCX.

In case you just want to show the total count, it means probably to enhance the document statistics (click on the "<n> words, <m> characters" panel at the statusbar). The duplicate ticket here is bug 123083 with some code pointers.
Comment 10 Buovjaga 2022-04-29 06:51:06 UTC
I discussed this in the dev chat and after some back and forth I had an idea that could be implemented as an extension:

Insert a comment for each paragraph. The comment contains the word count.
When you print, go to the options tab and select Comments: Place in margins.

The API command for inserting a comment is
.uno:InsertAnnotation

Details: https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1text_1_1textfield_1_1Annotation.html

How does that sound?

Adding the word count as formatting data would be problematic for compatibility. Showing the count in place of line numbers might be confusing "e.g. when hyphenation is active, or in Asian texts" per one comment.

Regarding Stuart's comment 1, it is possible to navigate by words using this API method and looping by different word counts: https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1text_1_1XWordCursor.html
Comment 11 tripleo 2022-04-29 10:18:13 UTC
(In reply to Heiko Tietze from comment #9)
> If you insert a variable into the document it needs to be defined in the
> format. And for your use case not only in ODF but also DOCX.

Like I mentioned above, I don't care about docx. If I want this feature, I will use odt. (Unless there's something I'm missing...)

Thank you for the pointer -- I'll check it out.
Comment 12 tripleo 2022-04-29 10:28:17 UTC
(In reply to Buovjaga from comment #10)

...

> Insert a comment for each paragraph. 
> cross
> How does that sound?

...

My use case demands that a cumulative word count is presented per-line.


> Adding the word count as formatting data would be problematic for
> compatibility. 

Based on the comments elicited so far I have given up on cross-format compatibility (as explained in comment #11).

> Showing the count in place of line numbers might be confusing
> "e.g. when hyphenation is active, or in Asian texts" per one comment.

Personally, I do not use hyphenation, but maybe in this case a warning is sufficient?
As to your second point, I do not see a future for myself with Asian texts. (But do you mean that they are sometimes RTL?)

Right now, I am content to maintain a private fork, with all the pain and suffering this will bring ;)

I'm just not familiar with the codebase, so that's what I need help with at the moment. It doesn't seem like this will be mainlined, so, eh...
Comment 13 Buovjaga 2022-04-29 11:51:18 UTC
Another comment from the chat just now:
"A simpler solution to the problem is to have a macro that adds word-count fields into the running text, similar it is done to various bible texts (for sentences)."
Comment 14 tripleo 2022-05-01 14:49:25 UTC
(In reply to Buovjaga from comment #13)

> similar it is done to various bible texts (for sentences).

Not to give you work, but could you give a screenshot or something of that nature.

Also I have no idea how to do the macros.  Please don't ask me to program BASIC.  I left that alone in the 90s. (Half sarcasm.)
Comment 15 Buovjaga 2022-05-01 15:57:15 UTC
(In reply to tripleo from comment #14)
> (In reply to Buovjaga from comment #13)
> 
> > similar it is done to various bible texts (for sentences).
> 
> Not to give you work, but could you give a screenshot or something of that
> nature.
> 
> Also I have no idea how to do the macros.  Please don't ask me to program
> BASIC.  I left that alone in the 90s. (Half sarcasm.)

Sorry, I was just relaying the idea of someone else.

Maybe some kind soul could help and create such a macro, if you asked in https://ask.libreoffice.org/
Comment 16 tripleo 2022-05-17 21:06:22 UTC
(In reply to Buovjaga from comment #15)

> Sorry, I was just relaying the idea of someone else.

No need to apologize, thank you for your input.

...


My use case demands that a cumulative word count is presented per-line.

I am not concerned with cross-format compatibility.  Just like nobody else (maybe except AbiWord or something (Google Docs??) ) is concerned with ODT compatibility.  I do not use any of these other software products.

Right now, I am content to maintain a private fork, with all the pain and suffering this will bring ;)

WONTFIX is sad, but expected -- I seen this coming.  My question is how do I do it myself (without spending the rest of the year punishing myself browsing C++ code?)
Comment 17 Buovjaga 2022-05-18 06:19:44 UTC
(In reply to tripleo from comment #16)
> WONTFIX is sad, but expected -- I seen this coming.  My question is how do I
> do it myself (without spending the rest of the year punishing myself
> browsing C++ code?)

Like I said in my comment 15, you can request help in https://ask.libreoffice.org/
If it can be done as a macro (Basic or Python), there is no need for C++ code.