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