bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / dialog / docstdlg.cxx
blob8e3f0acfc5119e2b10ec53647016a64cc3457d7f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <stdio.h>
21 #include <ctype.h>
22 #include <swwait.hxx>
23 #include <wrtsh.hxx>
24 #include <view.hxx>
25 #include <swmodule.hxx>
26 #include <globals.hrc>
27 #include <docsh.hxx>
28 #include <pview.hxx>
29 #include <doc.hxx>
30 #include <docstdlg.hxx>
31 #include <modcfg.hxx>
33 // for statistics fields
34 #include <fldmgr.hxx>
35 #include <fldbas.hxx>
37 SfxTabPage * SwDocStatPage::Create(Window *pParent, const SfxItemSet &rSet)
39 return new SwDocStatPage(pParent, rSet);
42 SwDocStatPage::SwDocStatPage(Window *pParent, const SfxItemSet &rSet)
44 : SfxTabPage(pParent, "StatisticsInfoPage", "modules/swriter/ui/statisticsinfopage.ui", rSet)
47 get(m_pPageNo, "nopages");
48 get(m_pTableNo, "notables");
49 get(m_pGrfNo, "nogrfs");
50 get(m_pOLENo, "nooles");
51 get(m_pParaNo, "noparas");
52 get(m_pWordNo, "nowords");
53 get(m_pCharNo, "nochars");
54 get(m_pCharExclSpacesNo, "nocharsexspaces");
56 get(m_pLineLbl, "lineft");
57 get(m_pLineNo, "nolines");
58 get(m_pUpdatePB, "update");
60 Update();
61 m_pUpdatePB->SetClickHdl(LINK(this, SwDocStatPage, UpdateHdl));
62 //#111684# is the current view a page preview no SwFEShell can be found -> hide the update button
63 SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current();
64 SwFEShell* pFEShell = pDocShell->GetFEShell();
65 if(!pFEShell)
67 m_pUpdatePB->Show(sal_False);
68 m_pLineLbl->Show(sal_False);
69 m_pLineNo->Show(sal_False);
75 SwDocStatPage::~SwDocStatPage()
79 /*--------------------------------------------------------------------
80 Description: fill ItemSet when changed
81 --------------------------------------------------------------------*/
84 sal_Bool SwDocStatPage::FillItemSet(SfxItemSet & /*rSet*/)
86 return sal_False;
89 void SwDocStatPage::Reset(const SfxItemSet &/*rSet*/)
92 /*------------------------------------------------------------------------
93 Description: update / set data
94 ------------------------------------------------------------------------*/
97 void SwDocStatPage::SetData(const SwDocStat &rStat)
99 m_pTableNo->SetText(OUString::number( rStat.nTbl ));
100 m_pGrfNo->SetText(OUString::number( rStat.nGrf ));
101 m_pOLENo->SetText(OUString::number( rStat.nOLE ));
102 m_pPageNo->SetText(OUString::number( rStat.nPage ));
103 m_pParaNo->SetText(OUString::number( rStat.nPara ));
104 m_pWordNo->SetText(OUString::number( rStat.nWord ));
105 m_pCharNo->SetText(OUString::number( rStat.nChar ));
106 m_pCharExclSpacesNo->SetText(OUString::number( rStat.nCharExcludingSpaces ));
109 /*------------------------------------------------------------------------
110 Description: update statistics
111 ------------------------------------------------------------------------*/
114 void SwDocStatPage::Update()
116 SfxViewShell *pVSh = SfxViewShell::Current();
117 ViewShell *pSh = 0;
118 if ( pVSh->ISA(SwView) )
119 pSh = ((SwView*)pVSh)->GetWrtShellPtr();
120 else if ( pVSh->ISA(SwPagePreView) )
121 pSh = ((SwPagePreView*)pVSh)->GetViewShell();
123 OSL_ENSURE( pSh, "Shell not found" );
125 SwWait aWait( *pSh->GetDoc()->GetDocShell(), sal_True );
126 pSh->StartAction();
127 aDocStat = pSh->GetDoc()->GetUpdatedDocStat();
128 pSh->EndAction();
130 SetData(aDocStat);
133 IMPL_LINK_NOARG(SwDocStatPage, UpdateHdl)
135 Update();
136 SwDocShell* pDocShell = (SwDocShell*) SfxObjectShell::Current();
137 SwFEShell* pFEShell = pDocShell->GetFEShell();
138 if(pFEShell)
139 m_pLineNo->SetText( OUString::number( pFEShell->GetLineCount(sal_False)));
140 //pButton->Disable();
141 return 0;
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */