Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/inc/ModelTraverser.hxx
Line
Count
Source
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
10
#pragma once
11
12
#include <vector>
13
#include <memory>
14
#include "drawdoc.hxx"
15
16
class SdrObject;
17
class SdrPage;
18
19
namespace sd
20
{
21
/**
22
 * Interface for the visitor class, which handles each visited SdrObject
23
 * in the DOM.
24
 */
25
class ModelTraverseHandler
26
{
27
public:
28
0
    virtual ~ModelTraverseHandler() {}
29
    virtual void handleSdrObject(SdrObject* pObject) = 0;
30
};
31
32
/** Options to change how the traverser is traversing the tree, what is included and what not */
33
struct TraverserOptions
34
{
35
    bool mbMasterPages = false;
36
};
37
38
/**
39
 * Traverses the DOM and calls a handler for each object (SdrObject) it
40
 * encounters.
41
 */
42
class ModelTraverser
43
{
44
private:
45
    std::vector<std::shared_ptr<ModelTraverseHandler>> m_pNodeHandler;
46
    SdDrawDocument* m_pDocument;
47
    TraverserOptions m_aTraverserOptions;
48
49
    void traverseObjects(SdrPage const& rPage);
50
    void traversePages();
51
    void traverseMasterPages();
52
53
public:
54
    ModelTraverser(SdDrawDocument* pDocument, TraverserOptions const& rTraverserOptions)
55
0
        : m_pDocument(pDocument)
56
0
        , m_aTraverserOptions(rTraverserOptions)
57
0
    {
58
0
    }
59
60
    void traverse();
61
    void addNodeHandler(std::shared_ptr<ModelTraverseHandler> pHandler);
62
};
63
64
} // end sd namespace
65
66
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */