2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-04-27 12:43:55 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 17:55:19 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-04-27 12:43:55 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-04-27 12:43:55 +00:00
|
|
|
*
|
2008-04-10 17:55:19 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-04-27 12:43:55 +00:00
|
|
|
*
|
2008-04-10 17:55:19 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-04-27 12:43:55 +00:00
|
|
|
*
|
2008-04-10 17:55:19 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-04-27 12:43:55 +00:00
|
|
|
*
|
2008-04-10 17:55:19 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-04-27 12:43:55 +00:00
|
|
|
*
|
2008-04-10 17:55:19 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-04-27 12:43:55 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 21:51:21 +00:00
|
|
|
|
2004-04-27 12:43:55 +00:00
|
|
|
#include <swtypes.hxx>
|
|
|
|
#include <wordcountdialog.hxx>
|
|
|
|
#include <docstat.hxx>
|
|
|
|
#include <dialog.hrc>
|
2011-11-01 22:47:33 -06:00
|
|
|
#include <cmdid.h>
|
|
|
|
#include <swmodule.hxx>
|
|
|
|
#include <wview.hxx>
|
|
|
|
#include <swwait.hxx>
|
|
|
|
#include <wrtsh.hxx>
|
2012-08-29 23:39:25 +01:00
|
|
|
#include <comphelper/string.hxx>
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
2012-11-14 15:25:02 +00:00
|
|
|
#include <svl/cjkoptions.hxx>
|
2012-08-29 23:39:25 +01:00
|
|
|
#include <vcl/msgbox.hxx>
|
2004-04-27 12:43:55 +00:00
|
|
|
|
2012-08-29 22:17:19 +01:00
|
|
|
IMPL_LINK_NOARG(SwWordCountFloatDlg, CloseHdl)
|
2011-11-01 22:47:33 -06:00
|
|
|
{
|
|
|
|
SfxViewFrame* pVFrame = ::GetActiveView()->GetViewFrame();
|
|
|
|
if (pVFrame != NULL)
|
|
|
|
{
|
|
|
|
pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
|
|
|
|
}
|
|
|
|
return 0;
|
2004-04-27 12:43:55 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 22:17:19 +01:00
|
|
|
SwWordCountFloatDlg::~SwWordCountFloatDlg()
|
2004-04-27 12:43:55 +00:00
|
|
|
{
|
2011-11-01 22:47:33 -06:00
|
|
|
ViewShell::SetCareWin( 0 );
|
2004-04-27 12:43:55 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 23:39:25 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void setValue(FixedText *pWidget, sal_uLong nValue)
|
|
|
|
{
|
|
|
|
rtl::OUString sValue(rtl::OUString::valueOf(static_cast<sal_Int64>(nValue)));
|
|
|
|
pWidget->SetText(sValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 22:17:19 +01:00
|
|
|
void SwWordCountFloatDlg::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc)
|
2004-04-27 12:43:55 +00:00
|
|
|
{
|
2012-08-29 23:39:25 +01:00
|
|
|
setValue(m_pCurrentWordFT, rCurrent.nWord);
|
|
|
|
setValue(m_pCurrentCharacterFT, rCurrent.nChar);
|
|
|
|
setValue(m_pCurrentCharacterExcludingSpacesFT, rCurrent.nCharExcludingSpaces);
|
2012-11-14 15:25:02 +00:00
|
|
|
setValue(m_pCurrentCjkcharsFT, rCurrent.nAsianWord);
|
2012-08-29 23:39:25 +01:00
|
|
|
setValue(m_pDocWordFT, rDoc.nWord);
|
|
|
|
setValue(m_pDocCharacterFT, rDoc.nChar);
|
|
|
|
setValue(m_pDocCharacterExcludingSpacesFT, rDoc.nCharExcludingSpaces);
|
2012-11-14 15:25:02 +00:00
|
|
|
setValue(m_pDocCjkcharsFT, rDoc.nAsianWord);
|
|
|
|
|
|
|
|
bool bShowCJK = (SvtCJKOptions().IsAnyEnabled() || rDoc.nAsianWord);
|
|
|
|
m_pCurrentCjkcharsFT->Show(bShowCJK);
|
|
|
|
m_pDocCjkcharsFT->Show(bShowCJK);
|
|
|
|
m_pCjkcharsLabelFT->Show(bShowCJK);
|
2004-04-27 12:43:55 +00:00
|
|
|
}
|
|
|
|
|
2011-11-01 22:47:33 -06:00
|
|
|
SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings,
|
|
|
|
SfxChildWindow* pChild,
|
|
|
|
Window *pParent,
|
|
|
|
SfxChildWinInfo* pInfo)
|
2012-08-29 22:17:19 +01:00
|
|
|
: SfxModelessDialog(_pBindings, pChild, pParent, "WordCountDialog", "modules/swriter/ui/wordcount.ui")
|
2011-11-01 22:47:33 -06:00
|
|
|
{
|
2012-08-30 00:56:52 +01:00
|
|
|
get(m_pCurrentWordFT, "selectwords");
|
|
|
|
get(m_pCurrentCharacterFT, "selectchars");
|
|
|
|
get(m_pCurrentCharacterExcludingSpacesFT, "selectcharsnospaces");
|
2012-11-14 15:25:02 +00:00
|
|
|
get(m_pCurrentCjkcharsFT, "selectcjkchars");
|
|
|
|
|
2012-08-30 00:56:52 +01:00
|
|
|
get(m_pDocWordFT, "docwords");
|
|
|
|
get(m_pDocCharacterFT, "docchars");
|
|
|
|
get(m_pDocCharacterExcludingSpacesFT, "doccharsnospaces");
|
2012-11-14 15:25:02 +00:00
|
|
|
get(m_pDocCjkcharsFT, "doccjkchars");
|
|
|
|
|
|
|
|
get(m_pCjkcharsLabelFT, "cjkcharsft");
|
|
|
|
|
2012-08-30 00:56:52 +01:00
|
|
|
get(m_pClosePB, "close");
|
2012-08-29 22:17:19 +01:00
|
|
|
|
2012-08-29 23:39:25 +01:00
|
|
|
long nPrefWidth = m_pCurrentWordFT->get_preferred_size().Width();
|
|
|
|
|
|
|
|
m_pCurrentWordFT->set_width_request(nPrefWidth);
|
|
|
|
m_pCurrentCharacterFT->set_width_request(nPrefWidth);
|
|
|
|
m_pCurrentCharacterExcludingSpacesFT->set_width_request(nPrefWidth);
|
2012-11-14 15:25:02 +00:00
|
|
|
m_pCurrentCjkcharsFT->set_width_request(nPrefWidth);
|
2012-08-29 23:39:25 +01:00
|
|
|
m_pDocWordFT->set_width_request(nPrefWidth);
|
|
|
|
m_pDocCharacterFT->set_width_request(nPrefWidth);
|
|
|
|
m_pDocCharacterExcludingSpacesFT->set_width_request(nPrefWidth);
|
2012-11-14 15:25:02 +00:00
|
|
|
m_pDocCjkcharsFT->set_width_request(nPrefWidth);
|
2012-08-29 23:39:25 +01:00
|
|
|
|
2011-11-01 22:47:33 -06:00
|
|
|
Initialize(pInfo);
|
2012-08-29 22:17:19 +01:00
|
|
|
|
|
|
|
m_pClosePB->SetClickHdl(LINK(this, SwWordCountFloatDlg, CloseHdl));
|
|
|
|
m_pClosePB->GrabFocus();
|
2011-11-01 22:47:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwWordCountFloatDlg::Activate()
|
|
|
|
{
|
|
|
|
SfxModelessDialog::Activate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwWordCountFloatDlg::UpdateCounts()
|
|
|
|
{
|
|
|
|
SwWrtShell &rSh = ::GetActiveView()->GetWrtShell();
|
|
|
|
SwDocStat aCurrCnt;
|
|
|
|
SwDocStat aDocStat;
|
|
|
|
{
|
|
|
|
SwWait aWait( *::GetActiveView()->GetDocShell(), sal_True );
|
|
|
|
rSh.StartAction();
|
|
|
|
rSh.CountWords( aCurrCnt );
|
|
|
|
aDocStat = rSh.GetUpdatedDocStat();
|
|
|
|
rSh.EndAction();
|
|
|
|
}
|
2012-08-29 22:17:19 +01:00
|
|
|
SetValues(aCurrCnt, aDocStat);
|
2011-11-01 22:47:33 -06:00
|
|
|
}
|
|
|
|
|
2012-08-27 16:05:11 +01:00
|
|
|
void SwWordCountFloatDlg::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat)
|
|
|
|
{
|
2012-09-27 15:06:29 +01:00
|
|
|
SetValues(rCurrCnt, rDocStat);
|
2012-08-27 16:05:11 +01:00
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|