From 686c35a3c37674d08c1f8585a621143c959b3f29 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Fri, 11 Jun 2021 12:23:45 +0900 Subject: indexing: indexing paragraph text with the ModelTraverser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds the basic paragraph text export for indexing, which uses the new ModelTraverser, which is inspired by AccessibilityCheck (and in the future it will be changed to use the ModelTraverser too, when it matures). ModelTraverser implements traversing through the model and executes a handler for a element of a model (which can be various things). IndexingExport class implements indexing export that uses the ModelTraverser to write into the indexing xml document, that uses the tools::XmlWriter. Change-Id: I7a6a5de332534270fe894a881131e5eb5ea9d881 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117356 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- sw/source/core/model/ModelTraverser.cxx | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 sw/source/core/model/ModelTraverser.cxx (limited to 'sw/source/core/model/ModelTraverser.cxx') diff --git a/sw/source/core/model/ModelTraverser.cxx b/sw/source/core/model/ModelTraverser.cxx new file mode 100644 index 000000000000..f46e173eca9f --- /dev/null +++ b/sw/source/core/model/ModelTraverser.cxx @@ -0,0 +1,39 @@ +/* -*- 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/. + * + */ + +#include +#include +#include + +namespace sw +{ +void ModelTraverser::traverse() +{ + if (m_pDoc == nullptr) + return; + + auto const& pNodes = m_pDoc->GetNodes(); + SwNode* pNode = nullptr; + for (sal_uLong n = 0; n < pNodes.Count(); ++n) + { + pNode = pNodes[n]; + if (pNode) + { + for (auto& pNodeHandler : mpNodeHandler) + { + pNodeHandler->handleNode(pNode); + } + } + } +} + +} // end sw namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3