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
From 5ac50b845feab1ab1901cd52593237c3676e097b Mon Sep 17 00:00:00 2001
From: Mattias Johnsson <m.t.johnsson@gmail.com>
Date: Wed, 27 Oct 2010 18:01:43 +1100
Subject: [PATCH] Add character count exclusive of whitespace to document statistics part 1
---
sw/inc/docstat.hxx | 1 +
sw/inc/ndtxt.hxx | 2 +
sw/source/core/doc/docstat.cxx | 2 +
sw/source/core/txtnode/txtedt.cxx | 115 +++++++++++++++++-------------
sw/source/ui/dialog/wordcountdialog.cxx | 6 ++
sw/source/ui/dialog/wordcountdialog.hrc | 30 +++++----
sw/source/ui/dialog/wordcountdialog.src | 42 +++++++++---
sw/source/ui/inc/wordcountdialog.hxx | 4 +
8 files changed, 130 insertions(+), 72 deletions(-)
diff --git a/sw/inc/docstat.hxx b/sw/inc/docstat.hxx
index a818e2f..8b156bf 100644
--- a/sw/inc/docstat.hxx
+++ b/sw/inc/docstat.hxx
@@ -44,6 +44,7 @@ struct SW_DLLPUBLIC SwDocStat
ULONG nAllPara;
ULONG nWord;
ULONG nChar;
+ ULONG nCharExcludingSpaces;
BOOL bModified;
SwDocStat();
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 08410b0..713a30b 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -189,6 +189,8 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable
SW_DLLPRIVATE ULONG GetParaNumberOfWords() const;
SW_DLLPRIVATE void SetParaNumberOfChars( ULONG nTmpChars ) const;
SW_DLLPRIVATE ULONG GetParaNumberOfChars() const;
+ SW_DLLPRIVATE void SetParaNumberOfCharsExcludingSpaces( ULONG nTmpChars ) const;
+ SW_DLLPRIVATE ULONG GetParaNumberOfCharsExcludingSpaces() const;
SW_DLLPRIVATE void InitSwParaStatistics( bool bNew );
/** create number for this text node, if not already existing
diff --git a/sw/source/core/doc/docstat.cxx b/sw/source/core/doc/docstat.cxx
index b75a057..e2bef7f 100644
--- a/sw/source/core/doc/docstat.cxx
+++ b/sw/source/core/doc/docstat.cxx
@@ -46,6 +46,7 @@ SwDocStat::SwDocStat() :
nAllPara(1),
nWord(0),
nChar(0),
+ nCharExcludingSpaces(0),
bModified(TRUE)
{}
@@ -63,6 +64,7 @@ void SwDocStat::Reset()
nAllPara= 1;
nWord = 0;
nChar = 0;
+ nCharExcludingSpaces = 0;
bModified = TRUE;
}
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index aa8faaa..ad2eb8b 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -93,7 +93,6 @@
#include <vector>
-
using rtl::OUString;
using namespace ::com::sun::star;
using namespace ::com::sun::star::frame;
@@ -385,7 +384,7 @@ inline BOOL InRange(xub_StrLen nIdx, xub_StrLen nStart, xub_StrLen nEnd) {
/* 5 cases:
* 1) The attribute is completely in the deletion range:
- * -> delete it
+ * -> delete it
* 2) The end of the attribute is in the deletion range:
* -> delete it, then re-insert it with new end
* 3) The start of the attribute is in the deletion range:
@@ -481,7 +480,6 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich,
continue;
}
-
if( nStt <= nAttrStart ) // Faelle: 1,3,5
{
if( nEnd > nAttrStart
@@ -599,7 +597,6 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich,
nsSetAttrMode::SETATTR_NOHINTADJUST );
}
-
// jetzt kein i+1, weil das eingefuegte Attribut
// ein anderes auf die Position geschoben hat !
continue;
@@ -624,8 +621,6 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich,
}
}
-
-
/*************************************************************************
* SwTxtNode::GetCurWord()
*
@@ -810,7 +805,6 @@ BOOL SwScanner::NextWord()
return TRUE;
}
-
USHORT SwTxtNode::Spell(SwSpellArgs* pArgs)
{
// Die Aehnlichkeiten zu SwTxtFrm::_AutoSpell sind beabsichtigt ...
@@ -938,7 +932,6 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs)
return pArgs->xSpellAlt.is() ? 1 : 0;
}
-
void SwTxtNode::SetLanguageAndFont( const SwPaM &rPaM,
LanguageType nLang, USHORT nLangWhichId,
const Font *pFont, USHORT nFontWhichId )
@@ -974,7 +967,6 @@ void SwTxtNode::SetLanguageAndFont( const SwPaM &rPaM,
}
-
USHORT SwTxtNode::Convert( SwConversionArgs &rArgs )
{
// get range of text within node to be converted
@@ -1405,7 +1397,6 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNode* /*pActNode*/, xub_StrLen
/*nActPos*/
return aRet;
}
-
// Wird vom CollectAutoCmplWords gerufen
void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos )
{
@@ -1421,7 +1412,6 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos
)
xub_StrLen nLen;
BOOL bACWDirty = FALSE, bAnyWrd = FALSE;
-
if( nBegin < nEnd )
{
USHORT nCnt = 200;
@@ -1457,7 +1447,6 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos
)
pNode->SetAutoCompleteWordDirty( FALSE );
}
-
/*************************************************************************
* SwTxtNode::Hyphenate
*************************************************************************/
@@ -1518,7 +1507,6 @@ BOOL SwTxtNode::Hyphenate( SwInterHyphInfo &rHyphInf )
// globale Variable
SwLinguStatistik aSwLinguStat;
-
void SwLinguStatistik::Flush()
{
if ( !nWords )
@@ -1586,7 +1574,6 @@ void SwLinguStatistik::Flush()
#endif
-
struct TransliterationChgData
{
xub_StrLen nStart;
@@ -1596,25 +1583,25 @@ struct TransliterationChgData
};
// change text to Upper/Lower/Hiragana/Katagana/...
-void SwTxtNode::TransliterateText(
+void SwTxtNode::TransliterateText(
utl::TransliterationWrapper& rTrans,
- xub_StrLen nStt, xub_StrLen nEnd,
+ xub_StrLen nStt, xub_StrLen nEnd,
SwUndoTransliterate* pUndo )
{
if (nStt < nEnd && pBreakIt->GetBreakIter().is())
{
// since we don't use Hiragana/Katakana or half-width/full-width transliterations here
- // it is fine to use ANYWORD_IGNOREWHITESPACES. (ANY_WORD btw is broken and will
+ // it is fine to use ANYWORD_IGNOREWHITESPACES. (ANY_WORD btw is broken and will
// occasionaly miss words in consecutive sentences). Also with ANYWORD_IGNOREWHITESPACES
// text like 'just-in-time' will be converted to 'Just-In-Time' which seems to be the
// proper thing to do.
const sal_Int16 nWordType = WordType::ANYWORD_IGNOREWHITESPACES;
//! In order to have less trouble with changing text size, e.g. because
- //! of ligatures or � (German small sz) being resolved, we need to process
- //! the text replacements from end to start.
- //! This way the offsets for the yet to be changed words will be
- //! left unchanged by the already replaced text.
+ //! of ligatures or � (German small sz) being resolved, we need to process
+ //! the text replacements from end to start.
+ //! This way the offsets for the yet to be changed words will be
+ //! left unchanged by the already replaced text.
//! For this we temporarily save the changes to be done in this vector
std::vector< TransliterationChgData > aChanges;
TransliterationChgData aChgData;
@@ -1686,19 +1673,19 @@ void SwTxtNode::TransliterateText(
{
// for 'sentence case' we need to iterate sentence by sentence
- sal_Int32 nLastStart = pBreakIt->GetBreakIter()->beginOfSentence(
- GetTxt(), nEnd,
+ sal_Int32 nLastStart = pBreakIt->GetBreakIter()->beginOfSentence(
+ GetTxt(), nEnd,
pBreakIt->GetLocale( GetLang( nEnd ) ) );
- sal_Int32 nLastEnd = pBreakIt->GetBreakIter()->endOfSentence(
- GetTxt(), nLastStart,
+ sal_Int32 nLastEnd = pBreakIt->GetBreakIter()->endOfSentence(
+ GetTxt(), nLastStart,
pBreakIt->GetLocale( GetLang( nLastStart ) ) );
-
+
// extend nStt, nEnd to the current sentence boundaries
- sal_Int32 nCurrentStart = pBreakIt->GetBreakIter()->beginOfSentence(
- GetTxt(), nStt,
+ sal_Int32 nCurrentStart = pBreakIt->GetBreakIter()->beginOfSentence(
+ GetTxt(), nStt,
pBreakIt->GetLocale( GetLang( nStt ) ) );
- sal_Int32 nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence(
- GetTxt(), nCurrentStart,
+ sal_Int32 nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence(
+ GetTxt(), nCurrentStart,
pBreakIt->GetLocale( GetLang( nCurrentStart ) ) );
// prevent backtracking to the previous sentence if selection starts at end of a
sentence
@@ -1706,19 +1693,19 @@ void SwTxtNode::TransliterateText(
{
// now nCurrentStart is probably located on a non-letter word. (unless we
// are in Asian text with no spaces...)
- // Thus to get the real sentence start we should locate the next real word,
+ // Thus to get the real sentence start we should locate the next real word,
// that is one found by DICTIONARY_WORD
- i18n::Boundary aBndry = pBreakIt->GetBreakIter()->nextWord(
+ i18n::Boundary aBndry = pBreakIt->GetBreakIter()->nextWord(
GetTxt(), nCurrentEnd,
pBreakIt->GetLocale( GetLang( nCurrentEnd ) ),
i18n::WordType::DICTIONARY_WORD);
// now get new current sentence boundaries
- nCurrentStart = pBreakIt->GetBreakIter()->beginOfSentence(
- GetTxt(), aBndry.startPos,
+ nCurrentStart = pBreakIt->GetBreakIter()->beginOfSentence(
+ GetTxt(), aBndry.startPos,
pBreakIt->GetLocale( GetLang( aBndry.startPos) ) );
- nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence(
- GetTxt(), nCurrentStart,
+ nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence(
+ GetTxt(), nCurrentStart,
pBreakIt->GetLocale( GetLang( nCurrentStart) ) );
}
// prevent advancing to the next sentence if selection ends at start of a sentence
@@ -1726,14 +1713,14 @@ void SwTxtNode::TransliterateText(
{
// now nCurrentStart is probably located on a non-letter word. (unless we
// are in Asian text with no spaces...)
- // Thus to get the real sentence start we should locate the previous real word,
+ // Thus to get the real sentence start we should locate the previous real word,
// that is one found by DICTIONARY_WORD
- i18n::Boundary aBndry = pBreakIt->GetBreakIter()->previousWord(
- GetTxt(), nLastStart,
+ i18n::Boundary aBndry = pBreakIt->GetBreakIter()->previousWord(
+ GetTxt(), nLastStart,
pBreakIt->GetLocale( GetLang( nLastStart) ),
i18n::WordType::DICTIONARY_WORD);
- nLastEnd = pBreakIt->GetBreakIter()->endOfSentence(
- GetTxt(), aBndry.startPos,
+ nLastEnd = pBreakIt->GetBreakIter()->endOfSentence(
+ GetTxt(), aBndry.startPos,
pBreakIt->GetLocale( GetLang( aBndry.startPos) ) );
if (nCurrentEnd > nLastEnd)
nCurrentEnd = nLastEnd;
@@ -1748,7 +1735,7 @@ void SwTxtNode::TransliterateText(
#endif
Sequence <sal_Int32> aOffsets;
- String sChgd( rTrans.transliterate( GetTxt(),
+ String sChgd( rTrans.transliterate( GetTxt(),
GetLang( nCurrentStart ), nCurrentStart, nLen, &aOffsets ));
if (!m_Text.Equals( sChgd, nStt, nLen ))
@@ -1766,8 +1753,8 @@ void SwTxtNode::TransliterateText(
pBreakIt->GetLocale( GetLang( nCurrentEnd ) ),
nWordType);
nCurrentStart = aFirstWordBndry.startPos;
- nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence(
- GetTxt(), nCurrentStart,
+ nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence(
+ GetTxt(), nCurrentStart,
pBreakIt->GetLocale( GetLang( nCurrentStart ) ) );
}
}
@@ -1830,7 +1817,6 @@ void SwTxtNode::TransliterateText(
}
}
-
void SwTxtNode::ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen,
const XubString& rText,
const Sequence<sal_Int32>& rOffsets )
@@ -1886,6 +1872,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
++rStat.nPara;
ULONG nTmpWords = 0;
ULONG nTmpChars = 0;
+ ULONG nTmpCharsExcludingSpaces = 0; // Number of characters in actual words (i.e.
excluding spaces)
// Shortcut: Whole paragraph should be considered and cached values
// are valid:
@@ -1893,6 +1880,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
{
nTmpWords = GetParaNumberOfWords();
nTmpChars = GetParaNumberOfChars();
+ nTmpCharsExcludingSpaces = GetParaNumberOfCharsExcludingSpaces();
}
else
{
@@ -1926,9 +1914,19 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
while ( aScanner.NextWord() )
{
- if ( aScanner.GetLen() > 1 ||
- CH_TXTATR_BREAKWORD != aExpandText.match(aBreakWord,
aScanner.GetBegin() ) )
- ++nTmpWords;
+
+//if ( aScanner.GetLen() > 1 ||
+ // CH_TXTATR_BREAKWORD != aExpandText.match(aBreakWord,
aScanner.GetBegin() ) )
+ // ++nTmpWords;
+ if(CH_TXTATR_BREAKWORD != aExpandText.match(aBreakWord,
aScanner.GetBegin() ))
+ {
+ // if ( aScanner.GetLen() > 1)
+ //{
+ ++nTmpWords;
+ //}
+ nTmpCharsExcludingSpaces += aScanner.GetLen();
+ }
+
}
}
@@ -1972,12 +1970,14 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
{
SetParaNumberOfWords( nTmpWords );
SetParaNumberOfChars( nTmpChars );
+ SetParaNumberOfCharsExcludingSpaces( nTmpCharsExcludingSpaces );
SetWordCountDirty( false );
}
}
rStat.nWord += nTmpWords;
rStat.nChar += nTmpChars;
+ rStat.nCharExcludingSpaces += nTmpCharsExcludingSpaces;
}
}
}
@@ -1992,6 +1992,7 @@ struct SwParaIdleData_Impl
SwWrongList* pSmartTags;
ULONG nNumberOfWords;
ULONG nNumberOfChars;
+ ULONG nNumberOfCharsExcludingSpaces;
bool bWordCountDirty : 1;
bool bWrongDirty : 1; // Ist das Wrong-Feld auf invalid?
bool bGrammarCheckDirty : 1;
@@ -2004,6 +2005,7 @@ struct SwParaIdleData_Impl
pSmartTags ( 0 ),
nNumberOfWords ( 0 ),
nNumberOfChars ( 0 ),
+ nNumberOfCharsExcludingSpaces ( 0 ),
bWordCountDirty ( true ),
bWrongDirty ( true ),
bGrammarCheckDirty ( true ),
@@ -2051,7 +2053,6 @@ const SwWrongList* SwTxtNode::GetWrong() const
}
// <--
-
void SwTxtNode::SetGrammarCheck( SwGrammarMarkUp* pNew, bool bDelete )
{
if ( m_pParaIdleData_Impl )
@@ -2118,6 +2119,20 @@ void SwTxtNode::SetWordCountDirty( bool bNew ) const
m_pParaIdleData_Impl->bWordCountDirty = bNew;
}
}
+
+ULONG SwTxtNode::GetParaNumberOfCharsExcludingSpaces() const
+{
+ return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->nNumberOfCharsExcludingSpaces : 0;
+}
+
+void SwTxtNode::SetParaNumberOfCharsExcludingSpaces( ULONG nNew ) const
+{
+ if ( m_pParaIdleData_Impl )
+ {
+ m_pParaIdleData_Impl->nNumberOfCharsExcludingSpaces = nNew;
+ }
+}
+
bool SwTxtNode::IsWordCountDirty() const
{
return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bWordCountDirty : 0;
diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx
index 113fe2b..808e169 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -58,12 +58,16 @@ SwWordCountDialog::SwWordCountDialog(Window* pParent) :
aCurrentWordFI( this, SW_RES( FI_CURRENTWORD )),
aCurrentCharacterFT( this, SW_RES( FT_CURRENTCHARACTER )),
aCurrentCharacterFI( this, SW_RES( FI_CURRENTCHARACTER )),
+ aCurrentCharacterExcludingSpacesFT( this, SW_RES( FT_CURRENTCHARACTEREXCLUDINGSPACES )),
+ aCurrentCharacterExcludingSpacesFI( this, SW_RES( FI_CURRENTCHARACTEREXCLUDINGSPACES )),
aDocFL( this, SW_RES( FL_DOC )),
aDocWordFT( this, SW_RES( FT_DOCWORD )),
aDocWordFI( this, SW_RES( FI_DOCWORD )),
aDocCharacterFT( this, SW_RES( FT_DOCCHARACTER )),
aDocCharacterFI( this, SW_RES( FI_DOCCHARACTER )),
+ aDocCharacterExcludingSpacesFT( this, SW_RES( FT_DOCCHARACTEREXCLUDINGSPACES )),
+ aDocCharacterExcludingSpacesFI( this, SW_RES( FI_DOCCHARACTEREXCLUDINGSPACES )),
aBottomFL(this, SW_RES( FL_BOTTOM )),
aOK( this, SW_RES( PB_OK )),
aHelp( this, SW_RES( PB_HELP ))
@@ -85,8 +89,10 @@ void SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& r
{
aCurrentWordFI.SetText( String::CreateFromInt32(rCurrent.nWord ));
aCurrentCharacterFI.SetText(String::CreateFromInt32(rCurrent.nChar ));
+
aCurrentCharacterExcludingSpacesFI.SetText(String::CreateFromInt32(rCurrent.nCharExcludingSpaces ));
aDocWordFI.SetText( String::CreateFromInt32(rDoc.nWord ));
aDocCharacterFI.SetText( String::CreateFromInt32(rDoc.nChar ));
+ aDocCharacterExcludingSpacesFI.SetText( String::CreateFromInt32(rDoc.nCharExcludingSpaces
));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/dialog/wordcountdialog.hrc b/sw/source/ui/dialog/wordcountdialog.hrc
index ccb6391..f8b64c8 100644
--- a/sw/source/ui/dialog/wordcountdialog.hrc
+++ b/sw/source/ui/dialog/wordcountdialog.hrc
@@ -26,18 +26,22 @@
************************************************************************/
#ifndef SW_WORDCOUNTDIALOG_HRC
#define SW_WORDCOUNTDIALOG_HRC
-#define FL_CURRENT 1
-#define FT_CURRENTWORD 2
-#define FI_CURRENTWORD 3
-#define FT_CURRENTCHARACTER 4
-#define FI_CURRENTCHARACTER 5
-#define FL_DOC 6
-#define FT_DOCWORD 7
-#define FI_DOCWORD 8
-#define FT_DOCCHARACTER 9
-#define FI_DOCCHARACTER 10
-#define FL_BOTTOM 11
-#define PB_OK 12
-#define PB_HELP 13
+#define FL_CURRENT 1
+#define FT_CURRENTWORD 2
+#define FI_CURRENTWORD 3
+#define FT_CURRENTCHARACTER 4
+#define FI_CURRENTCHARACTER 5
+#define FT_CURRENTCHARACTEREXCLUDINGSPACES 6
+#define FI_CURRENTCHARACTEREXCLUDINGSPACES 7
+#define FL_DOC 8
+#define FT_DOCWORD 9
+#define FI_DOCWORD 10
+#define FT_DOCCHARACTER 11
+#define FI_DOCCHARACTER 12
+#define FT_DOCCHARACTEREXCLUDINGSPACES 13
+#define FI_DOCCHARACTEREXCLUDINGSPACES 14
+#define FL_BOTTOM 15
+#define PB_OK 16
+#define PB_HELP 17
#endif
diff --git a/sw/source/ui/dialog/wordcountdialog.src b/sw/source/ui/dialog/wordcountdialog.src
index d2d4676..359d95e 100644
--- a/sw/source/ui/dialog/wordcountdialog.src
+++ b/sw/source/ui/dialog/wordcountdialog.src
@@ -32,7 +32,7 @@ ModalDialog DLG_WORDCOUNT
HelpID = HID_DLG_WORDCOUNT ;
OutputSize = TRUE ;
SVLook = TRUE ;
- Size = MAP_APPFONT ( 170 , 108 ) ;
+ Size = MAP_APPFONT ( 170 , 132 ) ;
Text [ en-US ] = "Word Count" ;
Moveable = TRUE ;
@@ -66,50 +66,74 @@ ModalDialog DLG_WORDCOUNT
Size = MAP_APPFONT ( 50 , 8 ) ;
Right = TRUE;
};
+ FixedText FT_CURRENTCHARACTEREXCLUDINGSPACES
+ {
+ Pos = MAP_APPFONT ( 12 , 38 ) ;
+ Size = MAP_APPFONT ( 80 , 8 ) ;
+ Text [ en-US ] = "Characters excluding spaces:";
+ };
+ FixedText FI_CURRENTCHARACTEREXCLUDINGSPACES
+ {
+ Pos = MAP_APPFONT ( 111 , 38 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Right = TRUE;
+ };
FixedLine FL_DOC
{
- Pos = MAP_APPFONT ( 6, 40 ) ;
+ Pos = MAP_APPFONT ( 6, 52 ) ;
Size = MAP_APPFONT ( 158 , 8 ) ;
Text [ en-US ] = "Whole document";
};
FixedText FT_DOCWORD
{
- Pos = MAP_APPFONT ( 12, 51 ) ;
+ Pos = MAP_APPFONT ( 12, 63 ) ;
Size = MAP_APPFONT ( 80 , 8 ) ;
Text [ en-US ] = "Words:";
};
FixedText FI_DOCWORD
{
- Pos = MAP_APPFONT ( 111 , 51 ) ;
+ Pos = MAP_APPFONT ( 111 , 63 ) ;
Size = MAP_APPFONT ( 50 , 8 ) ;
Right = TRUE;
};
FixedText FT_DOCCHARACTER
{
- Pos = MAP_APPFONT ( 12 , 63 ) ;
+ Pos = MAP_APPFONT ( 12 , 75 ) ;
Size = MAP_APPFONT ( 80 , 8 ) ;
Text [ en-US ] = "Characters:";
};
FixedText FI_DOCCHARACTER
{
- Pos = MAP_APPFONT ( 111, 63 ) ;
+ Pos = MAP_APPFONT ( 111, 75 ) ;
+ Size = MAP_APPFONT ( 50, 8 ) ;
+ Right = TRUE;
+ };
+ FixedText FT_DOCCHARACTEREXCLUDINGSPACES
+ {
+ Pos = MAP_APPFONT ( 12 , 87 ) ;
+ Size = MAP_APPFONT ( 80 , 8 ) ;
+ Text [ en-US ] = "Characters excluding spaces:";
+ };
+ FixedText FI_DOCCHARACTEREXCLUDINGSPACES
+ {
+ Pos = MAP_APPFONT ( 111, 87 ) ;
Size = MAP_APPFONT ( 50, 8 ) ;
Right = TRUE;
};
FixedLine FL_BOTTOM
{
- Pos = MAP_APPFONT ( 6 , 77 ) ;
+ Pos = MAP_APPFONT ( 6 , 101 ) ;
Size = MAP_APPFONT ( 158 , 8 ) ;
};
OKButton PB_OK
{
- Pos = MAP_APPFONT ( 61 , 88 ) ;
+ Pos = MAP_APPFONT ( 61 , 112 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
DefButton = TRUE ;
};
HelpButton PB_HELP
{
- Pos = MAP_APPFONT ( 114 , 88 ) ;
+ Pos = MAP_APPFONT ( 114 , 112 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
};
};
diff --git a/sw/source/ui/inc/wordcountdialog.hxx b/sw/source/ui/inc/wordcountdialog.hxx
index 72445e0..3d640ca 100644
--- a/sw/source/ui/inc/wordcountdialog.hxx
+++ b/sw/source/ui/inc/wordcountdialog.hxx
@@ -40,12 +40,16 @@ class SwWordCountDialog : public SfxModalDialog
FixedInfo aCurrentWordFI;
FixedText aCurrentCharacterFT;
FixedInfo aCurrentCharacterFI;
+ FixedText aCurrentCharacterExcludingSpacesFT;
+ FixedInfo aCurrentCharacterExcludingSpacesFI;
FixedLine aDocFL;
FixedText aDocWordFT;
FixedInfo aDocWordFI;
FixedText aDocCharacterFT;
FixedInfo aDocCharacterFI;
+ FixedText aDocCharacterExcludingSpacesFT;
+ FixedInfo aDocCharacterExcludingSpacesFI;
FixedLine aBottomFL;
--
1.7.1
From b5c9e65f69d6e005f561d0ca01685d37036dfbfa Mon Sep 17 00:00:00 2001
From: Mattias Johnsson <m.t.johnsson@gmail.com>
Date: Wed, 27 Oct 2010 18:05:28 +1100
Subject: [PATCH] Add character count exclusive of whitespace to document statistics part 2
---
toolkit/workben/layout/wordcount-plain.xml | 26 +++++++++++++++++---------
toolkit/workben/layout/wordcount-tight.xml | 11 +++++++++--
toolkit/workben/layout/wordcount.xml | 13 +++++++++++--
toolkit/workben/layout/wordcountdialog.cxx | 13 ++++++-------
toolkit/workben/layout/wordcountdialog.hxx | 4 ++++
5 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/toolkit/workben/layout/wordcount-plain.xml b/toolkit/workben/layout/wordcount-plain.xml
index a7c34fe..5adce42 100644
--- a/toolkit/workben/layout/wordcount-plain.xml
+++ b/toolkit/workben/layout/wordcount-plain.xml
@@ -1,6 +1,6 @@
-<modaldialog sizeable="true" height="108" help-id="HID_DLG_WORDCOUNT" moveable="true"
output-size="true" id="DLG_WORDCOUNT" sv-look="true" text="Word Count" width="170"
xmlns="http://openoffice.org/2007/layout" xmlns:cnt="http://openoffice.org/2007/layout/container">
+<modaldialog sizeable="true" height="132" help-id="HID_DLG_WORDCOUNT" moveable="true"
output-size="true" id="DLG_WORDCOUNT" sv-look="true" text="Word Count" width="170"
xmlns="http://openoffice.org/2007/layout" xmlns:cnt="http://openoffice.org/2007/layout/container">
<vbox>
<fixedline height="8" id="FL_CURRENT" text="Current selection" width="158" x="6" y="3"/>
<hbox>
@@ -11,19 +11,27 @@
<fixedtext height="8" id="FT_CURRENTCHARACTER" label="Characters:" width="80" x="12"
y="26"/>
<fixedtext height="8" id="FI_CURRENTCHARACTER" right="true" width="50" x="111" y="26"/>
</hbox>
- <fixedline height="8" id="FL_DOC" text="Whole document" width="158" x="6" y="40"/>
<hbox>
- <fixedtext height="8" id="FT_DOCWORD" label="Words:" width="80" x="12" y="51"/>
- <fixedtext height="8" id="FI_DOCWORD" right="true" width="50" x="111" y="51"/>
+ <fixedtext height="8" id="FT_CURRENTCHARACTEREXCLUDINGSPACES" label="Characters
excluding spaces:" width="80" x="12" y="38"/>
+ <fixedtext height="8" id="FI_CURRENTCHARACTEREXCLUDINGSPACES" right="true" width="50"
x="111" y="38"/>
</hbox>
+ <fixedline height="8" id="FL_DOC" text="Whole document" width="158" x="6" y="52"/>
<hbox>
- <fixedtext height="8" id="FT_DOCCHARACTER" label="Characters:" width="80" x="12"
y="63"/>
- <fixedtext height="8" id="FI_DOCCHARACTER" right="true" width="50" x="111" y="63"/>
+ <fixedtext height="8" id="FT_DOCWORD" label="Words:" width="80" x="12" y="63"/>
+ <fixedtext height="8" id="FI_DOCWORD" right="true" width="50" x="111" y="63"/>
</hbox>
- <fixedline height="8" id="FL_BOTTOM" width="158" x="6" y="77"/>
<hbox>
- <okbutton defbutton="true" height="14" id="PB_OK" width="50" x="61" y="88"/>
- <helpbutton height="14" id="PB_HELP" width="50" x="114" y="88"/>
+ <fixedtext height="8" id="FT_DOCCHARACTER" label="Characters:" width="80" x="12"
y="75"/>
+ <fixedtext height="8" id="FI_DOCCHARACTER" right="true" width="50" x="111" y="75"/>
+ </hbox>
+ <hbox>
+ <fixedtext height="8" id="FT_DOCCHARACTEREXCLUDINGSPACES" label="Characters excluding
spaces:" width="80" x="12" y="87"/>
+ <fixedtext height="8" id="FI_DOCCHARACTEREXCLUDINGSPACES" right="true" width="50"
x="111" y="87"/>
+ </hbox>
+ <fixedline height="8" id="FL_BOTTOM" width="158" x="6" y="101"/>
+ <hbox>
+ <okbutton defbutton="true" height="14" id="PB_OK" width="50" x="61" y="112"/>
+ <helpbutton height="14" id="PB_HELP" width="50" x="114" y="112"/>
</hbox>
</vbox>
</modaldialog>
diff --git a/toolkit/workben/layout/wordcount-tight.xml b/toolkit/workben/layout/wordcount-tight.xml
index a9f6a7a..b9af6f7 100644
--- a/toolkit/workben/layout/wordcount-tight.xml
+++ b/toolkit/workben/layout/wordcount-tight.xml
@@ -16,14 +16,21 @@
<fixedtext id="FT_CURRENTCHARACTER" label="Characters:" cnt:padding="13"/>
<fixedinfo id="FI_CURRENTCHARACTER" right="true" label="00" cnt:padding="13"/>
</hbox>
+ <hbox>
+ <fixedtext id="FT_CURRENTCHARACTEREXCLUDINGSPACES" label="Characters excluding spaces:"
cnt:padding="13"/>
+ <fixedinfo id="FI_CURRENTCHARACTEREXCLUDINGSPACES" right="true" label="000"
cnt:padding="13"/>
+ </hbox>
<fixedline id="FL_DOC" text="Whole document"/>
<hbox>
<fixedtext id="FT_DOCWORD" label="Words:" cnt:padding="13"/>
- <fixedinfo id="FI_DOCWORD" right="true" label="000" cnt:padding="13"/>
+ <fixedinfo id="FI_DOCWORD" right="true" label="0000" cnt:padding="13"/>
</hbox>
<hbox>
<fixedtext id="FT_DOCCHARACTER" label="Characters:" cnt:padding="13"/>
- <fixedinfo id="FI_DOCCHARACTER" right="true" label="0000" cnt:padding="13"/>
+ <fixedinfo id="FI_DOCCHARACTER" right="true" label="00000" cnt:padding="13"/>
+ </hbox>
+ <fixedtext id="FT_DOCCHARACTEREXCLUDINGSPACES" label="Characters excluding spaces:"
cnt:padding="13"/>
+ <fixedinfo id="FI_DOCCHARACTEREXCLUDINGSPACES" right="true" label="000000"
cnt:padding="13"/>
</hbox>
<fixedline cnt:padding="1" id="FL_BOTTOM"/>
<hbox border="5">
diff --git a/toolkit/workben/layout/wordcount.xml b/toolkit/workben/layout/wordcount.xml
index fa9d44f..4b4e362 100644
--- a/toolkit/workben/layout/wordcount.xml
+++ b/toolkit/workben/layout/wordcount.xml
@@ -23,6 +23,11 @@
<flow cnt:padding="60"/>
<fixedtext id="FI_CURRENTCHARACTER" right="true" _label="00"/>
</hbox>
+ <hbox>
+ <fixedtext id="FT_CURRENTCHARACTEREXCLUDINGSPACES" _label="Characters excluding
spaces:"/>
+ <flow cnt:padding="60"/>
+ <fixedtext id="FI_CURRENTCHARACTEREXCLUDINGSPACES" right="true" _label="000"/>
+ </hbox>
</vbox>
</hbox>
<!-- if we could do cnt:cnt:padding="-12" here, we would not have to close
@@ -32,11 +37,15 @@
<vbox cnt:padding="12" spacing="6">
<hbox>
<fixedtext id="FT_DOCWORD" _label="Words:"/>
- <fixedtext id="FI_DOCWORD" right="true" _label="000"/>
+ <fixedtext id="FI_DOCWORD" right="true" _label="0000"/>
</hbox>
<hbox>
<fixedtext id="FT_DOCCHARACTER" _label="Characters:"/>
- <fixedtext id="FI_DOCCHARACTER" right="true" _label="0000"/>
+ <fixedtext id="FI_DOCCHARACTER" right="true" _label="00000"/>
+ </hbox>
+ <hbox>
+ <fixedtext id="FT_DOCCHARACTEREXCLUDINGSPACES" _label="Characters excluding spaces:"/>
+ <fixedtext id="FI_DOCCHARACTEREXCLUDINGSPACES" right="true" _label="000000"/>
</hbox>
</vbox>
</hbox>
diff --git a/toolkit/workben/layout/wordcountdialog.cxx b/toolkit/workben/layout/wordcountdialog.cxx
index e49ed21..f14f0c8 100644
--- a/toolkit/workben/layout/wordcountdialog.cxx
+++ b/toolkit/workben/layout/wordcountdialog.cxx
@@ -54,9 +54,6 @@
#include <helpid.h>
#endif /* ENABLE_LAYOUT */
-/*-- 06.04.2004 16:05:55---------------------------------------------------
-
- -----------------------------------------------------------------------*/
SwWordCountDialog::SwWordCountDialog(Window* pParent) :
SfxModalDialog(pParent, SW_RES(DLG_WORDCOUNT)),
#if defined _MSC_VER
@@ -67,12 +64,16 @@ SwWordCountDialog::SwWordCountDialog(Window* pParent) :
aCurrentWordFI( this, SW_RES( FI_CURRENTWORD )),
aCurrentCharacterFT( this, SW_RES( FT_CURRENTCHARACTER )),
aCurrentCharacterFI( this, SW_RES( FI_CURRENTCHARACTER )),
+ aCurrentCharacterExcludingSpacesFT( this, SW_RES( FT_CURRENTCHARACTEREXCLUDINGSPACES )),
+ aCurrentCharacterExcludingSpacesFI( this, SW_RES( FI_CURRENTCHARACTEREXCLUDINGSPACES )),
aDocFL( this, SW_RES( FL_DOC )),
aDocWordFT( this, SW_RES( FT_DOCWORD )),
aDocWordFI( this, SW_RES( FI_DOCWORD )),
aDocCharacterFT( this, SW_RES( FT_DOCCHARACTER )),
aDocCharacterFI( this, SW_RES( FI_DOCCHARACTER )),
+ aDocCharacterExcludingSpacesFT( this, SW_RES( FT_DOCCHARACTEREXCLUDINGSPACES )),
+ aDocCharacterExcludingSpacesFI( this, SW_RES( FI_DOCCHARACTEREXCLUDINGSPACES )),
aBottomFL(this, SW_RES( FL_BOTTOM )),
aOK( this, SW_RES( PB_OK )),
aHelp( this, SW_RES( PB_HELP ))
@@ -85,15 +86,11 @@ SwWordCountDialog::SwWordCountDialog(Window* pParent) :
#endif /* ENABLE_LAYOUT */
FreeResource();
}
-/*-- 06.04.2004 16:05:56---------------------------------------------------
- -----------------------------------------------------------------------*/
SwWordCountDialog::~SwWordCountDialog()
{
}
-/*-- 06.04.2004 16:05:57---------------------------------------------------
- -----------------------------------------------------------------------*/
void SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc)
{
#if TEST_LAYOUT
@@ -102,8 +99,10 @@ void SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& r
#else /* !TEST_LAYOUT */
aCurrentWordFI.SetText( String::CreateFromInt32(rCurrent.nWord ));
aCurrentCharacterFI.SetText(String::CreateFromInt32(rCurrent.nChar ));
+
aCurrentCharacterExcludingSpacesFI.SetText(String::CreateFromInt32(rCurrent.nCharExcludingSpaces ));
aDocWordFI.SetText( String::CreateFromInt32(rDoc.nWord ));
aDocCharacterFI.SetText( String::CreateFromInt32(rDoc.nChar ));
+ aDocCharacterExcludingSpacesFI.SetText( String::CreateFromInt32(rDoc.nCharExcludingSpaces
));
#endif /* !TEST_LAYOUT */
}
diff --git a/toolkit/workben/layout/wordcountdialog.hxx b/toolkit/workben/layout/wordcountdialog.hxx
index 72445e0..3d640ca 100644
--- a/toolkit/workben/layout/wordcountdialog.hxx
+++ b/toolkit/workben/layout/wordcountdialog.hxx
@@ -40,12 +40,16 @@ class SwWordCountDialog : public SfxModalDialog
FixedInfo aCurrentWordFI;
FixedText aCurrentCharacterFT;
FixedInfo aCurrentCharacterFI;
+ FixedText aCurrentCharacterExcludingSpacesFT;
+ FixedInfo aCurrentCharacterExcludingSpacesFI;
FixedLine aDocFL;
FixedText aDocWordFT;
FixedInfo aDocWordFI;
FixedText aDocCharacterFT;
FixedInfo aDocCharacterFI;
+ FixedText aDocCharacterExcludingSpacesFT;
+ FixedInfo aDocCharacterExcludingSpacesFI;
FixedLine aBottomFL;
--
1.7.1
Context
- [Libreoffice] [PATCH] Fix for bug / feature request 30550 - Character count without spaces · Mattias Johnsson
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.