LibreOffice Module dbaccess (master) 1
adminpages.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <sfx2/tabdlg.hxx>
23#include <vcl/wizardmachine.hxx>
24#include <curledit.hxx>
25
26class SfxInt32Item;
27class SfxStringItem;
28
29namespace dbaui
30{
33 {
34 public:
35 virtual ~ISaveValueWrapper() = 0;
36 virtual void SaveValue() = 0;
37 virtual void Disable() = 0;
38 };
39
40 template < class T > class OSaveValueWidgetWrapper : public ISaveValueWrapper
41 {
43 public:
44 explicit OSaveValueWidgetWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
45 { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
46
47 virtual void SaveValue() override { m_pSaveValue->save_value(); }
48 virtual void Disable() override { m_pSaveValue->set_sensitive(false); }
49 };
50
51 template <> class OSaveValueWidgetWrapper<weld::Toggleable> : public ISaveValueWrapper
52 {
54 public:
55 explicit OSaveValueWidgetWrapper(weld::Toggleable* _pSaveValue) : m_pSaveValue(_pSaveValue)
56 { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
57
58 virtual void SaveValue() override { m_pSaveValue->save_state(); }
59 virtual void Disable() override { m_pSaveValue->set_sensitive(false); }
60 };
61
63 {
65 public:
67 { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
68
69 virtual void SaveValue() override { m_pSaveValue->save_value(); }
70 virtual void Disable() override { m_pSaveValue->set_sensitive(false); }
71 };
72
73 template <class T> class ODisableWidgetWrapper : public ISaveValueWrapper
74 {
76 public:
77 explicit ODisableWidgetWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
78 { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
79
80 virtual void SaveValue() override {}
81 virtual void Disable() override { m_pSaveValue->set_sensitive(false); }
82 };
83
84 // OGenericAdministrationPage
85 class IDatabaseSettingsDialog;
86 class IItemSetHelper;
88 ,public ::vcl::IWizardPageController
89 {
90 private:
93 protected:
96
97 css::uno::Reference< css::uno::XComponentContext >
99 public:
100 OGenericAdministrationPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OUString& rId, const SfxItemSet& rAttrSet);
103
111 {
112 OSL_ENSURE(_pDialog && _pItemSetHelper,"Values are NULL!");
113 m_pAdminDialog = _pDialog;
114 m_pItemSetHelper = _pItemSetHelper;
115 }
116
121 void SetServiceFactory(const css::uno::Reference< css::uno::XComponentContext >& rxORB)
122 {
123 m_xORB = rxORB;
124 }
125
135 bool getSelectedDataSource(OUString& _sReturn, OUString const & _sCurr);
136
137 // svt::IWizardPageController
138 virtual void initializePage() override;
139 virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) override;
140 virtual bool canAdvance() const override;
141
142 void SetRoadmapStateValue( bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; }
144
145 protected:
147 virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
149 virtual void Reset(const SfxItemSet* _rCoreAttrs) override;
151 virtual void ActivatePage(const SfxItemSet& _rSet) override;
152
153 // BuilderPage overridables
154 virtual void Activate() override;
155
156 protected:
157 virtual void callModifiedHdl(weld::Widget* /*pControl*/ = nullptr) { m_aModifiedHandler.Call(this); }
158
160 virtual bool prepareLeave() { return true; }
161
165 virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue);
166
168 static void getFlags(const SfxItemSet& _rSet, bool& _rValid, bool& _rReadonly);
169
175 virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) = 0;
176
182 virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) = 0;
183
184 public:
197 static void fillBool(SfxItemSet& _rSet, const weld::CheckButton* pCheckBox, sal_uInt16 _nID, bool bOptionalBool, bool& _bChangedSomething, bool _bRevertValue = false);
198
209 static void fillInt32(SfxItemSet& _rSet,const weld::SpinButton* pEdit,TypedWhichId<SfxInt32Item> _nID, bool& _bChangedSomething);
210
221 static void fillString(SfxItemSet& _rSet,const weld::Entry* pEdit, TypedWhichId<SfxStringItem> _nID, bool& _bChangedSomething);
222 static void fillString(SfxItemSet& _rSet,const dbaui::OConnectionURLEdit* pEdit, TypedWhichId<SfxStringItem> _nID, bool& _bChangedSomething);
223
224 protected:
228 DECL_LINK(OnControlModified, weld::Widget*, void);
229 DECL_LINK(OnControlEntryModifyHdl, weld::Entry&, void);
230 DECL_LINK(OnControlSpinButtonModifyHdl, weld::SpinButton&, void);
231 DECL_LINK(OnControlModifiedButtonClick, weld::Toggleable&, void);
232 DECL_LINK(OnTestConnectionButtonClickHdl, weld::Button&, void);
233 };
234} // namespace dbaui
235
236/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
helper class to wrap the savevalue and disable call
Definition: adminpages.hxx:33
virtual void Disable()=0
virtual void SaveValue()=0
virtual void Disable() override
Definition: adminpages.hxx:81
virtual void SaveValue() override
Definition: adminpages.hxx:80
ODisableWidgetWrapper(T *_pSaveValue)
Definition: adminpages.hxx:77
OGenericAdministrationPage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OUString &rId, const SfxItemSet &rAttrSet)
Definition: adminpages.cxx:51
virtual void fillWindows(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList)=0
will be called inside <method>implInitControls</method> to disable if necessary
DECL_LINK(OnTestConnectionButtonClickHdl, weld::Button &, void)
bool m_abEnableRoadmap
to be called if something on the page has been modified
Definition: adminpages.hxx:92
DECL_LINK(OnControlSpinButtonModifyHdl, weld::SpinButton &, void)
virtual void Activate() override
Definition: adminpages.cxx:80
static void getFlags(const SfxItemSet &_rSet, bool &_rValid, bool &_rReadonly)
analyze the invalid and the readonly flag which may be present in the set
Definition: adminpages.cxx:93
virtual void ActivatePage(const SfxItemSet &_rSet) override
default implementation: call implInitControls with the given item set and _bSaveValue = sal_True
Definition: adminpages.cxx:88
void SetAdminDialog(IDatabaseSettingsDialog *_pDialog, IItemSetHelper *_pItemSetHelper)
Sets the ParentDialog.
Definition: adminpages.hxx:110
virtual void Reset(const SfxItemSet *_rCoreAttrs) override
default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
Definition: adminpages.cxx:75
virtual void fillControls(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList)=0
will be called inside <method>implInitControls</method> to save the value if necessary
IDatabaseSettingsDialog * m_pAdminDialog
Definition: adminpages.hxx:94
virtual void initializePage() override
Definition: adminpages.cxx:176
void SetModifiedHandler(const Link< OGenericAdministrationPage const *, void > &_rHandler)
set a handler which gets called every time something on the page has been modified
Definition: adminpages.hxx:102
static void fillString(SfxItemSet &_rSet, const weld::Entry *pEdit, TypedWhichId< SfxStringItem > _nID, bool &_bChangedSomething)
fills the String value into the item set when the value changed.
Definition: adminpages.cxx:219
virtual bool prepareLeave()
called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_T...
Definition: adminpages.hxx:160
Link< OGenericAdministrationPage const *, void > m_aModifiedHandler
Definition: adminpages.hxx:91
void SetRoadmapStateValue(bool _bDoEnable)
Definition: adminpages.hxx:142
virtual bool canAdvance() const override
Definition: adminpages.cxx:186
DECL_LINK(OnControlEntryModifyHdl, weld::Entry &, void)
css::uno::Reference< css::uno::XComponentContext > m_xORB
Definition: adminpages.hxx:98
void SetServiceFactory(const css::uno::Reference< css::uno::XComponentContext > &rxORB)
Sets the ServiceFactory.
Definition: adminpages.hxx:121
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
default implementation: call FillItemSet, call prepareLeave,
Definition: adminpages.cxx:63
virtual void callModifiedHdl(weld::Widget *=nullptr)
Definition: adminpages.hxx:157
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override
Definition: adminpages.cxx:182
DECL_LINK(OnControlModifiedButtonClick, weld::Toggleable &, void)
bool getSelectedDataSource(OUString &_sReturn, OUString const &_sCurr)
opens a dialog filled with all data sources available for this type and returns the selected on.
Definition: adminpages.cxx:121
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue)
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
Definition: adminpages.cxx:150
DECL_LINK(OnControlModified, weld::Widget *, void)
This link be used for controls where the tabpage does not need to take any special action when the co...
static void fillBool(SfxItemSet &_rSet, const weld::CheckButton *pCheckBox, sal_uInt16 _nID, bool bOptionalBool, bool &_bChangedSomething, bool _bRevertValue=false)
fills the Boolean value into the item set when the value changed.
Definition: adminpages.cxx:190
static void fillInt32(SfxItemSet &_rSet, const weld::SpinButton *pEdit, TypedWhichId< SfxInt32Item > _nID, bool &_bChangedSomething)
fills the int value into the item set when the value changed.
Definition: adminpages.cxx:211
OSaveValueWidgetWrapper(dbaui::OConnectionURLEdit *_pSaveValue)
Definition: adminpages.hxx:66
OSaveValueWidgetWrapper(weld::Toggleable *_pSaveValue)
Definition: adminpages.hxx:55
virtual void Disable() override
Definition: adminpages.hxx:48
virtual void SaveValue() override
Definition: adminpages.hxx:47
OSaveValueWidgetWrapper(T *_pSaveValue)
Definition: adminpages.hxx:44
DeactivateRC
#define SAL_NO_VTABLE