[Libreoffice] [PATCH] Fix for bug / feature request 30550 - Character count without spaces

Mattias Johnsson m.t.johnsson at gmail.com
Wed Oct 27 00:26:05 PDT 2010


Hi all,

Here are my patches for the easy hack / programming task "Count
characters without whitespace in the Writer statistics." Since it's
something translators have apparently been asking for OO.org to have
for eight years (see
http://www.openoffice.org/issues/show_bug.cgi?id=10356 and
https://bugs.freedesktop.org/show_bug.cgi?id=30550) it'd be nice for
it to appear in LibreOffice :-)

I've added an extra couple of lines to the word count dialog box which
give the number of characters excluding whitespace in both selected
text and the entire document. As far as the UI decision goes, I
checked in MS Word, and that's what it does, so I figure if it's good
enough for MS it's good enough for us.

Note: I'm still getting started with the LibreOffice code base, and
I'm not entirely certain what I'm doing. For example, I have no idea
about what is supposed to happen with regard to internationalisation,
or whether this also works under Windows, given that it affects the
UI.

Still, it builds and works under Ubuntu 10.10 x86_64. I've tested it
with a number of documents and it seems to give the right answers
(with a caveat, see below), and the answers with respect to the
standard word/character count are the same as before, so I at least
haven't broken anything. If my patches aren't up to scratch, hopefully
other people can at least use them as a starting point.

Now the caveat. There seems to be a bug, in that at least one document
(www.oasis-open.org/committees/download.php/25054/07-08-22-MetaData-Examples.odt
) gives the wrong word/character count if you open it and check the
document statistics. However if you edit it at all, such as adding a
character, and then check the statistics, they're then correct. It's
as though the load doesn't mark the word count as dirty or something.
Documents I create, save and open seem to work fine.

The reason I'm submitting these patches despite this bug is that that
bug was present before I made my changes. I just pulled the latest
git, built and checked to make sure. So my feature change works, and
moves things forward, but doesn't fix this orginal bug which I found
during testing my changes. Note that OpenOffice.org 3.2 (Ubuntu 10.10
x86_64 repository version) doesn't seem to have the bug.

It's not immediately obvious to me how to fix it, but hopefully it'll
be blindingly obvious to someone else.

Please examine, test, and tell me if I've done stuff that's horribly wrong :-P

Patches contributed under MPL 1.1 / GPLv3+ / LGPLv3+ licenses.

Cheers,
Mattias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chars-exclusive-of-whitespace-part1.patch
Type: text/x-patch
Size: 24822 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20101027/eb277650/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chars-exclusive-of-whitespace-part2.patch
Type: text/x-patch
Size: 11010 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20101027/eb277650/attachment-0003.bin>


More information about the LibreOffice mailing list