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_CUI_SOURCE_INC_DLGNAME_HXX
20 #define INCLUDED_CUI_SOURCE_INC_DLGNAME_HXX
21 
22 #include <vcl/weld.hxx>
23 
24 /// Dialog for editing a name
25 class SvxNameDialog : public weld::GenericDialogController
26 {
27 private:
28     std::unique_ptr<weld::Entry> m_xEdtName;
29     std::unique_ptr<weld::Label> m_xFtDescription;
30     std::unique_ptr<weld::Button> m_xBtnOK;
31 
32     Link<SvxNameDialog&,bool> m_aCheckNameHdl;
33 
34     DECL_LINK(ModifyHdl, weld::Entry&, void);
35 
36 public:
37     SvxNameDialog(weld::Window* pWindow, const OUString& rName, const OUString& rDesc);
38 
GetName() const39     OUString GetName() const { return m_xEdtName->get_text(); }
40 
41     /** add a callback Link that is called whenever the content of the edit
42         field is changed.  The Link result determines whether the OK
43         Button is enabled (> 0) or disabled (== 0).
44 
45         @param rLink a Callback declared with DECL_LINK and implemented with
46                IMPL_LINK, that is executed on modification.
47 
48         @param bCheckImmediately If true, the Link is called directly after
49                setting it. It is recommended to set this flag to true to avoid
50                an inconsistent state if the initial String (given in the CTOR)
51                does not satisfy the check condition.
52 
53         @todo Remove the parameter bCheckImmediately and incorporate the 'true'
54               behaviour as default.
55      */
SetCheckNameHdl(const Link<SvxNameDialog &,bool> & rLink,bool bCheckImmediately)56     void SetCheckNameHdl(const Link<SvxNameDialog&,bool>& rLink, bool bCheckImmediately)
57     {
58         m_aCheckNameHdl = rLink;
59         if (bCheckImmediately)
60             m_xBtnOK->set_sensitive(rLink.Call(*this));
61     }
62 
SetEditHelpId(const OString & aHelpId)63     void SetEditHelpId(const OString& aHelpId) { m_xEdtName->set_help_id(aHelpId);}
64 };
65 
66 /** #i68101#
67     Dialog for editing Object name
68     plus uniqueness-callback-linkHandler */
69 class SvxObjectNameDialog : public weld::GenericDialogController
70 {
71 private:
72     // name
73     std::unique_ptr<weld::Entry> m_xEdtName;
74 
75     // buttons
76     std::unique_ptr<weld::Button> m_xBtnOK;
77 
78     // callback link for name uniqueness
79     Link<SvxObjectNameDialog&,bool> aCheckNameHdl;
80 
81     DECL_LINK(ModifyHdl, weld::Entry&, void);
82 
83 public:
84     // constructor
85     SvxObjectNameDialog(weld::Window* pWindow, const OUString& rName);
86 
87     // data access
GetName() const88     OUString GetName() const { return m_xEdtName->get_text(); }
89 
90     // set handler
SetCheckNameHdl(const Link<SvxObjectNameDialog &,bool> & rLink)91     void SetCheckNameHdl(const Link<SvxObjectNameDialog&,bool>& rLink)
92     {
93         aCheckNameHdl = rLink;
94     }
95 };
96 
97 /** #i68101#
98     Dialog for editing Object Title and Description */
99 class SvxObjectTitleDescDialog : public weld::GenericDialogController
100 {
101 private:
102     // title
103     std::unique_ptr<weld::Entry> m_xEdtTitle;
104 
105     // description
106     std::unique_ptr<weld::TextView> m_xEdtDescription;
107 
108 public:
109     // constructor
110     SvxObjectTitleDescDialog(weld::Window* pWindow, const OUString& rTitle, const OUString& rDesc);
111     // data access
GetTitle() const112     OUString GetTitle() const { return m_xEdtTitle->get_text(); }
GetDescription() const113     OUString GetDescription() const { return m_xEdtDescription->get_text(); }
114 };
115 
116 #endif // INCLUDED_CUI_SOURCE_INC_DLGNAME_HXX
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
119