LibreOffice Module sw (master) 1
docstdlg.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <swwait.hxx>
21#include <wrtsh.hxx>
22#include <view.hxx>
23#include <docsh.hxx>
24#include <pview.hxx>
25#include <doc.hxx>
26#include <docstdlg.hxx>
28
30#include <vcl/settings.hxx>
31#include <vcl/svapp.hxx>
32#include <osl/diagnose.h>
33
34std::unique_ptr<SfxTabPage> SwDocStatPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet)
35{
36 return std::make_unique<SwDocStatPage>(pPage, pController, *rSet);
37}
38
40 : SfxTabPage(pPage, pController, "modules/swriter/ui/statisticsinfopage.ui", "StatisticsInfoPage", &rSet)
41 , m_xPageNo(m_xBuilder->weld_label("nopages"))
42 , m_xTableNo(m_xBuilder->weld_label("notables"))
43 , m_xGrfNo(m_xBuilder->weld_label("nogrfs"))
44 , m_xOLENo(m_xBuilder->weld_label("nooles"))
45 , m_xParaNo(m_xBuilder->weld_label("noparas"))
46 , m_xWordNo(m_xBuilder->weld_label("nowords"))
47 , m_xCharNo(m_xBuilder->weld_label("nochars"))
48 , m_xCharExclSpacesNo(m_xBuilder->weld_label("nocharsexspaces"))
49 , m_xLineLbl(m_xBuilder->weld_label("lineft"))
50 , m_xLineNo(m_xBuilder->weld_label("nolines"))
51 , m_xUpdatePB(m_xBuilder->weld_button("update"))
52{
53 Update();
54 m_xUpdatePB->connect_clicked(LINK(this, SwDocStatPage, UpdateHdl));
55 //#111684# is the current view a page preview no SwFEShell can be found -> hide the update button
56 SwDocShell* pDocShell = static_cast<SwDocShell*>( SfxObjectShell::Current() );
57 SwFEShell* pFEShell = pDocShell ? pDocShell->GetFEShell() : nullptr;
58 if(!pFEShell)
59 {
60 m_xUpdatePB->hide();
61 m_xLineLbl->hide();
62 m_xLineNo->hide();
63 }
64}
65
67{
68}
69
70// Description: fill ItemSet when changed
72{
73 return false;
74}
75
77{
78}
79
80// Description: update / set data
82{
84 m_xTableNo->set_label(rLocaleData.getNum(rStat.nTable, 0));
85 m_xGrfNo->set_label(rLocaleData.getNum(rStat.nGrf, 0));
86 m_xOLENo->set_label(rLocaleData.getNum(rStat.nOLE, 0));
87 m_xPageNo->set_label(rLocaleData.getNum(rStat.nPage, 0));
88 m_xParaNo->set_label(rLocaleData.getNum(rStat.nPara, 0));
89 m_xWordNo->set_label(rLocaleData.getNum(rStat.nWord, 0));
90 m_xCharNo->set_label(rLocaleData.getNum(rStat.nChar, 0));
91 m_xCharExclSpacesNo->set_label(rLocaleData.getNum(rStat.nCharExcludingSpaces, 0));
92}
93
94// Description: update statistics
96{
98 SwViewShell *pSh = nullptr;
99 if ( auto pSwView = dynamic_cast<SwView *>( pVSh ) )
100 pSh = pSwView->GetWrtShellPtr();
101 else if ( auto pPagePreview = dynamic_cast<SwPagePreview *>( pVSh ) )
102 pSh = pPagePreview->GetViewShell();
103
104 OSL_ENSURE( pSh, "Shell not found" );
105
106 if (!pSh)
107 return;
108
109 SwWait aWait( *pSh->GetDoc()->GetDocShell(), true );
110 pSh->StartAction();
112 pSh->EndAction();
113
115}
116
118{
119 Update();
120 SwDocShell* pDocShell = static_cast<SwDocShell*>( SfxObjectShell::Current());
121 SwFEShell* pFEShell = pDocShell ? pDocShell->GetFEShell() : nullptr;
122 if (pFEShell)
123 m_xLineNo->set_label(OUString::number(pFEShell->GetLineCount()));
124}
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const LocaleDataWrapper & GetUILocaleDataWrapper() const
static const AllSettings & GetSettings()
virtual const SwDocStat & GetUpdatedDocStat(bool bCompleteAsync, bool bFields)=0
Updates the document statistics if the document has been modified and returns a reference to the resu...
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
SwFEShell * GetFEShell()
For Core - it knows the DocShell but not the WrtShell!
Definition: docsh.cxx:1223
std::unique_ptr< weld::Label > m_xWordNo
Definition: docstdlg.hxx:45
SwDocStat m_aDocStat
Definition: docstdlg.hxx:52
SwDocStatPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: docstdlg.cxx:39
std::unique_ptr< weld::Label > m_xParaNo
Definition: docstdlg.hxx:44
void SetData(const SwDocStat &rStat)
Definition: docstdlg.cxx:81
std::unique_ptr< weld::Label > m_xPageNo
Definition: docstdlg.hxx:40
std::unique_ptr< weld::Label > m_xOLENo
Definition: docstdlg.hxx:43
void Update()
Definition: docstdlg.cxx:95
std::unique_ptr< weld::Button > m_xUpdatePB
Definition: docstdlg.hxx:50
std::unique_ptr< weld::Label > m_xGrfNo
Definition: docstdlg.hxx:42
std::unique_ptr< weld::Label > m_xTableNo
Definition: docstdlg.hxx:41
std::unique_ptr< weld::Label > m_xLineLbl
Definition: docstdlg.hxx:48
std::unique_ptr< weld::Label > m_xCharExclSpacesNo
Definition: docstdlg.hxx:47
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: docstdlg.cxx:71
std::unique_ptr< weld::Label > m_xLineNo
Definition: docstdlg.hxx:49
std::unique_ptr< weld::Label > m_xCharNo
Definition: docstdlg.hxx:46
virtual void Reset(const SfxItemSet *rSet) override
Definition: docstdlg.cxx:76
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: docstdlg.cxx:34
virtual ~SwDocStatPage() override
Definition: docstdlg.cxx:66
SwDocShell * GetDocShell()
Definition: doc.hxx:1370
IDocumentStatistics const & getIDocumentStatistics() const
Definition: doc.cxx:387
sal_Int32 GetLineCount()
Definition: editsh.cxx:855
View of a document.
Definition: pview.hxx:162
void StartAction()
Definition: viewsh.hxx:619
void EndAction(const bool bIdleEnd=false)
Definition: viewsh.hxx:625
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
Definition: view.hxx:146
IMPL_LINK_NOARG(SwDocStatPage, UpdateHdl, weld::Button &, void)
Definition: docstdlg.cxx:117
static SfxItemSet & rSet
sal_uLong nWord
Definition: docstat.hxx:35
sal_uInt16 nOLE
Definition: docstat.hxx:29
sal_uInt16 nTable
Definition: docstat.hxx:27
sal_uLong nCharExcludingSpaces
Definition: docstat.hxx:38
sal_uInt16 nGrf
Definition: docstat.hxx:28
sal_uLong nPara
paragraphs for document statistic: non-empty and non-hidden ones
Definition: docstat.hxx:32
sal_uLong nPage
Definition: docstat.hxx:30
sal_uLong nChar
Definition: docstat.hxx:37