xref: /aoo42x/main/sw/source/ui/dialog/docstdlg.cxx (revision 8ef2f12b)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
27cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <stdio.h>
32cdf0e10cSrcweir #include <ctype.h>
33cdf0e10cSrcweir #include <swwait.hxx>
34cdf0e10cSrcweir #include <wrtsh.hxx>
35cdf0e10cSrcweir #ifndef _VIEW_HXX
36cdf0e10cSrcweir #include <view.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <swmodule.hxx>
39cdf0e10cSrcweir #ifndef _GLOBALS_HRC
40cdf0e10cSrcweir #include <globals.hrc>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _DOCSH_HXX
43cdf0e10cSrcweir #include <docsh.hxx>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef _PVIEW_HXX
46cdf0e10cSrcweir #include <pview.hxx>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #include <doc.hxx>
49cdf0e10cSrcweir #include <docstdlg.hxx>
50cdf0e10cSrcweir #ifndef _MODCFG_HXX
51cdf0e10cSrcweir #include <modcfg.hxx>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // fuer Statistikfelder
55cdf0e10cSrcweir #include <fldmgr.hxx>
56cdf0e10cSrcweir #include <fldbas.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #ifndef _DOCSTDLG_HRC
59cdf0e10cSrcweir #include <docstdlg.hrc>
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir /*--------------------------------------------------------------------
64cdf0e10cSrcweir 	Beschreibung: Create
65cdf0e10cSrcweir  --------------------------------------------------------------------*/
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 
Create(Window * pParent,const SfxItemSet & rSet)68cdf0e10cSrcweir SfxTabPage *  SwDocStatPage::Create(Window *pParent, const SfxItemSet &rSet)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	return new SwDocStatPage(pParent, rSet);
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir /*--------------------------------------------------------------------
74cdf0e10cSrcweir 	Beschreibung:	Ctor
75cdf0e10cSrcweir  --------------------------------------------------------------------*/
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
SwDocStatPage(Window * pParent,const SfxItemSet & rSet)78cdf0e10cSrcweir SwDocStatPage::SwDocStatPage(Window *pParent, const SfxItemSet &rSet) :
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	SfxTabPage	(pParent, SW_RES(TP_DOC_STAT), rSet),
81cdf0e10cSrcweir     aPageLbl	(this, SW_RES( FT_PAGE		 )),
82cdf0e10cSrcweir 	aPageNo		(this, SW_RES( FT_PAGE_COUNT )),
83cdf0e10cSrcweir     aTableLbl	(this, SW_RES( FT_TABLE		 )),
84cdf0e10cSrcweir     aTableNo    (this, SW_RES( FT_TABLE_COUNT)),
85cdf0e10cSrcweir     aGrfLbl		(this, SW_RES( FT_GRF		 )),
86cdf0e10cSrcweir 	aGrfNo		(this, SW_RES( FT_GRF_COUNT  )),
87cdf0e10cSrcweir     aOLELbl		(this, SW_RES( FT_OLE		 )),
88cdf0e10cSrcweir 	aOLENo		(this, SW_RES( FT_OLE_COUNT  )),
89cdf0e10cSrcweir     aParaLbl	(this, SW_RES( FT_PARA		 )),
90cdf0e10cSrcweir 	aParaNo		(this, SW_RES( FT_PARA_COUNT )),
91cdf0e10cSrcweir     aWordLbl	(this, SW_RES( FT_WORD		 )),
92cdf0e10cSrcweir 	aWordNo		(this, SW_RES( FT_WORD_COUNT )),
93cdf0e10cSrcweir     aCharLbl	(this, SW_RES( FT_CHAR 	     )),
94cdf0e10cSrcweir    	aCharNo		(this, SW_RES( FT_CHAR_COUNT )),
95cdf0e10cSrcweir     aLineLbl    (this, SW_RES( FT_LINE       )),
96cdf0e10cSrcweir 	aLineNo		(this, SW_RES( FT_LINE_COUNT )),
97cdf0e10cSrcweir 	aUpdatePB	(this, SW_RES( PB_PDATE      ))
98cdf0e10cSrcweir {
99cdf0e10cSrcweir     Update();
100cdf0e10cSrcweir 	FreeResource();
101cdf0e10cSrcweir 	aUpdatePB.SetClickHdl(LINK(this, SwDocStatPage, UpdateHdl));
102cdf0e10cSrcweir     //#111684# is the current view a page preview no SwFEShell can be found -> hide the update button
103cdf0e10cSrcweir     SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current();
104cdf0e10cSrcweir     SwFEShell* pFEShell = pDocShell->GetFEShell();
105cdf0e10cSrcweir     if(!pFEShell)
106cdf0e10cSrcweir     {
107cdf0e10cSrcweir         aUpdatePB.Show(sal_False);
108cdf0e10cSrcweir         aLineLbl.Show(sal_False);
109cdf0e10cSrcweir         aLineNo .Show(sal_False);
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
~SwDocStatPage()115cdf0e10cSrcweir  SwDocStatPage::~SwDocStatPage()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir /*--------------------------------------------------------------------
120cdf0e10cSrcweir 	Beschreibung:	ItemSet fuellen bei Aenderung
121cdf0e10cSrcweir  --------------------------------------------------------------------*/
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
FillItemSet(SfxItemSet &)124cdf0e10cSrcweir sal_Bool  SwDocStatPage::FillItemSet(SfxItemSet & /*rSet*/)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	return sal_False;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir /*--------------------------------------------------------------------
130cdf0e10cSrcweir 	Beschreibung:
131cdf0e10cSrcweir  --------------------------------------------------------------------*/
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 
Reset(const SfxItemSet &)134cdf0e10cSrcweir void  SwDocStatPage::Reset(const SfxItemSet &/*rSet*/)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir }
137cdf0e10cSrcweir /*------------------------------------------------------------------------
138cdf0e10cSrcweir  Beschreibung:	Aktualisieren / Setzen der Daten
139cdf0e10cSrcweir ------------------------------------------------------------------------*/
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 
SetData(const SwDocStat & rStat)142cdf0e10cSrcweir void SwDocStatPage::SetData(const SwDocStat &rStat)
143cdf0e10cSrcweir {
144cdf0e10cSrcweir 	aTableNo.SetText(String::CreateFromInt32( rStat.nTbl ));
145cdf0e10cSrcweir 	aGrfNo.SetText(String::CreateFromInt32( rStat.nGrf ));
146cdf0e10cSrcweir 	aOLENo.SetText(String::CreateFromInt32( rStat.nOLE ));
147cdf0e10cSrcweir 	aPageNo.SetText(String::CreateFromInt32( rStat.nPage ));
148cdf0e10cSrcweir 	aParaNo.SetText(String::CreateFromInt32( rStat.nPara ));
149cdf0e10cSrcweir 	aWordNo.SetText(String::CreateFromInt32( rStat.nWord ));
150cdf0e10cSrcweir 	aCharNo.SetText(String::CreateFromInt32( rStat.nChar ));
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir /*------------------------------------------------------------------------
154cdf0e10cSrcweir  Beschreibung:	Aktualisieren der Statistik
155cdf0e10cSrcweir ------------------------------------------------------------------------*/
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
Update()158cdf0e10cSrcweir void SwDocStatPage::Update()
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	SfxViewShell *pVSh = SfxViewShell::Current();
161cdf0e10cSrcweir 	ViewShell *pSh = 0;
162cdf0e10cSrcweir 	if ( pVSh->ISA(SwView) )
163cdf0e10cSrcweir 		pSh = ((SwView*)pVSh)->GetWrtShellPtr();
164cdf0e10cSrcweir 	else if ( pVSh->ISA(SwPagePreView) )
165cdf0e10cSrcweir         pSh = ((SwPagePreView*)pVSh)->GetViewShell();
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	ASSERT( pSh, "Shell not found" );
168cdf0e10cSrcweir 
169*8ef2f12bSOliver-Rainer Wittmann 	SwWait aWait( *pSh->GetDoc()->GetDocShell(), true );
170cdf0e10cSrcweir 	pSh->StartAction();
171cdf0e10cSrcweir     aDocStat = pSh->GetDoc()->GetDocStat();
172cdf0e10cSrcweir 	pSh->GetDoc()->UpdateDocStat( aDocStat );
173cdf0e10cSrcweir 	pSh->EndAction();
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	SetData(aDocStat);
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir /*-----------------19.06.97 16.37-------------------
179cdf0e10cSrcweir 	Zeilennummer aktualisieren
180cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwDocStatPage,UpdateHdl,PushButton *,EMPTYARG)181cdf0e10cSrcweir IMPL_LINK( SwDocStatPage, UpdateHdl, PushButton*, EMPTYARG)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir 	Update();
184cdf0e10cSrcweir 	SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current();
185cdf0e10cSrcweir 	SwFEShell* pFEShell = pDocShell->GetFEShell();
186cdf0e10cSrcweir     if(pFEShell)
187cdf0e10cSrcweir         aLineNo.SetText( String::CreateFromInt32( pFEShell->GetLineCount(sal_False)));
188cdf0e10cSrcweir 	//pButton->Disable();
189cdf0e10cSrcweir 	return 0;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192