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