/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ #include <DocumentStatisticsManager.hxx> #include <doc.hxx> #include <fldbas.hxx> #include <docsh.hxx> #include <IDocumentFieldsAccess.hxx> #include <IDocumentState.hxx> #include <IDocumentLayoutAccess.hxx> #include <view.hxx> #include <ndtxt.hxx> #include <fmtfld.hxx> #include <rootfrm.hxx> #include <docufld.hxx> #include <docstat.hxx> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/frame/XModel.hpp>
if (!bCompleteAsync)
{
maStatsUpdateIdle.Stop(); while (IncrementalDocStatCalculate(
std::numeric_limits<tools::Long>::max(), bFields)) {}
} elseif (IncrementalDocStatCalculate(5000, bFields))
maStatsUpdateIdle.Start(); else
maStatsUpdateIdle.Stop();
}
// returns true while there is more to do bool DocumentStatisticsManager::IncrementalDocStatCalculate(tools::Long nChars, bool bFields)
{
mbInitialized = true;
mpDocStat->Reset();
mpDocStat->nPara = 0; // default is 1!
// This is the inner loop - at least while the paras are dirty. for( SwNodeOffset i = m_rDoc.GetNodes().Count(); i > SwNodeOffset(0) && nChars > 0; )
{
SwNode* pNd = m_rDoc.GetNodes()[ --i ]; switch( pNd->GetNodeType() )
{ case SwNodeType::Text:
{
tools::Longconst nOldChars(mpDocStat->nChar);
SwTextNode *pText = static_cast< SwTextNode * >( pNd ); if (pText->CountWords(*mpDocStat, 0, pText->GetText().getLength()))
{
nChars -= (mpDocStat->nChar - nOldChars);
} break;
} case SwNodeType::Table: ++mpDocStat->nTable; break; case SwNodeType::Grf: ++mpDocStat->nGrf; break; case SwNodeType::Ole: ++mpDocStat->nOLE; break; case SwNodeType::Section: break; default: break;
}
}
// For e.g. autotext documents there is no pSwgInfo (#i79945)
SwDocShell* pObjShell(m_rDoc.GetDocShell()); if (pObjShell)
{ const uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
pObjShell->GetModel(), uno::UNO_QUERY_THROW); const uno::Reference<document::XDocumentProperties> xDocProps(
xDPS->getDocumentProperties()); // #i96786#: do not set modified flag when updating statistics constbool bDocWasModified( m_rDoc.getIDocumentState().IsModified() ); const ModifyBlocker_Impl b(pObjShell); // rhbz#1081176: don't jump to cursor pos because of (temporary) // activation of modified flag triggering move to input position auto aViewGuard(pObjShell->LockAllViews());
xDocProps->setDocumentStatistics(aStat); if (!bDocWasModified)
{
m_rDoc.getIDocumentState().ResetModified();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.