2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 17:50:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:50:00 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:50:00 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:50:00 +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.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:50:00 +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).
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 17:50:00 +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.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 21:49:09 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <swwait.hxx>
|
|
|
|
#include <wrtsh.hxx>
|
|
|
|
#include <view.hxx>
|
|
|
|
#include <swmodule.hxx>
|
|
|
|
#include <globals.hrc>
|
|
|
|
#include <docsh.hxx>
|
|
|
|
#include <pview.hxx>
|
|
|
|
#include <doc.hxx>
|
|
|
|
#include <docstdlg.hxx>
|
|
|
|
#include <modcfg.hxx>
|
|
|
|
|
2010-10-20 15:36:15 +01:00
|
|
|
// for statistics fields
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <fldmgr.hxx>
|
|
|
|
#include <fldbas.hxx>
|
|
|
|
|
|
|
|
#include <docstdlg.hrc>
|
|
|
|
|
|
|
|
|
|
|
|
SfxTabPage * SwDocStatPage::Create(Window *pParent, const SfxItemSet &rSet)
|
|
|
|
{
|
|
|
|
return new SwDocStatPage(pParent, rSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
SwDocStatPage::SwDocStatPage(Window *pParent, const SfxItemSet &rSet) :
|
|
|
|
|
|
|
|
SfxTabPage (pParent, SW_RES(TP_DOC_STAT), rSet),
|
|
|
|
aPageLbl (this, SW_RES( FT_PAGE )),
|
2011-02-21 18:43:22 +01:00
|
|
|
aPageNo (this, SW_RES( FT_PAGE_COUNT )),
|
2000-09-18 16:15:01 +00:00
|
|
|
aTableLbl (this, SW_RES( FT_TABLE )),
|
|
|
|
aTableNo (this, SW_RES( FT_TABLE_COUNT)),
|
|
|
|
aGrfLbl (this, SW_RES( FT_GRF )),
|
|
|
|
aGrfNo (this, SW_RES( FT_GRF_COUNT )),
|
|
|
|
aOLELbl (this, SW_RES( FT_OLE )),
|
|
|
|
aOLENo (this, SW_RES( FT_OLE_COUNT )),
|
|
|
|
aParaLbl (this, SW_RES( FT_PARA )),
|
|
|
|
aParaNo (this, SW_RES( FT_PARA_COUNT )),
|
|
|
|
aWordLbl (this, SW_RES( FT_WORD )),
|
|
|
|
aWordNo (this, SW_RES( FT_WORD_COUNT )),
|
|
|
|
aCharLbl (this, SW_RES( FT_CHAR )),
|
|
|
|
aCharNo (this, SW_RES( FT_CHAR_COUNT )),
|
2011-03-18 15:59:29 +01:00
|
|
|
aCharExclSpacesLbl (this, SW_RES( FT_CHAR_EXCL_SPACES )),
|
2011-03-04 21:46:43 +01:00
|
|
|
aCharExclSpacesNo (this, SW_RES( FT_CHAR_COUNT_EXCL_SPACES )),
|
2007-09-27 10:36:55 +00:00
|
|
|
aLineLbl (this, SW_RES( FT_LINE )),
|
2000-09-18 16:15:01 +00:00
|
|
|
aLineNo (this, SW_RES( FT_LINE_COUNT )),
|
|
|
|
aUpdatePB (this, SW_RES( PB_PDATE ))
|
|
|
|
{
|
|
|
|
Update();
|
|
|
|
FreeResource();
|
|
|
|
aUpdatePB.SetClickHdl(LINK(this, SwDocStatPage, UpdateHdl));
|
2003-09-04 10:48:58 +00:00
|
|
|
//#111684# is the current view a page preview no SwFEShell can be found -> hide the update button
|
|
|
|
SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current();
|
|
|
|
SwFEShell* pFEShell = pDocShell->GetFEShell();
|
|
|
|
if(!pFEShell)
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
aUpdatePB.Show(sal_False);
|
|
|
|
aLineLbl.Show(sal_False);
|
|
|
|
aLineNo .Show(sal_False);
|
2003-09-04 10:48:58 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SwDocStatPage::~SwDocStatPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
2011-02-25 20:29:15 +01:00
|
|
|
Description: fill ItemSet when changed
|
2000-09-18 16:15:01 +00:00
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwDocStatPage::FillItemSet(SfxItemSet & /*rSet*/)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2007-09-27 10:36:55 +00:00
|
|
|
void SwDocStatPage::Reset(const SfxItemSet &/*rSet*/)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
/*------------------------------------------------------------------------
|
2011-02-25 20:29:15 +01:00
|
|
|
Description: update / set data
|
2000-09-18 16:15:01 +00:00
|
|
|
------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
void SwDocStatPage::SetData(const SwDocStat &rStat)
|
|
|
|
{
|
|
|
|
aTableNo.SetText(String::CreateFromInt32( rStat.nTbl ));
|
|
|
|
aGrfNo.SetText(String::CreateFromInt32( rStat.nGrf ));
|
|
|
|
aOLENo.SetText(String::CreateFromInt32( rStat.nOLE ));
|
|
|
|
aPageNo.SetText(String::CreateFromInt32( rStat.nPage ));
|
|
|
|
aParaNo.SetText(String::CreateFromInt32( rStat.nPara ));
|
|
|
|
aWordNo.SetText(String::CreateFromInt32( rStat.nWord ));
|
|
|
|
aCharNo.SetText(String::CreateFromInt32( rStat.nChar ));
|
2011-03-04 21:46:43 +01:00
|
|
|
aCharExclSpacesNo.SetText(String::CreateFromInt32( rStat.nCharExcludingSpaces ));
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------
|
2011-02-25 20:29:15 +01:00
|
|
|
Description: update statistics
|
2000-09-18 16:15:01 +00:00
|
|
|
------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
void SwDocStatPage::Update()
|
|
|
|
{
|
|
|
|
SfxViewShell *pVSh = SfxViewShell::Current();
|
|
|
|
ViewShell *pSh = 0;
|
|
|
|
if ( pVSh->ISA(SwView) )
|
|
|
|
pSh = ((SwView*)pVSh)->GetWrtShellPtr();
|
|
|
|
else if ( pVSh->ISA(SwPagePreView) )
|
2002-12-04 11:20:07 +00:00
|
|
|
pSh = ((SwPagePreView*)pVSh)->GetViewShell();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-10-20 15:36:15 +01:00
|
|
|
OSL_ENSURE( pSh, "Shell not found" );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
SwWait aWait( *pSh->GetDoc()->GetDocShell(), sal_True );
|
2000-09-18 16:15:01 +00:00
|
|
|
pSh->StartAction();
|
2011-08-23 16:25:52 +01:00
|
|
|
aDocStat = pSh->GetDoc()->GetUpdatedDocStat();
|
2000-09-18 16:15:01 +00:00
|
|
|
pSh->EndAction();
|
|
|
|
|
|
|
|
SetData(aDocStat);
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SwDocStatPage, UpdateHdl)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
Update();
|
|
|
|
SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current();
|
|
|
|
SwFEShell* pFEShell = pDocShell->GetFEShell();
|
2003-09-04 10:48:58 +00:00
|
|
|
if(pFEShell)
|
2011-01-17 15:06:54 +01:00
|
|
|
aLineNo.SetText( String::CreateFromInt32( pFEShell->GetLineCount(sal_False)));
|
2000-09-18 16:15:01 +00:00
|
|
|
//pButton->Disable();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|