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 
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_DLG_DETAILPAGES_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_DLG_DETAILPAGES_HXX
22 
23 #include "adminpages.hxx"
24 #include <charsets.hxx>
25 #include <charsetlistbox.hxx>
26 #include "TextConnectionHelper.hxx"
27 #include "admincontrols.hxx"
28 
29 #include <o3tl/typed_flags_set.hxx>
30 
31 enum class OCommonBehaviourTabPageFlags {
32     NONE        = 0x0000,
33     UseCharset  = 0x0002,
34     UseOptions  = 0x0004,
35 };
36 namespace o3tl {
37     template<> struct typed_flags<OCommonBehaviourTabPageFlags> : is_typed_flags<OCommonBehaviourTabPageFlags, 0x0006> {};
38 }
39 
40 namespace dbaui
41 {
42     /** eases the implementation of tab pages handling user/password and/or character
43         set and/or generic options input
44         <BR>
45         The controls to be used have to be defined within the resource, as usual, but
46         this class does all the handling necessary.
47     */
48     class OCommonBehaviourTabPage : public OGenericAdministrationPage
49     {
50         OCommonBehaviourTabPageFlags m_nControlFlags;
51 
52         std::unique_ptr<weld::Label> m_xOptionsLabel;
53         std::unique_ptr<weld::Entry> m_xOptions;
54 
55         std::unique_ptr<weld::Label> m_xDataConvertLabel;
56         std::unique_ptr<weld::Label> m_xCharsetLabel;
57         std::unique_ptr<CharSetListBox> m_xCharset;
58 
59         std::unique_ptr<weld::CheckButton> m_xAutoRetrievingEnabled;
60         std::unique_ptr<weld::Label> m_xAutoIncrementLabel;
61         std::unique_ptr<weld::Entry> m_xAutoIncrement;
62         std::unique_ptr<weld::Label> m_xAutoRetrievingLabel;
63         std::unique_ptr<weld::Entry> m_xAutoRetrieving;
64 
65     public:
66         virtual bool        FillItemSet (SfxItemSet* _rCoreAttrs) override;
67 
68         OCommonBehaviourTabPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rId, const SfxItemSet& _rCoreAttrs, OCommonBehaviourTabPageFlags nControlFlags);
69     protected:
70 
71         virtual ~OCommonBehaviourTabPage() override;
72 
73         // subclasses must override this, but it isn't pure virtual
74         virtual void        implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
75 
76         // <method>OGenericAdministrationPage::fillControls</method>
77         virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
78 
79         // <method>OGenericAdministrationPage::fillWindows</method>
80         virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
81     private:
82         DECL_LINK(CharsetSelectHdl, weld::ComboBox&, void);
83     };
84 
85 
86     // ODbaseDetailsPage
87     class ODbaseDetailsPage : public OCommonBehaviourTabPage
88     {
89     public:
90         virtual bool        FillItemSet ( SfxItemSet* _rCoreAttrs ) override;
91 
92         ODbaseDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rCoreAttrs);
93         virtual ~ODbaseDetailsPage() override;
94     private:
95         OUString            m_sDsn;
96 
97         std::unique_ptr<weld::CheckButton> m_xShowDeleted;
98         std::unique_ptr<weld::Label> m_xFT_Message;
99         std::unique_ptr<weld::Button> m_xIndexes;
100 
101     protected:
102         virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
103 
104     private:
105         DECL_LINK(OnButtonClicked, weld::Button&, void);
106     };
107 
108     // OAdoDetailsPage
109     class OAdoDetailsPage : public OCommonBehaviourTabPage
110     {
111     public:
112         OAdoDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
113     };
114 
115     // OOdbcDetailsPage
116     class OOdbcDetailsPage : public OCommonBehaviourTabPage
117     {
118     public:
119         virtual bool        FillItemSet ( SfxItemSet* _rCoreAttrs ) override;
120 
121         OOdbcDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
122         virtual ~OOdbcDetailsPage() override;
123     protected:
124         virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
125     private:
126         std::unique_ptr<weld::CheckButton> m_xUseCatalog;
127     };
128 
129     // OUserDriverDetailsPage
130     class OUserDriverDetailsPage : public OCommonBehaviourTabPage
131     {
132     public:
133         virtual bool        FillItemSet ( SfxItemSet* _rCoreAttrs ) override;
134 
135         OUserDriverDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rCoreAttrs);
136         virtual ~OUserDriverDetailsPage() override;
137     protected:
138         virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
139         virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
140         virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
141     private:
142         std::unique_ptr<weld::Label> m_xFTHostname;
143         std::unique_ptr<weld::Entry> m_xEDHostname;
144         std::unique_ptr<weld::Label> m_xPortNumber;
145         std::unique_ptr<weld::SpinButton> m_xNFPortNumber;
146         std::unique_ptr<weld::CheckButton> m_xUseCatalog;
147     };
148 
149     // OMySQLODBCDetailsPage
150     class OMySQLODBCDetailsPage : public OCommonBehaviourTabPage
151     {
152     public:
153         OMySQLODBCDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
154     };
155 
156     // OGeneralSpecialJDBCDetailsPage
157     class OGeneralSpecialJDBCDetailsPage final : public OCommonBehaviourTabPage
158     {
159     public:
160         OGeneralSpecialJDBCDetailsPage(weld::Container* pPage, weld::DialogController* pController,
161                                        const SfxItemSet& _rCoreAttrs,
162                                        sal_uInt16 _nPortId,
163                                        bool bShowSocket = true);
164         virtual ~OGeneralSpecialJDBCDetailsPage() override;
165 
166     private:
167 
168         virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) override;
169         virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
170         virtual void callModifiedHdl(weld::Widget* pControl = nullptr) override;
171 
172         DECL_LINK(OnTestJavaClickHdl, weld::Button&, void);
173 
174         OUString                   m_sDefaultJdbcDriverName;
175         sal_uInt16                 m_nPortId;
176         bool                       m_bUseClass;
177 
178         std::unique_ptr<weld::Entry> m_xEDHostname;
179         std::unique_ptr<weld::SpinButton> m_xNFPortNumber;
180         std::unique_ptr<weld::Label> m_xFTSocket;
181         std::unique_ptr<weld::Entry> m_xEDSocket;
182         std::unique_ptr<weld::Label> m_xFTDriverClass;
183         std::unique_ptr<weld::Entry> m_xEDDriverClass;
184         std::unique_ptr<weld::Button> m_xTestJavaDriver;
185     };
186 
187     // MySQLNativePage
188     class MySQLNativePage : public OCommonBehaviourTabPage
189     {
190     public:
191         MySQLNativePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
192         virtual ~MySQLNativePage() override;
193 
194     private:
195         std::unique_ptr<weld::Widget> m_xMySQLSettingsContainer;
196         std::unique_ptr<MySQLNativeSettings> m_xMySQLSettings;
197         std::unique_ptr<weld::Label> m_xSeparator1;
198         std::unique_ptr<weld::Label> m_xSeparator2;
199         std::unique_ptr<weld::Label> m_xUserNameLabel;
200         std::unique_ptr<weld::Entry> m_xUserName;
201         std::unique_ptr<weld::CheckButton> m_xPasswordRequired;
202 
203     protected:
204         virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) override;
205         virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
206         virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
207         virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
208     };
209 
210     // OOdbcDetailsPage
211     class OLDAPDetailsPage : public OCommonBehaviourTabPage
212     {
213     public:
214         virtual bool        FillItemSet ( SfxItemSet* _rCoreAttrs ) override;
215 
216         OLDAPDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
217         virtual ~OLDAPDetailsPage() override;
218     protected:
219         virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
220     private:
221         sal_Int32 m_iSSLPort;
222         sal_Int32 m_iNormalPort;
223 
224         std::unique_ptr<weld::Entry> m_xETBaseDN;
225         std::unique_ptr<weld::CheckButton> m_xCBUseSSL;
226         std::unique_ptr<weld::SpinButton> m_xNFPortNumber;
227         std::unique_ptr<weld::SpinButton> m_xNFRowCount;
228 
229         DECL_LINK(OnCheckBoxClick, weld::ToggleButton&, void);
230     };
231 
232     // OTextDetailsPage
233     class OTextDetailsPage : public OCommonBehaviourTabPage
234     {
235     public:
236         virtual bool        FillItemSet ( SfxItemSet* _rCoreAttrs ) override;
237 
238         OTextDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
239         virtual ~OTextDetailsPage() override;
240 
241     protected:
242         virtual bool prepareLeave() override;
243 
244         virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
245         virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
246         virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
247 
248     private:
249         std::unique_ptr<OTextConnectionHelper> m_xTextConnectionHelper;
250     };
251 
252 }   // namespace dbaui
253 
254 #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_DETAILPAGES_HXX
255 
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
257