Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/inc/xmlsourcedlg.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 "anyrefdg.hxx"
13
#include <orcusxml.hxx>
14
15
#include <vcl/weld/TreeView.hxx>
16
17
#include <set>
18
#include <memory>
19
20
class ScDocument;
21
class ScOrcusXMLContext;
22
23
struct CustomCompare
24
{
25
    weld::TreeView& mrLbTree;
26
    CustomCompare(weld::TreeView& rLbTree)
27
0
        : mrLbTree(rLbTree)
28
0
    {
29
0
    }
30
    bool operator()(const std::unique_ptr<weld::TreeIter>& lhs,
31
                    const std::unique_ptr<weld::TreeIter>& rhs) const
32
0
    {
33
0
        return mrLbTree.iter_compare(*lhs, *rhs) == -1;
34
0
    }
35
};
36
37
class ScXMLSourceDlg : public ScAnyRefDlgController
38
{
39
    OUString maSrcPath;
40
41
    ScOrcusXMLTreeParam maXMLParam;
42
    std::unique_ptr<weld::TreeIter> mxCurRefEntry;
43
    std::unique_ptr<ScOrcusXMLContext> mpXMLContext;
44
45
    ScDocument& mrDoc;
46
    bool mbDlgLostFocus;
47
48
    formula::RefEdit* mpActiveEdit;
49
    std::unique_ptr<weld::Button> mxBtnSelectSource;
50
    std::unique_ptr<weld::Label> mxFtSourceFile;
51
52
    std::unique_ptr<weld::Container> mxMapGrid;
53
54
    std::unique_ptr<weld::TreeView> mxLbTree;
55
    std::unique_ptr<formula::RefEdit> mxRefEdit;
56
    std::unique_ptr<formula::RefButton> mxRefBtn;
57
58
    std::unique_ptr<weld::Button> mxBtnOk;
59
    std::unique_ptr<weld::Button> mxBtnCancel;
60
61
    CustomCompare maCustomCompare;
62
63
    std::set<std::unique_ptr<weld::TreeIter>, CustomCompare> maCellLinks;
64
    std::set<std::unique_ptr<weld::TreeIter>, CustomCompare> maRangeLinks;
65
66
public:
67
    ScXMLSourceDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, ScDocument& rDoc);
68
    virtual ~ScXMLSourceDlg() override;
69
70
    virtual bool IsRefInputMode() const override;
71
    virtual void SetReference(const ScRange& rRange, ScDocument& rDoc) override;
72
    virtual void Deactivate() override;
73
    virtual void SetActive() override;
74
    virtual void Close() override;
75
76
private:
77
    void SelectSourceFile();
78
    void LoadSourceFileStructure(const OUString& rPath);
79
    void TreeItemSelected();
80
    void DefaultElementSelected(const weld::TreeIter& rEntry);
81
    void RepeatElementSelected(const weld::TreeIter& rEntry);
82
    void AttributeSelected(const weld::TreeIter& rEntry);
83
84
    void SetNonLinkable();
85
    void SetSingleLinkable();
86
    void SetRangeLinkable();
87
    void SelectAllChildEntries(const weld::TreeIter& rEntry);
88
89
    /**
90
     * Check if any of its parents is linked or repeated.  The passed entry is
91
     * not checked; its parent is the first one to be checked, then all its
92
     * parents get checked all the way to the root.
93
     */
94
    bool IsParentDirty(const weld::TreeIter* pEntry) const;
95
96
    bool IsChildrenDirty(const weld::TreeIter* pEntry) const;
97
98
    void OkPressed();
99
    void CancelPressed();
100
    void RefEditModified();
101
102
    DECL_LINK(BtnPressedHdl, weld::Button&, void);
103
    DECL_LINK(TreeItemSelectHdl, weld::TreeView&, void);
104
    DECL_LINK(RefModifiedHdl, formula::RefEdit&, void);
105
};
106
107
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */