1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 #ifdef SW_DLLIMPLEMENTATION 31 #undef SW_DLLIMPLEMENTATION 32 #endif 33 34 35 #include <stdio.h> 36 #include <ctype.h> 37 #include <swwait.hxx> 38 #include <wrtsh.hxx> 39 #ifndef _VIEW_HXX 40 #include <view.hxx> 41 #endif 42 #include <swmodule.hxx> 43 #ifndef _GLOBALS_HRC 44 #include <globals.hrc> 45 #endif 46 #ifndef _DOCSH_HXX 47 #include <docsh.hxx> 48 #endif 49 #ifndef _PVIEW_HXX 50 #include <pview.hxx> 51 #endif 52 #include <doc.hxx> 53 #include <docstdlg.hxx> 54 #ifndef _MODCFG_HXX 55 #include <modcfg.hxx> 56 #endif 57 58 // fuer Statistikfelder 59 #include <fldmgr.hxx> 60 #include <fldbas.hxx> 61 62 #ifndef _DOCSTDLG_HRC 63 #include <docstdlg.hrc> 64 #endif 65 66 67 /*-------------------------------------------------------------------- 68 Beschreibung: Create 69 --------------------------------------------------------------------*/ 70 71 72 SfxTabPage * SwDocStatPage::Create(Window *pParent, const SfxItemSet &rSet) 73 { 74 return new SwDocStatPage(pParent, rSet); 75 } 76 77 /*-------------------------------------------------------------------- 78 Beschreibung: Ctor 79 --------------------------------------------------------------------*/ 80 81 82 SwDocStatPage::SwDocStatPage(Window *pParent, const SfxItemSet &rSet) : 83 84 SfxTabPage (pParent, SW_RES(TP_DOC_STAT), rSet), 85 aPageLbl (this, SW_RES( FT_PAGE )), 86 aPageNo (this, SW_RES( FT_PAGE_COUNT )), 87 aTableLbl (this, SW_RES( FT_TABLE )), 88 aTableNo (this, SW_RES( FT_TABLE_COUNT)), 89 aGrfLbl (this, SW_RES( FT_GRF )), 90 aGrfNo (this, SW_RES( FT_GRF_COUNT )), 91 aOLELbl (this, SW_RES( FT_OLE )), 92 aOLENo (this, SW_RES( FT_OLE_COUNT )), 93 aParaLbl (this, SW_RES( FT_PARA )), 94 aParaNo (this, SW_RES( FT_PARA_COUNT )), 95 aWordLbl (this, SW_RES( FT_WORD )), 96 aWordNo (this, SW_RES( FT_WORD_COUNT )), 97 aCharLbl (this, SW_RES( FT_CHAR )), 98 aCharNo (this, SW_RES( FT_CHAR_COUNT )), 99 aLineLbl (this, SW_RES( FT_LINE )), 100 aLineNo (this, SW_RES( FT_LINE_COUNT )), 101 aUpdatePB (this, SW_RES( PB_PDATE )) 102 { 103 Update(); 104 FreeResource(); 105 aUpdatePB.SetClickHdl(LINK(this, SwDocStatPage, UpdateHdl)); 106 //#111684# is the current view a page preview no SwFEShell can be found -> hide the update button 107 SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current(); 108 SwFEShell* pFEShell = pDocShell->GetFEShell(); 109 if(!pFEShell) 110 { 111 aUpdatePB.Show(sal_False); 112 aLineLbl.Show(sal_False); 113 aLineNo .Show(sal_False); 114 } 115 116 } 117 118 119 SwDocStatPage::~SwDocStatPage() 120 { 121 } 122 123 /*-------------------------------------------------------------------- 124 Beschreibung: ItemSet fuellen bei Aenderung 125 --------------------------------------------------------------------*/ 126 127 128 sal_Bool SwDocStatPage::FillItemSet(SfxItemSet & /*rSet*/) 129 { 130 return sal_False; 131 } 132 133 /*-------------------------------------------------------------------- 134 Beschreibung: 135 --------------------------------------------------------------------*/ 136 137 138 void SwDocStatPage::Reset(const SfxItemSet &/*rSet*/) 139 { 140 } 141 /*------------------------------------------------------------------------ 142 Beschreibung: Aktualisieren / Setzen der Daten 143 ------------------------------------------------------------------------*/ 144 145 146 void SwDocStatPage::SetData(const SwDocStat &rStat) 147 { 148 aTableNo.SetText(String::CreateFromInt32( rStat.nTbl )); 149 aGrfNo.SetText(String::CreateFromInt32( rStat.nGrf )); 150 aOLENo.SetText(String::CreateFromInt32( rStat.nOLE )); 151 aPageNo.SetText(String::CreateFromInt32( rStat.nPage )); 152 aParaNo.SetText(String::CreateFromInt32( rStat.nPara )); 153 aWordNo.SetText(String::CreateFromInt32( rStat.nWord )); 154 aCharNo.SetText(String::CreateFromInt32( rStat.nChar )); 155 } 156 157 /*------------------------------------------------------------------------ 158 Beschreibung: Aktualisieren der Statistik 159 ------------------------------------------------------------------------*/ 160 161 162 void SwDocStatPage::Update() 163 { 164 SfxViewShell *pVSh = SfxViewShell::Current(); 165 ViewShell *pSh = 0; 166 if ( pVSh->ISA(SwView) ) 167 pSh = ((SwView*)pVSh)->GetWrtShellPtr(); 168 else if ( pVSh->ISA(SwPagePreView) ) 169 pSh = ((SwPagePreView*)pVSh)->GetViewShell(); 170 171 ASSERT( pSh, "Shell not found" ); 172 173 SwWait aWait( *pSh->GetDoc()->GetDocShell(), sal_True ); 174 pSh->StartAction(); 175 aDocStat = pSh->GetDoc()->GetDocStat(); 176 pSh->GetDoc()->UpdateDocStat( aDocStat ); 177 pSh->EndAction(); 178 179 SetData(aDocStat); 180 } 181 182 /*-----------------19.06.97 16.37------------------- 183 Zeilennummer aktualisieren 184 --------------------------------------------------*/ 185 IMPL_LINK( SwDocStatPage, UpdateHdl, PushButton*, EMPTYARG) 186 { 187 Update(); 188 SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current(); 189 SwFEShell* pFEShell = pDocShell->GetFEShell(); 190 if(pFEShell) 191 aLineNo.SetText( String::CreateFromInt32( pFEShell->GetLineCount(sal_False))); 192 //pButton->Disable(); 193 return 0; 194 } 195 196