[PATCH] Word count dialog modeless

classic Classic list List threaded Threaded
16 messages Options
Matt Pratt Matt Pratt
Reply | Threaded
Open this post in threaded view
|

[PATCH] Word count dialog modeless

Hey everyone,

I've been meaning to do an easy hack ever since LibreOffice announced.
Not to get to political, but recently AOOo and the efforts of it's
backers has riled me up enough to push through the build issues I was
having and put my money (time) where my mouth is.

I've followed Michael Meek's blog over the years via planet GNOME, but
this post struck a chord with me:

http://mail-archives.apache.org/mod_mbox/incubator-ooo-dev/201110.mbox/%3C1319628345.22078.111.camel%40linux-yjtf.site%3E

So here I am with me first contribution.

I was thinking of an easy hack, but I had to submit a brief summary
recently where word count was limited and it was a pain to have to
continuously open the word count dialog.

I couldn't find a LO bug on this, but there is an OOo one from 2005:

http://openoffice.org/bugzilla/show_bug.cgi?id=46785

I thought it would be easier than it turned out to be, and expect some
changes may need to be made, but here it is, a fix for a 6 year old bug.

Patch licensed under LGPLv3+/MPL.

Thanks!

_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice

0001-Word-count-dialog-modeless.patch (27K) Download Attachment
Caolán McNamara Caolán McNamara
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Word count dialog modeless

On Tue, 2011-11-01 at 22:58 -0600, Matt Pratt wrote:
> I was thinking of an easy hack, but I had to submit a brief summary
> recently where word count was limited and it was a pain to have to
> continuously open the word count dialog.
>
> I couldn't find a LO bug on this, but there is an OOo one from 2005:
>
> http://openoffice.org/bugzilla/show_bug.cgi?id=46785

Looks very promising. Only catch so far is that wordcountwrapper.hxx is
missing from the patch, can you git add that one and send again ?

C.

_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Caolán McNamara Caolán McNamara
Reply | Threaded
Open this post in threaded view
|

[PUSHED][PATCH] Word count dialog modeless

On Wed, 2011-11-02 at 14:39 +0000, Caolán McNamara wrote:

> On Tue, 2011-11-01 at 22:58 -0600, Matt Pratt wrote:
> > I was thinking of an easy hack, but I had to submit a brief summary
> > recently where word count was limited and it was a pain to have to
> > continuously open the word count dialog.
> >
> > I couldn't find a LO bug on this, but there is an OOo one from 2005:
> >
> > http://openoffice.org/bugzilla/show_bug.cgi?id=46785
>
> Looks very promising. Only catch so far is that wordcountwrapper.hxx is
> missing from the patch, can you git add that one and send again ?

Oh wait, we don't need that header. Some small chopping and it builds
without it.

So, I've pushed this now. It made me chuckle to see the counts update as
I type along.

There are some titchy little wrinkles worth looking at, e.g. its got
handlers for cursor and mouse move and things like that to update the
count, but not apparently for selecting text by clicking the mouse, i.e.
double click to select a word and single click somewhere else to
unselect the text.

C.

_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Caolán McNamara Caolán McNamara
Reply | Threaded
Open this post in threaded view
|

Re: [PUSHED][PATCH] Word count dialog modeless

On Wed, 2011-11-02 at 14:55 +0000, Caolán McNamara wrote:
> There are some titchy little wrinkles worth looking at, e.g. its got
> handlers for cursor and mouse move and things like that to update the
> count, but not apparently for selecting text by clicking the mouse, i.e.
> double click to select a word and single click somewhere else to
> unselect the text.

I *think* the right thing to do is to additionally hook into "EndSelect"
which gets called when a selection is completed, and "Invalidate" which
seems to get called when a selection is discarded.
i.e.
http://cgit.freedesktop.org/libreoffice/core/commit/?id=0cbcb89fde8cc81db499bc1e388fd53ef6fa3c3f

Seems to work anyway.

C.

_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Michael Meeks-2 Michael Meeks-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Word count dialog modeless

In reply to this post by Matt Pratt
Hi Matt,

On Tue, 2011-11-01 at 22:58 -0600, Matt Pratt wrote:
> this post struck a chord with me:
> http://mail-archives.apache.org/mod_mbox/incubator-ooo-dev/201110.mbox/%3C1319628345.22078.111.camel%40linux-yjtf.site%3E
> So here I am with me first contribution.

        Awesome ! :-) thanks so much for getting involved, it is encouraging
indeed.

> I was thinking of an easy hack, but I had to submit a brief summary
> recently where word count was limited and it was a pain to have to
> continuously open the word count dialog.

        this is a highly requested feature by all and sundry, so you just made
a lot of people very happy. Speaking of which - it'd be great to people
know by updating:

        http://wiki.documentfoundation.org/ReleaseNotes/3.5

        with your name, and a short description - so you get proper credit come
release time :-)

> I thought it would be easier than it turned out to be, and
> expect some changes may need to be made, but here it is, a
> fix for a 6 year old bug.

        Brilliant; as I say lots of end-user requests for it, and journalists
love it no doubt. Do you have plans for other things ? One thing that
would prolly make people even happier would be the ability to dock the
window - I believe an SfxDockingWindow as a parent may help[1]. Of
course, to do that it'd be necessary (or useful) to make the dialog
re-size - which'd chuck you into the unpleasant world of VCL and it's
lack of layout containers - the fall-back being to manually move and
re-nail-down the widgets as the dialog re-sizes ;-) [ somewhat hair
raising ].

        Anyhow - like Caolan it was great to see it in action; and even not
noticeably hurting interactive performance on multi-hundred page
documents.

        Great work,

                Michael.

[1] - The StyleList dialog (usually shown by the far left button on
bottom toolbar in writer behaves like this, git grep DLG_STYLE_DESIGNER
or the color palette drop-downs from the toolbar do something similar
(but strangely differently title-wise)
--
[hidden email]  <><, Pseudo Engineer, itinerant idiot

_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Matt Pratt Matt Pratt
Reply | Threaded
Open this post in threaded view
|

Re: [PUSHED][PATCH] Word count dialog modeless

In reply to this post by Caolán McNamara
On 11/02/2011 10:10 AM, Caolán McNamara wrote:

> On Wed, 2011-11-02 at 14:55 +0000, Caolán McNamara wrote:
>> There are some titchy little wrinkles worth looking at, e.g. its got
>> handlers for cursor and mouse move and things like that to update the
>> count, but not apparently for selecting text by clicking the mouse, i.e.
>> double click to select a word and single click somewhere else to
>> unselect the text.
>
> I *think* the right thing to do is to additionally hook into "EndSelect"
> which gets called when a selection is completed, and "Invalidate" which
> seems to get called when a selection is discarded.
> i.e.
> http://cgit.freedesktop.org/libreoffice/core/commit/?id=0cbcb89fde8cc81db499bc1e388fd53ef6fa3c3f
>
> Seems to work anyway.

Wow, thanks for sorting out the wrinkles and pushing the patch so quickly.

I think with your hook into EndSelect we may be able to get rid of the
mouse hook?
_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Matt Pratt Matt Pratt
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Word count dialog modeless

In reply to this post by Michael Meeks-2
Hi Michael,

On 11/02/2011 10:42 AM, Michael Meeks wrote:
>
> this is a highly requested feature by all and sundry, so you just made
> a lot of people very happy. Speaking of which - it'd be great to people
> know by updating:
>
> http://wiki.documentfoundation.org/ReleaseNotes/3.5
>
> with your name, and a short description - so you get proper credit come
> release time :-)

Done.

> Brilliant; as I say lots of end-user requests for it, and journalists
> love it no doubt. Do you have plans for other things ? One thing that
> would prolly make people even happier would be the ability to dock the
> window - I believe an SfxDockingWindow as a parent may help[1]. Of
> course, to do that it'd be necessary (or useful) to make the dialog
> re-size - which'd chuck you into the unpleasant world of VCL and it's
> lack of layout containers - the fall-back being to manually move and
> re-nail-down the widgets as the dialog re-sizes ;-) [ somewhat hair
> raising ].

I did find this when I was initially looking around:

https://issues.apache.org/ooo/show_bug.cgi?id=41454

I would be pretty easy to add it to the Page section in the status bar.

e.g.

Page 1/2 (354 words)

Would that be an acceptable UI change?

I think MS Word has something I this, but I no idea if it on by default
or some soft of option or dock.

BTW, thanks for the mention on the blog. :)

Cheers,
Matt
_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Caolán McNamara Caolán McNamara
Reply | Threaded
Open this post in threaded view
|

Re: [PUSHED][PATCH] Word count dialog modeless

In reply to this post by Matt Pratt
On Wed, 2011-11-02 at 20:21 -0600, Matt Pratt wrote:
> I think with your hook into EndSelect we may be able to get rid of the
> mouse hook?

Give it a shot. Might be the case that EndSelect is not triggered while
holding down the mouse, i.e. dragging to select text, text gets
hightlighted, but count not updated until mouse released. Unsure if
that's what would happen, and if that is what happens if that's a good
thing or a bad thing.

C.

_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Jean-Baptiste_Faure Jean-Baptiste_Faure
Reply | Threaded
Open this post in threaded view
|

Re: [PUSHED][PATCH] Word count dialog modeless

In reply to this post by Matt Pratt
Le 03/11/2011 03:21, Matt Pratt a écrit :

> On 11/02/2011 10:10 AM, Caolán McNamara wrote:
>> On Wed, 2011-11-02 at 14:55 +0000, Caolán McNamara wrote:
>>> There are some titchy little wrinkles worth looking at, e.g. its got
>>> handlers for cursor and mouse move and things like that to update the
>>> count, but not apparently for selecting text by clicking the mouse, i.e.
>>> double click to select a word and single click somewhere else to
>>> unselect the text.
>>
>> I *think* the right thing to do is to additionally hook into "EndSelect"
>> which gets called when a selection is completed, and "Invalidate" which
>> seems to get called when a selection is discarded.
>> i.e.
>> http://cgit.freedesktop.org/libreoffice/core/commit/?id=0cbcb89fde8cc81db499bc1e388fd53ef6fa3c3f
>>
>>
>> Seems to work anyway.
>
> Wow, thanks for sorting out the wrinkles and pushing the patch so quickly.
>
> I think with your hook into EndSelect we may be able to get rid of the
> mouse hook?

Hi Matt,

I tested the new Word count dialog in the master. It works well but I
have two points:
- I do not know if it possible to make the window resizable, in order do
not mask the text area
- the counts are updated when you press a character key. If you use an
autotext (F3), the counts are updated once you have entered another
character. To test : enter DT+F3 (if your UI is in English, DT for Dummy
Text).

Thank you for this patch. :-)

Best regards.
JBF

--
Seuls des formats ouverts peuvent assurer la pérennité de vos documents.
_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Seuls des formats ouverts peuvent assurer la pérennité de vos documents.
Rodolfo R Gomes Rodolfo R Gomes
Reply | Threaded
Open this post in threaded view
|

Re: [PUSHED][PATCH] Word count dialog modeless

I found one issue:
- When we select by shortcuts (eg, shift + left arrow) it only updates
selection counts in a next selection (showing the results of the
previous selection region)

Regards.

2011/11/3 Jean-Baptiste Faure <[hidden email]>:

> Le 03/11/2011 03:21, Matt Pratt a écrit :
>> On 11/02/2011 10:10 AM, Caolán McNamara wrote:
>>> On Wed, 2011-11-02 at 14:55 +0000, Caolán McNamara wrote:
>>>> There are some titchy little wrinkles worth looking at, e.g. its got
>>>> handlers for cursor and mouse move and things like that to update the
>>>> count, but not apparently for selecting text by clicking the mouse, i.e.
>>>> double click to select a word and single click somewhere else to
>>>> unselect the text.
>>>
>>> I *think* the right thing to do is to additionally hook into "EndSelect"
>>> which gets called when a selection is completed, and "Invalidate" which
>>> seems to get called when a selection is discarded.
>>> i.e.
>>> http://cgit.freedesktop.org/libreoffice/core/commit/?id=0cbcb89fde8cc81db499bc1e388fd53ef6fa3c3f
>>>
>>>
>>> Seems to work anyway.
>>
>> Wow, thanks for sorting out the wrinkles and pushing the patch so quickly.
>>
>> I think with your hook into EndSelect we may be able to get rid of the
>> mouse hook?
>
> Hi Matt,
>
> I tested the new Word count dialog in the master. It works well but I
> have two points:
> - I do not know if it possible to make the window resizable, in order do
> not mask the text area
> - the counts are updated when you press a character key. If you use an
> autotext (F3), the counts are updated once you have entered another
> character. To test : enter DT+F3 (if your UI is in English, DT for Dummy
> Text).
>
> Thank you for this patch. :-)
>
> Best regards.
> JBF
>
> --
> Seuls des formats ouverts peuvent assurer la pérennité de vos documents.
> _______________________________________________
> LibreOffice mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>
_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Caolán McNamara Caolán McNamara
Reply | Threaded
Open this post in threaded view
|

Re: [PUSHED][PATCH] Word count dialog modeless

In reply to this post by Jean-Baptiste_Faure
On Thu, 2011-11-03 at 23:09 +0100, Jean-Baptiste Faure wrote:
> - I do not know if it possible to make the window resizable, in order do
> not mask the text area

Should put resizability aside for the moment. That's a long-standing
general problem with nearly all our dialogs which needs a some general
work to give a generic solution.

C.

_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Michael Meeks-2 Michael Meeks-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Word count dialog modeless

In reply to this post by Matt Pratt
Hi Matt,

On Wed, 2011-11-02 at 20:34 -0600, Matt Pratt wrote:
> I did find this when I was initially looking around:
>     https://issues.apache.org/ooo/show_bug.cgi?id=41454
>
> I would be pretty easy to add it to the Page section in the status bar.

        :-) sounds reasonable. My only concern would be to make it discoverable
and of course performance: would we take a per-keystroke hit there ? so
perhaps having it easy-to-enable but disabled by default would make
sense.

> eg. Page 1/2 (354 words)
> Would that be an acceptable UI change?

        Sounds fine to me - but we have the ux-advise list for this sort of
thing. I think Kendy is gunning to allow people to remove the status bar
altogether ;-) but ... no doubt that is not to everyone's taste.

> I think MS Word has something I this, but I no idea if it on by default
> or some soft of option or dock.

        Interesting question of course. Clearly docking the word-count window
is an easy option wrt. adding new UI.

        Some statusbar controls seem to live in svx/source/stbctrls/ I suspect
this page one is in writer. It looks like the string comes from:
sw/source/ui/view2.cxx /GetPageStr/ and is pushed to the view frame
by /UpdatePageNums/ which we prolly want to conditionally hook into - no
doubt it is more tangled than that, does it help ?

> BTW, thanks for the mention on the blog. :)

        Hey - thanks for the nice patch :-) looking forward to your next -
although the feature-freeze loometh on Dec 5th :-)

        All the best,

                Michael.

--
[hidden email]  <><, Pseudo Engineer, itinerant idiot

_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Stefan Knorr (Astron) Stefan Knorr (Astron)
Reply | Threaded
Open this post in threaded view
|

Re: [Libreoffice-ux-advise] [PATCH] Word count dialog modeless

Hi everyone,

First of all: very nice feature indeed!

On 15 November 2011 19:15, Michael Meeks <[hidden email]> wrote:
>        :-) sounds reasonable. My only concern would be to make it discoverable
> and of course performance: would we take a per-keystroke hit there ? so
> perhaps having it easy-to-enable but disabled by default would make
> sense.

How large is the hit? Has anyone measured already?
Personally, I can't really perceive anything when comparing writing
with the Word Count window open v/ without it.


>> eg. Page 1/2 (354 words)
>> Would that be an acceptable UI change?
>
>        Sounds fine to me - but we have the ux-advise list for this sort of
> thing. I think Kendy is gunning to allow people to remove the status bar
> altogether ;-) but ... no doubt that is not to everyone's taste.

I tend to agree with Kendy here. We also already have a lot of things
in the status bar already, to the point where it looks cluttered on
smaller screens.


>> I think MS Word has something I this, but I no idea if it on by default
>> or some soft of option or dock.
>
>        Interesting question of course. Clearly docking the word-count window
> is an easy option wrt. adding new UI.

I like this as a solution much better, that's for two reasons:
* currently we don't use the space to sides of the pages at all
(except for the ruler and the scrollbar)
* more information can be presented in a much more coherent manner
than in a status bar
Would it be possible to add the word count as a "Tasks" sidebar
element (see Impress/Draw)? (This is possible in Writer, see the
recently released AccessODF extension [1] which also uses the tasks
sidebar. I think the interface is also XML based there, no idea if
that tells us anything about how easy relayouting is.)

Astron.


[1] sourceforge.net/p/accessodf
_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Kevin Hunter Kevin Hunter
Reply | Threaded
Open this post in threaded view
|

Re: [Libreoffice-ux-advise] [PATCH] Word count dialog modeless

At 12:51pm -0500 Wed, 16 Nov 2011, Astron wrote:
> On 15 November 2011 19:15, Michael Meeks wrote:
>> :-) sounds reasonable. My only concern would be to make it
>> discoverable and of course performance: would we take a
>> per-keystroke hit there ? so perhaps having it easy-to-enable but
>> disabled by default would make sense.
>
> How large is the hit? Has anyone measured already? Personally, I
> can't really perceive anything when comparing writing with the Word
> Count window open v/ without it.

It seems to me to be an issue of how one implements the word count
statistics collection.  Are the word count statistics constantly kept
up-to-date via a incrementers/decrementers per key-stroke?  Or are they
only collected upon request?

 From a brief and unscientific test of copying 10MiB of copy and paste
text into a Writer document, waiting while it paginates to 2250 pages,
then timing how long it takes for the Word Count dialog to give results,
it would appear the former: every keystroke /already/ calculates the
these statistics.

Thus, my first un-educated guess is that this should have very little
performance impact.

Cheers,

Kevin
_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Christoph Noack Christoph Noack
Reply | Threaded
Open this post in threaded view
|

Re: [Libreoffice-ux-advise] [PATCH] Word count dialog modeless

Hi Matt, Kevin, Michael, Astron ... all!

First and foremost, Matt, thank you for the extremely helpful patch ...
or (speaking as a non-developer), for the great improvement. Awesome!

I finally had some time to test it and I'd like to point out three
(mostly tiny) things...

First, since the dialog is now non-modal, the "OK" button does not have
the desired meaning anymore. "Close" is more appropriate in this case -
could you please update that?

Second, the menu item "Word Count" is now a toggle for the dialog -
that's fine. But in this case we need a "checkbox" in front of the menu
item (true = dialog is enabled, false = dialog is not disabled).

Next, I played a bit and run into an issue when working with the Writer
Comments. Steps to reproduce:
     1. Prepare a document with text, and comments - set the cursor into
        the text
     2. Open the word count dialog -> the word count is correctly
        displayed
     3. Click into any note -> the word count dialog disappears
     4. Press ESC to exit the note

Expected result: The word count dialog appears and shows the correct
values. The cursor is back in the document (to continue typing). (Mmh,
is it possible to show the dialog also when editing the comments?)

Current result: The word count dialog appears, but shows no numbers. The
cursor is not in the document. (To me, it seems the Word Count dialog
gets the focus instead of the document).

Can you reproduce that? Shall I create an issue for that?


Matt, I hope you find that information somehow helpful. It would be cool
if some things could be implemented ... thank you again!

Cheers,
Christoph

Am Mittwoch, den 16.11.2011, 13:44 -0500 schrieb Kevin Hunter:

> At 12:51pm -0500 Wed, 16 Nov 2011, Astron wrote:
> > On 15 November 2011 19:15, Michael Meeks wrote:
> >> :-) sounds reasonable. My only concern would be to make it
> >> discoverable and of course performance: would we take a
> >> per-keystroke hit there ? so perhaps having it easy-to-enable but
> >> disabled by default would make sense.
> >
> > How large is the hit? Has anyone measured already? Personally, I
> > can't really perceive anything when comparing writing with the Word
> > Count window open v/ without it.
>
> It seems to me to be an issue of how one implements the word count
> statistics collection.  Are the word count statistics constantly kept
> up-to-date via a incrementers/decrementers per key-stroke?  Or are they
> only collected upon request?
>
>  From a brief and unscientific test of copying 10MiB of copy and paste
> text into a Writer document, waiting while it paginates to 2250 pages,
> then timing how long it takes for the Word Count dialog to give results,
> it would appear the former: every keystroke /already/ calculates the
> these statistics.
>
> Thus, my first un-educated guess is that this should have very little
> performance impact.
>
> Cheers,
>
> Kevin
> _______________________________________________
> Libreoffice-ux-advise mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/libreoffice-ux-advise


_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Stefan Knorr (Astron) Stefan Knorr (Astron)
Reply | Threaded
Open this post in threaded view
|

Re: [Libreoffice-ux-advise] [PATCH] Word count dialog modeless

Hi all,

FWIW, I just [pushed] a change to fix this, along with some other
minor updates to the UI, I hope that's fine with everyone:
> First, since the dialog is now non-modal, the "OK" button does not have
> the desired meaning anymore. "Close" is more appropriate in this case -
> could you please update that?

Next,...

> Next, I played a bit and run into an issue when working with the Writer
> Comments. Steps to reproduce:
>     1. Prepare a document with text, and comments - set the cursor into
>        the text
>     2. Open the word count dialog -> the word count is correctly
>        displayed
>     3. Click into any note -> the word count dialog disappears
>     4. Press ESC to exit the note
>
> Expected result: The word count dialog appears and shows the correct
> values. The cursor is back in the document (to continue typing). (Mmh,
> is it possible to show the dialog also when editing the comments?)
>
> Current result: The word count dialog appears, but shows no numbers. The
> cursor is not in the document. (To me, it seems the Word Count dialog
> gets the focus instead of the document).

Can reliably reproduce with my as-of-now very current build. Have you
opened a bug for that already, Christoph?


Astron.
_______________________________________________
LibreOffice mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/libreoffice