LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/dialog - wordcountdialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 75 0.0 %
Date: 2012-12-27 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 :         rtl::OUString sValue(rtl::OUString::valueOf(static_cast<sal_Int64>(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 :         setInitialLayoutSize(); //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 :     long nPrefWidth = m_pCurrentWordFT->get_preferred_size().Width();
     106             : 
     107           0 :     m_pCurrentWordFT->set_width_request(nPrefWidth);
     108           0 :     m_pCurrentCharacterFT->set_width_request(nPrefWidth);
     109           0 :     m_pCurrentCharacterExcludingSpacesFT->set_width_request(nPrefWidth);
     110           0 :     m_pCurrentCjkcharsFT->set_width_request(nPrefWidth);
     111           0 :     m_pDocWordFT->set_width_request(nPrefWidth);
     112           0 :     m_pDocCharacterFT->set_width_request(nPrefWidth);
     113           0 :     m_pDocCharacterExcludingSpacesFT->set_width_request(nPrefWidth);
     114           0 :     m_pDocCjkcharsFT->set_width_request(nPrefWidth);
     115             : 
     116           0 :     showCJK(SvtCJKOptions().IsAnyEnabled());
     117             : 
     118           0 :     Initialize(pInfo);
     119             : 
     120           0 :     m_pClosePB->SetClickHdl(LINK(this, SwWordCountFloatDlg, CloseHdl));
     121           0 :     m_pClosePB->GrabFocus();
     122           0 : }
     123             : 
     124           0 : void SwWordCountFloatDlg::Activate()
     125             : {
     126           0 :     SfxModelessDialog::Activate();
     127           0 : }
     128             : 
     129           0 : void SwWordCountFloatDlg::UpdateCounts()
     130             : {
     131           0 :     SwWrtShell &rSh = ::GetActiveView()->GetWrtShell();
     132           0 :     SwDocStat aCurrCnt;
     133           0 :     SwDocStat aDocStat;
     134             :     {
     135           0 :         SwWait aWait( *::GetActiveView()->GetDocShell(), sal_True );
     136           0 :         rSh.StartAction();
     137           0 :         rSh.CountWords( aCurrCnt );
     138           0 :         aDocStat = rSh.GetUpdatedDocStat();
     139           0 :         rSh.EndAction();
     140             :     }
     141           0 :     SetValues(aCurrCnt, aDocStat);
     142           0 : }
     143             : 
     144           0 : void SwWordCountFloatDlg::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat)
     145             : {
     146           0 :     SetValues(rCurrCnt, rDocStat);
     147           0 : }
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10