Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svtools/dlgname.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
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
#pragma once
20
21
#include <svtools/svtdllapi.h>
22
#include <vcl/formatter.hxx>
23
#include <vcl/weld/DialogController.hxx>
24
#include <vcl/weld/Entry.hxx>
25
#include <vcl/weld/FormattedSpinButton.hxx>
26
#include <vcl/weld/SpinButton.hxx>
27
#include <vcl/weld/TextView.hxx>
28
#include <vcl/weld/TreeView.hxx>
29
#include <vcl/weld/weld.hxx>
30
31
/// Dialog for editing a name
32
class SVT_DLLPUBLIC SvxNameDialog final : public weld::GenericDialogController
33
{
34
private:
35
    std::unique_ptr<weld::Entry> m_xEdtName;
36
    std::unique_ptr<weld::Label> m_xFtDescription;
37
    std::unique_ptr<weld::Button> m_xBtnOK;
38
    std::function<bool(const OUString&)> m_aCheckName;
39
40
    Link<SvxNameDialog&, bool> m_aCheckNameHdl;
41
    Link<SvxNameDialog&, OUString> m_aCheckNameTooltipHdl;
42
43
    DECL_LINK(ModifyHdl, weld::Entry&, void);
44
45
public:
46
    SvxNameDialog(weld::Window* pWindow, const OUString& rName, const OUString& rDesc,
47
                  const OUString& rTitle = u""_ustr);
48
49
0
    OUString GetName() const { return m_xEdtName->get_text(); }
50
51
0
    void SetCheckName(const std::function<bool(const OUString&)>& rFunc) { m_aCheckName = rFunc; }
52
53
    /** add a callback Link that is called whenever the content of the edit
54
        field is changed.  The Link result determines whether the OK
55
        Button is enabled (> 0) or disabled (== 0).
56
57
        @param rLink a Callback declared with DECL_DLLPRIVATE_LINK and implemented with
58
               IMPL_LINK, that is executed on modification.
59
     */
60
    void SetCheckNameHdl(const Link<SvxNameDialog&, bool>& rLink)
61
0
    {
62
0
        m_aCheckNameHdl = rLink;
63
0
        ModifyHdl(*m_xEdtName);
64
0
    }
65
66
    void SetCheckNameTooltipHdl(const Link<SvxNameDialog&, OUString>& rLink)
67
0
    {
68
0
        m_aCheckNameTooltipHdl = rLink;
69
0
        m_xBtnOK->set_tooltip_text(rLink.Call(*this));
70
0
    }
71
72
    void SetNameText(const OUString& aName)
73
0
    {
74
0
        m_xEdtName->set_text(aName);
75
0
        m_xEdtName->set_position(-1);
76
0
    }
77
78
0
    void SetEditHelpId(const OUString& aHelpId) { m_xEdtName->set_help_id(aHelpId); }
79
};
80
81
/// Dialog for editing a number
82
class SVT_DLLPUBLIC SvxNumberDialog final : public weld::GenericDialogController
83
{
84
private:
85
    std::unique_ptr<weld::SpinButton> m_xEdtNumber;
86
    std::unique_ptr<weld::Label> m_xFtDescription;
87
88
public:
89
    SvxNumberDialog(weld::Window* pWindow, const OUString& rDesc, sal_Int64 nValue, sal_Int64 nMin,
90
                    sal_Int64 nMax);
91
92
0
    sal_Int64 GetNumber() const { return m_xEdtNumber->get_value(); }
93
};
94
95
class SVT_DLLPUBLIC SvxDecimalNumberDialog final : public weld::GenericDialogController
96
{
97
private:
98
    std::unique_ptr<weld::FormattedSpinButton> m_xEdtNumber;
99
    std::unique_ptr<weld::Label> m_xFtDescription;
100
101
public:
102
    SvxDecimalNumberDialog(weld::Window* pWindow, const OUString& rDesc, double fValue);
103
104
0
    double GetNumber() const { return m_xEdtNumber->GetFormatter().GetValue(); }
105
};
106
107
/** #i68101#
108
    Dialog for editing Object name
109
    plus uniqueness-callback-linkHandler */
110
class SVT_DLLPUBLIC SvxObjectNameDialog final : public weld::GenericDialogController
111
{
112
private:
113
    // name
114
    std::unique_ptr<weld::Entry> m_xEdtName;
115
116
    // buttons
117
    std::unique_ptr<weld::Button> m_xBtnOK;
118
119
    // callback link for name uniqueness
120
    Link<SvxObjectNameDialog&, bool> aCheckNameHdl;
121
122
    DECL_LINK(ModifyHdl, weld::Entry&, void);
123
124
public:
125
    // constructor
126
    SvxObjectNameDialog(weld::Window* pWindow, const OUString& rName);
127
128
    // data access
129
0
    OUString GetName() const { return m_xEdtName->get_text(); }
130
131
    // set handler
132
0
    void SetCheckNameHdl(const Link<SvxObjectNameDialog&, bool>& rLink) { aCheckNameHdl = rLink; }
133
};
134
135
/** #i68101#
136
    Dialog for editing Object Title and Description */
137
class SVT_DLLPUBLIC SvxObjectTitleDescDialog final : public weld::GenericDialogController
138
{
139
private:
140
    // title
141
    std::unique_ptr<weld::Label> m_xTitleFT;
142
    std::unique_ptr<weld::Entry> m_xEdtTitle;
143
144
    // description
145
    std::unique_ptr<weld::Label> m_xDescriptionFT;
146
    std::unique_ptr<weld::TextView> m_xEdtDescription;
147
148
    std::unique_ptr<weld::CheckButton> m_xDecorativeCB;
149
150
    DECL_LINK(DecorativeHdl, weld::Toggleable&, void);
151
152
public:
153
    // constructor
154
    SvxObjectTitleDescDialog(weld::Window* pWindow, const OUString& rTitle, const OUString& rDesc,
155
                             bool isDecorative);
156
    // data access
157
0
    OUString GetTitle() const { return m_xEdtTitle->get_text(); }
158
0
    OUString GetDescription() const { return m_xEdtDescription->get_text(); }
159
0
    bool IsDecorative() const { return m_xDecorativeCB->get_active(); }
160
};
161
162
enum class ListMode
163
{
164
    String,
165
    Int64,
166
    Int32,
167
    Int16,
168
    Double
169
};
170
171
/** Generic dialog to edit lists */
172
class SVT_DLLPUBLIC SvxListDialog : public weld::GenericDialogController
173
{
174
private:
175
    ListMode m_aMode;
176
    std::unique_ptr<weld::TreeView> m_xList;
177
    std::unique_ptr<weld::Button> m_xAddBtn;
178
    std::unique_ptr<weld::Button> m_xRemoveBtn;
179
    std::unique_ptr<weld::Button> m_xEditBtn;
180
181
    DECL_LINK(SelectHdl_Impl, weld::TreeView&, void);
182
    DECL_LINK(DblClickHdl_Impl, weld::TreeView&, bool);
183
    DECL_LINK(AddHdl_Impl, weld::Button&, void);
184
    DECL_LINK(RemoveHdl_Impl, weld::Button&, void);
185
    DECL_LINK(EditHdl_Impl, weld::Button&, void);
186
187
    void SelectionChanged();
188
189
public:
190
    explicit SvxListDialog(weld::Window* pParent);
191
    virtual ~SvxListDialog() override;
192
193
    std::vector<OUString> GetEntries();
194
    void SetEntries(std::vector<OUString> const& rParams);
195
    void EditEntry();
196
    void SetMode(ListMode aMode);
197
};
198
199
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */