LCOV - code coverage report
Current view: top level - sw/source/ui/dialog - wordcountdialog.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 83 0.0 %
Date: 2014-11-03 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <officecfg/Office/Writer.hxx>
      21             : #include <swtypes.hxx>
      22             : #include <wordcountdialog.hxx>
      23             : #include <docstat.hxx>
      24             : #include <dialog.hrc>
      25             : #include <cmdid.h>
      26             : #include <swmodule.hxx>
      27             : #include <wview.hxx>
      28             : #include <swwait.hxx>
      29             : #include <wrtsh.hxx>
      30             : #include <comphelper/string.hxx>
      31             : #include <sfx2/viewfrm.hxx>
      32             : #include <svl/cjkoptions.hxx>
      33             : #include <unotools/localedatawrapper.hxx>
      34             : #include <vcl/msgbox.hxx>
      35             : #include <vcl/settings.hxx>
      36             : 
      37           0 : IMPL_LINK_NOARG(SwWordCountFloatDlg, CloseHdl)
      38             : {
      39           0 :     SfxViewFrame* pVFrame = ::GetActiveView()->GetViewFrame();
      40           0 :     if (pVFrame != NULL)
      41             :     {
      42           0 :         pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
      43             :     }
      44           0 :     return 0;
      45             : }
      46             : 
      47           0 : SwWordCountFloatDlg::~SwWordCountFloatDlg()
      48             : {
      49           0 :     SwViewShell::SetCareWin( 0 );
      50           0 : }
      51             : 
      52             : namespace
      53             : {
      54           0 :     void setValue(FixedText *pWidget, sal_uLong nValue, const LocaleDataWrapper& rLocaleData)
      55             :     {
      56           0 :         pWidget->SetText(rLocaleData.getNum(nValue, 0));
      57           0 :     }
      58             : 
      59           0 :     void setDoubleValue(FixedText *pWidget, double fValue)
      60             :     {
      61           0 :         OUString sValue(OUString::number(::rtl::math::round(fValue, 1)));
      62           0 :         pWidget->SetText(sValue);
      63           0 :     }
      64             : }
      65             : 
      66           0 : void SwWordCountFloatDlg::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc)
      67             : {
      68           0 :     const LocaleDataWrapper& rLocaleData = GetSettings().GetUILocaleDataWrapper();
      69           0 :     setValue(m_pCurrentWordFT, rCurrent.nWord, rLocaleData);
      70           0 :     setValue(m_pCurrentCharacterFT, rCurrent.nChar, rLocaleData);
      71           0 :     setValue(m_pCurrentCharacterExcludingSpacesFT, rCurrent.nCharExcludingSpaces, rLocaleData);
      72           0 :     setValue(m_pCurrentCjkcharsFT, rCurrent.nAsianWord, rLocaleData);
      73           0 :     setValue(m_pDocWordFT, rDoc.nWord, rLocaleData);
      74           0 :     setValue(m_pDocCharacterFT, rDoc.nChar, rLocaleData);
      75           0 :     setValue(m_pDocCharacterExcludingSpacesFT, rDoc.nCharExcludingSpaces, rLocaleData);
      76           0 :     setValue(m_pDocCjkcharsFT, rDoc.nAsianWord, rLocaleData);
      77             : 
      78           0 :     if (m_pStandardizedPagesLabelFT->IsVisible())
      79             :     {
      80           0 :         sal_Int64 nCharsPerStandardizedPage = officecfg::Office::Writer::WordCount::StandardizedPageSize::get();
      81             :         setDoubleValue(m_pCurrentStandardizedPagesFT,
      82           0 :             (double)rCurrent.nChar / nCharsPerStandardizedPage);
      83             :         setDoubleValue(m_pDocStandardizedPagesFT,
      84           0 :             (double)rDoc.nChar / nCharsPerStandardizedPage);
      85             :     }
      86             : 
      87           0 :     bool bShowCJK = (SvtCJKOptions().IsAnyEnabled() || rDoc.nAsianWord);
      88           0 :     bool bToggleCJK = m_pCurrentCjkcharsFT->IsVisible() != bShowCJK;
      89           0 :     if (bToggleCJK)
      90             :     {
      91           0 :         showCJK(bShowCJK);
      92           0 :         setOptimalLayoutSize(); //force resize of dialog
      93             :     }
      94           0 : }
      95             : 
      96           0 : void SwWordCountFloatDlg::showCJK(bool bShowCJK)
      97             : {
      98           0 :     m_pCurrentCjkcharsFT->Show(bShowCJK);
      99           0 :     m_pDocCjkcharsFT->Show(bShowCJK);
     100           0 :     m_pCjkcharsLabelFT->Show(bShowCJK);
     101           0 : }
     102             : 
     103           0 : void SwWordCountFloatDlg::showStandardizedPages(bool bShowStandardizedPages)
     104             : {
     105           0 :     m_pCurrentStandardizedPagesFT->Show(bShowStandardizedPages);
     106           0 :     m_pDocStandardizedPagesFT->Show(bShowStandardizedPages);
     107           0 :     m_pStandardizedPagesLabelFT->Show(bShowStandardizedPages);
     108           0 : }
     109             : 
     110           0 : SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings,
     111             :                                          SfxChildWindow* pChild,
     112             :                                          vcl::Window *pParent,
     113             :                                          SfxChildWinInfo* pInfo)
     114           0 :     : SfxModelessDialog(_pBindings, pChild, pParent, "WordCountDialog", "modules/swriter/ui/wordcount.ui")
     115             : {
     116           0 :     get(m_pCurrentWordFT, "selectwords");
     117           0 :     get(m_pCurrentCharacterFT, "selectchars");
     118           0 :     get(m_pCurrentCharacterExcludingSpacesFT, "selectcharsnospaces");
     119           0 :     get(m_pCurrentCjkcharsFT, "selectcjkchars");
     120           0 :     get(m_pCurrentStandardizedPagesFT, "selectstandardizedpages");
     121             : 
     122           0 :     get(m_pDocWordFT, "docwords");
     123           0 :     get(m_pDocCharacterFT, "docchars");
     124           0 :     get(m_pDocCharacterExcludingSpacesFT, "doccharsnospaces");
     125           0 :     get(m_pDocCjkcharsFT, "doccjkchars");
     126           0 :     get(m_pDocStandardizedPagesFT, "docstandardizedpages");
     127             : 
     128           0 :     get(m_pCjkcharsLabelFT, "cjkcharsft");
     129           0 :     get(m_pStandardizedPagesLabelFT, "standardizedpages");
     130             : 
     131           0 :     get(m_pClosePB, "close");
     132             : 
     133           0 :     showCJK(SvtCJKOptions().IsAnyEnabled());
     134           0 :     showStandardizedPages(officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::get());
     135             : 
     136           0 :     Initialize(pInfo);
     137             : 
     138           0 :     m_pClosePB->SetClickHdl(LINK(this, SwWordCountFloatDlg, CloseHdl));
     139           0 :     m_pClosePB->GrabFocus();
     140           0 : }
     141             : 
     142           0 : void SwWordCountFloatDlg::Activate()
     143             : {
     144           0 :     SfxModelessDialog::Activate();
     145           0 : }
     146             : 
     147           0 : void SwWordCountFloatDlg::UpdateCounts()
     148             : {
     149           0 :     SwWrtShell &rSh = ::GetActiveView()->GetWrtShell();
     150           0 :     SwDocStat aCurrCnt;
     151           0 :     SwDocStat aDocStat;
     152             :     {
     153           0 :         SwWait aWait( *::GetActiveView()->GetDocShell(), true );
     154           0 :         rSh.StartAction();
     155           0 :         rSh.CountWords( aCurrCnt );
     156           0 :         aDocStat = rSh.GetUpdatedDocStat();
     157           0 :         rSh.EndAction();
     158             :     }
     159           0 :     SetValues(aCurrCnt, aDocStat);
     160           0 : }
     161             : 
     162           0 : void SwWordCountFloatDlg::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat)
     163             : {
     164           0 :     SetValues(rCurrCnt, rDocStat);
     165           0 : }
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10