summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode
diff options
context:
space:
mode:
authorMattias Johnsson <m.t.johnsson@gmail.com>2010-10-27 18:01:43 +1100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2010-10-27 14:22:13 +0200
commitfa2857fbd214346cdb808971b5830bc8833decc4 (patch)
tree98f7c0b861f7af355279a68a5ea5290aad471597 /sw/source/core/txtnode
parent5b598f6b8cbd4356c41ef1ae716f898891da95ba (diff)
Add character count exclusive of whitespace to document statistics part 1
Diffstat (limited to 'sw/source/core/txtnode')
-rw-r--r--sw/source/core/txtnode/txtedt.cxx43
1 files changed, 26 insertions, 17 deletions
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 9230324eb4a1..72b259f8838c 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -93,7 +93,6 @@
#include <vector>
-
using rtl::OUString;
using namespace ::com::sun::star;
using namespace ::com::sun::star::frame;
@@ -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;
@@ -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,13 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
while ( aScanner.NextWord() )
{
- if ( aScanner.GetLen() > 1 ||
- CH_TXTATR_BREAKWORD != aExpandText.match(aBreakWord, aScanner.GetBegin() ) )
+
+ if(CH_TXTATR_BREAKWORD != aExpandText.match(aBreakWord, aScanner.GetBegin() ))
+ {
++nTmpWords;
+ nTmpCharsExcludingSpaces += aScanner.GetLen();
+ }
+
}
}
@@ -1972,12 +1964,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 +1986,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 +1999,7 @@ struct SwParaIdleData_Impl
pSmartTags ( 0 ),
nNumberOfWords ( 0 ),
nNumberOfChars ( 0 ),
+ nNumberOfCharsExcludingSpaces ( 0 ),
bWordCountDirty ( true ),
bWrongDirty ( true ),
bGrammarCheckDirty ( true ),
@@ -2051,7 +2047,6 @@ const SwWrongList* SwTxtNode::GetWrong() const
}
// <--
-
void SwTxtNode::SetGrammarCheck( SwGrammarMarkUp* pNew, bool bDelete )
{
if ( m_pParaIdleData_Impl )
@@ -2118,6 +2113,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;