LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/dialog - wordcountdialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2013-07-09 Functions: 0 13 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 <swtypes.hxx>
      21             : #include <wordcountdialog.hxx>
      22             : #include <docstat.hxx>
      23             : #include <dialog.hrc>
      24             : #include <cmdid.h>
      25             : #include <swmodule.hxx>
      26             : #include <wview.hxx>
      27             : #include <swwait.hxx>
      28             : #include <wrtsh.hxx>
      29             : #include <comphelper/string.hxx>
      30             : #include <sfx2/viewfrm.hxx>
      31             : #include <svl/cjkoptions.hxx>
      32             : #include <vcl/msgbox.hxx>
      33             : 
      34           0 : IMPL_LINK_NOARG(SwWordCountFloatDlg, CloseHdl)
      35             : {
      36           0 :     SfxViewFrame* pVFrame = ::GetActiveView()->GetViewFrame();
      37           0 :     if (pVFrame != NULL)
      38             :     {
      39           0 :         pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
      40             :     }
      41           0 :     return 0;
      42             : }
      43             : 
      44           0 : SwWordCountFloatDlg::~SwWordCountFloatDlg()
      45             : {
      46           0 :     ViewShell::SetCareWin( 0 );
      47           0 : }
      48             : 
      49             : namespace
      50             : {
      51           0 :     void setValue(FixedText *pWidget, sal_uLong nValue)
      52             :     {
      53           0 :         OUString sValue(OUString::number(nValue));
      54           0 :         pWidget->SetText(sValue);
      55           0 :     }
      56             : }
      57             : 
      58           0 : void SwWordCountFloatDlg::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc)
      59             : {
      60           0 :     setValue(m_pCurrentWordFT, rCurrent.nWord);
      61           0 :     setValue(m_pCurrentCharacterFT, rCurrent.nChar);
      62           0 :     setValue(m_pCurrentCharacterExcludingSpacesFT, rCurrent.nCharExcludingSpaces);
      63           0 :     setValue(m_pCurrentCjkcharsFT, rCurrent.nAsianWord);
      64           0 :     setValue(m_pDocWordFT, rDoc.nWord);
      65           0 :     setValue(m_pDocCharacterFT, rDoc.nChar);
      66           0 :     setValue(m_pDocCharacterExcludingSpacesFT, rDoc.nCharExcludingSpaces);
      67           0 :     setValue(m_pDocCjkcharsFT, rDoc.nAsianWord);
      68             : 
      69           0 :     bool bShowCJK = (SvtCJKOptions().IsAnyEnabled() || rDoc.nAsianWord);
      70           0 :     bool bToggleCJK = m_pCurrentCjkcharsFT->IsVisible() != static_cast<sal_Bool>(bShowCJK);
      71           0 :     if (bToggleCJK)
      72             :     {
      73           0 :         showCJK(bShowCJK);
      74           0 :         setOptimalLayoutSize(); //force resize of dialog
      75             :     }
      76           0 : }
      77             : 
      78           0 : void SwWordCountFloatDlg::showCJK(bool bShowCJK)
      79             : {
      80           0 :     m_pCurrentCjkcharsFT->Show(bShowCJK);
      81           0 :     m_pDocCjkcharsFT->Show(bShowCJK);
      82           0 :     m_pCjkcharsLabelFT->Show(bShowCJK);
      83           0 : }
      84             : 
      85           0 : SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings,
      86             :                                          SfxChildWindow* pChild,
      87             :                                          Window *pParent,
      88             :                                          SfxChildWinInfo* pInfo)
      89           0 :     : SfxModelessDialog(_pBindings, pChild, pParent, "WordCountDialog", "modules/swriter/ui/wordcount.ui")
      90             : {
      91           0 :     get(m_pCurrentWordFT, "selectwords");
      92           0 :     get(m_pCurrentCharacterFT, "selectchars");
      93           0 :     get(m_pCurrentCharacterExcludingSpacesFT, "selectcharsnospaces");
      94           0 :     get(m_pCurrentCjkcharsFT, "selectcjkchars");
      95             : 
      96           0 :     get(m_pDocWordFT, "docwords");
      97           0 :     get(m_pDocCharacterFT, "docchars");
      98           0 :     get(m_pDocCharacterExcludingSpacesFT, "doccharsnospaces");
      99           0 :     get(m_pDocCjkcharsFT, "doccjkchars");
     100             : 
     101           0 :     get(m_pCjkcharsLabelFT, "cjkcharsft");
     102             : 
     103           0 :     get(m_pClosePB, "close");
     104             : 
     105           0 :     showCJK(SvtCJKOptions().IsAnyEnabled());
     106             : 
     107           0 :     Initialize(pInfo);
     108             : 
     109           0 :     m_pClosePB->SetClickHdl(LINK(this, SwWordCountFloatDlg, CloseHdl));
     110           0 :     m_pClosePB->GrabFocus();
     111           0 : }
     112             : 
     113           0 : void SwWordCountFloatDlg::Activate()
     114             : {
     115           0 :     SfxModelessDialog::Activate();
     116           0 : }
     117             : 
     118           0 : void SwWordCountFloatDlg::UpdateCounts()
     119             : {
     120           0 :     SwWrtShell &rSh = ::GetActiveView()->GetWrtShell();
     121           0 :     SwDocStat aCurrCnt;
     122           0 :     SwDocStat aDocStat;
     123             :     {
     124           0 :         SwWait aWait( *::GetActiveView()->GetDocShell(), sal_True );
     125           0 :         rSh.StartAction();
     126           0 :         rSh.CountWords( aCurrCnt );
     127           0 :         aDocStat = rSh.GetUpdatedDocStat();
     128           0 :         rSh.EndAction();
     129             :     }
     130           0 :     SetValues(aCurrCnt, aDocStat);
     131           0 : }
     132             : 
     133           0 : void SwWordCountFloatDlg::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat)
     134             : {
     135           0 :     SetValues(rCurrCnt, rDocStat);
     136           0 : }
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10