Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <stdio.h>
30 : : #include <ctype.h>
31 : : #include <swwait.hxx>
32 : : #include <wrtsh.hxx>
33 : : #include <view.hxx>
34 : : #include <swmodule.hxx>
35 : : #include <globals.hrc>
36 : : #include <docsh.hxx>
37 : : #include <pview.hxx>
38 : : #include <doc.hxx>
39 : : #include <docstdlg.hxx>
40 : : #include <modcfg.hxx>
41 : :
42 : : // for statistics fields
43 : : #include <fldmgr.hxx>
44 : : #include <fldbas.hxx>
45 : :
46 : : #include <docstdlg.hrc>
47 : :
48 : :
49 : 0 : SfxTabPage * SwDocStatPage::Create(Window *pParent, const SfxItemSet &rSet)
50 : : {
51 : 0 : return new SwDocStatPage(pParent, rSet);
52 : : }
53 : :
54 : 0 : SwDocStatPage::SwDocStatPage(Window *pParent, const SfxItemSet &rSet) :
55 : :
56 : : SfxTabPage (pParent, SW_RES(TP_DOC_STAT), rSet),
57 : : aPageLbl (this, SW_RES( FT_PAGE )),
58 : : aPageNo (this, SW_RES( FT_PAGE_COUNT )),
59 : : aTableLbl (this, SW_RES( FT_TABLE )),
60 : : aTableNo (this, SW_RES( FT_TABLE_COUNT)),
61 : : aGrfLbl (this, SW_RES( FT_GRF )),
62 : : aGrfNo (this, SW_RES( FT_GRF_COUNT )),
63 : : aOLELbl (this, SW_RES( FT_OLE )),
64 : : aOLENo (this, SW_RES( FT_OLE_COUNT )),
65 : : aParaLbl (this, SW_RES( FT_PARA )),
66 : : aParaNo (this, SW_RES( FT_PARA_COUNT )),
67 : : aWordLbl (this, SW_RES( FT_WORD )),
68 : : aWordNo (this, SW_RES( FT_WORD_COUNT )),
69 : : aCharLbl (this, SW_RES( FT_CHAR )),
70 : : aCharNo (this, SW_RES( FT_CHAR_COUNT )),
71 : : aCharExclSpacesLbl (this, SW_RES( FT_CHAR_EXCL_SPACES )),
72 : : aCharExclSpacesNo (this, SW_RES( FT_CHAR_COUNT_EXCL_SPACES )),
73 : : aLineLbl (this, SW_RES( FT_LINE )),
74 : : aLineNo (this, SW_RES( FT_LINE_COUNT )),
75 : 0 : aUpdatePB (this, SW_RES( PB_PDATE ))
76 : : {
77 : 0 : Update();
78 : 0 : FreeResource();
79 : 0 : aUpdatePB.SetClickHdl(LINK(this, SwDocStatPage, UpdateHdl));
80 : : //#111684# is the current view a page preview no SwFEShell can be found -> hide the update button
81 : 0 : SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current();
82 : 0 : SwFEShell* pFEShell = pDocShell->GetFEShell();
83 : 0 : if(!pFEShell)
84 : : {
85 : 0 : aUpdatePB.Show(sal_False);
86 : 0 : aLineLbl.Show(sal_False);
87 : 0 : aLineNo .Show(sal_False);
88 : : }
89 : :
90 : 0 : }
91 : :
92 : :
93 : 0 : SwDocStatPage::~SwDocStatPage()
94 : : {
95 : 0 : }
96 : :
97 : : /*--------------------------------------------------------------------
98 : : Description: fill ItemSet when changed
99 : : --------------------------------------------------------------------*/
100 : :
101 : :
102 : 0 : sal_Bool SwDocStatPage::FillItemSet(SfxItemSet & /*rSet*/)
103 : : {
104 : 0 : return sal_False;
105 : : }
106 : :
107 : 0 : void SwDocStatPage::Reset(const SfxItemSet &/*rSet*/)
108 : : {
109 : 0 : }
110 : : /*------------------------------------------------------------------------
111 : : Description: update / set data
112 : : ------------------------------------------------------------------------*/
113 : :
114 : :
115 : 0 : void SwDocStatPage::SetData(const SwDocStat &rStat)
116 : : {
117 : 0 : aTableNo.SetText(String::CreateFromInt32( rStat.nTbl ));
118 : 0 : aGrfNo.SetText(String::CreateFromInt32( rStat.nGrf ));
119 : 0 : aOLENo.SetText(String::CreateFromInt32( rStat.nOLE ));
120 : 0 : aPageNo.SetText(String::CreateFromInt32( rStat.nPage ));
121 : 0 : aParaNo.SetText(String::CreateFromInt32( rStat.nPara ));
122 : 0 : aWordNo.SetText(String::CreateFromInt32( rStat.nWord ));
123 : 0 : aCharNo.SetText(String::CreateFromInt32( rStat.nChar ));
124 : 0 : aCharExclSpacesNo.SetText(String::CreateFromInt32( rStat.nCharExcludingSpaces ));
125 : 0 : }
126 : :
127 : : /*------------------------------------------------------------------------
128 : : Description: update statistics
129 : : ------------------------------------------------------------------------*/
130 : :
131 : :
132 : 0 : void SwDocStatPage::Update()
133 : : {
134 : 0 : SfxViewShell *pVSh = SfxViewShell::Current();
135 : 0 : ViewShell *pSh = 0;
136 : 0 : if ( pVSh->ISA(SwView) )
137 : 0 : pSh = ((SwView*)pVSh)->GetWrtShellPtr();
138 : 0 : else if ( pVSh->ISA(SwPagePreView) )
139 : 0 : pSh = ((SwPagePreView*)pVSh)->GetViewShell();
140 : :
141 : : OSL_ENSURE( pSh, "Shell not found" );
142 : :
143 : 0 : SwWait aWait( *pSh->GetDoc()->GetDocShell(), sal_True );
144 : 0 : pSh->StartAction();
145 : 0 : aDocStat = pSh->GetDoc()->GetUpdatedDocStat();
146 : 0 : pSh->EndAction();
147 : :
148 : 0 : SetData(aDocStat);
149 : 0 : }
150 : :
151 : 0 : IMPL_LINK_NOARG(SwDocStatPage, UpdateHdl)
152 : : {
153 : 0 : Update();
154 : 0 : SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current();
155 : 0 : SwFEShell* pFEShell = pDocShell->GetFEShell();
156 : 0 : if(pFEShell)
157 : 0 : aLineNo.SetText( String::CreateFromInt32( pFEShell->GetLineCount(sal_False)));
158 : : //pButton->Disable();
159 : 0 : return 0;
160 : : }
161 : :
162 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|