From 5041d7405224c9f11b1b7f60e85815547ec921c0 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Thu, 5 Dec 2024 17:41:36 -0500 Subject: [PATCH] Word count for references. This is different from the version in master, since JMarc rewrote the stats code. --- src/Buffer.cpp | 2 +- src/insets/InsetRef.cpp | 11 +++++++++++ src/insets/InsetRef.h | 2 ++ status.24x | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 79f41cb13f..e1e10e86c6 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -5496,7 +5496,7 @@ void Buffer::Impl::updateStatistics(DocIterator & from, DocIterator & to, bool s char_count_ = 0; blank_count_ = 0; - for (DocIterator dit = from ; dit != to && !dit.atEnd(); ) { + for (DocIterator dit = from; dit != to && !dit.atEnd(); ) { if (!dit.inTexted()) { dit.forwardPos(); continue; diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 7666d13e1d..d29ba1b2b9 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -668,4 +668,15 @@ docstring InsetRef::getTOCString() const return (broken_ ? _("BROKEN: ") : docstring()) + toc_string_; } +pair InsetRef::isWords() const +{ + docstring const & ref = getParam("reference"); + string const & cmd = params().getCmdName(); + // best we can do here + string const & lang = buffer().params().language->lang(); + docstring const refstring = displayString(ref, cmd, lang); + return pair(refstring.size(), wordCount(refstring)); +} + + } // namespace lyx diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index 52c8de79e2..3cadaea267 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -79,6 +79,8 @@ public: UpdateType utype, TocBackend & backend) const override; /// bool forceLTR(OutputParams const &) const override; + /// + std::pair isWords() const override; //@} /// \name Static public methods obligated for InsetCommand derived classes diff --git a/status.24x b/status.24x index e40b3fe522..930d6d74d0 100644 --- a/status.24x +++ b/status.24x @@ -33,6 +33,8 @@ What's new the outliner, even of they do not have a label yet. In the latter case, a label is autonatically inserted. +- Approximate word count for cross-references. + - Document PDF settings allow color links and frames around them. These two settings are mutually exclusive by default and we signal that within UI now. Workarounds can be found our and hyperref manual.