sw/inc/swabstdlg.hxx | 1 sw/source/core/txtnode/txtedt.cxx | 81 +++++++++++++++++-------------- sw/source/ui/dialog/swdlgfact.cxx | 4 + sw/source/ui/dialog/swdlgfact.hxx | 1 sw/source/ui/dialog/wordcountdialog.cxx | 5 + sw/source/ui/dialog/wordcountwrapper.cxx | 5 + sw/source/ui/inc/wordcountdialog.hxx | 3 + sw/source/ui/uiview/view2.cxx | 5 + 8 files changed, 69 insertions(+), 36 deletions(-)
New commits: commit 5192468dd49f5e1d821239cd51cea42f8bac7a4b Author: Caolán McNamara <caol...@redhat.com> Date: Mon Aug 27 16:05:11 2012 +0100 Related: fdo#51908 reuse the status bar word counts for the dialog Set the counts directly on the word count dialog when we have them precalculated from updating the status bar Change-Id: Idd64f20097af661dd4938af7fcc8506eca076e9c diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 2962991..016202c 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -203,6 +203,7 @@ class AbstractSwWordCountFloatDlg : public VclAbstractDialog { public: virtual void UpdateCounts() = 0; + virtual void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) = 0; virtual Window * GetWindow() = 0; //this method is added for return a Window type pointer }; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index f7c81aa..868b487 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -571,6 +571,10 @@ void AbstractSwWordCountFloatDlg_Impl::UpdateCounts() pDlg->UpdateCounts(); } +void AbstractSwWordCountFloatDlg_Impl::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) +{ + pDlg->SetCounts(rCurrCnt, rDocStat); +} AbstractMailMergeWizard_Impl::~AbstractMailMergeWizard_Impl() { diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index f4a24da..159f6e3 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -79,6 +79,7 @@ class AbstractSwWordCountFloatDlg_Impl : public AbstractSwWordCountFloatDlg { DECL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl,SwWordCountFloatDlg) virtual void UpdateCounts(); + virtual void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat); virtual Window * GetWindow(); //this method is added for return a Window type pointer }; diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx index c34c197..122d542 100644 --- a/sw/source/ui/dialog/wordcountdialog.cxx +++ b/sw/source/ui/dialog/wordcountdialog.cxx @@ -133,4 +133,9 @@ void SwWordCountFloatDlg::UpdateCounts() aDlg.SetValues(aCurrCnt, aDocStat); } +void SwWordCountFloatDlg::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) +{ + aDlg.SetValues(rCurrCnt, rDocStat); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/wordcountwrapper.cxx b/sw/source/ui/dialog/wordcountwrapper.cxx index aaca02d..2fb4b8d 100644 --- a/sw/source/ui/dialog/wordcountwrapper.cxx +++ b/sw/source/ui/dialog/wordcountwrapper.cxx @@ -58,3 +58,8 @@ void SwWordCountWrapper::UpdateCounts() { pAbstDlg->UpdateCounts(); } + +void SwWordCountWrapper::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) +{ + pAbstDlg->SetCounts(rCurrCnt, rDocStat); +} diff --git a/sw/source/ui/inc/wordcountdialog.hxx b/sw/source/ui/inc/wordcountdialog.hxx index 1960072..f70c6a8 100644 --- a/sw/source/ui/inc/wordcountdialog.hxx +++ b/sw/source/ui/inc/wordcountdialog.hxx @@ -78,6 +78,8 @@ class SwWordCountFloatDlg : public SfxModelessDialog Window *pParent, SfxChildWinInfo* pInfo); void UpdateCounts(); + + void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat); }; class SwWordCountWrapper : public SfxChildWindow @@ -93,6 +95,7 @@ protected: public: void UpdateCounts(); + void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat); }; #endif diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 7dfbe02..770866a 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -140,6 +140,7 @@ #include <svx/ofaitem.hxx> #include <unomid.h> #include <docstat.hxx> +#include <wordcountdialog.hxx> const char sStatusDelim[] = " : "; const char sStatusComma[] = " , ";//#outlinelevel, define a Variable for "," add by zhaojianwei @@ -1215,6 +1216,10 @@ void SwView::StateStatusLine(SfxItemSet &rSet) wordCount = wordCount.replaceAll("$2", rtl::OUString::valueOf(static_cast<sal_Int64>(selectionStats.nWord))); } rSet.Put(SfxStringItem(FN_STAT_WORDCOUNT, wordCount)); + + SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()); + if (pWrdCnt) + pWrdCnt->SetCounts(selectionStats, documentStats); } break; commit a59b51a683a21a44e9071e878addc6a7ace3b5a8 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Aug 27 12:41:19 2012 +0100 Resolves: fdo#51908 count empty paragraphs if they're numbered we want to count the numbering/bullet of otherwise empty paragraphs Change-Id: I6cdf5348bcbb97081afc743d24e6c4ffb355d085 diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index ca3b961..e37dada 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -1822,28 +1822,43 @@ void SwTxtNode::ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, void SwTxtNode::CountWords( SwDocStat& rStat, xub_StrLen nStt, xub_StrLen nEnd ) const { + if( nStt > nEnd ) + { // bad call + return; + } if (IsInRedlines()) { //not counting txtnodes used to hold deleted redline content return; } - - sal_Bool isCountAll = ( (0 == nStt) && (GetTxt().Len() == nEnd) ); - + bool bCountAll = ( (0 == nStt) && (GetTxt().Len() == nEnd) ); ++rStat.nAllPara; // #i93174#: count _all_ paragraphs - if( nStt >= nEnd ) - { // empty node or empty selection or bad call - return; - } if ( IsHidden() ) { // not counting hidden paras return; } + // count words in numbering string if started at beginning of para: + bool bCountNumbering = nStt == 0; + bool bHasBullet = false, bHasNumbering = false; + rtl::OUString sNumString; + if (bCountNumbering) + { + sNumString = GetNumString(); + bHasNumbering = !sNumString.isEmpty(); + if (!bHasNumbering) + bHasBullet = HasBullet(); + bCountNumbering = bHasNumbering || bHasBullet; + } + + if( nStt == nEnd && !bCountNumbering) + { // unnumbered empty node or empty selection + return; + } // count of non-empty paras ++rStat.nPara; // Shortcut when counting whole paragraph and current count is clean - if ( isCountAll && !IsWordCountDirty() ) + if ( bCountAll && !IsWordCountDirty() ) { // accumulate into DocStat record to return the values rStat.nWord += GetParaNumberOfWords(); @@ -1861,7 +1876,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat, const sal_uInt32 nExpandBegin = aConversionMap.ConvertToViewPosition( nStt ); const sal_uInt32 nExpandEnd = aConversionMap.ConvertToViewPosition( nEnd ); - if ( aExpandText.isEmpty() ) + if (aExpandText.isEmpty() && !bCountNumbering) { OSL_ENSURE(aExpandText.getLength() >= 0, "Node text expansion error: length < 0." ); return; @@ -1877,7 +1892,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat, sal_uInt32 nTmpCharsExcludingSpaces = 0; // all non-white chars // count words in masked and expanded text: - if( pBreakIt->GetBreakIter().is() ) + if (!aExpandText.isEmpty() && pBreakIt->GetBreakIter().is()) { // zero is NULL for pLanguage -----------v last param = true for clipping SwScanner aScanner( *this, aExpandText, 0, aConversionMap, i18n::WordType::WORD_COUNT, @@ -1905,41 +1920,35 @@ void SwTxtNode::CountWords( SwDocStat& rStat, // no nTmpCharsExcludingSpaces adjust needed neither for blanked out MaskedChars // nor for mid-word selection - set scanner bClip = true at creation - // count words in numbering string if started at beginning of para: - if ( nStt == 0 ) + // count outline number label - ? no expansion into map + // always counts all of number-ish label + if (bHasNumbering) // count words in numbering string { - // count outline number label - ? no expansion into map - // always counts all of number-ish label - const String aNumString = GetNumString(); - const xub_StrLen nNumStringLen = aNumString.Len(); - if ( nNumStringLen > 0 ) - { - LanguageType aLanguage = GetLang( 0 ); + LanguageType aLanguage = GetLang( 0 ); - SwScanner aScanner( *this, aNumString, &aLanguage, ModelToViewHelper(), - i18n::WordType::WORD_COUNT, 0, nNumStringLen, true ); + SwScanner aScanner( *this, sNumString, &aLanguage, ModelToViewHelper(), + i18n::WordType::WORD_COUNT, 0, sNumString.getLength(), true ); - while ( aScanner.NextWord() ) - { - ++nTmpWords; - const rtl::OUString &rWord = aScanner.GetWord(); - if (pBreakIt->GetBreakIter()->getScriptType(rWord, 0) == i18n::ScriptType::ASIAN) - ++nTmpAsianWords; - nTmpCharsExcludingSpaces += pBreakIt->getGraphemeCount(rWord); - } - - nTmpChars += pBreakIt->getGraphemeCount(aNumString); - } - else if ( HasBullet() ) + while ( aScanner.NextWord() ) { ++nTmpWords; - ++nTmpChars; - ++nTmpCharsExcludingSpaces; + const rtl::OUString &rWord = aScanner.GetWord(); + if (pBreakIt->GetBreakIter()->getScriptType(rWord, 0) == i18n::ScriptType::ASIAN) + ++nTmpAsianWords; + nTmpCharsExcludingSpaces += pBreakIt->getGraphemeCount(rWord); } + + nTmpChars += pBreakIt->getGraphemeCount(sNumString); + } + else if ( bHasBullet ) + { + ++nTmpWords; + ++nTmpChars; + ++nTmpCharsExcludingSpaces; } // If counting the whole para then update cached values and mark clean - if ( isCountAll ) + if ( bCountAll ) { SetParaNumberOfWords( nTmpWords ); SetParaNumberOfAsianWords( nTmpAsianWords );
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits