Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/include/vcl/abstdlg.hxx
Line
Count
Source (jump to first uncovered line)
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
#ifndef INCLUDED_VCL_ABSTDLG_HXX
20
#define INCLUDED_VCL_ABSTDLG_HXX
21
22
#include <sal/types.h>
23
#include <rtl/ustring.hxx>
24
#include <tools/color.hxx>
25
#include <vcl/ColorDialog.hxx>
26
#include <vcl/dllapi.h>
27
#include <vcl/vclptr.hxx>
28
#include <vcl/vclreferencebase.hxx>
29
#include <vector>
30
#include <functional>
31
#include <memory>
32
33
namespace com::sun::star::uno { template <class interface_type> class Reference; }
34
35
namespace com::sun::star::frame { class XModel; }
36
37
class BitmapEx;
38
class SdrObjGroup;
39
namespace weld
40
{
41
    class Dialog;
42
    class DialogController;
43
    class Window;
44
}
45
46
/**
47
* Some things multiple-inherit from VclAbstractDialog and OutputDevice,
48
* so we need to use virtual inheritance to keep the referencing counting
49
* OK.
50
*/
51
class VCL_DLLPUBLIC VclAbstractDialog : public virtual VclReferenceBase
52
{
53
protected:
54
    virtual             ~VclAbstractDialog() override;
55
public:
56
    virtual short       Execute() = 0;
57
58
    struct AsyncContext {
59
        // for the case where the owner is the dialog itself, and the dialog is an unwelded VclPtr based dialog
60
        VclPtr<VclReferenceBase> mxOwner;
61
        // for the case where the dialog is welded, and owned by a DialogController
62
        std::shared_ptr<weld::DialogController> mxOwnerDialogController;
63
        // for the case where the dialog is welded, and is running async without a DialogController
64
        std::shared_ptr<weld::Dialog> mxOwnerSelf;
65
        std::function<void(sal_Int32)> maEndDialogFn;
66
0
        bool isSet() const { return !!maEndDialogFn; }
67
    };
68
69
    /**
70
    * Usual codepath for modal dialogs. Some uno command decides to open a dialog,
71
      we call StartExecuteAsync() with a callback to handle the dialog result
72
      and that handler will be executed at some stage in the future,
73
      instead of right now.
74
    */
75
    bool StartExecuteAsync(const std::function<void(sal_Int32)> &rEndDialogFn)
76
0
    {
77
0
        AsyncContext aCtx;
78
0
        aCtx.mxOwner = this;
79
0
        aCtx.maEndDialogFn = rEndDialogFn;
80
0
        return StartExecuteAsync(aCtx);
81
0
    }
82
83
    /// Commence execution of a modal dialog.
84
    virtual bool StartExecuteAsync(AsyncContext &);
85
86
    // Screenshot interface
87
    virtual std::vector<OUString> getAllPageUIXMLDescriptions() const;
88
    virtual bool selectPageByUIXMLDescription(const OUString& rUIXMLDescription);
89
    virtual BitmapEx createScreenshot() const;
90
0
    virtual OUString GetScreenshotId() const { return {}; };
91
};
92
93
class VCL_DLLPUBLIC VclAbstractTerminatedDialog : public VclAbstractDialog
94
{
95
protected:
96
    virtual             ~VclAbstractTerminatedDialog() override = default;
97
public:
98
    virtual void        EndDialog(sal_Int32 nResult) = 0;
99
};
100
101
class AbstractColorPickerDialog : virtual public VclAbstractDialog
102
{
103
protected:
104
    virtual ~AbstractColorPickerDialog() override = default;
105
106
public:
107
    virtual void SetColor(const Color& rColor) = 0;
108
    virtual Color GetColor() const = 0;
109
};
110
111
class VCL_DLLPUBLIC AbstractPasswordToOpenModifyDialog : public VclAbstractDialog
112
{
113
protected:
114
    virtual             ~AbstractPasswordToOpenModifyDialog() override = default;
115
public:
116
    virtual OUString    GetPasswordToOpen() const   = 0;
117
    virtual OUString    GetPasswordToModify() const = 0;
118
    virtual bool        IsRecommendToOpenReadonly() const = 0;
119
    virtual void        Response(sal_Int32) = 0;
120
    virtual void        AllowEmpty() = 0;
121
};
122
123
class VCL_DLLPUBLIC AbstractSecurityOptionsDialog : public VclAbstractDialog
124
{
125
protected:
126
    virtual             ~AbstractSecurityOptionsDialog() override = default;
127
public:
128
    virtual bool        SetSecurityOptions() = 0;
129
};
130
131
class VCL_DLLPUBLIC AbstractScreenshotAnnotationDlg : public VclAbstractDialog
132
{
133
protected:
134
    virtual             ~AbstractScreenshotAnnotationDlg() override = default;
135
};
136
137
class VCL_DLLPUBLIC AbstractSignatureLineDialog : public VclAbstractDialog
138
{
139
protected:
140
    virtual ~AbstractSignatureLineDialog() override = default;
141
public:
142
    virtual void Apply() = 0;
143
};
144
145
class VCL_DLLPUBLIC AbstractSignSignatureLineDialog : public VclAbstractDialog
146
{
147
protected:
148
    virtual ~AbstractSignSignatureLineDialog() override = default;
149
public:
150
    virtual void Apply() = 0;
151
};
152
153
class VCL_DLLPUBLIC AbstractQrCodeGenDialog : public VclAbstractDialog
154
{
155
protected:
156
    virtual ~AbstractQrCodeGenDialog() override = default;
157
};
158
159
class VCL_DLLPUBLIC AbstractAdditionsDialog : public VclAbstractDialog
160
{
161
protected:
162
    virtual ~AbstractAdditionsDialog() override = default;
163
};
164
165
/** Edit Diagram dialog */
166
class VCL_DLLPUBLIC AbstractDiagramDialog : public VclAbstractDialog
167
{
168
protected:
169
    virtual ~AbstractDiagramDialog() override = default;
170
};
171
172
class VCL_DLLPUBLIC AbstractQueryDialog : public VclAbstractDialog
173
{
174
protected:
175
    virtual ~AbstractQueryDialog() override = default;
176
public:
177
    virtual bool ShowAgain() const = 0;
178
    virtual void SetYesLabel(const OUString& sLabel) = 0;
179
    virtual void SetNoLabel(const OUString& sLabel) = 0;
180
};
181
182
class VCL_DLLPUBLIC VclAbstractDialogFactory
183
{
184
public:
185
    virtual             ~VclAbstractDialogFactory();    // needed for export of vtable
186
    static VclAbstractDialogFactory* Create();
187
    // The Id is an implementation detail of the factory
188
    virtual VclPtr<VclAbstractDialog> CreateVclDialog(weld::Window* pParent, sal_uInt32 nId) = 0;
189
190
    virtual VclPtr<AbstractColorPickerDialog>
191
    CreateColorPickerDialog(weld::Window* pParent, Color nColor, vcl::ColorPickerMode eMode) = 0;
192
193
    // creates instance of PasswordToOpenModifyDialog from cui
194
    virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog(weld::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) = 0;
195
196
    // creates instance of SignatureDialog from cui
197
    virtual VclPtr<AbstractSignatureLineDialog>
198
    CreateSignatureLineDialog(weld::Window* pParent,
199
                              const css::uno::Reference<css::frame::XModel> xModel,
200
                              bool bEditExisting)
201
        = 0;
202
203
    // creates instance of SignSignatureDialog from cui
204
    virtual VclPtr<AbstractSignSignatureLineDialog>
205
    CreateSignSignatureLineDialog(weld::Window* pParent,
206
                                  const css::uno::Reference<css::frame::XModel> xModel)
207
        = 0;
208
209
    // creates instance of QrCodeDialog from cui
210
    virtual VclPtr<AbstractQrCodeGenDialog>
211
    CreateQrCodeGenDialog(weld::Window* pParent,
212
                              const css::uno::Reference<css::frame::XModel> xModel,
213
                              bool bEditExisting)
214
        = 0;
215
216
    // creates instance of ScreenshotAnnotationDlg from cui
217
    virtual VclPtr<AbstractScreenshotAnnotationDlg> CreateScreenshotAnnotationDlg(
218
        weld::Dialog& rParentDialog) = 0;
219
220
    // create additions dialog
221
    virtual VclPtr<AbstractAdditionsDialog>
222
        CreateAdditionsDialog(weld::Window* pParent, const OUString& sAdditionsTag) = 0;
223
224
    virtual VclPtr<AbstractDiagramDialog> CreateDiagramDialog(
225
        weld::Window* pParent,
226
        SdrObjGroup& rDiagram) = 0;
227
228
    virtual VclPtr<AbstractQueryDialog> CreateQueryDialog(
229
        weld::Window* pParent,
230
        const OUString& sTitle, const OUString& sText, const OUString& sQuestion,
231
        bool bShowAgain) = 0;
232
233
#ifdef _WIN32
234
    virtual VclPtr<VclAbstractDialog>
235
    CreateFileExtCheckDialog(weld::Window* _pParent, const OUString& sTitle, const OUString& sMsg)
236
        = 0;
237
#endif
238
};
239
240
#endif
241
242
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */