[Libreoffice-bugs] [Bug 30550] Character count without spaces

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Oct 14 15:00:39 CEST 2010


https://bugs.freedesktop.org/show_bug.cgi?id=30550

--- Comment #4 from Norbert Thiebaud <nthiebaud at gmail.com> 2010-10-14 06:00:37 PDT ---
for the counting it looks like the interesting function is:

void SwTxtNode::CountWords( SwDocStat& rStat, xub_StrLen nStt, xub_StrLen nEnd
) const
in writer/sw/source/core/txtnode.cxx

something like

diff --git a/sw/source/core/txtnode/txtedt.cxx
b/sw/source/core/txtnode/txtedt.cxx
index 19af890..ac83925 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1885,6 +1885,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
             ++rStat.nPara;
             ULONG nTmpWords = 0;
             ULONG nTmpChars = 0;
+            ULONG nTmpWordsChars = 0; // Count the umber of chars used in
words

             // Shortcut: Whole paragraph should be considered and cached
values
             // are valid:
@@ -1892,6 +1893,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
             {
                 nTmpWords = GetParaNumberOfWords();
                 nTmpChars = GetParaNumberOfChars();
+                nTmpWordsChars = GetParaNumberOfWordsChars();
             }
             else
             {
@@ -1925,9 +1927,14 @@ void SwTxtNode::CountWords( SwDocStat& rStat,

                     while ( aScanner.NextWord() )
                     {
-                        if ( aScanner.GetLen() > 1 ||
-                             CH_TXTATR_BREAKWORD !=
aExpandText.match(aBreakWord, aScanner.GetBegin() ) )
-                            ++nTmpWords;
+                        if(CH_TXTATR_BREAKWORD != ExpandText.match(aBreakWord,
aScanner.GetBegin() ))
+                        {
+                            if ( aScanner.GetLen() > 1)
+                            {
+                                ++nTmpWords;
+                            }
+                            nTmpWordsChar += aScanner.GetLen();
+                        }
                     }
                 }


should count the number of characters used in 'words' in a textnode.
which then need to be accumulated in the stat of the document...

then of course there are gui change to display it, and possibly some change to
be able to store it in the saved document (in order not to recalculated it at
every open...)...
That I have no clue where and how yet...

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Libreoffice-bugs mailing list