summaryrefslogtreecommitdiff
path: root/sw/source/ui
diff options
context:
space:
mode:
authorMichal Siedlaczek <michal.siedlaczek@gmail.com>2014-01-25 11:19:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-05-20 09:29:53 -0500
commit43cd2f79da7a639d09fe43e6194f7568cbc78970 (patch)
tree9e849f9fe9cb0467f9d6eaf939c9a8c755610823 /sw/source/ui
parent63bc29b2a80e746a439f248c1bb8daa3d516370c (diff)
Displaying the number of standardized pages in the Word count window
The number of standardized pages (unit defined in the options) for the entire document and the selected area is displayed (if enabled in options) in the Word count window. The number of pages of size P for an area containing N characters equals P/N. This value is a float with one decimal place precision. The default size of the standardized page is 1800 characters (including whitespace characters). The configuration can be altered in Options->Writer->General. Conflicts: sw/source/ui/config/optload.cxx Change-Id: If13e87c73cb7706ff6618fa0352ba29c7c670aec Reviewed-on: https://gerrit.libreoffice.org/7642 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/ui')
-rw-r--r--sw/source/ui/config/optload.cxx40
-rw-r--r--sw/source/ui/dialog/wordcountdialog.cxx27
2 files changed, 66 insertions, 1 deletions
diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx
index baf04a4400b8..d4db9ff63daf 100644
--- a/sw/source/ui/config/optload.cxx
+++ b/sw/source/ui/config/optload.cxx
@@ -81,6 +81,8 @@ SwLoadOptPage::SwLoadOptPage(Window* pParent, const SfxItemSet& rSet)
get(m_pUseSquaredPageMode, "squaremode");
get(m_pUseCharUnit, "usecharunit");
get(m_pWordCountED, "wordcount");
+ get(m_pShowStandardizedPageCount, "standardizedpageshow");
+ get(m_pStandardizedPageSizeNF, "standardpagesize");
SvxStringArray aMetricArr( SW_RES( STR_ARR_METRIC ) );
for ( sal_uInt32 i = 0; i < aMetricArr.Count(); ++i )
@@ -119,6 +121,9 @@ SwLoadOptPage::SwLoadOptPage(Window* pParent, const SfxItemSet& rSet)
m_pUseSquaredPageMode->Hide();
m_pUseCharUnit->Hide();
}
+
+ Link aLink = LINK(this, SwLoadOptPage, StandardizedPageCountCheckHdl);
+ m_pShowStandardizedPageCount->SetClickHdl(aLink);
}
SfxTabPage* SwLoadOptPage::Create( Window* pParent,
@@ -127,6 +132,12 @@ SfxTabPage* SwLoadOptPage::Create( Window* pParent,
return new SwLoadOptPage(pParent, rAttrSet );
}
+IMPL_LINK_NOARG(SwLoadOptPage, StandardizedPageCountCheckHdl)
+{
+ m_pStandardizedPageSizeNF->Enable(m_pShowStandardizedPageCount->IsChecked());
+ return 0;
+}
+
bool SwLoadOptPage::FillItemSet( SfxItemSet& rSet )
{
bool bRet = false;
@@ -198,8 +209,30 @@ bool SwLoadOptPage::FillItemSet( SfxItemSet& rSet )
bRet = true;
}
+ if (m_pShowStandardizedPageCount->GetState() != m_pShowStandardizedPageCount->GetSavedValue())
+ {
+ boost::shared_ptr< comphelper::ConfigurationChanges > batch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::set(
+ m_pShowStandardizedPageCount->IsChecked(),
+ batch);
+ batch->commit();
+ bRet = sal_True;
+ }
+
+ if (m_pStandardizedPageSizeNF->GetText() != m_pStandardizedPageSizeNF->GetSavedValue())
+ {
+ boost::shared_ptr< comphelper::ConfigurationChanges > batch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Writer::WordCount::StandardizedPageSize::set(
+ m_pStandardizedPageSizeNF->GetValue(),
+ batch);
+ batch->commit();
+ bRet = sal_True;
+ }
+
bool bIsSquaredPageModeFlag = m_pUseSquaredPageMode->IsChecked();
- if ( m_pUseSquaredPageMode->IsValueChangedFromSaved() )
+ if ( bIsSquaredPageModeFlag != m_pUseSquaredPageMode->GetSavedValue() )
{
pMod->ApplyDefaultPageMode( bIsSquaredPageModeFlag );
if ( m_pWrtShell )
@@ -291,6 +324,11 @@ void SwLoadOptPage::Reset( const SfxItemSet& rSet)
m_pWordCountED->SetText(officecfg::Office::Writer::WordCount::AdditionalSeparators::get());
m_pWordCountED->SaveValue();
+ m_pShowStandardizedPageCount->Check(officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::get());
+ m_pShowStandardizedPageCount->SaveValue();
+ m_pStandardizedPageSizeNF->SetValue(officecfg::Office::Writer::WordCount::StandardizedPageSize::get());
+ m_pStandardizedPageSizeNF->SaveValue();
+ m_pStandardizedPageSizeNF->Enable(m_pShowStandardizedPageCount->IsChecked());
}
IMPL_LINK_NOARG(SwLoadOptPage, MetricHdl)
diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx
index 7fe4ec61d77c..2ff4f41fcd73 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <officecfg/Office/Writer.hxx>
#include <swtypes.hxx>
#include <wordcountdialog.hxx>
#include <docstat.hxx>
@@ -54,6 +55,12 @@ namespace
{
pWidget->SetText(rLocaleData.getNum(nValue, 0));
}
+
+ void setDoubleValue(FixedText *pWidget, double fValue)
+ {
+ OUString sValue(OUString::number(::rtl::math::round(fValue, 1)));
+ pWidget->SetText(sValue);
+ }
}
void SwWordCountFloatDlg::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc)
@@ -68,6 +75,15 @@ void SwWordCountFloatDlg::SetValues(const SwDocStat& rCurrent, const SwDocStat&
setValue(m_pDocCharacterExcludingSpacesFT, rDoc.nCharExcludingSpaces, rLocaleData);
setValue(m_pDocCjkcharsFT, rDoc.nAsianWord, rLocaleData);
+ if (m_pStandardizedPagesLabelFT->IsVisible())
+ {
+ sal_Int64 nCharsPerStandardizedPage = officecfg::Office::Writer::WordCount::StandardizedPageSize::get();
+ setDoubleValue(m_pCurrentStandardizedPagesFT,
+ (double)rCurrent.nChar / nCharsPerStandardizedPage);
+ setDoubleValue(m_pDocStandardizedPagesFT,
+ (double)rDoc.nChar / nCharsPerStandardizedPage);
+ }
+
bool bShowCJK = (SvtCJKOptions().IsAnyEnabled() || rDoc.nAsianWord);
bool bToggleCJK = m_pCurrentCjkcharsFT->IsVisible() != bShowCJK;
if (bToggleCJK)
@@ -84,6 +100,13 @@ void SwWordCountFloatDlg::showCJK(bool bShowCJK)
m_pCjkcharsLabelFT->Show(bShowCJK);
}
+void SwWordCountFloatDlg::showStandardizedPages(bool bShowStandardizedPages)
+{
+ m_pCurrentStandardizedPagesFT->Show(bShowStandardizedPages);
+ m_pDocStandardizedPagesFT->Show(bShowStandardizedPages);
+ m_pStandardizedPagesLabelFT->Show(bShowStandardizedPages);
+}
+
SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings,
SfxChildWindow* pChild,
Window *pParent,
@@ -94,17 +117,21 @@ SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings,
get(m_pCurrentCharacterFT, "selectchars");
get(m_pCurrentCharacterExcludingSpacesFT, "selectcharsnospaces");
get(m_pCurrentCjkcharsFT, "selectcjkchars");
+ get(m_pCurrentStandardizedPagesFT, "selectstandardizedpages");
get(m_pDocWordFT, "docwords");
get(m_pDocCharacterFT, "docchars");
get(m_pDocCharacterExcludingSpacesFT, "doccharsnospaces");
get(m_pDocCjkcharsFT, "doccjkchars");
+ get(m_pDocStandardizedPagesFT, "docstandardizedpages");
get(m_pCjkcharsLabelFT, "cjkcharsft");
+ get(m_pStandardizedPagesLabelFT, "standardizedpages");
get(m_pClosePB, "close");
showCJK(SvtCJKOptions().IsAnyEnabled());
+ showStandardizedPages(officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::get());
Initialize(pInfo);