sc: factor out some more code
[LibreOffice.git] / sw / source / core / model / ModelTraverser.cxx
blob6ab8e39c42cf3ef6132d5e16228dba3c583b2ef8
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 */
11 #include <ModelTraverser.hxx>
12 #include <node.hxx>
13 #include <ndarr.hxx>
14 #include <IDocumentDrawModelAccess.hxx>
15 #include <svx/svdpage.hxx>
16 #include <drawdoc.hxx>
18 namespace sw
20 void ModelTraverser::traverse()
22 if (m_pDoc == nullptr)
23 return;
25 auto const& pNodes = m_pDoc->GetNodes();
26 SwNode* pNode = nullptr;
28 for (SwNodeOffset n(0); n < pNodes.Count(); ++n)
30 pNode = pNodes[n];
31 if (pNode)
33 for (auto& pNodeHandler : mpNodeHandler)
35 pNodeHandler->handleNode(pNode);
40 IDocumentDrawModelAccess& rDrawModelAccess = m_pDoc->getIDocumentDrawModelAccess();
41 auto* pModel = rDrawModelAccess.GetDrawModel();
42 for (sal_uInt16 nPage = 0; nPage < pModel->GetPageCount(); ++nPage)
44 SdrPage* pPage = pModel->GetPage(nPage);
45 for (const rtl::Reference<SdrObject>& pObject : *pPage)
47 for (auto& pNodeHandler : mpNodeHandler)
49 pNodeHandler->handleSdrObject(pObject.get());
55 } // end sw namespace
57 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */