Branch data Line data Source code
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 : :
21 : : #include "adminpages.hxx"
22 : : #include "DbAdminImpl.hxx"
23 : : #include "dbu_dlg.hrc"
24 : : #include "DriverSettings.hxx"
25 : : #include "dsitems.hxx"
26 : : #include "propertysetitem.hxx"
27 : : #include "UITools.hxx"
28 : : #include "UserAdmin.hxx"
29 : : #include "UserAdminDlg.hrc"
30 : : #include "UserAdminDlg.hxx"
31 : :
32 : : #include <comphelper/componentcontext.hxx>
33 : : #include <connectivity/dbmetadata.hxx>
34 : : #include <cppuhelper/exc_hlp.hxx>
35 : : #include <svl/eitem.hxx>
36 : : #include <svl/intitem.hxx>
37 : : #include <svl/stritem.hxx>
38 : : #include <tools/diagnose_ex.h>
39 : : #include <vcl/msgbox.hxx>
40 : : #include <vcl/stdtext.hxx>
41 : :
42 : : //.........................................................................
43 : : namespace dbaui
44 : : {
45 : : //.........................................................................
46 : : using namespace ::com::sun::star::uno;
47 : : using namespace ::com::sun::star::beans;
48 : : using namespace ::com::sun::star::lang;
49 : : using namespace ::com::sun::star::sdbc;
50 : : using namespace ::com::sun::star::sdbcx;
51 : :
52 : : //========================================================================
53 : : //= OUserAdminDlg
54 : : DBG_NAME(OUserAdminDlg)
55 : : //========================================================================
56 : 0 : OUserAdminDlg::OUserAdminDlg(Window* _pParent
57 : : , SfxItemSet* _pItems
58 : : ,const Reference< XMultiServiceFactory >& _rxORB
59 : : ,const ::com::sun::star::uno::Any& _aDataSourceName
60 : : ,const Reference< XConnection >& _xConnection)
61 : : :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_USERADMIN), _pItems)
62 : : ,m_pItemSet(_pItems)
63 : : ,m_xConnection(_xConnection)
64 [ # # ][ # # ]: 0 : ,m_bOwnConnection(!_xConnection.is())
[ # # ]
65 : : {
66 : : DBG_CTOR(OUserAdminDlg,NULL);
67 : :
68 [ # # ][ # # ]: 0 : m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,_pParent,this));
[ # # ]
69 [ # # ]: 0 : m_pImpl->setDataSourceOrName(_aDataSourceName);
70 [ # # ]: 0 : Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
71 [ # # ]: 0 : m_pImpl->translateProperties(xDatasource, *_pItems);
72 [ # # ]: 0 : SetInputSet(_pItems);
73 : : // propagate this set as our new input set and reset the example set
74 [ # # ][ # # ]: 0 : delete pExampleSet;
75 [ # # ][ # # ]: 0 : pExampleSet = new SfxItemSet(*GetInputSetImpl());
[ # # ]
76 : :
77 [ # # ][ # # ]: 0 : AddTabPage(TAB_PAGE_USERADMIN, String(ModuleRes(STR_PAGETITLE_USERADMIN)), OUserAdmin::Create,0, sal_False, 1);
[ # # ][ # # ]
78 : :
79 : : // remove the reset button - it's meaning is much too ambiguous in this dialog
80 [ # # ]: 0 : RemoveResetButton();
81 [ # # ]: 0 : FreeResource();
82 : 0 : }
83 : :
84 : : // -----------------------------------------------------------------------
85 [ # # ][ # # ]: 0 : OUserAdminDlg::~OUserAdminDlg()
[ # # ]
86 : : {
87 [ # # ]: 0 : if ( m_bOwnConnection )
88 : : {
89 : : try
90 : : {
91 [ # # ]: 0 : ::comphelper::disposeComponent(m_xConnection);
92 : : }
93 [ # # ]: 0 : catch(const Exception&)
94 : : {
95 : : }
96 : : }
97 : :
98 [ # # ]: 0 : SetInputSet(NULL);
99 [ # # ][ # # ]: 0 : DELETEZ(pExampleSet);
100 : :
101 : : DBG_DTOR(OUserAdminDlg,NULL);
102 [ # # ][ # # ]: 0 : }
103 : : // -----------------------------------------------------------------------
104 : 0 : short OUserAdminDlg::Execute()
105 : : {
106 : : try
107 : : {
108 [ # # ][ # # ]: 0 : ::dbtools::DatabaseMetaData aMetaData( createConnection().first );
[ # # ]
109 [ # # ][ # # ]: 0 : if ( !aMetaData.supportsUserAdministration( ::comphelper::ComponentContext( getORB() ) ) )
[ # # ][ # # ]
[ # # ]
110 : : {
111 [ # # ][ # # ]: 0 : String sError(ModuleRes(STR_USERADMIN_NOT_AVAILABLE));
112 [ # # ][ # # ]: 0 : throw SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
[ # # ][ # # ]
113 [ # # ]: 0 : }
114 : : }
115 [ # # # ]: 0 : catch(const SQLException&)
116 : : {
117 [ # # # # : 0 : ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), GetParent(), getORB() );
# # # # #
# # # ]
118 : 0 : return RET_CANCEL;
119 : : }
120 : 0 : catch(const Exception&)
121 : : {
122 : : DBG_UNHANDLED_EXCEPTION();
123 : : }
124 : 0 : short nRet = SfxTabDialog::Execute();
125 [ # # ]: 0 : if ( nRet == RET_OK )
126 : 0 : m_pImpl->saveChanges(*GetOutputItemSet());
127 : 0 : return nRet;
128 : : }
129 : : //-------------------------------------------------------------------------
130 : 0 : void OUserAdminDlg::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage)
131 : : {
132 : : // register ourself as modified listener
133 [ # # ]: 0 : static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB());
134 : 0 : static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
135 : :
136 : 0 : AdjustLayout();
137 : 0 : Window *pWin = GetViewWindow();
138 [ # # ]: 0 : if(pWin)
139 : 0 : pWin->Invalidate();
140 : :
141 : 0 : SfxTabDialog::PageCreated(_nId, _rPage);
142 : 0 : }
143 : : // -----------------------------------------------------------------------------
144 : 0 : const SfxItemSet* OUserAdminDlg::getOutputSet() const
145 : : {
146 : 0 : return m_pItemSet;
147 : : }
148 : : // -----------------------------------------------------------------------------
149 : 0 : SfxItemSet* OUserAdminDlg::getWriteOutputSet()
150 : : {
151 : 0 : return m_pItemSet;
152 : : }
153 : : // -----------------------------------------------------------------------------
154 : 0 : ::std::pair< Reference<XConnection>,sal_Bool> OUserAdminDlg::createConnection()
155 : : {
156 [ # # ]: 0 : if ( !m_xConnection.is() )
157 : : {
158 [ # # ]: 0 : m_xConnection = m_pImpl->createConnection().first;
159 : 0 : m_bOwnConnection = m_xConnection.is();
160 : : }
161 [ # # ]: 0 : return ::std::pair< Reference<XConnection>,sal_Bool> (m_xConnection,sal_False);
162 : : }
163 : : // -----------------------------------------------------------------------------
164 : 0 : Reference< XMultiServiceFactory > OUserAdminDlg::getORB() const
165 : : {
166 : 0 : return m_pImpl->getORB();
167 : : }
168 : : // -----------------------------------------------------------------------------
169 : 0 : Reference< XDriver > OUserAdminDlg::getDriver()
170 : : {
171 : 0 : return m_pImpl->getDriver();
172 : : }
173 : : // -----------------------------------------------------------------------------
174 : 0 : ::rtl::OUString OUserAdminDlg::getDatasourceType(const SfxItemSet& _rSet) const
175 : : {
176 : 0 : return m_pImpl->getDatasourceType(_rSet);
177 : : }
178 : : // -----------------------------------------------------------------------------
179 : 0 : void OUserAdminDlg::clearPassword()
180 : : {
181 : 0 : m_pImpl->clearPassword();
182 : 0 : }
183 : : // -----------------------------------------------------------------------------
184 : 0 : void OUserAdminDlg::setTitle(const ::rtl::OUString& _sTitle)
185 : : {
186 [ # # ]: 0 : SetText(_sTitle);
187 : 0 : }
188 : : //-------------------------------------------------------------------------
189 : 0 : void OUserAdminDlg::enableConfirmSettings( bool _bEnable )
190 : : {
191 : : (void)_bEnable;
192 : 0 : }
193 : : //-------------------------------------------------------------------------
194 : 0 : sal_Bool OUserAdminDlg::saveDatasource()
195 : : {
196 : 0 : return PrepareLeaveCurrentPage();
197 : : }
198 : : //.........................................................................
199 : : } // namespace dbaui
200 : : //.........................................................................
201 : :
202 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|